in mdiForm
in user Form/ModuleCode:Public cDlogM As VBCCR16.CommonDialog
Code:Dim cDlogF As VBCCR16.CommonDialog
Set MDIForm1.cDlogM = New VBCCR16.CommonDialog
set cDlogF = MDIForm1.cDlogM
Printable View
Bug Report: ListView, whether listitems exist or not
- when listview is shown and has 2+ column headers, remove all but one
- re-add 1 or 2 column headers
- Subscript out of Range error
I think the control is trying to redraw somewhere between the column header being added, but the header not being appended to the collection yet.
Updated: I don't know if this was the right thing to do or not, but solved the problem...
Class: lvwColumnHeaders
Method: Add
Action: moved the "ShadowListView.FColumnHeadersAdd" call to end of method
-----------------------------------------------------------------------------------------------
Have an option for you. Not just reporting bugs!
Been playing with your ListView and found something lacking ;). I noticed you added several types of sorting options, but didn't include the one I was looking for... Explorer-like sorting when text & numeric listitems are intermixed. Suggestion follows.
edited: sample of differences, logical compare on the left sideCode:Private Declare Function StrCmpLogicalW Lib "shlwapi" (ByVal psz1 As Long, ByVal psz2 As Long) As Long
Private Function ListItemsSortingFunctionLogical(ByVal lParam1 As Long, ByVal lParam2 As Long) As Long
Dim Text1 As String, Text2 As String
Text1 = Me.FListItemText(lParam1 + 1, PropSortKey)
Text2 = Me.FListItemText(lParam2 + 1, PropSortKey)
ListItemsSortingFunctionLogical = StrCmpLogicalW(StrPtr(Text1), StrPtr(Text2))
If PropSortOrder = LvwSortOrderDescending Then ListItemsSortingFunctionLogical = -ListItemsSortingFunctionLogical
End Function
2string 20string 3string 2string 20string 3string st2ring st20ring st3ring st2ring st20ring st3ring string2 string2 string3 string20 string20 string3
Edited. Following is not a bug per-se. Behavior in the VB usercontrols does the same. A misunderstanding on my part, thinking that deleting a column removed the column contents. It does not, it just removes the column and hides the far right visible subitem.
Krool, found another bug.
This one will take a bit more work. When a listview column is removed, you shift all subitems left one. That only works if the last subitem was the one removed. In your sample project, try removing column 2 (subitem 1). The column headers shift correctly, but the subitems do not.
Updated. May have fixed it, but unsure. I think you need to take a closer look at what happens to subitems when columns are added/removed during runtime on populated listviews.
UC: ListView
Method: FColumnHeadersAdd
Action: call RebuildListItems, passing current column header count. If you are inserting columns in listsubitems for new columns vs. always appending, then I'd imagine you want to pass the new index instead
Method: FColumnHeadersRemove
Action: call RebuildListItems, passing the subitem index to be removed as a negative value. This is called before SetColumnsSubItemIndex, not after
Method: RebuildListItems
Action: added Index parameter and tweaked a little code:
Code:If .FListSubItemsCount > 0 Then
If Index = Count Then ' adding new column
' however you want to handle this, I didn't look at it
ElseIf -Index < Count Then
.ListSubItems.Remove -Index
End If
End If
The fix as you suggested is OK. However, I would like to replicate the problem to look for another potential issue.
But I couldn't replicate. Can you bundle a small demo?
Thanks. Will include sort option StrCmpLogicalW soon.
The MS ListView behaves exactly the same. So I do not consider this being a "bug". Thanks however for your testing.
I used your demo in post #1. I added 2 new test buttons with code below. Note. Setting .Redraw=False also prevents the error.
Code:' button to remove listitems & column headers
Dim n&
ListView1.ListItems.Clear
For n = ListView1.ColumnHeaders.Count To 2 Step -1
ListView1.ColumnHeaders.Remove n
Next
' button to re-add columns & errors
ListView1.ColumnHeaders.Add , , "NewCol"
ListView1.ColumnHeaders.Add , , "NewCol2"
Wow, never really noticed. I was assuming it would react similar to deleting a column from an Excel sheet. But v6 of the Listview doesn't shift column contents when headers are removed. I should've been using the .ListSubItems.Remove method of each listview item to produce the results I expected. With old age no longer creeping up, it has settled in, wonder if this is something I re-learned?Quote:
The MS ListView behaves exactly the same. So I do not consider this being a "bug". Thanks however for your testing.
For what it's worth, if a post is in the wrong thread, you can just report it, as the mods can move the post to the right thread, as long as we know which thread is the right thread.
I still tested on Windows 7 where it does not happen.
I tested now on Windows 10 and it crashes upon CDDS_ITEMPREPAINT on the Header Control, which makes sense.
I will make an update as you suggested in the ColumnHeaders::Add method to shift the FColumnHeadersAdd after it has been added to the Collection.
EDIT: Bugfix applied.
Hey
1. How can I check whether a vertical scrollbar has appeared in a listview? I want to resize column widths if a vertical scrollbar appear.
2. Is it possible to allow a vertical scrollbar to appear when needed, but not a horizontal scrollbar?
P.S. I am aware of ShowScrollBar, but when I use it to hide the horizontal scrollbar then visual artifacts appear in the bottom row where the scrollbar would have been, and the horizontal scrollbar appears anyway when I scroll vertically.
While trying to find a solution, I encountered some odd behavior, can't say whether they're bugs or not:
3.Quote:
Sub ComputeControlSize(VisibleCount As Long, Width As Single, Height As Single, [ProposedWidth As Single], [ProposedHeight As Single])
Member of VBCCR16.ListView
A method that returns the width and height for a given number of visible list items.
This always prints 0. The LV's width is 5295 twips, height is 2475, using View=LvwViewReport. Since the LV at that font size can only show 11 rows, and I set the VisibleCount parameter to 20 (I also tried with just 1), I would expect the computed vertical size to be larger than 2475.Code:Dim ww As Single
Dim hh As Single
Call lv.ComputeControlSize(20, 5295, 2475, ww, hh)
Debug.Print "ww: " & ww & ", hh: " & hh
4.I added 4 ListItems to that LV, but Debug.Print lv.GetVisibleCount prints 11. There are 11 fully-visible rows, but only 4 ListItems. The description is misleading.Quote:
Function GetVisibleCount() As Long
Member of VBCCR16.ListView
Returns the number of fully visible list items. If the list view is in 'icon', 'small icon' or 'tile' view then the return value is the total number of list items.
That works, thanks Krool.
Use GetWindowLong and test for WS_VSCROLL.
In the article below is described how to avoid vertical scrollbar. (intercept WM_NCCALCSIZE)
So for a horizontal it is likewise the same.
https://stackoverflow.com/questions/...n-details-mode
For reference, I used:
Code:Public Enum ScrollBarStyles
Horizontal_SBS = &H100000
Vertical_SBS = &H200000
End Enum
Public Function isScrollbarVisible(ByVal hWnd As Long, ByVal sbs As ScrollBarStyles) As Boolean
Dim wndStyle As Long
wndStyle = GetWindowLong(hWnd, GWL_STYLE)
isScrollbarVisible = (wndStyle And sbs) <> 0
End Function
' Usage:
If isScrollbarVisible(lv.hWnd, ScrollBarStyles.Horizontal_SBS) Then
(...)
Hello Krool,
You could avoid using the "On Error Resume Next" and solve the error that appears on the line
Code:If CLng (Button.Parent.ActiveControl.Default)> 0 Then Else Default = False
Code:Private Sub DrawButton(ByVal hWnd As Long, ByVal hDC As Long, ByVal Button As Object)
...
Select Case ButtonPart
Case BP_PUSHBUTTON
Default = Button.Default
If GetFocus() <> hWnd Then
On Error Resume Next
If CLng(Button.Parent.ActiveControl.Default) > 0 Then Else Default = False
On Error GoTo 0
End If
...
End Sub
I don't know what you mean..
However, you are referring to the VisualStyles.bas to fix the graphical style for the VB.CommandButton.
The CLng(Button.Parent.ActiveControl.Default) should never be > 0.
It only forks to the true branch when an error happens. (in this case Default should remain True even if GetFocus() <> hWnd)
So it is intended to have an OERN.
I have this error and it always stops there.
Attachment 177145
Attachment 177147
Krool,
The Val() only fix the error 13 runtime, but I have another error is no fixed with Val()
Update released.
Included the VirtualCombo control.
It is actually a super-classed combo box control with a no-data list box portion. (LBS_NODATA)
I called the class "VComboBoxWndClass".
It would be a mess to include a "VirtualMode" property to the existing ComboBoxW. Therefore like the ImageCombo, FontCombo (and even VB.DriveListBox) are separate encapsulated combo box controls. (trimmed down to what actually is needed)
Populating a VirtualCombo control is very quickly as just the .ListCount property must be set. (it can also be set at design-time)
The VirtualCombo control retrieves the strings (when they need to be drawn) via the GetVirtualItem event.
IncrementalSearch/FindVirtualItem event can also be handled to enable full functionality and behavior.
Behavior bugfix for the VirtualCombo control when Style is <> DropDownList.
The ComboBox attempts to apply the top index for the drop-down list according to the text of the edit portion.
For this case the LB_FINDSTRING is now handled and the related FindVirtualItem event must be handled for correct top index behavior by the ComboBox.
Also added the DrawMode property, which can only be set to Normal (ownerdraw handled by VirtualCombo itself) or to OwnerDrawFixed where a ItemDraw event will be fired. (OwnerDrawVariable not possible due to LBS_NODATA restriction)
Since the VirtualCombo control is in a early stage I decided to change the event param in the 'IncrementalSearch' event.
The old params were..
and the new one is simply..Code:Event IncrementalSearch(ByVal KeyChar As Integer, ByVal StartIndex As Long, ByRef FoundIndex As Long)
The difference in addition is also that the SearchString can "build-up" if typing multiple keys within a short interval. (short interval = system's double click time, multiplied with 2)Code:Event IncrementalSearch(ByVal SearchString As String, ByVal StartIndex As Long, ByRef FoundIndex As Long)
So, using Len(SearchString) tells you the current "level" of incremental search.
If classic search (like in a typical ListBox) is wanted with only 1 character search then simply just use Right$(SearchString, 1) within the IncrementalSearch event.
Hi Krool,
I'm having a problem getting VBCCR16.OCX working in my project. I get the following error dialog. VBCCR14.OCX seems to work. (Windows 10 Pro)
I regsvr32.exe the VBCCR16.OCX as administrator in a console.
VBCCR15 does the same as VBCCR16.
Is this a Windows 10 issue running the IDE?
There is the common habit of transferring the data again and again.
For example, you have a Recordset which queried a huge list.
Normally, you would populate a ComboBox from that recordset into the ComboBox via .AddItem.
So, in fact the data is in memory twice. (in the recordset and in the ComboBox)
Using Virtual controls is not very known here. The advantage is that you only need to retrieve the data once, in our example in a recordset.
The virtual control is only told how many records we have. So it is "populated" in light speed.
Whenever the virtual control needs to draw the items in the current viewport it will raise a event. In that event you search the recordset for that specified index.
So, the drawing tends to be slightly slower but that is marginal compared to the advantage of the light speed population.
All the VBCCR controls pop this dialog with a different GUID.
Krool,
I have VBCCR16 and the sidebysideand styles file as part of my project. I did a search of the registry using the listview GUID. FWIW VBCCR15 does the same as VBCCR16 with the dialog error.
Update
I unregistered all VBCCR## versions other than VBCCR16.OCX and it still is popping the error dialog. For some reason the VB6 component list is still showing VBCCR14 even though I unregistered all instances on the laptop.
I then registered VBCCR14.OCX and was able to add VBCCR controls to the form again.
VBCCR 1.6.109
I have a ListView with 2 columns (Report Mode).
The 2. column contains text with more than 300 characters but only 260 characters will be displayed.
Using .AutoSize (LvwColumnHeaderAutoSizeToItems Or LvwColumnHeaderAutoSizeToHeader) resizes the column to a max of 260 chars only.
Manually setting of the column width makes the column widther but still only 260 characters are displayed at the column and the rest of the text is truncated...
Can you remove the 260 char display restriction per column or is this a hardcoded limitation of the ListView?
It's a hard limit by comctl32.dll. Only 260 will be displayed, but as the list view items are single-lined it is actually sufficient in most cases. (read-ability)
It will be included in OCX version 1.7
Reason to not include in 1.6 is to maintain binary compatibility and keep the same clsid.
I want a Label to auto-size its width to fit the length of the label text but I want its height to remain unchanged. The AutoSize property of the label control changes both height and width. Right now I'm hard-coding the height I want everywhere I set the label's caption but is there a more elegant way to do this? I'm open to subclassing this with some guidance.
TIA
According to documentation I've seen, the VB6 Label can do this using these settings:
LabelW does not behave the same way however.Code:AutoSize = True
WordWrap = False
Quote:
Use the AutoSize and WordWrap properties to determine how the Label displays lengthy text in its Caption. If you set the AutoSize property of the Label to True (default is False), the Label automatically shrinks or stretches to the exact size needed to display the text. The WordWrap property determines whether or not an autosized Label changes size in a horizontal direction (WordWrap = False, its default value) or in a vertical direction (WordWrap = True). Remember, WordWrap has an effect only if you first set AutoSize to True.
> According to documentation I've seen, the VB6 Label can do this using these settings:
IMO auto-sizing VB.Label *always* recalculates Height. This might remain unchanged if the new recalculated value is the same as the old value (i.e. rarely or when repeating previous auto-sizing).
WordWrap controls if Width is fixed (not Height). When WordWrap is True then Width is not re-calculated. When WordWrap is False *both* Width and Height are re-calculated.
cheers,
</wqw>
p.s. Consider when is this auto-sizing happening -- on Caption property assignment, on Font assignment, on WordWrap assigment and on AutoSize pulsing (set False and immediately to True) -- which is *very* confusing and just not very clever programming interface design for such functionality. (Bet this kludge happened progressively while adding features with each new VB version.)
The position of the text of a checkbox or option button a little bit wrong when using a font size larger than 9px:
Attachment 177565
Larger:
Attachment 177564
I guess the text position should be 1 pixel up if the font size is larger than 9px
or you have to auto center the text by checking the text height and the checkbox/option height to make this water proof for all font sizes.
deleted
https://sun9-5.userapi.com/P4EDrUS5i...yO31ZaRCIc.jpg
Listview smallicons glitch when screen DPI>96
Whats the problem with the icons? i dont get it...
You should post a second picture and show how they look without the "glitch".
DPI=96 (screen size 100%). Icons are OK:
https://sun9-37.userapi.com/iFJrdq4f...IlS9lpcIKY.jpg
DPI=120 (screen size 125%). Icons are OK if themed, but bugged if classic:
https://sun9-38.userapi.com/jTaYqwXe...JLLx0U6K0Q.jpghttps://sun9-54.userapi.com/UbTl06_s...jzRI6rLT84.jpg
DPI=192 (screen size 200% - I use it for 4K display). Icons have bug. And here it is obvious that the Imagelist returns part of the next ListImage. Although it should not. The MS version does not.
https://sun9-10.userapi.com/9TwCUZeL...rnjlckG1tk.jpg