Enabling/Disabling Menu Items
-
Hello all, I know I've done this before, but my code notes don't reflect it, and I can't for the life of me remember how to do it. It's probably easy, but the easy solutions always illude me. :) My app needs to either process data, or not process data at startup depending on a registry setting. The user is also able to stop or start the process via a menu item. If the process is started at startup, then the stop menu item needs to be enabled and the start menu item needs to be disabled. If the process is stopped at startup, then the opposite must occur in the menu's. The registry setting is read at startup. Here's my questions: 1. Where does the registry read function go? OnCreateClient, or PreCreateWindow? 2. In the Update functions for each menu ie start process and stop process, how do I enable one and disable the other, and vice versa. Thanks! Frank "Keyboard Error - Press F1 to Continue"
-
Hello all, I know I've done this before, but my code notes don't reflect it, and I can't for the life of me remember how to do it. It's probably easy, but the easy solutions always illude me. :) My app needs to either process data, or not process data at startup depending on a registry setting. The user is also able to stop or start the process via a menu item. If the process is started at startup, then the stop menu item needs to be enabled and the start menu item needs to be disabled. If the process is stopped at startup, then the opposite must occur in the menu's. The registry setting is read at startup. Here's my questions: 1. Where does the registry read function go? OnCreateClient, or PreCreateWindow? 2. In the Update functions for each menu ie start process and stop process, how do I enable one and disable the other, and vice versa. Thanks! Frank "Keyboard Error - Press F1 to Continue"
Process startup info on InitInstance. Enable/Disable menu items using the ON_UPDATE_COMMAND_UI macro cheers, Chris Maunder
-
Hello all, I know I've done this before, but my code notes don't reflect it, and I can't for the life of me remember how to do it. It's probably easy, but the easy solutions always illude me. :) My app needs to either process data, or not process data at startup depending on a registry setting. The user is also able to stop or start the process via a menu item. If the process is started at startup, then the stop menu item needs to be enabled and the start menu item needs to be disabled. If the process is stopped at startup, then the opposite must occur in the menu's. The registry setting is read at startup. Here's my questions: 1. Where does the registry read function go? OnCreateClient, or PreCreateWindow? 2. In the Update functions for each menu ie start process and stop process, how do I enable one and disable the other, and vice versa. Thanks! Frank "Keyboard Error - Press F1 to Continue"
Frank Deo wrote: 1. Where does the registry read function go? OnCreateClient, or PreCreateWindow? It depends on what kind of data you are reading (i.e. will it affect the window that you are about to display?) The place where I usually initialize data is on the function that handles WM_CREATE, but you have other options such as InitInstance, OnInitialUpdate, (if dialog base OnInitDialog), etc. Frank Deo wrote: 2. In the Update functions for each menu ie start process and stop process, how do I enable one and disable the other, and vice versa. To enable or disable menu items you can have a look at ON_UPDATE_COMMAND_UI or ON_UPDATE_COMMAND_UI_RANGE. Also the CCmdUI class. You can also have a look at EnableMenuItem(). pCmdUI->Enable( TRUE ); // FALSE to disable // Afterall, I realized that even my comment lines have bugs When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
-
Process startup info on InitInstance. Enable/Disable menu items using the ON_UPDATE_COMMAND_UI macro cheers, Chris Maunder
-
Frank Deo wrote: 1. Where does the registry read function go? OnCreateClient, or PreCreateWindow? It depends on what kind of data you are reading (i.e. will it affect the window that you are about to display?) The place where I usually initialize data is on the function that handles WM_CREATE, but you have other options such as InitInstance, OnInitialUpdate, (if dialog base OnInitDialog), etc. Frank Deo wrote: 2. In the Update functions for each menu ie start process and stop process, how do I enable one and disable the other, and vice versa. To enable or disable menu items you can have a look at ON_UPDATE_COMMAND_UI or ON_UPDATE_COMMAND_UI_RANGE. Also the CCmdUI class. You can also have a look at EnableMenuItem(). pCmdUI->Enable( TRUE ); // FALSE to disable // Afterall, I realized that even my comment lines have bugs When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
-
Thanks Toni, between EnableMenuItem and pCmdUI->Enable() I figured it out. :) Frank "Keyboard Error - Press F1 to Continue"