Thread: Alert Windows

    #1
  1. No Profile Picture
    Dude' Where's My JD and Coke
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Newbury, England
    Posts
    37
    Rep Power
    11

    Alert Windows


    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
  2. #2
  3. ASP.Net MVP
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Aug 2003
    Location
    WI
    Posts
    4,378
    Rep Power
    1511
    In windows they are called Message Boxes, and do more than just alert.
    Code:
    int nResult=MessageBox(HWND, "Message Text", "Caption Text", MB_OKCANCEL|MB_ICONEXCLAIMATION|MB_DEFBUTTON1);
    if (nResult == IDOK)
      // do something
    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:

    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.
    Primary Forum: .Net Development
    Holy cow, I'm now an ASP.Net MVP!

    [Moving to ASP.Net] | [.Net Dos and Don't for VB6 Programmers]

    http://twitter.com/jcoehoorn
  4. #3
  5. No Profile Picture
    Dude' Where's My JD and Coke
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Newbury, England
    Posts
    37
    Rep Power
    11

    Thanks


    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
  6. #4
  7. ASP.Net MVP
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Aug 2003
    Location
    WI
    Posts
    4,378
    Rep Power
    1511
    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.
    Primary Forum: .Net Development
    Holy cow, I'm now an ASP.Net MVP!

    [Moving to ASP.Net] | [.Net Dos and Don't for VB6 Programmers]

    http://twitter.com/jcoehoorn
  8. #5
  9. No Profile Picture
    Offensive Member
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2002
    Location
    in the perfect world
    Posts
    622
    Rep Power
    27
    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.

    Frank Zappa
  10. #6
  11. No Profile Picture
    Dude' Where's My JD and Coke
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Newbury, England
    Posts
    37
    Rep Power
    11
    Thanks MB_APPMODAL || MB_SYSTEMMODAL should be enough to look for.

    Thanks for the help!

IMN logo majestic logo threadwatch logo seochat tools logo