Using Win32 functions in Visual FoxPro Image Gallery
Dialog Box
..msdn
GetDlgCtrlID
GetDlgItem
MessageBox
MessageBoxIndirect
SetDlgItemInt
SetDlgItemText
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
MessageBox
    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 display a user-defined icon in the MessageBox dialog
How to change the name and the size of the font in the MessageBox dialog
Using the MessageBox Win32 function
Declaration:
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
Parameters:
hWnd
[in] Handle to the owner window of the message box to be created

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

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

uType
[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
Usage:
#DEFINE MB_RTLREADING 0x00100000
#DEFINE MB_RIGHT 0x00080000

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

LOCAL cMessage, cCaption, nDlgType
TEXT TO cMessage NOSHOW PRETEXT 4
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).
ENDTEXT

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

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

nDlgType = BITOR(MB_RTLREADING, MB_RIGHT, 64)
*nDlgType = BITOR(MB_RTLREADING, 64)

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

FUNCTION ToUnicode(cStr As String) As String
RETURN STRCONV(m.cStr+CHR(0), 5)
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:

Usage:
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  
FreeTranslation.com 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: 45
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.38), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
Last Topics Visited (54.91.38.173)
8 sec.Function: 'WinHttpOpenRequest'
17 sec.Function: 'GetKBCodePage'
25 sec.Function: 'SetConsoleTextAttribute'
34 sec.Function: 'GetIpStatistics'
42 sec.
50 sec.Example: 'Locking mouse and keyboard input for the VFP application'
1.02 min.Function: 'GetTcpStatistics'
1.15 min.Function: 'ScreenToClient'
1.32 min.Function: 'GetComputerName'
1.47 min.Function: 'MAPISendMail'
Google
Advertise here!