Hide

SftTabs/OCX 6.5 - Tab Control for VB6

Display
Print

Images Sample (VB6)

This sample demonstrates image manipulation techniques.

The source code is located at C:\Program Files (x86)\Softelvdm\SftTabs OCX 6.5\Samples\Images\Form1.frm or C:\Program Files\Softelvdm\SftTabs OCX 6.5\Samples\Images\Form1.frm (on 32-bit Windows versions).

Option Explicit

Private Sub Form_Load()
    If Not SftTabs1.GDIPlusSupport Then
        MsgBox ("This sample requires GDI+ support. Sorry.")
        End
    End If
    SftTabs1_Switched
End Sub

Private Sub CloseButton_Click()
    End
End Sub

Private Sub PrevButton_Click()
    SftTabs1.Tabs.Previous
End Sub

Private Sub NextButton_Click()
    SftTabs1.Tabs.Next
End Sub

Private Sub SftTabs1_Switched()
    ' update next/previous button status
    PrevButton.Enabled = (SftTabs1.Tabs.Current > 0)
    NextButton.Enabled = (SftTabs1.Tabs.Current < SftTabs1.Tabs.Count - 1)
    ' here we always enable the tab used to show image states
    ' the tab might be disabled as the user switches away. To insure that
    ' we can switch back, we have to enable it. As the tab may be moved (as
    ' other tabs are inserted, we locate the tab by name instead of its index
    Dim tb As SftTabsTab
    Set tb = SftTabs1.TabByName("ImageSampleTab")
    tb.Enabled = True
End Sub

Private Sub LoadGDIPImgButton_Click()
    ' Load a GDI+ image
    CommonDialog1.Flags = cdlOFNExplorer Or cdlOFNFileMustExist
    CommonDialog1.FileName = ""
    CommonDialog1.ShowOpen
    If CommonDialog1.FileName <> "" Then
        On Error GoTo errorexit
        SftTabs1.Tab(SftTabs1.Tabs.Current).Image.LoadImage CommonDialog1.FileName, True
    End If
    Exit Sub

errorexit:
    MsgBox (Err.Description)
End Sub

Private Sub CheckboxButton_Click()
    ' define a checkbox image
    Dim tb As SftTabsTab
    Dim img As SftPictureObject
    Set tb = SftTabs1.Tab(SftTabs1.Tabs.Current)
    Set img = tb.Image
    SftTabs1.BulkUpdate = True
    img.Clear
    img.Appearance = sftImageCheckboxYes
    tb.Align = alignSftTabsLeft
    SftTabs1.BulkUpdate = False
End Sub

Private Sub SftTabs1_TabClicked(ByVal DblClick As Boolean, ByVal TabClicked As Integer, ByVal TabArea As SftTabsLib.SftTabsTabAreaConstants)
    ' a tab has been clicked
    ' check if a checkbox was clicked. If so, toggle it and prevent tab switching
    If TabArea = tabareaSftTabsImage Then
        Dim tb As SftTabsTab
        Set tb = SftTabs1.Tab(TabClicked)
        If tb.Image.Appearance = sftImageCheckboxYes Then
            tb.Image.Appearance = sftImageCheckboxNo
            SftTabs1.CancelMode
        ElseIf tb.Image.Appearance = sftImageCheckboxNo Then
            tb.Image.Appearance = sftImageCheckboxYes
            SftTabs1.CancelMode
        End If
    End If
End Sub

Private Sub ColorSampleButton_Click()
    ' define a colorsample image
    Dim tb As SftTabsTab
    Dim img As SftPictureObject
    Set tb = SftTabs1.Tab(SftTabs1.Tabs.Current)
    Set img = tb.Image
    SftTabs1.BulkUpdate = True
    img.Clear
    img.SetColorSample vbBlue, vbRed
    img.Height = 16
    img.Width = 32
    tb.Align = alignSftTabsBottomGraph
    SftTabs1.BulkUpdate = False
End Sub

Private Sub ImageListButton_Click()
    ' define an image using an image list
    Dim tb As SftTabsTab
    Dim img As SftPictureObject
    Set tb = SftTabs1.Tab(SftTabs1.Tabs.Current)
    Set img = tb.Image
    SftTabs1.BulkUpdate = True
    img.Clear
    img.SetImageList ImageList1, 1
    tb.Align = alignSftTabsTopGraph
    SftTabs1.BulkUpdate = False
End Sub

Private Sub EnableCurrentTab_Click()
    Dim tb As SftTabsTab
    Set tb = SftTabs1.Tab(SftTabs1.Tabs.Current)
    tb.Enabled = Not tb.Enabled
End Sub

Private Sub SwitchStyleButton_Click()
    SftTabs1.BulkUpdate = True
    If SftTabs1.Style = styleSftTabsModernTop Then
        SftTabs1.Style = styleSftTabsButtonsTop
        SftTabs1.Tabs.Rows = 2
    ElseIf SftTabs1.Style = styleSftTabsButtonsTop Then
        SftTabs1.Style = styleSftTabsModernTop
        SftTabs1.Tabs.Rows = 1
    End If
    SftTabs1.BulkUpdate = False
End Sub

Last Updated 08/13/2020 - (email)
© 2024 Softel vdm, Inc.