Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
GDI+: copying to the Clipboard (a) image of active FoxPro window/form, (b) image file
How to change display settings: screen resolution, screen refresh rate
Adding and deleting Scheduled Tasks using NetScheduleJob API functions
GetFileOwner - Get the owner of an NTFS file
Using Video Capture: displaying on FoxPro form frames and previewing video obtained from a digital camera
Capturing keyboard activity of another application with the Raw Input API (VFP9)
How to retrieve information about a cache entry (Internet Explorer)
Custom GDI+ class
How to display Windows On-Screen Keyboard
Winsock: sending email messages (SMTP, port 25)
Mapping and disconnecting network drives
Windows Shell Icons displayed and exported to ICO files (Vista)
How to convert a bitmap file to monochrome format (1 bpp)
Custom HttpRequest class (WinHTTP)
Transparent Menu Class (requires VFP9)
Enumerating raw input devices attached to the system (keyboard, mouse, human interface device)
Using EnumPrinters function to enumerate locally installed printers
Displaying icons in the system tray (VFP9)
GDI+: Implementing image scrolling with inertia
How to create MD-5 and SHA-1 hash values from a string
How to detect if additional monitor is connected and active
HOWTO: Use the Win32 API to Access File Dates and Times
Using WM_COPYDATA for interprocess communication (VFP9)
Enumerating printer drivers installed
Using Extended MessageBox() Class

User rating: 10/10 (1 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
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:
#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



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: 74  
Listed functions:
Printer friendly API declarations
My comment:
Even better MessageBox customization can be achieved by creating an external library (ActiveX, DLL or FLL) and calling it from VFP application.
Download MsgBox FLL
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
*====================================================
*
Word Index links for this example:
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.


Copyright 2001-2014 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), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
Last Topics Visited (54.211.219.68)
58 sec.Function: 'GetMonitorContrast'
2.45 min.Function: 'NetMessageNameDel'
Function group: 'Network Management'
12.25 min.Example: 'GDI+: how to make VFP controls visually shake and shudder'
1 day(s)Example: 'Displaying bitmap using the AlphaBlend function'
 Example: 'How to prevent users from accessing the Windows Desktop and from switching to other applications'
 Example: 'Winsock: reading email messages (POP3, port 110)'
 Example: 'Using FrameRgn for displaying system colors'
 Function: 'getnameinfo'
Function group: 'Windows Sockets 2 (Winsock)'
2 day(s)Example: 'How to generate GUID values'
 Function: 'GetMonitorContrast'
Google
Advertise here!