Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
See more:
Hi,

I want to know how to create a custom button in dialog's title bar? and that button look should be same as other icons like maximize or minimize or help context icon. And I want to know the handler also for the custom button click event. Please help me with this . Thanks in advance.
Posted

This is pretty difficult but quite doable. Basically, you need to handle Windows messages WM_NCCALCSIZE, WM_NCPAINT, WM_NCBUTTONUP, WM_NCBUTTONDOWN, WM_NCMOUSEMOVE, WM_NCRBUTTONDBLCLK and implement of the logic of button operation. In those WM_NC... message names "NC" means non-client.

You also need to consult system metrics to correctly size and position your button, see http://msdn.microsoft.com/en-us/library/ms724385(v=vs.85).aspx[^].

—SA
 
Share this answer
 
v2
 
Share this answer
 
Comments
bunathangaraj 24-May-11 2:47am    
Hi, i have tried this one only .. it worked but my custom looks different than minimize, maximize, context help buttons .. different in the sense if i click custom button it goes down and again i have to click make the button up exactly unlike context help buttons. And also i dont know the hander for the custom button click event. if you know, pls help me.
Check this article,
http://www.codeguru.com/cpp/controls/buttonctrl/windowsxp/article.php/c8211/
CCustomBitmapButton is a custom cwnd class.Check the notifications send by the CCustomBitmapButton, and how they are handled in the dialog.
why not to create single document and the view class is derive the CFormView.That is easy what you do.
 
Share this answer
 
Check James' Custom Titlebar[^]

I always like how James presenting a tutorial, it's so clean and precise
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900