reverse coler with VC++
Hi ...
It's all right...
FindWindow(LPCTSTR lpszClassName, LPCTSTR lpszWindowName ) function is a good method to find a window ... and the "CLASS NAME" (LPCTSTR lpClassName ... first parameter) is a good idea to search a window !
The class name of MSWord 2003 is "OpusApp" ... I think which also previous versions of MSWord have same ClassName ... but you can to use SPY++ to verify this.
Well ... now you know how to get the HANDLE: you have the pointer to CWnd object and the relative HANDLE (m_hWnd) .
You need, also, to create your personal CWnd class to handle the WM_PAINT message, WM_CTLCOLOR, WM_ERASEBKGND, or other re-coloring/paint messages events wich you want reHandle... if you wont to repaint NonClientArea (caption,systemmenu ... etc) you need to handle the appropriate messages
Now subclass the MSWord window: when a window is dynamically subclassed, windows messages will route through the CWnd message map and call message handlers in the CWnd class first. Messages that are passed to the base class will be passed to the default message handler in the window.
A (very) little example:
CWnd m_MyWindow; //your WndClass alredy defined
CWnd pWnd=FindWindow("OpusApp",NULL);
m_MyWindow.SubclassWindow(pWnd->GetSafeHwnd());
Now your MyWindow class can to hande every message directed to MainFrame of MSWorrd ... MyWindow can to handle the messages after or befor to redirect the message to Word window, but ... pay attention: if you want to handle message directed to child window, you need to subclass that window ... or windows!!
... and remebrer to call ...
m_MyWindow.UnsubclassWindow();
... when you destroy ... OnDestroy ... your application.
Bye ... mik27