StringGadget updating dependant on WaitWindowEvent()

Everything else that doesn't fall into one of the other PB categories.
halo
Enthusiast
Enthusiast
Posts: 104
Joined: Mon Jan 26, 2004 2:49 am

StringGadget updating dependant on WaitWindowEvent()

Post by halo »

I have a problem.

I am writing a DLL that controls a properties window for the main application. When the properties window is open, the user can still click and select things in the main window.

The problem is that string gadget text only gets updated if you use a WaitWindowEvent() command. However, if you use this command, it will freeze the program when you are trying to click on things in the main window. There doesn't seem to be any event for when you change the focus, so even though the properties window is not the active window, it still hangs until another event occurs.

The logical thing to do would be to use a WindowEvent() loop instead of WaitWindowEvent(). However, the string gadgets are totally unresponsive under these conditions.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: StringGadget updating dependant on WaitWindowEvent()

Post by PB »

> The logical thing to do would be to use a WindowEvent() loop instead of
> WaitWindowEvent(). However, the string gadgets are totally unresponsive
> under these conditions.

Without seeing your code, this may be due to the CPU being 100% used
during the WindowEvent() loop. Try sticking Delay(1) in the loop like so:

Code: Select all

ev=WindowEvent() : if ev=0 : Delay(1) : EndIf ; Release CPU when app is idle.
halo
Enthusiast
Enthusiast
Posts: 104
Joined: Mon Jan 26, 2004 2:49 am

Post by halo »

I fixed this by using a callback function. If the window gets a close event, a global variable is set. I then have a function that returns true if the window has been closed. You can just call the "Has the window been closed" function at any time, instead of trying to intercept the event.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

Okay, I misunderstood what the problem was. :)
Post Reply