From 41979f5b609300f47f2754d13258625b61ae68fa Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 17 Jun 2009 06:34:57 +0000 Subject: [PATCH] 2009-06-17 08:33 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * utils/hbmk2/hbmk2.prg + Added support for rest of embedded compiler installations: pocc64, poccarm, dos/watcom. Since these share a common install kit with other targets, they can only be selected using -comp= switch and in this case they will be used if the installation is present. * contrib/hbwin/win_misc.c + Added support for embedded Chr(0) to WIN_ANSITOWIDE() and WIN_WIDETOANSI(). ! Fixed WIN_ANSITOWIDE(). Dunno when it worked the last time, but it must be long ago (SysStringLen() was returning zero). * contrib/hbwin/Makefile * contrib/hbwin/win_misc.c + contrib/hbwin/wapi_shellapi.c * Moved and renamed WIN_SHELLEXECUTE() to WAPI_SHELLEXECUTE() since this implementation is a full wrapper of original Windows API. Incompatible. Please update your sources. * contrib/hbwin/legacyco.c * Formatting. --- harbour/ChangeLog | 38 +++++++++--- harbour/contrib/hbwin/Makefile | 1 + harbour/contrib/hbwin/legacyco.c | 2 +- harbour/contrib/hbwin/wapi_shellapi.c | 86 +++++++++++++++++++++++++++ harbour/contrib/hbwin/win_misc.c | 43 ++------------ harbour/utils/hbmk2/hbmk2.prg | 8 ++- 6 files changed, 131 insertions(+), 47 deletions(-) create mode 100644 harbour/contrib/hbwin/wapi_shellapi.c diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 13baf5067c..4646952484 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,30 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-06-17 08:33 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) + * utils/hbmk2/hbmk2.prg + + Added support for rest of embedded compiler installations: + pocc64, poccarm, dos/watcom. Since these share a common + install kit with other targets, they can only be selected + using -comp= switch and in this case they will be used + if the installation is present. + + * contrib/hbwin/win_misc.c + + Added support for embedded Chr(0) to WIN_ANSITOWIDE() and + WIN_WIDETOANSI(). + ! Fixed WIN_ANSITOWIDE(). Dunno when it worked the last time, + but it must be long ago (SysStringLen() was returning zero). + + * contrib/hbwin/Makefile + * contrib/hbwin/win_misc.c + + contrib/hbwin/wapi_shellapi.c + * Moved and renamed WIN_SHELLEXECUTE() to WAPI_SHELLEXECUTE() + since this implementation is a full wrapper of original + Windows API. Incompatible. Please update your sources. + + * contrib/hbwin/legacyco.c + * Formatting. + 2009-06-16 23:16 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * harbour/contrib/hbxbp/Makefile @@ -41,7 +65,7 @@ + Implemented XbpScrollBar()s. + Added one more menu option to open same dialog n number of times. It is still at infant stage as all the event handlers are not in place. - Infact if demoXBP.prg is compiled in MT mode I think it will not + Infact if demoXBP.prg is compiled in MT mode I think it will not be a issue. Viktor, can you see why I cannot compile demoXBP.prg in MT mode? @@ -51,10 +75,10 @@ * harbour/contrib/hbqt/hbqt_slots.cpp * harbour/contrib/hbqt/hbqt_slots.h * harbour/contrib/hbqt/moc_slots.cpp - ! Greatly improved SIGNAL/SLOT mechanism. + ! Greatly improved SIGNAL/SLOT mechanism. Now SIGNAL to SLOT connection is almost instant no matter how many widgets the application is employing. - ! Implemented to relaase code blocks and reuse vacant slots. + ! Implemented to relaase code blocks and reuse vacant slots. It reduces the memory leakage considerably. * harbour/contrib/hbqt/tests/demoqt.prg @@ -62,16 +86,16 @@ 2009-06-17 00:05 UTC+0300 Mindaugas Kavaliauskas (dbtopas/at/dbtopas.lt) * harbour/contrib/hbwin/axcore.c - ! fixed GPF on ActiveX application exit caused by invalid + ! fixed GPF on ActiveX application exit caused by invalid AtlAxWinTerm() call. ; It's inline function and it does not exists in atl.dll ; MSDN says: When Do I Need to Call AtlAxWinTerm? - AtlAxWinTerm unregisters the "AtlAxWin7" window class. You should - call this function... If don't call this function, the window class + AtlAxWinTerm unregisters the "AtlAxWin7" window class. You should + call this function... If don't call this function, the window class will be unregistered automatically when the process terminates. - ; Thanks Toninho for self contained 3 lines GPF sample without + ; Thanks Toninho for self contained 3 lines GPF sample without FWH, gtwvg, etc! 2009-06-16 18:39 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) diff --git a/harbour/contrib/hbwin/Makefile b/harbour/contrib/hbwin/Makefile index 9013a6ec9b..62650d89c8 100644 --- a/harbour/contrib/hbwin/Makefile +++ b/harbour/contrib/hbwin/Makefile @@ -31,6 +31,7 @@ C_SOURCES = \ win_prt.c \ win_regc.c \ wapi_commctrl.c \ + wapi_shellapi.c \ wapi_winbase.c \ wapi_winuser.c \ diff --git a/harbour/contrib/hbwin/legacyco.c b/harbour/contrib/hbwin/legacyco.c index f8afb28419..f083ab507b 100644 --- a/harbour/contrib/hbwin/legacyco.c +++ b/harbour/contrib/hbwin/legacyco.c @@ -108,7 +108,7 @@ HB_FUNC( MESSAGEBOX ) LPTSTR lpStr1 = HB_TCHAR_CONVTO( hb_parcx( 2 ) ); LPTSTR lpStr2 = HB_TCHAR_CONVTO( hb_parcx( 3 ) ); HWND hWnd = HB_ISNUM( 1 ) ? ( HWND ) ( HB_PTRUINT ) hb_parnint( 1 ) : - ( HWND ) hb_parptr( 1 ); + ( HWND ) hb_parptr( 1 ); hb_retni( MessageBox( hWnd, lpStr1, lpStr2, hb_parni( 4 ) ) ); HB_TCHAR_FREE( lpStr1 ); HB_TCHAR_FREE( lpStr2 ); diff --git a/harbour/contrib/hbwin/wapi_shellapi.c b/harbour/contrib/hbwin/wapi_shellapi.c new file mode 100644 index 0000000000..ee7cb01bdd --- /dev/null +++ b/harbour/contrib/hbwin/wapi_shellapi.c @@ -0,0 +1,86 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * Windows API functions (shellapi.h - shell32.dll) + * + * Copyright 2008-2009 Viktor Szakats (harbour.01 syenar.hu) + * www - http://www.harbour-project.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ + +#define HB_OS_WIN_USED + +#include "hbapi.h" + +#include + +/* TODO: Add hb_osEncode(). */ + +HB_FUNC( WAPI_SHELLEXECUTE ) +{ +#if defined( HB_OS_WIN_CE ) + hb_retnint( -1 ); +#else + LPTSTR lpOperation = HB_ISCHAR( 2 ) ? HB_TCHAR_CONVTO( hb_parc( 2 ) ) : NULL; + LPTSTR lpFile = HB_TCHAR_CONVTO( hb_parcx( 3 ) ); + LPTSTR lpParameters = HB_ISCHAR( 4 ) ? HB_TCHAR_CONVTO( hb_parc( 4 ) ) : NULL; + LPTSTR lpDirectory = HB_ISCHAR( 5 ) ? HB_TCHAR_CONVTO( hb_parc( 5 ) ) : NULL; + + hb_retnint( ( HB_PTRDIFF ) ShellExecute( ( HWND ) hb_parptr( 1 ), + ( LPCTSTR ) lpOperation, /* edit, explore, open, print, play?, properties? */ + ( LPCTSTR ) lpFile, + ( LPCTSTR ) lpParameters, + ( LPCTSTR ) lpDirectory, + HB_ISNUM( 6 ) ? hb_parni( 6 ) : SW_SHOWNORMAL /* nShowCmd */ ) ); + + if( lpOperation ) + HB_TCHAR_FREE( lpOperation ); + HB_TCHAR_FREE( lpFile ); + if( lpParameters ) + HB_TCHAR_FREE( lpParameters ); + if( lpDirectory ) + HB_TCHAR_FREE( lpDirectory ); +#endif +} diff --git a/harbour/contrib/hbwin/win_misc.c b/harbour/contrib/hbwin/win_misc.c index ce782e0149..1ddf559405 100644 --- a/harbour/contrib/hbwin/win_misc.c +++ b/harbour/contrib/hbwin/win_misc.c @@ -54,37 +54,6 @@ #include "hbapi.h" -#include - -/* TODO: Add hb_osEncode(). */ - -HB_FUNC( WIN_SHELLEXECUTE ) -{ -#if defined( HB_OS_WIN_CE ) - hb_retnint( -1 ); -#else - LPTSTR lpOperation = HB_ISCHAR( 2 ) ? HB_TCHAR_CONVTO( hb_parc( 2 ) ) : NULL; - LPTSTR lpFile = HB_TCHAR_CONVTO( hb_parcx( 3 ) ); - LPTSTR lpParameters = HB_ISCHAR( 4 ) ? HB_TCHAR_CONVTO( hb_parc( 4 ) ) : NULL; - LPTSTR lpDirectory = HB_ISCHAR( 5 ) ? HB_TCHAR_CONVTO( hb_parc( 5 ) ) : NULL; - - hb_retnint( ( HB_PTRDIFF ) ShellExecute( ( HWND ) hb_parptr( 1 ), - ( LPCTSTR ) lpOperation, /* edit, explore, open, print, play?, properties? */ - ( LPCTSTR ) lpFile, - ( LPCTSTR ) lpParameters, - ( LPCTSTR ) lpDirectory, - HB_ISNUM( 6 ) ? hb_parni( 6 ) : SW_SHOWNORMAL /* nShowCmd */ ) ); - - if( lpOperation ) - HB_TCHAR_FREE( lpOperation ); - HB_TCHAR_FREE( lpFile ); - if( lpParameters ) - HB_TCHAR_FREE( lpParameters ); - if( lpDirectory ) - HB_TCHAR_FREE( lpDirectory ); -#endif -} - HB_FUNC( WIN_RUNDETACHED ) { LPTSTR lpCommandName = HB_ISCHAR( 1 ) ? HB_TCHAR_CONVTO( hb_parc( 1 ) ) : NULL; @@ -208,20 +177,20 @@ HB_FUNC( WIN_GETCOMMANDLINEPARAM ) HB_TCHAR_FREE( buffer ); } -/* TODO: Add embedded zero support by using hb_mbntowc() */ HB_FUNC( WIN_ANSITOWIDE ) { - BSTR wString = hb_mbtowc( hb_parcx( 1 ) ); + unsigned long nLen = hb_parclen( 1 ); + BSTR wString = hb_mbntowc( hb_parcx( 1 ), nLen ); - hb_retclen_buffer( ( char * ) wString, SysStringLen( wString ) ); + hb_retclen_buffer( ( char * ) wString, nLen * sizeof( wchar_t ) ); } -/* TODO: Add embedded zero support by using hb_wcntomb() */ HB_FUNC( WIN_WIDETOANSI ) { - char * cString = hb_wctomb( ( wchar_t * ) hb_parcx( 1 ) ); + unsigned long nLen = hb_parclen( 1 ); + char * cString = hb_wcntomb( ( wchar_t * ) hb_parcx( 1 ), nLen ); - hb_retclen_buffer( cString, strlen( cString ) ); + hb_retclen_buffer( cString, nLen / sizeof( wchar_t ) ); } HB_FUNC( WIN_N2P ) diff --git a/harbour/utils/hbmk2/hbmk2.prg b/harbour/utils/hbmk2/hbmk2.prg index 57e15b600e..63e4d425f2 100644 --- a/harbour/utils/hbmk2/hbmk2.prg +++ b/harbour/utils/hbmk2/hbmk2.prg @@ -1085,13 +1085,17 @@ FUNCTION hbmk( aArgs, /* @ */ lPause, /* @ */ lUTF8 ) AAdd( aCOMPDET_EMBED, { {| cPrefix | tmp1 := PathNormalize( l_cHB_INSTALL_PREFIX ) + "mingw64" + hb_osPathSeparator() + "bin" , iif( hb_FileExists( tmp1 + hb_osPathSeparator() + cPrefix + "gcc" + cCCEXT_mingw ), tmp1, NIL ) }, "win", "mingw64" , "x86_64-pc-mingw32-" } ) AAdd( aCOMPDET_EMBED, { {| cPrefix | tmp1 := PathNormalize( l_cHB_INSTALL_PREFIX ) + "mingwarm" + hb_osPathSeparator() + "bin" , iif( hb_FileExists( tmp1 + hb_osPathSeparator() + cPrefix + "gcc" + cCCEXT_mingw ), tmp1, NIL ) }, "wce", "mingwarm", "arm-mingw32ce-" } ) AAdd( aCOMPDET_EMBED, { {| cPrefix | tmp1 := PathNormalize( l_cHB_INSTALL_PREFIX ) + "mingwarm" + hb_osPathSeparator() + "bin" , iif( hb_FileExists( tmp1 + hb_osPathSeparator() + cPrefix + "gcc" + cCCEXT_mingw ), tmp1, NIL ) }, "wce", "mingwarm", "arm-wince-mingw32ce-" } ) - AAdd( aCOMPDET_EMBED, { {| cPrefix | tmp1 := PathNormalize( l_cHB_INSTALL_PREFIX ) + "pocc" + hb_osPathSeparator() + "Bin" , iif( hb_FileExists( tmp1 + hb_osPathSeparator() + cPrefix + "pocc.exe" ), tmp1, NIL ) }, "win", "pocc" , "" , {| cARCH, cCOMP, cPathBin | hbmk_COMP_Setup( cARCH, cCOMP, cPathBin + hb_osPathSeparator() + ".." ) } } ) - AAdd( aCOMPDET_EMBED, { {| cPrefix | tmp1 := PathNormalize( l_cHB_INSTALL_PREFIX ) + "watcom" + hb_osPathSeparator() + "binnt", iif( hb_FileExists( tmp1 + hb_osPathSeparator() + cPrefix + "wpp386.exe" ), tmp1, NIL ) }, "win", "watcom" , "" , {| cARCH, cCOMP, cPathBin | hbmk_COMP_Setup( cARCH, cCOMP, cPathBin + hb_osPathSeparator() + ".." ) } } ) AAdd( aCOMPDET_EMBED, { {| cPrefix | tmp1 := PathNormalize( l_cHB_INSTALL_PREFIX ) + "djgpp" + hb_osPathSeparator() + "bin" , iif( hb_FileExists( tmp1 + hb_osPathSeparator() + cPrefix + "gcc.exe" ), tmp1, NIL ) }, "dos", "djgpp" , "" , {| cARCH, cCOMP, cPathBin | hbmk_COMP_Setup( cARCH, cCOMP, cPathBin + hb_osPathSeparator() + ".." ) } } ) + AAdd( aCOMPDET_EMBED, { {| cPrefix | tmp1 := PathNormalize( l_cHB_INSTALL_PREFIX ) + "watcom" + hb_osPathSeparator() + "binnt", iif( hb_FileExists( tmp1 + hb_osPathSeparator() + cPrefix + "wpp386.exe" ), tmp1, NIL ) }, "win", "watcom" , "" , {| cARCH, cCOMP, cPathBin | hbmk_COMP_Setup( cARCH, cCOMP, cPathBin + hb_osPathSeparator() + ".." ) } } ) + AAdd( aCOMPDET_EMBED, { {| cPrefix | tmp1 := PathNormalize( l_cHB_INSTALL_PREFIX ) + "watcom" + hb_osPathSeparator() + "binw" , iif( hb_FileExists( tmp1 + hb_osPathSeparator() + cPrefix + "wpp386.exe" ), tmp1, NIL ) }, "dos", "watcom" , "" , {| cARCH, cCOMP, cPathBin | hbmk_COMP_Setup( cARCH, cCOMP, cPathBin + hb_osPathSeparator() + ".." ) } } ) + AAdd( aCOMPDET_EMBED, { {| cPrefix | tmp1 := PathNormalize( l_cHB_INSTALL_PREFIX ) + "pocc" + hb_osPathSeparator() + "Bin" , iif( hb_FileExists( tmp1 + hb_osPathSeparator() + cPrefix + "pocc.exe" ), tmp1, NIL ) }, "win", "pocc" , "" , {| cARCH, cCOMP, cPathBin | hbmk_COMP_Setup( cARCH, cCOMP, cPathBin + hb_osPathSeparator() + ".." ) } } ) + AAdd( aCOMPDET_EMBED, { {| cPrefix | tmp1 := PathNormalize( l_cHB_INSTALL_PREFIX ) + "pocc" + hb_osPathSeparator() + "Bin" , iif( hb_FileExists( tmp1 + hb_osPathSeparator() + cPrefix + "pocc.exe" ), tmp1, NIL ) }, "win", "pocc64" , "" , {| cARCH, cCOMP, cPathBin | hbmk_COMP_Setup( cARCH, cCOMP, cPathBin + hb_osPathSeparator() + ".." ) } } ) + AAdd( aCOMPDET_EMBED, { {| cPrefix | tmp1 := PathNormalize( l_cHB_INSTALL_PREFIX ) + "pocc" + hb_osPathSeparator() + "Bin" , iif( hb_FileExists( tmp1 + hb_osPathSeparator() + cPrefix + "pocc.exe" ), tmp1, NIL ) }, "wce", "poccarm" , "" , {| cARCH, cCOMP, cPathBin | hbmk_COMP_Setup( cARCH, cCOMP, cPathBin + hb_osPathSeparator() + ".." ) } } ) #elif defined( __PLATFORM__DOS ) AAdd( aCOMPDET_EMBED, { {| cPrefix | tmp1 := PathNormalize( l_cHB_INSTALL_PREFIX ) + "djgpp" + hb_osPathSeparator() + "bin" , iif( hb_FileExists( tmp1 + hb_osPathSeparator() + cPrefix + "gcc.exe" ), tmp1, NIL ) }, "dos", "djgpp" , "" , {| cARCH, cCOMP, cPathBin | hbmk_COMP_Setup( cARCH, cCOMP, cPathBin + hb_osPathSeparator() + ".." ) } } ) + AAdd( aCOMPDET_EMBED, { {| cPrefix | tmp1 := PathNormalize( l_cHB_INSTALL_PREFIX ) + "watcom" + hb_osPathSeparator() + "binw" , iif( hb_FileExists( tmp1 + hb_osPathSeparator() + cPrefix + "wpp386.exe" ), tmp1, NIL ) }, "dos", "watcom" , "" , {| cARCH, cCOMP, cPathBin | hbmk_COMP_Setup( cARCH, cCOMP, cPathBin + hb_osPathSeparator() + ".." ) } } ) #elif defined( __PLATFORM__UNIX )