Link in ListIconGadget

Just starting out? Need help? Post your questions and find answers here.
DerProgrammierer78
New User
New User
Posts: 3
Joined: Thu Nov 11, 2010 6:41 pm

Link in ListIconGadget

Post by DerProgrammierer78 »

Hi ...

I want to place a clickable link into a ListIconGadget. The Problem is, that this link should look like an icon or like "[link]" and not like "http://www.blablabla.com/subdir/subdir/blabla.html".

Is there a way to solve this problem?
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Link in ListIconGadget

Post by netmaestro »

You could try something along these lines, windows only of course:

Code: Select all

Structure linkdata
  index$
  link$
EndStructure

Global NewMap links.linkdata()

Procedure LVProc(hwnd, msg, wparam, lparam)
  oldproc = GetProp_(hwnd, "oldproc")
  gadget = GetDlgCtrlID_(hwnd)
  Static lastitem=-1, lastsubitem=-1
  
  Select msg
    Case #WM_NCDESTROY
      RemoveProp_(hwnd, "oldproc")
      
    Case #WM_MOUSEMOVE
      GetCursorPos_(@cp.POINT)
      MapWindowPoints_(0,hwnd,@cp,1)
      HitInfo.LVHITTESTINFO 
      Hitinfo\pt\x = cp\x
      HitInfo\pt\y = cp\y
      SendMessage_(hwnd,#LVM_SUBITEMHITTEST ,0,@HitInfo)
      item = HitInfo\iItem
      subitem = HitInfo\iSubItem
      
      If item<>lastitem Or subitem<>lastsubitem
        SetGadgetItemColor(gadget,lastitem,#PB_Gadget_FrontColor,#Blue,2)
        lastitem = item
        lastsubitem = subitem
        If subitem = 2 And item >=0
          SetGadgetItemColor(gadget,item,#PB_Gadget_FrontColor,#Red,2)
        EndIf
      EndIf
      
    Case #WM_LBUTTONDOWN
      GetCursorPos_(@cp.POINT)
      MapWindowPoints_(0,hwnd,@cp,1)
      HitInfo.LVHITTESTINFO 
      Hitinfo\pt\x = cp\x
      HitInfo\pt\y = cp\y
      SendMessage_(hwnd,#LVM_SUBITEMHITTEST ,0,@HitInfo)
      item = HitInfo\iItem
      subitem = HitInfo\iSubItem
      If subitem = 2 And item>=0
        Debug links(Str(GetGadgetItemData(gadget, item)))\link$
      EndIf
      
  EndSelect
  
  ProcedureReturn CallWindowProc_(oldproc, hwnd, msg, wparam, lparam)
EndProcedure

OpenWindow(0,0,0,640,480,"",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
ListIconGadget(0,0,0,640,480,"Column 0", 155,#PB_ListIcon_GridLines)
SetProp_(GadgetID(0),"oldproc",SetWindowLongPtr_(GadgetID(0),#GWL_WNDPROC,@LVProc()))
AddGadgetColumn(0, 1, "Column 1", 155)
AddGadgetColumn(0, 2, "Column 2", 65)
AddGadgetColumn(0, 3, "Column 3", 245)

For i=0 To 20
  AddGadgetItem(0, -1, "Stuff"+Chr(10)+"Things"+Chr(10)+"[Link "+Str(i)+"]"+Chr(10)+"Items")
  SetGadgetItemColor(0,i,#PB_Gadget_FrontColor,#Blue,2)
  SetGadgetItemData(0, i, i) ; necessary to preserve index on sorts or deletions
  links(Str(i))\link$ = "Target --> "+Str(i)
Next

Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow
This is just one approach, there are several to choose from in presenting the link and storage-retrieval of targets. You could use hyperlink gadgets inside the listicon for example. I'm trying to keep it simple.
BERESHEIT
Post Reply