Hi guys,
The TabControl has a Deselecting event with TabControlCancelEventArgs, where e.Cancel can be set to true to cancel the action. Can we have the same for the MDI Parent Form? Or in the (MDI Child) Form, in the DeActivate event have EventArgs with a Cancel action? Unless there is another way to stop switching between MDI children which I don’t know.
Best,
Alex
Hi Alex,
You can prevent a form (including mdi children) from getting deactivated by calling Activate() in OnDeactivate(). In the activation/deactivation process Wisej checked whether the deactivated form has reactivated itself.
You can also prevent a form (including mdi children) from getting closed by setting e.Cancel=true in OnFormClosing().
Best,
Luca
Hi Alex,
Menu merging is controlled by 2 properties: MergeOrder and MergeType.
Find a basic sample here and see how/where menus are added.
Best regards
Frank
Hi Frank,
It works, thanks!
Since we are talking about MDI, can you elaborate on the following point of your new beta version? To be honest I don’t quite understand what you mean. An example would be very helpful:
“Mdi child forms merge their menu into the parent’s menu when activated.”
Best,
Alex
Hi Alex,
can you please retest with build 1.2.82 ?
Thanks in advance,
Frank
Ok, Luca, no worries, I’ll wait for the next build, or may be the release!
Best,
Alex
Hi Alex,
I can’t reproduce with my build, so hopefully it was fixed by something else. There has been a lot of work with the mdi system to close the release, including merging the mdi child menu with the parent’s menu, moving the preview icon out of the tabs bar so it’s in a fixed location – which required a rewrite of the tabbed mdi child system.
Best,
Luca
Hi Luca,
I knew about the e.Cancel in the OnFormClosing, that’s why I was expecting the same in OnDeActivate. I hadn’t thought about calling the Activate method in the OnDeActivate event.
However, when I did it, I got stacked in a stackoverflow. It looks like the activation in the deactivate event keeps firing in a loop. Unless I haven’t understood your comment above “In the activation/deactivation process Wisej checked whether the deactivated form has reactivated itself” and I should be doing something myself.
I have attached a simple project which shows the problem. Go to the second MDI tab: with the textbox empty, you can freely switch tabs. If you enter “1” in the textbox and try to switch, the operation is caught in the deactivate/activate chain and the stackoverflow occurs.
Best,
Alex