Dialog Box Problem
-
I have a dialog based application which the user accesses through a password. Now there are 2 categories of users and depending on the login and password the application has to display 2 different user screens. How do I do this? Also when I first wrote this application I had just one user in mind so all the code is present in the dialog class CApplicationDlg. Is it possible for me to hide all the controls on this dialog box and create a new user screen on the same dialog box when the 2nd user type logs in? Thanks Mike.
-
I have a dialog based application which the user accesses through a password. Now there are 2 categories of users and depending on the login and password the application has to display 2 different user screens. How do I do this? Also when I first wrote this application I had just one user in mind so all the code is present in the dialog class CApplicationDlg. Is it possible for me to hide all the controls on this dialog box and create a new user screen on the same dialog box when the 2nd user type logs in? Thanks Mike.
Well, I guess the simplest way to get this done, given the original design of your project, is as follows:
- Create two sets of controls for each user profile and merge them into the only dialog resource. You'll end up with a mess of overlapping controls, so you might want to do the work separately in auxiliary dialog resources and then copy and paste to the final destination. On the process some controls will be shared (i.e., they exist for both user profiles), keep that in mind and do not duplicate them.
- Have all the controls hidden by default. If you select Test on the Resource menu, the dialog should appear empty.
- Have two static arrays defined for your
CDialog
class, each specifying the IDs of the controls that should appear for the corresponding user profile. - Add a variable to the constructor of your
CDialog
class indicating the user profile. - In
OninitDialog
you just have to walk thorugh the appropriate array of control IDs and callGetDlgItem(id)->ShowWindow(SW_SHOW)
.
Hope this helps. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
-
Well, I guess the simplest way to get this done, given the original design of your project, is as follows:
- Create two sets of controls for each user profile and merge them into the only dialog resource. You'll end up with a mess of overlapping controls, so you might want to do the work separately in auxiliary dialog resources and then copy and paste to the final destination. On the process some controls will be shared (i.e., they exist for both user profiles), keep that in mind and do not duplicate them.
- Have all the controls hidden by default. If you select Test on the Resource menu, the dialog should appear empty.
- Have two static arrays defined for your
CDialog
class, each specifying the IDs of the controls that should appear for the corresponding user profile. - Add a variable to the constructor of your
CDialog
class indicating the user profile. - In
OninitDialog
you just have to walk thorugh the appropriate array of control IDs and callGetDlgItem(id)->ShowWindow(SW_SHOW)
.
Hope this helps. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
I figured that out thanks. But the problem now is that I need a menu bar for one user category and no menu for the other user category. By default the dialog box loads a menu bar, and I want to remove it when the user 2 enters. So I did the following CMenu* menu = GetSystemMenu(TRUE); menu->DestroyMenu(); But the program crashes! What do I do? Thanks, Mike
-
I figured that out thanks. But the problem now is that I need a menu bar for one user category and no menu for the other user category. By default the dialog box loads a menu bar, and I want to remove it when the user 2 enters. So I did the following CMenu* menu = GetSystemMenu(TRUE); menu->DestroyMenu(); But the program crashes! What do I do? Thanks, Mike
Well, maybe you can do it the other way around: by default have no menu in your dialog, and set it when needed with
SetMenu
. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo