CommonControls (Replacement of the MS common controls) - Page 45-VBForums
Page 45 of 45 FirstFirst ... 3542434445
Results 1,761 to 1,768 of 1768

Thread: CommonControls (Replacement of the MS common controls)

  1. #1761
    Addicted Member
    Join Date
    Apr 2015
    Posts
    237

    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
    799

    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
    Addicted Member
    Join Date
    Apr 2015
    Posts
    237

    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
    512

    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
    Addicted Member
    Join Date
    Apr 2015
    Posts
    237

    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: 41
Size:  50.4 KB



    Karl
    Last edited by Karl77; Yesterday at 05:11 AM. Reason: I wrote nonsense before

  6. #1766

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2012
    Posts
    799

    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: 41
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
    Addicted Member
    Join Date
    Apr 2015
    Posts
    237

    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
    799

    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.

Page 45 of 45 FirstFirst ... 3542434445

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.