ListIconGadget()
ListIconGadget()
Hello,
Is it possible to use the copy functionality within the ListIconGadget? I would like to copy part of a line in the ListIconGadget and paste it in a StringGadget
Michel
Is it possible to use the copy functionality within the ListIconGadget? I would like to copy part of a line in the ListIconGadget and paste it in a StringGadget
Michel
-
- Enthusiast
- Posts: 536
- Joined: Mon Feb 16, 2009 10:42 am
- Location: sweden
- Contact:
Re: ListIconGadget()
You are really not specific about what you want, kind of hard to understand
Code: Select all
Procedure copygadget()
For i=0 To CountGadgetItems(0)-1
SetGadgetText(1,GetGadgetText(1)+GetGadgetItemText(0,i)+#CRLF$)
Next
EndProcedure
OpenWindow(0,100,100,640,480,"X")
ListIconGadget(0,0,0,100,100,"X",100)
AddGadgetItem(0,-1,"XXX")
StringGadget(1,200,0,100,100,"")
ButtonGadget(2,400,0,100,100,"COPY")
Repeat
a=WaitWindowEvent()
If a=#PB_Event_CloseWindow
CloseWindow(0)
ElseIf a=#PB_Event_Gadget
If EventGadget()=2
copygadget()
EndIf
EndIf
Until Not IsWindow(0)
Re: ListIconGadget()
Hello Jesperbrannmark,
Thank you for your idea. Unfortunately it's not exact what I have in mind.
In fact I want to extract a part of a line by CTRL-C and paste it by CTRL-V into a string gadget.
Michel
Thank you for your idea. Unfortunately it's not exact what I have in mind.
In fact I want to extract a part of a line by CTRL-C and paste it by CTRL-V into a string gadget.
Michel
Re: ListIconGadget()
Hi
Code: Select all
Global oldCallback,ListIcon
Procedure LIcallback(hwnd, msg, wparam, lparam)
result = CallWindowProc_(oldCallback, hwnd, msg, wparam, lparam)
Select msg
Case #WM_LBUTTONDOWN
pInfo.LVHITTESTINFO
pInfo\pt\x = (lParam & $FFFF)
pInfo\pt\y = (lParam>> 16 & $FFFF)
SendMessage_(ListIcon,#LVM_SUBITEMHITTEST,0,@pInfo)
r.RECT
r\top = pInfo\iSubItem
r\left = #LVIR_BOUNDS
SendMessage_(ListIcon, #LVM_GETSUBITEMRECT, pInfo\iItem, @r)
ResizeGadget(1,r\left+18,r\top+14,r\right-r\left,r\bottom-r\top)
BringWindowToTop_(GadgetID(1))
SetGadgetText(1, GetGadgetItemText(0, pInfo\iItem,pInfo\iSubItem))
EndSelect
ProcedureReturn result
EndProcedure
OpenWindow(0,0,0,640,480,"Test",#PB_Window_SystemMenu| #PB_Window_ScreenCentered)
ListIcon = ListIconGadget(0,10,10,620,360,"",0,#PB_ListIcon_GridLines)
AddGadgetColumn(0,1,"Column 1",210)
AddGadgetColumn(0,2,"Column 2",200)
AddGadgetColumn(0,3,"Column 3",200)
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
StringGadget(1,0,0,0,0,"",#PB_String_BorderLess )
StringGadget(2,10,380,250,22,"")
oldCallback = SetWindowLongPtr_(ListIcon, #GWL_WNDPROC, @LIcallback())
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_Gadget
Select EventGadget()
Case 2
BringWindowToTop_(GadgetID(0))
EndSelect
EndSelect
Until Quit = 1
Egypt my love
Re: ListIconGadget()
Without API stuff (crossplatform
):Extended with the posibility to get the complete row or only a special column
Bernd

Code: Select all
Procedure.s GetGadgetEntry(Gadget, Col = -1)
Result$ = ""
Row = GetGadgetState(Gadget)
If Row <> -1
If Col = -1
Repeat
Col + 1
Until GetGadgetItemAttribute(Gadget, -1, #PB_ListIcon_ColumnWidth, Col) = 0
Col - 1
For i = 0 To Col
Result$ + GetGadgetItemText(Gadget, Row, i)
If i < Col : Result$ + " " : EndIf
Next i
Else
Result$ = Result$ + GetGadgetItemText(Gadget, Row, Col)
EndIf
EndIf
ProcedureReturn Result$
EndProcedure
OpenWindow(0, 100, 100, 230, 120, "X")
ListIconGadget(0, 10, 10, 90, 100, "Col1", 50, #PB_ListIcon_FullRowSelect)
AddGadgetColumn(0, 1, "Col2", 50)
AddGadgetItem(0, -1, "XXX" + #LF$ + "123")
AddGadgetItem(0, -1, "YYY" + #LF$ + "456")
AddGadgetItem(0, -1, "ZZZ" + #LF$ + "789")
StringGadget(1, 120, 10, 100, 100, "")
AddKeyboardShortcut(0, #PB_Shortcut_Control|#PB_Shortcut_C, 100)
AddKeyboardShortcut(0, #PB_Shortcut_Control|#PB_Shortcut_V, 101)
Exit = #False
Repeat
Event =WaitWindowEvent()
Select Event
Case #PB_Event_Menu
Select EventMenu()
Case 100
If GetActiveGadget() = 0
;SetClipboardText(GetGadgetEntry(0))
SetClipboardText(GetGadgetEntry(0, 1))
EndIf
Case 101
If GetActiveGadget() = 1
SetGadgetText(1, GetClipboardText())
EndIf
EndSelect
Case #PB_Event_CloseWindow
Exit = #True
EndSelect
Until Exit

Bernd
Last edited by infratec on Sat Dec 03, 2011 1:57 pm, edited 1 time in total.
Re: ListIconGadget()
Berned Hi
He ment select and copy any part of the text from any cell

He ment select and copy any part of the text from any cell
Egypt my love
Re: ListIconGadget()
Hi RASHAD,
In my opinion he want to copy one column of one row.
Bernd
P.S.: But anyway, now michel has a solution
Do you think so?michel wrote: In fact I want to extract a part of a line by CTRL-C and paste it by CTRL-V into a string gadget.
In my opinion he want to copy one column of one row.
Bernd
P.S.: But anyway, now michel has a solution

Re: ListIconGadget()
Hello Rashad,
You exactly understood my wish.
Now when I use your code I discover a problem when the ListIconGadget is positioned below the Stringgadgetposition; the selected text is written in the window. Can you please check.
Michel
You exactly understood my wish.

Now when I use your code I discover a problem when the ListIconGadget is positioned below the Stringgadgetposition; the selected text is written in the window. Can you please check.
Michel
Re: ListIconGadget()
Hi michel
Code: Select all
Global oldCallback,ListIcon
Procedure LIcallback(hwnd, msg, wparam, lparam)
result = CallWindowProc_(oldCallback, hwnd, msg, wparam, lparam)
Select msg
Case #WM_LBUTTONDOWN
pInfo.LVHITTESTINFO
pInfo\pt\x = (lParam & $FFFF)
pInfo\pt\y = (lParam>> 16 & $FFFF)
SendMessage_(ListIcon,#LVM_SUBITEMHITTEST,0,@pInfo)
r.RECT
r\top = pInfo\iSubItem
r\left = #LVIR_BOUNDS
SendMessage_(ListIcon, #LVM_GETSUBITEMRECT, pInfo\iItem, @r)
ResizeGadget(1,r\left+GadgetX(0)+8,r\top+GadgetY(0) + 4,r\right-r\left-GadgetX(0),r\bottom-r\top-4)
BringWindowToTop_(GadgetID(1))
SetGadgetText(1, GetGadgetItemText(0, pInfo\iItem,pInfo\iSubItem))
EndSelect
ProcedureReturn result
EndProcedure
OpenWindow(0,0,0,640,480,"Test",#PB_Window_SystemMenu| #PB_Window_ScreenCentered)
ListIcon = ListIconGadget(0,10,60,620,360,"",0,#PB_ListIcon_GridLines)
AddGadgetColumn(0,1,"Column 1",210)
AddGadgetColumn(0,2,"Column 2",200)
AddGadgetColumn(0,3,"Column 3",200)
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
StringGadget(1,0,0,0,0,"",#PB_String_BorderLess )
StringGadget(2,10,10,250,22,"")
oldCallback = SetWindowLongPtr_(ListIcon, #GWL_WNDPROC, @LIcallback())
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_Gadget
Select EventGadget()
Case 2
BringWindowToTop_(GadgetID(0))
EndSelect
EndSelect
Until Quit = 1
Egypt my love
Re: ListIconGadget()
Hi Rashad,
It works
thank you
Michel
It works



thank you
Michel
highlight/block cell text
I'm interesting ...RASHAD can u change code then it able to select all content of cell whenever i click into cell (highlight/block cell text) 



Re: ListIconGadget()
Hi Tomi
1- You can press Shift + Left Click at the end of required text
Or
2- Use Right Click Popup Menu + Select All
And here is a modified version
1- You can press Shift + Left Click at the end of required text
Or
2- Use Right Click Popup Menu + Select All
And here is a modified version
Code: Select all
Global oldCallback,ListIcon,StrHwnd,oldproc, header_h
Procedure Hheight(hwnd, msg, wParam, lParam)
Select msg
Case #HDM_LAYOUT
result = CallWindowProc_(oldproc, hwnd, msg, wParam, lParam)
*hdlayout.HD_LAYOUT = lParam
If *hdlayout\prc <> 0
*rect.RECT = *hdlayout\prc
*rect\top = header_h
EndIf
If *hdlayout\pwpos <> 0
*windowpos.WINDOWPOS = *hdlayout\pwpos
*windowpos\cy = header_h
EndIf
Default
result = CallWindowProc_(oldproc, hWnd, Msg, wParam, lParam)
EndSelect
ProcedureReturn result
EndProcedure
Procedure LIcallback(hwnd, msg, wparam, lparam)
result = CallWindowProc_(oldCallback, hwnd, msg, wparam, lparam)
Select msg
Case #WM_LBUTTONDOWN
pInfo.LVHITTESTINFO
pInfo\pt\x = (lParam & $FFFF)
pInfo\pt\y = (lParam>> 16 & $FFFF)
SendMessage_(ListIcon,#LVM_SUBITEMHITTEST,0,@pInfo)
r.RECT
r\top = pInfo\iSubItem
r\left = #LVIR_BOUNDS
SendMessage_(ListIcon, #LVM_GETSUBITEMRECT, pInfo\iItem, @r)
GetClientRect_(ListIcon,rw.RECT)
If r\right > rw\right
r\right = rw\right
EndIf
MoveWindow_(StrHwnd,r\left+GadgetX(0)+2,r\top+GadgetY(0)+4,r\right-r\left-2,r\bottom-r\top,1)
BringWindowToTop_(StrHwnd)
SetGadgetText(1, GetGadgetItemText(0, pInfo\iItem,pInfo\iSubItem))
EndSelect
ProcedureReturn result
EndProcedure
LoadFont(1, "Arial", 14)
SetGadgetFont(#PB_Default, FontID(1))
OpenWindow(0,0,0,640,480,"Test",#PB_Window_SystemMenu| #PB_Window_ScreenCentered)
ListIcon = ListIconGadget(0,10,60,620,360,"",0,#PB_ListIcon_GridLines)
hdc = GetDC_(ListIcon)
SelectObject_(hdc, FontID(1))
GetTextMetrics_(hdc, @tm.TEXTMETRIC)
AddGadgetColumn(0,1,"Column 1",210)
AddGadgetColumn(0,2,"Column 2",200)
AddGadgetColumn(0,3,"Column 3",200)
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
header_h = 40 ;Set Header Height
Header = SendMessage_(ListIcon, #LVM_GETHEADER, 0, 0)
oldproc = SetWindowLongPtr_(Header, #GWL_WNDPROC, @Hheight())
SendMessage_(ListIcon, #LVM_SCROLL, 0, 0)
StrHwnd = StringGadget(1,0,0,0,0,"" ,#PB_String_BorderLess)
;SetGadgetColor(1, #PB_Gadget_BackColor, $E1FEFD)
SetGadgetColor(1, #PB_Gadget_FrontColor, $0F0FFE)
StringGadget(2,10,10,250,tm\tmheight+4,"")
oldCallback = SetWindowLongPtr_(ListIcon, #GWL_WNDPROC, @LIcallback())
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_Gadget
Select EventGadget()
Case 2
;MoveWindow_(StrHwnd,0,0,0,0,1)
EndSelect
EndSelect
Until Quit = 1
Egypt my love
Re: ListIconGadget()
many thanks dear RASHAD
very nice




