how to get the message of the messsagebox?
hi members of the forum , i have a question about messageboxes , this is:
How to get the "string" message of a messagebox from window handle?, i mean not the title of the the messagebox, just the message that show the messagebox
thank you
Well, if you already have the HWND of the Message Box then you can do:
| |
char text[256]; GetWindowText(FindWindowEx(hwnd_msgbox, 0, "Static", 0), text, 256); |
1) MessageBox() pauses the thread it is called in so you have to get the text from another thread.
2) I don't know what you are doing so I can't say how you should get the message box's HWND to begin with but depending on your circumstances FindWindow(Ex)(), GetForegroundWindow(), GetAncestor(), and friends might help your cause.
thanks RITZ, i could get the text of the message , with your help, about the FindwindowsEx function, but i just could get the text of the message only for a messagebox with the button OK, but in the messageboxes that have more buttons, like "yes", "no" and "cancel", i couldn′t get the text of the messagebox, should I change the parameter of FindwindowEx?
thanks again for your help
I see, I'm sure that is because of the icon wich is also a static control.
| |
void GetMessageBoxText(HWND hw_msgbox, char *text, int max) { HWND hw_static = 0; do { hw_static = FindWindowEx(hw_msgbox, hw_static, "Static", 0); // find first/next static control in message box } while(GetWindowLong(hw_static, GWL_STYLE) & SS_ICON); // reiterate if this static control is an icon GetWindowText(hw_static, text, max); // grab text } |
That should do it.. (untested).