I want to send a message to WindowProc() function of application from a static callback function.
The PostMessage() and SendMessage() functions makes "Unhandled Exception". Can anybody tell me how to make the PostMessage() call no error.
If I use global namespace Postmessage, there is no error.
The runtime error message is as follows:
"Unhandled exception at 0x7c28e12a (mfc71d.dll) in MIDIApplication.exe: 0xC0000005: Access violation reading location 0x00000020."
The code causing the error is: AfxGetMainWnd()->SendMessage(wMsg, 0, dwParam1); where wMsg is the message and dwParam1 is the LParam in argument list of static callback function: MidiInProc().
Thanks for your help!!
Hi, pWnd is not NULL. The value is 0x0012ea24.
Is it possible to use DispatchMessage() to send message to WindowProc().
What is difference between DispatchMessage and PostMessage()?
I am happy that your issue has been resolved. But, so you can learn from this experience with others... let me explain my theory about what was happening.
You stated that you were calling AfxGetMainWnd() from within a callback function. Callbacks are often not excuting within the same thread as the main window. They may be called from an external thread.
"If AfxGetMainWnd is called from the application's primary thread, it returns the application's main window according to the above rules. If the function is called from a secondary thread in the application, the function returns the main window associated with the thread that made the call."
What kind of exception? From where is it being thrown? What does the code look like around the "throw" site? What are the parameters you're passing to the API? Is the HWND valid? In short we need some more detailed information.
Can any one tell me what could be problem with following code ?
adoctrl.m_UserId = tempuserid;
adoctrl.m_NewAccount = LArray;
adoctrl.m_InactivateAccount = LArray;
1.) Is GetSystemDefaultLangID() the best way to detect which language version of the OS is running? Or GetUserDefaultLangID()? Or something else?
2.) Is there a way to temporarily trick the US version of XP into thinking it's in another language? I tried changing the "Default input language" in the "Regional and Language Options" control panel, along with both GetSystemDefaultLangID() and GetUserDefaultLangID() in my code, but they both return English regardless of what I set for the default input language. Do I need localized installs of XP to test my localizations?
That change did not seem to affect anything. After reboot, XP was still in English and my code (calling GetSystemDefaultLangID()) is still reporting English. I set the option to both Vietnamese and Chinese(Taiwan), but neither had any effect.
Last Visit: 31-Dec-99 19:00 Last Update: 30-Nov-21 15:46