CommonControls (Replacement of the MS common controls) - Page 45-VBForums
Page 45 of 46 FirstFirst ... 354243444546 LastLast
Results 1,761 to 1,800 of 1826

Thread: CommonControls (Replacement of the MS common controls)

  1. #1761
    Hyperactive Member
    Join Date
    Apr 2015
    Posts
    256

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Eduardo- View Post
    That's not what happens to me.
    Eduardo, Krool is right.
    In here, it also happens with your example.
    Not always.

    Krool's suggestion to do the selection on MouseUp helps, kind of.

    As we must be able to set the focus by Tab key, we need the GotFocus event.
    Works good.
    But when we set the focus by mouse, the GotFocus kicks in, and does something which is not ok.
    No problem, MouseUp cures it.

    But it doesn't look clean, we can see the selection change from GotFocus to MouseUp.

    I remember there is a possibility to check HOW a control got the focus.
    http://www.devx.com/vb2themax/Tip/18274

    EDIT:
    Solved.
    We just need to invoke the selection routine in both GotFocus and MouseUp.
    See attached project.
    Textbox problem SOLVED.zip.docx

    Sorry Krool for the suspicion on your control.
    Last edited by Karl77; Sep 20th, 2017 at 04:56 AM.

  2. #1762

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2012
    Posts
    827

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Karl77 View Post
    As we must be able to set the focus by Tab key, we need the GotFocus event.
    Works good.
    But when we set the focus by mouse, the GotFocus kicks in, and does something which is not ok.
    No problem, MouseUp cures it.

    But it doesn't look clean, we can see the selection change from GotFocus to MouseUp
    That is handled in my example...

    Code:
    Private Sub TextBoxW2_GotFocus()
    If GetMouseStateFromMsg() = 0 Then
        With TextBoxW2
        .SelStart = 0
        .SelLength = Len(.Text)
        .Tag = "Focused"
        End With
    End If
    End Sub

  3. #1763
    Hyperactive Member
    Join Date
    Apr 2015
    Posts
    256

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Krool View Post
    That is handled in my example...

    Code:
    Private Sub TextBoxW2_GotFocus()
    If GetMouseStateFromMsg() = 0 Then
        With TextBoxW2
        .SelStart = 0
        .SelLength = Len(.Text)
        .Tag = "Focused"
        End With
    End If
    End Sub
    Oh well, I didn't see, my eyes only saw the Tag property.
    Sorry again.

  4. #1764
    Fanatic Member
    Join Date
    Feb 2017
    Posts
    536

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Karl77 View Post
    Eduardo, Krool is right.
    In here, it also happens with your example.
    Ah, now I think that you mean that it happens to the standard VB TextBox when the focus comes from a Krool's TexBoxW.
    I didn't test that.

    I tested just with a CommandButton and an UserControl, and it doesn't happen.

    Quote Originally Posted by Karl77 View Post
    Not always.
    Only when the click is long. May be VB checks that if the click doesn't pass the double click time, then it preserves the selection, always (at least here in my machine).
    MSDN online for VB6 - Language Reference - Controls Reference
    Download MSDN October 2001: disk 1, 2 and 3

  5. #1765
    Hyperactive Member
    Join Date
    Apr 2015
    Posts
    256

    Re: CommonControls (Replacement of the MS common controls)

    Pager small error

    I wondered why it is not possible to set the border of a Pager, or the button size.
    To retrace, place a command button on the Pager form in the demo, and try

    Code:
    With Pager1
    .BorderWidth = 5
    .ButtonSize = 200
    End With
    Or use the properties panel.

    Nothing happens, because

    Code:
    Public Property Let BorderWidth(ByVal Value As Single)
    If Value < 0 Then
        If Ambient.UserMode = False Then
            MsgBox "Invalid property value", vbCritical + vbOKOnly
            Exit Property
        Else
            Err.Raise 380
        End If
    End If
    Dim IntValue As Integer, ErrValue As Long
    On Error Resume Next
    IntValue = CInt(UserControl.ScaleX(Value, vbContainerSize, vbPixels))
    ErrValue = Err.Number
    On Error GoTo 0
    If IntValue >= 0 And ErrValue = 0 Then
        PropBorderWidth = IntValue
        If PagerHandle <> 0 Then
            SendMessage PagerHandle, PGM_SETBORDER, 0, ByVal PropBorderWidth
            Me.Refresh
        End If
    Else
        If Ambient.UserMode = False Then
            MsgBox "Invalid property value", vbCritical + vbOKOnly
            Exit Property
        Else
            Err.Raise 380
        End If
    End If
    UserControl.PropertyChanged "BorderWidth"
    End Property
    Something is wrong with IntValue.
    If I, just for a test, use Value, then something happens.

    ---

    Perhaps there are some more 'instances' of this.

    Name:  VBF4.jpg
