Page 1 of 1

Can't ResizeGadget to variable width?

Posted: Tue Dec 27, 2016 4:17 pm
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

Re: Can't ResizeGadget to variable width?

Posted: Tue Dec 27, 2016 4:57 pm
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

Re: Can't ResizeGadget to variable width?

Posted: Tue Dec 27, 2016 5:07 pm
by ignign0kt
:oops: idk why I assumed it was global by default. Thanks