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.
For an AutoCAD application I need to temporarily hide a dialog window and return control to the main window, in order to enable the user to select objects on the drawing screen. After the user has selected objects, control is returned to the dialog.
I do not use MFC, because I subclassed an existing dialog procedure.
What sequence of messages should I send in order to make the dialog hidden and visible again?
With code or manually? If you mean manually, open the EXE in a resource editor like VS, and add the file with the editor. With code, use the resorce APIs, BeginUpdateResource(), UpdateResource(), EndUpdateResource()
I have a question for you. I have a program is based on a basic binary tree.
There needs to be a function to swap nodes or from left to right. so in other words,
if 1 is the root and on the left is a 2 and on the right is a 3, I would want to swap the 2 and 3.
For each node entered.
Any ideas on how to write this out?
Last Visit: 31-Dec-99 19:00 Last Update: 7-Dec-21 14:39