Views: 236
Size:  50.4 KB



    Karl
    Last edited by Karl77; Sep 21st, 2017 at 05:11 AM. Reason: I wrote nonsense before

  6. #1766

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2012
    Posts
    827

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Karl77 View Post
    Pager small error

    I wondered why it is not possible to set the border of a Pager, or the button size.
    To retrace, place a command button on the Pager form in the demo, and try

    Code:
    With Pager1
    .BorderWidth = 5
    .ButtonSize = 200
    End With
    Or use the properties panel.

    Nothing happens, because

    Code:
    Public Property Let BorderWidth(ByVal Value As Single)
    If Value < 0 Then
        If Ambient.UserMode = False Then
            MsgBox "Invalid property value", vbCritical + vbOKOnly
            Exit Property
        Else
            Err.Raise 380
        End If
    End If
    Dim IntValue As Integer, ErrValue As Long
    On Error Resume Next
    IntValue = CInt(UserControl.ScaleX(Value, vbContainerSize, vbPixels))
    ErrValue = Err.Number
    On Error GoTo 0
    If IntValue >= 0 And ErrValue = 0 Then
        PropBorderWidth = IntValue
        If PagerHandle <> 0 Then
            SendMessage PagerHandle, PGM_SETBORDER, 0, ByVal PropBorderWidth
            Me.Refresh
        End If
    Else
        If Ambient.UserMode = False Then
            MsgBox "Invalid property value", vbCritical + vbOKOnly
            Exit Property
        Else
            Err.Raise 380
        End If
    End If
    UserControl.PropertyChanged "BorderWidth"
    End Property
    Something is wrong with IntValue.
    If I, just for a test, use Value, then something happens.

    ---

    Perhaps there are some more 'instances' of this.

    Name:  VBF4.jpg
Views: 236
Size:  50.4 KB



    Karl
    That's normal. Since the ScaleMode of the Form is Twips a value of 5 results in 0 pixels.

  7. #1767
    Hyperactive Member
    Join Date
    Apr 2015
    Posts
    256

    Re: CommonControls (Replacement of the MS common controls)

    Code:
    That's normal. Since the ScaleMode of the Form is Twips a value of 5 results in 0 pixels.
    Again I was stupid.
    Twips not Pixels.

  8. #1768

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2012
    Posts
    827

    Re: CommonControls (Replacement of the MS common controls)

    Update released.

    The reason why the StatusBar flickers so much because it flashes between erasing (WM_ERASEBKGND) and drawing (WM_PAINT).
    As there was no in-built DoubleBuffer support for the StatusBar it needed to be done manually.
    This was achieved by blocking WM_ERASEBKGND and do the erasing and drawing into a memory DC in WM_PAINT.

  9. #1769

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2012
    Posts
    827

    Re: CommonControls (Replacement of the MS common controls)

    Also updated the ToolBar concerning the DoubleBuffer property.
    The built-in TBSTYLE_EX_DOUBLEBUFFER style is not used anymore. It is now done "manually", likewise as in the StatusBar control now.
    This has the advantage that the BackColor and Transparent property are now also working whe DoubleBuffer is set to True.
    Also it can be used on comctl32 version 5.8x. (TBSTYLE_EX_DOUBLEBUFFER needed version 6.0 or higher)

  10. #1770
    Hyperactive Member
    Join Date
    Apr 2015
    Posts
    256

    Re: CommonControls (Replacement of the MS common controls)

    Spinbox question

    Tried in the 2017-09-22 demo

    I want do disallow the user input by keyboard, only the up/down buttons and the mousewheel shall work.
    Is the Locked property the right one?
    Seems to have no effect...
    And what about HideSelection?
    I see no difference when True/False.

    I assume I'm too blind again, but can't avoid to ask.
    What do I have to do to disable the textbox part for direct input?

    Thanks,
    Karl

  11. #1771

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2012
    Posts
    827

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Karl77 View Post
    I want do disallow the user input by keyboard, only the up/down buttons and the mousewheel shall work.
    Is the Locked property the right one?
    Seems to have no effect...
    And what about HideSelection?
    I see no difference when True/False.
    The Locked property is the right one. On my side it is working. (also the HideSelection property works as expected)

  12. #1772
    Hyperactive Member
    Join Date
    Apr 2015
    Posts
    256

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Krool View Post
    The Locked property is the right one. On my side it is working. (also the HideSelection property works as expected)
    Yes, Locked locks the input.
    But the cursor blinks, also the whole text is selected.
    It looks like an input is possible.
    It gets selected when using the up/down buttons.

    Try with the attached example.

    I get this:
    Name:  VBF6.jpg
