Could anyone show me how to populate Krool's Treeview from database?
Printable View
Could anyone show me how to populate Krool's Treeview from database?
Update released.
Bugfix that setting SelectedItem to Nothing will not fire Click event, if index changed, in the ImageCombo control.
Behavior is the same as in a normal ComboBox setting ListIndex to -1.
The ImageCombo cleared the selection but did not fired a Click event when there was a selected index before.
EDIT: The MS ImageCombo does not fire a Click event. But it's not logical and should behave as a normal ComboBox, which fires a Click event..
This demo is showing of how to use the ImageCombo control as a DriveCombo. (Unicode replacement for the VB.DriveListBox and use of system icons)
Hi and thanks for these wonderful controls Krool!
I have successfully replaced my old UniSuitePlus controls with VBCCR, as apart from they no longer are supported VBCCR also gives me the option to utilize only the controls I need. However, my old UniComboBox & UniListBox controls had some useful Events that are missing in VBCCR. I'm now trying to add this functionality by modify the VBCCR code (Yes, I'm aware of that it falls on my responsibility to keep track of and adjust for any future updates).
Basically, what I need help with is to find the proper places for the "RaiseEvent" calls to the Events I have added. The UniSuite Combo- and ListBox controls has the nice and useful functionality to distinguish between if ListIndex changed due to user action (Keyboard or Mouse Click) or if it was due action in the code. So for this I have added a ListIndexChanged() Event and it's quite strait forward to implement as it's simply a matter of either replace RaiseEvent Click or add RaiseEvent ListIndexChanged to the same location. So no problem there really.
What's more problematic for me is to find the proper location to detect that the user clicked either the Escape or the Return key ending the Edit operaton. My old ComboBox control has the events "BeginEdit" and "EndEdit", which I have also added. I have solved BeginEdit but for the other here I need to catch the reason why Edit operation ended (and corresponding place in the code), which basically can be due to 4 causes:
Loss of focus, Drop Down of List or pressing either Escape or Return keys (maybe Tab as well but that would probably fall under loss of focus). Here I could need some guidance though as I figure t has to be in some of the subclass sub/Function routines but the structure there seems quite complex.
I have identified "Private Sub IOleInPlaceActiveObjectVB_TranslateAccelerator(...)" as one routine where much of this already is tested for and putting Debug.Print statements there seems to yield needed result but at the same time other things with these keys are also happening there and I have just recently started to look deeper into this with subclassing.
So if anyone can help me out here, where to start etc. and/or maybe where not to go... and I will try to learn as I go.
TIA 7
just some hints:
The combobox does have a hWndEdit property for the edit box. Check the internal variable name for this property and search for the subclassing code that uses this variable. For more information about subclassing the edit box, check the MSDN.
Mith, thanks for your hints, they helped me out of my confusion as having been away from coding for some time it didn't cross my mind that the Edit portion sort of is a control within the control or at least it fits my mind to think of it that way.
I have a follow up question though. I have created my own ActiveX project to host just the controls I am using and noted the original OCX project has a Conditional Compiler Argument "CondComp=VBCCR_OCX = 1" (not present in the StdExe version) that leads me to the PreTranslateMsg stuff, which I have no previous experience with. But is it a correct assumption of me to include that conditional argument in my private project to have my ocx make use of the PreTranslate code?
TIA 7
If you want to use your private OCX in a VBA environment you need the PreTranslateMsg stuff. Otherwise (VB6 only) you don't.
But that PreTranslateMsg stuff is used only as kind of fallback.
So it doesn't harm to set "CondComp=VBCCR_OCX = 1" in your private OCX as well, even when you use it in VB6 only.
Thanks Krool, yes I use it in VB6 only and have no other plans. Maybe in TwinBasic later if I make that step, but I have noticed that UsePreTranslateMsg got set to False anyway even if I set the VBCCR_OCX=1 or not, due to being VB6 I now understand.
All well then and once I got it working I will share what I came up with as it may be of use to someone else as well. Now I just need to gain a bit deeper understanding of this whole subclass procedure to reach the state where it feels like I know what I'm doing ;)
Ops one more question surrounding this...
In WindowsProceEdit there is this code
If I were to put a RaiseEvent statement here, would it be prefereble to do that after ActivateIPAO and before DeActivateIPAO are called or it doesn't matter? I'm asking because the stuff that hides behind those calls are over my head right now and I'd prefer not to screw up things ;-) My intuition tells me though that I probably should do it after the Activate call and before the DeActive, is that correct?Code:Private Function WindowProcEdit(ByVal hWnd As LongPtr, ByVal wMsg As Long, ByVal wParam As LongPtr, ByVal lParam As LongPtr) As LongPtr
Select Case wMsg
Case WM_SETFOCUS
If wParam <> UserControl.hWnd And wParam <> ComboBoxHandle Then SetFocusAPI UserControl.hWnd: Exit Function
#If ImplementPreTranslateMsg = True Then
If UsePreTranslateMsg = False Then Call ActivateIPAO(Me) Else Call ComCtlsPreTranslateMsgActivate(hWnd)
#Else
Call ActivateIPAO(Me)
#End If
Case WM_KILLFOCUS
#If ImplementPreTranslateMsg = True Then
If UsePreTranslateMsg = False Then Call DeActivateIPAO Else Call ComCtlsPreTranslateMsgDeActivate
...
Trying to understand the internals of the code, and in ComboBoxW.ctl I find
and I can't help to wonder if the use of ListBoxW constants (LB_FINDSTRING & LB_FINDSTRINGEXACT) here is a bug or a feature, and if the latter what are they supposed to catch?Code:Private Function WindowProcList(ByVal hWnd As LongPtr, ByVal wMsg As Long, ByVal wParam As LongPtr, ByVal lParam As LongPtr) As LongPtr
Select Case wMsg
...
Case LB_FINDSTRING
If PropAlwaysFindExact = True Then wMsg = LB_FINDSTRINGEXACT
End Select
WindowProcList = ComCtlsDefaultProc(hWnd, wMsg, wParam, lParam)
Select Case wMsg
Case WM_MOUSEMOVE
If (GetMouseStateFromParam(wParam) And vbLeftButton) = vbLeftButton Then Call CheckTopIndex
Case WM_MOUSEWHEEL, WM_VSCROLL, LB_SETTOPINDEX
Call CheckTopIndex
End Select
End Function
EDIT: also notice LB_SETTOPINDEX that seems to be starngely placed here?
EDIT2: By "strangely placed" I mean, these are ListBox message constants, used in a ComboBox subclass routine. I don't quite get the logic in that.
Hi guys,
Congrats Kroll, putting this tool together, I did not use it yet, so can't say much...
I´m trying to test the Treeview...
I´ve followed the installation instructions but I´m getting the msg:
User-defined type not defined
CODE LINE (Declarations):
Private PropNodes As TvwNodes
Any help will be great.
MBS.
Got it, seems to be working fine... I'll let you guys know if it works for my project!
Thanks again, Krool!!
Thanks so much Kroll, all I wanted was the "node.checkbox" property.... but trying to replace the standard treeview control with the VBCCR treeview brought me 2 major problems:
a) Annoying flickering on mouse move/tracking over the control
b) the IDE crashed twice
And, the behavior on the events of VBCCR treeview I would have to adjust lots of lines of coding, would take a lot of effort...
So, at the end, I kept the standard control.
Once again, thanks for the the tool, i will try other controls in the future.
MBS
I tried a simple app using the Common Controls Replacement posted in the first post for ListView control in Report mode.
I loaded a short string into the .Text property for 10,000 and 100,000 rows.
Only one column.
Has the excruciatingly long app Exit time been addressed ?
Form_Unload takes way to long with large ListView row count.
Any fix?
Does this listview have a faster paging mode or is that no helpful.
huge thank you to you Mr. Krool
Is there a way to know if a ListView displays its horizontal scrollbar?
Thanks
I also have fun from time to time trying to apply 'SetWindowTheme' on an MsForms which embeds your controls
for the moment I only encounter failures :(
has anyone succeeded? and have a suggestion to submit to me?
Krool
good morning
i was using this code with MS listview
But now with your listview control , I get object doesn't support this propertyCode:Dim i As Long
For i = 1 To ListView1.ListItems.count
If ListView1.ListItems(i) = 1 Then
ListView1.ListItems(i).ListSubItems(1) = val(ListView1.ListItems(i).ListSubItems(1)) + val(ListView1.ListItems(i).ListSubItems(2)) / 30
End If
Next
thank you for any help
Update released.
Bugfix that the Text property was not the default property in the LvwListSubItem object.
When using the virtual mode of the listview, it becomes impossible to use listview checkbox
thank you
thank you Krool for your quick response
I'm getting type mismatch here.Code:Private Sub lvw_GetVirtualItem(ByVal ItemIndex As Long, ByVal SubItemIndex As Long, ByVal VirtualProperty As VBCCR18.LvwVirtualPropertyConstants, Value As Variant)
If VirtualProperty = LvwVirtualPropertyChecked Then
RS.AbsolutePosition = ItemIndex
Value = RS.Fields(SubItemIndex).Value
End If
End Sub
Value = RS.Fields(SubItemIndex).Value
thank you for any help
Update released.
Improved the HDN_DROPDOWN handler to remove any WM_LBUTTONDOWN/WM_LBUTTONDBLCLK message afterwards for the header window only so that we can get a toggle effect on the split button.
This is exactly the same as the Button/ToolbarWindow32 window does for BCN_DROPDOWN/TBN_DROPDOWN. Bug in the SysListView32?
The improvement is most useful when showing a popup menu as drop-down.
The code is just:
If MS will one day fix the bug (unlikely) it will cause no harm to have that piece of code then still there.Code:While PeekMessage(Msg, ListViewHeaderHandle, WM_LBUTTONDOWN, WM_LBUTTONDOWN, PM_REMOVE) <> 0 Or PeekMessage(Msg, ListViewHeaderHandle, WM_LBUTTONDBLCLK, WM_LBUTTONDBLCLK, PM_REMOVE) <> 0: Wend
The Value expects a Boolean. You are most likely providing something which can't be coerced into a boolean.
Krool
Good day
Is it possible to get only one entry checked in the listview?
Update released.
Bugfix in the VirtualItemCount property to add flag LVSICF_NOSCROLL.
With this flag the behavior of adding/removing items is the same as in non-virtual mode.
That flag LVSICF_NOSCROLL was meant to fix LVM_SETITEMCOUNT as of IE 3.0.
LVSICF_NOINVALIDATEALL allow further customization.
However, it was not added intentionally because the underlying data could be changed for the current page as well.
Quote from CMFCListCtrl- LVSICF_NOINVALIDATEALL
However, often the .VirtualItemCount is used to just tell the ListView that our data has changed. So we can't add this flag. And IMO it's not a big overhead to redraw always the current view (page) when setting the count.Quote:
Say your list control contains 10 items and shows 10 items per page. When you call SetItemCountEx(20, LVSICF_NOINVALIDATEALL) it will not refresh the view, because the additional 10 items will be outside of the view. So unless the data shown by the list control also has changed, I would always use this flag to prevent unnecessary flickering.
Internal improvement for CoolBar.
What does it mean..
If a Band in the MS CoolBar does not have a child, then it assigns a dummy "placeholder" window which is transparent.
If a band get's a real child or get's removed that placeholder window is destroyed. If the real child is detached a placeholder window is created again etc ..
So the VBCCR CoolBar replicates that exactly and does not assign a -1 HWND anymore, which seemed to work but of course makes errors inside the rebar control and was not optimal.
Also upon UserControl_Terminate all real children will be detached so that the rebar control does not call DestroyWindow API on VB6 controls, which can be problematic as well.
Hi Krool
I can't add an image at runtime to listview as I was doing with MS listview
Is there a workaround?Code:picBG.Width = lvw.Width
picBG.Height = lvw.ListItems(1).Height * (lvw.ListItems.count)
picBG.ScaleHeight = lvw.ListItems.count
picBG.ScaleWidth = 1
picBG.DrawWidth = 1
picBG.Cls
For i = 1 To lvw.ListItems.count
If lvw.ListItems(i).Text = "Yes" Then
lvw.ListItems(i).Checked = True
picBG.Line (0, i - 1)-(1, i), &H80FFFF, BF
Else
lvw.ListItems(i).Checked = False
picBG.Line (0, i - 1)-(1, i), &HFFFFFF, BF
End If
Next i
lvw.Picture = picBG.Image
Else
picBG.Cls
lvw.Picture = picBG.Image
End If
OCX version 1.8
thank you
Krool
If I Add a MS listview control and a picturebox on the form then I ran this code
the picturebox image is shown on the listview.Code:lvw.Picture = pic.Image
With your listview, I do the same thing but the picturebox image doesn't show on the listview.
I haven't checked but is "Picture" a "Property Set" or a "Property Let" for this ListView control? Might need to use the "Set" keyword...
Incorrect posting, delete
Incorrect posting, delete
for me the result is as following:
Attachment 192580
Are you using the OCX version 1.8?
this is the result when I run the codes
Did you change anything in the listview properties?
Attachment 192582
I also noticed that even in the IDE I can't add a picture unlike the MS listview.
Has it to do with the OS.
I;m using W11
Can anyone of the members test my demo?
I tested on an old w 7 but still the same problem