Page 1 of 1

how I can get the backcolor of columns ???

Posted: Sat May 22, 2010 6:30 pm
by AL90
Dear User,

some days I try to get the correct background color of an column. Normal I can get it with

Code: Select all

Debug Hex(GetSysColor_(#COLOR_BTNFACE))
but the result is always $F0F0F0 when I use another themes without the original AERO. :roll:
Anyone an idea how I can get the correct color ?

Re: how I can get the backcolor of columns ???

Posted: Sat May 22, 2010 6:50 pm
by netmaestro
What's a column?

Re: how I can get the backcolor of columns ???

Posted: Sat May 22, 2010 7:35 pm
by AL90
netmaestro wrote:What's a column?
From an ListIconGadget.

Re: how I can get the backcolor of columns ???

Posted: Sat May 22, 2010 8:52 pm
by netmaestro
I guess you'd have to read the color you find at the item and subitem you're interested in. A little timewaster:

Code: Select all

OpenWindow(0,0,0,320,500,"",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
ListIconGadget(0,10,10,300,400,"Column 0",100)
AddGadgetColumn(0,1,"Column 1",100)
AddGadgetColumn(0,2,"Column 2",100)
For i=0 To 30
  AddGadgetItem(0,-1,"line "+Str(i)+Chr(10)+"line "+Str(i)+Chr(10)+"line "+Str(i))
  bc = 180+Random(75):cc = 180+Random(75):dc = 180+Random(75)
  SetGadgetItemColor(0,i,#PB_Gadget_BackColor,RGB(bc,cc,dc),1)
  bc = 180+Random(75):cc = 180+Random(75):dc = 180+Random(75)
  SetGadgetItemColor(0,i,#PB_Gadget_BackColor,RGB(bc,cc,dc),2)
Next

Procedure GetBackColor(listicon, item, subitem)
  FillMemory(@itemrect.RECT, SizeOf(RECT))
  itemrect\top = SubItem
  SendMessage_(listicon, #LVM_GETSUBITEMRECT, item, @itemrect.RECT)
  dc = GetWindowDC_(listicon)
  color = GetPixel_(dc,itemrect\left+2,itemrect\top+2)
  ReleaseDC_(listicon, dc)
  ProcedureReturn color
EndProcedure

Procedure GetSubItem(listicon)
  Static HitInfo.LVHITTESTINFO
  GetCursorPos_(@cp.POINT)
  ScreenToClient_(listicon, cp)
  With HitInfo 
    \pt\x = cp\x
    \pt\y = cp\y
  EndWith
  SendMessage_(listicon,#LVM_SUBITEMHITTEST,0,@HitInfo)
  ProcedureReturn @HitInfo
EndProcedure

Repeat
  ev = WaitWindowEvent()
  Select ev
    Case #WM_LBUTTONDOWN
      *hi.LVHITTESTINFO = GetSubItem(GadgetID(0))
      Debug Hex(GetBackColor( GadgetID(0), *hi\iitem, *hi\isubitem ))
  EndSelect
Until ev=#PB_Event_CloseWindow

Re: how I can get the backcolor of columns ???

Posted: Sat May 22, 2010 11:38 pm
by AL90
yes that works very good. Thanks you very much netmaestro. :D

BTW: I require this to get the transparent color for arrow images in the header of an listicon.
An icon file was normal better but is not supported by the listicon. (?) all my tries was failed. :?

Re: how I can get the backcolor of columns ???

Posted: Sun May 23, 2010 12:12 am
by netmaestro
Oh, if it's just the header color you want it's a lot simpler:

Code: Select all

OpenWindow(0,0,0,320,500,"",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
ListIconGadget(0,10,10,300,400,"Column 0",100)
AddGadgetColumn(0,1,"Column 1",100)
AddGadgetColumn(0,2,"Column 2",100)

header = SendMessage_(GadgetID(0), #LVM_GETHEADER,0,0)
hdc = GetDC_(header)
color = GetPixel_(hdc, 3,3)
ReleaseDC_(header, hdc)
Debug Hex(color)

Repeat
  ev = WaitWindowEvent()
 
Until ev=#PB_Event_CloseWindow
Just bear in mind that with skins enabled the header buttons will be a dual color/gradient.

Re: how I can get the backcolor of columns ???

Posted: Sun May 23, 2010 2:10 am
by AL90
Oh yes that's very small and better. But the result is the same like GetSysColor_().
For solution I use now the original arrows from windows. Here an example:

Code: Select all

Procedure.l SetHeaderImage(Gadget.l, column.l, TextAlign, Arrow.l)

  ; get headerID
  HwndHeader = SendMessage_(GadgetID(Gadget), #LVM_GETHEADER, 0, 0)
  TextColumn.s = Space(255)
  Var.LVCOLUMN\mask = #LVCF_TEXT
  Var\pszText = @TextColumn
  Var\cchTextMax = 255
  SendMessage_(GadgetID(Gadget), #LVM_GETCOLUMN, column, @Var)
  ; variable on HDITEM
  VarHeader.HDITEM\mask = #HDI_BITMAP | #HDI_FORMAT | #HDI_TEXT
  VarHeader\fmt = #HDF_BITMAP | TextAlign | #HDF_STRING | Arrow
  VarHeader\hbm = 0
  VarHeader\pszText = @TextColumn
  VarHeader\cchTextMax = Len(TextColumn)
  SendMessage_(HwndHeader, #HDM_SETITEM, column, @VarHeader)

EndProcedure 

If OpenWindow(0, 100, 100, 240, 200, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

  ListIconGadget(0, 5, 5, 230, 190, "Name", 100, #PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
  AddGadgetColumn(0, 1, "Size", 100)

  SetHeaderImage(0, 0, #LVCFMT_LEFT, #HDF_SORTUP)
  SetHeaderImage(0, 1, #LVCFMT_RIGHT, #HDF_SORTDOWN)

  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow

EndIf
I think own images will never 100% work with skins. (?)
Thanks again for your help. :wink:

Re: how I can get the backcolor of columns ???

Posted: Sun May 23, 2010 4:48 am
by USCode
AL90 wrote:Anyone an idea how I can get the correct color ?
Is GetGadgetItemColor() what you want?

Re: how I can get the backcolor of columns ???

Posted: Sun May 23, 2010 7:54 am
by RASHAD
@AL90 try the next

Code: Select all


Global r.RECT

Procedure ColorThread(Parameter)
            hdc = GetDC_(0)
            Color = GetPixel_(hdc, r\left+5,r\top+15)     ;GetPixel_(hdc, x,y) - Any value for x & y
            Red = Red(Color)
            Green = Green(Color)
            Blue = Blue(Color)
            Pixelc$ = RSet(Hex(Red), 2, "0") + RSet(Hex(Green), 2, "0") + RSet(Hex(Blue), 2, "0")
            MessageRequester("","Pixel Color : " + Pixelc$+#LF$+"Pixel Color : RGB("+Str(Red)+","+Str(Green)+","+Str(Blue)+")"+#LF$)
EndProcedure


Procedure.l SetHeaderImage(Gadget.l, column.l, TextAlign, Arrow.l)

  ; get headerID
  HwndHeader = SendMessage_(GadgetID(Gadget), #LVM_GETHEADER, 0, 0)
  TextColumn.s = Space(255)
  Var.LVCOLUMN\mask = #LVCF_TEXT
  Var\pszText = @TextColumn
  Var\cchTextMax = 255
  SendMessage_(GadgetID(Gadget), #LVM_GETCOLUMN, column, @Var)
  ; variable on HDITEM
  VarHeader.HDITEM\mask = #HDI_BITMAP | #HDI_FORMAT | #HDI_TEXT
  VarHeader\fmt = #HDF_BITMAP | TextAlign | #HDF_STRING | Arrow
  VarHeader\hbm = 0
  VarHeader\pszText = @TextColumn
  VarHeader\cchTextMax = Len(TextColumn)
  SendMessage_(HwndHeader, #HDM_SETITEM, column, @VarHeader)

EndProcedure 

If OpenWindow(0, 100, 100, 240, 200, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

  ListIconGadget(0, 5, 5, 230, 190, "Name", 100, #PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
  GetWindowRect_(GadgetID(0),r.RECT)
  AddGadgetColumn(0, 1, "Size", 100)

  SetHeaderImage(0, 0, #LVCFMT_LEFT, #HDF_SORTUP)
  SetHeaderImage(0, 1, #LVCFMT_RIGHT, #HDF_SORTDOWN)
  
  CreateThread(@ColorThread(), 154)

  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow

EndIf


Re: how I can get the backcolor of columns ???

Posted: Sun May 23, 2010 1:56 pm
by AL90
USCode wrote:Is GetGadgetItemColor() what you want?
No, this is not usable for the problem.
RASHAD wrote:@AL90 try the next
Its also does'nt work. Use an skin with transparent column color and add the following line to test it.

Code: Select all

PureCOLOR_SetGadgetColor(0,0,$800000)
The result is so not '$800000'.

Re: how I can get the backcolor of columns ???

Posted: Sun May 23, 2010 6:13 pm
by RASHAD
@AL90

1- Replace the next 'ColorThread(Parameter)' with the one in the previous post
2- Remember to put the exact x & y of the req. point in
Color = GetPixel_(hdc,r\left+5,r\top+5)
3- Let us see the result

Code: Select all

Procedure ColorThread(Parameter)
            hdc = GetDC_(0)
            Delay(200)
            Color = GetPixel_(hdc,r\left+5,r\top+5)     ;GetPixel_(hdc, x,y) - Any value for x & y
            ReleaseDC_(WindowID(0),hdc)
            Red = Red(Color)
            Green = Green(Color)
            Blue = Blue(Color)
            Pixelc$ = RSet(Hex(Red), 2, "0") + RSet(Hex(Green), 2, "0") + RSet(Hex(Blue), 2, "0")
            MessageRequester("","Pixel Color : " + Pixelc$+#LF$+"Pixel Color : RGB("+Str(Red)+","+Str(Green)+","+Str(Blue)+")"+#LF$)
EndProcedure

Re: how I can get the backcolor of columns ???

Posted: Sun May 23, 2010 7:30 pm
by AL90
RASHAD wrote:3- Let us see the result
oh yes it works now. I get 0,0,128 ($80000) if the skin has an transparent column and $FFFFFF if normal column. :D
but I must the delay set up to 250 with it works correct. otherwise I get again $F0F0F0.

BTW: I'm not sure why it works only with threads (?) If I call the procedure normal, the result will again false. :shock:

Code: Select all

Global r.RECT

Procedure ColorThread(Parameter)
            hdc = GetDC_(0)
            Delay(Parameter)
            Color = GetPixel_(hdc,r\left+5,r\top+5)     ;GetPixel_(hdc, x,y) - Any value for x & y
            ReleaseDC_(WindowID(0),hdc)
            Red = Red(Color)
            Green = Green(Color)
            Blue = Blue(Color)
            Pixelc$ = RSet(Hex(Red), 2, "0") + RSet(Hex(Green), 2, "0") + RSet(Hex(Blue), 2, "0")
            MessageRequester("","Pixel Color : " + Pixelc$+#LF$+"Pixel Color : RGB("+Str(Red)+","+Str(Green)+","+Str(Blue)+")"+#LF$)
EndProcedure

If OpenWindow(0, 100, 100, 240, 200, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

  ListIconGadget(0, 5, 5, 230, 190, "Name", 100, #PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
  GetWindowRect_(GadgetID(0),r.RECT)
  AddGadgetColumn(0, 1, "Size", 100)
  SetGadgetColor(0,#PB_Gadget_BackColor,$800000)
;  ColorThread(250)

  CreateThread(@ColorThread(), 250)

  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow

EndIf

Re: how I can get the backcolor of columns ???

Posted: Sun May 23, 2010 10:18 pm
by RASHAD
You can get the color value at any time but not at the start of the prog
without using Thread

Code: Select all


Global r.RECT,x,y

Procedure ColorThread(x,y)
            hdc = GetDC_(0)
            Color = GetPixel_(hdc,x,y)     ;GetPixel_(hdc, x,y) - Any value for x & y
            ReleaseDC_(WindowID(0),hdc)
            Red = Red(Color)
            Green = Green(Color)
            Blue = Blue(Color)
            Pixelc$ = RSet(Hex(Blue), 2, "0") + RSet(Hex(Green), 2, "0") + RSet(Hex(Red), 2, "0")
            MessageRequester("","Pixel Color : $" + Pixelc$+#LF$+"Pixel Color : RGB("+Str(Red)+","+Str(Green)+","+Str(Blue)+")"+#LF$)
EndProcedure

If OpenWindow(0, 100, 100, 240, 240, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

  ListIconGadget(0, 5, 5, 230, 190, "Name", 100, #PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
  ButtonGadget(1,5, 200, 60,25, "TEST")
  GetWindowRect_(GadgetID(0),r.RECT)
  AddGadgetColumn(0, 1, "Size", 100)
  SetGadgetColor(0,#PB_Gadget_BackColor,$800000)
  
  Repeat
      Select WaitWindowEvent()
          Case #PB_Event_CloseWindow
              Q = 1
    
          Case #PB_Event_Gadget
          
          Select EventGadget()
           Case 1
              ColorThread(r\left+50,r\top+50)            
          EndSelect
     EndSelect 
  Until Q = 1
EndIf

Re: how I can get the backcolor of columns ???

Posted: Mon May 24, 2010 3:09 pm
by AL90
RASHAD wrote:You can get the color value at any time but not at the start of the prog without using Thread
ok. i will see what i can do. thanks for your help. :wink: