SftTree/DLL 7.5 - Tree Control
SftBox/OCX 5.0 - Combo Box Control
SftButton/OCX 3.0 - Button Control
SftMask/OCX 7.0 - Masked Edit Control
SftTabs/OCX 6.5 - Tab Control (VB6 only)
SftTree/OCX 7.5 - Tree Control
SftPrintPreview/DLL 2.0 - Print Preview Control (discontinued)
SftTree/DLL 7.5 - Tree Control
SftBox/OCX 5.0 - Combo Box Control
SftButton/OCX 3.0 - Button Control
SftDirectory 3.5 - File/Folder Control (discontinued)
SftMask/OCX 7.0 - Masked Edit Control
SftOptions 1.0 - Registry/INI Control (discontinued)
SftPrintPreview/OCX 1.0 - Print Preview Control (discontinued)
SftTabs/OCX 6.5 - Tab Control (VB6 only)
SftTree/OCX 7.5 - Tree Control
SftTabs/NET 6.0 - Tab Control (discontinued)
SftTree/NET 2.0 - Tree Control
This sample demonstrates the Main form of an MDI application with a tab control used to switch between documents.
Also see MDITab Document Form
The source code is located at C:\Program Files (x86)\Softelvdm\SftTabs OCX 6.5\Samples\MDITab\frmMain.frm or C:\Program Files\Softelvdm\SftTabs OCX 6.5\Samples\MDITab\frmMain.frm (on 32-bit Windows versions).
' Most of the code shown implements a very simple MDI style application
' To find the code which handles tab switching and tab management, search for
' SftTabs1. Actually, don't be surprised if you find very little code.
' Make sure to also look at the code for the Form "frmDocument".
Private Declare Function OSWinHelp% Lib "user32" Alias "WinHelpA" (ByVal hwnd&, ByVal HelpFile$, ByVal wCommand%, dwData As Any)
Private Sub MDIForm_Load()
Me.Left = GetSetting(App.Title, "Settings", "MainLeft", 1000)
Me.Top = GetSetting(App.Title, "Settings", "MainTop", 1000)
Me.Width = GetSetting(App.Title, "Settings", "MainWidth", 6500)
Me.Height = GetSetting(App.Title, "Settings", "MainHeight", 6500)
LoadNewDoc
' Resize the tab control's height so it uses the least amount
' of space possible
SftTabs1.MakeNaturalSize
MsgBox ("Please use File, New to add documents. Notice how the tab" & _
" control shows the name of each document.")
End Sub
Private Sub LoadNewDoc()
Static lDocumentCount As Long
Dim frmD As frmDocument
Dim iTab As Integer
lDocumentCount = lDocumentCount + 1
Set frmD = New frmDocument
frmD.Caption = "Document " & lDocumentCount
frmD.Show
' Add a new tab associated with this MDI child window
' We'll save a reference to the form object in the tab's Tag1
' property
With SftTabs1.Direct
' add the tab
iTab = .Tabs.Add(frmD.Caption)
' define colors
.Tab(iTab).BackColorStart = &HFEECDD
.Tab(iTab).BackColorEnd = &HE2A981
.Tab(iTab).BackColor = &HE2A981
.Tab(iTab).BackColorActiveStart = &HFEECDD
.Tab(iTab).BackColorActiveEnd = &HE2A981
.Tab(iTab).BackColorActive = &HE2A981
' define a close button for the tab
.Tab(iTab).CloseButton = True
' define a tooltip for the tab
.Tab(iTab).ToolTip = "This tab activates the form named " & frmD.Caption
' and save a reference to the MDI child form object that this
' tab represents
.Tab(iTab).Tag1 = frmD
.Tabs.Current = iTab ' make this the current tab
End With
End Sub
Private Sub OpenDoc(ByVal Name As String)
Dim frmD As frmDocument
Dim iTab As Integer
Set frmD = New frmDocument
frmD.Caption = Name
frmD.Show
' Add a new tab associated with this MDI child window
' We'll save a reference to the form object in the tab's Tag1
' property
With SftTabs1.Direct
' add the tab
iTab = .Tabs.Add(frmD.Caption)
' define colors
.Tab(iTab).BackColorStart = &HFEECDD
.Tab(iTab).BackColorEnd = &HE2A981
.Tab(iTab).BackColor = &HE2A981
.Tab(iTab).BackColorActiveStart = &HFEECDD
.Tab(iTab).BackColorActiveEnd = &HE2A981
.Tab(iTab).BackColorActive = &HE2A981
' define a close button for the tab
.Tab(iTab).CloseButton = True
' define a tooltip for the tab
.Tab(iTab).ToolTip = "This tab activates the form named " & frmD.Caption
' and save a reference to the MDI child form object that this
' tab represents
.Tab(iTab).Tag1 = frmD
End With
End Sub
Private Sub MDIForm_Unload(Cancel As Integer)
If Me.WindowState <> vbMinimized Then
SaveSetting App.Title, "Settings", "MainLeft", Me.Left
SaveSetting App.Title, "Settings", "MainTop", Me.Top
SaveSetting App.Title, "Settings", "MainWidth", Me.Width
SaveSetting App.Title, "Settings", "MainHeight", Me.Height
End If
End Sub
Private Sub mnuHelpAbout_Click()
MsgBox "About Box Code goes here!"
End Sub
Private Sub SftTabs1_Switched()
With SftTabs1.Direct
' The user has clicked on the tab control and the
' matching MDI child has to be made active
' We have saved a reference to the form object in
' the tab's Tag1 property of the tab control.
If .Tabs.Current >= 0 Then
.Tab(.Tabs.Current).Tag1.SetFocus
End If
End With
End Sub
Private Sub SftTabs1_TabClicked(ByVal DblClick As Boolean, ByVal TabClicked As Integer, ByVal TabArea As SftTabsLib.SftTabsTabAreaConstants)
With SftTabs1.Direct
If TabArea = tabareaSftTabsImage2 Then
' The user clicked the close button
.CancelMode ' make sure the tab control doesn't further handle this click event
' first activate the tab (and the associated form)
.Tabs.Current = TabClicked
' and unload the form
Unload Me.ActiveForm
End If
End With
End Sub
Private Sub tbToolBar_ButtonClick(ByVal Button As ComctlLib.Button)
Select Case Button.Key
Case "New"
LoadNewDoc
Case "New"
mnuFileNew_Click
Case "Open"
mnuFileOpen_Click
Case "Save"
mnuFileSave_Click
Case "Print"
mnuFilePrint_Click
Case "Cut"
mnuEditCut_Click
Case "Copy"
mnuEditCopy_Click
Case "Paste"
mnuEditPaste_Click
Case "Bold"
'To Do
MsgBox "Bold Code goes here!"
Case "Italic"
'To Do
MsgBox "Italic Code goes here!"
Case "Underline"
'To Do
MsgBox "Underline Code goes here!"
Case "Left"
'To Do
MsgBox "Left Code goes here!"
Case "Center"
'To Do
MsgBox "Center Code goes here!"
Case "Right"
'To Do
MsgBox "Right Code goes here!"
End Select
End Sub
Private Sub mnuHelpContents_Click()
Dim nRet As Integer
'if there is no helpfile for this project display a message to the user
'you can set the HelpFile for your application in the
'Project Properties dialog
If Len(App.HelpFile) = 0 Then
MsgBox "Unable to display Help Contents. There is no Help associated with this project.", vbInformation, Me.Caption
Else
On Error Resume Next
nRet = OSWinHelp(Me.hwnd, App.HelpFile, 3, 0)
If Err Then
MsgBox Err.Description
End If
End If
End Sub
Private Sub mnuHelpSearch_Click()
Dim nRet As Integer
'if there is no helpfile for this project display a message to the user
'you can set the HelpFile for your application in the
'Project Properties dialog
If Len(App.HelpFile) = 0 Then
MsgBox "Unable to display Help Contents. There is no Help associated with this project.", vbInformation, Me.Caption
Else
On Error Resume Next
nRet = OSWinHelp(Me.hwnd, App.HelpFile, 261, 0)
If Err Then
MsgBox Err.Description
End If
End If
End Sub
Private Sub mnuWindowArrangeIcons_Click()
Me.Arrange vbArrangeIcons
End Sub
Private Sub mnuWindowCascade_Click()
Me.Arrange vbCascade
End Sub
Private Sub mnuWindowNewWindow_Click()
'To Do
MsgBox "New Window Code goes here!"
End Sub
Private Sub mnuWindowTileHorizontal_Click()
Me.Arrange vbTileHorizontal
End Sub
Private Sub mnuWindowTileVertical_Click()
Me.Arrange vbTileVertical
End Sub
Private Sub mnuEditCopy_Click()
'To Do
MsgBox "Copy Code goes here!"
End Sub
Private Sub mnuEditCut_Click()
'To Do
MsgBox "Cut Code goes here!"
End Sub
Private Sub mnuEditPaste_Click()
'To Do
MsgBox "Paste Code goes here!"
End Sub
Private Sub mnuEditPasteSpecial_Click()
'To Do
MsgBox "Paste Special Code goes here!"
End Sub
Private Sub mnuEditUndo_Click()
'To Do
MsgBox "Undo Code goes here!"
End Sub
Private Sub mnuFileOpen_Click()
Dim sFile As String
With dlgCommonDialog
'To Do
'set the flags and attributes of the
'common dialog control
.Filter = "All Files (*.*)|*.*"
.ShowOpen
If Len(.FileName) = 0 Then
Exit Sub
End If
sFile = .FileName
End With
'process the opened file
OpenDoc (sFile)
End Sub
Private Sub mnuFileClose_Click()
'To Do
Unload Me.ActiveForm
End Sub
Private Sub mnuFileSave_Click()
'To Do
MsgBox "Save Code goes here!"
End Sub
Private Sub mnuFileSaveAs_Click()
'To Do
'Setup the common dialog control
'prior to calling ShowSave
dlgCommonDialog.ShowSave
End Sub
Private Sub mnuFileSaveAll_Click()
'To Do
MsgBox "Save All Code goes here!"
End Sub
Private Sub mnuFileProperties_Click()
'To Do
MsgBox "Properties Code goes here!"
End Sub
Private Sub mnuFilePageSetup_Click()
dlgCommonDialog.ShowPrinter
End Sub
Private Sub mnuFilePrintPreview_Click()
'To Do
MsgBox "Print Preview Code goes here!"
End Sub
Private Sub mnuFilePrint_Click()
'To Do
MsgBox "Print Code goes here!"
End Sub
Private Sub mnuFileSend_Click()
'To Do
MsgBox "Send Code goes here!"
End Sub
Private Sub mnuFileMRU_Click(Index As Integer)
'To Do
MsgBox "MRU Code goes here!"
End Sub
Private Sub mnuFileExit_Click()
'unload the form
Unload Me
End Sub
Private Sub mnuFileNew_Click()
LoadNewDoc
End Sub
