Re: CommonControls (Replacement of the MS common controls)
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..
Re: CommonControls (Replacement of the MS common controls)
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
M$ vs. VB6 = The biggest betrayal and strategic mistake of the century!?
Re: CommonControls (Replacement of the MS common controls)
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.
Re: CommonControls (Replacement of the MS common controls)
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
M$ vs. VB6 = The biggest betrayal and strategic mistake of the century!?
Re: CommonControls (Replacement of the MS common controls)
Originally Posted by 7edm
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.
Re: CommonControls (Replacement of the MS common controls)
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
M$ vs. VB6 = The biggest betrayal and strategic mistake of the century!?
Re: CommonControls (Replacement of the MS common controls)
Ops one more question surrounding this...
In WindowsProceEdit there is this code
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
...
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?
M$ vs. VB6 = The biggest betrayal and strategic mistake of the century!?
Re: CommonControls (Replacement of the MS common controls)
Trying to understand the internals of the code, and in ComboBoxW.ctl I find
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
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?
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.
Last edited by 7edm; Jun 2nd, 2024 at 12:26 PM.
M$ vs. VB6 = The biggest betrayal and strategic mistake of the century!?
Re: CommonControls (Replacement of the MS common controls)
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
Re: CommonControls (Replacement of the MS common controls)
Originally Posted by MBS
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.
The best is you begin with the OCX as it's very user-friendly. In the first post of this thread you find a link to the OCX thread where you can download the OCX, which you need to register and then can easily use it.
Re: CommonControls (Replacement of the MS common controls)
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
Re: CommonControls (Replacement of the MS common controls)
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.
Re: CommonControls (Replacement of the MS common controls)
Originally Posted by LorinM
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.
Yeah it's one class per row. So the unload time is equal bad on 1 column or 50 columns.
Reason is VB6 fault for class destruction.
The same ListView code is super fast in twinBasic.
You may turn on .VirtualMode to solve the unload time.
Re: CommonControls (Replacement of the MS common controls)
Krool
good morning
i was using this code with MS listview
Code:
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
But now with your listview control , I get object doesn't support this property
thank you for any help
Re: CommonControls (Replacement of the MS common controls)
Originally Posted by samer22
Krool
good morning
i was using this code with MS listview
Code:
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
But now with your listview control , I get object doesn't support this property
thank you for any help
It seems the .Text property for ListSubItem is not "Default".
So it's a mismatch between MS and VBCCR, confirmed.
I will make an fix very soon and patch the typelib to have no compatibility break.
Thanks for informing.
Re: CommonControls (Replacement of the MS common controls)
Originally Posted by Krool
Handle GetVirtualItem where VirtualProperty is LvwVirtualPropertyChecked.
thank you Krool for your quick response
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
I'm getting type mismatch here.
Value = RS.Fields(SubItemIndex).Value
thank you for any help
Re: CommonControls (Replacement of the MS common controls)
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:
Code:
While PeekMessage(Msg, ListViewHeaderHandle, WM_LBUTTONDOWN, WM_LBUTTONDOWN, PM_REMOVE) <> 0 Or PeekMessage(Msg, ListViewHeaderHandle, WM_LBUTTONDBLCLK, WM_LBUTTONDBLCLK, PM_REMOVE) <> 0: Wend
If MS will one day fix the bug (unlikely) it will cause no harm to have that piece of code then still there.
Originally Posted by Mustaphi
thank you Krool for your quick response
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
I'm getting type mismatch here.
Value = RS.Fields(SubItemIndex).Value
thank you for any help
The Value expects a Boolean. You are most likely providing something which can't be coerced into a boolean.
Re: CommonControls (Replacement of the MS common controls)
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.
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.
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.
Re: CommonControls (Replacement of the MS common controls)
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.
Re: CommonControls (Replacement of the MS common controls)
Originally Posted by Mustaphi
Hi Krool
I can't add an image at runtime to listview as I was doing with MS listview
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
Is there a workaround?
OCX version 1.8
thank you
For me that little code block works. The image is set on the lvw.
Maybe provide a full isolated demo to replicate the issue?
I assume it is outside of the code block you have provided.
Re: CommonControls (Replacement of the MS common controls)
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?