CListBox 的LBN_SELCHANGE消息该怎么发送ID为IDC_EDIT3
Sendmessage参数该怎么写

解决方案 »

  1.   

    是的,
    用Spy来看,这样会容易了解消息机制。
      

  2.   

    LBN_SELCHANGE Notification--------------------------------------------------------------------------------An application sends the LBN_SELCHANGE notification message when the selection in a list box has changed. The parent window of the list box receives this notification message through the WM_COMMAND message. Syntax
    LBN_SELCHANGE    WPARAM wParam
        LPARAM lParam;
        
    ParameterswParam
    The low-order word is the list box identifier. 
    The high-order word is the notification message.lParam
    Handle to the list box
      

  3.   

    SendMessage(hWnd, WM_COMMAND, MAKEWPARAM(IDC_EDIT3, LBN_SELCHANGE), (LPARAM)GetDlgItem(IDC_EDIT3)->GetSafeHwnd());
      

  4.   

    给控件发消息用SendMessage不方便的,有一个专用的API:
    LONG SendDlgItemMessage(
      HWND hDlg, // handle of dialog box
      int nIDDlgItem, // identifier of control
      UINT Msg, // message to send
      WPARAM wParam, // first message parameter
      LPARAM lParam // second message parameter
      );
      

  5.   

    IDC_EDIT3是列表框的id吧
    SendMessage(hWnd, WM_COMMAND, MAKEWPARAM(IDC_EDIT3, LBN_SELCHANGE), (LPARAM)GetDlgItem(IDC_EDIT3)->GetSafeHwnd());
    hWnd为对话框的窗口句柄,故可在对话框的成员函数里调CWnd版的SendMessage()SendMessage(WM_COMMAND, MAKEWPARAM(IDC_EDIT3, LBN_SELCHANGE), (LPARAM)GetDlgItem(IDC_EDIT3)->GetSafeHwnd());