Can't ResizeGadget to variable width?

Just starting out? Need help? Post your questions and find answers here.
ignign0kt
User
User
Posts: 59
Joined: Thu Sep 21, 2006 9:09 pm

Can't ResizeGadget to variable width?

Post by ignign0kt »

I was just trying to see if I could resize a textgadget using a variable width, but I must be missing something here, because it's not working.
What am I not doing right?

Code: Select all

Global Window_1

Global Text_0

Enumeration
  #Font_0
EndEnumeration

LoadFont(#Font_0,"Arial", 40)

str$ = "TESTING"
strLength.i = Len(str$)

Procedure OpenWindow_1(x = 0, y = 0, width = 750, height = 260)
  Window_1 = OpenWindow(#PB_Any, x, y, width, height, "", #PB_Window_SystemMenu)
  Text_0 = TextGadget(#PB_Any, 110, 70, 50, 80, "")
  
  SetGadgetText(Text_0, str$)
  SetGadgetFont(Text_0, FontID(#Font_0))
  
  ResizeGadget(Text_0, #PB_Ignore, #PB_Ignore, strLength*50, #PB_Ignore)
EndProcedure

Procedure Window_1_Events(event)
  Select event
    Case #PB_Event_CloseWindow
      ProcedureReturn #False

    Case #PB_Event_Menu
      Select EventMenu()
      EndSelect

    Case #PB_Event_Gadget
      Select EventGadget()
      EndSelect
  EndSelect
  ProcedureReturn #True
EndProcedure

OpenWindow_1()

Repeat
  event = WaitWindowEvent()
Until Window_1_Events(event) = #False
infratec
Always Here
Always Here
Posts: 7577
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Can't ResizeGadget to variable width?

Post by infratec »

Hi,

the variable strLength is 0.
Since you don't use Global to define it.
So inside the procedure it is 0.

Use always EnableExplicit at top of the code, then you see such 'bugs'.

Bernd
ignign0kt
User
User
Posts: 59
Joined: Thu Sep 21, 2006 9:09 pm

Re: Can't ResizeGadget to variable width?

Post by ignign0kt »

:oops: idk why I assumed it was global by default. Thanks
Post Reply