-
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?
-
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.
-
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.
-
Re: CommonControls (Replacement of the MS common controls)
Quote:
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.
Quote:
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.
Quote:
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.
-
Re: CommonControls (Replacement of the MS common controls)
Quote:
Originally Posted by
Krool
Do you have a Sub Main which calls InitVisualStyles prior to first form load?
yes , I placed it there
-
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 .
-
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 .
-
Re: CommonControls (Replacement of the MS common controls)
the previous problem does not occur in the exe , it happens only in IDE
-
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
-
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?
-
Re: CommonControls (Replacement of the MS common controls)
Quote:
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.
-
Re: CommonControls (Replacement of the MS common controls)
Quote:
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.
-
Re: CommonControls (Replacement of the MS common controls)
Quote:
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.
-
Re: CommonControls (Replacement of the MS common controls)
Quote:
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)
-
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.
-
Re: CommonControls (Replacement of the MS common controls)
Quote:
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*
-
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
-
Re: CommonControls (Replacement of the MS common controls)
Quote:
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.
-
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
-
Re: CommonControls (Replacement of the MS common controls)
Quote:
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?
-
Re: CommonControls (Replacement of the MS common controls)
Quote:
Originally Posted by
Semke
is the ocx also updated?
Yes, of course.
-
1 Attachment(s)
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. ;)
Attachment 162373
Good work
-
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.
-
Re: CommonControls (Replacement of the MS common controls)
Quote:
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
-
Re: CommonControls (Replacement of the MS common controls)
Quote:
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 .
-
Re: CommonControls (Replacement of the MS common controls)
Sorry for double posting
Quote:
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 .
-
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
-
1 Attachment(s)
Re: CommonControls (Replacement of the MS common controls)
Quote:
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 :eek2:
I am close to the concept found there :bigyello:
Attachment 162401
-
Re: CommonControls (Replacement of the MS common controls)
-
1 Attachment(s)
Re: CommonControls (Replacement of the MS common controls)
-
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
-
Re: CommonControls (Replacement of the MS common controls)
BTW, Edwardo's post about SelText in the RichTextBox Control fixed the undo problem
-
Re: CommonControls (Replacement of the MS common controls)
Quote:
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)
Quote:
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)
Quote:
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.
-
Re: CommonControls (Replacement of the MS common controls)
Quote:
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.
-
Re: CommonControls (Replacement of the MS common controls)
Quote:
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?
-
Re: CommonControls (Replacement of the MS common controls)
Quote:
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.
-
Re: CommonControls (Replacement of the MS common controls)
Quote:
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.
Quote:
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...
-
Re: CommonControls (Replacement of the MS common controls)
Quote:
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.
-
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
-
Re: CommonControls (Replacement of the MS common controls)
Quote:
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. :confused: I tested with OCX and Std-EXE version.. (at least on XP and 7)
-
Re: CommonControls (Replacement of the MS common controls)
Quote:
Originally Posted by
Krool
I can't replicate this. :confused: I tested with OCX and Std-EXE version.. (at least on XP and 7)
Now I wanted to throw together a small sample, and I can't replicate as well.
Nothing happened in the meantime, only a PC standby.
The small problem bothered me for so long, and now it is solved automatically.
I don't understand.
I'll watch more closely to know when the problem occurs and come back (or not).
Thanks for your effort
EDIT:
The effect is back again.
Unfortunately, I have no clue what happened.
A restart of the IDE cures the symptom.
After a while it comes back.
Krool, do you have an idea what I should check?
(There is no code in the UC that I test with.)
EDIT2:
Short after the UC issue an additional issue came up.
Hosam already reported it in #2047.
It's about command buttons don't react on the first click.
Perhaps this triggers your fantasy?
-
Re: CommonControls (Replacement of the MS common controls)
Internal improvement in the CommonDialog class for ShowPrinterEx function.
Prior to this update a WH_CALLWNDPROCRET hook for ShowPrinterEx (when 'HookEvents' = True) was used. (in order to raise InitDialog)
Now a more effective (no hook) lightweight IPrintDialogCallback is used to raise the InitDialog.
If needed in future, more features related to IPrintDialogCallback (and possibly IPrintDialogServices) may be added to interact more with the dialog while it's open.
-
1 Attachment(s)
Re: CommonControls (Replacement of the MS common controls)
TOOLTIP APPEARANCE QUESTION
The tooltips on TabStripW, ToolbarW and some more are fine, and they support even multiline.
Also the appearance is fine.
Other controls like CommandButtonW, FrameW etc. show different looking tooltips.
Here is an example:
Attachment 162595
Is there any chance to get the same tooltips as with TabStripW etc. in any control?
Thanks.
-
Re: CommonControls (Replacement of the MS common controls)
Hi Krool,
Writing here after quite some time.
As ever, remaining immensely thankful to your controls. They are proving to be of immeasurable benefit to the society. My thanks in TONS once again.
Well, I use the non-ocx version (always) and I wish to place the following two observations. Please note that I observed the following while testing with the latest non-ocx version too. I did not test with any of the ocx versions though, so far.
Observation 1.
To set a word as hyperlink in a RichTextBox control (for e.g. to set the word "works" in a RichTextBox named 'rtb1' as a hyperlink), I keep the word "works" selected and call the following code:
Code:
Dim myFormat As CHARFORMAT2
With myFormat
.cbSize = LenB(myFormat)
.dwEffects = CFE_LINK
.dwMask = CFM_LINK
End With
SendMessage rtb1.hWnd, EM_SETCHARFORMAT, SCF_SELECTION, myFormat
The above code works in Windows7. The word "works" does turn into a hyperlink (i.e. it does get underlined, does get displayed in blue color and when the mouse hovers over the word "works", the cursor does change to hand pointer).
But, the code does not work in Windows10. In Windows 10, the word "works" remains as it is, without turning into a hyperlink.
So, what has to be done for Windows10? Kindly please help, when possible.
(I tried certain things but they did not help. So, I checked whether the above code works when the normal 'MS RichTextBox' Control is used in Windows 10. It does work. The word "works" does turn into a hyperlink in a RichTextBox created using the 'MS RichTextBox' Control)
Observation 2.
In a RichTextBox, when the MaxLength propery is left at its default value of '0', I am able to internally set texts of length more than the 64kb. But, when I copy/paste text from outside sources OR try to type in the text area, no characters appear if the text length of our RichTextBox has crossed 64kb already. For this, what I have been doing is to explicitly set the MaxLength of our RichTextBoxes to '2147483647'. This works well. No problems while copying texts from external sources OR when trying to type. Even if the text length has already crossed 64KB, everything works correctly. But, I personally feel it is safer for the developer only if even with the default value of '0', normal behavior is exhibited. So, if possible to set right this issue, kindly please set it right.
Hope my above observations were/are right. If not, kindly please bear with me and please let me know what mistake I have done and guide me on what to do to set right the above issues.
My best wishes to you at all times, for your supremely phenomenal work!
-
Re: CommonControls (Replacement of the MS common controls)
Quote:
Originally Posted by
softv
Observation 1.
To set a word as hyperlink in a RichTextBox control (for e.g. to set the word "works" in a RichTextBox named 'rtb1' as a hyperlink), I keep the word "works" selected and call the following code:
Code:
Dim myFormat As CHARFORMAT2
With myFormat
.cbSize = LenB(myFormat)
.dwEffects = CFE_LINK
.dwMask = CFM_LINK
End With
SendMessage rtb1.hWnd, EM_SETCHARFORMAT, SCF_SELECTION, myFormat
The above code works in Windows7. The word "works" does turn into a hyperlink (i.e. it does get underlined, does get displayed in blue color and when the mouse hovers over the word "works", the cursor does change to hand pointer).
But, the code does not work in Windows10. In Windows 10, the word "works" remains as it is, without turning into a hyperlink.
So, what has to be done for Windows10? Kindly please help, when possible.
(I tried certain things but they did not help. So, I checked whether the above code works when the normal 'MS RichTextBox' Control is used in Windows 10. It does work. The word "works" does turn into a hyperlink in a RichTextBox created using the 'MS RichTextBox' Control)
Thank you softv for your points.
Concerning this point I can say that you should try to set the 'AutoURLDetect' property to False. It's by default to True in the RichTextBox.
Because MSDN says:
Do not set SetAutoURLDetect to TRUE if your edit control uses the CFE_LINK effect for text other than URLs. SetAutoURLDetect enables this effect for URLs and disables it for all other text
Also good to point out this because my RichTextBox is lacking a 'SelLink' property. Will be put in Todo. Currently I would like to maintain sync between ocx and non-ocx that's why I will for the moment not release such a new feature.
Quote:
Originally Posted by
softv
Observation 2.
In a RichTextBox, when the MaxLength propery is left at its default value of '0', I am able to internally set texts of length more than the 64kb. But, when I copy/paste text from outside sources OR try to type in the text area, no characters appear if the text length of our RichTextBox has crossed 64kb already. For this, what I have been doing is to explicitly set the MaxLength of our RichTextBoxes to '2147483647'. This works well. No problems while copying texts from external sources OR when trying to type. Even if the text length has already crossed 64KB, everything works correctly. But, I personally feel it is safer for the developer only if even with the default value of '0', normal behavior is exhibited. So, if possible to set right this issue, kindly please set it right.
Hope my above observations were/are right. If not, kindly please bear with me and please let me know what mistake I have done and guide me on what to do to set right the above issues.
That's right. According to MSDN:
Specifies the maximum amount of text that can be entered. If this parameter is zero, the default maximum is used, which is 64K characters. A COM object counts as a single character.
Quote:
Originally Posted by
Karl77
The tooltips on TabStripW, ToolbarW and some more are fine, and they support even multiline.
Also the appearance is fine.
Other controls like CommandButtonW, FrameW etc. show different looking tooltips.
Here is an example:
Attachment 162595
Is there any chance to get the same tooltips as with TabStripW etc. in any control?
I understand fully. However, it's not possible to overwrite the in-built 'ToolTipText' of the VBControlExtender.
For instance with the TabStrip control. I can't overwrite the 'TabStrip1.ToolTipText' property. Of course I can provide a better tooltip for the tabs, e.g. 'TabStrip1.Tabs(1).ToolTipText'
-
Re: CommonControls (Replacement of the MS common controls)
Quote:
Originally Posted by
Krool
However, it's not possible to overwrite the in-built 'ToolTipText' of the VBControlExtender.
For instance with the TabStrip control. I can't overwrite the 'TabStrip1.ToolTipText' property. Of course I can provide a better tooltip for the tabs, e.g. 'TabStrip1.Tabs(1).ToolTipText'
What about a ToolTipTextW property then?
Just an idea.
-
Re: CommonControls (Replacement of the MS common controls)
Quote:
Originally Posted by
Krool
Thank you softv for your points.
Concerning this point I can say that you should try to set the 'AutoURLDetect' property to False. It's by default to True in the RichTextBox.
Because MSDN says:
Do not set SetAutoURLDetect to TRUE if your edit control uses the CFE_LINK effect for text other than URLs. SetAutoURLDetect enables this effect for URLs and disables it for all other text
Thanks for your prompt reply, as ever, Krool.
The workaround suggested by you does help for Windows10. It works and Thank You so much. :)
Well, you must be knowing the following already with regard to Windows7 systems but yet stating it hereunder since, based on the same, I have a question.
In Windows 7, even with AutoURLDetect property set to True, I am able to easily set hyperlinks for our RichTextBox's text containing 100s of absolute URLs (e.g. http://google.com) and named URLs (e.g. "Click here to visit Google"). The AutoURLDetect property (which is set to True) takes care of setting the hyperlinks for the absolute urls, automatically. So, I need to take care of setting the hyperlinks for the named URLs alone, programmatically (using the already mentioned code, which uses CFE_LINK and CFM_LINK).
Based on the above, I have a question for Windows 10 systems.
In Windows 10 (may be in Windows 8 too; I do not have a Windows 8 system), it is clear now that setting 'AutoURLDetect property to False' for our RichTextBox (say rtb1) alone can help me set hyperlinks for named URLs in rtb1's text, when using the 'CFE_LINK and CFM_LINK' method. That being the case, the only way I have now (in Windows 10 systems) to set hyperlinks for all the URLs when rtb1's text contains both named and absolute URLs (in 100s) is:
- Set the AutoURLDetect property of rtb1 to False.
- Set the hyperlinks for the named URLs in rtb1's text, as usual. i.e. set them programmatically (using the already mentioned code, which uses CFE_LINK and CFM_LINK)
- Programmatically detect all the absolute URLs in rtb1's text.
- Set hyperlinks for the detected absolute URLs using the same 'CFE_LINK and CFM_LINK' method, the one used for setting hyperlinks for named URLs.
Is my above approach right? If not, when possible, either you or any other member may kindly let me know the better/easier approach. Thanks.
My hearty thanks and best wishes, at all times, for all your noble deeds, Krool.
-
1 Attachment(s)
Re: CommonControls (Replacement of the MS common controls)
LABELW REFRESH PROBLEM
A LabelW gets a new caption in a loop.
To let it display, I let it .Refresh.
This has no effect.
The new caption is not displayed.
I tried with an intrinsic label, and that works ok.
And surprise, if an intrinsic label gets the .Refresh, then the LabelW updates as well.
A miracle...
Try in the attached sample.
To see LabelW becoming lazy, it is sufficient to set the standard label .Visible = false.
Thank you
Attachment 162617
-
Re: CommonControls (Replacement of the MS common controls)
A Repaint routine can be implemented as a stronger alternative to Refresh like this
thinBasic Code:
Private Sub pvPumpMessages(ByVal hWnd As Long, ByVal lFromMsg As Long, ByVal lToMsg As Long)
Dim uMsg As APIMSG
Do While PeekMessage(uMsg, hWnd, lFromMsg, lToMsg, PM_REMOVE) <> 0
Call DispatchMessage(uMsg)
Loop
End Sub
Public Sub Repaint()
pvPumpMessages ContainerHwnd, WM_PAINT, WM_PAINT
End Sub
. . . or Karl77 can call pvPumpMessages in client code after batch updating the other 100s of labels on the form in question :-))
cheers,
</wqw>
-
Re: CommonControls (Replacement of the MS common controls)
Quote:
Originally Posted by
Karl77
LABELW REFRESH PROBLEM
Should be solved now. Thanks also to wqweto.
It's now properly implemented into the LabelW control.
Quote:
Originally Posted by
Karl77
What about a ToolTipTextW property then?
Not so bad idea. Will be put in the Todo's.
Quote:
Originally Posted by
softv
Is my above approach right?
Yes, but for Windows 7 I did the following observation:
True. In Windows 7 you can have AutoURLDetect to True and set manual links.
However, when I type something on a word block that have a partial link it will be gone if any char is typed.
Example: "asdasdasdasdasdasdasdx"
When the blue was marked as link and I put an x at end of the word block the blue link is erased.
But that's only the case when AutoURLDetect is True. If it's False then there is no harm.
In Windows 10 then you have no way to make manual links when AutoURLDetect is True. Which is in accordance to the MSDN description.
So my opinion is that this was a "behavior bug" in Windows 7 and was corrected then. Manual links shouldn't be possible when AutoURLDetect is True.
-
Re: CommonControls (Replacement of the MS common controls)
(LABELW REFRESH PROBLEM)
Quote:
Originally Posted by
Krool
Should be solved now. Thanks also to wqweto.
It's now properly implemented into the LabelW control.
Confirmed.
Works ok now.
Thanks to both of you.
-
Re: CommonControls (Replacement of the MS common controls)
Update released.
Major performenance boost when interacting with the .ComboItems collection in the ImageCombo control.
The following figures (in seconds) illustrate the effect. (run in IDE)
old:
Code:
10000x Add (index missing) = 0,754062
10000x Add (index:1) = 450,999812
10000x Item (index:i) = 0,142875
10000x Item (index:1) = 0,046875
10000x Remove (index:1) = 427,6133
new:
Code:
10000x Add (index missing) = 0,749937
10000x Add (index:1) = 5,776812
10000x Item (index:i) = 0,046875
10000x Item (index:1) = 0,031250
10000x Remove (index:1) = 5,814750
It's embarrassing to show this. The old figures got proportionately slower the more items.
-
Re: CommonControls (Replacement of the MS common controls)
Housekeeping update.
Enumeration.cls got removed and replaced by a lightweight COM replacement (based on DEXWERX's [VB6] IEnumVARIANT / For Each support without a typelib) directly in VTableHandle.bas.
The Enumeration is now faster and less complicated.
-
Re: CommonControls (Replacement of the MS common controls)
Quote:
Originally Posted by
Krool
The Enumeration is now faster and less complicated.
Sounds good.
I wanted to start to take over the new code into 'my' OCX.
But first I have a question.
In the new VTableHandle.bas, there is this line:
Code:
If VTableIPAOData.RefCount > 0 Or 1 > 2 Then
I don't understand the > 0 Or 1 > 2.
Isn't 1 > 2 always false?
Karl
-
Re: CommonControls (Replacement of the MS common controls)
Quote:
Originally Posted by
Karl77
In the new VTableHandle.bas, there is this line:
Code:
If VTableIPAOData.RefCount > 0 Or 1 > 2 Then
I don't understand the > 0 Or 1 > 2.
Isn't 1 > 2 always false?
The Or 1 > 2 is a leftover and can be removed, which I will do at next oppurtinity.
Luckily this has no impact/effect if it's there or not, but of course not needed.
Reason for this was that I wanted to test something and exclude this block.
Therefore I did:
Code:
If VTableIPAOData.RefCount > 0 And 1 > 2 Then
So the line is never True. (For testing)
Then I wanted to allow (temporary) the block and changed to:
Code:
If VTableIPAOData.RefCount > 0 Or 1 > 2 Then
It was intended that at the end this temp 1 > 2 is removed.
However, again. Luckily this forgotten removal has no impact and will be cleaned at next occasion.
-
Re: CommonControls (Replacement of the MS common controls)
Important update released for VTableHandle.bas.
Possible delay in *_Terminate events in Forms, UserControls etc. (could cause possible gdi overloads)
I am so sorry for this incompetence. :mad:
Code:
Public Sub DeActivateIPAO()
On Error GoTo CATCH_EXCEPTION
If VTableIPAOData.OriginalIOleIPAO Is Nothing Then Exit Sub
Dim PropOleObject As OLEGuids.IOleObject
Dim PropOleInPlaceSite As OLEGuids.IOleInPlaceSite
Dim PropOleInPlaceFrame As OLEGuids.IOleInPlaceFrame
Dim PropOleInPlaceUIWindow As OLEGuids.IOleInPlaceUIWindow
Dim PropOleInPlaceActiveObject As OLEGuids.IOleInPlaceActiveObject
Dim PosRect As OLEGuids.OLERECT
Dim ClipRect As OLEGuids.OLERECT
Dim FrameInfo As OLEGuids.OLEINPLACEFRAMEINFO
Set PropOleObject = VTableIPAOData.OriginalIOleIPAO
Set PropOleInPlaceActiveObject = VTableIPAOData.OriginalIOleIPAO
Set PropOleInPlaceSite = PropOleObject.GetClientSite
PropOleInPlaceSite.GetWindowContext PropOleInPlaceFrame, PropOleInPlaceUIWindow, VarPtr(PosRect), VarPtr(ClipRect), VarPtr(FrameInfo)
PropOleInPlaceFrame.SetActiveObject PropOleInPlaceActiveObject, vbNullString
If Not PropOleInPlaceUIWindow Is Nothing Then PropOleInPlaceUIWindow.SetActiveObject PropOleInPlaceActiveObject, vbNullString
Set VTableIPAOData.OriginalIOleIPAO = Nothing
Set VTableIPAOData.IOleIPAO = Nothing
CATCH_EXCEPTION:
End Sub
The bugfix is marked as red in above internal function 'DeactivateIPAO'.
After restoring the IPAO to VB's original IPAO it is necessary to de-reference our objects in VTableIPAOData.
As this was not done previously there was a reference link that hindered the UserControls to fire _Terminate event and also Form_Terminate.
So please replace. It will for sure solve other issues you may have encounter.
-
Re: CommonControls (Replacement of the MS common controls)
Quote:
Originally Posted by
Krool
Reason for this was that I wanted to test something and exclude this block.
Therefore I did:
Code:
If VTableIPAOData.RefCount > 0 And 1 > 2 Then
So the line is never True. (For testing)
FWIW, I'm using And False to disable predicates like this
thinBasic Code:
If VTableIPAOData.RefCount > 0 And False Then
and later enable with Then ' before fake conjunction like this
thinBasic Code:
If VTableIPAOData.RefCount > 0 Then ' And False Then
cheers,
</wqw>
-
Re: CommonControls (Replacement of the MS common controls)
Quote:
Originally Posted by
Krool
Important update released for VTableHandle.bas.
This is not incompetence, it is the exact opposite.
Same is true for 'embarrasing' in post #2092.
You can and do solve things.
Regarding the change in VTableHandle, it has indeed a big impact on stability.
With this change it is the 1st time MZTool's Programm analysis runs through my large project.
Before it always hung at some point and crashed VB in the end.
Very good!
Up to now I didn't see the unresponsive command buttons as well (see e.g. #2081).
EDIT:
The strange active UC problem, reported in #2079, is not healed by the change.
-
Re: CommonControls (Replacement of the MS common controls)
This is just a great project / contribution to the community.
It has far surpassed the original CCRP. (not to mention the original was closed source, and died without fixing some major bugs)
-
Re: CommonControls (Replacement of the MS common controls)
I'd just like to throw my vote of confidence in too.
Krool, this is an absolutely phenomenal project, and your diligence to maintaining it says volumes about your integrity.
All The Best,
Elroy