Listicongadget column identity

Just starting out? Need help? Post your questions and find answers here.
epog10
User
User
Posts: 93
Joined: Sat May 29, 2010 11:46 am
Location: UK

Listicongadget column identity

Post by epog10 »

Apologies if the following has been answered in the forum - as an occasional user I have not found it.

I can get the line number in which a cell was clicked with GetGadgetState. But is there an equivalent way of getting the column number?

Regards,
epog10
User avatar
Shardik
Addict
Addict
Posts: 2060
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: Listicongadget column identity

Post by Shardik »

Unfortunately you don't tell us your operating system. Therefore you may take a look into this cross-platform example which reports the clicked cell (row and column) in a ListIconGadget. It utilizes the procedure GetSelectedColumn().

By the way, you had created that linked thread from 2015. :wink:
Last edited by Shardik on Thu Feb 23, 2023 8:09 pm, edited 3 times in total.
User avatar
the.weavster
Addict
Addict
Posts: 1577
Joined: Thu Jul 03, 2003 6:53 pm
Location: England

Re: Listicongadget column identity

Post by the.weavster »

Or perhaps consider using ListEx instead of ListIconGadget
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Listicongadget column identity

Post by netmaestro »

Here it is for Windows, if you use another OS it won't help you.

Code: Select all

