WM_COPYDATA not received by SDI application
-
I am getting valid HWND of another SDI application using FindWindow and sending message "WM_COPYDATA". But OnCopyData is not called at the receiving application. What could be the reason for WM_COPYDATA not received? Regards
-- "Programming is an art that fights back!"
-
I am getting valid HWND of another SDI application using FindWindow and sending message "WM_COPYDATA". But OnCopyData is not called at the receiving application. What could be the reason for WM_COPYDATA not received? Regards
-- "Programming is an art that fights back!"
The first question to resolve is... - what window are you sending the WM_COPYDATA to? If you do a FindWindow on an MFC SDI application by windows title you will find you've got the handle of the CMainFrame derived window, not the view window where generally all the interesting I/O happens. One really clean way of using WM_COPYDATA is to create a "data copy target" window who's sole job is to recieve and process WM_COPYDATA. This window will be invisible and/or off screen so no one can interact with it. Cheers, Ash
-
The first question to resolve is... - what window are you sending the WM_COPYDATA to? If you do a FindWindow on an MFC SDI application by windows title you will find you've got the handle of the CMainFrame derived window, not the view window where generally all the interesting I/O happens. One really clean way of using WM_COPYDATA is to create a "data copy target" window who's sole job is to recieve and process WM_COPYDATA. This window will be invisible and/or off screen so no one can interact with it. Cheers, Ash
Thanks for the help!! I've resolved the problem, I forget to give the size of data to be sent:
cpds.cbData = _tcslen(csData) + 1;
. Also if the receiving application runs in IDE(Running as Admin), and the sending application launched externally(Normal mode), then sending copydata message failed and GetLastError() returns "Access denied". So the sending application must have same or higher credentials as the receiving application. Regards-- "Programming is an art that fights back!"