两个的情况已实现,如何作群处理?
两个的实现代码(该对话框有背景,button2到button1的位置后原来button2上的背景没改变,如何把button2的背景换为button1的?)
void CMOMODlg::OnButton1()
{
GetDlgItem(IDC_BUTTON1)->ShowWindow(SW_HIDE); CRect rect1;
GetDlgItem(IDC_BUTTON1)->GetWindowRect(rect1);
CWnd *pWnd;
pWnd = GetDlgItem( IDC_BUTTON2);
ScreenToClient(rect1);
pWnd->MoveWindow(rect1); 小弟设想的方法是定义一个函数,参数是IDC_BUTTONn, 具体如何实现?
今天刚进来,没啥米,请高手们不吝赐教阿
两个的实现代码(该对话框有背景,button2到button1的位置后原来button2上的背景没改变,如何把button2的背景换为button1的?)
void CMOMODlg::OnButton1()
{
GetDlgItem(IDC_BUTTON1)->ShowWindow(SW_HIDE); CRect rect1;
GetDlgItem(IDC_BUTTON1)->GetWindowRect(rect1);
CWnd *pWnd;
pWnd = GetDlgItem( IDC_BUTTON2);
ScreenToClient(rect1);
pWnd->MoveWindow(rect1); 小弟设想的方法是定义一个函数,参数是IDC_BUTTONn, 具体如何实现?
今天刚进来,没啥米,请高手们不吝赐教阿
afx_msg void memberFxn( UINT id, NMHDR * pNotifyStruct, LRESULT * result );//id为你当前点中的ID值
ON_NOTIFY_RANGE( wNotifyCode, id, idLast, memberFxn )//比如:ON_NOTIFY_RANGE( NM_CLICK,IDC_BUTTON1,IDC_BUTTONN,OnButtonRange)
要注意的是IDC_BUTTON1到IDC_BUTTONN要连续
至于在OnButtonRange中如何处理以实现你的功能,把你设背景的代码贴上...
可以遍历全部控件 ,BOOL CALLBACK EnumChildProc(hWnd, NULL)
{
TCHAR szClassName[256];
GetClassName(hwnd, szClassName, 255); if ((0 == lstrcmpi(szClassName, _T("Button"))
{
...
}
}在对话框中
EnumChildWindows(m_hWnd, EnumChildProc, NULL)
或者参照二楼的
ON_NOTIFY_RANGE( wNotifyCode, id, idLast, memberFxn )//比如:ON_NOTIFY_RANGE( NM_CLICK,IDC_BUTTON1,IDC_BUTTONN,OnButtonRange)