Please help in finding bug....

Started by
6 comments, last by zackriggle 21 years, 4 months ago
I am having trouble creating a dialog from a dialog. I have tried DialogBox, CreateDialog, and ****DialogParam, as well as ShowWindow() after each one. I have uploaded my files here: My .zip file I would be eternally grateful if you help me track it down. The bug itself (along with some damn assertion error elsewhere) is in "server dialogprocs.h", on line 160. Note that there are several other files (all of the client files) which do not have any affect on either the assertion or dialog box bugs. [edited by - zackriggle on December 7, 2002 3:01:08 PM]
Advertisement
what''s the bug?
I am creating a dialog from inside the main dialog. I do it like this:

theHwnd = CreateDialog(GetModuleHandle(NULL), MAKEINTRESOURCE(dlg_Toolbox), hwnd, dlgprocToolbox);

However, when this returns, theHwnd == 0. dlg_Toolbox and dlgprocToolbox are both okay. It all compiles fine, but it fails at runtime. What could possibly cause it to fail?

It''''d make our lives a hell of a lot easier
and how do i reproduce it?
that's the catch -- I don't know whats making it go wrong. I have other identical function calls that work perfectly, but then there is only one dialog showing at a time....

Also note that if I close the dialog window that is already open, THEN open the new one, everything goes according to plan.... hmmmm....

I think it may also have something to do with this in my WinMain:


    // hInst is the HINSTANCE var from WinMain// dialogWin is a LPSTR (char*) -- global// dialogProc is a global DLGPROC//// When one dialog is done, it changes the globals, then ends// itself so that the next one can go on (like from logon screen// to buddy list -- only one at a time).//// I think the loop may have something to do with it (but// I don't know what...//while(DialogBox(hInst, dialogWin, NULL, dialogProc)){ // Do noting except loop};    


[edited by - zackriggle on December 7, 2002 6:41:01 PM]
let me rephrase.

i downloaded your project, built it, and ran it. i got a window up, no assertions, no violations.

i built server project, ran that, got a window.

there are no problems that i can see.

you have to state the following:

1. what project is giving you trouble.
2. how you execute it.
3. what you expect to see on screen.
4. what you actually see on screen.
5. sequence of actions i need to run to get the assertion error you''re getting.
Sorry about that.

1.) Run server.exe
2.) Create a new game (doesn't matter names and the like)
3.) Click "Tool Box"
4.) As you will see in the code pertaining to that button, a window SHOULD open with the tool dialog. It doesn't. If you test it, adding this at the end of the DM_B_TOOLBOX message section

if(theHwnd == 0)
MessageBox(NULL, "Error: Invalid HWND", "Error!", MB_OK)

5.) After this, close the Game Window, then close the Create New Game window -- there you get the assertion error.

[edited by - zackriggle on December 7, 2002 7:27:33 PM]
GetLastError after DialogBox reports:

Cannot create a top-level child window.

you''ll need to either make your dialog a popup window, or provide a valid window handle in third parameter.

you get the assertion because you''ve screwed up your memory allocations.

you can''t delete memory allocated with new using free.

you''re also allocating memory for strings in MGAME_B_MAKE, not deleting originally allocated memory, leaking the former.

do yourself a favor and use std::string, please.

This topic is closed to new replies.

Advertisement