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.

Dark GDK / How do you use a messagebox?

Author
Message
Scope 51791
16
Years of Service
User Offline
Joined: 25th Jul 2008
Location:
Posted: 19th Aug 2008 06:42
I have created a message box which you either pick Yes or No. This is what i have so far:



But the question is, how do I make it so if you press "Yes" the program breaks and if you press "No", the messagebox dissapears but the program doesn't close.
Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 19th Aug 2008 07:09 Edited at: 19th Aug 2008 07:14
As far as I can tell, it's not possible to catch input from the boxes, due to the fact that you don't have access to the hWnd of the GDK. Sorry.

Of course, I may be wrong. I'll check the header a little more thoroughly.

EDIT: I did some looking, and, although I didn't find any declaration of the hWnd, I did find this undocumented command.



Someone more knowledgeable of the Win32 API should see what they can do with that.

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
Scope 51791
16
Years of Service
User Offline
Joined: 25th Jul 2008
Location:
Posted: 19th Aug 2008 07:14
Darn, there has to be a way to do it. can't I include the windows.h or something like that?
Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 19th Aug 2008 07:25
Once I learn the WinAPI well enough (I'm working on it), I'll post any method I discover of using that undocumented command.

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
Scope 51791
16
Years of Service
User Offline
Joined: 25th Jul 2008
Location:
Posted: 19th Aug 2008 07:38
Ok, I resolved the problem and I feel pretty good. Here is the code that I got to work:

Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 19th Aug 2008 07:44
MessageBoxA () should return a result.




Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 19th Aug 2008 07:48
Ahhh, I should have looked at MSDN.

Also, Lilith, use MessageBox. MessageBox a is for non-UNICODE apps. Supposedly, it's bad practice.

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 19th Aug 2008 07:58
I don't have to practice to be bad.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 19th Aug 2008 08:00 Edited at: 19th Aug 2008 08:03
Quote: "I don't have to practice to be bad."


Wait, what? Lol.

EDIT:
Apparently, using MessageBox (which is MessageBoxW) makes it more difficult. Forget bad practice.

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 19th Aug 2008 08:12
I'm just that good at being bad.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 19th Aug 2008 08:41 Edited at: 19th Aug 2008 08:54
Lol.

I'm messing with the function in console apps.



You could easily replace the //Print Answers section with something that finds what percent of the questions were answered correctly.

EDIT:
Here's the updated code for the curious.



Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 19th Aug 2008 08:56 Edited at: 19th Aug 2008 08:58
Quote: "Also, Lilith, use MessageBox. MessageBox a is for non-UNICODE apps. Supposedly, it's bad practice."

MessageBoxA and MessageBoxW are the same as MessageBox, the only difference is that one is ANSI while the other is Unicode. The version that is used depends on whether UNICODE is defined or not. If you do have the character set set to Unicode in the project options but you want to pass ANSI strings, you must explicitly use the MessageBoxA identifier.

Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 19th Aug 2008 08:57
Quote: "MessageBoxA and MessageBoxW are the same as MessageBox, the only difference is that one is ANSI while the other is Unicode. The version that is used depends on whether UNICODE is defined or not."


Yeah. I corrected myself.

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 19th Aug 2008 08:59
Just clarifying the difference.

elantzb
16
Years of Service
User Offline
Joined: 10th May 2008
Location: Classified
Posted: 20th Aug 2008 04:12 Edited at: 20th Aug 2008 04:12
may i suggest?

http://forum.thegamecreators.com/?m=forum_view&t=132099&b=22

~you can call me lantz~
Scope 51791
16
Years of Service
User Offline
Joined: 25th Jul 2008
Location:
Posted: 21st Aug 2008 01:02
I search the gdk forum before posting. I saw that thread but didn't help me with how to make something happen based on the button you pressed. I figured out how to do it already but thank you.
elantzb
16
Years of Service
User Offline
Joined: 10th May 2008
Location: Classified
Posted: 22nd Aug 2008 06:43
yeah, i guess it would have helped if my function actually checked for input.

~you can call me lantz~

Login to post a reply

Server time is: 2024-09-30 05:30:10
Your offset time is: 2024-09-30 05:30:10