Sie sind auf Seite 1von 3

Using Extended MessageBox() Class -- Visual FoxPro : Using Win32 (...

http://www.news2news.com/vfp/?example=424&PHPSESSID=f5a5a98...

Using Win32 functions in Visual FoxPro


functions examples solutions solutions updates about functions examples updates links home articles

Image Gallery
5.08 min.

Last Topics Visited (75.74.254.123)

Sign Up for the Membership and obtain access to advanced code samples.---------login

Function: 'GetPrinter' Example: 'How to position the GETPRINTER() dialog'

Code examples:
How to change display settings: screen resolution, screen refresh rate How to register custom Event Log source Winsock: sending email messages (SMTP, port 25) Custom GDI+ class How to convert a bitmap file to monochrome format (1 bpp) Using FoxTray ActiveX control: System Tray Icon and menu attached to VFP form Custom HttpRequest class (WinHTTP) Capturing keyboard activity of another application with the Raw Input API (VFP9) Mapping and disconnecting network drives Sending email messages with Simple MAPI Enumerating servers of the specified type (e.g. SQL Server) in the primary domain Converting Unicode data from the Clipboard to a character string using a given code page Printing Image File, programmatically set print page orientation to landscape Custom HttpRequest class (WinINet) Custom FTP Class for Visual FoxPro application How to adjust monitor brightness (Vista, monitor with DDC support) Windows Shell Icons displayed and exported to ICO files (Vista) Printing text with the Escape function How to activate Windows Calculator How to ping a remote site using ICMP API calls Reading and setting explicit Application User Model ID for the current process (Win7) How to detect if additional monitor is connected and active Using EnumPrinters function to enumerate locally installed printers How to change the name and the size of the font in the MessageBox dialog

Using Extended MessageBox() Class


User rating: 10/10 (1 votes) Rate this code sample: More code examples this page Listed functions Add comment W32 Constants Translate

5.13 min.

More last topics visited ...

Before you begin:

There is more advanced version of this code. Click to open the Extended MessageBox Library (FLL) web page. *** The source code for the class: Extended MessageBox() Class. For all VFP versions this class extends regular MessageBox() function with: - dialog timeout interval - adjustable button captions - dialog window positioning on start MessageBox() with changed button captions:

MessageBox() with timeout:

See also: How to position the GETPRINTER() dialog Extended MessageBox Class How to change font name and size in the MessageBox dialog Creating an Open dialog box to specify the drive, directory, and name of a file to open (Shell32 version) Creating the Open dialog box to specify the drive, directory, and name of a file to open Creating the Save dialog box to specify the drive, directory, and name of a file to save How to display a dialog box that enables the user to select a folder (an alternative to the GETDIR)

#DEFINE IDYES #DEFINE IDNO DO demo1 DO demo2

6 7

Other pages with examples: >> [1] 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

PROCEDURE demo1 IF VARTYPE(_screen.msgboxtimer) <> "U" _SCREEN.RemoveObject("msgboxtimer") ENDIF _SCREEN.AddObject("msgboxtimer", "Tmsgbox") WITH _SCREEN.msgboxtimer .X=100 .Y=100 .captions[6] = "I like it" .captions[7] = "Not really" .captions[2] = "Dont care" ? .MsgBox("How do you like extended MessageBox? 32+3, "MessageBox") ENDWITH

",;

1 of 3

9/25/2013 4:32 PM

Using Extended MessageBox() Class -- Visual FoxPro : Using Win32 (...

http://www.news2news.com/vfp/?example=424&PHPSESSID=f5a5a98...

PROCEDURE demo2 IF VARTYPE(_screen.msgboxtimer) <> "U" _SCREEN.RemoveObject("msgboxtimer") ENDIF _SCREEN.AddObject("msgboxtimer", "Tmsgbox") WITH _SCREEN.msgboxtimer ? .MsgBox("Press either or within 5 seconds. 32+4, "MessageBox with timeout", 5000, IDNO) ENDWITH

",;

User rating: 10/10 (1 votes) Rate this code sample:

752 bytes Created: 2003-10-17 13:48:15 Modified: 2011-12-10 09:20:22 Visits in 7 days: 103

Listed functions:

My comment:
Even better MessageBox customization can be achieved by creating an external library (ActiveX, DLL or FLL) and calling it from VFP application.

The background color, the message text font & color, button fonts and captions, not to mention other customizable parameters, can be controlled by the calling application. *** This is a wrapper for the class created by Ray Roper: *=================================================== * Function...: XMessageBox * Author.....: Ray Roper * Date.......: January 13, 2006 * Notice.....: Copyright (c) , NovaSoft Solutions * ...........: All Rights Reserved. * Abstract...: Extended MessageBox function wrapper * Called From: Anywhere * Parameters : * tcMsg = Message displayed * tnType = dialog type; as in MB_ICONQUESTION + MB_YESNO * tcTitle = dialog title * tnTimeOut = time out in milliseconds * tnDefault = default button ID, (as in IDNO = 7; * not same as MESSAGEBOX) * taCaps = array of button captions by button type ID: * #DEFINE IDOK 1 && OK button caption array index * #DEFINE IDCANCEL 2 && Cancel button caption array index * #DEFINE IDABORT 3 && Abort button caption array index * #DEFINE IDRETRY 4 && Retry button caption array index * #DEFINE IDIGNORE 5 && Ignore button caption array index * #DEFINE IDYES 6 && Yes button caption array index * #DEFINE IDNO 7 && No button caption array index * tnX = X coordinate of dialog _screen postion in pixels; * if zero defaults to center * tnY = Y coordinate of dialog _screen postion in pixels; * if zero defaults to center *=================================================== * FUNCTION XMessageBox * *- MsgBox(cMsg, nType, cTitle, nTimeout, nDefault) LPARAMETERS tcMsg,tnType,tcTitle,; tnTimeOut,tnDefault,taCaps,tnX,tnY * EXTERNAL ARRAY taCaps * LOCAL ; lnReturn,; lnCap * IF VARTYPE(_screen.msgboxtimer) <> "U"

2 of 3

9/25/2013 4:32 PM

Using Extended MessageBox() Class -- Visual FoxPro : Using Win32 (...

http://www.news2news.com/vfp/?example=424&PHPSESSID=f5a5a98...

_screen.RemoveObject("msgboxtimer") ENDIF _screen.AddObject("msgboxtimer","Tmsgbox") WITH _screen.msgboxtimer .X = IIF(!EMPTY(tnX),tnX,0) .Y = IIF(!EMPTY(tnY),tnY,0) FOR lnCap = 1 TO 7 .captions[lnCap] = taCaps[lnCap] ENDFOR lnReturn = .MsgBox(tcMsg,tnType,tcTitle,; tnTimeOut,tnDefault) ENDWITH RETURN lnReturn * *==================================================== * End: XMessageBox *==================================================== *

Word Index links for this example:


dialog box Icon ActiveX background color Open Dialog Box name of a file to save Save dialog box name of a file to open

Translate this page:


Spanish Portuguese German French Italian

FreeTranslation.com offers instant, free translations of text or web pages.

User Contributed Notes:


There are no notes on this subject. Log in to post a comment

functions examples solutions updates about

links

articles

login

Copyright 2001-2013 News2News, Inc. Before reproducing or distributing any data from this site please ask for an approval from its owner. Unless otherwise specified, this page is for your personal and non-commercial use. The information on this page is presented AS IS, meaning that you may use it at your own risk. Microsoft Visual FoxPro and Windows are trade marks of Microsoft Corp. All other trademarks are the property of their respective owners. Privacy policy Credits: PHP (4.4.9), an HTML-embedded scripting language, MySQL (5.1.68-log), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice. Hosted by Korax Online Inc.

Advertise here!

3 of 3

9/25/2013 4:32 PM

Das könnte Ihnen auch gefallen