Well I program a example for you!
#include <afxtempl.h>
#define ID_BUTTON_FRIST 100
#define BUTTON_COUNT 5
class CAaaaaDlg : public CDialog
{
void CAaaaaDlg::CreateButttons(void);
protected:
HICON m_hIcon;
CArray<HWND,HWND> m_arrButton;
..............
//}}AFX_MSG
afx_msg void OnCustomButtonHandler(UINT nID );
BOOL CAaaaaDlg::OnInitDialog()
{
CDialog::OnInitDialog();
..............
// TODO: Add extra initialization here
CreateButttons();
return TRUE; // return TRUE unless you set the focus to a control
}
1。
// The code fragment below shows how to use ON_COMMAND_RANGE macro
// to map a contiguous range of command IDs to a single message
// handler function (i.e. OnFileMenuItems() is the sample below). In
// addition, it also shows how to use CheckMenuRadioItem() to check a
// selected menu item and makes it a radio item.
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
// ...
//}}AFX_MSG_MAP
ON_COMMAND_RANGE(ID_FILE_MENUITEM1, ID_FILE_MENUITEM3, OnFileMenuItems)
END_MESSAGE_MAP()