用SendMessage()向窗口发送消息时,如何传递参数,
例如:把字符串“asdfsad”作为参数?
SendMessage()有两种:mfc的CWindow的成员和API函数
CWindow::SendMessage
LRESULT SendMessage( UINT message, WPARAM wParam = 0, LPARAM lParam = 0 );LRESULT SendMessage(
HWND hWnd, 
UINT Msg, 
WPARAM wParam, 
LPARAM lParam );

解决方案 »

  1.   

    char* pChar = "asdfsad";
    SendMessage(WM_MYMSG,0,(LPARAM)pChar);
      

  2.   

    char *pChar= "asdfsad";
    ::sendMessage(hWnd,WM_MSG,0,(LPARAM)&pChar);
      

  3.   

    ::sendMessage(hWnd,WM_MSG,0,(LPARAM)&pChar);
                                   ------------------?
      

  4.   

    char* pChar = "asdfsad";
    SendMessage(WM_MYMSG,0,(LPARAM)pChar);
    在消息处理函数中再把pChar转换过来就行了
      

  5.   

    WPARAM wParam, 
    LPARAM lParam
    这两个就是消息的参数,在消息处理中将他们转换成需要的就可以了