Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Asynchronous MESSAGEBOX

Forms

Asynchronous MESSAGEBOX

by  ChrisRChamberlain  Posted    (Edited  )
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:
[color blue]WAIT WINDOW [This is for your information, etc] NOWAIT NOCLEAR[/color]
provides an alternative, but is not Windows compliant.

A synchronous example would be:-
Code:
[color blue]MESSAGEBOX([This is for your information, etc],64,[Message],4000)[/color]

A top-level form that is both asynchronous and simulates the previous example is called with:-
Code:
[color blue]
WITH THISFORM
[tab]DO FORM ADDBS(.cHomeFolder) ;
[tab][tab]+ [forms\message.scx] ;
[tab][tab]WITH ;
[tab][tab]4000 ,;[color green] && Timer interval[/color]
[tab][tab].Left ,;[color green] && Left[/color]
[tab][tab].Top ,;[color green] && Top[/color]
[tab][tab][Message] ,;[color green] && Form caption[/color]
[tab][tab][This is for your information, etc] ,;[color green] && line 1[/color]
[tab][tab][] ,;[color green] && line 2[/color]
[tab][tab][] ,;[color green] && line 3[/color]
[tab][tab][] ,;[color green] && line 4[/color]

ENDW
[/color]
[img http://www.pdfcommander.net/images/message.bmp]​

The [color blue].Init()[/color] 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:
[color blue]SET CURSOR OFF[/color]
in the [color blue].Init()[/color] event if there are no other VFP application forms visible and do the reverse in the [color blue].Destroy()[/color] 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 [color blue]NAME[/color] 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]
[link http://www.pdfcommander.net]PDFcommander[sup]tm[/sup].net[/link]
[link http://www.pdfcommander.net]PDFcommander[sup]tm[/sup].com[/link]
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top