我需要在其它地方发消息给按钮,让按钮执行点击操作,怎么搞?::SendMessage(GetDlgItem(IDC_BUTTON1)->m_hWnd,BN_CLICKED,0,0);
这样不成功呀

解决方案 »

  1.   

    应该是给这个按钮的父窗口发送消息 WM_COMMAND
    The WM_COMMAND message is sent when the user selects a command item from a menu, when a control sends a notification message to its parent window, or when an accelerator keystroke is translated. WM_COMMAND 
    wNotifyCode = HIWORD(wParam); // notification code 
    wID = LOWORD(wParam);         // item, control, or accelerator identifier 
    hwndCtl = (HWND) lParam;      // handle of control 
      

  2.   

    BN_CLICKED是控件发给其父窗口的,参考LS。
      

  3.   


    ::SendMessage(m_hWnd, WM_COMMAND, MAKEWPARAM(IDC_BUTTON1, BN_CLICKED), (LPARAM)(GetDlgItem(IDC_BUTTON1)->m_hWnd));