Refresh gadget before a delay

Just starting out? Need help? Post your questions and find answers here.
Lebostein
Addict
Addict
Posts: 807
Joined: Fri Jun 11, 2004 7:07 am

Refresh gadget before a delay

Post by Lebostein »

Code: Select all

Procedure x()
  ...
  SetGadgetText(GID_Text, "Loading...")
  LoadData() ; needs 1 or 2 Seconds
  SetGadgetText(GID_Text, "Ready")
  ...
EndProcedure
Problem: the text gadget is not updated while loading. The text "Loading..." does not appear. I can add a WindowEvent() after settext but my procedure is binded and WindowEvent() is not allowed. Any hints?
User avatar
Demivec
Addict
Addict
Posts: 4091
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Refresh gadget before a delay

Post by Demivec »

Make your x() procedure handle different parts in stages (using Select/Case to process each possible stage) with all but the first stage handled and signaled by using PostEvent() at the end of each stage (whenever you need a screen update). You can keep track of process in a structure you create in the procedure and include its address as part of the next stage's event data.

You would bind each of the sub events to the same procedure.
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Refresh gadget before a delay

Post by Dude »

Try this before LoadData():

Code: Select all

UpdateWindow_(GadgetID(GID_Text))
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: Refresh gadget before a delay

Post by Josh »

Windows only:

Try to set a DoEvents() before LoadData()

Code: Select all

Procedure DoEvents()
  Define Msg.MSG

  While PeekMessage_(Msg, 0, 0, 0, #PM_REMOVE) <> 0
    TranslateMessage_(Msg)
    DispatchMessage_(Msg)
  Wend

EndProcedure
sorry for my bad english
Post Reply