HOW: EnumWindows() on modal dialog
So I code like this:
void main()
{
EnumWindows(xxx, NOTEPAD);
char acMName[100];
int nMenuID;
HMENU hMenu = GetMenu(g_hWnd);
for(int i=0; i<GetMenuItemCount(hMenu); i++) {
memset(acMName, '\0', sizeof(char)*100);
GetMenuString(hMenu, i, acMName, 100, MF_BYPOSITION);
nMenuID = GetMenuItemID(hMenu, i);
if (_strnicmp(acMName, "&file", 100) == 0) {
SendMessage(g_hWnd, WM_COMMAND, nMenuID, NULL);
HMENU hSubMenu = GetSubMenu(hMenu, i);
for(int j=0; j<GetMenuItemCount(hSubMenu); j++) {
memset(acMName, '\0', sizeof(char)*100);
GetMenuString(hSubMenu, j, acMName, 100, MF_BYPOSITION);
nMenuID = GetMenuItemID(hSubMenu, j);
if (_strnicmp(acMName, "&open... ctrl+o", 100) == 0)
SendMessage(g_hWnd, WM_COMMAND, nMenuID, NULL);
}
}
}Once I get the open common dialog box up, it will hits the cancel button (just for testing).. In order to get the cancel button, I must EnumWindow() the Open Common box to get a handle like this..
g_hWnd = 0;
EnumWindows(xxx, OPEN);
if (g_hWnd == 0)
printf("NULL");
else
printf("not NULL");
}until here it was failed, the answer is NULL, because it jam at the common box and stop executing the code.. I think EnumWindows() is not suitable for modal dialog box.. Am I right?
So does anyone have any idea on this?
THank YOu @!

