CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2000
    Posts
    114

    Use a form as subform (as control)

    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

  2. #2
    Join Date
    Mar 2000
    Posts
    114

    Re: Use a form as subform (as control)

    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

  3. #3
    Join Date
    Feb 2005
    Location
    Israel
    Posts
    1,475

    Re: Use a form as subform (as control)

    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.

  4. #4
    Join Date
    Mar 2000
    Posts
    114

    Re: Use a form as subform (as control)

    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

  5. #5
    Join Date
    Feb 2005
    Location
    Israel
    Posts
    1,475

    Re: Use a form as subform (as control)

    Quote Originally Posted by jkristia
    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.

  6. #6
    Join Date
    Mar 2000
    Posts
    114

    Re: Use a form as subform (as control)

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured