|
Take a look at this snippet, it may give you an idea.
This is "under construction" code , not plug and pray!
I use it with strDevice = "USB".
There is a SetupDi API for getting "friendly name", somewhere in my messy code.
DWORD dwFlag = DIGCF_ALLCLASSES | DIGCF_PRESENT;
TRACE("\nSetupDiGetClassDevs %s ", strDevice);
HDEVINFO hDevInfo = SetupDiGetClassDevs(NULL,strDevice, NULL,dwFlag);
if( INVALID_HANDLE_VALUE == hDevInfo ) {
TRACE("\nINVALID_HANDLE_VALUE == hDevInfo ");
return false;
}
TRACE("\nFind all selected devices %s",strDevice);
SP_DEVINFO_DATA* pspDevInfoData =
(SP_DEVINFO_DATA*)HeapAlloc(GetProcessHeap(), 0, sizeof(SP_DEVINFO_DATA));
pspDevInfoData->cbSize = sizeof(SP_DEVINFO_DATA);
int i = 0;
DWORD DataT ;
DWORD nSize=0 ;
TCHAR buf[MAX_PATH];
while (SetupDiEnumDeviceInfo(hDevInfo,i,pspDevInfoData))
{
SetupDiGetDeviceInstanceId(hDevInfo, pspDevInfoData, buf, sizeof(buf), &nSize);
{
TRACE("\nFind LittelWire ");
CString strTest = buf;
// CString strResult = strTest.SpanIncluding("0C9F");
int iFoundIndex = strTest.Find(strDeviceID);
TRACE("\nCount %i Buffer %s",i, buf);
if(iFoundIndex > 0 )
{
TRACE("\nCount %i Buffer %s Device %s found", i, buf, strDeviceID);
return true;
}
}
i++;
}
TRACE("\nDevice %s not found", strDeviceID);
return false;
|
|
|
|
|
Hi,
i have a dialog box and a picture control on that dialog box in mfc. I want to create a button on the right of the screen (similar to "Feedback" button seen on various sites). I created a button and positioned it on the right of the screen, but when clicked on any other control of the dialog box, the button hides under the picture control canvas.
Anybody have any idea.?
Any help will be appreciated.
Regards,
Mbatra
|
|
|
|
|
It sounds like the picture is being redrawn so it will obviously cover the button. Try positioning the button somewhere else.
|
|
|
|
|
Hi,
Thanx for the reply.
I have to show the buttons at the right of the screen. Similar to "Feedback" button we normally see on various sites.
I have one doubt, My computer screen size is larger compared to some others. So I want to ask should I use the GetWindowRect() OR GetClientRect() function to compute the size of the screen, because if I do it according to my screen size and position the buttons at the right of the screen, For a computer with smaller screen size, it will not be properly visible.
Regards,
Mbatra
|
|
|
|
|
mbatra31 wrote: For a computer with smaller screen size, it will not be properly visible. That's rather obvious. You should always check the Window, Client or Screen size depending on where you want your controls positioned.
|
|
|
|
|
Hi,
Its done..! Issue was with the positioning only.
Thanx for the help.
Regards,
Mbatra
|
|
|
|
|
From what Richard replied, and re-reading your message, I guess you have a button, and a picture control on your dialog, and they overlap.
What you need is a button which shows its own picture. You can attach an icon to the button from the resource editor, or you can use one of the many picture button controls available here:
http://www.codeproject.com/KB/buttons/[^]
Iain.
I am one of "those foreigners coming over here and stealing our jobs". Yay me!
|
|
|
|
|
Hi Iain,
I have a button and a bitmap. I am using CSkinButton class to set normal & hover state bitmaps on the button. I want to position the button on the right of the screen (similar to "feedback" button we normally see on various websites.) Now my computer screen size is larger, So when I position the buttons on the right side according to my computer screen size, its ok , but if I use this exe on some other computer which has a smaller screen size, button are not visible properly.
I want to place the buttons in the middle-right of the screen.
Regards,
Mbatra
|
|
|
|
|
Just position it somewhere where the controls don't overlap. You can have overlapping controls but it's really not worth the hassle. By the way, you can always get the size and position of your other control and do some math to figure out the proper placement of the button under it (if you're creating the controls at run-time).
|
|
|
|
|
I find that if the UI thread is block. it will be blocked when call CListCtrl::GetItemCount().
I want to know how the MFC low level to achieve this function?
If I use the MsgWaitForMultiObjects to block UI thread. How to set the QS_ALLINPUTS?
|
|
|
|
|
I'm not sure if I understand you correctly.
But you can see how wait functions work here - Halt! Who Goes There?[^]
|
|
|
|
|
Low level of MFC is the Win32 API. Open the context menu by right clicking on a call to CListCtrl::GetItemCount() and choose 'Go to definition'. You will see that it is an inline function that sends the LVM_GETITEMCOUNT message to the list control window. This message is not processed while your GUI thread is blocked.
A general rule is: Never block GUI threads. If you have to wait for events, do this in worker threads.
|
|
|
|
|
Hi Jochen Arndt,
You are very nice. But why I cannot see the source code of CListCtrl::GetItemCount()?
My develop tools is visual studio 2008.
|
|
|
|
|
I don't know why. You may also place the cursor on the call and press F12. With VS 2003 here, the MFC CListCtrl::GetItemCount() code is located in the VC subdirectory atlmfc\include\afxcmn.inl.
I suggested to look on the MFC sources so that you can see that most functions will only (or besides other tasks) just send messages.
If you don't have used the 'Go to definition' feature so far, give it a try. It is very useful. Not only for MFC functions, but also for your own ones to quickly see the source.
|
|
|
|
|
Thank you Jochen Arndt
I search the visual studio installed folder, and then find this file. It's greatly thing to see the MFC controls source.
|
|
|
|
|
plz i want a code that detect if an image is RGB or not ![Smile | :)](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
|
Hi All,
Can any one help me out to work on zlib compression.
Thanks in advance!
|
|
|
|
|
Start here[^], and study the documentation.
|
|
|
|
|
This question is both vague and applicable to that very specific library. Why don't you read the manual and come back with more specific questions?
|
|
|
|
|
hi every one ...
i have written com dll i want to debug the dll i dont how to do it .
please reply
Best Regards
sarfaraz
|
|
|
|
|
hi every one ...
i have written com dll i want to debug the dll i dont how to do it .
please reply
Best Regards
sarfaraz
|
|
|
|
|
1) Write a exe program that uses your COM.
2) Launch the exe.
3) Open your COM Project is Visual Studio
4) Attach the already running exe with the Project.
5) Keep the break points and start debugging it.
|
|
|
|
|
see am not able to understand the 4th step.
attach in the sense by changing the configuration properties in that debugging and then
command and passing the path of the exe. if this the way then its control not coming to break point or i may be wrong to the exe ....
Best Regards
Sarfaraz
|
|
|
|
|
You can debug your code by loading the DLL directly into your application rather than using it in registered mode: see the CoLoadLibrary function[^].
|
|
|
|