#DEFINE IDYES 6
#DEFINE IDNO 7
DO demo1
DO demo2
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
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
|
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"
_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
*====================================================
* |