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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. closing of a dialog box on button click problem!

closing of a dialog box on button click problem!

Scheduled Pinned Locked Moved C / C++ / MFC
c++help
19 Posts 6 Posters 0 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.
  • enhzflepE enhzflep

    Dhiraj kumar Saini wrote:

    So please help me as to in whcih class I have to use the above cod ewhich you have provided.

    CEmoticonsDlg, since this is the dialog you want to be able to close by clicking on the background. (as in, not on any of the 16 buttons)

    D Offline
    D Offline
    Dhiraj kumar Saini
    wrote on last edited by
    #10

    what code should i write in the messege handler ON_WM_KILLFOCUS

    enhzflepE 1 Reply Last reply
    0
    • D Dhiraj kumar Saini

      what code should i write in the messege handler ON_WM_KILLFOCUS

      enhzflepE Offline
      enhzflepE Offline
      enhzflep
      wrote on last edited by
      #11

      Dhiraj kumar Saini wrote:

      what code should i write in the messege handler ON_WM_KILLFOCUS

      The already supplied one?[^]

      D 1 Reply Last reply
      0
      • enhzflepE enhzflep

        Dhiraj kumar Saini wrote:

        what code should i write in the messege handler ON_WM_KILLFOCUS

        The already supplied one?[^]

        D Offline
        D Offline
        Dhiraj kumar Saini
        wrote on last edited by
        #12

        I have used the following message handler but now on clicking the emoticon button the dialogbox CEmoticonDlg is not being opened. Please tell me whats the problem. Its urgent

        void CEmotionsDlg::OnKillFocus(CWnd* pNewWnd)
        {
        CDialog::OnKillFocus(pNewWnd);
        // TODO: Add your message handler code here
        SendMessage(WM_CLOSE,0,0);
        }

        This is how I am opening the CEmoticonDlg Dialog box

        void CChatDlg::OnEmotions()
        {
        CEmotionsDlg m_EmotionsDlg(this);
        m_EmotionsDlg.DoModal();
        }

        Thanks In Advance

        I 1 Reply Last reply
        0
        • D Dhiraj kumar Saini

          I have used the following message handler but now on clicking the emoticon button the dialogbox CEmoticonDlg is not being opened. Please tell me whats the problem. Its urgent

          void CEmotionsDlg::OnKillFocus(CWnd* pNewWnd)
          {
          CDialog::OnKillFocus(pNewWnd);
          // TODO: Add your message handler code here
          SendMessage(WM_CLOSE,0,0);
          }

          This is how I am opening the CEmoticonDlg Dialog box

          void CChatDlg::OnEmotions()
          {
          CEmotionsDlg m_EmotionsDlg(this);
          m_EmotionsDlg.DoModal();
          }

          Thanks In Advance

          I Offline
          I Offline
          Iain Clarke Warrior Programmer
          wrote on last edited by
          #13

          Your getting beyond anyone's ability to help you here. You need to put breakpoints in your code, and see what error codes are. My suspicion is your CEmotionsDlg is starting, and stopping almost straight away. Put a breakpoint in the OnKillFocus handler, and see if I'm right. Put a breakpoint in the OnInitDialog handler, see if it gets called. Put a breakpoint on the m_EmotionsDlg.DoModal(); line and follow the code inside. Do you get errors? If in doubt, put breakpoints everywhere! Maybe you have a breakpoint somewhere, and the act of swapping to the debugger is losing focus on your dialog, and... Iain.

          D 1 Reply Last reply
          0
          • I Iain Clarke Warrior Programmer

            Your getting beyond anyone's ability to help you here. You need to put breakpoints in your code, and see what error codes are. My suspicion is your CEmotionsDlg is starting, and stopping almost straight away. Put a breakpoint in the OnKillFocus handler, and see if I'm right. Put a breakpoint in the OnInitDialog handler, see if it gets called. Put a breakpoint on the m_EmotionsDlg.DoModal(); line and follow the code inside. Do you get errors? If in doubt, put breakpoints everywhere! Maybe you have a breakpoint somewhere, and the act of swapping to the debugger is losing focus on your dialog, and... Iain.

            D Offline
            D Offline
            Dhiraj kumar Saini
            wrote on last edited by
            #14

            I have used the break points after domodal the control is going in InitDialog but not in the KillFocus Message Handler

            I 1 Reply Last reply
            0
            • D Dhiraj kumar Saini

              I have used the break points after domodal the control is going in InitDialog but not in the KillFocus Message Handler

              I Offline
              I Offline
              Iain Clarke Warrior Programmer
              wrote on last edited by
              #15

              Well, your dialog is starting (which is good news), but it is also finishing too early. You need to find out why it's finishing early then. Ask yourself what you know about stopping dialog. Maybe the OnInitDialog is not working correctly. Maybe something in your code is stopping the dialog? Try a breakpoint in CDialog::EndDialog - it could tell you which bit of your code is killing the dialog. Same with OnClose... If you still can't find it, comment out 99% of the dialog code until it stays up. Then start putting code back again until it breaks. This is going to be a pain to track down, but none of it is rocket science. Just plod through your code until you find the offending line or two. Iain.

              D 1 Reply Last reply
              0
              • I Iain Clarke Warrior Programmer

                Well, your dialog is starting (which is good news), but it is also finishing too early. You need to find out why it's finishing early then. Ask yourself what you know about stopping dialog. Maybe the OnInitDialog is not working correctly. Maybe something in your code is stopping the dialog? Try a breakpoint in CDialog::EndDialog - it could tell you which bit of your code is killing the dialog. Same with OnClose... If you still can't find it, comment out 99% of the dialog code until it stays up. Then start putting code back again until it breaks. This is going to be a pain to track down, but none of it is rocket science. Just plod through your code until you find the offending line or two. Iain.

                D Offline
                D Offline
                Dhiraj kumar Saini
                wrote on last edited by
                #16

                Ok I will try it.

                1 Reply Last reply
                0
                • D Dhiraj kumar Saini

                  Hi, I am working on an mfc application in which I am opening a dialog box containing smileys on button click. Now what I want is to close the dialog dialog box with smileys when mouse click event is fired anywhere on the screen. Thanks Dhiraj Kumar Saini

                  D Offline
                  D Offline
                  David Crow
                  wrote on last edited by
                  #17

                  Dhiraj kumar Saini wrote:

                  ...when mouse click event is fired anywhere on the screen.

                  See SetCapture().

                  "Love people and use things, not love things and use people." - Unknown

                  "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

                  D 1 Reply Last reply
                  0
                  • D David Crow

                    Dhiraj kumar Saini wrote:

                    ...when mouse click event is fired anywhere on the screen.

                    See SetCapture().

                    "Love people and use things, not love things and use people." - Unknown

                    "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

                    D Offline
                    D Offline
                    Dhiraj kumar Saini
                    wrote on last edited by
                    #18

                    Can you help me out with some tutorial for how to use SetCapture

                    D 1 Reply Last reply
                    0
                    • D Dhiraj kumar Saini

                      Can you help me out with some tutorial for how to use SetCapture

                      D Offline
                      D Offline
                      David Crow
                      wrote on last edited by
                      #19

                      Dhiraj kumar Saini wrote:

                      Can you help me out with some tutorial for how to use SetCapture

                      Other than what is provided here?

                      "Love people and use things, not love things and use people." - Unknown

                      "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

                      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