|
Dear All,
Good day. I have problem with the code below (which I used to get the directory path in the address bar of explorer.exe):
<small>
TCHAR lpString[1024] = _T("");
if ((strcmp(c, "ExploreWClass") == 0) || strcmp(c, "CabinetWClass") == 0) {
HWND hWorker, hReBar32, hCombo32, hCombo, hEdit;
hWorker = FindWindowEx(hwnd, 0, "WorkerW", NULL);
if (hWorker) {
hReBar32 = FindWindowEx(hWorker, 0, "ReBarWindow32", NULL);
if (hReBar32) {
hCombo32 = FindWindowEx(hReBar32, 0, "ComboBoxEx32", NULL);
if (hCombo32) {
hCombo = FindWindowEx(hCombo32, 0, "ComboBox", NULL);
if (hCombo) {
hEdit = FindWindowEx(hCombo, 0, "Edit", NULL);
if (hEdit) {
SendMessage(hEdit, WM_GETTEXT, 1024, (LPARAM)(void*)lpString);
}
}
}
}
}
}
</small>
I believed due to Vista Architecture different from 2K and XP, this code doesn't work anymore and it always fail at FindWindowEx(hReBar32, 0, "ComboBoxEx32", NULL); in Vista. Anybody can give me some instructions on how to make this work with Vista?
|
|
|
|
|
Hirakawa wrote: it always fail at FindWindowEx(hReBar32, 0, "ComboBoxEx32", NULL); in Vista
What does GetLastError returns ?
Prasad
MS MVP - VC++
|
|
|
|
|
Hi Prasad_Som
Thank you for reply. I use the following codes to get the last error and I got dword value 0.
DWORD dwResult = GetLastError();
CString Temporary;
Temporary.Format("%d", dwResult);
AfxMessageBox(Temporary);
|
|
|
|
|
Hirakawa wrote: I got dword value 0.
It indicates sucess but you need to use this code after failed API .
hCombo = FindWindowEx(hCombo32, 0, "ComboBox", NULL);
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
0,
(LPTSTR) &lpMsgBuf,
0,
NULL
);
MessageBox( NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );
LocalFree( lpMsgBuf );
Prasad
MS MVP - VC++
|
|
|
|
|
Hi Prasad,
Thank you. I got a string "The operation completed successfully" when running your code but I still fail at hCombo32 = FindWindowEx(hReBar32, 0, "ComboBoxEx32", NULL);
Best regards,
|
|
|
|
|
Suggesting to post this query in Vista forum.
It can be best answered there. As users having exposure to vista will visit there.
Prasad
MS MVP - VC++
|
|
|
|
|
Hirakawa wrote: FindWindowEx(hReBar32, 0, "ComboBoxEx32", NULL);
in the vista when I checked the ComboBoxEx32 is not directly under the "ReBarWindow32".There is a window in between. the class name is "Address Band Root". So you have to first find "Address Band Root" window under the ReBarWindow32 and then the ComboBoxEx32 from it.
|
|
|
|
|
Hi Nave,
Thank you for reply. I tried to use the FindWindowEx to find the "Address Band Root". Good news is it really exist but the problem still with FindWindowEx(hReBar32, 0, "ComboBoxEx32", NULL);
By the way, can you teach me what method do you use to find out or learn about the existing of "Address Band Root"?
|
|
|
|
|
So why not just use Spy++ to see if the parent/child windows have the same relationship on the two platforms?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thank you to everyone who replied. I found the answer:
I need to find "Address Band Root" and "msctls_progress32" before "ComboBoxEx32"
|
|
|
|
|
I'm trying to make a program like Texas Calculatem, www.calculatem.com,
where it will read my hole cards and the cards on the board, then tell
me my odds!
I can't figure out how I would have the program read what cards are in
my hand or on the board. Any help would be appreciated, Thanks!
|
|
|
|
|
If you draw each card as a Graphics GDI+ object you can find them easier.
|
|
|
|
|
In my Dialog Based MFC application i have a menu, one of the items should be disabled and grey upon startup (Maybe i can use the "Grayed" checkbox on the settings for the item?), then a few moments later, usable. Ive searched around alot, yet not find exactly what i want or something 100% working. So far i have created the UPDATE_COMMAND_UI function for the menu item, and put pCmdUI->Enable(false); into it. So now when i click it nothing happens. (its not grey though) So how do i grey it out?
thanks!
//Johannes
|
|
|
|
|
1. Make the controls disabled in the dialog template
2. In OnInitDialog() , set a timer
3. In OnTimer() , enable the controls.
|
|
|
|
|
Some of the command routing for like menus is not hooked up from CDialog. You can hook it up yourself somehow... I forget... search on MSDN (Using Google if I were you) to find some really really old articles or technical notes about this that show you how to solve the problem.
|
|
|
|
|
There's also CWnd::UpdateDialogControls() which allows the use of ON_UPDATE_COMMAND_UI in dialogs.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Ive looked at UpdateDialogControls() and it seems to be connected with UPDATE_COMMAND_UI. Ive searched around alot, on iGoogle, MSDN and codeproject yet not found something simple and working..
Another thing i dont understand is that UPDATE_COMMAND_UI seems to be executed when the menu item is clicked? but it cant really be clicked if it is disabled... Why cant it be as easy as to enable/disable the other dialog controls....
Thanks for the help
//Johannes
|
|
|
|
|
Hi all,
I'm trying to write an app like a LAN Messenger using MailSlots, everything works fine (almost), i just can't detect when the mailslot server doesn't exists. And i don't figure how i can do it .
I'm writing to the mailslot using a CreateFile statement like the ones in this wonderful site ... but nothing bad happens when the mailslot is closed.
Someone knows how i can realize this trick????
Any suggestion is welcome, Thank you in advance
|
|
|
|
|
Hi,
I use a CButton-derived ThemeButton (http://www.codeproject.com/buttonctrl/WowButtons.asp[^]) in my project. It works on XP, but crashes on Windows 2000 with the following error:
"The instruction at '0x00000000' referenced memory at '0x00000000'. The memory could not be 'read'."
I traced it and it happened in the following function:
void ThemeButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
HDC hDC = lpDrawItemStruct->hDC;
CDC* pDC = CDC::FromHandle(hDC);
CRect rc = lpDrawItemStruct->rcItem;
CString sText (_T(""));
::CopyRect(&m_pGDSData->rcClip,rc);
::CopyRect(&m_pGDSData->rcDest,rc);
m_pGDSData->hDC = hDC;
if( !(lpDrawItemStruct->itemState & (ODS_DISABLED|ODS_SELECTED)) )
{
if( !m_tracking )
{
if( lpDrawItemStruct->itemState & ODS_FOCUS )
::CopyRect(&m_pGDSData->rcSrc,m_rcDefault);
else
::CopyRect(&m_pGDSData->rcSrc,m_rcNormal);
}
else
::CopyRect(&m_pGDSData->rcSrc,m_rcHot);
}
else
{
if( lpDrawItemStruct->itemState & ODS_SELECTED )
::CopyRect(&m_pGDSData->rcSrc,m_rcPressed);
if( lpDrawItemStruct->itemState & ODS_DISABLED )
::CopyRect(&m_pGDSData->rcSrc,m_rcDissabled);
}
<big>(*GdiDrawStreamFunc)(hDC,sizeof(GdiDrawStreamStruct),m_pGDSData); </big>
...
}
BOOL ThemeButton::InitControl(...)
{
...
m_pGDSData = new GdiDrawStreamStruct;
ZeroMemory(m_pGDSData,sizeof(GdiDrawStreamStruct));
m_pGDSData->... = ...;
m_pGDSData->... = ...;
...
}
in the .h file:
PGdiDrawStreamStruct m_pGDSData;
typedef struct GdiDrawStreamStruct_tag
{
DWORD signature;
DWORD reserved;
HDC hDC;
RECT rcDest;
DWORD unknown1;
HBITMAP hImage;
DWORD unknown2;
RECT rcClip;
RECT rcSrc;
DWORD drawOption;
DWORD leftArcValue;
DWORD rightArcValue;
DWORD topArcValue;
DWORD bottomArcValue;
DWORD crTransparent;
} GdiDrawStreamStruct, *PGdiDrawStreamStruct;
Can anyone help me see how it could behave differently in XP and 2K?
Thanks.
|
|
|
|
|
Is GdiDrawStreamFunc NULL?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
No.
<br />
typedef BOOL (__stdcall *GdiDrawStream)(HDC hDC, DWORD dwStructSize,PGdiDrawStreamStruct pStream);<br />
static GdiDrawStream GdiDrawStreamFunc = (GdiDrawStream)GetProcAddress(GetModuleHandle(_T("GDI32.DLL")),_T("GdiDrawStream\0"));
|
|
|
|
|
Right, I've seen the code. The exception kind of indicated a NULL function pointer.
I imagine it's using visual styles available only on XP+
Visual Styles[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Does this mean there is ABSOLUTELY no way this code could run in Win2K?
(If you see header part on http://www.codeproject.com/buttonctrl/WowButtons.asp[^], you can see that it SHOULD run even on Win95/NT4. Or I shouldn't rely on this information?)
If that so, is there any way I can differentiate which code is executed depending on the windows version? (The declaration is in the .h file, not in .cpp)
Can I do something like: (pseudo-code) in the .h file
class CMyDlg : public CDialog
{
...
enum { IDD = IDD_MYDLG };
if(WindowsVersion>=XP)
ThemeButton m_btn1;
else
CButton m_btn1;
...
...
}
|
|
|
|
|
I'm not sure why my posts got voted 5....I haven't helped any
If I had documentation on this "GdiDrawStream" function in GDI32.DLL it would be much easier
to give a definite answer.
If this is something that is only supported with the new visual styles, and you want to use it in
Windows 2000, then I would recommend modifying the button class instead of checking the OS
version in the class using the buttons (like you've shown). That would encapsulate the OS
versioning stuff nicely so you wouldn't need to use different button classes in your dialogs.
The ThemeButton class is already derived from CButton, so it should be pretty easy to
modify the class - if the OS version is < XP just use the default CButton implementation.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: I'm not sure why my posts got voted 5....I haven't helped any
Maybe you are spurring visions of Filet-O-Fish
|
|
|
|