Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SSTab Question

Status
Not open for further replies.

WebGuyToo

Programmer
Aug 18, 2004
124
US
Does anyone know how to insert or add a new or sub form in a SSTab control?

Any ideas would be greatly appreciated.

WebGuyToo
 
To apply a subform to a tab control, place a picture box on your form where you want the subform to be on your tab.

Place this code in a bas module:
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Private Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Declare Sub SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)

Private Const GWL_STYLE = (-16)
Private Const GWL_HWNDPARENT = (-8)
Private Const WS_CHILD = &H40000000
Private Const HWND_TOP = 0&
Private Const SWP_NOZORDER = &H4
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_SHOWWINDOW = &H40

Public Sub OpenSubForm(SubForm As Form, HostHWND As Long)
'***********************************************************************

Dim DispRec As RECT
Dim Style As Long
' Get Display Rectangle dimentions
GetClientRect HostHWND, DispRec
' Load subform
Load SubForm
' Get current window style
Style = GetWindowLong(SubForm.hwnd, GWL_STYLE)
' Append "WS_CHILD" style to the hWnd window style
Style = Style Or WS_CHILD
' Add new style to window
SetWindowLong SubForm.hwnd, GWL_STYLE, Style
' Set host window as parent window
SetParent SubForm.hwnd, HostHWND
' Save the hWnd Parent in hWnd's window struct.
SetWindowLong SubForm.hwnd, GWL_HWNDPARENT, HostHWND
' Save the hWnd Parent in hWnd's window struct.
' Display the subform
SetWindowPos SubForm.hwnd, _
HWND_TOP, 0&, 0&, DispRec.Right, DispRec.Bottom, _
SWP_NOZORDER Or SWP_NOACTIVATE Or SWP_SHOWWINDOW

End Sub

Finally, create the borderless form as your subform.
Attach your form to the tabbed control calling the opensubform like this:

OpenSubForm frmName, Picture1.hwnd

Hope that answered your question.
 
thanks tcode... I'll give it a try. I know who you are, but I wont give away your identity.

WebGuyToo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top