In most circumstances, you know the messages you can send to a window. I strongly suspect you might be not taking the right path for your task. What are you trying to accomplish actually? I.e. what you are asking is uncommon, and the real task can most probably can be solved by other means.
Anyways. If you have a pointer to some MFC CWnd-derived object, it is still possible to 'reverse engineer' it's MFC message handlers defined in the class pointed by that CWnd*. MFC defines all message handlers in a map using BEGIM_MESSAGE_MAP/END_MESSAGE_MAP. What these macros actually do is, they define a virtual function called GetMessageMap() and a data array containing structures describing message mapping. So you can could use wnd->GetMessageMap() and then iterate over the mapped message handlers. Each entry contains information about the message handler, and the mapped function. Note that GetMessageMap is a protected function, so to access it from outside, you'll need a wrapper. Something like this:
struct Accessor : public CWnd
{
// overwrite protected
virtual const AFX_MSGMAP* GetMessageMap() const { return CWnd::GetMessageMap(); }
};
Accessor* msg_map_access = (Accessor*) window;
const AFX_MSGMAP* msg_map = msg_map_access->GetMessageMap();
const AFX_MSGMAP_ENTRY* entry = msg_map->lpEntries;
while (entry->nSig != AfxSig_end)
{
/// do something with the entries
}
Again, this is not common practice; normally, you never do that. So it would be nice to hear the motivation why you need this.