Re: CommonControls (Replacement of the MS common controls)
Excuse me , but I couldn`t find a description for the method in comments in activex version or even in mountainman`s documentation . Where can I find it ?
And for commandbuttonw , my bad . I have forgotten to set it at first .
Edit :
I found it in object browser . Thanks krool .
Last edited by Hosam AL Dein; Jan 12th, 2020 at 01:02 PM.
Info:
I really thought about the renaming. Rather to rename as 'VisualStylesFixes' or as you suggested 'VisualStyleFixes'.
However, looking at this as a single noun phrase rather than "two words in plural" brought me to the conclusion to 'VisualStylesFixes', because a 'fix' is a relationship between multiple components.
Thus, the singular form is "visual styles fix". (There is never just 1 single visual style affected, thus this always refer to plural visual styles)
And as there are different kind of fixes the plural is "visual styles fixes".
Re: CommonControls (Replacement of the MS common controls)
Krool, Great!
Now a different topic - migration.
In my effort to migrate my large project to use VBCCR, I got the idea of simply replacing every occurrence of standard MS widgets with VBCCR ones using sed (tested in Linux using sed-4.5).
Re: CommonControls (Replacement of the MS common controls)
Originally Posted by Krool
Which compile time errors? Then you know the spot which is causing the error and you can fix it.
Having MSComctlLib.Node in the code would cause errors at compile-time, but that is not the problem. The problem I'm experiencing is an error when trying to open a form in the IDE, and as far as I know the form has no MSComctlLib.Node (I searched through the form code).
Re: CommonControls (Replacement of the MS common controls)
Originally Posted by OldClock
Having MSComctlLib.Node in the code would cause errors at compile-time, but that is not the problem. The problem I'm experiencing is an error when trying to open a form in the IDE, and as far as I know the form has no MSComctlLib.Node (I searched through the form code).
The .frx file is the problem in this case.
You can only delete it and supply then the lost information again in the properties.
Update released. The migration problem for 'PasswordChar' got fixed. So you can update your script accordingly that the removal is not necessary anymore.
Re: CommonControls (Replacement of the MS common controls)
Krool, thank you for these controls, they saved my app.
I have a problem with the status bar control, the "Spring" autosize parameter seems to not work like the standard control.
When all the panels of the bar have the "Spring" parameter and you resize the container window, in the standard controls they resize proportionally, but in your control all but the last panel remain of the design-time size, while the last one fills all the new space.
What can I do to reproduce the standard control behavior?
Attached a sample project. StatusBar.zip
Re: CommonControls (Replacement of the MS common controls)
Originally Posted by sbri
I have a problem with the status bar control, the "Spring" autosize parameter seems to not work like the standard control.
When all the panels of the bar have the "Spring" parameter and you resize the container window, in the standard controls they resize proportionally, but in your control all but the last panel remain of the design-time size, while the last one fills all the new space.
What can I do to reproduce the standard control behavior?
Fixed. Thanks!! (Update released)
Originally Posted by OldClock
kr00l is centering text in textboxes broken in 1.6.58? I can't get it centered...
I can't reproduce. For me it's centering and no problem in your demo...
My MainForm.frm is very large. Editing it in the VB6 IDE was slow when using Microsoft Windows Common Controls(-2) 6.0, but now with VBCCR16 (currently on 1.06.0058 OCX) it has become unusably slow (>20 seconds to open the MainForm for editing in the IDE). I suspect my program is larger than most, so it's no surprise that these issues appear.
Sometimes a crash occurs while opening the main form in the IDE or in the compiled program. The first time I run the compiled EXE after booting Windows (XP SP3 in VBox), the login screen shows correctly, and when I log it and the program tries to show the MainForm it crashes with a VBCCR window appearing with the error message
Run-time error '0'
The login screen should look like this:
When it crashes, it becomes like this, with those diagonal lines and horrible kerning:
If I re-run the EXE and re-login, the MainForm shows correctly.
These crashes do not result from the program's code, as it has been stable for a long time, and only appeared after switching to VBCCR. I suppose they come from a combination of factors: the main form containing a huge number of controls (2500 in total), perhaps more than VB6 was designed for; imperfections in VBCCR; and bugs in Windows.
Sometimes the same sort of crash happens from within the IDE, with the diagonal lines and bad kerning, but there the error signature says:
Is this a known issue, and is there anything I can do to mitigate it?
Unfortunately I am not allowed to upload the code.
I also ran into this error:
Run-time error '7':
Out of memory
It turns out this has nothing to do with memory, and appears only if the OCX file is not placed alongside my program's executable (I use side-by-side loading via the manifest file embedded in the resource file). It would be better if the error message actually said that the OCX file is missing.
Re: CommonControls (Replacement of the MS common controls)
OldClock,
The run time error '0' we had already a few times in this thread.
Its an incompatibility of 32 bit icons loaded at design time on in Vista+ (ok so far) but then later crashes when you attempt to use them in Win XP. (MS issue)
Re: CommonControls (Replacement of the MS common controls)
Hi Krool,
Thank you for your effort to keep this project alive and up-to-date, it's a huge commitment, also huge time-consumer. Appreciate it.
Today I decided to replace some of components in my application with a ListView control. Since dark theme is widely used nowadays, my app also support it. However, when I added Groups to my listview, the result wasn't very beautiful as you can see below:
Initially, I tried to set fore color of the Group text as follows:
Code:
Friend Property Let FGroupForeColor(ByVal Value As OLE_COLOR)
Dim groupMetrics As LVGROUPMETRICS
groupMetrics.cbSize = Len(groupMetrics)
groupMetrics.Mask = LVGMF_TEXTCOLOR
groupMetrics.crHeader = Value
If ListViewHandle <> 0 Then
SendMessage ListViewHandle, LVM_SETGROUPMETRICS, 0, ByVal VarPtr(groupMetrics)
Me.Refresh
End If
End Property
Unfortunately, LVGMF_TEXTCOLOR is not implemented (really) and the result was...none.
Most of the Google results state that changing color of group text is not possible (like this). However, I found that article in MSDN forum:
The code is quite ugly but it works somehow, just to prove that it is completely possible to draw a custom Group header:
Code:
Case NM_CUSTOMDRAW
Dim FontHandle As Long, Bold As Boolean, ForeColor As OLE_COLOR
Dim NMLVCD As NMLVCUSTOMDRAW
CopyMemory NMLVCD, ByVal lParam, LenB(NMLVCD)
Select Case NMLVCD.NMCD.dwDrawStage
Case CDDS_PREPAINT
WindowProcUserControl = CDRF_NOTIFYITEMDRAW
If NMLVCD.dwItemType = LVCDI_GROUP Then
Dim rectHeader As RECT: rectHeader.Top = LVGGR_HEADER
Dim nItem As Long: nItem = NMLVCD.NMCD.dwItemSpec
Dim nRet As Long: nRet = SendMessage(ListViewHandle, LVM_GETGROUPRECT, nItem, rectHeader)
Dim hPen As Long: hPen = CreatePen(0, 1, vbRed)
Dim OldhPen As Long: OldhPen = SelectObject(NMLVCD.NMCD.hDC, hPen)
Dim hBrush As Long: hBrush = CreateSolidBrush(&H80FF&)
Dim OldhBrush As Long: OldhBrush = SelectObject(NMLVCD.NMCD.hDC, hBrush)
Rectangle NMLVCD.NMCD.hDC, rectHeader.Left, rectHeader.Top, rectHeader.Right, rectHeader.Bottom
Call SetTextColor(NMLVCD.NMCD.hDC, vbGreen)
Call DrawText(NMLVCD.NMCD.hDC, "TEST1-2-3", Len("TEST1-2-3"), rectHeader, DT_SINGLELINE Or DT_CENTER Or DT_VCENTER)
DeleteObject hPen: DeleteObject hBrush
End If
Exit Function
I believe that many people will appreciate a custom Group Header. My knowledge is not enough to make it bullet-proof, I just copy-paste. For example, now adding a footer doesn't work - IDE crash.
Dark theme really doesn't look good with blue group header
Thank you.
Edit: the code above doesn't break Group.Footer, in my case the Footer works only when SubsetLink is set, otherwise, the IDE crashes. It's the same with Standard EXE Version sample.
Code:
With .Groups.Add(, , "Header Title")
'.SubsetLink = "Subset Link?"
.Footer = "Footer Title"
.FooterAlignment = LvwGroupFooterAlignmentCenter
End With
Last edited by npac4o; Jan 21st, 2020 at 04:17 AM.
Reason: Attaching pictures to the post
Re: CommonControls (Replacement of the MS common controls)
Code:
If NMLVCD.dwItemType = LVCDI_GROUP Then
Dim rectHeader As RECT: rectHeader.Top = LVGGR_HEADER
Dim nItem As Long: nItem = NMLVCD.NMCD.dwItemSpec
Dim nRet As Long: nRet = SendMessage(ListViewHandle, LVM_GETGROUPRECT, nItem, rectHeader)
Dim hPen As Long: hPen = CreatePen(5, 1, vb3DFace)
Dim OldhPen As Long: OldhPen = SelectObject(NMLVCD.NMCD.hDC, hPen)
Dim hBrush As Long: hBrush = CreateSolidBrush(&H80FF&)
Dim OldhBrush As Long: OldhBrush = SelectObject(NMLVCD.NMCD.hDC, hBrush)
Dim lvg As LVGROUP: With lvg
.cbSize = Len(lvg)
.Mask = LVGF_STATE Or LVGF_GROUPID Or LVGF_HEADER
End With
nRet = SendMessage(ListViewHandle, LVM_GETGROUPINFO, nItem, lvg)
Dim sText As String: sText = GetStringFromPointer(lvg.pszHeader)
Call Rectangle(NMLVCD.NMCD.hDC, rectHeader.Left, rectHeader.Top, rectHeader.Right, rectHeader.Bottom)
Call SetTextColor(NMLVCD.NMCD.hDC, vbGreen)
Call DrawText(NMLVCD.NMCD.hDC, sText, Len(sText), rectHeader, DT_SINGLELINE Or DT_CENTER Or DT_VCENTER Or DT_NOCLIP)
DeleteObject hPen: DeleteObject hBrush
WindowProcUserControl = CDRF_SKIPDEFAULT
Else
WindowProcUserControl = CDRF_NOTIFYITEMDRAW
End If
It's a fun to experiment
Last edited by npac4o; Jan 21st, 2020 at 07:25 AM.
Re: CommonControls (Replacement of the MS common controls)
Hi!
I am looking at the Checkbox ownerdraw event, could you please give a description of the paramaters
OwnerDraw(ByVal Action As Long, ByVal State As Long, ByVal hDC As Long, ByVal Left As Long, ByVal Top As Long, ByVal Right As Long, ByVal Bottom As Long)
Re: CommonControls (Replacement of the MS common controls)
Originally Posted by npac4o
the code above doesn't break Group.Footer, in my case the Footer works only when SubsetLink is set, otherwise, the IDE crashes. It's the same with Standard EXE Version sample.
Code:
With .Groups.Add(, , "Header Title")
'.SubsetLink = "Subset Link?"
.Footer = "Footer Title"
.FooterAlignment = LvwGroupFooterAlignmentCenter
End With
Interesting. However, it applies only when the ListView1.GroupSubsetCount is > 0. (feature is enabled)
I don't know how to solve it, seems like a comctl32.dll bug.
But, you can workaround it by going way 1 or way 2:
Way1:
Code:
With .Groups.Add(, , "Header Title")
.SubsetLink = "" ' StrPtr <> 0
.Footer = "Footer Title"
.FooterAlignment = LvwGroupFooterAlignmentCenter
End With
Way2: (can be done of course already at design time. A new ListView has GroupSubsetCount = 0 by default)
Code:
ListView1.GroupSubsetCount = 0
Originally Posted by Semke
Hi!
I am looking at the Checkbox ownerdraw event, could you please give a description of the paramaters
OwnerDraw(ByVal Action As Long, ByVal State As Long, ByVal hDC As Long, ByVal Left As Long, ByVal Top As Long, ByVal Right As Long, ByVal Bottom As Long)
Certain members of the DRAWITEMSTRUCT are passed to the OwnerDraw event.
You may find plenty of examples on the net about subclassing a checkbox and handling WM_DRAWITEM.
So just look at those snippets and implement them accordingly into the OwnerDraw event.
Re: CommonControls (Replacement of the MS common controls)
Hey
I'm making a UserControl button using VBCCR 1.06.0059 widgets.
The button has three states:
Disabled
When disabled, the icon and text should be gray.
Normal
Icon and text white.
Hover
Icon and text gold.
The button is made using the Image, LabelW and FrameW widgets. Some VBCCR widgets, such as LabelW and FrameW, support the MouseEnter and MouseLeave events, however the UserControl itself does not. I created procedures for LabelW and FrameW to support the MouseEnter and MouseLeave events, however they never fire. What am I doing wrong?
I need the UserControl to change the image to "hover" when the user moves the mouse over it, and to revert the image to "normal" when the mouse leaves. Since the picture doesn't change on MouseEnter/MouseLeave, I made it change on Click to just show that the Click event works while the others don't.
The project is attached. Note how the FrameW1_MouseMove and LabelW1_MouseMove events fire (if you uncomment them), while UserControl_MouseMove and none of the MouseEnter/MouseLeave events ever fire.
Re: CommonControls (Replacement of the MS common controls)
Originally Posted by OldClock
I'm making a UserControl button using VBCCR 1.06.0059 widgets.
The button has three states:
Disabled
When disabled, the icon and text should be gray.
Normal
Icon and text white.
Hover
Icon and text gold.
The button is made using the Image, LabelW and FrameW widgets. Some VBCCR widgets, such as LabelW and FrameW, support the MouseEnter and MouseLeave events, however the UserControl itself does not. I created procedures for LabelW and FrameW to support the MouseEnter and MouseLeave events, however they never fire. What am I doing wrong?
I need the UserControl to change the image to "hover" when the user moves the mouse over it, and to revert the image to "normal" when the mouse leaves. Since the picture doesn't change on MouseEnter/MouseLeave, I made it change on Click to just show that the Click event works while the others don't.
The project is attached. Note how the FrameW1_MouseMove and LabelW1_MouseMove events fire (if you uncomment them), while UserControl_MouseMove and none of the MouseEnter/MouseLeave events ever fire.
Set .MouseTrack = True for FrameW and LabelW and try again.
Re: CommonControls (Replacement of the MS common controls)
Hello Krool, I'm using some of your controls in a project so thank you very much.
I want to ask you what's the purpose of having two properties in the ScrollBar control: RightToLeft and RightToLeftLayout that need to be both set to True to set the direction RTL?
Also I want to report that with the last version of the controls, opening the main form, selecting the ProgressBar, and pressing F4 to show the property screen, I get this error message:
I think it might be because you updated OLEGuids.tlb and I'm using an old version.
Anyway the controls that I am actually using in my project are from the older version (I downloaded it about two months ago), so I don't know if it would be a good idea to register the newer OLEGuids.tlb in my case.
Re: CommonControls (Replacement of the MS common controls)
Originally Posted by Eduardo-
I'm using some of your controls in a project so thank you very much.
I want to ask you what's the purpose of having two properties in the ScrollBar control: RightToLeft and RightToLeftLayout that need to be both set to True to set the direction RTL?
It's a complex story. Every control has it's unique treatment.
In general, when a RightToLeft = True then apply WS_EX_RTLREADING and if RightToLeft and RightToLeftLayout = True then apply only WS_EX_LAYOUTRTL.
Here is my internal documentation about the RightToLeft handling for each control:
Code:
> CoolBar
dwMask : RightToLeftLayout = True WS_EX_LAYOUTRTL; CDDS_PREPAINT in NM_CUSTOMDRAW SetTextAlign
Extra : RightToLeftLayout property
> LinkLabel
dwMask : CDDS_PREPAINT in NM_CUSTOMDRAW SetTextAlign
Extra : InitReverse .Alignment; ToolTip
> DTPicker
dwMask : RightToLeftLayout = True WS_EX_LAYOUTRTL; EditHandle: WS_EX_RTLREADING
Extra : RightToLeftLayout property; Reverse .CalendarRightAligned;
> MonthView
dwMask : RightToLeftLayout = True WS_EX_LAYOUTRTL
Extra : RightToLeftLayout property
> Pager
dwMask : RightToLeftLayout = True WS_EX_LAYOUTRTL
Extra : RightToLeftLayout property
> ListView
dwMask : RightToLeftLayout = True WS_EX_LAYOUTRTL; WS_EX_RTLREADING
Extra : RightToLeftLayout property; ToolTip; HDF_RTLREADING
> ComboBoxW/FontCombo
dwMask : WS_EX_RTLREADING Or WS_EX_RIGHT Or WS_EX_LEFTSCROLLBAR
Extra : Clear ES_RIGHT in .hWndEdit
> ImageCombo
dwMask : RightToLeftLayout = True WS_EX_LAYOUTRTL; WS_EX_RTLREADING Or WS_EX_RIGHT Or WS_EX_LEFTSCROLLBAR
Extra : RightToLeftLayout property; Clear ES_RIGHT in .hWndEdit
> ToolBar
dwMask : RightToLeftLayout = True WS_EX_LAYOUTRTL; TB_SETDRAWTEXTFLAGS DT_RTLREADING
Extra : RightToLeftLayout property; TPM_RIGHTALIGN+TPM_LAYOUTRTL in ShowButtonMenuItems; ToolTip; Call ReCreateToolBar
> Slider
dwMask : RightToLeftLayout = True WS_EX_LAYOUTRTL
Extra : RightToLeftLayout property; ToolTip; Call ReCreateSlider
> UpDown
dwMask : RightToLeftLayout = True WS_EX_LAYOUTRTL
Extra : RightToLeftLayout property
> ProgressBar
dwMask : RightToLeftLayout = True WS_EX_LAYOUTRTL
Extra : RightToLeftLayout property
> CommandLink
dwMask : RightToLeftLayout = True WS_EX_LAYOUTRTL; WS_EX_RTLREADING
Extra : RightToLeftLayout property
> Animation
dwMask : RightToLeftLayout = True WS_EX_LAYOUTRTL
Extra : RightToLeftLayout property; Call ReCreateAnimation
> TreeView
dwMask : RightToLeftLayout = True WS_EX_LAYOUTRTL; TVS_RTLREADING
Extra : RightToLeftLayout property
> StatusBar
dwMask : RightToLeftLayout = True WS_EX_LAYOUTRTL; 0
Extra : RightToLeftLayout property; ToolTip; DrawPanel SetTextAlign
> TabStrip
dwMask : RightToLeftLayout = True WS_EX_LAYOUTRTL; WS_EX_RTLREADING
Extra : RightToLeftLayout property; MapWindowPoints; ToolTip; Call ReCreateTabStrip
> SpinBox
dwMask : Edit: WS_EX_RTLREADING; UpDown: 0
Extra : InitReverse/Reverse .Alignment; InitReverse/Reverse .TextAlignment; Remove .Orientation
> CheckBoxW
dwMask : WS_EX_RTLREADING
Extra : InitReverse .Alignment; InitReverse/Reverse .TextAlignment; InitReverse/Reverse .ImageListAlignment
> CommandButtonW
dwMask : WS_EX_RTLREADING
Extra : Reverse .Alignment; InitReverse/Reverse .ImageListAlignment; InitReverse/Reverse .SplitButtonAlignment
> LabelW
dwMask : DT_RTLREADING
Extra : InitReverse .Alignment
> ListBoxW
dwMask : WS_EX_RTLREADING Or WS_EX_RIGHT Or WS_EX_LEFTSCROLLBAR
Extra : vbListBoxCheckbox SetTextAlign
> FrameW
dwMask : WS_EX_RTLREADING
Extra : InitReverse/Reverse .Alignment
> TextBoxW
dwMask : WS_EX_RTLREADING Or WS_EX_LEFTSCROLLBAR
Extra : InitReverse .Alignment
> RichTextBox
dwMask : WS_EX_RTLREADING Or WS_EX_RIGHT Or WS_EX_LEFTSCROLLBAR
Extra : Call ReCreateRichTextBox()
> OptionButtonW
dwMask : WS_EX_RTLREADING
Extra : InitReverse .Alignment; InitReverse/Reverse .TextAlignment; InitReverse/Reverse .ImageListAlignment
Originally Posted by Eduardo-
I think it might be because you updated OLEGuids.tlb and I'm using an old version.
Yes, just copy/paste the new OLEGuids.tlb and replace the old one.
Re: CommonControls (Replacement of the MS common controls)
Originally Posted by Krool
It's a complex story. Every control has it's unique treatment.
In general, when a RightToLeft = True then apply WS_EX_RTLREADING and if RightToLeft and RightToLeftLayout = True then apply only WS_EX_LAYOUTRTL.
I think I understand that you added the RightToLeft property to all controls that need to have a RightToLeftLayout property even if they are not displaying any text, just to standardize the controls properties and how they work.
The rule is: first set RightToLeft to True, then you are allowed to also set RightToLeftLayout to True.
Is that right?
Originally Posted by Krool
Yes, just copy/paste the new OLEGuids.tlb and replace the old one.
But can I have any problem if I stay using the old version of the controls with the new version of OLEGuids.tlb?
Re: CommonControls (Replacement of the MS common controls)
Originally Posted by Eduardo-
I think I understand that you added the RightToLeft property to all controls that need to have a RightToLeftLayout property even if they are not displaying any text, just to standardize the controls properties and how they work.
The rule is: first set RightToLeft to True, then you are allowed to also set RightToLeftLayout to True.
Is that right?
Yes
Originally Posted by Eduardo-
But can I have any problem if I stay using the old version of the controls with the new version of OLEGuids.tlb?
Yes you can have problems. What's the reason to only update one thing but not the other?
Re: CommonControls (Replacement of the MS common controls)
Originally Posted by Krool
Yes
OK.
Originally Posted by Krool
Yes you can have problems. What's the reason to only update one thing but not the other?
I didn't update anything.
I just wanted to see something and for it I downloaded and opened your latest version of Common Controls project, and then I saw the error and wanted to report it.
But no, I'm not planning to change the controls in my project often unless I have a reason. I'm just using some LabelWs, ComboBoxWs and a ProgressBar in a quite straightforward manner, mainly for supporting Unicode and RightToLeft (I'm not using the OCX version but the source code, and just what I need).
What problem can I have if I ever register the new TLB? (I guess a lot of people can be in the same situation because I don't think that everybody is updating their projects to the latest version of the controls continuously, but they could eventually register the new TLB -on purpose or perhaps unintentionally)
Re: CommonControls (Replacement of the MS common controls)
Originally Posted by Eduardo-
(I guess a lot of people can be in the same situation because I don't think that everybody is updating their projects to the latest version of the controls continuously, but they could eventually register the new TLB -on purpose or perhaps unintentionally)
It should have been perfect from the beginning. Somehow this was not possible and I am sorry for the continuously updates..
Re: CommonControls (Replacement of the MS common controls)
Is Windows XP supposed to be supported? I fired up a small XP VM and get some runtime errors with the Toolbar or maybe the related ImageList. I'm not planning to deploy to XP, so I won't bother looking into it any further if that OS isn't supported by VBCCR16.OCX.
Re: CommonControls (Replacement of the MS common controls)
Originally Posted by Krool
It should have been perfect from the beginning. Somehow this was not possible and I am sorry for the continuously updates..
Sorry Krool if you got offended. It wasn't my intention.
Sometimes we as programmers expect that everybody will update to the latest version, but for the users sometimes it is not so easy due to different reasons.
I want to comment that I tested updating to your latest version but I experienced an issue, so I went back to the previous one.
The issue can be seen also in your demo project.
To do so please open MainForm and go to the code in Form_Load.
Then put a stop watch in the first line (Call SetupVisualStylesFixes(Me)) by pressing F9.
Press F5 to run.
When it stops on that line, press F8 to continue step by step.
If the problem is reproduced successfully there, you'll see that the code flow goes to the line:
Code:
Private Function IOleControl_AddRef(ByRef This As Long) As Long
in VTableHandle module and does not move further by pressing F8 more times. It only resumes by pressing F5, but then lossing the possibility to run step by step.
I also found by chance an error in your demo project: to see it click on the button "RichTextBox Demo". The test program is trying to assign a read-only property.