Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Message Box being hidden

Message Box being hidden

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
12 Posts 6 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    braveheartkenya
    wrote on last edited by
    #1

    Hi all, I have some message boxes that are triggered from some buttons on a dialog. The dialog is set to open in full screen mode. The funny thing is that when the message boxes are triggered they get focus but they go behind my dialog. Any idea why this is happening and how to get the message box on top of the dialog? Thanks in advance.

    I F 2 Replies Last reply
    0
    • B braveheartkenya

      Hi all, I have some message boxes that are triggered from some buttons on a dialog. The dialog is set to open in full screen mode. The funny thing is that when the message boxes are triggered they get focus but they go behind my dialog. Any idea why this is happening and how to get the message box on top of the dialog? Thanks in advance.

      I Offline
      I Offline
      includeh10
      wrote on last edited by
      #2

      MessageBox(....,HWND hWnd). if hWnd is hidden, the message box is hidden also.


      A nice tool for optimizing your Microsoft html-help contents. Includeh10

      B 1 Reply Last reply
      0
      • B braveheartkenya

        Hi all, I have some message boxes that are triggered from some buttons on a dialog. The dialog is set to open in full screen mode. The funny thing is that when the message boxes are triggered they get focus but they go behind my dialog. Any idea why this is happening and how to get the message box on top of the dialog? Thanks in advance.

        F Offline
        F Offline
        FarPointer
        wrote on last edited by
        #3

        Set your dialog as its parent . int MessageBox( HWND hWnd (Set it as your dialog handle), LPCTSTR lpText, LPCTSTR lpCaption, UINT uType ); Regards, FarPointer

        B 1 Reply Last reply
        0
        • I includeh10

          MessageBox(....,HWND hWnd). if hWnd is hidden, the message box is hidden also.


          A nice tool for optimizing your Microsoft html-help contents. Includeh10

          B Offline
          B Offline
          braveheartkenya
          wrote on last edited by
          #4

          I'm quite new to MFC programming ... how do i make it visible?

          1 Reply Last reply
          0
          • F FarPointer

            Set your dialog as its parent . int MessageBox( HWND hWnd (Set it as your dialog handle), LPCTSTR lpText, LPCTSTR lpCaption, UINT uType ); Regards, FarPointer

            B Offline
            B Offline
            braveheartkenya
            wrote on last edited by
            #5

            Sorry i'm unfamiliar with how to create or use a handle. Could you please show me how to? Thanks in advance

            F G 2 Replies Last reply
            0
            • B braveheartkenya

              Sorry i'm unfamiliar with how to create or use a handle. Could you please show me how to? Thanks in advance

              F Offline
              F Offline
              FarPointer
              wrote on last edited by
              #6

              Hi, Please try this out:- m_hWnd :- this is the handle of the dialog MessageBox(m_hWnd,"AM I Working"); Regards, FarPointer

              1 Reply Last reply
              0
              • B braveheartkenya

                Sorry i'm unfamiliar with how to create or use a handle. Could you please show me how to? Thanks in advance

                G Offline
                G Offline
                Gary R Wheeler
                wrote on last edited by
                #7

                If you are using MFC, you can do the following:

                CMyDialog::OnButton()
                {
                ::MessageBox(m_hWnd,
                "Your message text goes here",
                "Caption for your message box",
                (MB_OK | MB_ICONINFORMATION));
                }

                In this case, CMyDialog is the name of your dialog class, derived from CDialog (which is in turn derived from CWnd). One of the members of all CWnd-derived objects is m_hWnd, which is the window handle.


                Software Zen: delete this;

                Fold With Us![^]

                B 1 Reply Last reply
                0
                • G Gary R Wheeler

                  If you are using MFC, you can do the following:

                  CMyDialog::OnButton()
                  {
                  ::MessageBox(m_hWnd,
                  "Your message text goes here",
                  "Caption for your message box",
                  (MB_OK | MB_ICONINFORMATION));
                  }

                  In this case, CMyDialog is the name of your dialog class, derived from CDialog (which is in turn derived from CWnd). One of the members of all CWnd-derived objects is m_hWnd, which is the window handle.


                  Software Zen: delete this;

                  Fold With Us![^]

                  B Offline
                  B Offline
                  braveheartkenya
                  wrote on last edited by
                  #8

                  I've just tried m_Hwnd as follows: ::MessageBox(m_hWnd,"This is the LAST record","Last Record",MB_ICONINFORMATION | MB_SYSTEMMODAL); But its still not coming to the front. Could there be something else wrong?

                  R N 2 Replies Last reply
                  0
                  • B braveheartkenya

                    I've just tried m_Hwnd as follows: ::MessageBox(m_hWnd,"This is the LAST record","Last Record",MB_ICONINFORMATION | MB_SYSTEMMODAL); But its still not coming to the front. Could there be something else wrong?

                    R Offline
                    R Offline
                    Ryan Binns
                    wrote on last edited by
                    #9

                    Kinda off topic... Don't use MB_SYSTEMMODAL unless you absolutely have to. It prevents the user from doing anything else on the computer other than interact with your message box. It's an exceptionally good way to cause extreme frustration and loss of confidence in your product...

                    Ryan

                    "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

                    B 1 Reply Last reply
                    0
                    • B braveheartkenya

                      I've just tried m_Hwnd as follows: ::MessageBox(m_hWnd,"This is the LAST record","Last Record",MB_ICONINFORMATION | MB_SYSTEMMODAL); But its still not coming to the front. Could there be something else wrong?

                      N Offline
                      N Offline
                      Nibu babu thomas
                      wrote on last edited by
                      #10

                      braveheartkenya wrote:

                      ::MessageBox(m_hWnd,"This is the LAST record","Last Record",MB_ICONINFORMATION | MB_SYSTEMMODAL);

                      You can try this one...

                      MessageBox(_T("This is the LAST record"), _T("Last Record"), MB_ICONINFORMATION | MB_SETFOREGROUND);
                      

                      Since you are using MFC you don't have to use m_hWnd here. MFC does that for you.


                      Nibu thomas Software Developer

                      B 1 Reply Last reply
                      0
                      • R Ryan Binns

                        Kinda off topic... Don't use MB_SYSTEMMODAL unless you absolutely have to. It prevents the user from doing anything else on the computer other than interact with your message box. It's an exceptionally good way to cause extreme frustration and loss of confidence in your product...

                        Ryan

                        "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

                        B Offline
                        B Offline
                        braveheartkenya
                        wrote on last edited by
                        #11

                        Thanks for the information ... i'll sure take it into account

                        1 Reply Last reply
                        0
                        • N Nibu babu thomas

                          braveheartkenya wrote:

                          ::MessageBox(m_hWnd,"This is the LAST record","Last Record",MB_ICONINFORMATION | MB_SYSTEMMODAL);

                          You can try this one...

                          MessageBox(_T("This is the LAST record"), _T("Last Record"), MB_ICONINFORMATION | MB_SETFOREGROUND);
                          

                          Since you are using MFC you don't have to use m_hWnd here. MFC does that for you.


                          Nibu thomas Software Developer

                          B Offline
                          B Offline
                          braveheartkenya
                          wrote on last edited by
                          #12

                          It didn't work, but i got another that did. Replace the MB_SETFOREGROUND with MB_DEFAULT_DESKTOP_ONLY. I don't know what it means, but it brings it on top and freezes the dialog. Any idea how i can bring it to the front but not freeze the dialog?

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups