Author Topic: dialog boxes?  (Read 5840 times)

0 Members and 1 Guest are viewing this topic.

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
dialog boxes?
« on: September 13, 2007 »
I've been looking for some way of making a dialog box to select windowed/fullscreen but everything I've found so far makes it look quite complicated, is it or is there any easier ways to do it?

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: dialog boxes?
« Reply #1 on: September 13, 2007 »
Simple Dialog Boxes can be done with MessageBox command - like you see it in
the NeHe tutorials. If you want more and cooler looking starting screens to select
various settings and displaying a logo e.g. it's actually a normal window - and therefor
you have to face with the typical windows gui management.
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: dialog boxes?
« Reply #2 on: September 13, 2007 »
You can either simply use
Code: [Select]
int res;
res = MessageBox(NULL, "Click Yes for Full Screen, No for Windowed", "Pick One!", MB_YESNO);
if (res == IDYES)
  fullscreen();
else if (res == IDNO)
  windowed();

alternatively if you want a whole box full of options you need to use the dialog editor in Visual Studio to create it, and then do all the message processing for the options in the box.  I can help you with that if you need it?

Jim
Challenge Trophies Won:

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Re: dialog boxes?
« Reply #3 on: September 13, 2007 »
Thanks benny and jim, that's pretty much what I was looking for for now jim but knowing how to be able to select resolutions and choose other options would be pretty handy too.

k++

Offline taj

  • Bytes hurt
  • DBF Aficionado
  • ******
  • Posts: 4810
  • Karma: 189
  • Scene there, done that.
    • View Profile
Re: dialog boxes?
« Reply #4 on: September 15, 2007 »
Wait ... does this mean I can use MessageBox before opening my window?

Would this work Jim?

Code: [Select]
MessageBox(NULL, "Muzik?", "", MB_YESNO) ? sound() : nosound() ;
MessageBox(NULL, "Full Screen?", "", MB_YESNO) ? fullscreen() : windowed() ;
That might squeeze nicely into 4k.
« Last Edit: September 16, 2007 by chris »
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: dialog boxes?
« Reply #5 on: September 15, 2007 »
Yep :)
Challenge Trophies Won:

Offline va!n

  • Pentium
  • *****
  • Posts: 1432
  • Karma: 109
    • View Profile
    • http://www.secretly.de
Re: dialog boxes?
« Reply #6 on: September 15, 2007 »
@chris:
Just check only the returncode of MessageBox any you know what the user selected... like

Code: [Select]
lPlaySound = MessageBox(NULL, "Muzik?", "", MB_YESNO)
lFullScreen = MessageBox(NULL, "Fullscreen?", "", MB_YESNO)

If lPlaySound = MB_YES   ; Can be optimized to      If lPlaySound     only
    lSound = True
Else
    lSound = False
Endif

If lFullScreen = MB_YES
    lScreen = True
Else
    lScreen = False
Endif

However, you can change the look and feel of the messagebox... just try this flags you can combine...

Code: [Select]
MB_ICONSTOP
MB_ICONQUESTION    ; possible the best for you...
MB_ICONWARNING
MB_ICONEXCLAMATION

MB_OK
MB_OKCANCEL
MB_YESNO
MB_YESNOCANCEL
MB_ARORTRETRYINGNORE



Edit:
Ah sorry, haven't seen JIMs post before... ^^   Btw, if you want an messagebox with own text on the buttons, this is possible too but a little bit complicated... If you want know how it work, just tell me and i will try to find the timer very soon to post an example..
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Offline taj

  • Bytes hurt
  • DBF Aficionado
  • ******
  • Posts: 4810
  • Karma: 189
  • Scene there, done that.
    • View Profile
Re: dialog boxes?
« Reply #7 on: September 15, 2007 »
Thanks Va!n. I was just looking fro the minimum byte use, nothing fancy.
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: dialog boxes?
« Reply #8 on: September 18, 2007 »
Here's a sample of how to do something a bit more complicated with the option box.

If you double click the dialog.rc file you will see the dialog in the visual studio editor.  From there you can right click any gadget and get and change its properties, LOTS of properties, or drag and drop new controls.  In the menu there are options to help you with the layout alignment and spacing.

NB. This is how I do dialog boxes - it's the Win32 way.  There are lots of other ways to achieve the same thing, the dialog editor can even write most of the code for you.

Jim
Challenge Trophies Won:

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Re: dialog boxes?
« Reply #9 on: September 19, 2007 »
Thanks Jim, can't get it to compile though:

.\dialog.rc(10) : fatal error RC1015: cannot open include file 'afxres.h'.

I've tried adding the mfc directory to the list of VC++ directories but that doesn't seem to help.

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: dialog boxes?
« Reply #10 on: September 20, 2007 »
On my PC, I have this folder which contains afxres.h, it's part of MFC which should be installed with Visual Studio.
C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\include
If I go to
Tools->Options->Projects and Solutions->VC++ Directories->Include Files
I have an entry in there which looks like
$(VCInstallDir)atlmfc\include

Why?  For some reason even when you select not to use MFC it still adds that include file to bring in winres.h.

Potential problems:
If you're using VS Express - does that file exist in your VS Express install?

Potential fixes:
Try replacing afxres.h with winres.h in the dialog.rc file.

Jim
Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: dialog boxes?
« Reply #11 on: September 20, 2007 »
I got the same problem with "afxres.h" file on VS2005 too, my solution is to remove it from resource file.

See attached file...
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: dialog boxes?
« Reply #12 on: September 20, 2007 »
I don't understand why our installs differ. ???  With VS.NET I always elect to install everything, it seems not to work too well if you selectively install only some bits of it.

Thanks for the fix though!

Jim
Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: dialog boxes?
« Reply #13 on: September 22, 2007 »
No problem :)

I do not install everything because I have a slow internet connection :( , it take ages to download all that stuff...
Challenge Trophies Won: