Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Unimatrix_001

Dialog Boxes

This topic is 5360 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''ve got the basic code from nehe for a OpenGl window. I have also created a couple of dialog boxes that allow for settings to be changed. However whenever the program is run it jumps right to the OpenGL window. How can I make it so that my dialog boxes are displayed before the window and then the window is created on the settings from the dialog box? Thanks Uni

Share this post


Link to post
Share on other sites
Advertisement
Something like this..?? Make sure you put the call to DialogBox(...) at the top of your winmain function

    
#include <windows.h>

#include "resource.h" // If you're using MSVC's resource editor

BOOL CALLBACK DlgProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
switch(msg)
{
case WM_INITDIALOG:
{
// Do stuff you need to init your dialogbox here
return TRUE;
}

case WM_COMMAND:
{
switch(LOWORD(wparam))
{
case IDOK:
{
DestroyWindow(hwnd);
return TRUE;
}
// Check the rest of your dialog box controls here
}

}

default:
return FALSE;
}

return TRUE;
}

INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, DlgProc);

// Insert the rest of your code here..

return 0;
}


God speed..


[edited by - Rickmeister on May 30, 2002 8:08:39 AM]

Share this post


Link to post
Share on other sites
Naw...it still ain''t working..this is what I''ve got:

rc1.rc - This has just got my dialog IDD_DIALOG1 in, not typing just the design of it

resource.h - With #define IDD_DIALOG1 1 in it and that''s it


Can''t I just put just after my WinMain start this:

int WINAPI WinMain(HINSTANCE hinstance,HINSTANCE hprevinstance,LPSTR lpcmdline,int nshowcmd)
{

MAKEINTRESOURCE(IDD_DIALOG1);
.
.
.

but then it says that IDD_DIALOG1 is an undeclared identifyer. Any ideas? I''ve done it before and it didn''t involve any sort of messaging.




Thanks

Uni

Share this post


Link to post
Share on other sites
Okies...update ...I''ve got just the same before except in my WinMain I now have:

int WINAPI WinMain(HINSTANCE hinstance,HINSTANCE hprevinstance,LPSTR lpcmdline,int nshowcmd)
{


"IDD_DIALOG1"::ShowWindow(hwnd,SW_SHOW);
.
.
.


But I''m getting:
error C2065: ''hwnd'' : undeclared identifier
error C2143: syntax error : missing '';'' before ''tag::id''

what goes in place of that hwnd? and what is up with the other one?

Thanks

Uni

Share this post


Link to post
Share on other sites
Right...I''ve now fixed that error but it still isn''t showing up the dialog box. Here''s the code I''ve got:

"IDD_DIALOG1";::ShowWindow(hwnd,SW_SHOW);

Although it still ain''t working

Share this post


Link to post
Share on other sites
ok.. let me try to explain it again..and don't accuse me for beeing a good teacher.. I assume that you're using MSVC

  • Step 1
    Insert a resource script into your current project (Insert->Resource or CTRL+R). Choose "Dialog" and save the script into your current project folder.

  • Step 2
    Include the "resource.h" header-file into your project.

  • Step 3
    Write the message handling function (I called it DlgProc in my previous post, but you may call it whatever you want..)

  • Step 4
    Before any other calls to the windows API, create and show the Dialog using the line
    DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOG1), NULL, DlgProc);  

  • Step 5
    To check if any of the controls in the dialog (buttons, switches etc) is activated you check the LOWORD of wparam.


  • To find out more about window controls/Dialog boxes check out DialogBoxes reference at MSDN
    Another great site for learning how to use the Win32 API is www.winprog.org

    [edit] damn tags....

    #define  Email Lex & Yacc Function Pointers Virtual Terrain Knowledge Base Real Programmers
    "Strong typing is for the weak minded!"

    [edited by - Rickmeister on May 30, 2002 3:42:50 PM]

    Share this post


    Link to post
    Share on other sites

    • Advertisement
    ×

    Important Information

    By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

    We are the game development community.

    Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

    Sign me up!