// By master Navarro
#include "fivewin.ch"
/* // duplicate? Porque?
#define MB_USERICON 128
#define MB_ICONASTERISK 64
#define MB_ICONEXCLAMATION 0x30
#define MB_ICONWARNING 0x30
#define MB_ICONERROR 16
#define MB_ICONHAND 16
#define MB_ICONQUESTION 32
#define MB_OK 0
#define MB_ABORTRETRYIGNORE 2
#define MB_APPLMODAL 0
#define MB_DEFAULT_DESKTOP_ONLY 0x20000
#define MB_HELP 0x4000
#define MB_RIGHT 0x80000
#define MB_RTLREADING 0x100000
#define MB_DEFBUTTON1 0
#define MB_DEFBUTTON2 256
#define MB_DEFBUTTON3 512
#define MB_DEFBUTTON4 0x300
#define MB_ICONINFORMATION 64
#define MB_ICONSTOP 16
#define MB_OKCANCEL 1
#define MB_RETRYCANCEL 5
*/
#define MB_SETFOREGROUND 0x10000
//duplicate? porque?
//#define MB_SYSTEMMODAL 4096
//#define MB_TASKMODAL 0x2000
//#define MB_YESNO 4
//#define MB_YESNOCANCEL 3
//#define MB_ICONMASK 240
//#define MB_DEFMASK 3840
//#define MB_MODEMASK 0x00003000
//#define MB_MISCMASK 0x0000C000
//#define MB_NOFOCUS 0x00008000
//#define MB_TYPEMASK 15
//#define MB_TOPMOST 0x40000
//#define MB_CANCELTRYCONTINUE 6
/* // duplicate? porque?
#define IDOK 1
#define IDCANCEL 2
#define IDABORT 3
#define IDRETRY 4
#define IDIGNORE 5
#define IDYES 6
#define IDNO 7
#define IDCLOSE 8
#define IDHELP 9
#define IDTRYAGAIN 10
#define IDCONTINUE 11
*/
#define MB_TIMEDOUT 32000
FUNCTION Main()
MsgInfoTimeout( 3 )
MsgYesNoTimeout( 5 )
MsgOkCancelTimeout( 5 )
RETURN NIL
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
Regards, saludos.