Using Win32 functions in Visual FoxPro Image Gallery
Dialog Box
Code examples:
How to change the name and the size of the font in the MessageBox dialog
How to display a user-defined icon in the MessageBox dialog
Using the MessageBox Win32 function
    Add comment     W32 Constants      Translate this page
Creates, displays, and operates a message box. The message box contains an application-defined message and title, plus any combination of predefined icons and push buttons
Code examples:
How to change the name and the size of the font in the MessageBox dialog
How to display a user-defined icon in the MessageBox dialog
Using the MessageBox Win32 function
int MessageBox(
  HWND hWnd,          // handle to owner window
  LPCTSTR lpText,     // text in message box
  LPCTSTR lpCaption,  // message box title
  UINT uType          // message box style
FoxPro declaration:
DECLARE INTEGER MessageBox IN user32 As MessageBoxA;
    INTEGER hwnd,;
    STRING  lpText,;
    STRING  lpCaption,;
    INTEGER wType
[in] Handle to the owner window of the message box to be created

[in] Pointer to a null-terminated string that contains the message to be displayed

[in] Pointer to a null-terminated string that contains the dialog box title

[in] Specifies the contents and behavior of the dialog box. This parameter can be a combination of flags
Return value:
If the function succeeds, the return value is one of the predefined menu-item values
#DEFINE MB_RIGHT 0x00080000

DECLARE INTEGER MessageBoxW IN user32 As MessageBoxAPI;
    INTEGER hWindow, STRING lpText,;
    STRING lpCaption, LONG uType

LOCAL cMessage, cCaption, nDlgType
Adding two right-to-left marks (RLMs), represented by Unicode 
formatting character U+200F, in the beginning of a MessageBox 
display string is interpreted by the Win32 MessageBox rendering 
engine so as to cause the reading order of the MessageBox to be 
rendered as right-to-left (RTL).

* Right-to-left mark
* CHR(0x0f) + CHR(0x20) +;
* CHR(0x0f) + CHR(0x20)

cMessage = ToUnicode( m.cMessage )
cCaption = ToUnicode( VERSION() )


= MessageBoxAPI(_screen.HWnd, m.cMessage, m.cCaption, m.nDlgType)

FUNCTION ToUnicode(cStr As String) As String
My comment:
See also: MessageBoxIndirect, TaskDialog, TaskDialogIndirect, SetWindowsHookEx

Right-to-left MessageBox (see Usage code above):

* * *
Click on the picture below to download
Extended MessageBox library (FLL) for Visual FoxPro.

Download MsgBox FLL

* * *
The Visual FoxPro contains a limited edition of this function, which is implemented via MESSAGEBOX() function. In most of the cases that is enough. Through the Win32 function you can reach all functionality of this dialog box.

The VFP, up to the version 6, gives an access to three groups of constants defining the contents and behavior of this object. There are several more groups (see the examples), which could be helpful.

For example, you can create a message box, which is placed on top of all open windows, not only the FoxPro Main window. Some other combinations of constants can give even more functionality, just try.

* * *
Another application of this function you might be interested in is to invoke a dailog in Automation Servers (EXE, DLL or MTDLL) created with Visual FoxPro. Built-in MessageBox generates an error (or at least fails to appear) while the API version of this function works Ok.

* * *
There are so many interfaces to this simple function from various programming languages. Here is another one from the Windows Scripting with the Timeout parameter puzzlingly positioned at the second place:

object.Popup (Message [, TimeOut][, Title] [, Format])

WshShell = CREATEOBJECT("WScript.Shell")
Result = WshShell.Popup("This is a popup box!", 10, "Title", 65)
? Result

* * *
An enhancement in the MessageBox implementation in Vista: the OS wraps long messages maintaining a reasonable width of the dialog window.

* * *
The SetWindowsHookEx, while virtually useless in pure VFP code, can easily be utillized in Visual FoxPro via creating a FLL or DLL library.

For example, provided a certain windows hook set, each following MESSAGEBOX() dialog within current VFP session would appear not centered but instead would automatically position itself at the specified screen location.

Word Index links for the MessageBox :
Translate this page:
  Spanish    Portuguese    German    French    Italian offers instant, free translations of text or web pages.
Created: 2001-07-18 12:00:00
Modified: 2010-04-09 12:19:13
Visited in last 7 days: 28
User Contributed Notes:
There are no notes on this subject.

Copyright 2001-2017 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.6.37), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
Last Topics Visited (
7 sec.Function: 'IsPwrSuspendAllowed'
14 sec.Function: 'WriteProcessMemory'
20 sec.Function: 'SHGetFileInfo'
27 sec.Function: 'SHGetFolderPath'
33 sec.Function: 'IsWellKnownSid'
41 sec.Function: 'WinHttpOpen'
48 sec.Function: 'GdipGetSmoothingMode'
55 sec.
Function group: 'GDI+ StringFormat'
1.02 min.Function: 'waveOutUnprepareHeader'
1.12 min.Function: 'SetLastError'
Advertise here!