diff --git a/harbour/ChangeLog b/harbour/ChangeLog index ada0356983..cd43785616 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,17 @@ The license applies to all entries newer than 2009-04-28. */ +2011-12-25 14:47 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) + * contrib/gtwvg/wvgcore.c + * contrib/gtwvg/wvgcuig.c + * contrib/gtwvg/wvggui.c + * contrib/gtwvg/wvggui.h + * contrib/gtwvg/wvgutils.c + * contrib/gtwvg/wvgwin.c + * contrib/gtwvg/wvgwing.c + ! Replaced: HB_TCHAR_* macros to HB_STR*() API. + I could not find the hb_str*() api interface for remaining macros. + 2011-12-24 12:05 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbqt/qtgui/hbqtgui.ch * contrib/hbqt/qtgui/hbqtgui.hbx diff --git a/harbour/contrib/gtwvg/wvgcore.c b/harbour/contrib/gtwvg/wvgcore.c index 4a32932ef7..e69b162d54 100644 --- a/harbour/contrib/gtwvg/wvgcore.c +++ b/harbour/contrib/gtwvg/wvgcore.c @@ -1226,7 +1226,8 @@ HB_FUNC( WVT_DRAWLABEL ) hFont = CreateFontIndirect( &logfont ); if( hFont ) { - LPTSTR text = HB_TCHAR_CONVTO( hb_parc( 3 ) ); + void * hText; + LPCTSTR text = HB_PARSTR( 3, &hText, NULL ); COLORREF fgClr = hb_wvt_FgColorParam( 6 ), bgClr = hb_wvt_BgColorParam( 7 ); @@ -1254,7 +1255,7 @@ HB_FUNC( WVT_DRAWLABEL ) SelectObject( _s->hGuiDC, hOldFontGui ); } #endif - HB_TCHAR_FREE( text ); + hb_strfree( hText ); DeleteObject( hFont ); hb_retl( HB_TRUE ); } @@ -1860,7 +1861,8 @@ HB_FUNC( WVT_DRAWBUTTON ) if( bText ) { - LPTSTR text = HB_TCHAR_CONVTO( hb_parc( 5 ) ); + void * hText; + LPCTSTR text = HB_PARSTR( 5, &hText, NULL ); #if ! defined( HB_OS_WIN_CE ) SelectObject( _s->hdc, GetStockObject( DEFAULT_GUI_FONT ) ); #else @@ -1909,7 +1911,7 @@ HB_FUNC( WVT_DRAWBUTTON ) ExtTextOut( _s->hGuiDC, xy.x, xy.y, 0, NULL, text, lstrlen( text ), NULL ); } - HB_TCHAR_FREE( text ); + hb_strfree( hText ); } else { @@ -2055,7 +2057,8 @@ HB_FUNC( WVT_DRAWLABELEX ) if( _s->pGUI->hUserFonts[ iSlot ] ) { - LPTSTR text = HB_TCHAR_CONVTO( hb_parc( 3 ) ); + void * hText; + LPCTSTR text = HB_PARSTR( 3, &hText, NULL ); COLORREF fgClr = hb_wvt_FgColorParam( 5 ), bgClr = hb_wvt_BgColorParam( 6 ); @@ -2080,7 +2083,7 @@ HB_FUNC( WVT_DRAWLABELEX ) ExtTextOut( _s->hGuiDC, xy.x, xy.y, 0, NULL, text, lstrlen( text ), NULL ); } #endif - HB_TCHAR_FREE( text ); + hb_strfree( hText ); hb_retl( HB_TRUE ); } @@ -2338,7 +2341,8 @@ HB_FUNC( WVT_DRAWLABELOBJ ) int iAlignHorz, iAlignVert, iAlignH, iAlignV; UINT uiOptions; SIZE sz = { 0, 0 }; - LPTSTR text = HB_TCHAR_CONVTO( hb_parc( 5 ) ); + void * hText; + LPCTSTR text = HB_PARSTR( 5, &hText, NULL ); COLORREF fgClr = hb_wvt_FgColorParam( 8 ), bgClr = hb_wvt_BgColorParam( 9 ); @@ -2415,7 +2419,7 @@ HB_FUNC( WVT_DRAWLABELOBJ ) ExtTextOut( _s->hGuiDC, x, y, uiOptions, &rect, text, lstrlen( text ), NULL ); } #endif - HB_TCHAR_FREE( text ); + hb_strfree( hText ); hb_retl( HB_TRUE ); } @@ -2752,7 +2756,8 @@ HB_FUNC( WVT_DRAWTEXTBOX ) int iAlignH = 0; RECT rc = { 0, 0, 0, 0 }; - LPTSTR text = HB_TCHAR_CONVTO( hb_parc( 6 ) ); + void * hText; + LPCTSTR text = HB_PARSTR( 6, &hText, NULL ); COLORREF fgClr = hb_wvt_FgColorParam( 9 ), bgClr = hb_wvt_BgColorParam( 10 ); @@ -2795,7 +2800,7 @@ HB_FUNC( WVT_DRAWTEXTBOX ) DrawText( _s->hGuiDC, text, lstrlen( text ), &rc, iAlignH | DT_WORDBREAK | DT_TOP ); } #endif - HB_TCHAR_FREE( text ); + hb_strfree( hText ); } /*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/gtwvg/wvgcuig.c b/harbour/contrib/gtwvg/wvgcuig.c index 8f2100174d..24194f53ed 100644 --- a/harbour/contrib/gtwvg/wvgcuig.c +++ b/harbour/contrib/gtwvg/wvgcuig.c @@ -97,6 +97,7 @@ static PHB_GOBJS hb_wvg_ObjectNew( PHB_GTWVT pWVT ) gObj->iState = GOBJ_OBJSTATE_ENABLED; gObj->lpText = NULL; gObj->bBlock = NULL; + gObj->hText = NULL; hb_retni( iHandle ); @@ -137,12 +138,8 @@ HB_FUNC( WVG_CLEARGUIOBJECTS ) { gObj = pWVT->gObjs->gObjNext; - if( pWVT->gObjs->lpText != NULL ) -#if defined( UNICODE ) - HB_TCHAR_FREE( pWVT->gObjs->lpText ); -#else - hb_xfree( pWVT->gObjs->lpText ); -#endif + if( pWVT->gObjs->hText ) + hb_strfree( pWVT->gObjs->hText ); if( pWVT->gObjs->hFont != NULL ) if( pWVT->gObjs->bDestroyFont ) DeleteObject( pWVT->gObjs->hFont ); @@ -223,11 +220,12 @@ HB_FUNC( WVG_SETGOBJDATA ) switch( iDataType ) { case GOBJ_OBJDATA_TEXT: - if( gObj->lpText ) - HB_TCHAR_FREE( gObj->lpText ); - gObj->lpText = HB_TCHAR_CONVTO( HB_ISCHAR( 3 ) ? hb_parc( 3 ) : "" ); + { + if( gObj->hText ) + hb_strfree( gObj->hText ); + gObj->lpText = HB_PARSTR( 3, &gObj->hText, NULL ); break; - + } #if ! defined( HB_OS_WIN_CE ) case GOBJ_OBJDATA_PICTURE: if( HB_ISNUM( 3 ) && hb_parni( 3 ) <= WVT_PICTURES_MAX ) @@ -618,11 +616,7 @@ HB_FUNC( WVG_LABEL ) gObj->aOffset.iBottom = hb_parvni( 3, 3 ); gObj->aOffset.iRight = hb_parvni( 3, 4 ); -#if defined( UNICODE ) - gObj->lpText = HB_TCHAR_CONVTO( hb_parc( 4 ) ); //hb_mbtowc( hb_parcx( 4 ) ); -#else - gObj->lpText = hb_strdup( hb_parcx( 4 ) ); -#endif + gObj->lpText = HB_PARSTR( 3, &gObj->hText, NULL ); gObj->iAlign = hb_parnidef( 5, TA_LEFT ); gObj->crRGBText = ( COLORREF ) hb_parnint( 7 ); @@ -1213,7 +1207,7 @@ HB_FUNC( WVG_TEXTBOX ) gObj->aOffset.iBottom = hb_parvni( 5, 3 ); gObj->aOffset.iRight = hb_parvni( 5, 4 ); - gObj->lpText = HB_TCHAR_CONVTO( hb_parc( 6 ) ); + gObj->lpText = HB_PARSTR( 6, &gObj->hText, NULL ); switch( hb_parni( 7 ) ) { diff --git a/harbour/contrib/gtwvg/wvggui.c b/harbour/contrib/gtwvg/wvggui.c index e627a67ba0..29f1867ac8 100644 --- a/harbour/contrib/gtwvg/wvggui.c +++ b/harbour/contrib/gtwvg/wvggui.c @@ -209,6 +209,9 @@ static void hb_gt_wvt_Free( PHB_GTWVT pWVT ) HB_WVT_UNLOCK + if( pWVT->hWindowTitle ) + hb_strfree( pWVT->hWindowTitle ); + /* Detach PRG callback */ hb_itemRelease( pWVT->pPP->pParentGT ); @@ -270,6 +273,16 @@ static PHB_GTWVT hb_gt_wvt_New( PHB_GT pGT, HINSTANCE hInstance, int iCmdShow ) pWVT->bResizable = HB_TRUE; pWVT->bClosable = HB_TRUE; + { + PHB_FNAME pFileName = hb_fsFNameSplit( hb_cmdargARGVN( 0 ) ); + PHB_ITEM pItem = hb_itemPutC( NULL, pFileName->szName ); + + pWVT->lpWindowTitle = HB_ITEMGETSTR( pItem, &pWVT->hWindowTitle, NULL ); + + hb_itemRelease( pItem ); + hb_xfree( pFileName ); + } + pWVT->pPP = ( HB_GT_PARAMS * ) hb_xgrab( sizeof( HB_GT_PARAMS ) ); pWVT->pPP->style = WS_THICKFRAME|WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX; pWVT->pPP->exStyle = 0; @@ -444,34 +457,6 @@ static int hb_gt_wvt_SizeChanged( PHB_GTWVT pWVT ) return 0; } -static void hb_gt_wvt_SetWindowTitle( HWND hWnd, const char * title ) -{ - LPTSTR text = HB_TCHAR_CONVTO( title ); - - SetWindowText( hWnd, text ); - HB_TCHAR_FREE( text ); -} - -static HB_BOOL hb_gt_wvt_GetWindowTitle( HWND hWnd, char ** title ) -{ - TCHAR buffer[WVT_MAX_TITLE_SIZE]; - int iResult; - - iResult = GetWindowText( hWnd, buffer, WVT_MAX_TITLE_SIZE ); - if( iResult > 0 ) - { -#ifdef UNICODE - *title = hb_wcntomb( buffer, iResult ); -#else - *title = hb_strndup( buffer, iResult ); -#endif - return HB_TRUE; - } - - *title = NULL; - return HB_FALSE; -} - static void hb_gt_wvt_MouseEvent( PHB_GTWVT pWVT, UINT message, WPARAM wParam, LPARAM lParam ) { POINT xy; @@ -1201,9 +1186,6 @@ static WPARAM hb_gt_wvt_ProcessMessages( PHB_GTWVT pWVT ) static HWND hb_gt_wvt_CreateWindow( PHB_GTWVT pWVT ) { HWND hWnd, hWndParent; - LPTSTR szAppName; - - szAppName = HB_TCHAR_CONVTO( hb_cmdargARGV()[ 0 ] ); hWndParent = NULL; @@ -1238,7 +1220,7 @@ static HWND hb_gt_wvt_CreateWindow( PHB_GTWVT pWVT ) hWnd = CreateWindowEx( pWVT->pPP->exStyle, /* extended style */ s_szClassName, /* classname */ - szAppName, /* window name */ + pWVT->lpWindowTitle, /* window name */ pWVT->pPP->style, /* style */ pWVT->pPP->x, /* x */ pWVT->pPP->y, /* y */ @@ -1249,9 +1231,6 @@ static HWND hb_gt_wvt_CreateWindow( PHB_GTWVT pWVT ) pWVT->hInstance, /* instance */ NULL ); /* lpParam */ - HB_TCHAR_FREE( szAppName ); - - ShowWindow( pWVT->hWnd, pWVT->pPP->bVisible ? SW_SHOWNORMAL : SW_HIDE ); UpdateWindow( pWVT->hWnd ); @@ -1278,13 +1257,6 @@ static HB_BOOL hb_gt_wvt_CreateConsoleWindow( PHB_GTWVT pWVT ) SendNotifyMessage( pWVT->hWnd, WM_SETICON, ICON_SMALL, ( LPARAM ) pWVT->hIcon ); SendNotifyMessage( pWVT->hWnd, WM_SETICON, ICON_BIG , ( LPARAM ) pWVT->hIcon ); } - - /* Set default window title */ - { - PHB_FNAME pFileName = hb_fsFNameSplit( hb_cmdargARGV()[ 0 ] ); - hb_gt_wvt_SetWindowTitle( pWVT->hWnd, pFileName->szName ); - hb_xfree( pFileName ); - } } return HB_TRUE; @@ -1566,15 +1538,13 @@ static HB_BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) } case HB_GTI_WINTITLE: { - if( pWVT->hWnd ) + pInfo->pResult = HB_ITEMPUTSTR( pInfo->pResult, pWVT->lpWindowTitle ); + if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING ) { - char * szTitle = NULL; - if( hb_gt_wvt_GetWindowTitle( pWVT->hWnd, &szTitle ) ) - pInfo->pResult = hb_itemPutCPtr( pInfo->pResult, szTitle ); - else - pInfo->pResult = hb_itemPutC( pInfo->pResult, NULL ); - if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING ) - hb_gt_wvt_SetWindowTitle( pWVT->hWnd, hb_itemGetCPtr( pInfo->pNewVal ) ); + hb_strfree( pWVT->hWindowTitle ); + pWVT->lpWindowTitle = HB_ITEMGETSTR( pInfo->pNewVal, &pWVT->hWindowTitle, NULL ); + if( pWVT->hWnd ) + SetWindowText( pWVT->hWnd, pWVT->lpWindowTitle ); } break; } @@ -1592,14 +1562,14 @@ static HB_BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) { if( ( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING ) ) { - HICON hIconToFree = ( pWVT->hIcon && pWVT->bIconToFree ) ? pWVT->hIcon : NULL; - LPTSTR lpImage; + HICON hIconToFree = pWVT->bIconToFree ? pWVT->hIcon : NULL; + void * hImageName; - lpImage = HB_TCHAR_CONVTO( hb_itemGetCPtr( pInfo->pNewVal ) ); pWVT->bIconToFree = HB_TRUE; - pWVT->hIcon = ( HICON ) LoadImage( ( HINSTANCE ) NULL, lpImage, - IMAGE_ICON, 0, 0, LR_LOADFROMFILE ); - HB_TCHAR_FREE( lpImage ); + pWVT->hIcon = ( HICON ) LoadImage( ( HINSTANCE ) NULL, + HB_ITEMGETSTR( pInfo->pNewVal, &hImageName, NULL ), + IMAGE_ICON, 0, 0, LR_LOADFROMFILE | LR_DEFAULTSIZE ); + hb_strfree( hImageName ); if( pWVT->hWnd ) { SendNotifyMessage( pWVT->hWnd, WM_SETICON, ICON_SMALL, ( LPARAM ) pWVT->hIcon ); /* Set Title Bar Icon */ @@ -1612,18 +1582,18 @@ static HB_BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) pInfo->pResult = hb_itemPutNInt( pInfo->pResult, ( HB_PTRDIFF ) pWVT->hIcon ); break; } + case HB_GTI_ICONRES: { if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING ) { - HICON hIconToFree = ( pWVT->hIcon && pWVT->bIconToFree ) ? pWVT->hIcon : NULL; - LPTSTR lpIcon; + HICON hIconToFree = pWVT->bIconToFree ? pWVT->hIcon : NULL; + void * hIconName; - lpIcon = HB_TCHAR_CONVTO( hb_itemGetCPtr( pInfo->pNewVal ) ); pWVT->bIconToFree = HB_FALSE; - pWVT->hIcon = LoadIcon( pWVT->hInstance, lpIcon ); - HB_TCHAR_FREE( lpIcon ); - + pWVT->hIcon = LoadIcon( pWVT->hInstance, + HB_ITEMGETSTR( pInfo->pNewVal, &hIconName, NULL ) ); + hb_strfree( hIconName ); if( pWVT->hWnd ) { SendNotifyMessage( pWVT->hWnd, WM_SETICON, ICON_SMALL, ( LPARAM ) pWVT->hIcon ); /* Set Title Bar Icon */ @@ -1635,7 +1605,7 @@ static HB_BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) } else if( hb_itemType( pInfo->pNewVal ) & HB_IT_NUMERIC ) { - HICON hIconToFree = ( pWVT->hIcon && pWVT->bIconToFree ) ? pWVT->hIcon : NULL; + HICON hIconToFree = pWVT->bIconToFree ? pWVT->hIcon : NULL; pWVT->bIconToFree = HB_FALSE; pWVT->hIcon = LoadIcon( pWVT->hInstance, @@ -1935,19 +1905,19 @@ static HB_BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) int iIconType = hb_arrayGetNI( pInfo->pNewVal2, 2 ); HICON hIcon = 0; NOTIFYICONDATA tnid; + void * hIconName; if( iIconType == 0 ) { - LPTSTR lpImage = HB_TCHAR_CONVTO( hb_arrayGetCPtr( pInfo->pNewVal2, 3 ) ); - hIcon = ( HICON ) LoadImage( ( HINSTANCE ) NULL, lpImage, + hIcon = ( HICON ) LoadImage( ( HINSTANCE ) NULL, + HB_ARRAYGETSTR( pInfo->pNewVal2, 3, &hIconName, NULL ), IMAGE_ICON, 0, 0, LR_LOADFROMFILE ); - HB_TCHAR_FREE( lpImage ); + hb_strfree( hIconName ); } else if( iIconType == 1 ) { - LPTSTR lpIcon = HB_TCHAR_CONVTO( hb_arrayGetCPtr( pInfo->pNewVal2, 3 ) ); - hIcon = LoadIcon( pWVT->hInstance, lpIcon ); - HB_TCHAR_FREE( lpIcon ); + hIcon = LoadIcon( pWVT->hInstance, HB_ARRAYGETSTR( pInfo->pNewVal2, 3, &hIconName, NULL ) ); + hb_strfree( hIconName ); } else if( iIconType == 2 ) { diff --git a/harbour/contrib/gtwvg/wvggui.h b/harbour/contrib/gtwvg/wvggui.h index 339a116a72..4f691d6fa3 100644 --- a/harbour/contrib/gtwvg/wvggui.h +++ b/harbour/contrib/gtwvg/wvggui.h @@ -90,6 +90,7 @@ #include "hbvm.h" #include "hbthread.h" #include "hbgfxdef.ch" +#include "hbwinuni.h" #include "hbgtwvg.ch" @@ -293,6 +294,9 @@ typedef struct HICON hIcon; /* Title Bar and Task List icon. Can be NULL. */ HB_BOOL bIconToFree; /* Do we need to free this icon when it's not NULL? */ + void * hWindowTitle; + LPCTSTR lpWindowTitle; + int CodePage; /* Code page to use for display characters */ HB_BOOL Win9X; /* Flag to say if running on Win9X not NT/2000/XP */ HB_BOOL CentreWindow; /* True if window is to be Reset into centre of window */ diff --git a/harbour/contrib/gtwvg/wvgutils.c b/harbour/contrib/gtwvg/wvgutils.c index cd806c9267..0278cda472 100644 --- a/harbour/contrib/gtwvg/wvgutils.c +++ b/harbour/contrib/gtwvg/wvgutils.c @@ -248,12 +248,11 @@ HB_FUNC( WVT_MESSAGEBOX ) { PHB_GTWVT _s = hb_wvt_gtGetWVT(); - LPTSTR title = HB_TCHAR_CONVTO( hb_parc( 1 ) ); - LPTSTR msg = HB_TCHAR_CONVTO( hb_parc( 2 ) ); - - hb_retni( MessageBox( _s->hWnd, title, msg, hb_parnidef( 3, MB_OK ) ) ); - HB_TCHAR_FREE( title ); - HB_TCHAR_FREE( msg ); + void * hTitle; + void * hMsg; + hb_retni( MessageBox( _s->hWnd, HB_PARSTR( 1, &hTitle, NULL ), HB_PARSTR( 2, &hMsg, NULL ), hb_parnidef( 3, MB_OK ) ) ); + hb_strfree( hTitle ); + hb_strfree( hMsg ); } /*----------------------------------------------------------------------*/ @@ -951,12 +950,12 @@ HB_FUNC( WVT_CREATEDIALOGDYNAMIC ) { if( HB_ISNUM( 3 ) ) { - LPTSTR lpTemplate = HB_TCHAR_CONVTO( hb_parc( 1 ) ); + void * hTemplate; hDlg = CreateDialogIndirect( ( HINSTANCE ) wvg_hInstance(), - ( LPDLGTEMPLATE ) lpTemplate, + ( LPDLGTEMPLATE ) HB_PARSTR( 1, &hTemplate, NULL ), hb_parl( 2 ) ? _s->hWnd : NULL, ( DLGPROC ) ( HB_PTRDIFF ) hb_parnint( 3 ) ); - HB_TCHAR_FREE( lpTemplate ); + hb_strfree( hTemplate ); } else { @@ -964,12 +963,12 @@ HB_FUNC( WVT_CREATEDIALOGDYNAMIC ) { case 0: { - LPTSTR lpTemplate = HB_TCHAR_CONVTO( hb_parc( 1 ) ); + void * hTemplate; hDlg = CreateDialog( ( HINSTANCE ) wvg_hInstance(), - lpTemplate, + HB_PARSTR( 1, &hTemplate, NULL ), hb_parl( 2 ) ? _s->hWnd : NULL, ( DLGPROC ) hb_wvt_gtDlgProcMLess ); - HB_TCHAR_FREE( lpTemplate ); + hb_strfree( hTemplate ); } break; @@ -1078,13 +1077,13 @@ HB_FUNC( WVT_CREATEDIALOGMODAL ) { case 0: { - LPTSTR lpTemplate = HB_TCHAR_CONVTO( hb_parc( 1 ) ); + void * hTemplate; iResult = DialogBoxParam( ( HINSTANCE ) wvg_hInstance(), - lpTemplate, + HB_PARSTR( 1, &hTemplate, NULL ), hParent, ( DLGPROC ) hb_wvt_gtDlgProcModal, ( LPARAM ) ( DWORD ) iIndex + 1 ); - HB_TCHAR_FREE( lpTemplate ); + hb_strfree( hTemplate ); } break; @@ -1259,10 +1258,9 @@ int nCopyAnsiToWideChar( LPWORD lpWCStr, LPCSTR lpAnsiIn ) HB_FUNC( WVT_LBADDSTRING ) { - LPTSTR text = HB_TCHAR_CONVTO( hb_parc( 3 ) ); - - SendMessage( GetDlgItem( ( HWND ) ( HB_PTRDIFF ) hb_parnint( 1 ), hb_parni( 2 ) ), LB_ADDSTRING, 0, ( LPARAM ) ( LPSTR ) text ); - HB_TCHAR_FREE( text ); + void * hText; + SendMessage( GetDlgItem( ( HWND ) ( HB_PTRDIFF ) hb_parnint( 1 ), hb_parni( 2 ) ), LB_ADDSTRING, 0, ( LPARAM ) HB_PARSTR( 3, &hText, NULL ) ); + hb_strfree( hText ); } /*----------------------------------------------------------------------*/ @@ -1290,10 +1288,9 @@ HB_FUNC( WVT_LBSETCURSEL ) HB_FUNC( WVT_CBADDSTRING ) { - LPTSTR text = HB_TCHAR_CONVTO( hb_parc( 3 ) ); - - SendMessage( GetDlgItem( ( HWND ) ( HB_PTRDIFF ) hb_parnint( 1 ), hb_parni( 2 ) ), CB_ADDSTRING, 0, ( LPARAM ) ( LPSTR ) text ); - HB_TCHAR_FREE( text ); + void * hText; + SendMessage( GetDlgItem( ( HWND ) ( HB_PTRDIFF ) hb_parnint( 1 ), hb_parni( 2 ) ), CB_ADDSTRING, 0, ( LPARAM ) HB_PARSTR( 3, &hText, NULL ) ); + hb_strfree( hText ); } /*----------------------------------------------------------------------*/ @@ -1317,13 +1314,13 @@ HB_FUNC( WVT_DLGSETICON ) } else { - LPTSTR icon = HB_TCHAR_CONVTO( hb_parc( 2 ) ); - hIcon = ( HICON ) LoadImage( ( HINSTANCE ) NULL, icon, IMAGE_ICON, 0, 0, LR_LOADFROMFILE ); + void * cIcon; + hIcon = ( HICON ) LoadImage( ( HINSTANCE ) NULL, HB_PARSTR( 2, &cIcon, NULL ), IMAGE_ICON, 0, 0, LR_LOADFROMFILE ); if( ! hIcon ) { - hIcon = ( HICON ) LoadImage( GetModuleHandle( NULL ), icon, IMAGE_ICON, 0, 0, 0 ); + hIcon = ( HICON ) LoadImage( GetModuleHandle( NULL ), HB_PARSTR( 2, &cIcon, NULL ), IMAGE_ICON, 0, 0, 0 ); } - HB_TCHAR_FREE( icon ); + hb_strfree( cIcon ); } if( hIcon ) diff --git a/harbour/contrib/gtwvg/wvgwin.c b/harbour/contrib/gtwvg/wvgwin.c index 6a8871f6c6..f3cddedba7 100644 --- a/harbour/contrib/gtwvg/wvgwin.c +++ b/harbour/contrib/gtwvg/wvgwin.c @@ -120,27 +120,21 @@ static HINSTANCE wvg_hInstance( void ) HB_FUNC( WVG_SENDMESSAGE ) { - LPTSTR cText = HB_ISCHAR( 4 ) ? HB_TCHAR_CONVTO( hb_parcx( 4 ) ) : NULL; - + void * hText = NULL; hb_retnl( ( HB_ULONG ) SendMessage( ( HWND ) ( HB_PTRDIFF ) hb_parnint( 1 ), ( UINT ) hb_parni( 2 ), ( ! HB_ISNUM( 3 ) ? 0 : ( WPARAM ) hb_parnint( 3 ) ), - ( HB_ISNIL( 4 ) ? 0 : ( cText ? ( LPARAM )( LPSTR ) cText : - ( LPARAM ) hb_parnint( 4 ) ) ) ) - ); - - if( cText ) + ( HB_ISCHAR( 4 ) ? ( LPARAM ) HB_PARSTR( 4, &hText, NULL ) : + ( LPARAM ) hb_parnint( 4 ) ) ) ); + if( hText ) { if( HB_ISBYREF( 4 ) ) { - char * szText = HB_TCHAR_CONVFROM( cText ); - hb_storc( szText, 4 ); - HB_TCHAR_FREE( szText ); + HB_STORSTR( hText, 4 ); } - HB_TCHAR_FREE( cText ); } + hb_strfree( hText ); } - /*----------------------------------------------------------------------*/ HB_FUNC( WVG_SENDDLGITEMMESSAGE ) @@ -267,10 +261,9 @@ HB_FUNC( WVG_GETDIALOGBASEUNITS ) HB_FUNC( WVG_SETDLGITEMTEXT ) { - LPTSTR lpBuffer = HB_TCHAR_CONVTO( hb_parcx( 3 ) ); - - SetDlgItemText( ( HWND ) ( HB_PTRDIFF ) hb_parnint( 1 ), hb_parni( 2 ), lpBuffer ); - HB_TCHAR_FREE( lpBuffer ); + void * hText; + SetDlgItemText( ( HWND ) ( HB_PTRDIFF ) hb_parnint( 1 ), hb_parni( 2 ), HB_PARSTR( 3, &hText, NULL ) ); + hb_strfree( hText ); } /*----------------------------------------------------------------------*/ @@ -332,14 +325,12 @@ HB_FUNC( WVG_GETDLGITEM ) HB_FUNC( WVG_MESSAGEBOX ) { - HWND hWnd = HB_ISNUM( 1 ) ? ( HWND ) ( HB_PTRDIFF ) hb_parnint( 1 ) : GetActiveWindow(); - LPTSTR lpMsg = HB_TCHAR_CONVTO( hb_parcx( 2 ) ); - LPTSTR lpTitle = HB_TCHAR_CONVTO( HB_ISCHAR( 3 ) ? hb_parc( 3 ) : "Info" ); - - hb_retni( MessageBox( hWnd, lpMsg, lpTitle, hb_parnidef( 4, MB_OK ) ) ); - - HB_TCHAR_FREE( lpTitle ); - HB_TCHAR_FREE( lpMsg ); + HWND hWnd = HB_ISNUM( 1 ) ? ( HWND ) ( HB_PTRDIFF ) hb_parnint( 1 ) : GetActiveWindow(); + void * hMsg; + void * hTitle; + hb_retni( MessageBox( hWnd, HB_PARSTR( 2, &hMsg, NULL ), HB_PARSTR( 3, &hTitle, NULL ), hb_parnidef( 4, MB_OK ) ) ); + hb_strfree( hMsg ); + hb_strfree( hTitle ); } /*----------------------------------------------------------------------*/ @@ -375,9 +366,9 @@ HB_FUNC( WVG_LOADICON ) } else { - LPTSTR lpBuffer = HB_TCHAR_CONVTO( hb_parcx( 1 ) ); - hIcon = ( HICON ) LoadImage( ( HINSTANCE ) NULL, lpBuffer, IMAGE_ICON, 0, 0, LR_LOADFROMFILE ); - HB_TCHAR_FREE( lpBuffer ); + void * hBuffer; + hIcon = ( HICON ) LoadImage( ( HINSTANCE ) NULL, HB_PARSTR( 1, &hBuffer, NULL ), IMAGE_ICON, 0, 0, LR_LOADFROMFILE ); + hb_strfree( hBuffer ); } hb_retnint( ( HB_PTRDIFF ) hIcon ); @@ -393,7 +384,8 @@ HB_FUNC( WVG_LOADICON ) HB_FUNC( WVG_LOADIMAGE ) { HANDLE hImage = 0; - LPTSTR lpBuffer = HB_TCHAR_CONVTO( hb_parcx( 1 ) ); + void * hBuffer; + LPCTSTR lpBuffer = HB_PARSTR( 1, &hBuffer, NULL ); int iSource = hb_parni( 2 ); switch( iSource ) @@ -414,7 +406,7 @@ HB_FUNC( WVG_LOADIMAGE ) break; } - HB_TCHAR_FREE( lpBuffer ); + hb_strfree( hBuffer ); hb_retnint( ( HB_PTRDIFF ) hImage ); } @@ -479,7 +471,8 @@ HB_FUNC( WVG_CREATEBRUSH ) HB_FUNC( WVG_DRAWTEXT ) { RECT rc = { 0, 0, 0, 0 }; - LPTSTR lpBuffer = HB_TCHAR_CONVTO( hb_parcx( 2 ) ); + void * hBuffer; + LPCTSTR lpBuffer = HB_PARSTR( 2, &hBuffer, NULL ); rc.left = hb_parvni( 3, 1 ); rc.top = hb_parvni( 3, 2 ); @@ -487,7 +480,7 @@ HB_FUNC( WVG_DRAWTEXT ) rc.bottom = hb_parvni( 3, 4 ); hb_retl( DrawText( ( HDC ) ( HB_PTRDIFF ) hb_parnint( 1 ), lpBuffer, lstrlen( lpBuffer ), &rc, hb_parni( 4 ) ) ); - HB_TCHAR_FREE( lpBuffer ); + hb_strfree( hBuffer ); } /*----------------------------------------------------------------------*/ @@ -548,10 +541,9 @@ HB_FUNC( WVG_SETFOREGROUNDWINDOW ) HB_FUNC( WVG_SETWINDOWTEXT ) { - LPTSTR text = HB_TCHAR_CONVTO( hb_parcx( 2 ) ); - - SetWindowText( wvg_parhwnd( 1 ), text ); - HB_TCHAR_FREE( text ); + void * hText; + SetWindowText( wvg_parhwnd( 1 ), HB_PARSTR( 2, &hText, NULL ) ); + hb_strfree( hText ); } /*----------------------------------------------------------------------*/ @@ -698,11 +690,10 @@ HB_FUNC( WVG_CHOOSECOLOR ) HB_FUNC( WVG_FINDWINDOW ) { HWND hwnd; - LPTSTR lpStr; + void * hText; - lpStr = HB_TCHAR_CONVTO( hb_parcx( 1 ) ); - hwnd = FindWindow( NULL, lpStr ); - HB_TCHAR_FREE( lpStr ); + hwnd = FindWindow( NULL, HB_PARSTR( 1, &hText, NULL ) ); + hb_strfree( hText ); if( hwnd ) hb_retnint( ( HB_PTRDIFF ) hwnd ); @@ -866,13 +857,13 @@ HB_FUNC( WVG_MAKELPARAM ) HB_FUNC( WVG_CREATEWINDOWEX ) { - HWND hWnd; - LPTSTR szClassName = HB_TCHAR_CONVTO( hb_parcx( 2 ) ); - LPTSTR szWinName = HB_TCHAR_CONVTO( hb_parcx( 3 ) ); + HWND hWnd; + void * hClassName; + void * hWinName; hWnd = CreateWindowEx( ( DWORD ) hb_parnint( 1 ), - szClassName, - szWinName, + HB_PARSTR( 2, &hClassName, NULL ), + HB_PARSTR( 3, &hWinName, NULL ), ( DWORD ) hb_parnint( 4 ), hb_parni( 5 ), hb_parni( 6 ), hb_parni( 7 ), hb_parni( 8 ), @@ -880,9 +871,8 @@ HB_FUNC( WVG_CREATEWINDOWEX ) HB_ISNUM( 10 ) ? ( HMENU ) ( HB_PTRDIFF ) hb_parnint( 10 ) : NULL, HB_ISNUM( 11 ) ? ( HINSTANCE ) ( HB_PTRDIFF ) hb_parnint( 11 ) : ( HINSTANCE ) wvg_hInstance(), NULL ); - - HB_TCHAR_FREE( szClassName ); - HB_TCHAR_FREE( szWinName ); + hb_strfree( hClassName ); + hb_strfree( hWinName ); hb_retnint( ( HB_PTRDIFF ) hWnd ); } @@ -890,11 +880,12 @@ HB_FUNC( WVG_CREATEWINDOWEX ) HB_FUNC( WVG_SENDMESSAGETEXT ) { - LPTSTR lpBuffer = HB_TCHAR_CONVTO( hb_parcx( 4 ) ); - - SendMessage( ( HWND ) ( HB_PTRDIFF ) hb_parnint( 1 ), hb_parni( 2 ), - ( WPARAM ) hb_parni( 3 ), ( LPARAM ) lpBuffer ); - HB_TCHAR_FREE( lpBuffer ); + void * hBuffer; + SendMessage( ( HWND ) ( HB_PTRDIFF ) hb_parnint( 1 ), + hb_parni( 2 ), + ( WPARAM ) hb_parni( 3 ), + ( LPARAM ) HB_PARSTR( 4, &hBuffer, NULL ) ); + hb_strfree( hBuffer ); } /*----------------------------------------------------------------------*/ @@ -1220,12 +1211,11 @@ HB_FUNC( WVG_SENDTOOLBARMESSAGE ) } case TB_ADDSTRING: { - int iString; - LPTSTR szCaption; + int iString; + void * hCaption; - szCaption = HB_TCHAR_CONVTO( hb_parcx( 3 ) ); - iString = ( int ) SendMessage( hTB, TB_ADDSTRING, ( WPARAM ) NULL, ( LPARAM ) szCaption ); - HB_TCHAR_FREE( szCaption ); + iString = ( int ) SendMessage( hTB, TB_ADDSTRING, ( WPARAM ) NULL, ( LPARAM ) HB_PARSTR( 3, &hCaption, NULL ) ); + hb_strfree( hCaption ); hbwapi_ret_NI( iString ); break; diff --git a/harbour/contrib/gtwvg/wvgwing.c b/harbour/contrib/gtwvg/wvgwing.c index 150a1869bc..2cc3040587 100644 --- a/harbour/contrib/gtwvg/wvgwing.c +++ b/harbour/contrib/gtwvg/wvgwing.c @@ -550,15 +550,15 @@ HB_FUNC( WVG_STATUSBARSETTEXT ) int iPart = hb_parnidef( 2, 1 ); TCHAR szText[ 1024 ]; int iFlags; - TCHAR * szCaption; + void * hCaption; iPart -= 1; /* Zero based */ iFlags = ( int ) HIWORD( SendMessage( hWndSB, SB_GETTEXT, ( WPARAM ) iPart, ( LPARAM ) szText ) ); - szCaption = HB_TCHAR_CONVTO( hb_parcx( 3 ) ); - SendMessage( hWndSB, SB_SETTEXT, ( WPARAM ) iPart | iFlags, ( LPARAM ) szCaption ); - HB_TCHAR_FREE( szCaption ); + SendMessage( hWndSB, SB_SETTEXT, ( WPARAM ) iPart | iFlags, ( LPARAM ) HB_PARSTR( 3, &hCaption, NULL ) ); + + hb_strfree( hCaption ); } } @@ -1078,25 +1078,23 @@ HB_FUNC( WVG_ADDTOOLBARBUTTON ) HB_BOOL bSuccess; HWND hWndTB = hbwapi_par_raw_HWND( 1 ); int iCommand = hb_parni( 4 ); - TCHAR * szCaption; switch( hb_parni( 5 ) ) { case 1: /* button from image */ { int iNewString; - - /* set string */ - szCaption = HB_TCHAR_CONVTO( hb_parcx( 3 ) ); - iNewString = ( int ) SendMessage( hWndTB, TB_ADDSTRING, ( WPARAM ) 0, ( LPARAM ) szCaption ); - HB_TCHAR_FREE( szCaption ); - #if 1 + /* set string */ + void * hCaption; + iNewString = ( int ) SendMessage( hWndTB, TB_ADDSTRING, ( WPARAM ) 0, ( LPARAM ) HB_PARSTR( 3, &hCaption, NULL ) ); + hb_strfree( hCaption ); + if( hb_parl( 6 ) ) { SendMessage( hWndTB, TB_SETMAXTEXTROWS, ( WPARAM ) 0, ( LPARAM ) 0 ); } - #endif + /* add button */ tbb.iBitmap = hb_parni( 2 ); tbb.idCommand = iCommand;