Click to See Complete Forum and Search --> : Use a form as subform (as control)
jkristia
March 9th, 2006, 11:45 AM
I have several places where I use a form as a subform, by simply set the border to none and toplevel = false.
Now, the problem is that I can’t TAB out of the form. In MFC there is a style called DS_CONTROL which can be used for this. I tried to enable WS_EX_CONTROLPARENT but that didn’t work.
What is the flag I need to enable to make a form behave as a control I can tab in or out of when placed on another form?
Thanks
Jesper
jkristia
March 9th, 2006, 12:24 PM
If I change it from From to Control, then it works correct. Anyone know which flag I have to disable to get the correct behavior if I derive from Form ?
Jesper
jhammer
March 9th, 2006, 01:12 PM
I am wondering why do you need to use a form in the first place.
Create a UserControl and save yourself the trouble.
Only my opinion.
jkristia
March 9th, 2006, 01:25 PM
I don't have to, I have already changed my 20+ Forms to derive from UserControl instead. The only thing that I think is missing from UserControl at design time is the Text, I have several places where I use the Text of the form as the text for either the Tab, tree node, selection caption etc, but of course that is not a big deal, just have set it after InitializeComponet.
But I'm still wondering how to get a Form to behave correct. See I have several controls (ViewCtrl, TreeDialog, WizardDlg etc) which all takes any kind of Control derived objects, and if it is a Form derive, then turns off the Border and TopLevel. So for these controls you can add either a Form or a UserControl as the 'page' it doesn't matter - except, if you use a Form then you don't get the correct Tab behavior, and since others are using these controls, I can go and ask all of them to change their Forms to UserControls (or at least I would prefer if I could handle it internally in the controls)
Jesper
jhammer
March 10th, 2006, 03:03 AM
I don't have to, I have already changed my 20+ Forms to derive from UserControl instead. The only thing that I think is missing from UserControl at design time is the Text, I have several places where I use the Text of the form as the text for either the Tab, tree node, selection caption etc, but of course that is not a big deal, just have set it after InitializeComponet.
If you set the BorderStyle to None, then you don't have the Text displayed. So I am guessing the you need the Text in order to use it in the container.
Each UserControl has a Text property. You can declare as many properties as you wish (for example: HeaderText). So I still don't see the problem.
jkristia
March 10th, 2006, 11:42 AM
ok, my controls takes any control derived objects, and I use the text field for the caption, tab, treenode name etc, but I don't care if a Form or a UserControl is passed. If a Form is passed, then my control sets for border to none, it's not from the designer I'm taking about. So the designer of a Form can set the Text in te designer, and when passed in to my controls I use that text and clears the border.
But that is not the point, the point is that some are passing Forms instead of UserControls, and I would like to be able to show that Form with the same behavior as as UserControl.
It must be possible somehow. It's not a problem whether I should accept only UserControl derived objects or not, I want to be able to show either - with same behavior.
Anyone know how to change a Form so it gets the correct Tab behavior ?
Jesper
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.