CHILD FORM

Started by paulDiagnos, November 26, 2008, 01:49:39 PM

Previous topic - Next topic

paulDiagnos

Hi Guys,

Has anyone got an example of trying to use the custom control to display a child form?

what i have produced so far that doesnt work is as follows...

'------------------------------------------------------------------------------------------------------------------------
Function OPTIONS_CUSTOMCONTROL1_INIT ( _
                                     ClassName   As Asciiz, _  ' windows class
                                     Caption     As Asciiz, _  ' window caption
                                     hWndParent  As Dword,  _  ' handle of parent window
                                     ExStyles    As Dword,  _  ' extended window styles
                                     Styles      As Dword,  _  ' standard window styles
                                     nLeft       As Dword,  _  ' left position of control
                                     nTop        As Dword,  _  ' top position of control
                                     nWidth      As Dword,  _  ' width of control
                                     nHeight     As Dword   _  ' height of control
                                     ) As Long


   'If your custom control uses CreateWindowEx then use the template below, otherwise
   'follow the instructions provided by the Custom Control's author. The Custom Control
   'INIT function is called during the %WM_CREATE message for the Form on which the
   'Custom Control is created.

   Local hWndControl As Dword

    InitCommonControls
      hWndControl = CreateWindow ("SysHeader32",ByVal %Null, _
                             %WS_CHILD Or %WS_VISIBLE Or  _
                             %HDS_HORZ OR %HDS_BUTTONS, _
                             nLeft, nTop, nWidth, nHeight, _
                             hWndParent,ByVal hwnd_sett,0,ByVal %Null)
     
     
   'It is important that this function return the Windows Handle to the newly created Control *** Do not delete this ***.
   Function = hWndControl


The idea i had was that hwnd_sett could be varied so i can load any child form i want into the custom control.  similar to tabs, but dont want tabs!!

cheers paul.

TechSupport

Hi Paul,

I don't think that I would use a child control to load your child Forms. Personally, I would load the forms in the WM_CREATE message handler of your main form and then show the child form as you need it.

Check out the demo project attached to this post. It is something that I wrote a long time ago to demonstrate this. I use child forms in my main forms all the time. It is a great way to group a whole mess of controls together and show/hide them as needed.

paulDiagnos

Fantastic.
I shall have a gander but looks exactly what I wanted.

Paul.

paulDiagnos

Works like a dream...

just one thing to note if its useful for other people
make the child form, a tabcontrolchild = %true.

cheers again
Paul.

TechSupport

Quote from: paulDiagnos on November 27, 2008, 07:21:50 AM
make the child form, a tabcontrolchild = %true.
That is a shortcut to make the form a child without the caption and borders, etc... There is nothing to stop someone from keeping that setting as FALSE and manually adjusting the other settings. Personally, I use the TabControlChild = %TRUE method because it is quicker.  :)