Dialog Box for Settings
Hi All,
I am writing a small OpenGL program, purely for learning purposes. I am using NEHE''s basecode and therefore not using MFC. The first thing I do in my WINMAIN function is to popup 2 yes-no message boxes to ask the user whether they want fullscreen and color depth. I would like to present the user with a settings dialog box instead, but can not seem to find any information on how to do this without using MFC.
If someone could please help it would be appreciated.
Thanx
Wiz74
Just another Corporate slave trying to release himself into the OpenGL void.
Are you using Visual C++? If so, you can make more complicated setup dialogs without using MFC. (Win32 API only) You can if you're not using VC, but I don't know how to edit the resources in other IDEs.
The following instructions are specifically for VC.
Click on Project -> Add to Project -> "New"
Select "Resource Script" from the new dialog, and give it a name
Now you'll see a third tab (between Class & Fileview)
also CLOSE the new window that opened (the name is whatever you picked.rc)
Select the middle tab (Res). Now right click on the only object in the left window, and select "insert"
From the new dialog that pops up, select dialog, and click new
NOW you can edit the dialog in the resource editor.
That was the easy part.
Now for some code :
make a function similar to this :
note that IDOK is defined in the dialog editor, the name of a button. you can case WHATEVER: as long as it's defined in the resource editor.
Note that the EndDialog() is VERY important, if you want the dialog to exit when the user clicks ok or cancel
IDC_RADIO2 is the name of a radio button in the dialog
Now here's how to display the dialog :
where
hgInst equals the program's hInstance,
IDD_VIDEO is whatever you named the dialog in the editor
ScreenSettingsProc is the whatever you named the other function you just wrote
If I left anything out, feel free to email or post. I'm not sure how to pre-check the radio buttons and check boxes, so I can't help you there... Anybody else know?
email
Something kinda sad about
the way that things have come to be.
Desensitized to everything.
What became of subtlety?
--Tool
Edited by - Lord Karnus on October 2, 2001 11:13:57 PM
The following instructions are specifically for VC.
Click on Project -> Add to Project -> "New"
Select "Resource Script" from the new dialog, and give it a name
Now you'll see a third tab (between Class & Fileview)
also CLOSE the new window that opened (the name is whatever you picked.rc)
Select the middle tab (Res). Now right click on the only object in the left window, and select "insert"
From the new dialog that pops up, select dialog, and click new
NOW you can edit the dialog in the resource editor.
That was the easy part.

make a function similar to this :
|
note that IDOK is defined in the dialog editor, the name of a button. you can case WHATEVER: as long as it's defined in the resource editor.
Note that the EndDialog() is VERY important, if you want the dialog to exit when the user clicks ok or cancel
IDC_RADIO2 is the name of a radio button in the dialog
Now here's how to display the dialog :
|
where
hgInst equals the program's hInstance,
IDD_VIDEO is whatever you named the dialog in the editor
ScreenSettingsProc is the whatever you named the other function you just wrote
If I left anything out, feel free to email or post. I'm not sure how to pre-check the radio buttons and check boxes, so I can't help you there... Anybody else know?
Something kinda sad about
the way that things have come to be.
Desensitized to everything.
What became of subtlety?
--Tool
Edited by - Lord Karnus on October 2, 2001 11:13:57 PM
[email=JValentine_13@hotmail.com]contact[/email]
Thank you mate. I have been scouring the web for the answer for what feels like weeks.
Ps. Sorry I forgot to mention the IDE that I am using, it is Visual C++ v6.
Once again thanx Lord Karnus, I am going to give it a go now.
Cya
Ps. Sorry I forgot to mention the IDE that I am using, it is Visual C++ v6.
Once again thanx Lord Karnus, I am going to give it a go now.
Cya
Just another Corporate slave trying to release himself into the OpenGL void.
I have another problem now. I created the dialog and it displays, but it only displays the controls (at moment 2 radio buttons and two normal buttons), but does not show the actual frame. Seems very strange, sort of have controls floating out in the middle of no-where. Mind you it actually works still.
Are there any properties in the dialog frame that need to be set. I have had a play with most of these and they do not seem to make any difference.
When I first did it, it still wasn''t working so I started a new Project (Win32 App) and dragged all the files into that.
Any idea''s as to why this might be happening.
PS. As far as I know you only forgot 1 thing:
#include "resource.h"
Are there any properties in the dialog frame that need to be set. I have had a play with most of these and they do not seem to make any difference.
When I first did it, it still wasn''t working so I started a new Project (Win32 App) and dragged all the files into that.
Any idea''s as to why this might be happening.
PS. As far as I know you only forgot 1 thing:
#include "resource.h"
Just another Corporate slave trying to release himself into the OpenGL void.
I''m going to take a guess....
Look in the dialog boxes properties (I think maybe on the Extended properties tab) for a Visable checkbox and make sure its selected.
Good luck
Look in the dialog boxes properties (I think maybe on the Extended properties tab) for a Visable checkbox and make sure its selected.
Good luck
Tried that, and it doesn't work. Thats one of the first things I tried.
Edited by - wiz74 on October 3, 2001 6:27:52 AM
Edited by - wiz74 on October 3, 2001 6:27:52 AM
Just another Corporate slave trying to release himself into the OpenGL void.
It actually looks like it is not re-drawing the frame. I started the program and while the settings dialog box (well the controls anyway) is up, I maximized Outlook and when I minimized Outlook again the settings dialog was all white with the writing from Outlook still over it, I couldn''t even see the controls. So I pressed roughly were I thought the cancel button was, and sure enough clicked the cancel button and actually saw it (the cancel button) while it was pressed.
Have also noticed that in the Taskbar there is a task for the dialog box but when you right click on it you get nothing.
Have also noticed that in the Taskbar there is a task for the dialog box but when you right click on it you get nothing.
Just another Corporate slave trying to release himself into the OpenGL void.
In the code example provided by Karnus, return FALSE for unhandled messages. The problem you are experiencing is because the dialog wnd is not being redrawn ie WM_PAINT or WM_ERASEBKGND
messages are not getting default processing.
From msdn 'DialogProc': "Except in response to the WM_INITDIALOG message, the dialog box procedure should return nonzero if it processes the message, and zero if it does not. "
Edited by - Ken Fitlike on October 3, 2001 3:39:24 PM
messages are not getting default processing.
From msdn 'DialogProc': "Except in response to the WM_INITDIALOG message, the dialog box procedure should return nonzero if it processes the message, and zero if it does not. "
Edited by - Ken Fitlike on October 3, 2001 3:39:24 PM
Country: Scotland [not listed in the ''Country'' combobox].
Thanx Ken, I will try this when I get home tonight. I knew it had to have to do with the redraw not happening, just couldn''t figure out why.
Once again, thank you Ken.
Once again, thank you Ken.
Just another Corporate slave trying to release himself into the OpenGL void.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement