Results 1 to 15 of 15

Thread: VB6 Tab Control

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2018
    Posts
    32

    VB6 Tab Control

    Finally I could made a Tabcontrol that we can add controls as in MS tab control.
    Features
    • Design time Tabbing
    • Tab Reordering
    • Scrolling Spinner
    • Enable Disable Tabs
    • Skin Support

    Removed exe from attachment
    Attached Images Attached Images  
    Attached Files Attached Files
    Last edited by joshyfrancis; May 7th, 2019 at 04:08 AM. Reason: just changed the title as per the guidelines.

  2. #2

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2018
    Posts
    32

    Smile Re: Tab Control

    Thanks

  4. #4
    Hyperactive Member
    Join Date
    Jun 2016
    Location
    EspaƱa
    Posts
    506

    Re: Tab Control

    very good control I like it a lot and it seems simple.
    but there is a problem in the attachment there is an .exe delete it and upload it again, if you can not delete the post, executables or binaries are not allowed.


    a greeting

  5. #5
    Frenzied Member
    Join Date
    Dec 2008
    Location
    Melbourne Australia
    Posts
    1,487

    Re: Tab Control

    I just came across this in PSC, and downloaded it.
    Noticed it uses subclassing and traced that portion to wqweto's codebank entry.

    When first loading it (the PSC download), I did my usual 'KISS' check to see if it had any dependencies (which I like to minimize/avoid).
    Noticed it had a reference to DAO, which i unticked (I assumed it was a left over that is not needed),
    As I unticked it (DAO), the Form (or at least all of the Tab .ctl's) all glazed over with that zebra striped look saying 'I am now untouchable'
    Is that a portend of what may happen in the future (in one of my larger important projects) ?
    Sorry to look a gift horse(zebra) in the stripes,
    Rob

  6. #6

    Thread Starter
    Member
    Join Date
    Jan 2018
    Posts
    32

    Re: Tab Control

    Quote Originally Posted by Bobbles View Post

    When first loading it (the PSC download), I did my usual 'KISS' check to see if it had any dependencies (which I like to minimize/avoid).
    Noticed it had a reference to DAO, which i unticked (I assumed it was a left over that is not needed),
    As I unticked it (DAO), the Form (or at least all of the Tab .ctl's) all glazed over with that zebra striped look saying 'I am now untouchable'
    Is that a portend of what may happen in the future (in one of my larger important projects) ?
    Sorry to look a gift horse(zebra) in the stripes,
    Rob
    About zebra stripes:
    Don't worry, please close the form design view and open it again. We don't need any references. When we add/remove any reference or activex control , usercontrols in forms become like this.

  7. #7
    Lively Member
    Join Date
    Aug 2017
    Posts
    75

    Re: VB6 Tab Control

    Very good, but there is a bug that I can't fix, there is a red border when it is resized and that persists even when I minimize the vb6, only leaving when I close the vb6

    Name:  screenshot.93.jpg
Views: 4306
Size:  77.4 KB

    Name:  screenshot.94.jpg
Views: 4263
Size:  21.9 KB

  8. #8
    Lively Member
    Join Date
    Aug 2017
    Posts
    75

    Re: VB6 Tab Control

    I found something
    Last edited by germano.barbosa; Feb 27th, 2020 at 05:27 PM.

  9. #9
    Lively Member
    Join Date
    Aug 2017
    Posts
    75

    Re: VB6 Tab Control

    I managed to fix it

    Code:
    Public Function SubclassProc(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long, Handled As Boolean) As Long
    'Dim x As Single
    'Dim y As Single
    '
    '    Select Case wMsg
    '        Case WM_LBUTTONDOWN
    '            x = (lParam And &HFFFF&)
    '            y = (lParam \ &H10000 And &HFFFF&)
    '
    '    End Select
    '    '--- note: performance optimization for design-time subclassing
    '    If Not Handled And ThunkPrivateData(m_pSubclass) = EBMODE_DESIGN Then
    '        Handled = True
    '        SubclassProc = DefSubclassProc(hwnd, wMsg, wParam, lParam)
    '    End If
        If mUserMode = True Then
            Handled = True
            SubclassProc = DefSubclassProc(hwnd, wMsg, wParam, lParam)
            Exit Function
        End If
    
    Dim lTab As Long
    Dim x As Single
    Dim y As Single
        Select Case wMsg
             Case WM_LBUTTONDOWN ' UserControl message, only in design mode (Not Ambient.UserMode), to provide change of selected tab by clicking at design time
        '            If TypeOf UserControl.Parent Is Form Then
        '                 UserControl.Parent.Caption = Timer
        '            End If
    '                If Not MouseIsOverAContainedControl Then
                        lTab = selIndex
        '                Call ProcessMouseMove(vbLeftButton, 0, (lParam And &HFFFF&) * Screen_TwipsPerPixelX, (lParam \ &H10000 And &HFFFF&) * Screen_TwipsPerPixelX)
        '                    X = (lParam And &HFFFF&) * Screen_TwipsPerPixelX
        '                    Y = (lParam \ &H10000 And &HFFFF&) * Screen_TwipsPerPixely
                            x = (lParam And &HFFFF&)
                            y = (lParam \ &H10000 And &HFFFF&)
        '                    UserControl.Parent.Caption = "X " & X & " Y " & Y
                        Call UserControl_MouseDown(vbLeftButton, -1, x, y)
                        If selIndex <> lTab Then
                            Handled = True
                            SubclassProc = 0
                            Exit Function
                        End If
    '                End If
        '            If mChangeControlsBackColor And (mTabBackColor <> vbButtonFace) Then
        '                mLastContainedControlsCount = UserControl.ContainedControls.Count
        '                tmrCheckContainedControlsAdditionDesignTime.Enabled = True
        '            End If
        End Select
            Handled = True '<<<< changed here
            SubclassProc = DefSubclassProc(hwnd, wMsg, wParam, lParam)
    
    End Function
    But there is another bug, after that change, it works fine, but
    if i resize the tab control down during design time, the tab's buttons stop refreshing.
    Closing the designer window and opening it makes go back to refreshing.
    It works correctly on run time, even if resized down.

  10. #10

    Thread Starter
    Member
    Join Date
    Jan 2018
    Posts
    32

    Re: VB6 Tab Control

    Quote Originally Posted by germano.barbosa View Post

    But there is another bug, after that change, it works fine, but
    if i resize the tab control down during design time, the tab's buttons stop refreshing.
    Closing the designer window and opening it makes go back to refreshing.
    It works correctly on run time, even if resized down.
    Code:
    Private Sub UserControl_Resize()
    On Error Resume Next
        CreateGraphicsDC
     'Uncomment below line
            Draw
            Me.Refresh
    End Sub
    If the above solution doesn't work, please check your VB6 compatibility

    Name:  VB6 compatibility.jpg
Views: 4367
Size:  36.7 KB

  11. #11
    Addicted Member
    Join Date
    Jun 2010
    Posts
    182

    Re: VB6 Tab Control

    Hi and thanks for this great achievement! I have one problem though. When I run my VB project and then click on a tab, the view changes correctly and displays controls in the 2nd container, but the tab doesn't change and remains blue and the previous tab stays orange. In the IDE designer it behaves as it should, it's only when I run the project it doesn't work.

    I created a test project with a tabcontrol and added exact same controls to the container and then it runs fine, so appears to be some conflict with my project code. Any idea what could possibly cause this or exactly where in your code this could go wrong?
    M$ vs. VB6 = The biggest betrayal and strategic mistake of the century!?

  12. #12
    Addicted Member
    Join Date
    Jun 2010
    Posts
    182

    Re: VB6 Tab Control

    Some follow up on my previous post. Just to test I added a TabControl to another simpler form in my project and here the control seems to work, except for that the bottom line of the border rectangle is cut off. I also added a second control to the problematic form and just dropped some label controls on these tabs to demonstrate the issue in the attached image. The tab on the red background is on the second, working form, here opened in front of the non-working..

    Name:  tabissue.jpg
Views: 4010
Size:  22.7 KB

    Both controls here show the container for Tab 2, and apart from that Tab 1 still seems to be selected on the left control, there is one more detail I have noticed. As you can see on the right side control, the Tab 2 caption has a focus rectangle after it has been clicked, this never appears on the control on the problematic form. So my conclusion is that it has to be some kind of focus issue.

    One more thing, as you can see on the left control the border rectangle's bottom line is stuck with rest of the control flowing outside. THis seems to happen when site control on the form and size it beyond a certain size, not only when you resize it after sitting. As you pointed out elsewhere, closing the form and reopen it solves the issue both in the designer and at run time. However, and this may be related to the above, after closing and reopen the form of left control the problem was solved in the designer, but at run time the border issue is still there. Same happens with the original control I sited on same form, but it's much larger so have excluded it from the image. However, this border issue seems to be "proportional" in relation to the size of the sited control.

    OK I will leave it there and continue to investigate if I can figure out what happens, but if you have any idea of what may go on or where to look/test/debug it would be appreciated.
    M$ vs. VB6 = The biggest betrayal and strategic mistake of the century!?

  13. #13

    Thread Starter
    Member
    Join Date
    Jan 2018
    Posts
    32

    Re: VB6 Tab Control

    Quote Originally Posted by 7edm View Post
    Some follow up on my previous post. Just to test I added a TabControl to another simpler form in my project and here the control seems to work, except for that the bottom line of the border rectangle is cut off. I also added a second control to the problematic form and just dropped some label controls on these tabs to demonstrate the issue in the attached image. The tab on the red background is on the second, working form, here opened in front of the non-working..

    Name:  tabissue.jpg
Views: 4010
Size:  22.7 KB

    Both controls here show the container for Tab 2, and apart from that Tab 1 still seems to be selected on the left control, there is one more detail I have noticed. As you can see on the right side control, the Tab 2 caption has a focus rectangle after it has been clicked, this never appears on the control on the problematic form. So my conclusion is that it has to be some kind of focus issue.

    One more thing, as you can see on the left control the border rectangle's bottom line is stuck with rest of the control flowing outside. THis seems to happen when site control on the form and size it beyond a certain size, not only when you resize it after sitting. As you pointed out elsewhere, closing the form and reopen it solves the issue both in the designer and at run time. However, and this may be related to the above, after closing and reopen the form of left control the problem was solved in the designer, but at run time the border issue is still there. Same happens with the original control I sited on same form, but it's much larger so have excluded it from the image. However, this border issue seems to be "proportional" in relation to the size of the sited control.

    OK I will leave it there and continue to investigate if I can figure out what happens, but if you have any idea of what may go on or where to look/test/debug it would be appreciated.
    Hi, Thank you for your interest in this project. Can you please attach the problematic forms here with source code so that I may check and reproduce the conditions that caused the bug.

  14. #14
    Addicted Member
    Join Date
    Jun 2010
    Posts
    182

    Re: VB6 Tab Control

    Hi Joshyfrancis,

    I felt like I don't have time to deal with this right now, so decided to try out Eduardo's SSTabEx control instead, which seems to work so will stick with that for the time being. I still like your control and may try it in another project, and also when I have more time to dive into the control code as well. Keep up the good work.
    M$ vs. VB6 = The biggest betrayal and strategic mistake of the century!?

  15. #15
    Addicted Member
    Join Date
    Jan 2010
    Posts
    250

    Re: VB6 Tab Control

    just want to request, for each tab ..please add close button on each tab. much like delphi tab

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