Benutzer mit den meisten Antworten
CMFCPropertyGridCtrl access violation with MessageBox/AfxMessage in OnPropertyChanged if property is Combobox

Frage
-
It seems, that I can't attach my sources, so I try to explain the problem. Using a simple single-view application, no document-model, generated with the wizard, two views in a splitterwnd. One view creates a CMFCPropertyGridCtrl, with a single property. Two Options added, edit allowed.
Added a callback on changes:
afx_msg
LRESULTOnPropertyChanged(WPARAMwp, LPARAMlp);
Just a ::MessageBox inside the callback.
If I Change the value and press return, the messagebox is shown and everything runs. If I chnage the Combobox selection, the app crashes with an Access Violation 0x00000005. If I try These with the example NewControls, everything runs fine.
The Crash is in wincore.cpp,
(m_pfnSuper != NULL)
LRESULT CWnd::DefWindowProc(UINT nMsg, WPARAM wParam, LPARAM lParam)
with m_pfnSuper == 0xfeeefeee. Perhaps the expanded Combobox is choosen as hwnd or whatever.
Antworten
-
Yes, but why. I found a solution.
Inherit a class from CMFCPropertyGridProperty, override OnSelectCombo, insert OnCloseCombo before OnUpdateValue. The combobox is closed after selection and the MessageBox/AfxMessage works fine.
- Als Antwort markiert Ionut DumaModerator Donnerstag, 25. April 2013 12:26
Alle Antworten
-
Nur ein kleiner hinweis zu 0xfeeefeee. Es scheint so zu sein, als ob das Objekt / Speicher wieder freigegeben wurde. Das ist eine der Magic Numbers im Debugging:
http://en.wikipedia.org/wiki/Magic_number_(programming)#Magic_debug_values
Vielleicht gibt Dir mein kleiner hinweis ja den richtigen Denkanstoß.
Best regards
Bordon
Note: Posted code pieces may not have a good programming style and may not perfect. It is also possible that they do not work in all situations. Code pieces are only indended to explain something particualar. -
Yes, but why. I found a solution.
Inherit a class from CMFCPropertyGridProperty, override OnSelectCombo, insert OnCloseCombo before OnUpdateValue. The combobox is closed after selection and the MessageBox/AfxMessage works fine.
- Als Antwort markiert Ionut DumaModerator Donnerstag, 25. April 2013 12:26
-
Fein, dass Du das Problem finden konntest. Übrigens, das ist hier die deutschsprachige VC++ Ecke, die für Englisch wäre hier:
http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/threads
Best regards
Bordon
Note: Posted code pieces may not have a good programming style and may not perfect. It is also possible that they do not work in all situations. Code pieces are only indended to explain something particualar.