Código: Selecionar todos
FUNCTION MsgYesNo( cText )
LOCAL lValue
lValue := wapi_MessageBox( wvgSetAppWindow():hWnd, cText, "Confirma?", MB_YESNO + MB_ICONQUESTION + MB_DEFBUTTON2 ) == IDYES
RETURN lValue
FUNCTION MsgExclamation( cText )
wapi_MessageBox( wvgSetAppWindow():hWnd, cText, "Atenci¢n!", MB_ICONASTERISK )
RETURN NIL
FUNCTION MsgWarning( cText )
wapi_MessageBox( wvgSetAppWindow():hWnd, cText, "Atenci¢n!", MB_ICONEXCLAMATION )
RETURN NIL
FUNCTION MsgStop( cText )
wapi_MessageBox( wvgSetAppWindow():hWnd, cText, "Atenci¢n!", MB_ICONHAND )
RETURN NIL
FUNCTION MSGINFO( cText, cTitle )
RETURN WAPI_MESSAGEBOX( 0, cText, cTitle, MB_ICONQUESTION )
Procedure MsgInfoTimeout( nTimeout )
Local nFlag, nMilliSeconds, nRet
nFlag := MB_OK + MB_SETFOREGROUND + MB_SYSTEMMODAL + MB_ICONINFORMATION
nMilliSeconds := nTimeout * 1000
nRet := MessageBoxTimeout ("Test a timeout of " + hb_ntos (nTimeout) + " seconds.", "MsgInfo Timeout", nFlag, nMilliSeconds)
DO CASE
CASE nRet == IDOK
MsgInfo ( "OK" , "Result" )
CASE nRet == MB_TIMEDOUT
MsgInfo ( "TimeOut in " + hb_ntos (nTimeout) + " seconds." , "Result" )
OTHERWISE
MsgInfo ( "TimeOut --> nRet = " + hb_ntos (nRet) , "Result" )
ENDCASE
Return
Procedure MsgYesNoTimeout( nTimeout )
Local nFlag, nMilliSeconds, nRet
nFlag := MB_YESNO + MB_SETFOREGROUND + MB_SYSTEMMODAL + MB_ICONQUESTION
nMilliSeconds := nTimeout * 1000
nRet := MessageBoxTimeout ("Test a timeout of " + hb_ntos (nTimeout) + " seconds.", "MsgYesNo Timeout", nFlag, nMilliSeconds)
DO CASE
CASE nRet == IDYES
MsgInfo ( "YES" , "Result" )
CASE nRet == IDNO
MsgInfo ( "NO" , "Result" )
CASE nRet == MB_TIMEDOUT
MsgInfo ( "TimeOut in " + hb_ntos (nTimeout) + " seconds." , "Result" )
OTHERWISE
MsgInfo ( "TimeOut --> nRet = " + hb_ntos (nRet) , "Result" )
ENDCASE
Return
Procedure MsgOkCancelTimeout( nTimeout )
Local nFlag, nMilliSeconds, nRet
nFlag := MB_OKCANCEL + MB_SETFOREGROUND + MB_SYSTEMMODAL + MB_ICONQUESTION
nMilliSeconds := nTimeout * 1000
nRet := MessageBoxTimeout ("Test a timeout of " + hb_ntos (nTimeout) + " seconds.", "MsgOkCancel Timeout", nFlag, nMilliSeconds)
DO CASE
CASE nRet == IDOK
MsgInfo ( "OK" , "Result" )
CASE nRet == IDCANCEL
MsgInfo ( "CANCEL" , "Result" )
CASE nRet == MB_TIMEDOUT
MsgInfo ( "TimeOut in " + hb_ntos (nTimeout) + " seconds." , "Result" )
OTHERWISE
MsgInfo ( "TimeOut --> nRet = " + hb_ntos (nRet) , "Result" )
ENDCASE
Return
#pragma BEGINDUMP
#ifdef __POCC__
#define _WIN32_WINNT 0x0500
#else
#define _WIN32_WINNT 0x0400
#endif
#include <windows.h>
#include "hbapi.h"
/*
#ifdef __XHARBOUR__
#include "hbverbld.h"
#if defined( HB_VER_CVSID ) && ( HB_VER_CVSID < 9639 )
#define HB_ISCHAR( n ) ISCHAR( n )
#endif
#if defined( HB_VER_CVSID ) && ( HB_VER_CVSID < 9798 )
#define HB_ISNIL( n ) ISNIL( n )
#endif
#endif
*/
// JK HMG 1.2 Experimental Build 16g
// MessageBoxIndirect( [hWnd], cText, [cCaption], [nStyle], [xIcon], [hInst], [nHelpId], [nProc], [nLang] )
// Contributed by Andy Wos <andywos@unwired.com.au>
HB_FUNC( MESSAGEBOXINDIRECT )
{
MSGBOXPARAMS mbp;
mbp.cbSize = sizeof( MSGBOXPARAMS );
mbp.hwndOwner = HB_ISNIL( 1 ) ? GetActiveWindow() : ( HWND ) hb_parnl( 1 );
mbp.hInstance = HB_ISNIL( 6 ) ? GetModuleHandle( NULL ) : ( HINSTANCE ) hb_parnl( 6 );
mbp.lpszText = HB_ISCHAR( 2 ) ? hb_parc( 2 ) : ( HB_ISNIL( 2 ) ? NULL : MAKEINTRESOURCE( hb_parni( 2 ) ) );
mbp.lpszCaption = HB_ISCHAR( 3 ) ? hb_parc( 3 ) : ( HB_ISNIL( 3 ) ? "" : MAKEINTRESOURCE( hb_parni( 3 ) ) );
mbp.dwStyle = ( DWORD ) hb_parni( 4 );
mbp.lpszIcon = HB_ISCHAR( 5 ) ? hb_parc( 5 ) : ( HB_ISNIL( 5 ) ? NULL : MAKEINTRESOURCE( hb_parni( 5 ) ) );
mbp.dwContextHelpId = HB_ISNIL( 7 ) ? 0 : ( DWORD ) hb_parni( 7 );
mbp.lpfnMsgBoxCallback = HB_ISNIL( 8 ) ? NULL : ( MSGBOXCALLBACK ) hb_parnl( 8 );
mbp.dwLanguageId = HB_ISNIL( 9 ) ? MAKELANGID( LANG_NEUTRAL, SUBLANG_NEUTRAL ) : ( DWORD ) hb_parni( 9 );
hb_retni( ( int ) MessageBoxIndirect( &mbp ) );
}
typedef int ( WINAPI * PMessageBoxTimeout )( HWND, LPCSTR, LPCSTR, UINT, WORD, DWORD );
static PMessageBoxTimeout pMessageBoxTimeout = NULL;
int WINAPI MessageBoxTimeout( HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType, WORD wLanguageId, DWORD dwMilliseconds )
{
if( pMessageBoxTimeout == NULL )
{
HMODULE hLib = LoadLibrary( "User32.dll" );
pMessageBoxTimeout = ( PMessageBoxTimeout ) GetProcAddress( hLib, "MessageBoxTimeoutA" );
}
if( pMessageBoxTimeout == NULL )
return FALSE;
return pMessageBoxTimeout( hWnd, lpText, lpCaption, uType, wLanguageId, dwMilliseconds );
}
// HMG_MessageBoxTimeout (Text, Caption, nTypeButton, nMilliseconds) ---> Return iRetButton
HB_FUNC( MESSAGEBOXTIMEOUT )
{
HWND hWnd = GetActiveWindow();
const char * lpText = ( const char * ) hb_parc( 1 );
const char * lpCaption = ( const char * ) hb_parc( 2 );
UINT uType = HB_ISNIL( 3 ) ? MB_OK : ( UINT ) hb_parnl( 3 );
WORD wLanguageId = MAKELANGID( LANG_NEUTRAL, SUBLANG_NEUTRAL );
DWORD dwMilliseconds = HB_ISNIL( 4 ) ? ( DWORD ) 0xFFFFFFFF : ( DWORD ) hb_parnl( 4 );
int iRet = MessageBoxTimeout( hWnd, lpText, lpCaption, uType, wLanguageId, dwMilliseconds );
hb_retni( iRet );
}
#pragma ENDDUMP

