webu
Full Member
Posts: 149
|
Post by webu on Dec 21, 2023 19:14:32 GMT 1
Hi,
if i make a double-click to a part of a list-item, i want to do different things in col 1 or col 2 or col n
if i make a click to a ColumnHeader, i can get with ColumnHeader.Index the index:
Sub lv1_ColumnClick(ColumnHeader As ColumnHeader) Message "Click on col-number " & ColumnHeader.Index
But how do I get the column number when I (double)click on a normal part of a row?
Sub lv1_DblClick Message "Click on col-number " ??
What is for the ??
|
|
|
Post by (X) on Dec 21, 2023 21:08:03 GMT 1
A possible way is to use the HitTest event that will return the x,y coordinates where the mouse was clicked on the Listview control. Then you can check which columnheader the x falls in between.
Dim ch As ColumnHeader For each ch in LV1.ColumnHeaders <do something with ch.Index, ch.Left and ch.Width> Next
|
|
webu
Full Member
Posts: 149
|
Post by webu on Dec 21, 2023 21:31:29 GMT 1
And you're sure that's the only way? No index-var like 'ColumnHeader.Index' in the header line?
|
|
|
Post by (X) on Dec 21, 2023 21:34:54 GMT 1
I should have said: A possible way so it does not seem like there is only one way. There may be other ways.
If you click on the column header I think you can get the column index directly, but, that was not what you asked about.
From Help Document:
Sub lv1_ColumnClick(ColumnHeader As ColumnHeader)
Trace ColumnHeader.Index
End Sub
|
|
webu
Full Member
Posts: 149
|
Post by webu on Dec 21, 2023 22:05:14 GMT 1
I already had the sub you quoted from help in my opening post. Don't we have an operating system function like Sub ObjectUnderTheMouse(obj as object)
I confess, unfortunately I don't know that either... Maybe I should ask www.you.com about this
|
|
webu
Full Member
Posts: 149
|
Post by webu on Dec 21, 2023 22:14:27 GMT 1
|
|
|
Post by (X) on Dec 21, 2023 22:14:56 GMT 1
Bing offers a way using API's. I've never seen such a function in GB32. I guess when the mouse moves, you could check if the mouse pointer is within the bounds(left, top, right, bottom) of any controls in any form you are wondering about.
|
|
|
Post by (X) on Dec 21, 2023 22:23:25 GMT 1
You.com's answer is spot on! ( I didn't even hear about You.com until now. Thanks webu!)
Private Sub ListView1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) Dim row As Integer Dim col As Integer ' Find the row and column under the mouse FindListViewRowColumn X, Y, row, col ' Display the row and column numbers MsgBox "Clicked on Row: " & row & ", Column: " & col End Sub
Private Sub FindListViewRowColumn(X As Single, Y As Single, ByRef row As Integer, ByRef col As Integer) Dim item As ListItem ' Find the item under the mouse Set item = ListView1.HitTest(X, Y) ' Get the column that contains the X position col = GetListViewColumn(X) ' Get the row index row = item.Index + 1 End Sub
Private Function GetListViewColumn(X As Single) As Integer Dim col As Integer ' Loop through the columns For col = 1 To ListView1.ColumnHeaders.Count ' Check if the X position is within the column bounds If X >= ListView1.ColumnHeaders(col).Left And X <= ListView1.ColumnHeaders(col).Left + ListView1.ColumnHeaders(col).Width Then ' Return the column index GetListViewColumn = col Exit Function End If Next col ' Return -1 if no column is found GetListViewColumn = -1 End Function
|
|
webu
Full Member
Posts: 149
|
Post by webu on Dec 22, 2023 21:36:47 GMT 1
Addendum: I was ultimately very disappointed with the commands and functions you.com claimed to have available in GFA-Basic-32 to address the problem. Even when I pointed out to you.com after the chat that GFA does not have this function and that command or object property, it only modified it slightly and came up with more nonsense that does not exist in GFA-Basic-32.
Meaning: somewhat disappointing, unfortunately.
Deutsch:
Nachtrag: Ich bin letztlich sehr enttäuscht gewesen, was you.com an Befehlen und Funktionen in GFA-Basic-32 angeblich zur Verfügung hatte, um das Problem anzugehen. Auch als ich in der Folge des Chats you.com darauf hinwies, dass GFA diese Funktion und jenen Befehl oder Objekt-Eigenschaft gar nicht besitzt, hat es nur geringfügig modifiziert und sich weiteren Unsinn ausgedacht, den es unter GFA-Basic-32 nicht gibt. Bedeutet: Etwas enttäuschend, leider.
|
|
webu
Full Member
Posts: 149
|
Post by webu on Dec 22, 2023 21:44:28 GMT 1
By the way: A program that uses this function to do different things when you click on different columns in a row is KeePass. Give it a try.
Deutsch:
Übrigens: Ein Programm, das diese Funktion nutzt, unterschiedliches zu tun, wenn man unterschiedliche Spalten in einer Zeile anklickt, ist KeePass. Versucht es gerne mal.
|
|