Page 1 of 1

PanelGadget resizing...

Posted: Mon Oct 12, 2009 5:00 pm
by DoubleDutch
I want to make a panel gadget that is just the size of the tabs (but multirow - not the default scroll type).

I've created this little test...

Code: Select all

#SubjectPanel=1


Procedure PanelMultiLine(Gadget,Flag)
	Style=GetWindowLong_(GadgetID(Gadget),#GWL_STYLE )
	If Flag
		Style|#TCS_MULTILINE
		Style!#TCS_SINGLELINE
	Else
		Style!#TCS_MULTILINE
		Style|#TCS_SINGLELINE
	EndIf
	SetWindowLong_(GadgetID(Gadget),#GWL_STYLE,Style)
EndProcedure

  If OpenWindow(0, 0, 0, 322, 220, "PanelGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    SubjectPanel=PanelGadget(#SubjectPanel, 8, 8, 306, 0)
    AddGadgetItem (#SubjectPanel, -1, "Panel 0")
		tabheight=GetGadgetAttribute(#SubjectPanel,#PB_Panel_TabHeight) ; returns height of the panel tabs on top of the gadget.
			PanelMultiLine(#SubjectPanel,#True)
			For loop=1 To 40
      AddGadgetItem (#SubjectPanel, -1, "Panel "+Str(loop))
      Next
      ResizeGadget(#SubjectPanel,#PB_Ignore,#PB_Ignore,#PB_Ignore,1) ; this will make the row count correct

			rows = SendMessage_(GadgetID(#SubjectPanel),#TCM_GETROWCOUNT,0,0)

			ResizeGadget(#SubjectPanel,#PB_Ignore,#PB_Ignore,#PB_Ignore,((tabheight-4)*rows)+4)

    CloseGadgetList()
    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf
I've arrived (using a bit of trial and error) that 4 seems to be a magic number - but where should this 4 come from? What is the system measurement for this 4? It seems to work for normal and xp skinned modes.

Or, is there a better way to do this?

Re: PanelGadget resizing...

Posted: Mon Oct 12, 2009 6:31 pm
by srod
Does the following work for you ?

Code: Select all

#SubjectPanel=1


Procedure PanelMultiLine(Gadget,Flag)
   Style=GetWindowLong_(GadgetID(Gadget),#GWL_STYLE )
   If Flag
      Style|#TCS_MULTILINE
      Style!#TCS_SINGLELINE
   Else
      Style!#TCS_MULTILINE
      Style|#TCS_SINGLELINE
   EndIf
   SetWindowLong_(GadgetID(Gadget),#GWL_STYLE,Style)
EndProcedure

  If OpenWindow(0, 0, 0, 322, 220, "PanelGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    SubjectPanel=PanelGadget(#SubjectPanel, 8, 8, 306, 0)
    AddGadgetItem (#SubjectPanel, -1, "Panel 0")
      tabheight=GetGadgetAttribute(#SubjectPanel,#PB_Panel_TabHeight) ; returns height of the panel tabs on top of the gadget.
         PanelMultiLine(#SubjectPanel,#True)
         For loop=1 To 40
      AddGadgetItem (#SubjectPanel, -1, "Panel "+Str(loop))
      Next
      ResizeGadget(#SubjectPanel,#PB_Ignore,#PB_Ignore,#PB_Ignore,1) ; this will make the row count correct

         SendMessage_(SubjectPanel, #TCM_GETITEMRECT, 0, rc.RECT)
         ResizeGadget(#SubjectPanel,#PB_Ignore,#PB_Ignore,#PB_Ignore,rc\bottom+1)
    CloseGadgetList()
    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf

Re: PanelGadget resizing...

Posted: Mon Oct 12, 2009 11:49 pm
by DoubleDutch
Yep.

Thanks very much. :)