Updated 18 march 2001. Now with keyboard and focus cues (only for W2k/Me)
Download source files - 4 Kb
Download demo project - 16.5 Kb

Introduction
This code was based on articles written by
Norm Almond and
David Peterson.
Why a new one? I needed a menu button that acts exactly like a pushbutton.
I believe I have done it.
Nevertheless, my button is not as cool as Norm Almond's is. I mean, there is no code
for displaying a bitmap. Feel free to add it yourself or borrow it from Norm Almond's article.
Implementation
I have developed two classes: CMenuButton and CAutoMenuButton. CAutoMenuButtonM
is the same button as CMenuButton, but adds its caption as the first and default menu item.
Useful behavior, isn't it?
How To Use
First of all, make your parent class support reflection of notification messages:
BEGIN_MSG_MAP(CMainDlg)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_ID_HANDLER(IDOK, OnOK)
COMMAND_RANGE_HANDLER(ID_FILE_NEW, ID_FILE_CLOSE, OnFileCmd)
<U>REFLECT_NOTIFICATIONS()</U>
END_MSG_MAP()
Then, declare your buttons:
WTLEX::CAutoMenuButton m_ctlOK;
WTLEX::CMenuButton m_ctlButtons[4];
And assign it an ID:
m_ctlOK = GetDlgItem(IDOK);
for(int i = 0; i < 4; i++)
{
m_ctlButtons[i] = GetDlgItem(IDC_NORMAL + i);
m_ctlButtons[i].SetMenuID(IDR_BTNMENU);
}
SetMenuID does not need to be called when you supply it in the constructor:
CMainDlg() : m_ctlOK(IDR_BTNMENU)
{
}
That's all :)