Gadget number too large error

Just starting out? Need help? Post your questions and find answers here.
Allen
User
User
Posts: 92
Joined: Wed Nov 10, 2021 2:05 am

Gadget number too large error

Post by Allen »

Hi,

I got an gadget number too large error at line 26 in below code. If I use line 14 an 15 (instaed of 15 and 26). It work OK. Any idea?
6.01 x64 win 10, both CBE and ASM BE.

Code: Select all

Procedure TimeOut(DurationSec.i)
  Protected.s Message$="Time remaining  : "
  Protected.s Button$= "Push this button to ABORT"
  Protected.i Main,Message,Abort,TimeWinTimer,EditorFont,Event
  
  Enumeration
    #Message
  EndEnumeration
  
  EditorFont=LoadFont(#PB_Any, "SimHei",16);,#PB_Font_Bold)
  SetGadgetFont(#PB_Default, FontID(EditorFont))
  Main=OpenWindow(#PB_Any, 0, 0, 500, 250, "Message",  #PB_Window_MinimizeGadget| #PB_Window_ScreenCentered )

  ;TextGadget(#Message, 20, 20, 400, 200,Message$+Str(DurationSec)); ------------This line works OK
  Message=TextGadget(#PB_Any, 20, 20, 400, 200,Message$+Str(DurationSec)); ------------This line  does not work
  Abort=ButtonGadget(#PB_Any,100,150, 300, 30, Button$)
  If DurationSec>0
    TimeWinTimer=AddWindowTimer(Main, #PB_Any, 1000) ; 
  EndIf

  Repeat                          
    event = WaitWindowEvent(20)
    If Event = #PB_Event_Timer 
      DurationSec-1
      ;TextGadget(#Message, 20, 20, 400, 200,Message$+Str(DurationSec)); ------------This line works OK
      TextGadget(Message, 20, 20, 400, 200,Message$+Str(DurationSec)); ------------This line  does not work
      If DurationSec<=0
        MessageRequester("Info","Time Out")
      EndIf
    EndIf  
    If (EventGadget()=Abort ) 
      CloseWindow(Main)
      ProcedureReturn
    EndIf  
  Until event = #PB_Event_CloseWindow
  CloseWindow(Main)
EndProcedure

TimeOut(15)
If I change Line 26 to

Code: Select all

SetGadgetText(Message,Message$+Str(DurationSec))
The Button does not shown.

Thanks

Allen
Last edited by Allen on Fri Mar 31, 2023 9:26 am, edited 1 time in total.
Fred
Administrator
Administrator
Posts: 16619
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Gadget number too large error

Post by Fred »

You can't use the result of #PB_Any to create again an object with this id.
Allen
User
User
Posts: 92
Joined: Wed Nov 10, 2021 2:05 am

Re: Gadget number too large error

Post by Allen »

Fred,

Thanks.

I find my mistake. I should use "SetGadgetText(Message,Message$+Str(DurationSec))". I set the text gadet size too large that it covers the Button gadget.

Allen
Post Reply