pass variable between dialogs
-
hi,i have one dialog called "main" and another "login", when the program starts, "main" starts and in the OnInitDialog() it calls another dialog called "login" and the main is hidden using ShowWindow(SW_HIDE). From the "login" dialog how can i show the "main" dialog without restarting it and hence the OnInitDialog() starting again. or how do i pass a variable from "login" to "main" to use in an if statment in the OnInitDialog() to indicated the "login" has previously been called hope i make some bit of sense!! thanks
-
hi,i have one dialog called "main" and another "login", when the program starts, "main" starts and in the OnInitDialog() it calls another dialog called "login" and the main is hidden using ShowWindow(SW_HIDE). From the "login" dialog how can i show the "main" dialog without restarting it and hence the OnInitDialog() starting again. or how do i pass a variable from "login" to "main" to use in an if statment in the OnInitDialog() to indicated the "login" has previously been called hope i make some bit of sense!! thanks
If you display the "login"-dialog with a call to DoModal() from the "main"-dialog's OnInitDialog(), the "main"-dialog won't be displayed until the user have dismissed the "login"-dialog. Save the status depending on whether the login procedure was successful or not in a member of the "login"-dialog so that it can be retrieved when the execution continues in the "main"-dialog's OnInitDialog(). If the login procedure failed, simply use PostQuitMessage() to close the application or take whatever action you like. Hope this helps -- Roger
It's supposed to be hard, otherwise anybody could do it!
-
If you display the "login"-dialog with a call to DoModal() from the "main"-dialog's OnInitDialog(), the "main"-dialog won't be displayed until the user have dismissed the "login"-dialog. Save the status depending on whether the login procedure was successful or not in a member of the "login"-dialog so that it can be retrieved when the execution continues in the "main"-dialog's OnInitDialog(). If the login procedure failed, simply use PostQuitMessage() to close the application or take whatever action you like. Hope this helps -- Roger
It's supposed to be hard, otherwise anybody could do it!
thanks for the reply PostQuitMessage(0); does the job alright that i was looking for. but for future reference i would still like to know how to pass variables between dialogs say declare a int in "main" and pass it to "login" and "login" sends it back with a value inside it. thanks -- modified at 11:14 Friday 24th March, 2006
-
thanks for the reply PostQuitMessage(0); does the job alright that i was looking for. but for future reference i would still like to know how to pass variables between dialogs say declare a int in "main" and pass it to "login" and "login" sends it back with a value inside it. thanks -- modified at 11:14 Friday 24th March, 2006
It depens on the type of dialog you are using. For non-modal dialogs you can send a message the same as you would send any other message, using SendMessage() specifying your own paramaters for lParam and wParam. But with Modal dialogs, the main dialog is halted until the child dialog is closed. You are able to send a message from the child to the parent using PostMessage(). Another method is through the use of global pointers. I'm sure there are other methods, but the above 2 have always fulfilled my needs.
-
hi,i have one dialog called "main" and another "login", when the program starts, "main" starts and in the OnInitDialog() it calls another dialog called "login" and the main is hidden using ShowWindow(SW_HIDE). From the "login" dialog how can i show the "main" dialog without restarting it and hence the OnInitDialog() starting again. or how do i pass a variable from "login" to "main" to use in an if statment in the OnInitDialog() to indicated the "login" has previously been called hope i make some bit of sense!! thanks