Dialog Box Resources

This is a discussion on Dialog Box Resources within the Windows Programming forums, part of the Platform Specific Boards category; So I used a dialog box resource editor to create a template resource for my win32 application. I wrote this ...

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    60

    Dialog Box Resources

    So I used a dialog box resource editor to create a template resource for my win32 application. I wrote this code:


    #include<windows.h>
    #include "resource.h" // defines DD_FORMVIEW


    LRESULT CALLBACK DialogProcedure(HWND hdlg,UINT msg
    WPARAM wparm, LPARAM lparm){
    switch(msg){
    case WM_COMMAND:
    EndDialog(hdlg,0); // to end the dialog if a button is clicked
    break;
    default:
    return DefDlgProc(hdlg,msg,wparam,lparam);
    }
    return 0;
    }

    int WINAPI WinMain(HINSTANCE hinst,HINSTANCE phinst,
    LPSTR commline,int showstyle){
    DialogBox(hinst,MAKEINTRESOURCE(DD_FORMVIEW),
    NULL, (DLGPROC) DialogProcedure);
    // the second parameter is my dialog box resource I created
    // the third parameter (should be a window handle, but the
    // application should consist only of the dialog box
    return 0;
    }


    So: The application is built without complaints of compiler or linker. But starting the executable DOES NOT DISPLAY THE DIALOG BOX! Nothing happens. It seems the DialogBox function is totally ignored. If you could give me an example code of a working Dialog Box this would help me.

  2. #2
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768

    Lightbulb

    Code:
    BOOL CALLBACK MyDlg(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
     {
      switch(Msg)
       {
        case WM_INITDIALOG:
                return(1);
    /*
    or return(TRUE); it's the same.
    here you init the dialog box, and it will appear .
    this spot also could be used to send things to the controls,
    place static controls... etc.
    */
        case WM_COMMAND:
                switch(LOWORD(wParam))  // the control's ID is been passed only in the low order (LOWORD) of the wParam!
                 {
                  case ID_OK:  // control's ID (ID_OK) - like a button.
                          MessageBox (hDlg, "Message" , "!!!", 0);
                          EndDialog(hDlg, ID_OK);  // makes the Dialog to close.
                          return(1);
                 }
                break;
       }
      return(0);   // or return(FALSE);
     }
    I can see you're really new to this... read some here: WinProg.net it's nice, but not enough, so you better buy a book... also you should get the MSDN, check microsoft.com
    Last edited by Devil Panther; 04-25-2003 at 04:52 AM.
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    Has DD_FORMVIEW got the style WS_VISIBLE?
    Have you included the script.rc file containing the resource DD_FORMVIEW?

    Or try a call to

    ShowWindow(hdlg,SW_SHOW);
    UpdateWindow(hdlg);

    when you init the dlg WM_INITDIALOG

    AFAIK you do not need to return TRUE to the WM_INITDIALOG msg to make the dlg appear.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 02-13-2008, 02:59 PM
  2. Parent of a BrowseForFolder dialog box
    By @nthony in forum Windows Programming
    Replies: 4
    Last Post: 01-08-2007, 02:54 PM
  3. New Theme
    By XSquared in forum A Brief History of Cprogramming.com
    Replies: 160
    Last Post: 04-01-2004, 08:00 PM
  4. Mingw Dialog Box resources
    By golfinguy4 in forum Windows Programming
    Replies: 3
    Last Post: 07-17-2002, 12:45 AM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 10:44 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21