2009-12-09 04:06 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)

* include/hbwinuni.h
    + Added HB_PARSTRDEF() macro. So far the same as HB_PARSTR(), but
      it's supposed to mark places where hb_parcx() was used (where
      WinAPI expects non-optional string parameter).

  * contrib/hbwin/wapi_winbase.c
  * contrib/hbwin/wapi_winuser.c
  * contrib/hbwin/wapi_shellapi.c
  * contrib/hbwin/legacyco.c
    + Using new UNICODE parameter passing macros instead of HB_TCHAR*() ones.
    ; NOTE: I'm unsure how to apply the same to wapi_commctrl.c, could anyone help?
            Here the string is assigned to win structure and passed to winapi,
            which may mean that string space should be kept there after
            returning from function.

  * contrib/hbxbp/xbpgeneric.prg
    ! Using HB_SYMBOL_UNUSED() to mark unused parameters, instead of
      local solution.
    % Minor optimizations.
    * MSGBOX() changed to not display all text in bold.
    + Changed <BR> to <br /> in MSGBOX().
This commit is contained in:
Viktor Szakats
2009-12-09 03:09:59 +00:00
parent c9b1bb999e
commit d7d7523ca7
7 changed files with 87 additions and 82 deletions

View File

@@ -17,6 +17,29 @@
past entries belonging to author(s): Viktor Szakats.
*/
2009-12-09 04:06 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* include/hbwinuni.h
+ Added HB_PARSTRDEF() macro. So far the same as HB_PARSTR(), but
it's supposed to mark places where hb_parcx() was used (where
WinAPI expects non-optional string parameter).
* contrib/hbwin/wapi_winbase.c
* contrib/hbwin/wapi_winuser.c
* contrib/hbwin/wapi_shellapi.c
* contrib/hbwin/legacyco.c
+ Using new UNICODE parameter passing macros instead of HB_TCHAR*() ones.
; NOTE: I'm unsure how to apply the same to wapi_commctrl.c, could anyone help?
Here the string is assigned to win structure and passed to winapi,
which may mean that string space should be kept there after
returning from function.
* contrib/hbxbp/xbpgeneric.prg
! Using HB_SYMBOL_UNUSED() to mark unused parameters, instead of
local solution.
% Minor optimizations.
* MSGBOX() changed to not display all text in bold.
+ Changed <BR> to <br /> in MSGBOX().
2009-12-08 18:27 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
* contrib/hbide/hbide.prg
* contrib/hbide/idemisc.prg

View File

@@ -112,13 +112,13 @@ HB_FUNC( WIDETOANSI )
HB_FUNC( MESSAGEBOX )
{
LPTSTR lpStr1 = HB_TCHAR_CONVTO( hb_parcx( 2 ) );
LPTSTR lpStr2 = HB_TCHAR_CONVTO( hb_parcx( 3 ) );
void * hStr1;
void * hStr2;
HWND hWnd = HB_ISNUM( 1 ) ? ( HWND ) ( HB_PTRUINT ) hb_parnint( 1 ) :
( HWND ) hb_parptr( 1 );
hb_retni( MessageBox( hWnd, lpStr1, lpStr2, hb_parni( 4 ) ) );
HB_TCHAR_FREE( lpStr1 );
HB_TCHAR_FREE( lpStr2 );
hb_retni( MessageBox( hWnd, ( LPCTSTR ) HB_PARSTR( 2, &hStr1, NULL ), ( LPCTSTR ) HB_PARSTR( 3, &hStr2, NULL ), hb_parni( 4 ) ) );
hb_strfree( hStr1 );
hb_strfree( hStr2 );
}
HB_FUNC( __OLEPDISP )

View File

@@ -68,7 +68,7 @@ HB_FUNC( WAPI_SHELLEXECUTE )
void * hDirectory;
hb_retnint( ( HB_PTRDIFF ) ShellExecute( ( HWND ) hb_parptr( 1 ),
( LPCTSTR ) HB_PARSTR( 2, &hOperation , NULL ), /* edit, explore, open, print, play?, properties? */
( LPCTSTR ) HB_PARSTRDEF( 2, &hOperation , NULL ), /* edit, explore, open, print, play?, properties? */
( LPCTSTR ) HB_PARSTR( 3, &hFile , NULL ),
( LPCTSTR ) HB_PARSTR( 4, &hParameters, NULL ),
( LPCTSTR ) HB_PARSTR( 5, &hDirectory , NULL ),

View File

@@ -53,24 +53,12 @@
#define HB_OS_WIN_USED
#include "hbapi.h"
#include "hbwinuni.h"
#include "hbwapi.h"
HB_FUNC( WAPI_GETCOMMANDLINE )
{
char * buffer = HB_TCHAR_CONVFROM( GetCommandLine() );
{
/* Convert from OS codepage */
char * pszFree = NULL;
const char * pszResult = hb_osDecodeCP( buffer, &pszFree, NULL );
if( pszFree )
hb_retc_buffer( pszFree );
else
hb_retc( pszResult );
}
HB_TCHAR_FREE( buffer );
HB_RETSTR( GetCommandLine() );
}
HB_FUNC( WAPI_GETCURRENTPROCESS )
@@ -117,11 +105,11 @@ HB_FUNC( WAPI_SETERRORMODE )
HB_FUNC( WAPI_LOADLIBRARY )
{
LPTSTR lpName = HB_TCHAR_CONVTO( hb_parcx( 1 ) );
void * hName;
hb_retptr( LoadLibrary( ( LPCTSTR ) lpName ) );
hb_retptr( LoadLibrary( ( LPCTSTR ) HB_PARSTRDEF( 1, &hName, NULL ) ) );
HB_TCHAR_FREE( lpName );
hb_strfree( hName );
}
HB_FUNC( WAPI_FREELIBRARY )
@@ -141,12 +129,11 @@ HB_FUNC( WAPI_GETPROCADDRESS )
/* HMODULE WINAPI GetModuleHandle( __in_opt LPCTSTR lpModuleName ); */
HB_FUNC( WAPI_GETMODULEHANDLE )
{
LPTSTR lpModuleName = HB_ISCHAR( 1 ) ? ( LPTSTR ) HB_TCHAR_CONVTO( hb_parc( 1 ) ) : ( LPTSTR ) NULL;
void * hModuleName;
wapi_ret_HANDLE( GetModuleHandle( lpModuleName ) );
wapi_ret_HANDLE( GetModuleHandle( ( LPCTSTR ) HB_PARSTR( 1, &hModuleName, NULL ) ) );
if( lpModuleName )
HB_TCHAR_FREE( lpModuleName );
hb_strfree( hModuleName );
}
/* VOID WINAPI Sleep( __in DWORD dwMilliseconds ); */
@@ -157,37 +144,36 @@ HB_FUNC( WAPI_SLEEP )
HB_FUNC( WAPI_OUTPUTDEBUGSTRING )
{
LPTSTR lpOutputString = HB_ISCHAR( 1 ) ? ( LPTSTR ) HB_TCHAR_CONVTO( hb_parc( 1 ) ) : ( LPTSTR ) NULL;
void * hOutputString;
OutputDebugString( lpOutputString );
OutputDebugString( ( LPCTSTR ) HB_PARSTR( 1, &hOutputString, NULL ) );
if( lpOutputString )
HB_TCHAR_FREE( lpOutputString );
hb_strfree( hOutputString );
}
HB_FUNC( WAPI_FORMATMESSAGE )
{
LPTSTR lpSource = HB_ISCHAR( 2 ) ? HB_TCHAR_CONVTO( hb_parc( 2 ) ) : NULL;
HB_SIZE nBufferLen = hb_parclen( 5 );
LPTSTR lpBuffer = nBufferLen > 0 ? ( LPTSTR ) hb_xgrab( nBufferLen * sizeof( LPTSTR ) ) : NULL;
void * hSource = NULL;
hb_retnl( FormatMessage( ( DWORD ) hb_parnldef( 1, FORMAT_MESSAGE_FROM_SYSTEM ) /* dwFlags */,
( LPCVOID ) ( HB_ISCHAR( 2 ) ? lpSource : hb_parptr( 2 ) ),
HB_ISNUM( 3 ) ? ( DWORD ) hb_parnl( 3 ) : GetLastError() /* dwMessageId */,
( DWORD ) hb_parnldef( 4, MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ) ) /* dwLanguageId */,
( LPTSTR ) lpBuffer,
( DWORD ) nBufferLen,
NULL /* TODO: Add support for this parameter. */ ) );
DWORD dwBufferLen = ( DWORD ) hb_parclen( 5 );
LPTSTR lpBuffer = dwBufferLen > 0 ? ( LPTSTR ) hb_xgrab( dwBufferLen * sizeof( LPTSTR ) ) : NULL;
DWORD dwRetVal;
hb_retnl( dwRetVal = FormatMessage( ( DWORD ) hb_parnldef( 1, FORMAT_MESSAGE_FROM_SYSTEM ) /* dwFlags */,
( LPCVOID ) ( HB_ISCHAR( 2 ) ? HB_PARSTR( 2, &hSource, NULL ) : hb_parptr( 2 ) ),
HB_ISNUM( 3 ) ? ( DWORD ) hb_parnl( 3 ) : GetLastError() /* dwMessageId */,
( DWORD ) hb_parnldef( 4, MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ) ) /* dwLanguageId */,
lpBuffer,
dwBufferLen,
NULL /* TODO: Add support for this parameter. */ ) );
if( lpBuffer )
{
char * buffer = HB_TCHAR_CONVFROM( lpBuffer );
hb_storc( buffer, 5 );
HB_TCHAR_FREE( buffer );
HB_STORSTR( dwRetVal ? lpBuffer : NULL, 5 );
hb_xfree( lpBuffer );
}
else
hb_storc( NULL, 5 );
if( lpSource )
HB_TCHAR_FREE( lpSource );
hb_strfree( hSource );
}

View File

@@ -71,22 +71,22 @@ HB_FUNC( WAPI_GETDESKTOPWINDOW )
HB_FUNC( WAPI_MESSAGEBOX )
{
LPTSTR lpStr1 = HB_TCHAR_CONVTO( hb_parcx( 2 ) );
LPTSTR lpStr2 = HB_TCHAR_CONVTO( hb_parcx( 3 ) );
hb_retni( MessageBox( ( HWND ) hb_parptr( 1 ), lpStr1, lpStr2, hb_parni( 4 ) ) );
HB_TCHAR_FREE( lpStr1 );
HB_TCHAR_FREE( lpStr2 );
void * hStr1;
void * hStr2;
hb_retni( MessageBox( ( HWND ) hb_parptr( 1 ), ( LPCTSTR ) HB_PARSTR( 2, &hStr1, NULL ), ( LPCTSTR ) HB_PARSTR( 3, &hStr2, NULL ), hb_parni( 4 ) ) );
hb_strfree( hStr1 );
hb_strfree( hStr2 );
}
HB_FUNC( WAPI_CREATEWINDOWEX )
{
LPTSTR lpStr1 = HB_TCHAR_CONVTO( hb_parcx( 2 ) );
LPTSTR lpStr2 = HB_TCHAR_CONVTO( hb_parcx( 3 ) );
void * hClassName;
void * hWindowName;
hb_retptr( CreateWindowEx(
( DWORD ) hb_parnl( 1 ) /* dwExStyle */,
( LPCTSTR ) lpStr1 /* lpClassName */,
( LPCTSTR ) lpStr2 /* lpWindowName */,
( LPCTSTR ) HB_PARSTRDEF( 2, &hClassName, NULL ),
( LPCTSTR ) HB_PARSTRDEF( 3, &hWindowName, NULL ),
HB_ISNUM( 4 ) ? ( DWORD ) hb_parnl( 4 ) : WS_OVERLAPPEDWINDOW /* dwStyle */,
HB_ISNUM( 5 ) ? ( int ) hb_parni( 5 ) : ( int ) CW_USEDEFAULT /* x */,
HB_ISNUM( 6 ) ? ( int ) hb_parni( 6 ) : ( int ) CW_USEDEFAULT /* y */,
@@ -97,8 +97,8 @@ HB_FUNC( WAPI_CREATEWINDOWEX )
( HINSTANCE ) hb_parptr( 11 ) /* hInstance */,
( LPVOID ) hb_parptr( 12 ) /* lpParam */ ) );
HB_TCHAR_FREE( lpStr1 );
HB_TCHAR_FREE( lpStr2 );
hb_strfree( hClassName );
hb_strfree( hWindowName );
}
HB_FUNC( WAPI_DESTROYWINDOW )
@@ -301,17 +301,14 @@ HB_FUNC( WAPI_SETFOCUS )
#if 0
HB_FUNC( WAPI_LOADBITMAP )
{
LPTSTR lpBmp;
if( HB_ISNUM( 2 ) )
lpBmp = ( LPTSTR ) MAKEINTRESOURCE( wapi_par_INT( 2 ) );
hb_retptr( LoadBitmap( wapi_par_HINSTANCE( 1 ), ( LPTSTR ) MAKEINTRESOURCE( wapi_par_INT( 2 ) ) ) );
else
lpBmp = ( LPTSTR ) HB_TCHAR_CONVTO( hb_parcx( 2 ) );
hb_retptr( LoadBitmap( wapi_par_HINSTANCE( 1 ), lpBmp ) );
if( ! HB_ISNUM( 2 ) )
HB_TCHAR_FREE( lpBmp );
{
void * hBmp;
hb_retptr( LoadBitmap( wapi_par_HINSTANCE( 1 ), ( LPCTSTR ) HB_PARSTRDEF( 2, &hBmp, NULL ) ) );
hb_strfree( hBmp );
}
}
#endif
/*----------------------------------------------------------------------*/

View File

@@ -133,7 +133,7 @@ FUNCTION hbxbp_InitializeEventBuffer()
IF empty( t_events )
t_events := array( EVENT_BUFFER )
aeval( t_events, {|e,i| e := e, t_events[ i ] := { 0, NIL, NIL, NIL } } )
aeval( t_events, {|e,i| HB_SYMBOL_UNUSED( e ), t_events[ i ] := { 0, NIL, NIL, NIL } } )
ENDIF
RETURN nil
@@ -143,7 +143,7 @@ FUNCTION hbxbp_InitializeEventBuffer()
FUNCTION hbxbp_ClearEventBuffer()
IF !empty( t_events )
aeval( t_events, {|e,i| e := e, t_events[ i ] := NIL } )
aeval( t_events, {|e,i| HB_SYMBOL_UNUSED( e ), t_events[ i ] := NIL } )
t_events := NIL
ENDIF
@@ -166,11 +166,10 @@ FUNCTION hbxbp_SetEventLoop( oELoop )
/*----------------------------------------------------------------------*/
FUNCTION PostAppEvent( nEvent, mp1, mp2, oXbp )
LOCAL lSuccess := .T.
SetAppEvent( nEvent, mp1, mp2, oXbp )
RETURN lSuccess
RETURN .T.
/*----------------------------------------------------------------------*/
@@ -226,9 +225,7 @@ FUNCTION AppEvent( mp1, mp2, oXbp, nTimeout )
/*----------------------------------------------------------------------*/
FUNCTION SetAppWindow( oXbp )
LOCAL oldAppWindow
oldAppWindow := t_oAppWindow
LOCAL oldAppWindow := t_oAppWindow
IF hb_isObject( oXbp )
t_oAppWindow := oXbp
@@ -270,12 +267,12 @@ FUNCTION MsgBox( cMsg, cTitle )
DEFAULT cTitle TO " "
cMsg := strtran( cMsg, chr( 13 )+chr( 10 ), "<BR>" )
cMsg := strtran( cMsg, chr( 13 ), "<BR>" )
cMsg := strtran( cMsg, chr( 10 ), "<BR>" )
cMsg := strtran( cMsg, chr( 13 ) + chr( 10 ), "<br />" )
cMsg := strtran( cMsg, chr( 13 ), "<br />" )
cMsg := strtran( cMsg, chr( 10 ), "<br />" )
oMB := QMessageBox():new()
oMB:setText( "<b>"+ cMsg +"</b>" )
oMB:setText( /* "<b>" + */ cMsg /* + "</b>" */ )
oMB:setIcon( QMessageBox_Information )
oMB:setParent( SetAppWindow():pWidget )
oMB:setWindowFlags( Qt_Dialog )

View File

@@ -61,12 +61,14 @@
#if defined( UNICODE )
#define HB_PARSTR( n, h, len ) hb_parstr_u16( n, HB_CDP_ENDIAN_NATIVE, h, len )
#define HB_RETSTR( str ) hb_retstr_u16( HB_CDP_ENDIAN_NATIVE, str )
#define HB_RETSTRLEN( str, len ) hb_retstrlen_u16( HB_CDP_ENDIAN_NATIVE, str, len )
#define HB_STORSTR( str, n ) hb_storstr_u16( HB_CDP_ENDIAN_NATIVE, str, n )
#define HB_STORSTRLEN( str, len, n ) hb_storstrlen_u16( HB_CDP_ENDIAN_NATIVE, str, len, n )
#define HB_PARSTRDEF( n, h, len ) hb_parstr_u16( n, HB_CDP_ENDIAN_NATIVE, h, len )
#define HB_RETSTR( str ) hb_retstr_u16( HB_CDP_ENDIAN_NATIVE, ( const HB_WCHAR * ) ( str ) )
#define HB_RETSTRLEN( str, len ) hb_retstrlen_u16( HB_CDP_ENDIAN_NATIVE, ( const HB_WCHAR * ) ( str ), len )
#define HB_STORSTR( str, n ) hb_storstr_u16( HB_CDP_ENDIAN_NATIVE, ( const HB_WCHAR * ) ( str ), n )
#define HB_STORSTRLEN( str, len, n ) hb_storstrlen_u16( HB_CDP_ENDIAN_NATIVE, ( const HB_WCHAR * ) ( str ), len, n )
#else
#define HB_PARSTR( n, h, len ) hb_parstr( n, hb_setGetOSCP(), h, len )
#define HB_PARSTRDEF( n, h, len ) hb_parstr( n, hb_setGetOSCP(), h, len )
#define HB_RETSTR( str ) hb_retstr( hb_setGetOSCP(), str )
#define HB_RETSTRLEN( str, len ) hb_retstrlen( hb_setGetOSCP(), str, len )
#define HB_STORSTR( str, n ) hb_storstr( hb_setGetOSCP(), str, n )