Re: CommonControls (Replacement of the MS common controls)
Originally Posted by Krool
I bet that on MS ListView V5 you have the same..
The MS ListView V6 is a zombie state version of an ancient comctl32.dll.
If you would like this to be fixed then good luck opening a MS ticket.
I don't think that Microsoft will devote time to the classic theme in 2020
I'm sure it will be easier for me to generate a scaled ImageList for each DPI on runtime. Thanks
Last edited by tnrprog; Jun 11th, 2020 at 06:31 AM.
Re: CommonControls (Replacement of the MS common controls)
I have a listview question. Standard behavior is when focus is lost a selected item is no longer highlighted with the select (blue) color, but gets soft grey and less visible for the user as selected.
If you select hide selection then it will be white making it look like nothing is selected at all. For my project I switched from listbox to listview where list box keeps the highlighted color but listbox is very limited in its usage.
Is it possible to keep the (blue) color after a different control gets focus or is this just a vb/windows thingy and am I out of luck?
Re: CommonControls (Replacement of the MS common controls)
Originally Posted by MSI-Packager
I have a listview question. Standard behavior is when focus is lost a selected item is no longer highlighted with the select (blue) color, but gets soft grey and less visible for the user as selected.
If you select hide selection then it will be white making it look like nothing is selected at all. For my project I switched from listbox to listview where list box keeps the highlighted color but listbox is very limited in its usage.
Is it possible to keep the (blue) color after a different control gets focus or is this just a vb/windows thingy and am I out of luck?
Thx for the awesome controls btw!
There is no "straight forward" solution as the select (blue) color overrides any (possible) custom draw.
BUT, there is a nice trick using the DropHighlight functionality. (important is that HideSelection is True)
There is no visual difference in the appearance of a DropHighlight row or Selected row.
If single-selection is enough then using the in-built functionality is sufficient.
Code:
Private Sub Form_Load()
ListView1.MultiSelect = False
ListView1.HideSelection = True
End Sub
Private Sub ListView1_GotFocus()
Set ListView1.DropHighlight = Nothing
End Sub
Private Sub ListView1_LostFocus()
Set ListView1.DropHighlight = ListView1.SelectedItem
End Sub
However, if you need MultiSelect = True then a little bit API is doing the job.
Code:
Private Type LVITEM
Mask As Long
iItem As Long
iSubItem As Long
State As Long
StateMask As Long
pszText As Long
cchTextMax As Long
iImage As Long
lParam As Long
iIndent As Long
End Type
Private Declare Function SendMessage Lib "user32" Alias "SendMessageW" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByRef lParam As Any) As Long
Private Sub ListViewMultiDropHighlightFromSelRange(ByVal Obj As ListView, Optional ByVal Reset As Boolean)
Const LVM_FIRST As Long = &H1000
Const LVM_GETNEXTITEM As Long = (LVM_FIRST + 12)
Const LVM_SETITEMSTATE As Long = (LVM_FIRST + 43)
Const LVNI_ALL As Long = &H0, LVNI_SELECTED As Long = &H2
Const LVIS_DROPHILITED As Long = &H8
Dim iItem As Long, LVI As LVITEM
LVI.StateMask = LVIS_DROPHILITED
If Reset = False Then
LVI.State = LVIS_DROPHILITED
iItem = SendMessage(Obj.hWnd, LVM_GETNEXTITEM, -1, ByVal LVNI_ALL Or LVNI_SELECTED)
Do While iItem > -1
SendMessage Obj.hWnd, LVM_SETITEMSTATE, iItem, ByVal VarPtr(LVI)
iItem = SendMessage(Obj.hWnd, LVM_GETNEXTITEM, iItem, ByVal LVNI_ALL Or LVNI_SELECTED)
Loop
Else
LVI.State = 0
SendMessage Obj.hWnd, LVM_SETITEMSTATE, -1, ByVal VarPtr(LVI)
End If
End Sub
Private Sub Form_Load()
ListView1.MultiSelect = True
ListView1.HideSelection = True
End Sub
Private Sub ListView1_GotFocus()
ListViewMultiDropHighlightFromSelRange ListView1, True
End Sub
Private Sub ListView1_LostFocus()
ListViewMultiDropHighlightFromSelRange ListView1
End Sub
Re: CommonControls (Replacement of the MS common controls)
I tried moving the VBCC16.OCX to the SysWOW64 directory (and registered it) but I'm still getting the control not registered error. The toolbar shows all the VBCCR controls but if I try to place one on the form the error dialog appears.
Re: CommonControls (Replacement of the MS common controls)
Originally Posted by ScriptBASIC
I tried moving the VBCC16.OCX to the SysWOW64 directory (and registered it) but I'm still getting the control not registered error. The toolbar shows all the VBCCR controls but if I try to place one on the form the error dialog appears.
Re: CommonControls (Replacement of the MS common controls)
Is it possible for ListView in report style to set different backcolor of even and odd items like it works with FlexGrid's "BackColor" and "BackColorAlt" ?
Re: CommonControls (Replacement of the MS common controls)
Originally Posted by tnrprog
Is it possible for ListView in report style to set different backcolor of even and odd items like it works with FlexGrid's "BackColor" and "BackColorAlt" ?
Yes, you can handle the ItemBkColor event and change when Mod 2.
Re: CommonControls (Replacement of the MS common controls)
Hi Krool,Many thanks for your continued hard work! Is there any chance we could get a scrollbar control? (something like the flatscrollbar in mscomct2). i really detest the built in scroll bars of vb6.
Re: CommonControls (Replacement of the MS common controls)
Included new control 'VListBox'. (virtual list box)
It is intended to not call it 'VirtualList' (likewise to the 'VirtualCombo') as 'VirtualList' is a common word to refer to a virtual list view.
In this work for the new control I found some things to fix/improve for the 'ListBoxW' control:
- 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
Re: CommonControls (Replacement of the MS common controls)
Im using the Slider control from the vbccr activex control as a volume control. When I have it in vertical layout mode the small value starts at the top and values get larger as you scroll down. Is there a way to reverse this? I would like the small value at the bottom and large at the top. so as you move the slider up, the volume increases. The "Reverse" property seemed to have no effect.
Re: CommonControls (Replacement of the MS common controls)
Originally Posted by vbLewis
Im using the Slider control from the vbccr activex control as a volume control. When I have it in vertical layout mode the small value starts at the top and values get larger as you scroll down. Is there a way to reverse this? I would like the small value at the bottom and large at the top. so as you move the slider up, the volume increases. The "Reverse" property seemed to have no effect.
The "Reversed" property says: Returns/sets a value that determines whether or not to reverse the default, making down equal left and up equal right on horizontal orientation and left equal down and right equal up on vertical orientation.
So it just reverses the left and right arrow keys, which is useful. (TBS_DOWNISLEFT)
In addition TBS_REVERSED is set, which has no effect on the control; it is simply a flag that can be checked..
Re: CommonControls (Replacement of the MS common controls)
Thanks for the reply! Thats what i was doing, recalculating but the tooltip still showed it going down instead of up so i will try the modifytiptext event. I was just hoping there was an easy way to reverse the up down direction.
Re: CommonControls (Replacement of the MS common controls)
Krool, consider adding support for listview's LVN_ODCACHEHINT notification. It helps with virtual listivews. Supporting it is just a few lines of code. Users, on the other hand need to learn to use it.
Supporting it... you'll need a new udt: NMLVCACHEHINT and a new event: VirtualSetCacheHint
Code:
Case LVN_ODCACHEHINT
Dim NMLVC As NMLVCACHEHINT
CopyMemory NMLVC, ByVal lParam, LenB(NMLVC)
RaiseEvent VirtualSetCacheHint(NMLVC.iFrom + 1, NMLVC.iTo + 1)
For users. Most often with virtual listviews, you won't have data cached. It will be in a stream, in a database, in a file, somewhere else, but not in active memory, i.e., some array. In other words, you need to retrieve it when it's needed. The cache hint is how the listview attempts to tell you, "hey I'm gonna need these items in the short term - might want to pre-cache them". Only at that point, do you load your data and cache it in memory. The message is likely to tell you to cache no more than 50-ish items (whatever can fit on screen). Then when Krool raises his GetVirtualItem event, you get the data from your cache. Listviews don't always ask for items you cached, so you need to verify the item is in your cache and fallback to retrieving it otherwise.
Edited: Here's how I implemented the cache. My actual code is a bit more complex. I also don't want to cache subitems whose columns are not on screen (horz scrollbar in effect). In addition, the listview, for whatever reasons, always queries the 1st 8 listitems, so not a bad idea to keep them permanently cached.
Code:
ReDim strCache(0 To ListView1.ColumnHeaders.Count - 1, FromItem To ToItem) ' String array
' "FromItem" passed in VirtualSetCacheHint event
' "ToItem" passed in VirtualSetCacheHint event
... populate the array with the items from your database or whatever
And this is how one could use that cache
Code:
Private Sub ListView1_GetVirtualItem(ByVal Index As Long, ByVal SubItemIndex As Long, ByVal VirtualProperty As LvwVirtualPropertyConstants, ByRef Value As Variant)
If Index < LBound(strCache, 2) Or Index > UBound(strCache, 2) Then
' not in cache, retrieve it manually
Else
Value = strCache(SubItemIndex, Index)
End If
End Sub
Last edited by LaVolpe; Jun 27th, 2020 at 10:09 PM.
Insomnia is just a byproduct of, "It can't be done"
Re: CommonControls (Replacement of the MS common controls)
Originally Posted by LaVolpe
consider adding support for listview's LVN_ODCACHEHINT notification. It helps with virtual listivews.
Thanks as always for your constructive input.
When I use a virtual list view (e.g. SQLite DataSet) then all is already pre-cached and thus no need for it.
However, maybe for other cases it might be useful. Therefore I included the 'VirtualSetCacheHint event' 1:1 as you suggested.
Concerning virtual list view in general I found other things:
1.
a virtual list view sends LVN_ITEMCHANGED only for some cases. If a range is selected it uses LVN_ODSTATECHANGED and not LVN_ITEMCHANGED for each item.
I catch now LVN_ODSTATECHANGED and translate a 'ItemSelect event' for each item in that range.
Also a virtual list view informs only about each selected item, not about each deselected item.
It uses an alias for deselection. A .iItem = -1 in LVN_ITEMCHANGED. So in order to give full feature I need to pass then a 'ItemSelect event' with ListItem 'As Nothing' and the param 'Selected' as False.
2.
There is a problem when using a virtual ListView control in a control array in the GetVirtualItem event.
Because the param 'Index As Long' clashes with the 'Index As Integer'.
I renamed the 'Index As Long' to 'ItemIndex As Long'.
Re: CommonControls (Replacement of the MS common controls)
Originally Posted by Krool
Thanks as always for your constructive input.
However, maybe for other cases it might be useful. Therefore I included the 'VirtualSetCacheHint event' 1:1 as you suggested.
But if your recordset is 100K records, dozen+ fields, would you really want to cache all that ahead of time? If not, the "cache hint" option performs better than JIT accessing database fields in response to the GetVirtualItem callback. In other cases, the source could be a stream or large random-access file for example.
There are other issues too, but more on the user side -- learning curves (for me too). For example, if you position a column via code, depending on how you are designing your cache, you may need to rebuild the cache as the column offsets in the cache may now be wrong. The virtual listview doesn't seem to send a new cache hint message when changing a column's order via code.
P.S. Another enhancement I needed to add... ColumnHeaders(x).EnsureVisible or something similar. When navigating the listview by keyboard (subitem to subitem, custom handled), there is no easy way to set the active column, triggering a horizontal scroll as needed. The solution was to call HDM_SETFOCUSEDITEM. LVM_SETSELECTEDCOLUMN selects, but doesn't activate. In the image below, if I keep hitting the right arrow, the highlighted item changes. At column 7+, I'll want the listview to scroll so that the highlighted item will be completely in view.
Last edited by LaVolpe; Jun 28th, 2020 at 02:54 PM.
Insomnia is just a byproduct of, "It can't be done"
Re: CommonControls (Replacement of the MS common controls)
Originally Posted by LaVolpe
Another enhancement I needed to add... ColumnHeaders(x).EnsureVisible or something similar.
There is a undocumented message which does the job.
However, it seems that it works only as of Vista+ (comctl32.dll 6.1 or greater)
Code:
Const LVM_FIRST As Long = &H1000
Const LVM_ENSURESUBITEMVISIBLE As Long = (LVM_FIRST + 184) ' Undocumented
Dim ItemIndex As Long, SubItemIndex As Long
ItemIndex = 0 ' zero-based
SubItemIndex = 2 ' zero-based
' Returns 1 on success
Debug.Print SendMessage(ListView1.hWnd, LVM_ENSURESUBITEMVISIBLE, ItemIndex, ByVal SubItemIndex)
Re: CommonControls (Replacement of the MS common controls)
LaVolpe, I did a test with just setting the focus (SetFocusAPI) to the header control and pressing keyoard arrow keys. (but no HDM_SETFOCUSEDITEM needed)
What is your current code?
Re: CommonControls (Replacement of the MS common controls)
What is your current code?
The right arrow keydown is trapped. On enter, I calculate the next subitem (column header index) based on column order and force a repaint of the listitem if no scroll is needed else I call HDM_SETFOCUSEDITEM which triggers the repaint. When it repaints, the old selected subitem's backcolor is redone and new one is yellow.
^^ edited: subitem vs. item ^^
Last edited by LaVolpe; Jun 29th, 2020 at 01:47 PM.
Insomnia is just a byproduct of, "It can't be done"
Re: CommonControls (Replacement of the MS common controls)
Update released.
I didn't test the VirtualCombo when not manifested, means comctl version 5.8x.
Because I just noticed that it fails.
However, adding the red marked line of code in the WM_CREATE handler of the 'ComboLBox' window fixed it for comctl version 5.8x.
Why this was not needed for comctl version 6.x is unknown for me..
Code:
If wMsg = WM_CREATE Then
Dim CS As CREATESTRUCT
CopyMemory CS, ByVal lParam, LenB(CS)
CS.dwStyle = CS.dwStyle Or LBS_NODATA
CopyMemory ByVal lParam, CS, LenB(CS)
SetWindowLong hWnd, GWL_STYLE, CS.dwStyle
VcbComboLBoxHandle = hWnd
End If
Re: CommonControls (Replacement of the MS common controls)
Krool, more for your consideration...
Customizing listivew items/subitems beyond just a font, forecolor or backcolor. It is entirely possible to draw a subitem completely on your own without having to owner-draw the entire listview. However, your raised event doesn't provide what is needed, though it could.
If the raised event would pass the hDC and RECT for the current item/subitem, then a user has more control. But that needs some thinking about how to raise the events (prepaint, paint, postpaint?) and how to respond to them. For example, CDRF_NEWFONT Or CDRF_NOTIFYSUBITEMDRAW may not be enough to return on CDDS_ITEMPREPAINT. May need CDRF_NOTIFYPOSTPAINT for example and respond to
Code:
Case CDDS_ITEMPOSTPAINT, (CDDS_ITEMPOSTPAINT Or CDDS_SUBITEM)
I was just thinking that if the control offers customizing per item, it probably should offer the entire package. Anyway, just a suggestion.
In my case, I wanted a subitem to appear raised. In order to do that, I needed to respond to the post-paint message so I could draw a raised border:
If you are considering it, here is what I'm using now. Comments added for you.
Code:
Public Event CustomDrawNotify(CustomDraw As Boolean)
' sent on Case NM_CUSTOMDRAW. If param returned false, exit subclass, no custom drawing
' event sent before copying the draw structure from received lParam
Public Event DrawItemPrePaint(ByVal ItemIndex As Long, ByVal SubItemIndex As Long, WantPaintEvents As Boolean)
' sent on Case CDDS_PREPAINT, If last param returned false, exit subclass, no drawing of this item
' otherwise, set subclass proc to CDRF_NOTIFYITEMDRAW
' note: v6 of listview class can set .dwItemSpec = -1
' the NMLVCD.ItemType should be checked for v6. If value is 2 then CDDS_PREPAINT notification applies to all items
Public Event DrawItemPaint(ByVal ItemIndex As Long, ByVal SubItemIndex As Long, _
ForeColor As OLE_COLOR, BackColor As OLE_COLOR, ItemStateFlags As Long, _
ByVal hDC As Long, ByVal pRECT As Long, WantPostPaintEvent As Boolean)
' sent on Case CDDS_ITEMPREPAINT, (CDDS_ITEMPREPAINT Or CDDS_SUBITEM)
' note: pRECT can be RECT structure if in TLB
' Setting ItemStateFlags to exclude bit 2 prevents default selection coloring on subitems when FullRow select applies
' subclass proc returns CDRF_NOTIFYSUBITEMDRAW Or CDRF_NEWFONT by default
' and if WantPostPaintEvent is returned true, then proc return value includes CDRF_NOTIFYPOSTPAINT
Public Event DrawItemPostPaint(ByVal ItemIndex As Long, ByVal SubItemIndex As Long, _
ByVal hDC As Long, ByVal pRECT As Long)
' final custom drawing event sent on Case CDDS_ITEMPOSTPAINT, (CDDS_ITEMPOSTPAINT Or CDDS_SUBITEM)
' note: pRECT can be RECT structure if in TLB
Note the ForeColor & BackColor params are sent byref and applied to clrText, clrTextBk.
user should supply CLR_DEFAULT (0xFF000000) or CLR_NONE (0xFFFFFFFF) if applicable
Last edited by LaVolpe; Jul 3rd, 2020 at 03:35 PM.
Insomnia is just a byproduct of, "It can't be done"
Re: CommonControls (Replacement of the MS common controls)
Originally Posted by LaVolpe
Customizing listivew items/subitems beyond just a font, forecolor or backcolor. It is entirely possible to draw a subitem completely on your own without having to owner-draw the entire listview. However, your raised event doesn't provide what is needed, though it could.
Yes, it's very complex to offer NM_CUSTOMDRAW via delegated events (e.g. CustomDraw event) and not understand by many.
That's why I thought to dismiss that kind of events and if an app needs really very customized appearance they are likely to subclass the control anyway, then they can also catch NM_CUSTOMDRAW and override it.
In my opinion it kind of bloat the control further off if offering all kinds of custom draw events. So I am likely to keep it this way.
Another question, more like a general question to everyone, for the TreeView control:
It's concerning the 'FocusRect' of the Caret item in the TreeView control.
The comctl32.dll 5.8x and 6.0 (XP) do it nice I think:
However, on 6.1 (Vista) or greater the appearance is changed/tricked:
There would be a way to *fix* this in the NM_CUSTOMDRAW. (code example below)
Proceed to fix this? Or don't care at all? Providing another property which could say -> enum ShowFocusRect, 0=NoControl, 1=Off, 2=On
So (default 0) would have no change at all, Having 1 would erase CDIS_FOCUS always for the caret item and 2 would have below code.
Code:
' CDIS_FOCUS controls if the tree view draws a focus rect.
If (NMTVCD.NMCD.uItemState And CDIS_FOCUS) = 0 Then
' If CDIS_FOCUS is not set but it is the caret item then force a focus rect.
If SendMessage(TreeViewHandle, TVM_GETNEXTITEM, TVGN_CARET, ByVal 0&) = NMTVCD.NMCD.dwItemSpec Then
NMTVCD.NMCD.uItemState = NMTVCD.NMCD.uItemState Or CDIS_FOCUS
CopyMemory ByVal lParam, NMTVCD, LenB(NMTVCD)
End If
Else
' If CDIS_FOCUS is set but it is not the caret item then avoid a focus rect.
If SendMessage(TreeViewHandle, TVM_GETNEXTITEM, TVGN_CARET, ByVal 0&) <> NMTVCD.NMCD.dwItemSpec Then
NMTVCD.NMCD.uItemState = NMTVCD.NMCD.uItemState And Not CDIS_FOCUS
CopyMemory ByVal lParam, NMTVCD, LenB(NMTVCD)
End If
End If
The benefit of having the focus rect properly is that if you click a node and pressing the mouse button (not released yet) and you move the caret item via keyboards then it visually known where the caret item is. (illustration below, with fix code applied)
Re: CommonControls (Replacement of the MS common controls)
Yes, it's very complex to offer NM_CUSTOMDRAW via delegated events (e.g. CustomDraw event) and not understand by many.
That's why I thought to dismiss that kind of events and if an app needs really very customized appearance they are likely to subclass the control anyway, then they can also catch NM_CUSTOMDRAW and override it.
I understand. The advantage of including an event for each drawing stage is that a user wouldn't need to subclass a control that is already subclassed and is already checking for those messages. But, I do understand.
Insomnia is just a byproduct of, "It can't be done"
Re: CommonControls (Replacement of the MS common controls)
Hi!
I have 2 Features which would be nice to add to the ComboBox;
1) autocomplete from items in the list, with an option to raise an event if the text that was input is not an item in the list (this would be raised during the validate event, or even a new event could be created for this purpose.
2) cancel the dropdown before it has been dropped.
Re: CommonControls (Replacement of the MS common controls)
Included the MultiSelect function to the TreeView control.
It is somewhat a common need for certain usages. For example in a drag and drop usage. With a multi select TreeView it is easier to drag more items at once.
I think some explanation is necessary:
When MultiSelect is 0 - None all is like before. Otherwise the MultiSelect feature is turned on.
If set to 1 - All then the selection is "free" without any restriction. However, when doing a shift selection then also the collapsed (hidden) nodes will be selected.
This can be changed when setting MultiSelect to 2 - VisibleOnly, then it is ensured that during a shift selection only the visible nodes are selected. (thus any collapsed child nodes are not selected)
The last option 3 - RestrictSiblings will ensure that only within a subset of siblings a selection can be made.
The new 'TvwSelectedNodes' class is convinient to access all the currently selected nodes.
The index 1 is certainly always the focused caret item since it is sorted by the order of selection(grow/history).
Code:
Dim Node As TvwNode
For Each Node In TreeView1.SelectedNodes
Debug.Print Node.Text
Next Node
To sort out the focused caret item just compare with the .SelectedItem property. It is still valid like in a single-select TreeView.
Code:
Dim Node As TvwNode
For Each Node In TreeView1.SelectedNodes
If Not Node Is TreeView1.SelectedItem Then Debug.Print Node.Text
Next Node
A given node can be included/removed in the selection by code in using the .Selected property of a Node.
Code:
Node.Selected = [True / False]
The .SelectedIndex function of a Node returns index of the selected nodes collection associated with this node.
If that function will make any sense in a scenario/use-case I don't know. I just included it for completeness.
Code:
Dim Node As TvwNode
For Each Node In TreeView1.SelectedNodes
Debug.Print TreeView1.SelectedNodes(Node.SelectedIndex).Text
Next Node
Also for completeness the .AnchorItem property which returns the current reference from which a multiple selection starts.
Code:
If Not TreeView1.AnchorItem Is Nothing Then Debug.Print TreeView1.AnchorItem.Text
The behavior and usage should be stable as I fiddled and tested it for a while to ensure a good starting point.
However, please report any bugs if encountered.
EDIT: AnchorItem not read-only anymore. It supports now Get/Let/Set. So it can be modified by code, if needed.
Re: CommonControls (Replacement of the MS common controls)
Krool,
I'd be lying if I said that I've done justice to testing your control set. As it is, I am struggling to release an update of my own. To top that, my development box just fried my boot drive
I absolutely will be testing many of the control thoroughly; in fact, I hope to include them in the next update to the project I mentioned above. I'm sorry I haven't been able to do more with them yet - believe me when I say that I think they are a Godsend, and MS should send you a few years of back pay (or pay each of us something for our struggles thus far
Please don't take my lack of progress reporting as a sign of lack of appreciation, or interest. Life is tough like that, sometimes.
If you want to be done working on them, I suppose the community may have to do some maintenance, if needed. Regardless, you *will* get that progress report from me, eventually.
Anyway, thanks for the professional control set, and professional code!
Re: CommonControls (Replacement of the MS common controls)
Update released.
Reworked the .WorkAreas property in the ListView control.
It is more convinient to use at it uses the new 'LvwWorkAreas' collection class.
With it the items can be added/removed or cleared more easily.
Code:
ListView1.WorkAreas.Add 0, 0, ListView1.Width / 2, ListView1.Height
Dim WorkArea As LvwWorkArea
For Each WorkArea In ListView1.WorkAreas
Debug.Print WorkArea.Index & "/" & WorkArea.Left & "/" & WorkArea.Width
Next WorkArea
ListView1.WorkAreas.Remove 1
ListView1.WorkAreas.Clear
'LvwWorkAreas' uses no "private" data and fully relies on LVM_GETWORKAREAS/LVM_SETWORKAREAS.
So even if an app uses pure API for work area creation it can make use of the collections.
Another enhancement is that a particular list item can be tested to which work area it belongs to.
The rules are according to MSDN (https://docs.microsoft.com/en-us/win...-working-areas), so if multiple work areas overlap it returns the first one.
Code:
Dim WorkArea As LvwWorkArea
Set WorkArea = ListView1.ListItems(1).WorkArea
If Not WorkArea Is Nothing Then
MsgBox "Within working area '" & WorkArea.Index & "'."
Else
MsgBox "Not within a working area"
End If
Also the other way around, starting from a 'LvwWorkArea' all list items belonging to it can be retrieved.
It also follows the same rules when multiple working areas overlap.
Code:
Dim Item As Variant
For Each Item In ListView1.WorkAreas(1).ListItemIndices
Debug.Print Item
Next Item
Re: CommonControls (Replacement of the MS common controls)
Update released.
Included new "NodeRangeSelect" event for the TreeView control.
Let's imagine you want that a disabled node does not get selected.
So, you handle the "NodeBeforeSelect" event and return Cancel.
Code:
Private Sub TreeView1_NodeBeforeSelect(ByVal Node As TvwNode, Cancel As Boolean)
' Avoid caret (focus) node to be changed for a disabled node.
If Node.Enabled = False Then Cancel = True
End Sub
However, for a shift-range selection (MultiSelect = True) the NodeBeforeSelect event is only fired for the new focused item.
Now, for each node in a shift-range selection the "NodeRangeSelect" is fired. (Anchor and focused item being excluded)
Code:
Private Sub TreeView1_NodeRangeSelect(ByVal Node As TvwNode, Cancel As Boolean)
' Avoid that a disabled node will be selected in a shift-range selection.
If Node.Enabled = False Then Cancel = True
End Sub
With this enhancement a disabled node can be effectively avoided to be selected in a multi-select TreeView.
Re: CommonControls (Replacement of the MS common controls)
I hope these are unique questions. I have just gotten started with this wealth of powerful controls, and I have 2 questions so far:
1. I found the OverTypeMode property of the TextBoxW control, and tried to set it in VB's property window in design mode, in VB's Immediate window in Break mode, and at runtime by pressing the Insert key when a TextBoxW control had focus, but I couldn't seem to trigger OverType mode, no matter what. What am I doing wrong?
2. I didn't expect to see this, but I was hoping: Many standard controls, like the TextBox, ComboBox, and ListBox let you set the text ForeColor, and BackColor, but not the "HighlightColor", which is traditionally dark blue. I believe this color comes from the user's chosen global Windows settings. Is this something that I could add to my own copy of VBCCR without too much trouble? And, if so, would you, Krool, or anyone else be interested to have this as a standard new setting in the VBCCR controls? I would be happy to add it myself, and provide it, if I thought that 1) I had the ability, and 2) that it was wanted, and 3) that it wouldn't break anything for anyone.
I am trying to provide a user "theme edit" capability to a particular screen, but this could be an issue if the user chooses dark blue for their text ForeColor, for instance. (I know, "don't do that"
Thanks in advance for your time and consideration.
Re: CommonControls (Replacement of the MS common controls)
Originally Posted by KurtB
1. I found the OverTypeMode property of the TextBoxW control, and tried to set it in VB's property window in design mode, in VB's Immediate window in Break mode, and at runtime by pressing the Insert key when a TextBoxW control had focus, but I couldn't seem to trigger OverType mode, no matter what. What am I doing wrong?
2. I didn't expect to see this, but I was hoping: Many standard controls, like the TextBox, ComboBox, and ListBox let you set the text ForeColor, and BackColor, but not the "HighlightColor", which is traditionally dark blue. I believe this color comes from the user's chosen global Windows settings. Is this something that I could add to my own copy of VBCCR without too much trouble? And, if so, would you, Krool, or anyone else be interested to have this as a standard new setting in the VBCCR controls? I would be happy to add it myself, and provide it, if I thought that 1) I had the ability, and 2) that it was wanted, and 3) that it wouldn't break anything for anyone.
1. Ensure that AllowOverType property is True.
2. Not possible for standard. However, you can set DrawMode property to OwnerDraw. Then you can color all how you like at the cost of additional code in your sources. (Handling ItemDraw event etc.)
Re: CommonControls (Replacement of the MS common controls)
Krool,
I can't get the ComCtlsDemo sample to compile or even load properly to work within the IDE. The culprit is line 123 in Animation.ctl:
Code:
Private Sub IOleInPlaceActiveObjectVB_TranslateAccelerator(ByRef Handled As Boolean, ByRef RetVal As Long, ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long, ByVal Shift As Long)
Re: CommonControls (Replacement of the MS common controls)
Originally Posted by MountainMan
Krool,
I can't get the ComCtlsDemo sample to compile or even load properly to work within the IDE. The culprit is line 123 in Animation.ctl:
Code:
Private Sub IOleInPlaceActiveObjectVB_TranslateAccelerator(ByRef Handled As Boolean, ByRef RetVal As Long, ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long, ByVal Shift As Long)
You have an outdated OLEGuids.tlb.
Just replace on syswow64 (or system32 on 32bit OS) with the new one in the download.
Re: CommonControls (Replacement of the MS common controls)
Originally Posted by Krool
1. Ensure that AllowOverType property is True.
2. Not possible for standard. However, you can set DrawMode property to OwnerDraw. Then you can color all how you like at the cost of additional code in your sources. (Handling ItemDraw event etc.)
AllowOverType, huh? Duh! I didn't see that.
OwnerDraw is always a good thing. It's overkill for my desired usage, though.
Re: CommonControls (Replacement of the MS common controls)
Hey
VBCCR16 1.6.126
See the attached project.
1. Is it possible to prevent Windows from overriding a ComboBox's BackColor when using CboStyleDropDownList? I set a combobox to &H00C0FFFF& (gold color) and Windows XP correctly shows all three ComboBox styles in gold, but Windows 10 only shows CboStyleDropDownCombo and CboStyleSimpleCombo in gold while showing CboStyleDropDownList in gray (probably from the Windows color scheme).
2. Is it possible to programmatically disable the ComboBox drop-down animation? I wrote a routine to allow the user to search through a combo for a keyword and show only matching results. It works nicely in Windows XP where the drop-down shows instantly, but in Windows 10 the drop-down is animated and that makes searching slow.
3. When the mouse cursor hovers over the program window, Windows hides the mouse cursor when I call ComboBox.DroppedDown = True. That's very user-unfriendly. How do I prevent Windows from hiding the cursor?
4. Does the VBCCR ComboBox allow a better way of searching for partial matches at any point in the string than the way I did it?
Re: CommonControls (Replacement of the MS common controls)
vbccr_testing_v1.0.0.zip above contains the compiled program. Attached here is the source code.
VBCCR16.OCX missing due to its 5MB size - the forum allows attachments of max 1MB.