|
-
Sep 9th, 2017, 10:32 AM
#1
Re: CommonControls (Replacement of the MS common controls)
I think I will not implement Schmidts approach for fast class allocation and destruction because there is an risk for an memory leak.
If it would be an isolated area with no outside influence I would go that way. But here we have influence of "outside", means the end-user developing with the ListView control.
When the end-user developer now caches the ListItems and call .Clear then Schmidts approach will fail as the RefCounter was influenced by the end-user developer.
So there is always a risk here..
The only way I see to get an real performance boost in general is to get rid of the 1 Class usage per Row in the ListView control. (go the UDT way)
However, the down-side of this is that the end-user developer cannot compare two items if there are the same, e.g.
Code:
Private Sub ListView1_ItemClick(ByVal Item As LvwListItem, ByVal Button As Integer)
If Item Is ListView1.ListItems(1) Then MsgBox "test123"
End Sub
would not work anymore.
So question to everyone, which way to go? Or keep like it is?
-
Sep 9th, 2017, 11:37 AM
#2
Fanatic Member
Re: CommonControls (Replacement of the MS common controls)
 Originally Posted by Krool
Code:
Private Sub ListView1_ItemClick(ByVal Item As LvwListItem, ByVal Button As Integer)
If Item Is ListView1.ListItems(1) Then MsgBox "test123"
End Sub
would not work anymore.
So question to everyone, which way to go? Or keep like it is?
Go the UDT road.
-
Sep 9th, 2017, 02:15 PM
#3
Re: CommonControls (Replacement of the MS common controls)
 Originally Posted by Karl77
Go the UDT road.
To be honest I have no mood to go that road either.. 
It is so convenient the current way as the 1 class per row is stored as ObjPtr in the lParam member of LVITEM.
Changing this has for sure other perfomance drawbacks.
So I am likely to suggest for such large lists: go virtual.
-
Sep 9th, 2017, 04:35 PM
#4
Fanatic Member
Re: CommonControls (Replacement of the MS common controls)
 Originally Posted by Krool
To be honest I have no mood to go that road either.. 
It is so convenient the current way as the 1 class per row is stored as ObjPtr in the lParam member of LVITEM.
Changing this has for sure other perfomance drawbacks.
So I am likely to suggest for such large lists: go virtual.
Yes, you are right.
Especially for this seldom case.
-
Sep 19th, 2017, 08:14 AM
#5
Fanatic Member
Re: CommonControls (Replacement of the MS common controls)
Textbox problem
In my program I have a routine that selects all text in a textbox when it gets the focus (optional).
This doesn't work with TextBoxW so very well.
Code:
Private Sub TextBoxW1_GotFocus()
With TextBoxW1
.SelStart = 0
.SelLength = 999
End With
End Sub
The effect is, that the text gets selected from the start to the clicked point.
The intrinsic textbox doesn't show this behavior.
The text gets completely selected as intended.
-
Sep 19th, 2017, 11:16 AM
#6
Re: CommonControls (Replacement of the MS common controls)
 Originally Posted by Karl77
Textbox problem
In my program I have a routine that selects all text in a textbox when it gets the focus (optional).
This doesn't work with TextBoxW so very well.
Code:
Private Sub TextBoxW1_GotFocus()
With TextBoxW1
.SelStart = 0
.SelLength = 999
End With
End Sub
The effect is, that the text gets selected from the start to the clicked point.
The intrinsic textbox doesn't show this behavior.
The text gets completely selected as intended.
I did a test with an intrinsic VB TextBox and the TextBoxW:
Code:
Private Sub Text1_GotFocus()
With Text1
.SelStart = 0
.SelLength = 999
End With
End Sub
Private Sub TextBoxW2_GotFocus()
With TextBoxW2
.SelStart = 0
.SelLength = 999
End With
End Sub
Both do select the whole text at GotFocus but the mouse click changes the length of selection to actual clicked point.
So in my point behavior is exactly the same.
EDIT:
Proper implementation of AutoSelect by OnFocus would be as following:
Code:
Private Sub TextBoxW2_GotFocus()
If GetMouseStateFromMsg() = 0 Then
With TextBoxW2
.SelStart = 0
.SelLength = Len(.Text)
.Tag = "Focused"
End With
End If
End Sub
Private Sub TextBoxW2_LostFocus()
TextBoxW2.Tag = vbNullString
End Sub
Private Sub TextBoxW2_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
With TextBoxW2
If .SelLength = 0 And .Tag = vbNullString Then
.Tag = "Focused"
.SelStart = 0
.SelLength = Len(.Text)
End If
End With
End Sub
EDIT2:
I could include an "AutoSelectOnFocus" property which would take care of this internally.
Last edited by Krool; Sep 19th, 2017 at 11:47 AM.
-
Sep 19th, 2017, 01:31 PM
#7
Fanatic Member
Re: CommonControls (Replacement of the MS common controls)
The intrinsic works different from my view and experience.
It is forgiving regarding the mouseclick.
 Originally Posted by Krool
I could include an "AutoSelectOnFocus" property which would take care of this internally.
Highly appreciated.
I need the tag property for other things.
Thank you very much.
EDIT:
I'm not sure if "AutoSelectOnFocus" is enough.
This would cover only the case when all shall be selected.
There are other behaviors which require different handling.
All with GotFocus by mouse click into the textbox.
A: Move the cursor to the end
B: Select all and move cursor to the end
C: Select all and move cursor to the start
D: Do nothing, just leave the cursor where it was set by click
As said, no problem with the intrinsic textbox.
If all this should happen in the textbox control, I would need "OnFocusSelectMode".
Wouldn't it be easier to swallow the mouseclick 1x?
EDIT2:
It seems to be a completely different problem.
See from #1758 on.
Last edited by Karl77; Sep 20th, 2017 at 02:21 AM.
-
Sep 19th, 2017, 05:09 PM
#8
Re: CommonControls (Replacement of the MS common controls)
 Originally Posted by Karl77
The intrinsic works different from my view and experience.
It is forgiving regarding the mouseclick.
Can you please provide a Demo showing the different behaviors?
-
Oct 5th, 2017, 06:01 AM
#9
Fanatic Member
Re: CommonControls (Replacement of the MS common controls)
SUBCLASSING ADVICE
Up to now I use SSUBTMR6.DLL for subclassing.
From now on, I want to use the same technique that Krool uses in his controls.
I'm stuck.
Implements ISubclass creates the ISubclass_Message function, and I could do what I want from there.
But I don't know how to bring messages into the game.
In SSUBTMR6.DLL I simply had to attach/detach messages, which I could process in ISubclass_WindowProc.
How does it work with Krool's subclassing?
A very basic example would help me out.
Thank you.
Edit:
I try this in the main form of the example (post #1).
-
Oct 5th, 2017, 12:10 PM
#10
Re: CommonControls (Replacement of the MS common controls)
 Originally Posted by Karl77
SUBCLASSING ADVICE
Up to now I use SSUBTMR6.DLL for subclassing.
From now on, I want to use the same technique that Krool uses in his controls.
I'm stuck.
Implements ISubclass creates the ISubclass_Message function, and I could do what I want from there.
But I don't know how to bring messages into the game.
In SSUBTMR6.DLL I simply had to attach/detach messages, which I could process in ISubclass_WindowProc.
How does it work with Krool's subclassing?
A very basic example would help me out.
Thank you.
Edit:
I try this in the main form of the example (post #1).
Krool's method (common controls subclassing) does not filter messages. unless intercepted, you get them all.
also you gotta make sure you forward to ComCtlsDefaultProc (DefSubclassProc) in your ISubclass_Message
Code:
Option Explicit
Implements ISubclass
Private Sub Form_Load()
ComCtlsSetSubclass hWnd, Me, 0
End Sub
Private Sub Form_Unload(Cancel As Integer)
ComCtlsRemoveSubclass hWnd
End Sub
Private Function ISubclass_Message(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long, ByVal dwRefData As Long) As Long
Select Case wMsg
Case WM_DESTROY
End Select
ISubclass_Message = ComCtlsDefaultProc(hWnd, wMsg, wParam, lParam)
End Function
Last edited by DEXWERX; Oct 5th, 2017 at 12:38 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|