Page 52 of 94 FirstFirst ... 2424950515253545562 ... LastLast
Results 2,041 to 2,080 of 3744

Thread: CommonControls (Replacement of the MS common controls)

  1. #2041
    Hyperactive Member
    Join Date
    Feb 2015
    Location
    Colorado USA
    Posts
    269

    Re: CommonControls (Replacement of the MS common controls)

    Krool,

    You are saying we need to use InitVisualStyles in Procedure Main before showing a form. Okay. How about SetupVisualStyles? It is in VisualStyles.bas in the demo program (no OCX) and it looks like you put it as the first line of code in each of the forms. However, it is not present in the OCX version so do we assume that it got called internally in your OCX for each form or that is isn't needed or something else. if we should call it in the Form_Load procedure, do we nneed to put SetupVisualStyles into a different module or use VisualStyles.bas?

  2. #2042

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,388

    Re: CommonControls (Replacement of the MS common controls)

    The OCX is a isolated component, it can't access any form of the application that uses it.

    VisualStyles is a Std-EXE process topic and has nothing todo with the OCX.
    You can use the OCX in VBA with no theming at all.
    Or use in Vb6 with no theming at all.

    If you decide to theme your Vb6 exe you have to deal with issues like everybody else exe.

    For example, you use a vb6 exe with theming manifest and only use vb6 native controls (No OCX) then you will notice that focus rects are not shown.
    It's complete independent... i hope you got it now.

  3. #2043
    Hyperactive Member
    Join Date
    Feb 2015
    Location
    Colorado USA
    Posts
    269

    Re: CommonControls (Replacement of the MS common controls)

    That makes sense but it also brings up three questions that i have been wondering about for a while.

    1 - In the Std-Exe demo there is no manifest included like there is for the OCX version. Does the Std-Exe version do theming and if so, how does it do it without a manifest?

    2 - How difficult would it be to make a same program using the OCX version that is basically the same as the Std-Exe demo? That would be a really good sample so that we could figure out what we have to do with the OCX version to get the same results as the Std-Exe version (such as needing to use SetUpVisualStyles at the top of each form) and vice versa.

    3 - Aren't the MS Office products (Excel, Word, etc.) themed? If our VBA code is basically children of the top level Office programs why aren't they themed as well?

    Thanks.

  4. #2044

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,388

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by MountainMan View Post
    1 - In the Std-Exe demo there is no manifest included like there is for the OCX version. Does the Std-Exe version do theming and if so, how does it do it without a manifest?
    The Std-EXE demo has a manifest. Look in the Resources subfolder for Resources.res.

    Quote Originally Posted by MountainMan View Post
    2 - How difficult would it be to make a same program using the OCX version that is basically the same as the Std-Exe demo? That would be a really good sample so that we could figure out what we have to do with the OCX version to get the same results as the Std-Exe version (such as needing to use SetUpVisualStyles at the top of each form) and vice versa.
    There are basically the same. For both usages you need to include manifest and fix visual styles issues.

    Quote Originally Posted by MountainMan View Post
    3 - Aren't the MS Office products (Excel, Word, etc.) themed? If our VBA code is basically children of the top level Office programs why aren't they themed as well?
    The office products (EXCEL.EXE etc.) have no manifest therefore when you put a VBCCR control on a UserForm it won't be themed.
    The intrinsic controls which the office product are used are basically super-classed owner drawn styled controls. Therefore it looks like there are somewhat themed, but not same theming as VBCCR.

  5. #2045
    Addicted Member
    Join Date
    Jul 2017
    Posts
    233

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Krool View Post
    Do you have a Sub Main which calls InitVisualStyles prior to first form load?
    yes , I placed it there

  6. #2046
    Addicted Member
    Join Date
    Jul 2017
    Posts
    233

    Re: CommonControls (Replacement of the MS common controls)

    one more problem , I think there is something I am missing . As I mentioned above , I am using the ocx .
    another issue showed up . For all the controls ,they dont initiate click event at the first hit and require two hits . The first one sets the focus the second one is for click .
    I have placed InitVisualStyles in my main sub and called setupvisualstyles in the form load .

  7. #2047
    Addicted Member
    Join Date
    Jul 2017
    Posts
    233

    Re: CommonControls (Replacement of the MS common controls)

    sorry for double posting

    one more problem , I think there is something I am missing . As I mentioned above , I am using the ocx .
    another issue showed up . For all the controls ,they dont initiate click event at the first hit and require two hits . The first one sets the focus the second one is for click .
    I have placed InitVisualStyles in my main sub and called setupvisualstyles in the form load .

  8. #2048
    Addicted Member
    Join Date
    Jul 2017
    Posts
    233

    Re: CommonControls (Replacement of the MS common controls)

    the previous problem does not occur in the exe , it happens only in IDE

  9. #2049

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,388

    Re: CommonControls (Replacement of the MS common controls)

    Hosam AL Dein,

    I can't help you by magic.
    Please isolate your issue in a demo project with no other dependencies than VBCCR then I can try to help.
    Thanks

  10. #2050
    Hyperactive Member
    Join Date
    Feb 2015
    Location
    Colorado USA
    Posts
    269

    Re: CommonControls (Replacement of the MS common controls)

    Krool,

    Back to the visual styles of the OCX version. When I look in the code for forms in ComCtlsDemo I find the first line is always a call to SetupVisualStyles which is in VisualStyles.bas in the Common folder. However, when I look at the code included with the OCX version I find a file named VisualStyles.bas but it is a very abbreviated version of the VisualStyles.bas and it doesn't have a Sub named SetupVisualStyles. If I understand your previous posts right, we still need to include the code from this sub in each of our forms in order to get themes to work properly with our forms. Is this correct?

    Also, I see that the 2 files in the Common folder for the OCX (Common.bas and VisualStyles.bas) are both needed to compile VBCCR16 into VBCCR16.OCX. Other than what is mentioned above regarding possible use of the sub SetupvisualStyles (which isn't in either of these modules anyway), are there any routines in either of the two subs that you recommend/require we use to be able to use your controls and get the theming effects?

  11. #2051
    Fanatic Member
    Join Date
    Apr 2015
    Posts
    524

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Hosam AL Dein View Post
    For all the controls ,they dont initiate click event at the first hit and require two hits . The first one sets the focus the second one is for click .
    I had this as well.

    It came up from time to time, and the only cure was a reboot.
    But even then it came back sooner or later.
    The effect is seen less often since all Comctl constants were replaced by their VBCCR equivalents.
    Sounds unlikely, but that's what I experienced.

    The effect still comes up, but it takes some hours or days.
    I think the cause could be a GDI or other memory leak?

    @Krool
    No chance to bake a demo app showing this.
    I tried, but 'of course' the problem doesn't show in a simple small project.
    That's why I never mentioned it.
    Fortunately, the problem is in the IDE only.
    EXE is ok.

  12. #2052

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,388

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by MountainMan View Post
    Krool,

    Back to the visual styles of the OCX version. When I look in the code for forms in ComCtlsDemo I find the first line is always a call to SetupVisualStyles which is in VisualStyles.bas in the Common folder. However, when I look at the code included with the OCX version I find a file named VisualStyles.bas but it is a very abbreviated version of the VisualStyles.bas and it doesn't have a Sub named SetupVisualStyles. If I understand your previous posts right, we still need to include the code from this sub in each of our forms in order to get themes to work properly with our forms. Is this correct?

    Also, I see that the 2 files in the Common folder for the OCX (Common.bas and VisualStyles.bas) are both needed to compile VBCCR16 into VBCCR16.OCX. Other than what is mentioned above regarding possible use of the sub SetupvisualStyles (which isn't in either of these modules anyway), are there any routines in either of the two subs that you recommend/require we use to be able to use your controls and get the theming effects?
    Correct. The OCX has just an trimmed down version of VisualStyles.bas. It has only functions to determine whether theming is on or not to control if some features are available or not.
    In your Std-Exe you shall use the full VisualStyles.bas and apply the InitVisualStyles and SetupVisualStyles accordingly.

  13. #2053
    Lively Member
    Join Date
    Oct 2016
    Posts
    112

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Krool View Post
    Correct. The OCX has just an trimmed down version of VisualStyles.bas. It has only functions to determine whether theming is on or not to control if some features are available or not.
    In your Std-Exe you shall use the full VisualStyles.bas and apply the InitVisualStyles and SetupVisualStyles accordingly.
    I have been using the ocx for some time now. I never had any problems, I never used the InitVisualStyles and SetupVisualStyles.
    From what I am reading here, it looks like I have to include the full VisualStyles.bas in every project. is this correct? if so for what purpose.
    please correct me If I misunderstood.

  14. #2054
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Semke View Post
    I have been using the ocx for some time now. I never had any problems, I never used the InitVisualStyles and SetupVisualStyles.
    From what I am reading here, it looks like I have to include the full VisualStyles.bas in every project. is this correct? if so for what purpose.
    please correct me If I misunderstood.
    It's not required. It's only if you want to fix some visual inconsistencies, like the aforementioned focus rects.
    (Some built in windows dialogs don't even show proper focus)

  15. #2055
    Lively Member
    Join Date
    Sep 2016
    Location
    Texas panhandle
    Posts
    64

    Re: CommonControls (Replacement of the MS common controls)

    Sorry if this has already been discussed but
    in the RichTextBox Control the KeyUp and KeyDown events never return
    vbAltMask. Shift and Control work fine.

  16. #2056

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,388

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by VBClassic04 View Post
    Sorry if this has already been discussed but
    in the RichTextBox Control the KeyUp and KeyDown events never return
    vbAltMask. Shift and Control work fine.
    Oh. Yes, it's a missing feature.
    The following red marked code needs to be included in the key handlers in TextBoxW and RichtTextBox. (WindowProcControl)
    Code:
        Case WM_KEYDOWN, WM_KEYUP, WM_SYSKEYDOWN, WM_SYSKEYUP
            Dim KeyCode As Integer
            KeyCode = wParam And &HFF&
            If wMsg = WM_KEYDOWN Or wMsg = WM_SYSKEYDOWN Then
                RaiseEvent KeyDown(KeyCode, GetShiftStateFromMsg())
            ElseIf wMsg = WM_KEYUP Or wMsg = WM_SYSKEYUP Then
                RaiseEvent KeyUp(KeyCode, GetShiftStateFromMsg())
            End If
            Select Case wMsg
                Case WM_KEYDOWN, WM_KEYUP
                    [...]
                    TextBoxCharCodeCache = ComCtlsPeekCharCode(hWnd)
            End Select
            wParam = KeyCode
    Also other controls might be affected such as VBFlexGrid. But not all VB intrinsic controls show vbAltMask. E.g. VB.ListBox won't show vbAltMask.
    I need to investigate further before releasing fixes.
    Also IOleInPlaceActiveObjectVB::TranslateAccelerator might needs to be included with those WM_SYS*
    Last edited by Krool; Oct 7th, 2018 at 09:27 AM.

  17. #2057
    Lively Member
    Join Date
    Sep 2016
    Location
    Texas panhandle
    Posts
    64

    Re: CommonControls (Replacement of the MS common controls)

    Many thanks Krool. The changes worked perfectly.
    I'm working on a text editor and I added these
    routines to the control.

    Code:
    Private Const EM_LINEFROMCHAR As Long = &HC9 '**added
    Private Const EM_GETRECT As Long = &HB2      '**
    '....
    Public Sub GoToLine(ByVal Line As Long, Optional ByVal Column As Long = 0)
     Dim LIndex As Long
     Dim LLength As Long
     If (Line >= 0) And (Line <= GetLineCount - 1) Then
      LIndex = SendMessage(RichTextBoxHandle, EM_LINEINDEX, Line, ByVal 0&)
      LLength = Len(GetLine(Line))
      If Column > LLength Then Column = LLength
      SetRange LIndex, Column
      Call SendMessage(RichTextBoxHandle, EM_SCROLLCARET, 0&, 0&) 'brings the line into view
      Call SendMessage(RichTextBoxHandle, EM_SETSEL, -1&, 0&) 'unselect
     End If
    End Sub
    
    Private Sub SetRange(ByVal SelSt As Long, ByVal SelLen As Long)
     Dim tChrRng As RECHARRANGE
     tChrRng.Min = SelSt
     tChrRng.Max = SelSt + SelLen
     Call SendMessage(RichTextBoxHandle, EM_EXSETSEL, 0&, tChrRng)
    End Sub
    
    Public Function CurrLineLength() As Long
     CurrLineLength = SendMessage(RichTextBoxHandle, EM_LINELENGTH, SelStart, ByVal 0&)
    End Function
    
    Public Sub SelectAll()
     Call SendMessage(RichTextBoxHandle, EM_SETSEL, 0&, ByVal -1&)
    End Sub
    
    Public Function CurrentLineNumber() As Long
     CurrentLineNumber = SendMessage(RichTextBoxHandle, EM_LINEFROMCHAR, SelStart, ByVal 0&)
    End Function
    
    Public Function CurrentColumnNumber() As Long
     Dim LIndex As Long
     Dim Line As Long
     Line = CurrentLineNumber
     LIndex = SendMessage(RichTextBoxHandle, EM_LINEINDEX, Line, ByVal 0&)
     CurrentColumnNumber = SelStart - LIndex
    End Function
    
    Public Function FirstVisibleLine() As Long
     FirstVisibleLine = SendMessage(RichTextBoxHandle, EM_GETFIRSTVISIBLELINE, 0&, ByVal 0&)
    End Function
    Public Function LastVisibleLine() As Long
     Dim LIndex As Long
     Dim PT As POINTAPI
     Dim RC As RECT
     Call SendMessage(RichTextBoxHandle, EM_GETRECT, 0&, RC)
     PT.X = 0
     PT.Y = RC.Bottom
     LIndex = SendMessage(RichTextBoxHandle, EM_CHARFROMPOS, 0&, PT)
     LastVisibleLine = SendMessage(RichTextBoxHandle, EM_EXLINEFROMCHAR, 0&, ByVal LIndex)
    End Function
    
    Public Function VisibleLineCount() As Long
     VisibleLineCount = LastVisibleLine - FirstVisibleLine + 1
    End Function

  18. #2058

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,388

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by VBClassic04 View Post
    The changes worked perfectly.
    Update released.
    WM_SYSKEYDOWN/WM_SYSKEYUP is now considered on all KeyDown/KeyUp events of every control affected.
    IOleInPlaceActiveObjectVB::TranslateAccelerator was not concerned and it made no sense at all to consider WM_SYSKEYDOWN/WM_SYSKEYUP also there.

    Thanks again for bringing this up.

    EDIT:
    Your 'GoToLine' is very similar or equal to the 'ScrollToLine' in-built function in the RichTextBox.

  19. #2059
    Lively Member
    Join Date
    Sep 2016
    Location
    Texas panhandle
    Posts
    64

    Re: CommonControls (Replacement of the MS common controls)

    Mr Krool, another question about the RichTextBox control.
    I would expect that using the SelText method would make
    CanUndo be true. However, it does not. The Change Event
    is triggered as expected.

    Perhaps something to do with the SetEventMask call in the
    CreateRichTextBox routine?


    Code:
    Private Sub cmdRepl_Click()      'button Replace
     RTF.SelText = txtRepl.Text
     Debug.Print RTF.CanUndo      'always false
     cmdFind_Click                      'find next match
    End Sub

  20. #2060
    Lively Member
    Join Date
    Oct 2016
    Posts
    112

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Krool View Post
    Update released.
    WM_SYSKEYDOWN/WM_SYSKEYUP is now considered on all KeyDown/KeyUp events of every control affected.
    IOleInPlaceActiveObjectVB::TranslateAccelerator was not concerned and it made no sense at all to consider WM_SYSKEYDOWN/WM_SYSKEYUP also there.

    Thanks again for bringing this up.

    EDIT:
    Your 'GoToLine' is very similar or equal to the 'ScrollToLine' in-built function in the RichTextBox.
    is the ocx also updated?

  21. #2061

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,388

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Semke View Post
    is the ocx also updated?
    Yes, of course.

  22. #2062
    Member lrd_VB6's Avatar
    Join Date
    Jul 2014
    Location
    FRANCE
    Posts
    36

    Re: CommonControls (Replacement of the MS common controls)

    Hello,

    Here is the update of my converter for the latest version of VBCCRxx (16).
    Translates your code using VBCCR from 11 to 15 for version 16.
    All converted files are saved (.bak) as a precaution.

    When you have a project of 10000 lines (and more), it makes the task easier.

    VBCCRvxx_converter.zip

    Good work

  23. #2063
    Fanatic Member
    Join Date
    Apr 2015
    Posts
    524

    Re: CommonControls (Replacement of the MS common controls)

    DARK MODE QUESTION

    Now we have a bunch of very fine and usable controls.
    Invaluable for today's VB6 apps.
    All the controls do look and work good on white or light gray background.

    Nowadays more and more applications with a dark mode come up.
    I'm not a big fan, it feels a bit like in MS-DOS times.
    My personal taste is not important in this respect.
    Some users do want a dark UI.

    Generally not a big deal to switch certain colors.
    Unfortunately, most VBCCR (~=comctl32) controls don't offer such color properties.
    Some do, e.g. the toolbar.

    Would it be possible to tweak the other VBCCR controls somehow to use the wanted colors?

    Thank you.

  24. #2064
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,064

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by VBClassic04 View Post
    Mr Krool, another question about the RichTextBox control.
    I would expect that using the SelText method would make
    CanUndo be true. However, it does not. The Change Event
    is triggered as expected.

    Perhaps something to do with the SetEventMask call in the
    CreateRichTextBox routine?


    Code:
    Private Sub cmdRepl_Click()      'button Replace
     RTF.SelText = txtRepl.Text
     Debug.Print RTF.CanUndo      'always false
     cmdFind_Click                      'find next match
    End Sub
    Hello Krool. I recently had a similar issue and found a solution for changing text by code and still letting the user to undo the change.

    First the text in the control that has to be replaced must be selected (using .SelStart and .SelLenght or by other means)
    Code:
    Const EM_REPLACESEL As Long = &HC2
    
    SendMessage txtCtl.hWnd, EM_REPLACESEL, ByVal 1&, ByVal strNewText
    HTH

  25. #2065
    Addicted Member
    Join Date
    Jul 2017
    Posts
    233

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Karl77 View Post
    DARK MODE QUESTION

    Now we have a bunch of very fine and usable controls.
    Invaluable for today's VB6 apps.
    All the controls do look and work good on white or light gray background.

    Nowadays more and more applications with a dark mode come up.
    I'm not a big fan, it feels a bit like in MS-DOS times.
    My personal taste is not important in this respect.
    Some users do want a dark UI.

    Generally not a big deal to switch certain colors.
    Unfortunately, most VBCCR (~=comctl32) controls don't offer such color properties.
    Some do, e.g. the toolbar.

    Would it be possible to tweak the other VBCCR controls somehow to use the wanted colors?

    Thank you.
    Totally agree with this point . I am so concerned of the GUI look and feel . Thankfully ,the folks on the forum here brought up many controls supporting this approach . But , as you mentioned karl , VB6 still lacking some points to fully support the approach you are aiming . But I will add 2 points , The colors issue only will not get us there , The more important requirements for controls are :

    1- Being flat
    2- Accepting Png ( or mainly support transparency with no restrictions ) in Icons and normal images .

    These points are fulfilled in some user controls here in the forum but it definitely will be great to add it to Krool VBCCR .
    I can participate in this project with some user controls I have made but not in VBCCR itself . It has techniques I never practiced before .

  26. #2066
    Addicted Member
    Join Date
    Jul 2017
    Posts
    233

    Re: CommonControls (Replacement of the MS common controls)

    Sorry for double posting



    Quote Originally Posted by Karl77 View Post
    DARK MODE QUESTION

    Now we have a bunch of very fine and usable controls.
    Invaluable for today's VB6 apps.
    All the controls do look and work good on white or light gray background.

    Nowadays more and more applications with a dark mode come up.
    I'm not a big fan, it feels a bit like in MS-DOS times.
    My personal taste is not important in this respect.
    Some users do want a dark UI.

    Generally not a big deal to switch certain colors.
    Unfortunately, most VBCCR (~=comctl32) controls don't offer such color properties.
    Some do, e.g. the toolbar.

    Would it be possible to tweak the other VBCCR controls somehow to use the wanted colors?

    Thank you.
    Totally agree with this point . I am so concerned of the GUI look and feel . Thankfully ,the folks on the forum here brought up many controls supporting this approach . But , as you mentioned karl , VB6 still lacking some points to fully support the approach you are aiming . But I will add 2 points , The colors issue only will not get us there , The more important requirements for controls are :

    1- Being flat
    2- Accepting Png ( or mainly support transparency with no restrictions ) in Icons and normal images .

    These points are fulfilled in some user controls here in the forum but it definitely will be great to add it to Krool VBCCR .
    I can participate in this project with some user controls I have made but not in VBCCR itself . It has techniques I never practiced before .

  27. #2067
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    Re: CommonControls (Replacement of the MS common controls)

    Not speaking for KROOL, but I think DARK MODE is a bit outside the scope of VBCCR. VBCCR at it's heart is an implementation of the already existing themed Windows Common Controls (Comctl32.dll).

    If the Common Controls don't support Dark Mode, how would you propose VBCCR would?

    All the controls would have to be created from scratch, custom drawn, without using Comctl32.
    What you're proposing would have to be a completely separate project, possibly much larger in scope than VBCCR, specifically targeting a UWP design language.

    Who wants to get started on the VBUWPUI project?

    https://developer.microsoft.com/en-u...ws/apps/design

    https://docs.microsoft.com/en-us/win...to-uwp-enhance

    I would think the renderer would be based on Direct2D, similar to the XAML compositer.
    https://stackoverflow.com/questions/...l-in-win32-app
    Last edited by DEXWERX; Oct 12th, 2018 at 08:42 AM.

  28. #2068
    Addicted Member
    Join Date
    Jul 2017
    Posts
    233

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by DEXWERX View Post
    Not speaking for KROOL, but I think DARK MODE is a bit outside the scope of VBCCR. VBCCR at it's heart is an implementation of the already existing themed Windows Common Controls (Comctl32.dll).

    If the Common Controls don't support Dark Mode, how would you propose VBCCR would?

    All the controls would have to be created from scratch, custom drawn, without using Comctl32.
    What you're proposing would have to be a completely separate project, possibly much larger in scope than VBCCR, specifically targeting a UWP design language.

    Who wants to get started on the VBUWPUI project?

    https://developer.microsoft.com/en-u...ws/apps/design

    https://docs.microsoft.com/en-us/win...to-uwp-enhance
    Can these controls be adopted in VB6 ? If yes , I will be learning the language tomorrow

    I am close to the concept found there
    Name:  interface.jpg
Views: 1141
Size:  28.1 KB
    Last edited by Hosam AL Dein; Oct 12th, 2018 at 08:19 AM.

  29. #2069
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    Re: CommonControls (Replacement of the MS common controls)

    Last edited by DEXWERX; Oct 12th, 2018 at 09:00 AM.

  30. #2070
    Addicted Member
    Join Date
    Jul 2017
    Posts
    233

    Re: CommonControls (Replacement of the MS common controls)

    I am surprised https://github.com/Microsoft/Desktop...es/VB6withXaml . It can be done !
    Name:  apps.13706.13909669453248747.967611fe-eff8-4129-8d1f-57e3a7ffc56f.jpg
Views: 1224
Size:  24.2 KB
    Last edited by Hosam AL Dein; Oct 12th, 2018 at 09:11 AM.

  31. #2071
    Lively Member
    Join Date
    Sep 2016
    Location
    Texas panhandle
    Posts
    64

    Re: CommonControls (Replacement of the MS common controls)

    A suggested correction to the Find method of the RichTextBox Control.
    This allows searching in the Up direction.

    Code:
    Public Function Find(ByVal Text As String, Optional ByVal Min As Long, Optional ByVal Max As Long = -1, Optional ByVal Options As RtfFindOptionConstants) As Long
     If RichTextBoxHandle <> 0 Then
      Dim REFTEX As REFINDTEXTEX, dwOptions As Long
      With REFTEX
       With .CharRange
        If Min >= 0 Then
         .Min = Min
        Else
         Err.Raise 380
        End If
        If Max >= -1 Then
         .Max = Max
        Else
         Err.Raise 380
        End If
       End With
       .lpstrText = StrPtr(Text)
       Const FR_DOWN As Long = &H1
       If Min < Max Then                             '********** added
        dwOptions = FR_DOWN
       End If                                              '**********added
       If (Options And RtfFindOptionWholeWord) <> 0 Then dwOptions = dwOptions Or FR_WHOLEWORD
       If (Options And RtfFindOptionMatchCase) <> 0 Then dwOptions = dwOptions Or FR_MATCHCASE
       Find = SendMessage(RichTextBoxHandle, EM_FINDTEXTEX, dwOptions, ByVal VarPtr(REFTEX))
       If (Options And RtfFindOptionNoHighlight) = 0 And Find <> -1 Then SendMessage RichTextBoxHandle, EM_EXSETSEL, 0, ByVal VarPtr(.CharRangeText)
      End With
     End If
    End Function

  32. #2072
    Lively Member
    Join Date
    Sep 2016
    Location
    Texas panhandle
    Posts
    64

    Re: CommonControls (Replacement of the MS common controls)

    BTW, Edwardo's post about SelText in the RichTextBox Control fixed the undo problem

  33. #2073

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,388

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by DEXWERX View Post
    I think DARK MODE is a bit outside the scope of VBCCR.
    I agree. VBCCR should not be the solution for everything. It is intended to get rid of the old OCX dependencies and to support Unicode. (and more handy, bugfixes, features etc..)
    If new "modern" UI is needed then another alternative approach is better. (without comct32.dll)

    Quote Originally Posted by VBClassic04 View Post
    A suggested correction to the Find method of the RichTextBox Control.
    This allows searching in the Up direction.

    Code:
    Public Function Find(ByVal Text As String, Optional ByVal Min As Long, Optional ByVal Max As Long = -1, Optional ByVal Options As RtfFindOptionConstants) As Long
     If RichTextBoxHandle <> 0 Then
      Dim REFTEX As REFINDTEXTEX, dwOptions As Long
      With REFTEX
       With .CharRange
        If Min >= 0 Then
         .Min = Min
        Else
         Err.Raise 380
        End If
        If Max >= -1 Then
         .Max = Max
        Else
         Err.Raise 380
        End If
       End With
       .lpstrText = StrPtr(Text)
       Const FR_DOWN As Long = &H1
       If Min < Max Then                             '********** added
        dwOptions = FR_DOWN
       End If                                              '**********added
       If (Options And RtfFindOptionWholeWord) <> 0 Then dwOptions = dwOptions Or FR_WHOLEWORD
       If (Options And RtfFindOptionMatchCase) <> 0 Then dwOptions = dwOptions Or FR_MATCHCASE
       Find = SendMessage(RichTextBoxHandle, EM_FINDTEXTEX, dwOptions, ByVal VarPtr(REFTEX))
       If (Options And RtfFindOptionNoHighlight) = 0 And Find <> -1 Then SendMessage RichTextBoxHandle, EM_EXSETSEL, 0, ByVal VarPtr(.CharRangeText)
      End With
     End If
    End Function
    You can search up also without any modification.
    Example in RichTextBoxForm:
    Code:
    If (CommonDialogFind.Flags And CdlFRDown) = CdlFRDown Then
        RetVal = RichTextBox1.Find(CommonDialogFind.FindWhat, RichTextBox1.SelStart + RichTextBox1.SelLength, , Options)
    Else
        RetVal = RichTextBox1.Find(CommonDialogFind.FindWhat, , RichTextBox1.SelStart, Options)
    End If
    However, I might consider including an 'RtfFindOptionUp' or 'RtfFindOptionReverse'. When flag is set, no FR_DOWN (default) will be set.

    But, I can't include your addition as it changes behavior which some apps does not expect. (compatibility)

    Quote Originally Posted by VBClassic04 View Post
    BTW, Edwardo's post about SelText in the RichTextBox Control fixed the undo problem
    The solution is just to pass 1 in wparam on EM_REPLACESEL.
    MSDN:
    wParam
    Specifies whether the replacement operation can be undone. If this is TRUE, the operation can be undone. If this is FALSE , the operation cannot be undone.


    It seems the "MS RichTextBox" (RICHTX32.OCX) also seems to trigger CanUndo on .SelText.
    So, in the next update I will change wparam from 0 to 1 on EM_REPLACESEL. (for both, RichTextBox and TextBoxW)

    EDIT: EM_REPLACESEL fix released.
    Last edited by Krool; Oct 12th, 2018 at 12:19 PM.

  34. #2074
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,064

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Krool View Post
    It seems the "MS RichTextBox" (RICHTX32.OCX) also seems to trigger CanUndo on .SelText.
    So, in the next update I will change wparam from 0 to 1 on EM_REPLACESEL. (for both, RichTextBox and TextBoxW)
    I tested it and the standard textbox doesn't allow to undo the action after a selection is replaced by code, unlike the RichTextBox.

  35. #2075

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,388

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Eduardo- View Post
    I tested it and the standard textbox doesn't allow to undo the action after a selection is replaced by code, unlike the RichTextBox.
    Maybe because the MS RichTextBox has Undo and Redo methods, do they decided that SelText triggers Undo.
    Whereas standard TextBox has no duch methods there was no "need" that SelText triggers something.
    Anyhow, my TextBoxW has just like RichTextBox Undo method, so it makes sense or does not harm when SelText triggers Undo. Or?

  36. #2076
    PowerPoster
    Join Date
    Feb 2017
    Posts
    5,064

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Krool View Post
    Maybe because the MS RichTextBox has Undo and Redo methods, do they decided that SelText triggers Undo.
    Whereas standard TextBox has no duch methods there was no "need" that SelText triggers something.
    Anyhow, my TextBoxW has just like RichTextBox Undo method, so it makes sense or does not harm when SelText triggers Undo. Or?
    Yes Krool, that makes sense.

  37. #2077
    Fanatic Member
    Join Date
    Apr 2015
    Posts
    524

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by DEXWERX View Post
    Not speaking for KROOL, but I think DARK MODE is a bit outside the scope of VBCCR. VBCCR at it's heart is an implementation of the already existing themed Windows Common Controls (Comctl32.dll).
    If the Common Controls don't support Dark Mode, how would you propose VBCCR would?
    Dex, that was a question, not a proposal.
    My question came up because Krool achieved some interesting things like transparent toolbars.

    All the controls would have to be created from scratch, custom drawn, without using Comctl32.
    Too much effort for a small advantage.

    Perhaps one day in a newer comctl32 we'll find a 'color set' property...

  38. #2078
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Karl77 View Post
    Perhaps one day in a newer comctl32 we'll find a 'color set' property...
    One can hope, considering most back office / data type GUI's are still based on common controls.
    It's hard to say given all the effort that's been invested in UWP.

  39. #2079
    Fanatic Member
    Join Date
    Apr 2015
    Posts
    524

    Re: CommonControls (Replacement of the MS common controls)

    TEXTBOXW IN UC QUESTION

    The effect is seen in the IDE only.

    When I place an intrinsic textbox in a usercontrol, the textbox is inactive when the usercontrol is placed on a form.
    When I do the same with a TextBoxW it is active.
    Means I can move the cursor, type text etc.
    This is not only a cosmetic issue, it is cumbersome to select such a UC in the IDE.

    To retrace:
    Make a new project, and load the VBCCR component.
    Make a new UC, and place a TextBoxW on it.
    No additional code.
    Place this UC on a form.
    See the TextBoxW in action.
    Make a new UC, and place an intrinsic textbox on it.
    Place this 2nd UC on a form.
    See that that textbox is inactive.

    How can we get the same behavior as with the intrinsic textbox?

    Thank you

  40. #2080

    Thread Starter
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,388

    Re: CommonControls (Replacement of the MS common controls)

    Quote Originally Posted by Karl77 View Post
    TEXTBOXW IN UC QUESTION

    The effect is seen in the IDE only.

    When I place an intrinsic textbox in a usercontrol, the textbox is inactive when the usercontrol is placed on a form.
    When I do the same with a TextBoxW it is active.
    Means I can move the cursor, type text etc.
    This is not only a cosmetic issue, it is cumbersome to select such a UC in the IDE.

    To retrace:
    Make a new project, and load the VBCCR component.
    Make a new UC, and place a TextBoxW on it.
    No additional code.
    Place this UC on a form.
    See the TextBoxW in action.
    Make a new UC, and place an intrinsic textbox on it.
    Place this 2nd UC on a form.
    See that that textbox is inactive.

    How can we get the same behavior as with the intrinsic textbox?

    Thank you
    I can't replicate this. I tested with OCX and Std-EXE version.. (at least on XP and 7)

Page 52 of 94 FirstFirst ... 2424950515253545562 ... 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
  •  



Click Here to Expand Forum to Full Width