
Owner drawn button with drop-down menu
I have an owner drawn button class (CButtonSSL, published
at the Code Project
http://www.*-*-*.com/ ),
which is capable of displaying a drop-down arrow and a
menu.
I have recently discovered that if the parent window of
the button loses focus then when focus is regained the
check state of the menu items is lost, i.e. none of the
menu items are checked any more :(
In the source code the class stores a CMenu member
variable, m_menu. In the call to SetSSLButtonMenu the menu
is initialised with a call to m_menu.LoadMenu passing in
the resource ID of the menu. The menu item check states
are altered in the call to CheckSSLMenuItem which calls
m_menu.CheckMenuItem () passing in the menu ID and the
check state.
In the OnLButtonDown event handler the popup menu is shown
as follows:
CMenu* pMenu = m_menu.GetSubMenu (0);
pMenu->TrackPopupMenu (TPM_RIGHTALIGN | TPM_LEFTBUTTON,
x, y, GetParent ());
I have scoured the MSDN and other such resources and get
work out why the menu would be losing it's check states.
Any suggestions?
Kind Regards,
Derek Lakin
Salamander Software Ltd.
http://www.*-*-*.com/ ~salamander.software