CommonControls (Replacement of the MS common controls)
This project is intended to replace the MS common controls for VB6.
The "MSCOMCTL.OCX" (respectively "COMCTL32.OCX") can be replaced completly.
The "MSCOMCT2.OCX" (respectively "COMCT232.OCX") can be replaced completly.
The "RICHTX32.OCX" can be replaced completly.
The "COMDLG32.OCX" can be replaced completly.
The "COMCT332.OCX" can be replaced completly.
The "MCIWNDX.OCX" (shipped with VB5) can be replaced completly.
The "SYSINFO.OCX" can be replaced completly.
Unicode is supported for all the stated controls. Also these are full DPI-Aware.
At design-time (IDE) there is only one dependency. (OLEGuids.tlb)
This is a modified version of the original .tlb from the vbaccelerator website.
But for the compiled .exe there are no dependencies, because the .tlb gets then compiled into the executable.
Everything should be self explained, because all functions and properties have a description.
The source code of the project can also be viewed on GitHub.
This Demo shows of how to make the ToolBar control accessible per shortcut key on a MDIForm.
ActiveX Control version, together with a Registration-Free (Side-by-side) solution: Version 1.7
Notes:
- When using the SetParent or MoveWindow API, pass .hWndUserControl and not .hWnd.
- When changing the "Project Name", have all forms open, else all properties are lost. Because the library to which the controls are referring to is the "Project Name" itself. Having all forms open will ensure that the .frx files will be updated with the new "Project Name".
List of revisions:
Code:
19-Jan-2021
- TabMinWidth property can be set to -1 in the TabStrip control.
23-Sep-2020
- No crash anymore when passing a vbNullString to the .SelText property in various controls. (e.g. TextBoxW)
Though, the fix concerns only Windows XP or below. Because as of Vista+ a NULL StrPtr() on EM_REPLACESEL does not cause harm.
18-Aug-2020
- Enhancement for the FrameW control.
- Access key now supported.
- TabIndex now supported. (important to be set meaningful so the access key works properly)
- Included UseMnemonic property. (not available in a VB.Frame, thus being an advantage)
15-Aug-2020
- Some minor internal improvements.
08-Aug-2020
- Bugfix in the OLEDropMode property in the FrameW control.
It was not possible to set it to OLEDropModeManual when windowless control(s) were contained in it.
- It is now possible for the TbrButtonMenus collection to change the key on a particular TbrButtonMenu in the ToolBar control.
06-Aug-2020
- It is now possible for the TbrButtons collection to change the key on a particular TbrButton in the ToolBar control.
29-Jul-2020
- Included new RefreshMousePointer function in Common.bas.
- All controls who receive CBN_DROPDOWN will call RefreshMousePointer function when current hCursor is NULL.
This is a unresolved misbehavior in user32.dll ever since.
26-Jul-2020
- Internal improvement in the SelText property in the RichTextBox control.
25-Jul-2020
- It is now possible for the CbrBands collection to change the key on a particular CbrBand in the CoolBar control.
23-Jul-2020
- Internal improvement in the SysInfo control.
20-Jul-2020
- It is now possible for the SbrPanels collection to change the key on a particular SbrPanel in the StatusBar control.
- Included the 'NodeRangeSelect' event in TreeView control with a Cancel parameter.
It fires for each node when a range of nodes is about to be selected. (like 'NodeBeforeSelect', but for shift-range selection)
16-Jul-2020
- The GetEmptyMarkup event supports now right-to-left in the ListView control.
15-Jul-2020
- Added optional 'Index' param in the .WorkAreas.Add method (to insert before index) in the ListView control.
12-Jul-2020
- Reworked the .WorkAreas property in the ListView control.
It is not anymore a property which just returns/sets an array of coordinates.
Instead it returns now a collection to the new 'LvwWorkAreas' class.
The collection is not 'private' and relies fully on LVM_GETWORKAREAS/LVM_SETWORKAREAS.
The .ListItemIndices of a 'LvwWorkArea' returns all list items that belongs to a work area.
Also the new .WorkArea property of a 'LvwListItem' returns the work area to which a list item belongs to.
09-Jul-2020
- Included MultiSelect property in the TreeView control.
It can be set to 'None' (Default), 'All', 'VisibleOnly', 'RestrictSiblings'.
The new 'SelectedNodes' property returns a collection to the new 'TvwSelectedNodes' class.
With this class the count and the selected nodes can be retrieved or enumerated.
The most recent select node has index 1 and the oldest select node has the last index. (sorted by history)
Included the 'AnchorItem' property which returns the node from which a multiple selection starts.
Included the 'SelectedIndex' function in the TvwNode class. It returns the index of the associated selected nodes collection.
05-Jul-2020
- Internal improvement in the TreeView control.
01-Jul-2020
- VirtualCombo control now works on comctl version 5.8x.
- ItemBkColor now fired in a virtual ListView control.
- Internal improvement for the HighlightHot property in the ListView control.
30-Jun-2020
- Included Left/Top/Width/Height (read-only) property in the ListSubItem of the ListView control. (LVM_GETSUBITEMRECT)
- Included function 'FindNearestItem' in the ListView control. (LVFI_NEARESTXY)
28-Jun-2020
- Included CacheVirtualItems event in the ListView control. (LVN_ODCACHEHINT)
- LVN_ODSTATECHANGED processed to enhance the ItemSelect event in a virtual ListView control.
- Renamed param 'Index' to 'ItemIndex' in the GetVirtualItem event in the ListView control.
Thus it does not clash anymore with the 'Index As Integer' param in a control array.
- ItemSelect event can now pass a ListItem 'As Nothing' in a virtual ListView control. (LVN_ITEMCHANGED, iItem = -1)
Because a virtual list view does only inform about each selected item and not for each deselected item.
- It is now possible for the TbsTabs collection to change the key on a particular TbsTab in the TabStrip control.
27-Jun-2020
- It is now possible for the LvwGroups collection to change the key on a particular LvwGroup in the ListView control.
- It is now possible for the ImlListImages collection to change the key on a particular ImlListImage in the ImageList control.
26-Jun-2020
- Included the FontWeight property in the CommonDialog class.
23-Jun-2020
- Included the VListBox control. (virtual list box control)
The name 'VirtualList' would confuse as this is a common word for a virtual list view.
Thus to avoid that the name must contain 'ListBox' and to keep it short then 'VListBox'.
- TabbedTextOut API now used in a Checkbox/Option Style ListBoxW control when UseTabStops property is True.
- Bugfix in the 32-bit scrolling in a multi-column ListBoxW and when WS_EX_LEFTSCROLLBAR is set.
- Text property in ListBoxW now data-bindable to a VB.Data control.
07-Jun-2020
- Internal improvement in the OptionButtonW control.
- Bugfix in the OptionButtonW control, the default value property should be False in Read/WriteProperties.
This change makes migration from VB.OptionButton to OptionButtonW easier at the cost of compatibility break to old OptionButtonW.
- Major internal improvement for MCIWnd as no WM_MOUSEACTIVATE overhead necessary anymore.
This results for 'ComCtlsTopParentValidateControls' being obselete and was removed!
02-Jun-2020
- Included the BeforeUserInput/AfterUserInput event in the DTPicker control.
The BeforeUserInput provides a hWndEdit and AfterUserInput is always fired, even when canceled.
Existent ParseUserInput event only fires if the user did not cancel.
01-Jun-2020
- Internal improvements in the ComboBoxW/FontCombo/VirtualCombo/ImageCombo controls.
28-May-2020
- WM_UNICHAR handler now supports surrogate pairs. (UTF32 conversion)
26-May-2020
- SimpleText property now uses SBT_RTLREADING in case RightToLeft is True in the StatusBar control.
- Changed IncrementalSearch event params in the VirtualCombo control.
25-May-2020
- Behavior bugfixes in the VirtualCombo control when Style is <> DropDownList.
- Included DrawMode property in the VirtualCombo control.
Only options are Normal and OwnerDrawFixed. (OwnerDrawVariable not possible due to LBS_NODATA restriction)
24-May-2020
- Included the VirtualCombo control. (super-classed combo box control with a no-data list box portion)
The .ListCount property is write-able and populates the list very quickly.
GetVirtualItem event retrieves the item strings.
IncrementalSearch/FindVirtualItem event can also be handled to enable full functionality.
21-May-2020
- Included the DrawMode property in the Slider control.
20-May-2020
- Major internal improvement for ImageCombo as no WM_MOUSEACTIVATE overhead necessary anymore.
- Improvement for the WM_NCPAINT handler in the RichTextBox control.
- Included a WM_NCPAINT handler for the HotKey control to resolve msctls_hotkey32 class bugs. (it behaves then like an edit control)
18-May-2020
- Included SortType LvwSortTypeLogical in the ListView control.
- Bugfix related to 08-May-2020 update. (WM_PRINTCLIENT in IPAddress control)
17-May-2020
- Bugfix in the Add method of LvwColumnHeaders in the ListView control.
- Included Text property (read-only) in the HotKey control.
- BackColor property in the HotKey control works now also when Enabled = False.
- Major internal improvement for HotKey as no WM_MOUSEACTIVATE overhead necessary anymore.
09-May-2020
- UserControl.Cls added in the UserControl_Paint event in the IPAddress control.
08-May-2020
- The IPAddress control supports now the WM_PRINTCLIENT message.
This was lost due to the rebuild from scratch as of 17-Apr-2020. (no longer use of SysIPAddress32 class)
07-May-2020
- Width property of a Panel in the StatusBar control not read-only anymore. It behaves as the MS StatusBar.
06-May-2020
- Removed the BackColor property in the DTPicker control for simplification.
It was anyhow not possible anymore as of Vista+ ..
04-May-2020
- Included Font/Text/TextColor property in the ProgressBar control.
Text placeholders: {0} = Value, {1} = Min, {2} = Max and {3} = Percent value between 0 and 100.
03-May-2020
- Major internal improvement for LinkLabel/MonthView/ComboBoxW/FontCombo as no WM_MOUSEACTIVATE overhead necessary anymore.
- Other minor internal improvements.
30-Apr-2020
- Internal improvement in the OptionButtonW control.
28-Apr-2020
- Property bag for the CheckBoxW/CommandButtonW/OptionButtonW/FrameW caption's property not unicode anymore. (like LabelW from beginning)
This avoids some .frx refs as there is no property page anyway for these available to input unicode in the IDE.
No problem occurs with existing property bags, so no compatibility break.
- Other minor internal improvements in the ListView control.
27-Apr-2020
- Bugfix in the ListView control.
- The ItemFocus event is now able to fire at first item insertion. (Index = 1)
- The ItemFocus event will not have an Item set as 'Nothing' anymore when clearing the list. (mis-feature)
26-Apr-2020
- Bugfix in the GetClipboardText function in Common.bas.
23-Apr-2020
- FrameW responds now to WM_SETTEXT/WM_GETTEXT/WM_GETTEXTLENGTH like the VB.Frame.
22-Apr-2020
- Bugfix that an OwnerDrawn OptionButtonW did not raise the Click event, though the value got changed.
20-Apr-2020
- Major Bugfix in the CheckBoxW/CommandButtonW/CommandLink/LinkLabel/OptionButtonW control.
Forgot to call DeActivateIPAO method upon WM_KILLFOCUS.
- DPI-aware bugfix in the Slider control.
- Major internal improvement for SpinBox as no WM_MOUSEACTIVATE overhead necessary anymore.
19-Apr-2020
- Internal improvement in ComCtlsBase.bas.
- Improvement for Animation control.
- No re-creation anymore when changing BackColor property.
- Default value for AutoPlay property now False instead of True. (like in the original MS control)
- StartPlay and IsPlaying renamed to Play and Playing in the Animation control. (like in the original MS control)
- StartedPlay/StoppedPlay event merged into new Change event. (more VB-ish, use .Playing to determine current status)
18-Apr-2020
- Major internal improvement for ListView as no WM_MOUSEACTIVATE overhead necessary anymore.
- Renamed the Border property to 'BorderStyle' in the RichTextBox control. (like in the original MS control)
17-Apr-2020
- Major internal improvement in the IPAddress control as SysIPAddress32 class no longer used.
Instead everything is done from scratch within the UserControl and four internal edit controls.
The behavior and usage is 100% mimic, but looks more "VB-ish".
- BackColor property now possible.
- ForeColor property also effects now the three dots.
- UserControl_Resize does not need a re-creation. (SysIPAddress32 was fixed, no MoveWindow was possible!)
- BorderStyle property now possible. (e.g. Flat style)
- Design time property page included.
- Support for SysIPAddress32 IPM_* messages.
15-Apr-2020
- Modified OLEGuids.tlb as following: (compiled with same uuid)
- included hWnd param for IOleInPlaceActiveObjectVB and IOleControlVB
Unregister to old OLEGuids.tlb is not necessary, just overwrite the file.
- Bugfix in the various WM_CONTEXTMENU handlers. It can now also handle negative screen coordinates.
13-Apr-2020
- Behavior improvement for the LabelW control. (when AutoSize property set to True)
It now sets a temporary NULL clipping region in that case, like the VB.Label does.
- Major internal improvement for Slider/TabStrip as no WM_MOUSEACTIVATE overhead necessary anymore.
- Minor internal improvement in the TextBoxW and RichTextBox control.
12-Apr-2020
- Major internal improvement for TreeView as no WM_MOUSEACTIVATE overhead necessary anymore.
- Bugfix in the Checkboxes property in the TreeView control.
11-Apr-2020
- Major internal improvement for TextBoxW/RichTextBox/DTPicker/ListBoxW as no WM_MOUSEACTIVATE overhead necessary anymore.
- Behavior improvement for vbOLEDragAutomatic in the TextBoxW/ListBoxW control. (OLEDragMode property)
07-Apr-2020
- Major internal improvement for CheckBoxW/CommandButtonW/OptionButtonW/CommandLink as no WM_MOUSEACTIVATE overhead necessary anymore.
06-Apr-2020
- Minor internal improvement in the TabStrip and TreeView control.
29-Mar-2020
- Included the ShowColumnTips property in the ListView control to enable tooltips on the column headers.
Therefore ToolTipText, ToolTipTextFilterBtn and ToolTipTextDropDown property are included of a ColumnHeader in the ListView control.
- It is now possible for the LvwColumnHeaders collection to change the key on a particular LvwColumnHeader in the ListView control.
28-Mar-2020
- It is now possible for the ImcComboItems collection to change the key on a particular ImcComboItem in the ImageCombo control.
- Some other minor cleanup.
22-Mar-2020
- Bugfix in the CreateGDIFontFromOLEFont function. (Common.bas)
- Minor speed optimization in the LabelW control for auto-sizing.
Usage of function 'GDIFontFromOLEFont' instead of 'CreateGDIFontFromOLEFont'.
- Minor internal improvement in the CommonDialog class.
04-Mar-2020
- Internal improvement for ShowPrinter/ShowPrinterEx/ShowPageSetup dialog in the CommonDialog class.
The DevMode plays now by the rules. (https://support.microsoft.com/en-us/help/167345/how-to-modify-printer-settings-with-the-documentproperties-function)
27-Feb-2020
- Behavior change for returning printer params for ShowPrinter/ShowPrinterEx dialog in the CommonDialog class.
26-Feb-2020
- TreeView control now 'Alignable', so that it can be used in an MDIForm. (e.g. as 'menu tree')
25-Feb-2020
- SetFocus method of FrameW removed. (Cleanup)
This was a left-over after 13-Jan-2018 update where 'CanGetFocus' was changed to False.
- Changed Value property in the HotKey control so it works in VB.net AxInterop.
Optional 'ByRef Modifiers' param was changed from 'As VBRUN.ShiftConstants' to 'As Integer'.
- Changed params for PanelClick/PanelDblClick in the StatusBar control.
It now includes the 'Button As Integer' param.
- ContainerKeyDown in the ToolBar control changed from 'Sub' to 'Function'.
It can now return a reference to a TbrButton class, when a successfull button click was invoked.
- Included run-time function FindMnemonic in the ToolBar control.
20-Feb-2020
- Bugfix related to 19-Feb-2020.
19-Feb-2020
- Bugfix in the LabelW control when WordWrap and AutoSize are both set to True.
14-Feb-2020
- Bugfix that CommonDialog.ShowPrinterEx does not crash anymore on a form-less application.
CommonDialog.ShowPrinter was not affected as it can deal also without an owner window.
12-Feb-2020
- Passing vbNullString to the AddItem method of the ComboBoxW control does not cause an error anymore.
06-Feb-2020
- Improvement (cosmetic, not a bug) in VTableHandle.bas so that IOleControl do not disturb anymore in IDE on debugging.
This affects only the Std-EXE version (not OCX) and only when setting breakpoints. (F9, F8 etc.)
- Minor internal improvement in the ToolBar control.
15-Jan-2020
- Improvement in the SystemStartOfWeek property in the DTPicker and MonthView control.
- Bugfix for the StatusBar control when having multiple 'AutoSizeSpring' panels.
14-Jan-2020
- Improvement in the PasswordChar property in the TextBoxW and RichTextBox control.
09-Jan-2020
- Included the CustomColors property (Variant) in the CommonDialog class.
16 custom colors can be retrieved or changed via an array.
05-Jan-2020
- Improvement in VTableHandle.bas as IPerPropertyBrowsing must NOT be subclassed anymore.
No VTable remains subclassed, therefore VTableSubclass.cls got obselete and was removed!
- Modified OLEGuids.tlb as following: (compiled with same uuid)
- bugfix interface IPerPropertyBrowsing.
Unregister to old OLEGuids.tlb is not necessary, just overwrite the file.
03-Jan-2020
- Improvement in VTableHandle.bas as IOleControl must NOT be subclassed anymore.
It is necessary to replace also all controls. (.ctl)
28-Dec-2019
- Minor internal improvement in the ContainerKeyDown method in the ToolBar control.
26-Dec-2019
- Minor internal improvement in the..
- RestoreRecent property in the FontCombo control.
- WorkAreas/ColumnOrder property in the ListView control.
- TileViewIndices property of a ListItem in the ListView control.
- SetAcceleration method in the SpinBox control.
15-Nov-2019
- It is now possible for the TvwNodes collection to change the key on a particular TvwNode in the TreeView control.
25-Oct-2019
- No crash anymore when getting the Hint property in 'LvwGroup' in the ListView control.
13-Oct-2019
- Internal improvement for the Transparent property in all affected controls.
The internal transparent brush will be reset automatically upon UserControl_Resize.
As side-effect it also fixes the cluttered background on non-integral DPI.
09-Oct-2019
- Change of how to achieve DPI-awareness to the controls for non-integral DPI.
It's just a better technique now which reduces the number of resizes.
However, the change has no visible impact for the end-user.
08-Oct-2019
- Cosmetic bugfix in the DPICorrectionFactor() function in Common.bas.
It now returns a factor - by definition - in which a result shall be multiplied.
Before this bugfix the result must be divided, which was odd.
05-Oct-2019
- Modified OLEGuids.tlb as following: (compiled with same uuid)
- included interface IOleInPlaceObject.
Unregister to old OLEGuids.tlb is not necessary, just overwrite the file.
11-Sep-2019
- Bugfix that the .Tag property of 'TbrButtonMenu' was not restored from the PropertyBag in the ToolBar control.
24-Aug-2019
- BackColor property works now also when VisualStyles is False in the TabStrip control.
- Included the DoubleBuffer property in the TabStrip control.
22-Aug-2019
- Included the BackColor property and improved the DrawBackground method in the TabStrip control.
- Modified OLEGuids.tlb as following: (compiled with same uuid)
- enriched interface IOleObject with more methods.
Unregister to old OLEGuids.tlb is not necessary, just overwrite the file.
21-Aug-2019
- Included enum value 'RtfFindOptionReverse' for the Find method in the RichTextBox control.
20-Aug-2019
- UTF-16 BOM was missing in the internal StreamFileOut function in the RichTextBox control.
This fix is only meaningful when using 'RtfLoadSaveFormatUnicodeText' in the SaveFile method.
15-Aug-2019
- Included the SelLink run-time property in the RichTextBox control.
11-Aug-2019
- Potential double MouseUp event (not on double click; normal click) before and after MouseDown fixed on certain conditions in the ListView/TreeView control.
10-Aug-2019
- It is now possible for the LvwListItems collection to change the key on a particular LvwListItem in the ListView control.
[...]
11-Nov-2012
- First release.
Warning: This Std-EXE version here is not really IDE-Safe as the design-time (form designer) user control subclassing (AddressOf pointer) can just become invalid when the IDE wants to. It is recommended to use the OCX version.
Re: CommonControlsEx (Replacement of the MS common controls)
The benefit is that these controls are linked to the comctl32.dll, that means they support the latest API calls, functions, properties and visual styles (themes).
The existing common controls 6.0 from MS are not linked to the comctl32.dll, so they doesn't support the visual styles (themes).
Reason why: The controls of the comct32.dll are compiled directly into the common controls 6.0 from MS, but as of state of a old version of comctl32.dll
Only the common controls 5.0 from MS are linked to the comctl32.dll, but the COM hull is very old and so they have a leak of the latest functions and properties. Also controls like the DTPicker, MonthView or UpDown are not included.
Re: CommonControlsEx (Replacement of the MS common controls)
Originally Posted by Krool
The benefit is that these controls are linked to the comctl32.dll, that means they support the latest API calls, functions, properties and visual styles (themes).
The existing common controls 6.0 from MS are not linked to the comctl32.dll, so they doesn't support the visual styles (themes).
Reason why: The controls of the comct32.dll are compiled directly into the common controls 6.0 from MS, but as of state of a old version of comctl32.dll
Only the common controls 5.0 from MS are linked to the comctl32.dll, but the COM hull is very old and so they have a leak of the latest functions and properties. Also controls like the DTPicker, MonthView or UpDown are not included.
Can you please change the OLEGuids.tlb to a new name to avoid conflicts with my existing OLEGuids.tlb in system32 folder?
Re: CommonControlsEx (Replacement of the MS common controls)
Excellent work!
Originally Posted by Hack
What is the benefit of using these over the existing controls?
Does each control have the same properties? Do they have new properties?
In addition to what Krool stated, some folks, myself included, prefer that their apps have no dependencies whatsoever.
The controls have most of the necessary (similarly named) properties and methods and many of them have some new ones as well (the VisualStyles property for instance).
Originally Posted by Jonney
Can you please change the OLEGuids.tlb to a new name to avoid conflicts with my existing OLEGuids.tlb in system32 folder?
Open CommonControlsEx.vbp in any text editor and edit this line:
Code:
Reference=*\G{5B1EACE0-EDEB-11E1-AFF1-0800200C9A66}#1.0#0#..\..\..\..\WINDOWS\system32\OLEGuids.tlb#OLE Guid and interface definitions
to:
Code:
Reference=*\G{5B1EACE0-EDEB-11E1-AFF1-0800200C9A66}#1.0#0#OLEGuids\OLEGuids.tlb#OLE Guid and interface definitions
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Re: CommonControlsEx (Replacement of the MS common controls)
Originally Posted by Jonney
Can you please change the OLEGuids.tlb to a new name to avoid conflicts with my existing OLEGuids.tlb in system32 folder?
You can just rename the file "OLEGuids.tlb" at your own, for example to "OLEGuids2.tlb"
That is no problem, because the uuid and library name differs from the original. They can co-exist without conflicts.
You just need to re-register it in the IDE. (Project -> References... -> Browse for file)
Re: CommonControlsEx (Replacement of the MS common controls)
Originally Posted by Krool
You can just rename the file "OLEGuids.tlb" at your own, for example to "OLEGuids2.tlb"
That is no problem, because the uuid and library name differs from the original. They can co-exist without conflicts.
You just need to re-register it in the IDE. (Project -> References... -> Browse for file)
Thanks. I understood.
If you can add Unicode support, then those control can be used on PC with whatever locale setting.
How about others control built by CreateWindowEx such as Listview/Treeview? Listview support more new features such as Grouping now.
Re: CommonControlsEx (Replacement of the MS common controls)
Thanks for the update!
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Re: CommonControlsEx (Replacement of the MS common controls)
Originally Posted by Krool
Update released.
All controls support now Unicode and some other minor improvements are done.
Fairly support Unicode.
But because of nature of MS BUTTON, it doesn't an unicode compatible control.
Never mind, just leave this because it's hard to fully support Unicode for a Command button.
DrawText hDC, StrPtr(Button.Caption), -1, RectText, DT_CALCRECT Or DT_WORDBREAK
Button.Caption can never be held Unicode string, internal conversion has been done before you call DrawTextW.
Re: CommonControlsEx (Replacement of the MS common controls)
Originally Posted by Jonney
Button.Caption can never be held Unicode string, internal conversion has been done before you call DrawTextW.
This function will retrieve any button's caption, even if VB displays their Unicode captions as ?????.
Code:
Private Declare Function DefWindowProcW Lib "user32.dll" (ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Function GetCaption(ByRef oButton As Object) As String
Const WM_GETTEXT = &HD&, WM_GETTEXTLENGTH = &HE&
Dim Button_hWnd As Long
On Error GoTo 1
Button_hWnd = oButton.hWnd
GetCaption = Space$(DefWindowProcW(Button_hWnd, WM_GETTEXTLENGTH, 0&, 0&))
DefWindowProcW Button_hWnd, WM_GETTEXT, Len(GetCaption) + 1&, StrPtr(GetCaption)
1 On Error GoTo 0
End Function
VB's Button controls (CommandButton, CheckBox or OptionButton) can actually contain Unicode captions (via DefWindowProcW + WM_SETTEXT). VB doesn't display them properly though.
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Re: CommonControlsEx (Replacement of the MS common controls)
Thanks for including the StatusBar control!
Last edited by Bonnie West; Mar 1st, 2013 at 04:52 PM.
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Re: CommonControlsEx (Replacement of the MS common controls)
its really an amazing work,god bless you.Bro can you add listview and treeview with displayable unicode support?
it will great achievment if it possible
Re: CommonControlsEx (Replacement of the MS common controls)
Update released.
ListView control is added.
Groups and 'Tile' View are for the moment not included.
It can replace 100% the ListView from „MSCOMCTL.OCX". (Exception: ToolTipText of the ListSubItems)
But it has also many properties, methods and events more than the original.
Re: CommonControlsEx (Replacement of the MS common controls)
Originally Posted by Krool
Update released.
ListView control is added.
Groups and 'Tile' View are for the moment not included.
It can replace 100% the ListView from „MSCOMCTL.OCX". (Exception: ToolTipText of the ListSubItems)
But it has also many properties, methods and events more than the original.
Thank you for additional Listview.
From Vista/Win7,MS added lots of new features into Listview, such as enhanced grouping, Checkbox on Header,etc.
Please consider adding checkbox and Text Edit for subitems.
Re: CommonControls (Replacement of the MS common controls)
Update released.
ImageList control is completly rewritten. (It is not compatible with the previous version)
It works now like the original ImageList from MS but with some improvements, for example that the Style flag of the ListImages Draw method can be combined with multiples styles. (That was not possible in the original ImageList from MS) or that the Overlay function returns an icon instead of a bitmap or that the BackColor can be turned on or off (UseBackColor property).
Re: CommonControls (Replacement of the MS common controls)
I must say I'm truly impressed. Were I still using VB6, this would have been an incredible source of knowledge. I tended to write alot of my own controls(I still do in VB.Net) and I always want to learn as much as possible about creating them. I thought I had a good handle on it it but one glance at your source code, and even what you described about them being linked to ComCtl32.Dll showed me just how little I actually knew about control authoring in VB6. I tip my hat to you sir.
C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter
There's just no reason to use garbage like InputBox. -jmcilhinney
Re: CommonControls (Replacement of the MS common controls)
Update released.
ImageCombo control is added.
The biggest advantage is that you can set the style property. ('DropDownCombo', 'DropDownList' or 'SimpleCombo')
That was not possible on the original ImageCombo control. (It was always as 'DropDownCombo')
Also new is the 'ItemDrag' event, similar to the one used in the ListView control.
Re: CommonControls (Replacement of the MS common controls)
Very, very good work. Many thanks to you. I do not like to link to Microsofts Ocx-files (Mscommctl.....). With your controls i don't need that. My exe work so without registrations on every PC. And: i can do more things. I can change the WM_PAINT - message to what i will. I can change the colors, i can add a picture, i can paint the control. I must only change your code a little bit. Awsome.
Thank you very much!!!!!
Re: CommonControls (Replacement of the MS common controls)
Thank you for the work - it's a lovely change CommonControls.
I have one problem, very often crashes when you compile an application (even an example), and the exe-file is created. And sometimes crashes when you press End in the course of the program.
It would be nice if the progress bar for added display of progress on the taskbar. An example can be found here http://sourceforge.net/p/audica/code...skBarList3.cls
Re: CommonControls (Replacement of the MS common controls)
Also for the beautiful subsclassing commandbutton think it will be good to make changes if there is a caption and a picture, you have the image on the left and the caption to the left of the picture. So the picture will not be imposed on the text.
Code:
Private Sub DrawButton(ByVal hWnd As Long, ByVal hDC As Long, Button As Object)
.....
If Not Button.Caption = vbNullString Or Len(Button.Caption) > 0 Then
Set ButtonFont = Button.Font
FontOld = SelectObject(hDC, ButtonFont.hFont)
RectText = RectClient
DrawText hDC, StrPtr(Button.Caption), -1, RectText, DT_CALCRECT Or DT_WORDBREAK
RectText.Right = RectClient.Right
If ButtonPic Is Nothing Then
RectText.Left = RectClient.Left
RectText.Top = ((RectClient.Bottom - RectText.Bottom) / 2) + 3
RectText.Bottom = RectText.Top + RectText.Bottom
Else
RectText.Left = CInt(Button.Parent.ScaleX(ButtonPic.Width, vbHimetric, vbPixels)) + 4
'RectText.Top = RectClient.Top '(RectClient.Bottom - RectText.Bottom) + 1
RectText.Top = (((RectClient.Bottom - RectClient.Top) - (RectText.Bottom - RectText.Top)) / 2) + RectClient.Top
RectText.Bottom = RectClient.Bottom
End If
DrawThemeText Theme, hDC, 1, ButtonState, StrPtr(Button.Caption), -1, DT_CENTER Or DT_WORDBREAK, 0, RectText
SelectObject hDC, FontOld
End If
CloseThemeData Theme
If Not ButtonPic Is Nothing Then
W = CInt(Button.Parent.ScaleX(ButtonPic.Width, vbHimetric, vbPixels))
H = CInt(Button.Parent.ScaleY(ButtonPic.Height, vbHimetric, vbPixels))
If Not Button.Caption = vbNullString Or Len(Button.Caption) > 0 Then
X = RectClient.Left
'Y = RectClient.Top ' + ((RectClient.Bottom - RectClient.Left - H) / 2)
Y = (((RectClient.Bottom - RectClient.Top) - H) / 2) + RectClient.Top
Else
RectClient.Bottom = RectText.Top
X = RectClient.Left + ((RectClient.Right - RectClient.Left - W) / 2)
Y = RectClient.Top + ((RectClient.Bottom - RectClient.Left - H) / 2)
End If
If Enabled = True Then
If Button.UseMaskColor = True Then
Call DrawTransparentPicture(ButtonPic, hDC, X, Y, W, H, WinColor(Button.MaskColor))
Else
ButtonPic.Render hDC, X, Y + H, W, -H, 0, 0, ButtonPic.Width, ButtonPic.Height, ByVal 0
End If
Else
Call DrawDisabledPicture(ButtonPic, hDC, X, Y, W, H, WinColor(Button.MaskColor))
End If
End If