轉型 : CString to WParam or LPARAM / LPARAM or WPARAM to CString
使用時機: PostMessage & SendMessage
Sample :
//Get parent handle
CWnd *pParent = GetParent () ; //because the control is from CWnd
//check
DBG ( "pParent->m_hwnd : 0x%p \n " , pParent->m_hwnd ) ;
CString str_wparam ;
str_wparam.Empty() ; //init
CString str_lparam ;
str_lparam.Empty() ; //init
str_wparam.Format (_T("hello") ) ;
str_lparam.Format (_T("world") ) ;
::PostMessage (pParent->m_hwnd , WM_XXXX , (WPARAM) (LPCTSTR) str_wparam , (LPARAM)(LPCTSTR) str_lparam ) ;
-------------------------------------------------------
/*--接收端--*/
LRESULT CXXXDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
//事實上我比較喜歡用stitch 取代 if ... else if .. ,因為這樣看起來比較有精神-_-?
switch (message)
{
case WM_XXXX :
DBG ("wParam :%ws , lParam :%ws \n" , (LPCTSTR)wParam , (LPCTSTR)lParam ) ;
break;
}
//return 的也有分哦 !! 如果你是窗口類的 CDialog 請換成CWnd !
return CDialog::DefWindowProc(message, wParam, lParam);
}
留言列表