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
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...
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.
strcmp() returns 0 if they are the same
if(strcmp(password,"123456")) will be true if they are NOT the same.
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.
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
and i needed to pass hInstance
DialogBox(hwnd, MAKEINTRESOURCE(IDD_Exit), NULL,
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....
DialogBox(hInstance, MAKEINTRESOURCE(IDD_Exit), NULL,
P.S. thnx for the info about the callback needing a return.....i missed that
One too many brackets there :)
noboby knows how to display a dialog box when a message is sent to a window?... like what would I type after
to display a dialog box on the screen...
to get the HINSTANCE of the current window use GetModuleHandle(NULL);