PanelGadget resizing...

Windows specific forum
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

PanelGadget resizing...

Post 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?
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: PanelGadget resizing...

Post 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
I may look like a mule, but I'm not a complete ass.
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Re: PanelGadget resizing...

Post by DoubleDutch »

Yep.

Thanks very much. :)
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
Post Reply