Same caption problem as before, what am I doing wrong?
-
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!
-
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!
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?
-
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?
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.
-
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.
See this article. /ravi "There is always one more bug..." http://www.ravib.com ravib@ravib.com
-
See this article. /ravi "There is always one more bug..." http://www.ravib.com ravib@ravib.com
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
-
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?
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;
} -
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;
}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....
-
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....
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.
-
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.
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.