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. Same caption problem as before, what am I doing wrong?

Same caption problem as before, what am I doing wrong?

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
9 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.
  • G Offline
    G Offline
    generic_user_id
    wrote on last edited by
    #1

    I'm trying to draw the caption of a dialog myself, but windows keeps painting the button on the caption bar. Kilowatt said I had to put SetWindowLong(hDlg, DWL_MSGRESULT, FALSE); in the WM_NCACTIVATE handler, but adding that doesn't work with me. Probably I made a stupid mistake somewhere, or I forgot some obvious code, but simply adding the above code doesn't do anything at all. (SetWindowLong returns 0, when hDlg == m_hDlg) [edit] I forgot to mention that I return TRUE in WM_NCACTIVATE [/edit] What can I possibly be doing wrong, please help me. Thanks a lot in advance!

    P 1 Reply Last reply
    0
    • G generic_user_id

      I'm trying to draw the caption of a dialog myself, but windows keeps painting the button on the caption bar. Kilowatt said I had to put SetWindowLong(hDlg, DWL_MSGRESULT, FALSE); in the WM_NCACTIVATE handler, but adding that doesn't work with me. Probably I made a stupid mistake somewhere, or I forgot some obvious code, but simply adding the above code doesn't do anything at all. (SetWindowLong returns 0, when hDlg == m_hDlg) [edit] I forgot to mention that I return TRUE in WM_NCACTIVATE [/edit] What can I possibly be doing wrong, please help me. Thanks a lot in advance!

      P Offline
      P Offline
      Paul M Watt
      wrote on last edited by
      #2

      What are you using to develop your code? MFC, SDK, WTL I will post an example. Also, what exactly are you trying to accomplish, do you want to custom color the caption with different text and whatnot. Are you trying to custom draw the buttons in the corner?

      G P 2 Replies Last reply
      0
      • P Paul M Watt

        What are you using to develop your code? MFC, SDK, WTL I will post an example. Also, what exactly are you trying to accomplish, do you want to custom color the caption with different text and whatnot. Are you trying to custom draw the buttons in the corner?

        G Offline
        G Offline
        generic_user_id
        wrote on last edited by
        #3

        An example would be great! thanks! I'm using MFC, I need to change the hight of the caption, and therefore I need to paint it myself. Also I'm thinking about moving/drawing the buttons, but that's not as important. I think that covers about it, and again thanks.

        RaviBeeR 1 Reply Last reply
        0
        • G generic_user_id

          An example would be great! thanks! I'm using MFC, I need to change the hight of the caption, and therefore I need to paint it myself. Also I'm thinking about moving/drawing the buttons, but that's not as important. I think that covers about it, and again thanks.

          RaviBeeR Offline
          RaviBeeR Offline
          RaviBee
          wrote on last edited by
          #4

          See this article. /ravi "There is always one more bug..." http://www.ravib.com ravib@ravib.com

          G 1 Reply Last reply
          0
          • RaviBeeR RaviBee

            See this article. /ravi "There is always one more bug..." http://www.ravib.com ravib@ravib.com

            G Offline
            G Offline
            generic_user_id
            wrote on last edited by
            #5

            I read that article, but it didn't help me... Only the caption of a CView is modified in that example, it's a bit different for a CDialog. Thanks anyway

            1 Reply Last reply
            0
            • P Paul M Watt

              What are you using to develop your code? MFC, SDK, WTL I will post an example. Also, what exactly are you trying to accomplish, do you want to custom color the caption with different text and whatnot. Are you trying to custom draw the buttons in the corner?

              P Offline
              P Offline
              Paul M Watt
              wrote on last edited by
              #6

              I do not have very much time, so here is a code snippet from a WTL dialog example, you should be able to simply translate teh code to MFC. This will not repaint any custom parts, however it will prevent any portion of the borders and caption from being painted.

              LRESULT OnNCActivate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
              {
              //Perform your custom activation here.

                  //This is the key to prevent the caption from being painted 
                  //by the system
              ::SetWindowLong(m\_hWnd, DWL\_MSGRESULT, FALSE);
              return TRUE;
              

              }

              LRESULT OnNCPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
              {
              //You should call the defDlgProc for here.

                  //Preform your custom caption painting here.
              

              return TRUE;
              }

              G 1 Reply Last reply
              0
              • P Paul M Watt

                I do not have very much time, so here is a code snippet from a WTL dialog example, you should be able to simply translate teh code to MFC. This will not repaint any custom parts, however it will prevent any portion of the borders and caption from being painted.

                LRESULT OnNCActivate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
                {
                //Perform your custom activation here.

                    //This is the key to prevent the caption from being painted 
                    //by the system
                ::SetWindowLong(m\_hWnd, DWL\_MSGRESULT, FALSE);
                return TRUE;
                

                }

                LRESULT OnNCPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
                {
                //You should call the defDlgProc for here.

                    //Preform your custom caption painting here.
                

                return TRUE;
                }

                G Offline
                G Offline
                generic_user_id
                wrote on last edited by
                #7

                Thanks for your reply. I translated this part to mfc, with this as result:

                LRESULT CAnothertestDlg::OnNCPaint(WPARAM wParam, LPARAM lParam)
                {
                ::SetWindowLong(m_hWnd, DWL_MSGRESULT, FALSE);
                return TRUE;
                }

                LRESULT CAnothertestDlg::OnNCActivate(WPARAM wParam, LPARAM lParam)
                {
                return TRUE;
                }

                This is pretty much the same as what you told me before and I still don't get it working. I'm getting pretty desperate to get this working....

                P 1 Reply Last reply
                0
                • G generic_user_id

                  Thanks for your reply. I translated this part to mfc, with this as result:

                  LRESULT CAnothertestDlg::OnNCPaint(WPARAM wParam, LPARAM lParam)
                  {
                  ::SetWindowLong(m_hWnd, DWL_MSGRESULT, FALSE);
                  return TRUE;
                  }

                  LRESULT CAnothertestDlg::OnNCActivate(WPARAM wParam, LPARAM lParam)
                  {
                  return TRUE;
                  }

                  This is pretty much the same as what you told me before and I still don't get it working. I'm getting pretty desperate to get this working....

                  P Offline
                  P Offline
                  Paul M Watt
                  wrote on last edited by
                  #8

                  You have the examples backwards. it should be like this.

                  LRESULT CAnothertestDlg::OnNCPaint(WPARAM wParam, LPARAM lParam)
                  {
                  return TRUE;
                  }

                  LRESULT CAnothertestDlg::OnNCActivate(WPARAM wParam, LPARAM lParam)
                  {
                  ::SetWindowLong(m_hWnd, DWL_MSGRESULT, FALSE);
                  return TRUE;
                  }

                  please run this and let me know what you see. You should see a window where the borders and caption never get painted. The minimize and maximize buttons will however still be painted. By the way, the custom caption article that somebody else posted loks pretty good, teh key to making this work in the dialog is the SetWindowLong call in WM_NCACTIVATE.

                  G 1 Reply Last reply
                  0
                  • P Paul M Watt

                    You have the examples backwards. it should be like this.

                    LRESULT CAnothertestDlg::OnNCPaint(WPARAM wParam, LPARAM lParam)
                    {
                    return TRUE;
                    }

                    LRESULT CAnothertestDlg::OnNCActivate(WPARAM wParam, LPARAM lParam)
                    {
                    ::SetWindowLong(m_hWnd, DWL_MSGRESULT, FALSE);
                    return TRUE;
                    }

                    please run this and let me know what you see. You should see a window where the borders and caption never get painted. The minimize and maximize buttons will however still be painted. By the way, the custom caption article that somebody else posted loks pretty good, teh key to making this work in the dialog is the SetWindowLong call in WM_NCACTIVATE.

                    G Offline
                    G Offline
                    generic_user_id
                    wrote on last edited by
                    #9

                    Sorry, that was a typo, I compiled it with SetWindowLong in the other handler. The SetWindowLong line doesn't make a difference, nothing happens at all. (at least nothing directly visual) Even without the SetWindowLong call the borders of the NC area aren't painted at all. The border doesn't get painted, but that didn't happen in the first place, my problem was that not only the buttons were painted, but a small area around the buttons too, and there is a line drawn that seperates the client and the non-client area. If I don't make a handler to NCACTIVATE at all windows paints the NC area as soon as it looses focus, otherwise not. Maybe I didn't make myself entirely clear, but I would like windows to paint nothing at all outside of the client area, as windows refuses to draw the button without background. Heh, this isn't as easy as I thought it would be, even explaining a simple problem can be quite hard.

                    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