Page 1 of 1

Calculate inner width+height of PanelGadget items

Posted: Mon Dec 29, 2003 10:28 pm
by Danilo
Code updated For 5.20+

Code: Select all

;
; Calculate inner width+height of panel items
;
; by Danilo, 29.12.2003
;
Procedure GetPanelItemWidth(PanelGadget)
  ; returns the inner width of panel items
  tc.TC_ITEM\mask = #TCIF_PARAM
  If SendMessage_(GadgetID(PanelGadget),#TCM_GETITEM,0,@tc)
    GetClientRect_(tc\lParam,rect.RECT)
    ProcedureReturn rect\right
  EndIf
EndProcedure

Procedure GetPanelItemHeight(Panelgadget)
  ; returns the inner height of panel items
  tc.TC_ITEM\mask = #TCIF_PARAM
  If SendMessage_(GadgetID(PanelGadget),#TCM_GETITEM,0,@tc)
    GetClientRect_(tc\lParam,rect.RECT)
    ProcedureReturn rect\bottom
  EndIf
EndProcedure

Procedure ScrollbarWidth()
  ; returns the width of windows scrollbars
  ProcedureReturn GetSystemMetrics_(#SM_CXHSCROLL)
EndProcedure

Procedure ScrollbarHeight()
  ; returns the height of windows scrollbars
  ProcedureReturn GetSystemMetrics_(#SM_CYVSCROLL)
EndProcedure


OpenWindow(0,200,200,400,200,"Yo!",#PB_Window_SystemMenu)

PanelGadget(1,5,5,390,190)
AddGadgetItem(1,-1,"Panel Item 1")
ListViewGadget(2,0,0,GetPanelItemWidth(1),GetPanelItemHeight(1))
For a = 1 To 50
  AddGadgetItem(2,-1,"ListView Line "+Str(a))
Next a
AddGadgetItem(1,-1,"Panel Item 2")
ScrollAreaGadget(3,0,0,GetPanelItemWidth(1),GetPanelItemHeight(1),GetPanelItemWidth(1)-ScrollbarWidth(),50*25+10,10,#PB_ScrollArea_BorderLess)
For a = 0 To 49
  ButtonGadget(4+a,20,5+a*25,100,20,"Button "+Str(a+1))
Next a

Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow

Posted: Tue Jan 13, 2004 2:33 pm
by Berikco
Thanks, just what i needed :)

Posted: Wed Jan 14, 2004 1:02 am
by Danilo
Berikco wrote:Thanks, just what i needed :)
Better use this updated procedures:

Code: Select all

  Procedure GetPanelItemWidth(PanelGadget,Item)
    ; by Danilo, 29.12.2003
    ; returns the inner width of panel items
    tc.TC_ITEM\mask = #TCIF_PARAM
    If SendMessage_(GadgetID(PanelGadget),#TCM_GETITEM,Item,@tc)
      GetClientRect_(tc\lParam,rect.RECT)
      ProcedureReturn rect\right
    EndIf
  EndProcedure

  Procedure GetPanelItemHeight(Panelgadget,Item)
    ; by Danilo, 29.12.2003
    ; returns the inner height of panel items
    tc.TC_ITEM\mask = #TCIF_PARAM
    If SendMessage_(GadgetID(PanelGadget),#TCM_GETITEM,Item,@tc)
      GetClientRect_(tc\lParam,rect.RECT)
      ProcedureReturn rect\bottom
    EndIf
  EndProcedure
I´m using this procedures for myself in my current project
and found out later that it doesnt always work after switching
the panel tabs.
With the item/tab specified (beginning with 0), it always works.

Posted: Thu Jan 15, 2004 1:43 am
by Berikco
Danilo wrote:
Berikco wrote:Thanks, just what i needed :)
Better use this updated procedures:

I´m using this procedures for myself in my current project
and found out later that it doesnt always work after switching
the panel tabs.
With the item/tab specified (beginning with 0), it always works.
Ok, replaced the old with this new procedures.
Thanks again ;)