From 390711bd221841a87ed643452a34c8980e559f1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Czerpak?= Date: Wed, 18 Oct 2017 10:07:08 +0200 Subject: [PATCH] 2017-10-18 10:07 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * contrib/hbwin/hbwin.ch * contrib/hbwin/hbwin.hbx * contrib/hbwin/wapi_winuser_2.c + added PRG wrapper wapi_MessageBoxTimeout( , , , ; , , ) -> | WIN_MB_TIMEDOUT to undocumented MS-Windows function MessageBoxTimeout(). This function exists in all MS-Windows versions and is used internally by MessageBox() and MessageBoxEx() with 0xFFFFFFFF timeout. * contrib/hbwin/win_svc_2.c * src/common/hbfopen.c ! fixed POCC and XCC builds --- ChangeLog.txt | 16 +++++++++++++ contrib/hbwin/hbwin.ch | 1 + contrib/hbwin/hbwin.hbx | 1 + contrib/hbwin/wapi_winuser_2.c | 43 ++++++++++++++++++++++++++++++++++ contrib/hbwin/win_svc_2.c | 4 ++++ src/common/hbfopen.c | 2 +- 6 files changed, 66 insertions(+), 1 deletion(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 57bfeeb290..f4f7a15ba6 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -7,6 +7,22 @@ Entries may not always be in chronological/commit order. See license at the end of file. */ +2017-10-18 10:07 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * contrib/hbwin/hbwin.ch + * contrib/hbwin/hbwin.hbx + * contrib/hbwin/wapi_winuser_2.c + + added PRG wrapper + wapi_MessageBoxTimeout( , , , ; + , , ) + -> | WIN_MB_TIMEDOUT + to undocumented MS-Windows function MessageBoxTimeout(). + This function exists in all MS-Windows versions and is used internally + by MessageBox() and MessageBoxEx() with 0xFFFFFFFF timeout. + + * contrib/hbwin/win_svc_2.c + * src/common/hbfopen.c + ! fixed POCC and XCC builds + 2017-09-28 15:11 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * src/pp/ppcore.c ! fixed memory leak in unclosed extended block diff --git a/contrib/hbwin/hbwin.ch b/contrib/hbwin/hbwin.ch index 4f949c9d3c..233e626c21 100644 --- a/contrib/hbwin/hbwin.ch +++ b/contrib/hbwin/hbwin.ch @@ -720,6 +720,7 @@ #define WIN_MB_DEFMASK 0x00000F00 #define WIN_MB_MODEMASK 0x00003000 #define WIN_MB_MISCMASK 0x0000C000 +#define WIN_MB_TIMEDOUT 0x00007D00 /* win_SHFileOperation() functions */ #define WIN_FO_MOVE 0x0001 diff --git a/contrib/hbwin/hbwin.hbx b/contrib/hbwin/hbwin.hbx index a49a717bd7..fe8cff7ec0 100644 --- a/contrib/hbwin/hbwin.hbx +++ b/contrib/hbwin/hbwin.hbx @@ -137,6 +137,7 @@ DYNAMIC wapi_LoadLibrary DYNAMIC wapi_LoadMenu DYNAMIC wapi_MessageBeep DYNAMIC wapi_MessageBox +DYNAMIC wapi_MessageBoxTimeout DYNAMIC wapi_MoveToEx DYNAMIC wapi_MulDiv DYNAMIC wapi_OpenMutex diff --git a/contrib/hbwin/wapi_winuser_2.c b/contrib/hbwin/wapi_winuser_2.c index 4c16680d61..2dce154f3a 100644 --- a/contrib/hbwin/wapi_winuser_2.c +++ b/contrib/hbwin/wapi_winuser_2.c @@ -61,3 +61,46 @@ HB_FUNC( WAPI_MESSAGEBOX ) hb_strfree( hStr1 ); hb_strfree( hStr2 ); } + +static int s_MessageBoxTimeout( IN HWND hWnd, + IN LPCTSTR lpText, IN LPCTSTR lpCaption, + IN UINT uType, IN WORD wLanguageId, + IN DWORD dwMilliseconds ) +{ + /* undocumented Windows API */ + typedef int ( __stdcall * _HB_MSGBOXTOUT )( IN HWND hWnd, + IN LPCTSTR lpText, IN LPCTSTR lpCaption, + IN UINT uType, IN WORD wLanguageId, + IN DWORD dwMilliseconds ); + static _HB_MSGBOXTOUT s_pMessageBoxTimeout = ( _HB_MSGBOXTOUT ) -1; + + if( s_pMessageBoxTimeout == ( _HB_MSGBOXTOUT ) -1 ) + { + HMODULE hModule = GetModuleHandle( TEXT( "user32.dll" ) ); + s_pMessageBoxTimeout = hModule == NULL ? NULL : ( _HB_MSGBOXTOUT ) + HB_WINAPI_GETPROCADDRESST( hModule, "MessageBoxTimeout" ); + } + + return s_pMessageBoxTimeout ? + s_pMessageBoxTimeout( hWnd, lpText, lpCaption, uType, + wLanguageId, dwMilliseconds ) : + MessageBoxEx( hWnd, lpText, lpCaption, uType, wLanguageId ); +} + +HB_FUNC( WAPI_MESSAGEBOXTIMEOUT ) +{ + void * hStr1; + void * hStr2; + + int iResult = s_MessageBoxTimeout( hbwapi_par_raw_HWND( 1 ), + HB_PARSTR( 2, &hStr1, NULL ), + HB_PARSTR( 3, &hStr2, NULL ), + hbwapi_par_UINT( 4 ), + hbwapi_par_WORD( 5 ), + hbwapi_par_DWORD( 6 ) ); + + hbwapi_SetLastError( GetLastError() ); + hbwapi_ret_NI( iResult ); + hb_strfree( hStr1 ); + hb_strfree( hStr2 ); +} diff --git a/contrib/hbwin/win_svc_2.c b/contrib/hbwin/win_svc_2.c index c6c01a1313..9af144025d 100644 --- a/contrib/hbwin/win_svc_2.c +++ b/contrib/hbwin/win_svc_2.c @@ -46,6 +46,10 @@ #include "hbwapi.h" +#if defined( __POCC__ ) || defined( __XCC__ ) + #include /* it's disabled by WIN32_LEAN_AND_MEAN */ +#endif + HB_FUNC( WIN_SERVICEINSTALL ) { HB_BOOL bRetVal = HB_FALSE; diff --git a/src/common/hbfopen.c b/src/common/hbfopen.c index e39a0b3f47..4b84411f1a 100644 --- a/src/common/hbfopen.c +++ b/src/common/hbfopen.c @@ -61,7 +61,7 @@ ( defined( __WATCOMC__ ) || defined( _MSC_VER ) || \ defined( __MINGW32__ ) || defined( __BORLANDC__ ) || \ defined( __DMC__ ) ) && \ - ! defined( __MINGW32CE__ ) + ! defined( __MINGW32CE__ ) && ! defined( __POCC__ ) && ! defined( __XCC__ ) #define HB_USE_FSOPEN #include #if ! defined( SH_DENYNO ) && defined( _SH_DENYNO )