06-29-2020 11:13 AM
Hi,
How to use tab control as the enum of a state machine .
Thank you .
Best Regard.
06-29-2020 11:36 AM
I wouldn't.
Tab controls are mainly a visual display element to organize controls for the user. It is very rare that the tab control's value is actually used within the logic of the program.
The state machine should be controlled by an enum that has nothing to do with a tab control.
06-29-2020 12:06 PM
@Emna20 wrote:How to use tab control as the enum of a state machine ..
As Ravens said, your request is unusual and not something you typically want to do. Still, it should be equally easy to do because there is nothing special about a tab enum. Where did you run into roadblocks? Please show us a simplified version of your code.
Still, if you want to do it, you should turn the tab control into an indicator so it cannot be changed by the user at runtime and create states for each tab. You can even hide the tabs and just show controls and indicators relevant to each state on each tab page. Also make the tab a typedef, especially if you have a lot of its diagram constants floating around.
06-29-2020 03:23 PM
@altenbach wrote:
@Emna20 wrote:How to use tab control as the enum of a state machine ..
As Ravens said, your request is unusual and not something you typically want to do. Still, it should be equally easy to do because there is nothing special about a tab enum. Where did you run into roadblocks? Please show us a simplified version of your code.
Still, if you want to do it, you should turn the tab control into an indicator so it cannot be changed by the user at runtime and create states for each tab. You can even hide the tabs and just show controls and indicators relevant to each state on each tab page. Also make the tab a typedef, especially if you have a lot of its diagram constants floating around.
I think there are issues when you try to use a tab enum as a typedef because the copies don't update properly. I forget why. I just remember the pain...
06-29-2020 07:29 PM
@billko wrote:
I think there are issues when you try to use a tab enum as a typedef because the copies don't update properly. I forget why. I just remember the pain...
I have not seen that. However it is a pain having to edit the type definition to e.g. to add a new tab. ... and forget about changing the tab order. Gave up quickly of typedef'ing tab controls, even if not used a state variable. 😉
06-30-2020 03:17 AM
I've done some programs which basically work like that. Imagine a wizard type application which steps through tabs for the information, but i'd use a normal Enum for the states as it's common to need some extra states.
Otherwise it should work like any enum based state machine, connect it to a Case structure within a for loop and change tabs as needed for next state.