Click here to Skip to main content
15,893,790 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone!

I would like to start by saying thanks to everyone who takes some time to view this thread and try to help.

I have a popup menu, with submenu. The submenu's item should have push button instead of text.

That is pretty much it.

Should I owner draw it?

If so, some code example/ pseudo-code / instructions / tutorials / links ... would be welcome.

UPDATE #2:
***************************************************************************************

How can I create a simple push button in WM_DRAWITEM ?

I have tried with following code:

LPDRAWITEMSTRUCT lpDIS = (LPDRAWITEMSTRUCT)lParam;


HWND btnOk = CreateWindowEx(0,L"Button",L"test", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, lpDIS->rcItem.left + 10, lpDIS->rcItem.top + 10, 
lpDIS->rcItem.right - lpDIS->rcItem.left - 20,
lpDIS->rcItem.bottom - lpDIS->rcItem.top - 20,
hwnd, NULL, hInst, 0);


I don't know what to pass to CreateWindowEx() as parameter for parent window.

The button displays properly as a child window ( no border ), and its dimensions are good, but it is a child of the main window, not menu item.

How can I make it a part of the menu item ?

This is the only thing left.

Somebody please help me with some instructions or code examples or whatever...

Thank you.
*******************************************************************************************
UPDATE #3:

Is it possible that nobody knows how to create menu item with a simple push button in it?

Somebody help me please, I've been trying to do this on my own without success for nearly a month...

I am getting desperate.
********************************************************************************************
I work in MS Visual Studio Express 2008, on Windows XP, in C++, using pure WIN32 API.

If any other information is required ( source code or something similar ), please ask for it, I will more than gladly supply it.
Posted
Updated 11-Jun-13 17:19pm
v8
Comments
[no name] 17-May-13 21:02pm    
Yes you should probably owner draw it.
MyOldAccount 17-May-13 21:08pm    
I have never done such a thing, can you offer some advice in view of some code example/ links / tutorials/ pseudo-code or even simple instructions ?

I would highly appreciate it.

 
Share this answer
 
Comments
MyOldAccount 18-May-13 23:26pm    
That code is helpful, but it does not give an example of how to add push button to menu's item...
Still, thank you, I will try to make the most of it.
You have to use owner draw menu for this.
The update #2 seems to be almost correct.
To specify the parent, you need to provide the handle to the menu.
You can get this from lParam parameter of the WM_DRAWITEM message.
LPDRAWITEMSTRUCT lpDIS = (LPDRAWITEMSTRUCT)lParam;
lpDIS->hwndItem;    // This will be the menu handle to be used as the parent.

For owner drawn menus, take a look at this page - http://www.codeproject.com/KB/menus/[^]
 
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