Advertisement

access violation in CreateDialog

Started by March 05, 2000 11:12 AM
4 comments, last by Ridcully 24 years, 7 months ago
i am using a dialog in one of my applications. this is the code i use for initialization: HWND hDlg; hDlg = CreateDialog( hInstance, MAKEINTRESOURCE(IDD_LAUNCHER), hWnd, LProc); hInstance an hWnd are both valid, IDD_LAUNCER is the id of my dialog and LProc the dialog processing callback function. now the strange thing: this works all fine, but the debugger says "Access Violation" when i run over this line of code. the app does NOT crash, it works as defined. but the debug output still complains any ideas why this could happen? as nothing crashes i am quite happy with my code, but still i want to know what gives me an access violation here... thanks ridcully
i tested my app on a win2k platform, and there it does CRASH with a protection fault.
that mean i HAVE to fix that bug..
please, any suggestions will be helpful

ridcully
Advertisement
An Access Violation is an exception thrown when you try to access memory you don''t own. My guess is that one of your parameters is NULL, so you should probably check that, although typically AVs only happen with pointers...

------------------------------
Jonathan Little
invader@hushmail.com
http://www.crosswinds.net/~uselessknowledge
CreateDialog doesn''t return immediately. It first sends WM_INITDIALOG, possibly a WM_SETFONT, then shows the dialog, before it returns. Maybe your handlers for those a screwing up.


"That which the flame does not consume...consumes the flame. "
"That which the flame does not consume...consumes the flame. "
this is starting to get weird.
i wanted to look at a sample from microsoft and see how they got it work, and guess what:
i get the same access violations in the original ms-sample code as i am getting in my app!
the exact phrase is:
in CreateDialog: "first change exception in **.exe (kernel32.dll) : access violation"
and in GetOpenFilename: "first change exception in **.exe (commdlg32.dll) : access violation"
this string i get in the debug output window several times on the call of the mentioned functions.

so i guess that''s not a bug, but a feature, if even ms gets this error!
Well, I often see things like that in the debugger, but it isn''t always something you need to concern yourself with. I think its sad, but apparently MFC causes, and usually handles, lots of exceptions. As long as it returns correctly, I would ignore them. If it crashes, that''s another story. But if it only crashes on Win2K, that''s pretty suspicious.

Rock

This topic is closed to new replies.

Advertisement