Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / need fast help: trying to make a simple windows app...

Author
Message
Master Xilo
18
Years of Service
User Offline
Joined: 8th Sep 2006
Location: Bern, Switzerland
Posted: 19th Oct 2008 19:58 Edited at: 19th Oct 2008 20:04
HI,
The only purpose of this application is to show a first dialog, where you can open a 2nd one, then close that and the first one.

But when I call DestroyWindow() (= close) on the 2nd dialog, it closes it, minimizes the other one and completely freezes the whole application. I can re-maximize the 1st dialog, but when I click anywhere it just makes "bing".

Again (what happens):
- open dialog 1
- open dialog 2
- close dialog 2
- gets closed, dialog 1 gets minimized
- i can remaximize it, but the whole thing is frozen (just "bing"-sounds)


It's a very small project, I'd really appreciate it if someone could have a look and tell me wtf could be wrong.

[MSVC Project attached, 4.2 kb] (0.01 secs dowload time)

Source files:
main.cpp


res.h


res.rc


THANK YOU!

Attachments

Login to view attachments
Master Xilo
18
Years of Service
User Offline
Joined: 8th Sep 2006
Location: Bern, Switzerland
Posted: 19th Oct 2008 21:13
Anyone?
Please, of all these views at least some people must have already made something like this or have a suggestion.

If the dlgproc2 is only this:

It doesn't crash (but I don't see that dialog then of course):


NeX the Fairly Fast Ferret
19
Years of Service
User Offline
Joined: 10th Apr 2005
Location: The Fifth Plane of Oblivion
Posted: 19th Oct 2008 22:18
Hmm... confusing and obfuscated code. Definitely Visual Studio.

Would help you if I could understand it but I can't. One of the reasons I switched to Dev-C++/Code::Blocks.

Should I continue coding or focus on my art? Vote here:
http://www.polldaddy.com/p/953461/
NeX, the creator of a billion failed projects.
David R
21
Years of Service
User Offline
Joined: 9th Sep 2003
Location: 3.14
Posted: 19th Oct 2008 22:51
Try debugging it


09-f9-11-02-9d-74-e3-5b-d8-41-56-c5-63-56-88-c0
Master Xilo
18
Years of Service
User Offline
Joined: 8th Sep 2006
Location: Bern, Switzerland
Posted: 19th Oct 2008 23:01
@NeX the Fairly Fast Ferret
What's wrong with the code?
How does this say you it's Visual Studio?
Do you mean the resource file?

@David R
There's not much to debug.
I don't see what's wrong.
If I set a breakpoint at dlgproc's DestroyWindow, it's no reached...

I really don't know what to do.

Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 19th Oct 2008 23:07
Try using EndDialog instead of DestroyWindow.

Jeku
Moderator
21
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Vancouver, British Columbia, Canada
Posted: 19th Oct 2008 23:15 Edited at: 19th Oct 2008 23:15
Quote: "Hmm... confusing and obfuscated code. Definitely Visual Studio."


Neither confusing nor obfuscated, actually. That's standard Windows code

I would help you out but I haven't touched MFC since University--- 4 or 5 years ago at least.


Master Xilo
18
Years of Service
User Offline
Joined: 8th Sep 2006
Location: Bern, Switzerland
Posted: 19th Oct 2008 23:19
It's not MFC... (that would not be free)

@Benjamin
Thank you very much
Didn't know there was a special function for dialog windows.
It says "modal dialog boxes", so if I opened that dialog using CreateDialog, I could have used DestroyWindow()?

David R
21
Years of Service
User Offline
Joined: 9th Sep 2003
Location: 3.14
Posted: 19th Oct 2008 23:20
Quote: "There's not much to debug.
I don't see what's wrong.
If I set a breakpoint at dlgproc's DestroyWindow, it's no reached...

I really don't know what to do."


If DestroyWindow is never run, try breakpointing the switch and see whether it's even getting WM_CLOSE at all


09-f9-11-02-9d-74-e3-5b-d8-41-56-c5-63-56-88-c0
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 19th Oct 2008 23:23
Quote: "It says "modal dialog boxes", so if I opened that dialog using CreateDialog, I could have used DestroyWindow()?"

Yes, according to here.

Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 20th Oct 2008 23:44
I don't see an advantage to an API for dialog boxes - they're easy to make. Just disable the parent window (EnableWindow(hParentWnd, 0)) after the dialog is created. Specify the WS_DLGFRAME style for the dialog (I don't think that actually matters at all, but whatever). Then when destroying the window, make sure the procedure for the dialog enables the parent window (EnableWindow(hParentWnd, 1)). When the parent window isn't enabled you get what you just described.

Cheers,

-naota

I'm not a dictator to those that do stuff for me by will. Only those who don't.

Login to post a reply

Server time is: 2024-11-20 18:26:02
Your offset time is: 2024-11-20 18:26:02