Simple Dialog Box (noob)

This is a discussion on Simple Dialog Box (noob) within the Windows Programming forums, part of the Platform Specific Boards category; Making my way through some tutorials... I seem to be stuck on the concept of dialog boxes.. wondering if someone ...

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    93

    Simple Dialog Box (noob)

    Making my way through some tutorials... I seem to be stuck on the concept of dialog boxes.. wondering if someone could look over my code and tell me what is wrong...

    ill attach my .cpp file below since it is too long to post the code here...

    What I am trying to do is
    1) create a simple window (which i can do)
    2) when the user tries to close the window a dialog box will
    appear prompting the user for a password.
    3) if the password is correct the dialog box will close and the
    main window will close
    4) otherwise the dialog box will close and the main window
    will remain..

    thnx in advance for all the help

    P.S. i didn't include my resource files... my dialog box consists of an OK button a CANCEL button and a text window for user to type in password...
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    May 2002
    Posts
    50
    Hmmm exactly what is it that doesn't work? Without your resource file, I can't compile and run your code to find out. Everything looks ok on the surface but I can't tell if there are any runtime bugs hiding in the code.

    Post your resource file and I'll take another look.

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,854
    strcmp() returns 0 if they are the same

    so

    if(strcmp(password,"123456")) will be true if they are NOT the same.

    if(strcmp(password,"123456"))==0)//match

    The password dialog's callback is missing a break and a return. I think you have forgotten to end the wm_COMMAND switch.





    Next time please be more specific as to your problems.
    Last edited by novacain; 06-27-2002 at 12:26 AM.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  4. #4
    Registered User
    Join Date
    Feb 2002
    Posts
    93
    howdy.. sorry bout not givin' much info about my problem... was in a rush..... I've done more trial and error and it seems my problem is just getting the Dialog Box to appear when the 'X' button is clicked to close the window....

    it seems in my code I wrote

    Code:
    DialogBox(hwnd, MAKEINTRESOURCE(IDD_Exit), NULL,
                        (DLGPROC)CheckPasswordProc);
    and i needed to pass hInstance

    Code:
    DialogBox(hInstance, MAKEINTRESOURCE(IDD_Exit), NULL,
                        (DLGPROC)CheckPasswordProc);
    however i don't know how to pass an instance of the window in the callback function... other than that my program seems to run fine.... i've tested writing the second above code in the WINAPI section and it runs fine... except the point of my program is not to display the dialog box at startup....

    P.S. thnx for the info about the callback needing a return.....i missed that
    Last edited by tegwin; 06-27-2002 at 01:14 PM.

  5. #5
    Registered User
    Join Date
    Jan 2002
    Posts
    387
    >> if(strcmp(password,"123456"))==0)//match

    One too many brackets there

    if(strcmp(password,"123456")==0)//match
    "There are three kinds of people in the world...
    Those that can count and those that can't."

  6. #6
    Registered User
    Join Date
    Feb 2002
    Posts
    93
    noboby knows how to display a dialog box when a message is sent to a window?... like what would I type after

    WM_CREATE:

    to display a dialog box on the screen...

  7. #7
    Registered User
    Join Date
    Jan 2002
    Posts
    387
    to get the HINSTANCE of the current window use GetModuleHandle(NULL);
    "There are three kinds of people in the world...
    Those that can count and those that can't."

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Display Dialog Box Then Execute
    By stickman in forum C++ Programming
    Replies: 17
    Last Post: 05-10-2006, 11:02 AM
  2. make Child Dialog not Popup?
    By Zeusbwr in forum Windows Programming
    Replies: 5
    Last Post: 04-08-2005, 02:42 PM
  3. Dialog Box Resources
    By Mecnels in forum Windows Programming
    Replies: 2
    Last Post: 04-28-2003, 05:57 AM
  4. edit control in dialog box problems
    By Bajanine in forum Windows Programming
    Replies: 11
    Last Post: 11-11-2002, 05:55 PM
  5. Resize Dialog Box via Code :: MFC
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 10-27-2002, 10:00 PM

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