CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12
  1. #1
    Join Date
    Apr 2009
    Posts
    1,355

    [RESOLVED] win32 - how can i add more flags to messagebox?

    i'm changind the standard messagebox and seems to work greate
    my question is: the messagebox() return is from 1 to 11. how can i change the return value for check if the checkbox is checked?
    i did these:
    Code:
    int a=::MessageBox(parent,text.c_str(),title.c_str(), flags);
        if(blnMessageBoxCheckBox==true)
            a|=16;
    when i do:
    Code:
    int a = MessageBox("hi",to_string(blnMessageBoxCheckBox), MB_OK, MB_EX_TEXTCENTER | MB_EX_MODAL| MB_EX_PARENTCENTER | MB_EX_CHECKEDBOX);
            if(a & 16 )
                MessageBox("Checked");
            else
                MessageBox("UnChecked");
    i, always, recive 'UnChecked'. what i'm doing wrong with flag?

  2. #2
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: win32 - how can i add more flags to messagebox?

    Unless you really really need this in code you can't control.

    Why not simply create your own Dialog that does everything you want rather than making it difficult by having hooks and trying to make it return things it's not designed for, These sort of "hacks" or "mods" can seriously bite you in the rear end.

    - if windows decides to add stuff in a new version that is not compatible with what you're doing
    - if the user is using disabilities tools (zooming, screen reading, braile device etc).

  3. #3
    Join Date
    Apr 2009
    Posts
    1,355

    Re: win32 - how can i add more flags to messagebox?

    Quote Originally Posted by OReubens View Post
    Unless you really really need this in code you can't control.

    Why not simply create your own Dialog that does everything you want rather than making it difficult by having hooks and trying to make it return things it's not designed for, These sort of "hacks" or "mods" can seriously bite you in the rear end.

    - if windows decides to add stuff in a new version that is not compatible with what you're doing
    - if the user is using disabilities tools (zooming, screen reading, braile device etc).

    doing a const variable:
    Code:
     const int IDCHECKED=0x10;
    //..............................
    int a=::MessageBox(parent,text.c_str(),title.c_str(), flags);
        if(blnMessageBoxCheckBox==true)
            a|=IDCHECKED;
    ///testing:
    int a = MessageBox("hello world\nhello mom... hello dear angel... how are you?\n\n\thehehehehe","hi" , MB_OKCANCEL, MB_EX_MODAL| MB_EX_PARENTCENTER | MB_EX_CHECKEDBOX,"check me, please...");
            if(a & IDCHECKED)
                MessageBox("checked");
            else if(a&IDCANCEL)
                MessageBox("cancel");
            else if (a&IDOK)
                MessageBox("OK");
    but maybe you have right. if they change the ID consts or add more, my code will not work correctly. unless i use a number more big than 0x10?

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: win32 - how can i add more flags to messagebox?

    Why take a risk that the OS will make a change and break your code?

  5. #5
    Join Date
    Apr 2009
    Posts
    1,355

    Re: win32 - how can i add more flags to messagebox?

    Quote Originally Posted by Arjay View Post
    Why take a risk that the OS will make a change and break your code?
    you, both, have wright. but, without create my own messagebox, how can i avoid it?

  6. #6
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656

    Re: win32 - how can i add more flags to messagebox?

    Quote Originally Posted by Cambalinho View Post
    you, both, have wright. but, without create my own messagebox, how can i avoid it?
    I am with OReubens on that: don't use MessageBox() function if you need customization. Just create your own DialogBox and make it as flexible as you need.
    There is only one feature of the MessageBox that doesn't come for free with the dialog: it auto-size the static text box and the window itself. This is NOT a very big deal.
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

  7. #7
    Join Date
    Apr 2009
    Posts
    1,355

    Re: win32 - how can i add more flags to messagebox?

    please someone correct these(if is confused, please tell me):
    - i have 3 forms(parent windows, not childs). i'm close them by it's ZOrder. my question is: after close the 1st, why the other 2 forms ZOrder is automatic changed?

  8. #8
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: win32 - how can i add more flags to messagebox?

    Quote Originally Posted by Cambalinho View Post
    please someone correct these(if is confused, please tell me):
    - i have 3 forms(parent windows, not childs). i'm close them by it's ZOrder. my question is: after close the 1st, why the other 2 forms ZOrder is automatic changed?
    In general please post a new question for a different topic.

    As far as the question, wouldn't you expect the z-order to change by the system as windows get added and removed and brought into the foreground? If the system didn't do this, z-order values would be meaningless.

  9. #9
    Join Date
    Apr 2009
    Posts
    1,355

    Re: win32 - how can i add more flags to messagebox?

    Quote Originally Posted by Arjay View Post
    In general please post a new question for a different topic.

    As far as the question, wouldn't you expect the z-order to change by the system as windows get added and removed and brought into the foreground? If the system didn't do this, z-order values would be meaningless.
    sorry about that. i did the same question, before, without an answer
    see these ZOrder(it's a little diferent from what i said... but you see what i mean):
    codeBlocks IDE - form1 - form2 - messagebox
    now close the messagebox and form2. why the codeblocks IDE comes to front automatic after close form2?

  10. #10
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: win32 - how can i add more flags to messagebox?

    Quote Originally Posted by Cambalinho View Post
    why the codeblocks IDE comes to front automatic after close form2?
    I have to ask, "Why do you care?" Besides the academic question, it would be a mistake in my opinion to code your app based on how you think the system sets the z-order.

  11. #11
    Join Date
    Apr 2009
    Posts
    1,355

    Re: win32 - how can i add more flags to messagebox?

    Quote Originally Posted by Arjay View Post
    I have to ask, "Why do you care?" Besides the academic question, it would be a mistake in my opinion to code your app based on how you think the system sets the z-order.
    i'm sorry, i thot the ZOrder was only changed when i click on window. else the windows that win focus will be the next on back and not the otherone. but thanks for correct me.. thanks to all

  12. #12
    Join Date
    Apr 2009
    Posts
    1,355

    Re: [RESOLVED] win32 - how can i add more flags to messagebox?

    anotherthing: these problem only happens when i use the messagebox()(standard ou mixed), after close the messagebox() and 1 form.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured