INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Forms

Asynchronous MESSAGEBOX by ChrisRChamberlain
Posted: 30 Jan 06 (Edited 6 Feb 06)

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

CODE

WAIT WINDOW [This is for your information, etc] NOWAIT NOCLEAR
provides an alternative, but is not Windows compliant.

A synchronous example would be:-

CODE

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:-

CODE


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

CODE

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 smile

Chris pc2
PDFcommandertm.net
PDFcommandertm.com

Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close