vs2010,重载windowProc,编写控件消息响应函数

vs2010,重载windowProc,编写控件消息响应函数

  (2012-11-06 21:27:21)
转载
标签: 

杂谈

分类: MFC

来源:
http://blog.sina.com.cn/s/blog_6c8fad9f01014bt1.html

WM_COMMAND message:

http://msdn.microsoft.com/en-us/library/windows/desktop/ms647591(v=vs.85).aspx

winProc(message, wParam, lParam)
选择是WM_COMMAN的message;
根据wParam的高16位确定控件定义的通知码,比如对于COMBOBOX控件中的CBN_SELCHANGE消息码,意义是当combo当前选中的行的内容发生改变;
根据wParam的低16位确定控件的标识码;
对消息进行响应。
例子:
LRESULT CTestSolutionDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
    // TODO: Add your specialized code here and/or call the base class
    switch(message){
    case WM_COMMAND:
            if (LOWORD(wParam) >= IDC_CHECK_SELECT0 &&
                LOWORD(wParam) <= IDC_CHECK_SELECT9) {
                    enableWindowInLine(LOWORD(wParam) - IDC_CHECK_SELECT0,
                        IsDlgButtonChecked(LOWORD(wParam)));
            }
            else if(HIWORD(wParam) == CBN_SELCHANGE &&
                    LOWORD(wParam) >= IDC_COMBO_NAME0 &&
                    LOWORD(wParam) <= IDC_COMBO_NAME9) {
                        showMiContent(LOWORD(wParam) - IDC_COMBO_NAME0);
            }
            else if (LOWORD(wParam) >= IDC_EDIT_POS0 &&
                     LOWORD(wParam) <= IDC_EDIT_POS9) {
                        resetRange(LOWORD(wParam) - IDC_EDIT_POS0);
            }
            else if (LOWORD(wParam) >= IDC_EDIT_BITS0 &&
                    LOWORD(wParam) <= IDC_EDIT_BITS9) {
                         resetRange(LOWORD(wParam) - IDC_EDIT_BITS0);
            }
            break;
   

你可能感兴趣的:(我的转载文章,C++)