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. problem with adding About Diaglog

problem with adding About Diaglog

Scheduled Pinned Locked Moved C / C++ / MFC
debuggingc++helpquestionlearning
8 Posts 3 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.
  • T Offline
    T Offline
    tataxin
    wrote on last edited by
    #1

    I want to create About dialog after created main dialog. All I did as follows: - create about dialog - in Resource.rc, I add this:

    // create a line when right click dialog on taskbar
    STRINGTABLE
    BEGIN
    IDS_ABOUTBOX "&About ..."
    END

    - in CMyDlg.h, declare

    afx_msg void OnSysCommand(UINT nID, LPARAM lParam);

    - in CMyDlg.cpp, implement this method:

    void CMyDlg::OnSysCommand(UINT nID, LPARAM lParam)
    {
    /* set breakpoint to debug here */
    if ((nID & 0xFFF0) == IDM_ABOUTBOX)
    {
    CAboutDlg dlgAbout;
    dlgAbout.DoModal();
    }
    else
    {
    CDialog::OnSysCommand(nID, lParam);
    }
    }

    - in CMyDlg.cpp, register notify

    BEGIN_MESSAGE_MAP(CAboutDlg, CMyDlg)
    ON_WM_SYSCOMMAND()
    END_MESSAGE_MAP()

    that's all, but it doesn't work. I try to debug and found that it doesn't come into OnSysComand() method. What do I miss here? Thank you very much, :)

    S D 2 Replies Last reply
    0
    • T tataxin

      I want to create About dialog after created main dialog. All I did as follows: - create about dialog - in Resource.rc, I add this:

      // create a line when right click dialog on taskbar
      STRINGTABLE
      BEGIN
      IDS_ABOUTBOX "&About ..."
      END

      - in CMyDlg.h, declare

      afx_msg void OnSysCommand(UINT nID, LPARAM lParam);

      - in CMyDlg.cpp, implement this method:

      void CMyDlg::OnSysCommand(UINT nID, LPARAM lParam)
      {
      /* set breakpoint to debug here */
      if ((nID & 0xFFF0) == IDM_ABOUTBOX)
      {
      CAboutDlg dlgAbout;
      dlgAbout.DoModal();
      }
      else
      {
      CDialog::OnSysCommand(nID, lParam);
      }
      }

      - in CMyDlg.cpp, register notify

      BEGIN_MESSAGE_MAP(CAboutDlg, CMyDlg)
      ON_WM_SYSCOMMAND()
      END_MESSAGE_MAP()

      that's all, but it doesn't work. I try to debug and found that it doesn't come into OnSysComand() method. What do I miss here? Thank you very much, :)

      S Offline
      S Offline
      SandipG
      wrote on last edited by
      #2

      I guess you need to add the handler in the WinApp class. and by default MFC will add about dialog unless you explicitly removed the about dialog check box.

      T 1 Reply Last reply
      0
      • S SandipG

        I guess you need to add the handler in the WinApp class. and by default MFC will add about dialog unless you explicitly removed the about dialog check box.

        T Offline
        T Offline
        tataxin
        wrote on last edited by
        #3

        Thank you for reply me, SandipG. I don't have WinApp class, it's MFC project with Dialog based.

        S 1 Reply Last reply
        0
        • T tataxin

          Thank you for reply me, SandipG. I don't have WinApp class, it's MFC project with Dialog based.

          S Offline
          S Offline
          SandipG
          wrote on last edited by
          #4

          haha :D without application class you cant have MFC application. I am talking about the class which has Initinstance function.

          1 Reply Last reply
          0
          • T tataxin

            I want to create About dialog after created main dialog. All I did as follows: - create about dialog - in Resource.rc, I add this:

            // create a line when right click dialog on taskbar
            STRINGTABLE
            BEGIN
            IDS_ABOUTBOX "&About ..."
            END

            - in CMyDlg.h, declare

            afx_msg void OnSysCommand(UINT nID, LPARAM lParam);

            - in CMyDlg.cpp, implement this method:

            void CMyDlg::OnSysCommand(UINT nID, LPARAM lParam)
            {
            /* set breakpoint to debug here */
            if ((nID & 0xFFF0) == IDM_ABOUTBOX)
            {
            CAboutDlg dlgAbout;
            dlgAbout.DoModal();
            }
            else
            {
            CDialog::OnSysCommand(nID, lParam);
            }
            }

            - in CMyDlg.cpp, register notify

            BEGIN_MESSAGE_MAP(CAboutDlg, CMyDlg)
            ON_WM_SYSCOMMAND()
            END_MESSAGE_MAP()

            that's all, but it doesn't work. I try to debug and found that it doesn't come into OnSysComand() method. What do I miss here? Thank you very much, :)

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

            tataxin wrote:

            BEGIN_MESSAGE_MAP(CAboutDlg, CMyDlg) ON_WM_SYSCOMMAND() END_MESSAGE_MAP()

            This is the wrong message map. It should be:

            BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
            ON_WM_SYSCOMMAND()
            END_MESSAGE_MAP()

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

            "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

            T 1 Reply Last reply
            0
            • D David Crow

              tataxin wrote:

              BEGIN_MESSAGE_MAP(CAboutDlg, CMyDlg) ON_WM_SYSCOMMAND() END_MESSAGE_MAP()

              This is the wrong message map. It should be:

              BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
              ON_WM_SYSCOMMAND()
              END_MESSAGE_MAP()

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

              "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

              T Offline
              T Offline
              tataxin
              wrote on last edited by
              #6

              Thank you DavidCrow :) It works, but with a little strange. Whenever I right click application in taskbar and select "About ...", nothing happens. Then, I press Alt, the About dialog shows up. I don't know why???? :confused:

              D 1 Reply Last reply
              0
              • T tataxin

                Thank you DavidCrow :) It works, but with a little strange. Whenever I right click application in taskbar and select "About ...", nothing happens. Then, I press Alt, the About dialog shows up. I don't know why???? :confused:

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

                tataxin wrote:

                It works, but with a little strange. Whenever I right click application in taskbar and select "About ...", nothing happens.

                Does void CMyDlg::OnSysCommand() get called?

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

                "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                T 1 Reply Last reply
                0
                • D David Crow

                  tataxin wrote:

                  It works, but with a little strange. Whenever I right click application in taskbar and select "About ...", nothing happens.

                  Does void CMyDlg::OnSysCommand() get called?

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

                  "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                  T Offline
                  T Offline
                  tataxin
                  wrote on last edited by
                  #8

                  yes, it does. Here is the source code of OnSysCommand:

                  void CMyDlg::OnSysCommand(UINT nID, LPARAM lParam)
                  {
                  if ((nID & 0xFFF0) == IDM_ABOUTBOX)
                  {
                  CAboutDlg dlgAbout;
                  dlgAbout.DoModal(); // stop here (1)
                  }
                  else
                  {
                  CDialog::OnSysCommand(nID, lParam);
                  }
                  }

                  When I try to debug, it stops at (1) until I press Alt. After that, the About dialog shows.

                  modified on Monday, June 2, 2008 3:51 AM

                  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