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

Thread: CommonControls (Replacement of the MS common controls)

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

    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
    809

    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
    240

    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
    521

    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
    240

    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: 69
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
    809

    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: 69
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
    240

    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
    809

    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
    809

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

    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
    809

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

    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: 24
Size:  17.0 KB

    Spin.zip

  13. #1773

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2012
    Posts
    809

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

    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
    809

    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; Today at 03:55 PM.

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.