===>> Is there a function like DoEvents in Visual Basi

Just starting out? Need help? Post your questions and find answers here.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
goomoo
User
User
Posts: 42
Joined: Sun Dec 05, 2004 9:25 am
Location: China
Contact:

Post by goomoo »

There is still a problem.

The WindowEvent() function eat all events that can't pass events anymore,
for example:

Code: Select all

Procedure DoEvents()
  While WindowEvent():Wend
EndProcedure

OpenWindow(1,0,0,320,240,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"asdf")
CreateGadgetList(WindowID())
ButtonGadget(1,5,5,180,25,"Click me to get a msgbox!")
ListViewGadget(2,5,35,300,200)

fileNum.l=OpenFile(#PB_Any,"filelist.txt")
aline.s=ReadString()
While aline
  AddGadgetItem(2,-1,aline)
  aline=ReadString()
  DoEvents()
Wend

Repeat
  event.l=WaitWindowEvent()
  If EventGadgetID()=1 And EventType()=#PB_EventType_LeftClick
    ; while file loading not finished,this line doesn't work 
    MessageRequester("asfsafd","asdfsadfa") 
  EndIf
Until event=#PB_Event_CloseWindow
Hello, Everyone.
Thanks for your help.
goomoo
User
User
Posts: 42
Joined: Sun Dec 05, 2004 9:25 am
Location: China
Contact:

Post by goomoo »

Or else wirte all events process in a funciton separatly,like this:

Code: Select all


Procedure processEvents(event.l)
  If EventGadgetID()=1 And EventType()=#PB_EventType_LeftClick
    MessageRequester("asfsafd","asdfsadfa") 
  EndIf
  If event=#PB_Event_CloseWindow
    End
  EndIf 
EndProcedure

OpenWindow(1,0,0,320,240,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"asdf")
CreateGadgetList(WindowID())
ButtonGadget(1,5,5,180,25,"Click me to get a msgbox!")
ListViewGadget(2,5,35,300,200)

fileNum.l=OpenFile(#PB_Any,"filelist.txt")
aline.s=ReadString()
While aline
  AddGadgetItem(2,-1,aline)
  aline=ReadString()
  processEvents(WindowEvent())
Wend
CloseFile(fileNum)

Repeat
  event.l=WaitWindowEvent()
  processEvents(event)
Until event=#PB_Event_CloseWindow
Hello, Everyone.
Thanks for your help.
User avatar
SimpleMind
Enthusiast
Enthusiast
Posts: 112
Joined: Sun May 18, 2003 12:40 pm
Location: Netherlands

Post by SimpleMind »

Me too, Freak.
Give me books, fruit, french wine, fine weather and a little music.
John Keats
Ziltch
User
User
Posts: 59
Joined: Sun Aug 03, 2003 12:05 am
Location: Australia

Post by Ziltch »

Have you tried Hiding the treegadget first?

Code: Select all

HideGadget(#Tree_Gadget, #True)

Update TreeGadget code ...

HideGadget(#Tree_Gadget, #False)
I found that most of the delay I was facing in updating TreeGadgets was in the redrawing.
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

You can put this inside your loop, it will refresh the GUI:

Code: Select all

UpdateWindow_(WindowID(#your_window_number))
Delay(1)
Post Reply