Click here to Skip to main content
15,885,914 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to place the CButton inside a CListBox Item and handle the onclick event on the button.

thanx in advance
Posted
Updated 6-May-22 2:56am
v2

Take a look at this article[^], probably it will give you some advice on how to do that...

Hope this helps.
In the DrawItem() function you may find the below code
pDC->DrawFrameControl(&rect, DFC_BUTTON, DFCS_BUTTONRADIO | (sel?DFCS_CHECKED:0));


just change this to
pDC->DrawFrameControl(&rect, DFC_BUTTON, DFCS_BUTTONPUSH | (sel?DFCS_CHECKED:0));
 
Share this answer
 
v2
The suggested solution above merely (owner)draws a radio button. It does not create a CButton object and make it a CListBox menu item. Big difference. The OP wanted a real CButton control to be the menu items.
 
Share this answer
 
v2
Comments
TheRealSteveJudge 6-May-22 9:11am    
Thank you! The OP was desperately waiting for an answer to the question.
Finally, after just 11 years there is a solution. Let's hope the OP is still alive...
Sorry to disappoint, but my reply was no answer. That said, I am working on an answer because I need this capability for the MFC platform I am developing.

If more motivation is needed for this task, I point the readers to Windows 11's absolutely gorgeous Settings control. It implements presumably an in-house advanced CListBox control whose items are CButtons with drop-down or slide-off button arrows. The control is so advanced, added buttons move other surrounding controls out of the way. The result is astounding control of complex user data with efficient access and change capability. Nice work Microsoft.
 
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