SendMessage, GetMessage

I am aware that it is possible to send a message to a window.  Once the message is sent though I do not know how to retrieve it.  I think GetMessage() is the right function but how do I implement this

for example

1.How do I check for messages constantly without blocking users interaction with the window.

2.How do I manualy take care of some messages but leave the rest for windows to take care of.
leigh2Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
naveenkohliConnect With a Mentor Commented:
The message handling is all taken care of by MESSAGE MAP in your class. If you have right kind of message handlers added to map, then MFC will take care of its handling thru your message handlers.

e.g.
GetParent ()->SendMessage (WM_GRIDDATA_UPDATE, m_Row, (LPARAM)pDataStr);
send a message to its parent.

then i have entry in the message map of parent to handle this message

// In header file

//{{AFX_MSG(CGridView)
afx_msg LRESULT OnGridDataUpdate (WPARAM wParam, LPARAM lParam); -->>>> HANDLING WM_GRIDDATA_UPDATE message
//}}AFX_MSG
DECLARE_MESSAGE_MAP()

// In source file
BEGIN_MESSAGE_MAP(CGridView, CScrollView)
      //{{AFX_MSG_MAP(CGridView)
      ON_MESSAGE(WM_GRIDDATA_UPDATE, OnGridDataUpdate)
      //}}AFX_MSG_MAP
END_MESSAGE_MAP()

// Message handler function

LRESULT
CGridView::OnGridDataUpdate (WPARAM wParam, LPARAM lParam)
{
// Do your implementation here.
return TRUE;
}

2. If you don't want to handle the message , then you can return from that message handler so that message gets routed to next window in queue. When you return TRUE from function, it triggers that message has been taken care of. No further riuting.
0
All Courses

From novice to tech pro — start learning today.