Page 1 of 3

ManagedMessageBox() - RC1 released July 5

Posted: Sun Jul 02, 2006 3:50 am
by netmaestro
This is a command that gives you a standard PureBasic MessageRequester, but with some features added. You can choose the screen position, wait timeout, and button to press on expiry of the timeout. You can even change the default text on the buttons to text of your own choice. The syntax is simple:

Code: Select all

ManagedMessageBox(x, y, title$, message$, flags, waitsecs, defbutton, forcetxt$, statusmask$)


Here's a little demo to run: http://www.networkmaestro.com/test_mmb.exe

Here's the sourcecode for the demo:

Code: Select all

Declare.s GetResult(a)

;position and wait
a = ManagedMessageBox(100,100,"Position and Wait - French","Would you like to donate $100 now to Bill Gates?   ", #MB_ICONQUESTION|6, 5, 0, "Abandonner/Réessayer/Continuer", "/=")
ManagedMessageBox(0,0,"Notice","you chose "+getresult(a), 0, 1, 0, "", "/=")

; ;wait only
a = ManagedMessageBox(0,0,"Wait Only - German","How about Steve Ballmer?   ", #MB_ICONQUESTION|#MB_YESNO, 5, 1, "Ja/Nein/Abbrechen", "Choosing/in/seconds...")
ManagedMessageBox(0,0,"Notice","you chose "+getresult(a), 0, 1, 0, "", "/=")

; ;position without wait
a = ManagedMessageBox(600,200,"Position only - Spanish","George Bush? (Better take some time to think about this one)  ", #MB_ICONQUESTION|#MB_YESNOCANCEL, 0, 0, "Si/No/Cancelar", "/=")
ManagedMessageBox(0,0,"Notice","you chose "+getresult(a), 0, 1, 0, "", "/=")

End

Procedure.s GetResult(a)
  Select a
    Case 1  : a$="OK"
    Case 2  : a$="Cancel"    
    Case 3  : a$="Abort"
    Case 4  : a$="Retry"
    Case 5  : a$="Ignore"
    Case 6  : a$="Yes"
    Case 7  : a$="No"
    Case 8  : a$="Close"
    Case 9  : a$="Help"
    Case 10 : a$="Try Again"
    Case 11 : a$="Continue"
  EndSelect
  ProcedureReturn a$
EndProcedure
and finally, if you'd like to use this command in your projects, here's the library:

http://www.networkmaestro.com/ManagedMessageBox.zip

**new** http://www.networkmaestro.com/ManagedMessageBox394.zip

It's a standard PB messagerequester in every way, I'm just playing a few tricks on it. So all the information in the PB docs regarding MessageRequester() are valid for this version as well. There is one small difference, though. All ManagedMessageBox's are HWND_TOPMOST. Sticky fellows.

I gratefully accepted some event-management help from srod on this one.

Posted: Sun Jul 02, 2006 4:14 am
by White Eagle
For 3.94 or 4.0?

Posted: Sun Jul 02, 2006 6:14 am
by netmaestro
4.0 only for now, but if there's a demand I can make a version for 3.94, I think. It's mostly API, so it shouldn' present a problem.

Posted: Sun Jul 02, 2006 6:17 am
by White Eagle
There probably won't be a demand. It seems I am the only person still using 3.94 :cry:

Posted: Sun Jul 02, 2006 6:47 am
by mskuma
Cool. Since the countdown message is hardcoded in English, this might limit its usefulness for some people, so I'd suggest an optional parameter to let the programmer specify a custom string in another language.

Posted: Sun Jul 02, 2006 8:55 am
by netmaestro
Thanks, yes the opportunity to create your own status string is a good idea. I'll look at it tomorrow.

As is usually the case, first few downloaders should redownload now as I've fixed a couple of issues. At this point it seems pretty solid to me, but if anyone notices an unexpected or bad behaviour, please let me know.

Posted: Sun Jul 02, 2006 9:46 am
by blueznl
hey eagle, don't worry, still doing two projects in 3.94 :-)

Posted: Sun Jul 02, 2006 9:52 am
by DarkDragon
White Eagle wrote:There probably won't be a demand. It seems I am the only person still using 3.94 :cry:
I am still using it, because I can't use PB 4 for that now(ok I could, but it would cause too much errors).

Posted: Sun Jul 02, 2006 11:03 am
by Flype
same here.

i have still 3 'big' apps in 3.94
and 3 'big' new apps in 4.0.

at work, it's 50/50.
at home it's 100% 4.0 :wink:



Well Done netmaestro ! it's useful !

Posted: Mon Jul 03, 2006 5:46 am
by netmaestro
Thanks Flype, I'm a fan of your work too!

- 3.94 version completed, link added to first post

Posted: Mon Jul 03, 2006 6:36 am
by netmaestro
Sorry! Fixed mistake in 3.94 version, please re-download.

Posted: Mon Jul 03, 2006 10:24 am
by mskuma
netmaestro wrote:the opportunity to create your own status string is a good idea. I'll look at it tomorrow
As a suggestion, maybe use a substitution character for the actual number e.g. "Taking "$" in % seconds"
where $ & % are the substitutions for the button & countdown respectively. All other chars are the programmer's language-specific string to appear during the countdown.

I've noticed your related post in the off-topic section. Is it possible to the programmer specify the button states as parameters, and perhaps the nominated timeout button can be specified by a button number from left (starting with 0) to right (n, i.e. last number)? Just a suggestion.

Posted: Mon Jul 03, 2006 4:07 pm
by Intrigued
I would suggest that we can change the "Giving up in X seconds" bit to something of our choosing as well.

Thanks for sharing nonetheless.

Posted: Mon Jul 03, 2006 5:27 pm
by netmaestro
Yes, that is a good idea and the upcoming version will have a fully customizable status string.

Posted: Tue Jul 04, 2006 4:58 pm
by netmaestro
A new version is available. It provides full language support and control over the button texts and the status string for wait times. Latest versions of 4.0 and 3.94 libs are available in the first post, and an updated help file is included to show how to use the new features. Any problems let me know please.

PS: My server is up today but we are experiencing heavy thunderstorms so getting a live download could be a bit hit-or-miss.