Virtual listicon color [Resolved]

Just starting out? Need help? Post your questions and find answers here.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5357
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Virtual listicon color [Resolved]

Post by Kwai chang caine »

Hello at all :D

Thanks to RASHAD and NETMAESTRO, i have now a fast virtual listicon, able to give the XY and text value of the cell clicked 8)
http://www.purebasic.fr/english/viewtop ... 96#p494696

Code: Select all

Enumeration
 #Window
 #WinEntrer
 #ListIcon
 #StrEntrer
EndEnumeration

Structure ListIcon
 PosX.i
 PosY.i
 ColSelec.i
 LigneSelec.i
 LargeurColonne.i
 HauteurColonne.i
 Oldlist.l
EndStructure

#LVSICF_NOINVALIDATEALL = 1
#LVN_ODCACHEHINT = #LVN_FIRST - 13
#LVM_SUBITEMHITTEST = #LVM_FIRST + 57
#MaxLignes = 350000

Global Grid.ListIcon
Global Dim myItems.s(#MaxLignes)

Procedure WinCallback(hwnd, msg, wParam, lParam) ; RASHAD
 
 result = #PB_ProcessPureBasicEvents
 
 Select msg
   
  Case #WM_NOTIFY
   
   *pnmh.NMHDR = lParam
   
   Select *pnmh\code
   
    Case #LVN_ODCACHEHINT
   
     result = 0
     
    Case #LVN_GETDISPINFO
   
     *pnmlvdi.NMLVDISPINFO = lParam
     
     If *pnmlvdi\item\mask & #LVIF_TEXT
      Field$ = StringField(PeekS(@myItems(*pnmlvdi\item\iItem)), *pnmlvdi\item\iSubItem + 1, Chr(10))
      PokeS(*pnmlvdi\item\pszText, Field$)
     EndIf
     ;
   EndSelect
   
 EndSelect
 
 ProcedureReturn result
 
EndProcedure

Procedure SubClass_LV(hwnd, msg, wparam, lparam) ; NETMAESTRO
 
 Result = CallWindowProc_(Grid\Oldlist, hwnd, msg, wparam, lparam)
 
 Select msg   
   
  Case #WM_LBUTTONDOWN 
   HitInfo.LVHITTESTINFO
   Hitinfo\pt\x = WindowMouseX(#Window)
   HitInfo\pt\y = WindowMouseY(#Window)
   SendMessage_(GadgetID(#ListIcon), #LVM_SUBITEMHITTEST, 0, @HitInfo)
   Debug hitinfo\iItem
   Debug hitinfo\iSubItem
   Debug StringField(myItems(hitinfo\iItem),hitinfo\iSubItem+1,Chr(10))
   
 EndSelect
 
 ProcedureReturn Result
 
EndProcedure

OpenWindow(#Window, 0, 0, 640, 480, "ListIcon Gadget Mischief: Edit Selected Item", $CF0001)
ListIconGadget(#ListIcon, 0, 0, 640, 480, "", 0, #PB_ListIcon_GridLines|#LVS_OWNERDATA)
AddGadgetColumn(#ListIcon, 1, "Column 1", 210)
AddGadgetColumn(#ListIcon, 2, "Column 2", 210)
AddGadgetColumn(#ListIcon, 3, "Column 3", 215)

SetWindowCallback(@WinCallback())
SendMessage_(GadgetID(#ListIcon), #LVM_SETITEMCOUNT, #MaxLignes, #LVSICF_NOINVALIDATEALL) ; RASHAD
Grid\Oldlist = SetWindowLong_(GadgetID(#ListIcon), #GWL_WNDPROC, @SubClass_LV()) ; NETMAESTRO

For i=0 To #MaxLignes
 myItems(i) = Trim(Str(i)) + Chr(10) + "Hello" + Chr(10) + "i'm"  + Chr(10) + "KCC " + Trim(Str(i))
Next i

Repeat
 ev = WaitWindowEvent()
Until ev = #PB_Event_CloseWindow

But i want have the text of first column in blue
I have use SetItemColor but obviously that not works because it's a virtual ListIcon and she is managed only by the CallBack with the #Notify message
Worst... when i use SetItemColor, i believe the Subclassing of NETMAESTRO is called, and it's a nice whorehouse :shock:

Have you a way for changing the background, or text color of the code above ?

Have a good day
Last edited by Kwai chang caine on Thu Oct 12, 2017 3:42 pm, edited 1 time in total.
ImageThe happiness is a road...
Not a destination
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8433
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Virtual listicon color

Post by netmaestro »

the Subclassing of NETMAESTRO is called, and it's a nice whorehouse
I.. I.. I just don't know what to say in response to that :?
BERESHEIT
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4749
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: Virtual listicon color

Post by Fangbeast »

netmaestro wrote:
the Subclassing of NETMAESTRO is called, and it's a nice whorehouse
I.. I.. I just don't know what to say in response to that :?
I wouldn't take it personally. You know the french obsession with frogs and you know how those suckers breed. (heheheheheheheh)
Amateur Radio, D-STAR/VK3HAF
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4664
Joined: Sun Apr 12, 2009 6:27 am

Re: Virtual listicon color

Post by RASHAD »

I.. I.. I just don't know what to say in response to that :?
:mrgreen:

Direct and simple hack
Vive la France

Code: Select all

Enumeration
 #Window
 #WinEntrer
 #ListIcon
 #StrEntrer
EndEnumeration

#LVBKIF_SOURCE_HBITMAP = 1
#LVBKIF_STYLE_NORMAL = 0
#LVBKIF_STYLE_TILE = $10

Structure LVBKIMAGE
  ulFlags.l
  hbm.l
  pszImage.l
  cchImageMax.l
  xOffsetPercent.l
  yOffsetPercent.l
EndStructure

Structure ListIcon
  PosX.i
  PosY.i
  ColSelec.i
  LigneSelec.i
  LargeurColonne.i
  HauteurColonne.i
  Oldlist.l
EndStructure

#LVSICF_NOINVALIDATEALL = 1
#LVN_ODCACHEHINT = #LVN_FIRST - 13
#LVM_SUBITEMHITTEST = #LVM_FIRST + 57
#MaxLignes = 350000

Global Grid.ListIcon
Global Dim myItems.s(#MaxLignes)

Procedure WinCallback(hwnd, msg, wParam, lParam) ; RASHAD
 
 result = #PB_ProcessPureBasicEvents
 
 Select msg
   
  Case #WM_NOTIFY
     *NMHDR.NMHDR = lParam
       If *NMHDR\hWndFrom = GetWindow_(GadgetID(#ListIcon),#GW_CHILD) And *NMHDR\code = #HDN_ITEMCHANGING
          *phdn.NMHEADER = lParam  
                ProcedureReturn 1
       EndIf
   
   *pnmh.NMHDR = lParam
   
   Select *pnmh\code
   
    Case #LVN_ODCACHEHINT
   
     result = 0
     
    Case #LVN_GETDISPINFO
   
     *pnmlvdi.NMLVDISPINFO = lParam
     
     If *pnmlvdi\item\mask & #LVIF_TEXT
      Field$ = StringField(PeekS(@myItems(*pnmlvdi\item\iItem)), *pnmlvdi\item\iSubItem + 1, Chr(10))
      PokeS(*pnmlvdi\item\pszText, Field$)
     EndIf
     ;
   EndSelect
   
 EndSelect
 
 ProcedureReturn result
 
EndProcedure

Procedure SubClass_LV(hwnd, msg, wparam, lparam) ; NETMAESTRO
 
 Result = CallWindowProc_(Grid\Oldlist, hwnd, msg, wparam, lparam)
 
 Select msg   
   
  Case #WM_LBUTTONDOWN
   HitInfo.LVHITTESTINFO
   Hitinfo\pt\x = WindowMouseX(#Window)
   HitInfo\pt\y = WindowMouseY(#Window)
   SendMessage_(GadgetID(#ListIcon), #LVM_SUBITEMHITTEST, 0, @HitInfo)
   Debug hitinfo\iItem
   Debug hitinfo\iSubItem
   Debug StringField(myItems(hitinfo\iItem),hitinfo\iSubItem+1,Chr(10))
     
   
 EndSelect
 
 ProcedureReturn Result
 
EndProcedure

OpenWindow(#Window, 0, 0, 640, 480, "ListIcon Gadget Mischief: Edit Selected Item", $CF0001)
ListIconGadget(#ListIcon, 0, 0, 640, 480, "", 0, #PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect| #LVS_OWNERDATA)

AddGadgetColumn(#ListIcon, 1, "Column 1", 200)
AddGadgetColumn(#ListIcon, 2, "Column 2", 210)
AddGadgetColumn(#ListIcon, 3, "Column 3", 208)

CreateImage(0,GadgetWidth(#ListIcon),10,32,$FFFFFF)
StartDrawing(ImageOutput(0))
Box(0,0,200,10,$FFFEA983)
Box(410,0,210,10,$FF9D9FFE)
StopDrawing()

lbk.LVBKIMAGE
lbk\ulFlags = #LVBKIF_STYLE_NORMAL | #LVBKIF_SOURCE_HBITMAP | #LVBKIF_STYLE_TILE
lbk\hbm = ImageID(0)
SendMessage_(GadgetID(#ListIcon), #LVM_SETBKIMAGE, 0, @lbk)

SetWindowCallback(@WinCallback())
SendMessage_(GadgetID(#ListIcon), #LVM_SETITEMCOUNT, #MaxLignes, #LVSICF_NOINVALIDATEALL) ; RASHAD
Grid\Oldlist = SetWindowLong_(GadgetID(#ListIcon), #GWL_WNDPROC, @SubClass_LV()) ; NETMAESTRO

For i=0 To #MaxLignes
 myItems(i) = Trim(Str(i)) + Chr(10) + "Hello" + Chr(10) + "i'm"  + Chr(10) + "KCC " + Trim(Str(i))
Next i

Repeat
 ev = WaitWindowEvent()
Until ev = #PB_Event_CloseWindow
Egypt my love
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5357
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Virtual listicon color

Post by Kwai chang caine »

Fangbeast wrote:
netmaestro wrote:
the Subclassing of NETMAESTRO is called, and it's a nice whorehouse
I.. I.. I just don't know what to say in response to that :?
I wouldn't take it personally. You know the french obsession with frogs and you know how those suckers breed. (heheheheheheheh)
Exactely Fangbeast have one thousand time right 8)
It's a french expression (bad translated by me :oops: ), who mean "your code is perhaps called, and that make a very bad behavior, mega flickering" normal because your code (i suppose) do his job and see the change of color and do something, see by the callback, and that turn around :cry:

Dear great master NETMAESTRO, my hero since 12 years, how you can imagine i dare offense you personnally, even one second ? :shock:
In this case, I would merit ten lashes by bad word against you Image
I have a photo of your nice frog smile, and also some great masters like you, between two candles, and i pray all the day, to have cross your road at all, there is now, a long time ago 8)
Excuse me if i have annoyed you, with my stupid bad translated french expression :cry:

TheDigitalPharaoh wrote:Vive la France
:lol: Thank's a lot MASTER for your french sentence 8)
The France is a nice country...but it's often the "whorehouse" (Bordel) in french :wink: :lol: :lol:

Thanks for your code, but excuse me, i don't understand it...i don't see the changing of color ? :shock:
ImageThe happiness is a road...
Not a destination
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4749
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: Virtual listicon color

Post by Fangbeast »

Exactely Fangbeast have one thousand time right 8)
KCC, a man walks into a French Restaurant and says, "Waiter, do you have frog's legs" and the waiter replies, "No sir, I always walk this way" and the man they says, "Well then hop over here and give me something else!"
Amateur Radio, D-STAR/VK3HAF
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5357
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Virtual listicon color

Post by Kwai chang caine »

:lol: :lol: :lol:
I have nearly not understand, because in france, we don't say "Legs" but "thighs of frog" ...
And i don't dare say it's very good...perhaps great master NETMAESTRO read this a day and this time he loose his splendid smile for always :oops:

I can continue your joke :wink:
A man walks into a French Restaurant and says, "Waiter, do you have frog's legs"
and the waiter replies, "No sir, I always walk this way"
But perhaps you have "feet of pig"
and the waiter replies, "No sir, my feet is really clean, i not have that"
So finally, i'm sure you have a "head of PIG"
Seriously sir, I assure you, that I am not as stubborn as that :?
Really...for a great restaurant...you do not have much to eat :shock:
:mrgreen:
ImageThe happiness is a road...
Not a destination
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4749
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: Virtual listicon color

Post by Fangbeast »

Code: Select all

I can continue your joke  :wink:
Excellent kcc, you did a good job.

I don't have any more for tonight as I am being hunted by our crazy kitten.
Amateur Radio, D-STAR/VK3HAF
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4664
Joined: Sun Apr 12, 2009 6:27 am

Re: Virtual listicon color

Post by RASHAD »

Hi KCC
Enable modern theme to see the french flag :)
Egypt my love
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5357
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Virtual listicon color

Post by Kwai chang caine »

Ok master, i can't test now, i'm under android
But i found when even your answer strange :shock:
I have read several time your code and except the box, there is nothing who talking about color ...
I'm affraid it's a joke :lol:
Have a good night and at tommorow :wink:
ImageThe happiness is a road...
Not a destination
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4664
Joined: Sun Apr 12, 2009 6:27 am

Re: Virtual listicon color

Post by RASHAD »

Modified for modern theme or not

Code: Select all

Enumeration
 #Window
 #WinEntrer
 #ListIcon
 #StrEntrer
EndEnumeration

#LVBKIF_SOURCE_NONE = 0
#LVBKIF_SOURCE_HBITMAP = 1
#LVBKIF_SOURCE_URL = 2
#LVBKIF_SOURCE_MASK = 3
#LVBKIF_STYLE_NORMAL = 0
#LVBKIF_STYLE_TILE = $10
#LVBKIF_FLAG_TILEOFFSET = $100
#LVBKIF_STYLE_MASK = $10

Structure LVBKIMAGE Align #PB_Structure_AlignC
  ulFlags.l
  hbm.l
  pszImage.l
  cchImageMax.l
  xOffsetPercent.l
  yOffsetPercent.l
EndStructure

Structure ListIcon
  PosX.i
  PosY.i
  ColSelec.i
  LigneSelec.i
  LargeurColonne.i
  HauteurColonne.i
  Oldlist.l
EndStructure

#LVSICF_NOINVALIDATEALL = 1
#LVN_ODCACHEHINT = #LVN_FIRST - 13
#LVM_SUBITEMHITTEST = #LVM_FIRST + 57
#MaxLignes = 350000

Global Grid.ListIcon
Global Dim myItems.s(#MaxLignes)

Procedure WinCallback(hwnd, msg, wParam, lParam) ; RASHAD
 
 result = #PB_ProcessPureBasicEvents
 
 Select msg
   
  Case #WM_NOTIFY
     *NMHDR.NMHDR = lParam
       If *NMHDR\hWndFrom = GetWindow_(GadgetID(#ListIcon),#GW_CHILD) And *NMHDR\code = #HDN_ITEMCHANGING
          *phdn.NMHEADER = lParam 
                ProcedureReturn 1
       EndIf
   
   *pnmh.NMHDR = lParam
   
   Select *pnmh\code
   
    Case #LVN_ODCACHEHINT
   
     result = 0
     
    Case #LVN_GETDISPINFO
   
     *pnmlvdi.NMLVDISPINFO = lParam
     
     If *pnmlvdi\item\mask & #LVIF_TEXT
      Field$ = StringField(PeekS(@myItems(*pnmlvdi\item\iItem)), *pnmlvdi\item\iSubItem + 1, Chr(10))
      PokeS(*pnmlvdi\item\pszText, Field$)
     EndIf
     ;
   EndSelect
   
 EndSelect
 
 ProcedureReturn result
 
EndProcedure

Procedure SubClass_LV(hwnd, msg, wparam, lparam) ; NETMAESTRO
 
 Result = CallWindowProc_(Grid\Oldlist, hwnd, msg, wparam, lparam)
 
 Select msg   
   
  Case #WM_LBUTTONDOWN
   HitInfo.LVHITTESTINFO
   Hitinfo\pt\x = WindowMouseX(#Window)
   HitInfo\pt\y = WindowMouseY(#Window)
   SendMessage_(GadgetID(#ListIcon), #LVM_SUBITEMHITTEST, 0, @HitInfo)
   Debug hitinfo\iItem
   Debug hitinfo\iSubItem
   Debug StringField(myItems(hitinfo\iItem),hitinfo\iSubItem+1,Chr(10))
     
   
 EndSelect
 
 ProcedureReturn Result
 
EndProcedure

OpenWindow(#Window, 0, 0, 640, 480, "ListIcon Gadget Mischief: Edit Selected Item", $CF0001)
ListIconGadget(#ListIcon, 0, 0, 640, 480, "", 0, #PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect| #LVS_OWNERDATA)

AddGadgetColumn(#ListIcon, 1, "Column 1", 200)
AddGadgetColumn(#ListIcon, 2, "Column 2", 210)
AddGadgetColumn(#ListIcon, 3, "Column 3", 208)

CreateImage(0,GadgetWidth(#ListIcon),10,32,$FFFFFF)
StartDrawing(ImageOutput(0))
  Box(0,0,200,10,$FFFEA983)
  Box(410,0,210,10,$FF9D9FFE)
StopDrawing()

SaveImage(0,GetHomeDirectory()+"frenchflag.bmp")
img$ = GetHomeDirectory()+"frenchflag.bmp"

lbk.LVBKIMAGE
lbk\ulFlags =  #LVBKIF_SOURCE_URL | #LVBKIF_STYLE_TILE
lbk\pszImage = @img$
;lbk\hbm = ImageID(0)
SendMessage_(GadgetID(#ListIcon), #LVM_SETTEXTBKCOLOR, 0,#CLR_NONE)
SendMessage_(GadgetID(#ListIcon), #LVM_SETBKIMAGE, 0, @lbk)

SetWindowCallback(@WinCallback())
SendMessage_(GadgetID(#ListIcon), #LVM_SETITEMCOUNT, #MaxLignes, #LVSICF_NOINVALIDATEALL) ; RASHAD
Grid\Oldlist = SetWindowLong_(GadgetID(#ListIcon), #GWL_WNDPROC, @SubClass_LV()) ; NETMAESTRO

For i=0 To #MaxLignes
 myItems(i) = Trim(Str(i)) + Chr(10) + "Hello" + Chr(10) + "i'm"  + Chr(10) + "KCC " + Trim(Str(i))
Next i

Repeat
 ev = WaitWindowEvent()
Until ev = #PB_Event_CloseWindow
Egypt my love
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5357
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Virtual listicon color

Post by Kwai chang caine »

I have understand now !!! :lol:

The french FLAG !!!

Image

My nose have sniffed the joke, i'm not had really wrong !!! :lol:

This time...it's really a french ListIcon :lol:
Image

Well, thanks a lot GREAT MASTER for your precious HELP..... 8)
The backColor it's super, but at start i search to colorize also the text of only one column (The first for exampler)

I have try to put my cow pat in your jewel code :oops:

Code: Select all

SendMessage_(GadgetID(#ListIcon), #LVM_SETTEXTCOLOR, RGB(0,0,255), #CLR_NONE)
or 
SendMessage_(GadgetID(#ListIcon), #LVM_SETTEXTCOLOR, 0, RGB(0,0,255))
without succes ......obviously :mrgreen:

Have you a way for do this, without make the "bordel" (whorehouse) :lol: like i have do with my SetGadgetItemColor() of my start, in the NetMaestro SubClassing :oops:
ImageThe happiness is a road...
Not a destination
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4664
Joined: Sun Apr 12, 2009 6:27 am

Re: Virtual listicon color

Post by RASHAD »

Hi KCC
Virtual ListIconGadget() with almost any thing you need

Code: Select all


#ItemCount = 100000

#LVSICF_NOINVALIDATEALL = 1
#LVSICF_NOSCROLL = 2
#LVN_ODCACHEHINT = #LVN_FIRST - 13
#CDDS_ITEMPREPAINT = #CDDS_ITEM|#CDDS_PREPAINT 
#CDDS_SUBITEMPREPAINT = #CDDS_SUBITEM|#CDDS_ITEMPREPAINT

Global Dim myItems.s(#ItemCount+1,2)
Global oldproc, header_h

Procedure Hheight(hWnd, uMsg, wParam, lParam)    
   Select uMsg 
      Case #HDM_LAYOUT      
        SetGadgetItemAttribute(GetDlgCtrlID_(hWnd), 0, #PB_ListIcon_ColumnWidth , 0,0)
        result = CallWindowProc_(oldproc, hWnd, uMsg, 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, uMsg, wParam, lParam)
    
    EndSelect
    ProcedureReturn result
EndProcedure

Procedure winCB(hWnd, uMsg, wParam, lParam)
  result = #PB_ProcessPureBasicEvents
  Select uMsg
  
    Case #WM_SIZE
        WinX = WindowWidth(0)
        WinY = WindowHeight(0) 
        ResizeGadget(0,10,10,WinX - 20,WinY - 60)
        ResizeGadget(1,10,WinY - 40,80,25)
        ResizeGadget(2,100,WinY - 40,80,25)
        ResizeGadget(3,190,WinY - 40,80,25)
        
    Case #WM_NOTIFY
      *pnmh.NMHDR = lParam
        ; Fixed Column 0 Width
        If *pnmh\hWndFrom = GetWindow_(GadgetID(0), #GW_CHILD) And *pnmh\code = #HDN_FIRST
          *phdn.NMHEADER = lParam
             Li_c0 = SendMessage_(GadgetID(0), #LVM_GETCOLUMNWIDTH, 0,0)                       
          If *phdn\Iitem = 0 And Li_c0 > 149
                ProcedureReturn 1             
          EndIf
        EndIf
       
    Select *pnmh\code 
      Case #NM_CUSTOMDRAW 
        *LVCDHeader.NMLVCUSTOMDRAW = lParam 
          Select *LVCDHeader\nmcd\dwDrawStage    ;               
            Case #CDDS_PREPAINT
               ;result = #CDRF_NOTIFYITEMDRAW 
            Case #CDDS_ITEMPREPAINT
               result = #CDRF_NOTIFYSUBITEMDRAW            
            Case #CDDS_SUBITEMPREPAINT 
                Row = *LVCDHeader\nmcd\dwItemSpec 
                Col = *LVCDHeader\iSubItem
                ; Odd Row Color
                If Col & 1 = 1 And GetDlgItem_(hwnd,wParam) = GadgetID(0)
                  ;If  GetDlgItem_(hwnd,wParam) = GadgetID(0)
                    *LVCDHeader\clrText   = $2D36FD 
                    ;*LVCDHeader\clrTextBk = $BAEEE8 
                  ;EndIf
                Else
                  *LVCDHeader\clrText   = $0
                EndIf                
             result = #CDRF_DODEFAULT   ;#CDRF_NEWFONT
          EndSelect
         ;EndIf
         
      Case #LVN_ODCACHEHINT
        result = 0
        
      Case #LVN_GETDISPINFO
        *pnmlvdi.NMLVDISPINFO = lParam
        If *pnmlvdi\item\mask & #LVIF_TEXT
           *pnmlvdi\item\pszText = @myItems(*pnmlvdi\item\iItem,*pnmlvdi\item\iSubItem)
        EndIf

      Case #LVN_ODFINDITEM
        result = -1
        
      Case #LVN_COLUMNCLICK
        *HInfo.NMLISTVIEW = lParam
        SendMessage_(GadgetID(0), #LVM_SUBITEMHITTEST, 0, @*HInfo)
        Debug "Header Column :"+Str(*hinfo\iSubItem)
        
      Case #NM_CLICK
        HitInfo.LVHITTESTINFO
        Hitinfo\pt\x = WindowMouseX(0) 
        HitInfo\pt\y = WindowMouseY(0) - GadgetY(0)
        SendMessage_(GadgetID(0), #LVM_SUBITEMHITTEST, 0, @HitInfo)
        Debug "Row : "+Str(hitinfo\iItem)
        Debug "Column : "+Str(hitinfo\iSubItem)
        Debug myItems(hitinfo\iItem,hitinfo\iSubItem)         
    EndSelect      
      
  EndSelect
  ProcedureReturn result
EndProcedure

header_h = 20

LoadFont(0,"Broadway",12)
LoadFont(1,"Tahoma",12)

If OpenWindow(0, 0, 0, 640, 300, "ListIconGadgets", #PB_Window_SizeGadget|#PB_Window_SystemMenu | #PB_Window_MaximizeGadget| #PB_Window_ScreenCentered)
  SetWindowCallback(@winCB())
  ListIconGadget(0,10,10,620,240,"ID",150,#LVS_OWNERDATA| #LVS_AUTOARRANGE|#PB_ListIcon_FullRowSelect| #PB_ListIcon_GridLines)
  SetGadgetColor(0,#PB_Gadget_BackColor,$E6FFFF)
  SetGadgetColor(0,#PB_Gadget_LineColor,$C6C6C6)
  SetGadgetFont(0,FontID(1))
  Header = SendMessage_(GadgetID(0), #LVM_GETHEADER, 0, 0)
  SendMessage_(header,#WM_SETFONT,FontID(0),0)
  oldproc = SetWindowLong_(Header, #GWL_WNDPROC, @Hheight())
  ButtonGadget(1,10,260,80,25,"TEST")
  ButtonGadget(2,100,260,80,25,"Header H")
  ButtonGadget(3,190,260,80,25,"Row Height")
  SendMessage_(GadgetID(0), #LVM_SETITEMCOUNT, #ItemCount,#LVSICF_NOINVALIDATEALL|#LVSICF_NOSCROLL )
  AddGadgetColumn(0,2,"Name",300)
  AddGadgetColumn(0,3,"Name2",300)
  For i=0 To #ItemCount
    myItems(i,0) = Str(i)
    myItems(i,1) = "Name"+Str(i)
    myItems(i,2) = "Name2"+Str(i)
  Next
  
Repeat
  Select WaitWindowEvent()
      
      Case #PB_Event_CloseWindow
              Quit = 1
      
      Case #PB_Event_Gadget
        Select EventGadget()
           Case 1
                Item_1 = SendMessage_(GadgetID(0), #LVM_GETITEMSPACING, #True, 0) >> 16               ;Item Height             
                HotItem = GetScrollPos_(GadgetID(0),#SB_VERT)            
                SendMessage_(GadgetID(0), #LVM_SCROLL, 0, 0-(CountGadgetItems(0) * Item_1))           ;Scroll to Item 0
                SendMessage_(GadgetID(0), #LVM_GETITEMPOSITION,767,@p.POINT)             
                MessageRequester("System Modal Requester", Str(p\x)+"   "+Str(p\y), #MB_SYSTEMMODAL)
                
                ;**************************** Get Item Rect *****************************************            
                r.RECT 
                r\left = #LVIR_BOUNDS 
                SendMessage_(GadgetID(0), #LVM_GETITEMRECT,767,@r)
                MessageRequester("System Modal Requester", Str(r\left)+"   "+Str(r\bottom - Item_1), #MB_SYSTEMMODAL)
                
                ;**************************** Get SubItem Rect **************************************
                r\top = 1                                                                             ;SubItem = Column 1
                r\left = #LVIR_BOUNDS
                SendMessage_(GadgetID(0), #LVM_GETSUBITEMRECT,767,@r)                                 ;Item = 767
                MessageRequester("System Modal Requester", Str(r\left)+"   "+Str(r\bottom - Item_1), #MB_SYSTEMMODAL)
                SendMessage_(GadgetID(0), #LVM_SCROLL, 0, HotItem * Item_1)                           ;Scroll to Hot Item
            
              Case 2 ;Change Header Height on the fly
                header_h = 40
                SendMessage_(GadgetID(0), #LVM_SCROLL, 0, 0)
                InvalidateRect_(GadgetID(0),0,1) 
                      
           Case 3  ;Change Row Height on the fly
                hImg = ImageList_Create_(1, 30, #ILC_COLORDDB, 0, 0)
                SendMessage_(GadgetID(0), #LVM_SETIMAGELIST, #LVSIL_SMALL,hImg)
                ImageList_Destroy_(hImg)

        EndSelect
  EndSelect
Until Quit = 1
EndIf 
Egypt my love
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5357
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Virtual listicon color

Post by Kwai chang caine »

You are a MAGICIAN !!!

Exactely what i need and more 8)
All this complex code...just for me !!! :shock:
Thanks you very much GREAT MASTER 8)
That works very well

For celebrate our already old association...and also give to you a little present, i have create an icon
We are the dream team.....me have all the problems...and you.... all the solutions .... :mrgreen:

So... our goddess have all too

- The power beauty of egyptian women for represent your power knowledge :shock:
- The "KccMenbert who stinks, glass of wine, Baguette of brain, without forget the classical french beret, for represent... your humble servant :mrgreen:


The name of our icon, is

Image

One thousand of thanks
I continue to love you, my friend of end of the world

Have the most very good day of all the good days of the universe

Your fan for the life
Little KCC
ImageThe happiness is a road...
Not a destination
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4749
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: Virtual listicon color [Resolved]

Post by Fangbeast »

hahahaha, oohohohho, hehehehe.....
/me falls off the chair howling and squishes all the carpetbugs
Amateur Radio, D-STAR/VK3HAF
Post Reply