Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
USER INTERFACES >>  ASYNCHRONOUS MESSAGEBOX

  Chris Chamberlain
  Where is Chris Chamberlain?
 GL6 0PN
 United Kingdom
 Chris Chamberlain



Whilst the ubiquitous VFP MessageBox() function provides most of the functionality that the average application requires, being synchronous can prove problematical if all the developer needs it to do is pass information to a user.

An asynchronous example would be:-

WAIT WINDOW [This is for your information, etc] NOWAIT NOCLEAR

It's an alternative, but is not Windows compliant.

A synchronous example would be:-

MESSAGEBOX([This is for your information, etc],64,[Message],4000)

A top-level form that is both asynchronous and simulates the previous example is called with:-

WITH THISFORM
    DO FORM ADDBS(.cHomeFolder) ;
        + [forms\message.scx] ;
        WITH ;
        4000 ,; && Timer interval
        .Left ,; && Left
        .Top ,; && Top
        [Message] ,; && Form caption
        [This is for your information, etc] ,; && line 1
        [] ,; && line 2
        [] ,; && line 3
        [] ,; && line 4

ENDW

The .Init() event of the form resolves the issues of height, width, timeout etc and the information 'Icon' has been created from screenshots, one for Win 2K and the other for Win XP.

You may need to add

SET CURSOR OFF

in the .Init() event if there are no other VFP application forms visible and do the reverse in the .Destroy() event of the form.

You will need to configure the form to suit your own purposes, all of which can be done by passing parameters to the form, or alternatively by using object properties.

The example form accepts up to 8 parameters, only the first 5 of which are necessary for it to instantiate.

They are:-

Interval - Integer, milliseconds value for timer interval
Left - Integer, minus value means .AutoCenter = .T.
Top - Integer, minus value means .AutoCenter = .T.
Caption - Character, form caption
Line_1 - Character, line 1
Line_2 - Character, line 2
Line_3 - Character, line 3
Line_4 - Character, line 4

Where the form becomes useful is in loop processing whereby you may want to get information to the user but not wait for either user confirmation or a timeout to complete before continuing to process within the loop.

You may wish to ensure that you have only one instance of the form visible at any one time.

If so, you need to assign an object reference to the form by using the NAME clause and check its status before either closing the form and calling the form again or simply calling the form.

An example form and bitmaps can be downloaded from

http://www.pdfcommander.net/vfp/downloads/async_messagebox.zip

Suggestions as to improvements always welcome

Chris
www.pdfcommander.com
www.pdfcommander.net

FEEDBACK

Eric den Doop @ 11/19/2006 9:31:41 AM
Hi Chris,

Great to see you're using the new FAQ section!

FYI: I've added vfp tags to your code to tell the site to add syntax formatting.

I'll try to add formatting buttons to the toolbar for vfp code, bold, italic etc just like we have in the forum in a future update.

Chris Chamberlain @ 11/19/2006 9:38:18 AM
Eric

Thanks for the formatting - that will be a great help when available on the site

Chris

Eric den Doop @ 11/19/2006 8:31:05 PM
You can already add the formatting yourself. Just include the and tags, like for example:

<vfp>
messagebox("Hello World")
</vfp>
Have fun!

Chris Chamberlain @ 11/20/2006 9:32:28 AM
Great! Thanks, Eric



Your Name: 
Your Feedback: 

Spam Protection:
Enter the code shown: