September 8th, 2003, 09:14 AM
Does anyone know if an Alert Window / Dialog, has a particular style or something that defines it as an alert. I am trying to detect and generate errors based of alerts that appear during an automated test cycle.
Thanks in advance.
P.S. I have used SPY++ and other tools but have found that not only Alerts have the DS_* styles, Also i am not scared of C++ so samples in C, C++, C# and any of the VB's out there would be welcome
September 8th, 2003, 10:08 AM
In windows they are called Message Boxes, and do more than just alert.
The first part of the messagebox call is the hwnd parameter, but that's not important for this purpose. The second and third parts are obvious. The forth parameter sets how it will display. There are several options you can use here, and I'll give a brief list:
int nResult=MessageBox(HWND, "Message Text", "Caption Text", MB_OKCANCEL|MB_ICONEXCLAIMATION|MB_DEFBUTTON1);
if (nResult == IDOK)
// do something
Choose one of the following to set the available buttons:
MB_OKCANCEL, MB_OK, MB_ABORTRETRYIGNORE, MB_RETRYCANCEL, MB_YESNO, MB_YESNOCANCEL
Choose one or none of the following to set the icon:
MB_ICONEXCLAIMATION, MB_ICONWARNING (Exclaimation point)
MB_ICONINFORMATION, MB_ICONASTERISK (i in a Bubble)
MB_ICONQUESTION (? in a bubble)
MB_ICONSTOP, MB_ICONERROR, MB_ICONHAND (white x in red circle)
Choose one or none of the following to specify default button:
MB_DEFBUTTON1, MB_DEFBUTTON2, MB_DEFBUTTON3, MB_DEFBUTTON4
MessageBox returns one of the following values (int):
IDABORT, IDCANCEL, IDIGNORE, IDNO, IDOK, IDRETRY, IDYES
There are more options, but this is what you're most likely to find
in your testing. Hope it helps.
September 9th, 2003, 04:43 AM
Thanks for the reply but i know that they are created using MessageBox ( ... ); I just wanted to know if there were any styles specific to the ones that windows comes up with. For example a C# Checkbox has an extended style of 0x0000000B, I would be greatful if anyone out there has any ideas
September 10th, 2003, 01:04 PM
The combinations of styles I posted above is pretty much what's available. If you want to know the value of each item (ie, what value would MB_YESNO|MB_ICONASTERISK be) I suggest writing some code to assign the values to an integer and output the results, but you're really better off just using the names.
September 11th, 2003, 02:01 AM
There are plenty of message box styles.
Just look in winuser.h for a list (or just ask MSVC to take you to the definition of MB_OK.)
The style I think you are talking about is MB_APPLMODAL or MB_SYSTEMMODAL which do not allow any other actions until the messgebox is dealt with.
The essence of Christianity is told us in the Garden of Eden history. The fruit that was forbidden was on the Tree of Knowledge. The subtext is, All the suffering you have is because you wanted to find out what was going on. You could be in the Garden of Eden if you had just kept your f***ing mouth shut and hadn't asked any questions.
September 11th, 2003, 03:28 AM
Thanks MB_APPMODAL || MB_SYSTEMMODAL should be enough to look for.
Thanks for the help!