HOW: EnumWindows() on modal dialog

I have a program that use to communicate with other program... For example, I want to communicate with Notepad, and hit the open menu..

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 @!
[1770 byte] By [huahsin68] at [2007-11-18 23:21:01]
# 1 Re: HOW: EnumWindows() on modal dialog
Well, I think the code for the xxx function will help :-P
pinzo at 2007-11-11 0:59:50 >
# 2 Re: HOW: EnumWindows() on modal dialog
No!! it couldn't... I have run several test on modal dialog and modeless dialog..

the xxx function wouldn execute on modal dialog.. the code will stop until I response to the modal dialog.. if I response to the modal dialog, I mean I click on the OK button, then it execute xxx function..

So, do you have any other method to get the child handle of modal dialog...

THank YOu @!
huahsin68 at 2007-11-11 1:00:50 >