Non-blocking MessageRequester ?

Just starting out? Need help? Post your questions and find answers here.
delta69
User
User
Posts: 15
Joined: Fri Apr 25, 2003 10:56 pm

Non-blocking MessageRequester ?

Post by delta69 »

Hello,

I have a MessageRequester in a loop, and I'd like to display a warning message in the requester that don't stop the loop when waiting for user validation.

Is there a way to proceed without using a separate thread for the MessageRequester ?

Thanks for your help !

Regards.
Matt
Enthusiast
Enthusiast
Posts: 447
Joined: Sat May 21, 2005 1:08 am
Location: USA

Post by Matt »

This works nicely, but does use threads....

Code: Select all

Structure msgstruc
  title$
  message$
EndStructure

Procedure MessageBoxT(*para.msgstruc)
  MessageRequester(*para\title$, *para\message$)
  FreeMemory(*para)
EndProcedure
Procedure MessageBox(title$, message$)
  *tempstruc.msgstruc = AllocateMemory(SizeOf(msgstruc))
  *tempstruc\title$ = title$
  *tempstruc\message$ = message$
  CreateThread(@MessageBoxT(),*tempstruc)
EndProcedure

For a=1 To 3
  MessageBox("test","message!")
Next a

Delay(5000)
And then this works in Windows to allow access to the main window, rather than wait for all the message boxes to be closed:

Code: Select all

Structure msgstruc
  title$
  message$
EndStructure

Procedure MessageBoxT(*para.msgstruc)
  ;MessageRequester(*para\title$, *para\message$)
  MessageBox_(0, *para\title$, *para\message$, 0)
  FreeMemory(*para)
EndProcedure
Procedure MessageBox(title$, message$)
  *tempstruc.msgstruc = AllocateMemory(SizeOf(msgstruc))
  *tempstruc\title$ = title$
  *tempstruc\message$ = message$
  CreateThread(@MessageBoxT(),*tempstruc)
EndProcedure

For a=1 To 3
  MessageBox("test","message!")
Next a

OpenWindow(0, 0, 0, 100,100,"msgbox test")

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow

End
Why no threads?
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

MsgBox is definitely designed to block the calling thread,
because you should be able to change something before the processing continues.

dropping messages while processing normally is put into some listing gadget,
like the compiler messages downleft in the IDE.

sure it's more work, but you should program something own that is obviously different from a messagerequester...
else your customers may ask "wutufu? why does the bloody prog not stop while requester?"
oh... and have a nice day.
Matt
Enthusiast
Enthusiast
Posts: 447
Joined: Sat May 21, 2005 1:08 am
Location: USA

Post by Matt »

Yeah, it would be really simple to make a function that creates a window that looks like a message box, customized for your application, to get the job done just as Kaeru Gaman said...
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Non-blocking MessageRequester ?

Post by PB »

There's a post here (do a search) for a timed messagebox that times out
after X seconds... maybe that's what you want?
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
delta69
User
User
Posts: 15
Joined: Fri Apr 25, 2003 10:56 pm

Post by delta69 »

First of all, I'd like to thank eveybody for your help...

I was wondering if there was a "hidden" parameter for the MessageRequester allowing to do what I need. I'm #1 at reinventing the wheel coding 100's of buggy lines whereas the needed function already exists !

I had a look at MSDN's website before botehring you, but I didn't found what I was looking for. You're definitely right : This function just works as it should !

Thanks again for your help, I really appreciate. I will use Matt's code to implement my requester !

Regards.
Matt
Enthusiast
Enthusiast
Posts: 447
Joined: Sat May 21, 2005 1:08 am
Location: USA

Post by Matt »

First of all, I'd like to thank eveybody for your help...

I was wondering if there was a "hidden" parameter for the MessageRequester allowing to do what I need. I'm #1 at reinventing the wheel coding 100's of buggy lines whereas the needed function already exists !

I had a look at MSDN's website before botehring you, but I didn't found what I was looking for. You're definitely right : This function just works as it should !
Yep, I looked through the documentation as well before writing that code... as I was not able to find anything either :(
delta69 wrote: Thanks again for your help, I really appreciate. I will use Matt's code to implement my requester !
8)
Post Reply