Views: 198
Size:  17.0 KB

    Spin.zip

  13. #1773

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2012
    Posts
    827

    Re: CommonControls (Replacement of the MS common controls)

    For those with HideSelection = False did you select the 0 before, because when nothing is selected there is no difference between HideSelection False or True.
    The Locked property works as in the normal TextBox. It is your responsibility to give it a "Locked look" by for example setting BackColor to vbButtonFace.

  14. #1774
    Hyperactive Member
    Join Date
    Apr 2015
    Posts
    256

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Krool View Post
    For those with HideSelection = False did you select the 0 before, because when nothing is selected there is no difference between HideSelection False or True..
    Ok, I didn't understand the meaning of HideSelection, now I do.

    The Locked property works as in the normal TextBox. It is your responsibility to give it a "Locked look" by for example setting BackColor to vbButtonFace.
    Also understood.

    In a normal TextBox I can HideCaret on GotFocus.
    Code:
    Call HideCaret(SpinBox3.hWndEdit)
    Fine.
    Now it doesn't look like as we can type in something.

    When the SpinBox has the focus the border indicates that it has it.
    When I now use the arrow up/down keys or the mousewheel, we can see the changing numbers.
    But when I use the up/down buttons with the mouse, the text gets highlighted.
    Not wanted.

    I tried this, but it has no effect:
    Code:
    Private Sub SpinBox3_TextChange()
    
    Debug.Print "SpinBox3_TextChange"
    
    SpinBox3.SelStart = 0
    SpinBox3.SelLength = 0
    
    Debug.Print "len(SpinBox3.SelText)", Len(SpinBox3.SelText)
    
    End Sub

    Any idea what I can do to remove the highlight when using the buttons?

  15. #1775

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2012
    Posts
    827

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Karl77 View Post
    When the SpinBox has the focus the border indicates that it has it.
    When I now use the arrow up/down keys or the mousewheel, we can see the changing numbers.
    But when I use the up/down buttons with the mouse, the text gets highlighted.
    Not wanted.
    According to MSDN about UpDown controls with edit buddy control:
    "WM_LBUTTONUP: Completes the position change and releases the mouse capture if the up-down control has captured the mouse. If the buddy window is an edit control, it selects all the text in the edit control."

    So you could process the MouseUp event and undo the text highlighting.

    But why you want an locked SpinBox control at all?
    If you do not "trust" user input you can validate the user input right away after every input:
    Code:
    Private Sub SpinBox1_TextChange()
    Static InProc As Boolean
    If InProc = True Then Exit Sub
    InProc = True
    SpinBox1.ValidateText
    InProc = False
    ' other stuff to do
    End Sub
    Or later on:
    Code:
    Private Sub SpinBox1_LostFocus()
    SpinBox1.ValidateText
    End Sub
    Last edited by Krool; Sep 23rd, 2017 at 03:55 PM.

  16. #1776
    Hyperactive Member
    Join Date
    Apr 2015
    Posts
    256

    Re: CommonControls (Replacement of the MS common controls)

    But why you want an locked SpinBox control at all?
    Because it will replace a now existing selfmade spinbox UC (>10 years old).
    And I don't want to change feel.

    I will end up in re-creating my old Spinbox UC.
    It has a feature that is not there in VBCCR:
    Fire the change event after a determined time only.
    This means that when I scroll from 1 to 100, I don't get 100 change events.
    But after let's say after 0.2 sec. from the last real change.

    This 'Change delay' is quite useful when there is more time consuming code to execute.

  17. #1777
    Addicted Member
    Join Date
    Jun 2009
    Location
    C:\Windows\SysWOW64\
    Posts
    218

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Karl77 View Post
    Because it will replace a now existing selfmade spinbox UC (>10 years old).
    And I don't want to change feel.

    I will end up in re-creating my old Spinbox UC.
    It has a feature that is not there in VBCCR:
    Fire the change event after a determined time only.
    This means that when I scroll from 1 to 100, I don't get 100 change events.
    But after let's say after 0.2 sec. from the last real change.

    This 'Change delay' is quite useful when there is more time consuming code to execute.
    You can implement this behavior by putting the time-consuming code in a timer. The timer should be initially disabled, interval=200.
    Then, all you have to do is:

    vb Code:
    1. Private Sub SpinBox1_TextChange()
    2. Timer1.Enabled = False  'Reset timer
    3. Timer1.Enabled = True
    4. End Sub
    5.  
    6. Private Sub Timer1_Timer()
    7. Timer1.Enabled = False
    8.  
    9. 'Your code ...
    10. End Sub
    Last edited by Cube8; Sep 25th, 2017 at 01:55 AM.


  18. #1778
    Hyperactive Member
    Join Date
    Apr 2015
    Posts
    256

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Cube8 View Post
    You can implement this behavior by putting the time-consuming code in a timer. The timer should be initially disabled, interval=200.
    Then, all you have to do is:

    vb Code:
    1. Private Sub SpinBox1_TextChange()
    2. Timer1.Enabled = False  'Reset timer
    3. Timer1.Enabled = True
    4. End Sub
    5.  
    6. Private Sub Timer1_Timer()
    7. Timer1.Enabled = False
    8.  
    9. 'Your code ...
    10. End Sub
    That's what I have in my old ugly UC.
    I would like to have the timer in the UC, because if you have some SpinBoxes on a form, then you need as much timers or a more sophisticated approach.
    Not so comfy and save.

    EDIT:
    Regarding the manual input into the SpinBox, I changed my mind.
    While investigating the old UC, I saw there is the min/max range check already in the change event.
    So no risk to trust the user, the value is always correct.

    EDIT2:
    This automatic 'stay in range' is not given in the VBCCR SpinBox.
    Set Max to 10, and type in 123.
    It can be that that is a correct behavior.
    But correct doesn't always make sense.

    EDIT3:
    The VBCCR SpinBox is far better than mine, no question.
    Mousewheel, arrow keys etc.
    That's why I want to use it instead of my 'solution'.
    Last edited by Karl77; Sep 25th, 2017 at 02:51 AM.

  19. #1779
    Hyperactive Member
    Join Date
    Apr 2015
    Posts
    256

    Re: CommonControls (Replacement of the MS common controls)

    In the end, too easy...

    I can pack the VBCCR Spinbox into an own UC and add the wanted functionality.

    Still don't like that the text gets selected when using the up/down control.
    Ok, I could set the SpinBox text again in it's Change event, but with a delay it doesn't look very well.
    So I leave it as it is.

    This is my solution now:
    DelayedSpin.zip

    EDIT:
    Found a glitch in the VBCCR SpinBox.
    If I paste a value using the context menu, the Change event doesn't fire.
    To retrace:
    Select the text in the SpinBox by mouse.
    Right-click, and Paste.
    As the Change event doesn't come, no chance to check for the Min/Max range.
    Last edited by Karl77; Sep 25th, 2017 at 07:49 AM.

  20. #1780
    Lively Member Hosam AL Dein's Avatar
    Join Date
    Jul 2017
    Location
    Egypt , Cairo
    Posts
    115

    Re: CommonControls (Replacement of the MS common controls)

    I was using a previous version of the ocx . It was the one released about 10 days ago and everything was fine . I have a user control which has a listview .

    I have just updated to the current version and here is what happens :

    If the listview is populated and I end the project by "End" word or even by pressing the "break"command in IDE , VB crashes . This does not happen when the listview is not populated .
    Note 1 I use no subclassing at all .

    Edit 1 : I have no code in form_unload or in usercontrol_terminate

    Edit 2 : the previous version number is
    14-Sep-2017
    - Revision update. (Version 1.4.51)
    Last edited by Hosam AL Dein; Sep 26th, 2017 at 01:45 PM.

  21. #1781

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2012
    Posts
    827

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Karl77 View Post
    EDIT:
    Found a glitch in the VBCCR SpinBox.
    If I paste a value using the context menu, the Change event doesn't fire.
    To retrace:
    Select the text in the SpinBox by mouse.
    Right-click, and Paste.
    As the Change event doesn't come, no chance to check for the Min/Max range.
    It's not a bug. The Change event does only fire when the .Value property changes.

    When I open your project and Paste via ContextMenu a value of 342 the Change event will be fired as the value has changed to 100.
    In case you paste again 342 you get then "342342". However the value has not changed from 100. (equal to Max)
    If you want to catch up everything you need to handle the TextChange event and do .ValidateText.

    Quote Originally Posted by Hosam AL Dein View Post
    I was using a previous version of the ocx . It was the one released about 10 days ago and everything was fine . I have a user control which has a listview .

    I have just updated to the current version and here is what happens :

    If the listview is populated and I end the project by "End" word or even by pressing the "break"command in IDE , VB crashes . This does not happen when the listview is not populated.
    I cannot replicate with the current OCX. at least in a blank project. Can you provide a demo showing the problem?
    Last edited by Krool; Sep 26th, 2017 at 01:50 PM.

  22. #1782
    New Member
    Join Date
    Nov 2015
    Posts
    9

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Krool View Post
    The reason why the StatusBar flickers so much because it flashes between erasing (WM_ERASEBKGND) and drawing (WM_PAINT).
    As there was no in-built DoubleBuffer support for the StatusBar it needed to be done manually.
    This was achieved by blocking WM_ERASEBKGND and do the erasing and drawing into a memory DC in WM_PAINT.
    Thanks Krool, this was probably the cause of the issue I mentioned in a prior post . I'll try to setup my example again and confirm if the problem is gone.

  23. #1783
    Lively Member Hosam AL Dein's Avatar
    Join Date
    Jul 2017
    Location
    Egypt , Cairo
    Posts
    115

    Re: CommonControls (Replacement of the MS common controls)

    I made a separate project then added the usercontrol with the latest ocx version and the problem does not occur . How can I replicate the bug which causes vb to crash ?

  24. #1784
    Frenzied Member
    Join Date
    Jun 2015
    Posts
    1,491

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Hosam AL Dein View Post
    I made a separate project then added the usercontrol with the latest ocx version and the problem does not occur . How can I replicate the bug which causes vb to crash ?
    If that didn't work the typical strategy is to start with a copy of your project, and continue stripping it down until you find your bug.
    Imagine what it would be like to set breakpoints in, or step through subclassing code;
    and then being able to hit stop/end/debug or continue, without crashing the IDE.

    VB6.tlb | Bulletproof Subclassing in the IDE

  25. #1785
    Lively Member Hosam AL Dein's Avatar
    Join Date
    Jul 2017
    Location
    Egypt , Cairo
    Posts
    115

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by DEXWERX View Post
    If that didn't work the typical strategy is to start with a copy of your project, and continue stripping it down until you find your bug.
    thanks dexwerx , I will give this a try

  26. #1786
    Lively Member Hosam AL Dein's Avatar
    Join Date
    Jul 2017
    Location
    Egypt , Cairo
    Posts
    115

    Re: CommonControls (Replacement of the MS common controls)

    the frameW control forecolor is not working . Is this because I am using an earlier version or I am missing something ? . I am using version 14-Sep-2017 - Revision update. (Version 1.4.51)

  27. #1787

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2012
    Posts
    827

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Hosam AL Dein View Post
    the frameW control forecolor is not working . Is this because I am using an earlier version or I am missing something ? . I am using version 14-Sep-2017 - Revision update. (Version 1.4.51)
    The new FrameW is only in the Std-EXE version. It will be included in the next OCX version 1.5.

  28. #1788
    Addicted Member
    Join Date
    May 2011
    Posts
    188

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Hosam AL Dein View Post
    I made a separate project then added the usercontrol with the latest ocx version and the problem does not occur . How can I replicate the bug which causes vb to crash ?
    btw, ending a project with "END" keyword should only be used for debugging purpose.
    it's like telling Vb to "crash" the project, like the Stop button in the IDE.
    all handle will stay open wich might under some circonstance crash the project like you experience.

    Krool: does some of the component of the use Subclassing ? could crash under some circonstance.

  29. #1789
    Hyperactive Member
    Join Date
    Apr 2015
    Posts
    256

    Re: CommonControls (Replacement of the MS common controls)

    RichTextBox

    .SelFontName returns the string + a bunch of 00.
    When using Richtx32.ocx it's correct.

    Try the attached.RTF-VBCCR-2017-09-28.zip

  30. #1790

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2012
    Posts
    827

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Karl77 View Post
    RichTextBox

    .SelFontName returns the string + a bunch of 00.
    When using Richtx32.ocx it's correct.
    Done. Thanks
    OCX + Std-EXE got updated.

    Quote Originally Posted by VbNetMatrix View Post
    Krool: does some of the component of the use Subclassing ? could crash under some circonstance.
    What do you mean? If you mean the ComCtls then yes, they make heavy use of subclassing. Also VTable wise subclassing.
    The Std-EXE version will never be "End" secure as even when the subclassing could be done via ASM the VTable subclassing will still crash.
    So I stick to non-ASM subclassing (as it makes no sense) and just catch the "Stop" button via ComCtlsInitIDEStopProtection.
    However, the OCX should be certainly crash-free, even by "End".
    Last edited by Krool; Sep 28th, 2017 at 02:21 PM.

  31. #1791
    Hyperactive Member
    Join Date
    Apr 2015
    Posts
    256

    Re: CommonControls (Replacement of the MS common controls)

    Toolbar question

    I use the EXE version, but it is exactly the same with the OCX.

    I found that my way of populating a toolbar takes quite long.
    39 buttons/placeholders take 250msec.
    Also while a toolbar gets filled, the whole screen flickers.
    This happens when the containing form gets loaded, at this time it is not visible.
    Don't know if the toolbar itself flickers.
    I'm unhappy with the _screen_ flicker and the long processing time.

    I already tried to set Visible and Enabled, but it has no effect on the loading times and still flickers.
    Is there a built-in method to get that much faster, and also to avoid the screen flicker?

    Code:
    tc = GetTickCount
    
    With MF.tbr_Main
    
        .AllowCustomize = False
        .BackColor = ToolbarBackColor
        .Buttons.Clear
        Set .ImageList = IL 'the ImageList is a VBBCR ImageList
        .Divider = False
        .ShowTips = True
        .DoubleBuffer = False
        .Transparent = Not True
        .MinButtonWidth = 0
        .MaxButtonWidth = 0
        .TextAlignment = TbrTextAlignBottom
    
        Set B = .Buttons.Add(, "new", , TbrButtonStyleDefault, "new")
        B.ToolTipText = "New"
    
        Set B = .Buttons.Add(, , , TbrButtonStyleSeparator)
    
        'etc.
    
        .GetIdealSize WS, HS
        .Width = WS
        .Height = HS
    
        Set B = Nothing
    
    End With
    
    ms = CStr(GetTickCount - tc) & " msec."
    m = m & "Time to populate: " & vbCrLf & ms & vbCrLf
    
    'this comes after all toolbars are ready
    Debug.Print m
    Karl

  32. #1792

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2012
    Posts
    827

    Re: CommonControls (Replacement of the MS common controls)

    Make .DoubleBuffer = True instead of False to avoid flicker.

  33. #1793
    Hyperactive Member
    Join Date
    Apr 2015
    Posts
    256

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Krool View Post
    Make .DoubleBuffer = True instead of False to avoid flicker.
    I tried before.
    No effect on the screen flicker.
    It is a desktop flicker, not the toolbar itself.

    I can clearly see in my app the flicker comes from populating the toolbars.
    I have 11 toolbars, and the flicker occurs 11x.
    Nothing else is done when it happens.

    Unfortunately, and 'of course', in a small demo app there is no desktop flicker.

    But the long time to populate.
    The CC5 toolbar is ready in no time.
    Hmm.

    Still need an idea.

  34. #1794
    Hyperactive Member
    Join Date
    Dec 2011
    Location
    Oregon City, Oregon
    Posts
    256

    Re: CommonControls (Replacement of the MS common controls)

    What is the possibility of getting a multicolumn Combobox in the queue? Or is there one already there?

  35. #1795
    Hyperactive Member
    Join Date
    Apr 2015
    Posts
    256

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Karl77 View Post
    Still need an idea.
    Found out how to avoid the screen flicker.
    When I comment out this:

    Code:
    .TextAlignment = TbrTextAlignBottom
    then no flicker occurs.

    EDIT:
    Also the performance is FAR better, 78 instead of 250msec.
    Of course without the TextAlignment property, the toolbars are not as intended.

    EDIT2:
    The flicker is also there when I set TextAlignment after populating the buttons.
    Last edited by Karl77; Sep 29th, 2017 at 02:05 PM.

  36. #1796

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2012
    Posts
    827

    Re: CommonControls (Replacement of the MS common controls)

    Update released.

    The performance of the ToolBar has been increased.
    This was achieved by internally doing at some points (if applicable) a invalidation instead of a refresh.

    Quote Originally Posted by Karl77 View Post
    Found out how to avoid the screen flicker.
    When I comment out this:

    Code:
    .TextAlignment = TbrTextAlignBottom
    then no flicker occurs.
    Changing .TextAlignment will cause re-creating of the control. During the re-creation LockWindowUpdate is used:

    Code:
    Private Sub ReCreateToolBar()
    Dim Locked As Boolean
    With Me
    Locked = CBool(LockWindowUpdate(UserControl.hWnd) <> 0)
    [...]
    If Locked = True Then LockWindowUpdate 0
    .Refresh
    End With
    Maybe LockWindowUpdate does cause a screen flicker in your particular app, just a guess.

    Solution could be to set the .TextAlignment already at design-time to the wanted value.

    Quote Originally Posted by gwboolean View Post
    What is the possibility of getting a multicolumn Combobox in the queue? Or is there one already there?
    You mean something like this ?
    Last edited by Krool; Sep 29th, 2017 at 02:57 PM.

  37. #1797
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    3,040

    Re: CommonControls (Replacement of the MS common controls)

    Hi Krool,

    That's a nifty little C# project you've linked to in the prior post. Too bad it's not VB6.

    It looks like they've taken a standard ComboBox and attached a ListView to it for the dropdown. With that understanding, this seems like it'd be a fairly straightforward project for a custom User Control (possibly using your controls to start with). It's also somewhat nifty that the dropdown can go outside of the main form (which is also true of a standard ComboBox). It may take a bit of doing to work that out, but not that big a deal. As stated in a recent thread, I'd just use a second form to do that.

    Take Care,
    Elroy

  38. #1798
    Hyperactive Member
    Join Date
    Apr 2015
    Posts
    256

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Krool View Post
    During the re-creation LockWindowUpdate is used:
    From what I understand, MS says WM_SETREDRAW should be used instead.
    https://msdn.microsoft.com/de-de/lib...(v=vs.85).aspx
    Why did you decide for LockWindowUpdate?
    Just curious.

  39. #1799

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2012
    Posts
    827

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Karl77 View Post
    From what I understand, MS says WM_SETREDRAW should be used instead.
    https://msdn.microsoft.com/de-de/lib...(v=vs.85).aspx
    Why did you decide for LockWindowUpdate?
    Just curious.
    Refer to http://www.vbforums.com/showthread.p...=1#post5108773 for reason and explanation.

  40. #1800
    Member lrd_VB6's Avatar
    Join Date
    Jul 2014
    Location
    FRANCE
    Posts
    32

    Re: CommonControls (Replacement of the MS common controls)

    Hello,

    Sorry for my English, (google translated!)

    Me too, I noticed this effect with "LockWindowUpdate (0)". The whole screen is refreshed, causing the flicker.
    I prefer the "ValidateRect / InvalidateRect" method and generate a PAINT when necessary. Or make a DoEvents (by managing the reantrance)..
    With this method, I do not have the blinking of the screen.

Page 45 of 46 FirstFirst ... 354243444546 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.