|
-
Oct 1st, 2018, 04:48 PM
#2041
Hyperactive Member
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?
-
Oct 1st, 2018, 11:28 PM
#2042
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.
-
Oct 2nd, 2018, 12:05 PM
#2043
Hyperactive Member
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.
-
Oct 2nd, 2018, 12:18 PM
#2044
Re: CommonControls (Replacement of the MS common controls)
 Originally Posted by MountainMan
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.
 Originally Posted by MountainMan
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.
 Originally Posted by MountainMan
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.
-
Oct 3rd, 2018, 07:57 AM
#2045
Addicted Member
Re: CommonControls (Replacement of the MS common controls)
 Originally Posted by Krool
Do you have a Sub Main which calls InitVisualStyles prior to first form load?
yes , I placed it there
-
Oct 3rd, 2018, 08:16 AM
#2046
Addicted Member
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 .
-
Oct 3rd, 2018, 08:17 AM
#2047
Addicted Member
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 .
-
Oct 3rd, 2018, 08:26 AM
#2048
Addicted Member
Re: CommonControls (Replacement of the MS common controls)
the previous problem does not occur in the exe , it happens only in IDE
-
Oct 3rd, 2018, 10:41 AM
#2049
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
-
Oct 3rd, 2018, 03:05 PM
#2050
Hyperactive Member
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?
-
Oct 3rd, 2018, 04:56 PM
#2051
Fanatic Member
Re: CommonControls (Replacement of the MS common controls)
 Originally Posted by Hosam AL Dein
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.
-
Oct 3rd, 2018, 11:08 PM
#2052
Re: CommonControls (Replacement of the MS common controls)
 Originally Posted by MountainMan
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.
-
Oct 5th, 2018, 07:03 AM
#2053
Lively Member
Re: CommonControls (Replacement of the MS common controls)
 Originally Posted by Krool
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.
-
Oct 5th, 2018, 07:43 AM
#2054
Re: CommonControls (Replacement of the MS common controls)
 Originally Posted by Semke
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)
-
Oct 7th, 2018, 07:23 AM
#2055
Lively Member
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.
-
Oct 7th, 2018, 09:10 AM
#2056
Re: CommonControls (Replacement of the MS common controls)
 Originally Posted by VBClassic04
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.
-
Oct 8th, 2018, 07:45 AM
#2057
Lively Member
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
-
Oct 9th, 2018, 02:55 PM
#2058
Re: CommonControls (Replacement of the MS common controls)
 Originally Posted by VBClassic04
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.
-
Oct 10th, 2018, 09:55 AM
#2059
Lively Member
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
-
Oct 10th, 2018, 10:29 AM
#2060
Lively Member
Re: CommonControls (Replacement of the MS common controls)
 Originally Posted by Krool
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?
-
Oct 10th, 2018, 01:18 PM
#2061
Re: CommonControls (Replacement of the MS common controls)
 Originally Posted by Semke
is the ocx also updated?
Yes, of course.
-
Oct 10th, 2018, 03:11 PM
#2062
Member
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
-
Oct 12th, 2018, 02:09 AM
#2063
Fanatic Member
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.
-
Oct 12th, 2018, 05:08 AM
#2064
Re: CommonControls (Replacement of the MS common controls)
 Originally Posted by VBClassic04
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
-
Oct 12th, 2018, 06:55 AM
#2065
Addicted Member
Re: CommonControls (Replacement of the MS common controls)
 Originally Posted by Karl77
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 .
-
Oct 12th, 2018, 06:56 AM
#2066
Addicted Member
Re: CommonControls (Replacement of the MS common controls)
Sorry for double posting
 Originally Posted by Karl77
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 .
-
Oct 12th, 2018, 07:51 AM
#2067
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.
-
Oct 12th, 2018, 08:11 AM
#2068
Addicted Member
Re: CommonControls (Replacement of the MS common controls)
 Originally Posted by DEXWERX
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
Last edited by Hosam AL Dein; Oct 12th, 2018 at 08:19 AM.
-
Oct 12th, 2018, 08:53 AM
#2069
Re: CommonControls (Replacement of the MS common controls)
Last edited by DEXWERX; Oct 12th, 2018 at 09:00 AM.
-
Oct 12th, 2018, 09:07 AM
#2070
Addicted Member
Re: CommonControls (Replacement of the MS common controls)
Last edited by Hosam AL Dein; Oct 12th, 2018 at 09:11 AM.
-
Oct 12th, 2018, 09:35 AM
#2071
Lively Member
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
-
Oct 12th, 2018, 09:38 AM
#2072
Lively Member
Re: CommonControls (Replacement of the MS common controls)
BTW, Edwardo's post about SelText in the RichTextBox Control fixed the undo problem
-
Oct 12th, 2018, 11:25 AM
#2073
Re: CommonControls (Replacement of the MS common controls)
 Originally Posted by DEXWERX
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)
 Originally Posted by VBClassic04
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)
 Originally Posted by VBClassic04
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.
-
Oct 12th, 2018, 05:35 PM
#2074
Re: CommonControls (Replacement of the MS common controls)
 Originally Posted by Krool
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.
-
Oct 13th, 2018, 01:16 AM
#2075
Re: CommonControls (Replacement of the MS common controls)
 Originally Posted by Eduardo-
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?
-
Oct 13th, 2018, 06:48 AM
#2076
Re: CommonControls (Replacement of the MS common controls)
 Originally Posted by Krool
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.
-
Oct 15th, 2018, 01:05 AM
#2077
Fanatic Member
Re: CommonControls (Replacement of the MS common controls)
 Originally Posted by DEXWERX
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...
-
Oct 15th, 2018, 07:40 AM
#2078
Re: CommonControls (Replacement of the MS common controls)
 Originally Posted by Karl77
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.
-
Oct 17th, 2018, 04:06 AM
#2079
Fanatic Member
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
-
Oct 17th, 2018, 12:36 PM
#2080
Re: CommonControls (Replacement of the MS common controls)
 Originally Posted by Karl77
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)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|