Re: Send message issue
nicetom786@yahoo.com wrote:
Even though I use SendMessage I get an error-
SendMessageA does not take 4 parameters.
1>c:\\samples\\cml\mylistctrl.cpp(92) : error C2660:
'CWnd::SendMessageA' : function does not take 4 arguments
The code was
void CMyListCtrlOne::OnNMClick(NMHDR *pNMHDR, LRESULT *pResult)
{
//CFrameWnd * pFrame = (CFrameWnd *)(AfxGetApp()->m_pMainWnd);
//now get the view from that
//CCView *mv = (CCView*)pFrame->GetActiveView();
SendMessage(mv->m_myCtrlTab.userDlg->m_myListCtrTwo,WM_INSERT_ITEMS,0,0);
}
Why this happens and what is the way to correct this
When you call SendMessage from inside a CWnd-derived class the compiler
assumes you mean to call CWnd::SendMessage, which takes 3 parameters.
When you call SendMessage from a non-CWnd class (CDocument) the compiler
assumes you mean to call the 4-parameter SendMessage API. But you are
calling it incorrectly: its first parameter must be an HWND.
Use CWnd::SendMessage in both cases:
GetCurrntView()->m_myListctrl.SendMessage(
WM_MY_MESSAGE,
0,
0);
mv->m_myCtrlTab.userDlg->m_myListCtrTwo.SendMessage(WM_INSERT_ITEMS,0,0);
--
Scott McPhillips [VC++ MVP]