OpenWindow(0,0,0,320,275,"",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
ListIconGadget(0,0,0,320,240,"Column 0", 100)
AddGadgetColumn(0, 1,"Column 1",100)
AddGadgetColumn(0,2,"Column 2",100)
For i=0 To 10
  AddGadgetItem(0, -1, "Item "+Str(i)+" col 0"+Chr(10)+"Item "+Str(i)+" col 1"+Chr(10)+"Item "+Str(i)+" col 2")
Next
TextGadget(1, 10, 250, 40,20,"Item:")
StringGadget(2, 41, 247,40,20, "")
TextGadget(3, 100, 250, 50,20,"SubItem:")
StringGadget(4, 150, 247,40,20, "")

Repeat 
  EventID = WaitWindowEvent()
  Select EventID
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 0
          Select EventType()
            Case #PB_EventType_LeftClick
              GetCursorPos_(@here.POINT)
              With hti.LVHITTESTINFO
                \pt = here
              EndWith
              MapWindowPoints_(0,GadgetID(0), hti\pt, 1)
              SendMessage_(GadgetID(0), #LVM_SUBITEMHITTEST, 0, hti)
              SetGadgetText(2, Str(hti\iItem))
              SetGadgetText(4, Str(hti\iSubItem))
          EndSelect
      EndSelect
  EndSelect
Until EventID = #PB_Event_CloseWindow
BERESHEIT
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4955
Joined: Sun Apr 12, 2009 6:27 am

Re: Listicongadget column identity

Post by RASHAD »

Hi
It maybe cross platform using native commands
But I tested it only with PB 6.xx x86 - Windows 11 x64
Have fun :)

Code: Select all

OpenWindow(0,0,0,640,480,"Test",#PB_Window_SystemMenu| #PB_Window_ScreenCentered) 
ListIconGadget(0,10,10,620,460,"",0,#PB_ListIcon_GridLines)

AddGadgetColumn(0,1,"Column 1",110) 
AddGadgetColumn(0,2,"Column 2",100) 
AddGadgetColumn(0,3,"Column 3",100) 
AddGadgetColumn(0,4,"Column 4",100)
AddGadgetColumn(0,5,"Column 5",100)

For i = 0 To 16 
  linestr.s = LSet(Str(i),3," ") 
  AddGadgetItem(0, -1, Chr(10)+"Text on Line "+linestr+" in Column 1"+Chr(10)+"Text on Line "+linestr+" in Column 2"+Chr(10)+"Text on Line "+linestr+" in Column 3") 
Next

SetGadgetItemColor(0, #PB_All, #PB_Gadget_BackColor,$FEFFFF,1)
SetGadgetItemColor(0, #PB_All, #PB_Gadget_BackColor,$FDFFFF,2)
SetGadgetItemColor(0, #PB_All, #PB_Gadget_BackColor,$FCFFFF,3)
SetGadgetItemColor(0, #PB_All, #PB_Gadget_BackColor,$FBFFFF,4)
SetGadgetItemColor(0, #PB_All, #PB_Gadget_BackColor,$FAFFFF,5)    
  
Repeat
  Select  WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Quit = 1        
           
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 0
          Select EventType()                                        
            Case #PB_EventType_LeftClick
              x = WindowMouseX(0)
              y = WindowMouseY(0)
              StartDrawing(WindowOutput(0))
                For i = 1 To 20
                  Column = 255 - Blue(Point(x,y))
                  If Column < 10
                    Break
                  Else
                    y-1
                  EndIf
                Next                                   
              StopDrawing()
              Debug "Column "+Str(Column)                                        
          EndSelect
      EndSelect
  EndSelect
Until Quit = 1

Egypt my love
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Listicongadget column identity

Post by netmaestro »

That is just too clever for words, RASHAD! I spent some time trying to make it fail if I clicked on some black text and when I couldn't, I looked closer. Very neat indeed :mrgreen:
BERESHEIT
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4955
Joined: Sun Apr 12, 2009 6:27 am

Re: Listicongadget column identity

Post by RASHAD »

Hi NM
Thank you very much for your nice compliment :D
Egypt my love
User avatar
ChrisR
Addict
Addict
Posts: 1466
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: Listicongadget column identity

Post by ChrisR »

I admit, it's impressive and it works really well, I don't know how you came up with this bright idea :shock:
Like NM, I tried to capture the text in black, even with a character like Alt+219 (line below)
I don't really understand how it can work clicking on the black, but it works

Code: Select all

AddGadgetItem(0, -1, Chr(10)+"███ Text on Line ███ "+linestr+" in Column 1 ███"+Chr(10)+"███ Text on Line ███ "+linestr+" in Column 2 ███"+Chr(10)+"███ Text on Line ███ "+linestr+" in Column 3 ███")
Axolotl
Addict
Addict
Posts: 852
Joined: Wed Dec 31, 2008 3:36 pm

Re: Listicongadget column identity

Post by Axolotl »

Hi RASHAD,
very nice solution.
If you hit exactly the horizontal line, then the column is not correct.
I changed line 40 to "y - 1 : x + 1 " ; (probably x - 1 is working as well) then it works (at least for me).

@ChrisR, on the black color the column is bigger then 10 and the position is moving until the column is smaller than 10
Very tricky indeed.
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
User avatar
ChrisR
Addict
Addict
Posts: 1466
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: Listicongadget column identity

Post by ChrisR »

Thanks for the explanation, I hadn't looked further under the hood, wow, very ingenious

So if I understand correctly, we just need to change: For i = 1 To 20 -> y-1, if we change to a larger font eg: (If LoadFont(1, "Arial", 24) : SetGadgetFont(0, FontID(1)) : EndIf with a char like Alt+219 █
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4955
Joined: Sun Apr 12, 2009 6:27 am

Re: Listicongadget column identity

Post by RASHAD »

Hi guys
Thanks for your comments

@ Axolotl
x position is not suitable because the user can increase the column width by draging it to unknown limit
While y position is fine because there is always a colored segment upward and downward the included text beside it is limited to the Row Height depending on the size of the font used

@ ChrisR
Thanks for testing

But guys no one report if it works with Linux & Mac :D
Egypt my love
Axolotl
Addict
Addict
Posts: 852
Joined: Wed Dec 31, 2008 3:36 pm

Re: Listicongadget column identity

Post by Axolotl »

@ChrisR, exactly.
You can add this to the else path and you can follow the calculation.
BTW: I added x + 1, because I was able to click on the horizontal gridline ....

Code: Select all

y-1 : x + 1                      :Debug "  " + i + ": " + Column + " -- Change the Position to " + x + ", " + y 
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
User avatar
ChrisR
Addict
Addict
Posts: 1466
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: Listicongadget column identity

Post by ChrisR »

@Axolotl
I assume you mean able to click on the vertical gridline .... (for x+1)

To play with it a bit, to adapt the loop according to the font of the ListIcon, it should be possible to do like this, with also x+1 if you click on the vertical grid line :

Code: Select all

TmpGadget = TextGadget(#PB_Any, 0, 0, 0, 0, "█")
SetGadgetFont(TmpGadget, GetGadgetFont(0))
MaxTextHeight = GadgetHeight(TmpGadget, #PB_Gadget_RequiredSize)
FreeGadget(TmpGadget)
...............
StartDrawing(WindowOutput(0))
For i = 0 To 1
  For j = 1 To MaxTextHeight
    Column = 255 - Blue(Point(x,y))
    ;Debug "i = " + Str(i) + " - j = " + Str(j) + " - Column = " + Str(Column)
    If Column < 10 And Column > 0
      Break 2
    EndIf
    y-1
  Next
  y+MaxTextHeight
  x+1
Next
StopDrawing()
RASHAD wrote: Fri Feb 24, 2023 3:30 pm But guys no one report if it works with Linux & Mac :D
AZJIO
Addict
Addict
Posts: 2192
Joined: Sun May 14, 2017 1:48 am

Re: Listicongadget column identity

Post by AZJIO »

Code: Select all

EnableExplicit
Declare MyWindowCallback(hWin, Msg, wParam, lParam)

Global hListView

OpenWindow(0, 0, 0, 550, 320,"ListIconGadget", #PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget)

hListView = ListIconGadget(0,  2, 2, 499, 188, "col1  ", 90, #PB_ListIcon_FullRowSelect)
AddGadgetColumn(0, 1, "col2", 70)
AddGadgetColumn(0, 2, "col3  ", 120)
AddGadgetColumn(0, 3, "col4  ", 120)

AddGadgetItem(0, -1, "item 1" + #LF$ + "1111" + #LF$ + "1 in column 3" + #LF$ + "1 in column 4")
AddGadgetItem(0, -1, "item 2" + #LF$ + "2222" + #LF$ + "2 in column 3" + #LF$ + "2 in column 4")
AddGadgetItem(0, -1, "item 3" + #LF$ + "3333" + #LF$ + "3 in column 3" + #LF$ + "3 in column 4")
AddGadgetItem(0, -1, "item 4" + #LF$ + "4444" + #LF$ + "4 in column 3" + #LF$ + "4 in column 4")
AddGadgetItem(0, -1, "item 5" + #LF$ + "5555" + #LF$ + "5 in column 3" + #LF$ + "5 in column 4")

EditorGadget(1, 2, 195, 545, 122, #ES_AUTOVSCROLL | #WS_VSCROLL | #ES_NOHIDESEL | #ES_WANTRETURN)

SetWindowCallback(@MyWindowCallback())

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow

Procedure MyWindowCallback(hWin, Msg, wParam, lParam)
	Protected Result = #PB_ProcessPureBasicEvents
	Protected *pnmhdr.NMHDR =lParam
	Protected *pnmlv.NMLISTVIEW =lParam

	Select Msg
		Case #WM_NOTIFY
			Select *pnmhdr\hWndFrom
				Case hListView
					Select *pnmhdr\code
						Case #NM_CLICK
							SetGadgetText(1, "item number:" + #TAB$ + *pnmlv\iItem + #CRLF$ + "column number:" + #TAB$ + *pnmlv\iSubItem)
							ProcedureReturn #True
					EndSelect
			EndSelect
	EndSelect

	ProcedureReturn Result
EndProcedure
Full example, with keystrokes and different types of clicks (example AutoIt3)

Code: Select all

EnableExplicit
Declare MyWindowCallback(hWin, Msg, wParam, lParam)
#BCN_HOTITEMCHANGE = -1249

Structure NMBHOTITEM Extends NMHDR
  dwFlags.l
EndStructure

Structure NMLVSCROLL Extends NMHDR
	DX.i
	DY.i
EndStructure

Structure NMLVKEYDOWN Extends NMHDR Align 1
	VKey.w
	Flags.l
EndStructure

Global hListView, help.s, k = 0, hEdit, btn1, btn2
help.s = "Пример показывает возможность назначить управление/действия" + #CRLF$ + "пунктам используя клавиши модификаторы и способ клика мыши" + #CRLF$ + #CRLF$ + "Для каждого ListView можно назначить своё поведение," + #CRLF$ + "которое определяется в выборе -Case hWndListView-"


OpenWindow(0, 0, 0, 550, 320,"Кликайте по элементам в ListView, нажмите F2", #PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget)

hListView = ListIconGadget(0,  2, 2, 199, 88, "кол1  ", 60, #LVS_EDITLABELS | #PB_ListIcon_CheckBoxes | #PB_ListIcon_FullRowSelect)
AddGadgetColumn(0, 1, "кол2", 60)
AddGadgetColumn(0, 2, "кол3  ", 60)

AddGadgetItem(0, -1, "пункт 1" + #LF$ + "1111" + #LF$ + "1 в кол 3")
AddGadgetItem(0, -1, "пункт 2" + #LF$ + "2222" + #LF$ + "2 в кол 3")
AddGadgetItem(0, -1, "пункт 3" + #LF$ + "3333" + #LF$ + "3 в кол 3")
AddGadgetItem(0, -1, "пункт 4" + #LF$ + "4444" + #LF$ + "4 в кол 3")

hEdit = EditorGadget(1, 2, 95, 545, 222, #ES_AUTOVSCROLL | #WS_VSCROLL | #ES_NOHIDESEL | #ES_WANTRETURN)
SetGadgetText(1, help)
GetGadgetColor(1 , $fffbd7)

btn1 = ButtonGadget(2, 225, 66, 70, 25, "Первая")
btn2 = ButtonGadget(3, 315, 66, 70, 25, "Вторая")

SetWindowCallback(@MyWindowCallback())

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow

Procedure MyWindowCallback(hWin, Msg, wParam, lParam)
	Protected item, Text$, tmp$
	Static tmpOld$
	Protected Result = #PB_ProcessPureBasicEvents
	Protected *pnmhdr.NMHDR =lParam
	Protected *pitema.NMITEMACTIVATE =lParam
	Protected *pnmlv.NMLISTVIEW =lParam
	Protected *vlkey.NMLVKEYDOWN
	Protected *Info.NMLVDISPINFO
	Protected *pnmlv2.NMBHOTITEM
	Protected *scroll.NMLVSCROLL

	Select Msg
		Case #WM_NOTIFY
			k + 1
			SetWindowTitle(0 , "Вызов " + k + " ID =" + wParam)
			Select *pnmhdr\hWndFrom
				Case hListView
					Select *pnmhdr\code
						Case #LVN_COLUMNCLICK
							SetGadgetText(1, "LVN_COLUMNCLICK" + #TAB$ + "клик на заголовке колонки" + #CRLF$ + "дескриптор:" + #TAB$ + *pnmhdr\hWndFrom + #CRLF$ + "идентификатор:" + #TAB$ + *pnmhdr\IDFrom + #TAB$ + "(порядковый номер элемента в окне)" + #CRLF$ + "№ колонки:" + #TAB$ + *pnmlv\iSubItem + #TAB$ + "(отсчёт от 0)")

						Case #NM_DBLCLK ; левый двойной клик мышкой по пункту

							SetGadgetText(1, "NM_DBLCLK" + #TAB$ + "ДВОЙНОЙ клик левой кнопкой мыши" + #CRLF$ + "дескриптор:" + #TAB$ + *pnmhdr\hWndFrom + #CRLF$ + "идентификатор:" + #TAB$ + *pnmhdr\IDFrom + #TAB$ + "(порядковый номер элемента в GUI)" + #CRLF$ + "код клика:" + #TAB$ + *pnmhdr\code + #TAB$ + "(определяет правой или левой, двойной или одинарный клик мыши)" + #CRLF$ + "№ пункта:" + #TAB$ + *pnmlv\iItem + #TAB$ + "(номер строки, отсчёт от 0, -1 пустое пространство)" + #CRLF$ + "№ колонки:" + #TAB$ + *pnmlv\iSubItem + #TAB$ + "(отсчёт от 0)" + #CRLF$ + "удерж. клавиша:" + #TAB$ + *pitema\uKeyFlags + #TAB$ + "(0=ничего; 1=Alt, 2=Ctrl, 4=Shift, 3,5,6,7 - комбинации)")

						Case #NM_CLICK ; левый клик мышкой по пункту
							SetGadgetText(1, "NM_CLICK" + #TAB$ + "одинарный клик левой кнопкой мыши" + #CRLF$ + "дескриптор:" + #TAB$ + *pnmhdr\hWndFrom + #CRLF$ + "идентификатор:" + #TAB$ + *pnmhdr\IDFrom + #TAB$ + "(порядковый номер элемента в GUI)" + #CRLF$ + "код клика:" + #TAB$ + *pnmhdr\code + #TAB$ + "(определяет правой или левой, двойной или одинарный клик мыши)" + #CRLF$ + "№ пункта:" + #TAB$ + *pnmlv\iItem + #TAB$ + "(номер строки, отсчёт от 0, -1 пустое пространство)" + #CRLF$ + "№ колонки:" + #TAB$ + *pnmlv\iSubItem + #TAB$ + "(отсчёт от 0)" + #CRLF$ + "удерж. клавиша:" + #TAB$ + *pitema\uKeyFlags + #TAB$ + "(0=ничего; 1=Alt, 2=Ctrl, 4=Shift, 3,5,6,7 - комбинации)")
							ProcedureReturn #True
						Case #NM_HOVER ; Высылается элементом list-view когда мышь поверх пункта
							SetGadgetText(1, "NM_HOVER" + #TAB$ + "наведение курсора мыши" + #CRLF$ + "дескриптор:" + #TAB$ + *pnmhdr\hWndFrom + #CRLF$ + "идентификатор:" + #TAB$ + *pnmhdr\IDFrom + #TAB$ + "(порядковый номер элемента в GUI)" + #CRLF$ + "код клика:" + #TAB$ + *pnmhdr\code + #TAB$ + "(определяет правой или левой, двойной или одинарный клик мыши)" + #CRLF$ + "№ пункта:" + #TAB$ + *pnmlv\iItem + #TAB$ + "(номер строки, отсчёт от 0, -1 пустое пространство)" + #CRLF$ + "№ колонки:" + #TAB$ + *pnmlv\iSubItem + #TAB$ + "(отсчёт от 0)")
						Case #LVN_HOTTRACK ; Высылает в ListView, когда пользователь перемещает курсор мыши над пунктом
							tmp$ = "LVN_HOTTRACK" + #TAB$ + "наведение курсора мыши" + #CRLF$ + "дескриптор:" + #TAB$ + *pnmhdr\hWndFrom + #CRLF$ + "идентификатор:" + #TAB$ + *pnmhdr\IDFrom + #TAB$ + "(порядковый номер элемента в GUI)" + #CRLF$ + "код клика:" + #TAB$ + *pnmhdr\code + #TAB$ + "(определяет правой или левой, двойной или одинарный клик мыши)" + #CRLF$ + "№ пункта:" + #TAB$ + *pnmlv\iItem + #TAB$ + "(номер строки, отсчёт от 0, -1 пустое пространство)" + #CRLF$ + "№ колонки:" + #TAB$ + *pnmlv\iSubItem + #TAB$ + "(отсчёт от 0)"
							If tmp$<>tmpOld$
								SetGadgetText(1, tmp$)
								tmpOld$ = tmp$
							EndIf
						Case #LVN_BEGINSCROLL ; Начинается операция прокрутки, минимальная ОС WinXP
							*scroll.NMLVSCROLL=lParam
							SetGadgetText(1, "LVN_BEGINSCROLL" + #TAB$ + "прокрутка" + #CRLF$ + "DX:" + #TAB$ + *scroll\DX + #CRLF$ + "DY:" + #TAB$ + *scroll\DY)

						Case #LVN_KEYDOWN ; нажатие любой клавиши
							*vlkey.NMLVKEYDOWN=lParam
							If Int(Val(Right(GetGadgetText(1), 2))) <> *vlkey\VKey
; 								SetGadgetText(1, #CRLF$ + "Нажата клавиша №: " + Str(*vlkey\VKey))
								AddGadgetItem(1 , -1 , #CRLF$ + "Нажата клавиша №: " + Str(*vlkey\VKey))
							EndIf
							Select *vlkey\VKey
								Case 113; F2
									item = GetGadgetState(0)
									If item >= 0
										; edititem = GetItemLV()
										SendMessage_(hListView,#LVM_EDITLABEL,item,0) ; editcontrol =
										SetGadgetText(1, "Нажата клавиша F2" + #CRLF$ +"Редактирование пункта " + Str(item))
										ProcedureReturn #False
									Else
										SetGadgetText(1, "Нужно выделить пункт")
									EndIf
							EndSelect

						Case #LVN_ENDLABELEDITA, #LVN_ENDLABELEDITW ; конец редактирования пункта
							*Info.NMLVDISPINFO=lParam
							If *Info\item\mask & #LVIF_TEXT
								If Len(PeekS(*Info\item\pszText))
									ProcedureReturn #True
								EndIf
							EndIf

						Case #NM_RCLICK ; правый клик мышкой по пункту
							SetGadgetText(1, "NM_RCLICK" + #TAB$ + "одинарный клик ПРАВОЙ кнопкой мыши" + #CRLF$ + "дескриптор:" + #TAB$ + *pnmhdr\hWndFrom + #CRLF$ + "идентификатор:" + #TAB$ + *pnmhdr\IDFrom + #TAB$ + "(порядковый номер элемента в GUI)" + #CRLF$ + "код клика:" + #TAB$ + *pnmhdr\code + #TAB$ + "(определяет правой или левой, двойной или одинарный клик мыши)" + #CRLF$ + "№ пункта:" + #TAB$ + *pnmlv\iItem + #TAB$ + "(номер строки, отсчёт от 0, -1 пустое пространство)" + #CRLF$ + "№ колонки:" + #TAB$ + *pnmlv\iSubItem + #TAB$ + "(отсчёт от 0)" + #CRLF$ + "удерж. клавиша:" + #TAB$ + *pitema\uKeyFlags + #TAB$ + "(0=ничего; 1=Alt, 2=Ctrl, 4=Shift, 3,5,6,7 - комбинации)")

						Case #NM_RDBLCLK ; правый двойной клик мышкой по пункту
							SetGadgetText(1, "NM_RDBLCLK" + #TAB$ + "ДВОЙНОЙ клик ПРАВОЙ кнопкой мыши" + #CRLF$ + "дескриптор:" + #TAB$ + *pnmhdr\hWndFrom + #CRLF$ + "идентификатор:" + #TAB$ + *pnmhdr\IDFrom + #TAB$ + "(порядковый номер элемента в GUI)" + #CRLF$ + "код клика:" + #TAB$ + *pnmhdr\code + #TAB$ + "(определяет правой или левой, двойной или одинарный клик мыши)" + #CRLF$ + "№ пункта:" + #TAB$ + *pnmlv\iItem + #TAB$ + "(номер строки, отсчёт от 0, -1 пустое пространство)" + #CRLF$ + "№ колонки:" + #TAB$ + *pnmlv\iSubItem + #TAB$ + "(отсчёт от 0)" + #CRLF$ + "удерж. клавиша:" + #TAB$ + *pitema\uKeyFlags + #TAB$ + "(0=ничего; 1=Alt, 2=Ctrl, 4=Shift, 3,5,6,7 - комбинации)")
					EndSelect
				Default
					; Обработка события кнопок
					*pnmlv2.NMBHOTITEM=lParam
					Text$ = ""

					Select *pnmlv2\Code
						Case #BCN_HOTITEMCHANGE ; Win XP и выше
							If *pnmlv2\dwFlags & $10
								Text$ = "наведена"
							ElseIf *pnmlv2\dwFlags & $20
								Text$ = "оставлена"
							EndIf
							SetGadgetText(1, "Кнопка " + GetGadgetText(*pnmhdr\IDFrom) + " " + Text$ + #CRLF$ + "идентификатор" + #TAB$ + Str(*pnmlv2\IDFrom) + #CRLF$ + "дескриптор:" + #TAB$ + Str(*pnmhdr\hWndFrom))
					EndSelect
			EndSelect
	EndSelect

	ProcedureReturn Result
EndProcedure
User avatar
Shardik
Addict
Addict
Posts: 2060
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: Listicongadget column identity

Post by Shardik »

RASHAD wrote: Fri Feb 24, 2023 3:30 pm But guys no one report if it works with Linux & Mac :D
These are my test results with RASHAD's code and PB 6.00:
  • Linux Mint 19.3 'Tricia' x64: Column detection is very unreliable:
    Text on Line 0 in Column 1: Column 0
    Text on Line 0 in Column 2: Column 18
    Text on Line 0 in Column 3: Column 18
    Text on Line 0 in Column 4: Column 66
    Text on Line 0 in Column 5: Column 18
    Text on Line 1 in Column 1: Column 1
    Text on Line 1 in Column 2: Column 2
    Text on Line 1 in Column 3: Column 0
    Text on Line 1 in Column 4: Column 4
    Text on Line 1 in Column 5: Column 5
    Text on Line 2 in Column 1: Column 5
    Text on Line 2 in Column 2: Column 2
    Text on Line 2 in Column 3: Column 8
    Text on Line 2 in Column 4: Column 4
    Text on Line 2 in Column 5: Column 5
    These results vary with every new try!
  • MacOS 11.7.4 'Big Sur': Doesn't work at all. Output is always "Column 255" independant of the cell where the left click occurred. Probable cause:
    Help for ListIconGadget wrote:- SetGadgetItemColor(): Changes front or backcolor of the item (backcolor not supported on MacOS X).
  • WIndows 10 Version 22H2 x64: Works like a charm.
Post Reply