From fbe077d628633ecc1ad65416319158427953c56a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Czerpak?= Date: Tue, 26 Sep 2017 14:54:59 +0200 Subject: [PATCH] 2017-09-26 14:54 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * contrib/hbmemio/memio.c ! fixed FO_TRUNC attribute in MEM: file IO - thanks to Miroslav Georgiev for information about the problem * include/hbgtinfo.ch * src/rtl/gtwvt/gtwvt.h * src/rtl/gtwvt/gtwvt.c + added new hb_gtInfo() action HB_GTI_SYSMENUADD It allows to add new items to window system menu which selected add defined by user key code into keyboard queue, i.e. hb_gtInfo( HB_GTI_SYSMENUADD, HB_K_MENU, "Settings" ) * In WinCE builds use DeleteMenu() + AppendMenu() instead of missing ModifyMenu() ! pacified warning in non UNICODE builds --- ChangeLog.txt | 18 ++++++- contrib/hbmemio/memio.c | 36 +++++++++---- include/hbgtinfo.ch | 1 + src/rtl/gtwvt/gtwvt.c | 109 +++++++++++++++++++++++++++++++++++++--- src/rtl/gtwvt/gtwvt.h | 12 +++++ 5 files changed, 158 insertions(+), 18 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 7da76cc486..cf6d3e881d 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-09-26 14:54 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * contrib/hbmemio/memio.c + ! fixed FO_TRUNC attribute in MEM: file IO - thanks to Miroslav Georgiev + for information about the problem + + * include/hbgtinfo.ch + * src/rtl/gtwvt/gtwvt.h + * src/rtl/gtwvt/gtwvt.c + + added new hb_gtInfo() action HB_GTI_SYSMENUADD + It allows to add new items to window system menu which + selected add defined by user key code into keyboard queue, i.e. + hb_gtInfo( HB_GTI_SYSMENUADD, HB_K_MENU, "Settings" ) + * In WinCE builds use DeleteMenu() + AppendMenu() instead of + missing ModifyMenu() + ! pacified warning in non UNICODE builds + 2017-09-22 17:39 UTC Viktor Szakats (vszakats users.noreply.github.com) * src/compiler/hbcomp.c ! revert an accidental sync with 3.4 resulting in .prg source @@ -717,7 +733,7 @@ * contrib/gtwvg/gtwgud.c * contrib/gtwvg/gtwvgd.c + Added : hb_gtinfo( HB_GTI_WINTITLE ) now returns Windows handle. - Was a missing implementation since long. + Was a missing implementation since long. 2017-08-13 18:53 UTC Viktor Szakats (vszakats users.noreply.github.com) * config/global.mk diff --git a/contrib/hbmemio/memio.c b/contrib/hbmemio/memio.c index dfd93fcd4d..2532283c9f 100644 --- a/contrib/hbmemio/memio.c +++ b/contrib/hbmemio/memio.c @@ -509,20 +509,34 @@ HB_MEMFS_EXPORT HB_FHANDLE hb_memfsOpen( const char * szName, HB_USHORT uiFlags s_error = uiError; - if( ! pFile ) + if( pFile ) { - HB_MEMFSMT_UNLOCK(); - return FS_ERROR; - } - pFile->pInode->uiDeny |= uiFlags & FOX_DENYFLAGS; - if( uiFlags & FOX_READ ) - pFile->pInode->uiCountRead++; - if( uiFlags & FOX_WRITE ) - pFile->pInode->uiCountWrite++; + if( uiFlags & FO_TRUNC ) + { + pFile->pInode->llSize = 0; + if( pFile->pInode->llAlloc != HB_MEMFS_INITSIZE ) + { + pFile->pInode->llAlloc = HB_MEMFS_INITSIZE; + hb_xfree( pFile->pInode->pData ); + pFile->pInode->pData = ( char * ) hb_xgrab( ( HB_ULONG ) pFile->pInode->llAlloc ); + } + memset( pFile->pInode->pData, 0, ( HB_SIZE ) pFile->pInode->llAlloc ); + } + + pFile->pInode->uiDeny |= uiFlags & FOX_DENYFLAGS; + if( uiFlags & FOX_READ ) + pFile->pInode->uiCountRead++; + if( uiFlags & FOX_WRITE ) + pFile->pInode->uiCountWrite++; + + pFile->uiFlags = uiFlags; + hFile = memfsHandleAlloc( pFile ); + } + else + hFile = FS_ERROR; - pFile->uiFlags = uiFlags; - hFile = memfsHandleAlloc( pFile ); HB_MEMFSMT_UNLOCK(); + return hFile; } diff --git a/include/hbgtinfo.ch b/include/hbgtinfo.ch index 5bba5a3135..8bd5573527 100644 --- a/include/hbgtinfo.ch +++ b/include/hbgtinfo.ch @@ -150,6 +150,7 @@ #define HB_GTI_RESIZESTEP 73 /* Enable/Disable window resizing steps */ #define HB_GTI_CLOSEMODE 74 /* Close event: 0 terminate application, >=1 generate HB_K_CLOSE, 2 disable close button */ #define HB_GTI_MINIMIZED 75 /* Get/Set Window's Minimized status (supported by: GTQTC, GTXWC) */ +#define HB_GTI_SYSMENUADD 76 /* Add item to window system menu with keycode to generate when selected */ /* Font weights */ #define HB_GTI_FONTW_THIN 1 diff --git a/src/rtl/gtwvt/gtwvt.c b/src/rtl/gtwvt/gtwvt.c index be1d3e4d52..ad580ee1e6 100644 --- a/src/rtl/gtwvt/gtwvt.c +++ b/src/rtl/gtwvt/gtwvt.c @@ -140,7 +140,9 @@ static const TCHAR s_szClassName[] = TEXT( "Harbour_WVT_Class" ); static LRESULT CALLBACK hb_gt_wvt_WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ); static HB_BOOL hb_gt_wvt_FullScreen( PHB_GT pGT ); +#if defined( UNICODE ) static void hb_gt_wvt_ResetBoxCharBitmaps( PHB_GTWVT pWVT ); +#endif static void hb_gt_wvt_RegisterClass( HINSTANCE hInstance ) { @@ -237,6 +239,15 @@ static void hb_gt_wvt_Free( PHB_GTWVT pWVT ) HB_WVT_UNLOCK(); + while( pWVT->pMenu ) + { + PHB_GTWVT_MNU pMenu = pWVT->pMenu; + + pWVT->pMenu = pMenu->pNext; + hb_strfree( pWVT->hSelectCopy ); + hb_xfree( pMenu ); + } + if( pWVT->hSelectCopy ) hb_strfree( pWVT->hSelectCopy ); @@ -367,6 +378,8 @@ static PHB_GTWVT hb_gt_wvt_New( PHB_GT pGT, HINSTANCE hInstance, int iCmdShow ) pWVT->hSelectCopy = NULL; pWVT->bSelectCopy = HB_TRUE; + pWVT->pMenu = NULL; + { PHB_ITEM pItem = hb_itemPutCPtr( NULL, hb_cmdargBaseProgName() ); @@ -1377,6 +1390,7 @@ static HBITMAP hb_gt_wvt_DefineBoxChar( PHB_GTWVT pWVT, HB_USHORT usCh ) /* *********************************************************************** */ +#if defined( UNICODE ) static void hb_gt_wvt_ResetBoxCharBitmaps( PHB_GTWVT pWVT ) { int i; @@ -1390,6 +1404,7 @@ static void hb_gt_wvt_ResetBoxCharBitmaps( PHB_GTWVT pWVT ) for( i = 0; i < HB_BOXCH_TRANS_COUNT; ++i ) pWVT->boxIndex[ i ] = HB_BOXCH_TRANS_MAX; } +#endif /* *********************************************************************** */ @@ -3109,13 +3124,22 @@ static LRESULT CALLBACK hb_gt_wvt_WndProc( HWND hWnd, UINT message, WPARAM wPara return 0; case WM_SYSCOMMAND: - switch( wParam ) + if( wParam == SYS_EV_MARK ) { - - case SYS_EV_MARK: + pWVT->bBeginMarked = HB_TRUE; + return 0; + } + else if( wParam > SYS_EV_MARK ) + { + PHB_GTWVT_MNU pMenu = pWVT->pMenu; + while( pMenu ) { - pWVT->bBeginMarked = HB_TRUE; - return 0; + if( ( WPARAM ) pMenu->iEvent == wParam ) + { + hb_gt_wvt_AddCharToInputQueue( pWVT, pMenu->iKey ); + return 0; + } + pMenu = pMenu->pNext; } } break; @@ -3180,13 +3204,23 @@ static HB_BOOL hb_gt_wvt_CreateConsoleWindow( PHB_GTWVT pWVT ) { HMENU hSysMenu = GetSystemMenu( pWVT->hWnd, FALSE ); + if( hSysMenu ) { + PHB_GTWVT_MNU pMenu = pWVT->pMenu; + /* Create "Mark" prompt in SysMenu to allow console type copy operation */ AppendMenu( hSysMenu, MF_STRING, SYS_EV_MARK, pWVT->lpSelectCopy ); /* CloseButton [x] and "Close" window menu item */ EnableMenuItem( hSysMenu, SC_CLOSE, MF_BYCOMMAND | ( pWVT->CloseMode < 2 ? MF_ENABLED : MF_GRAYED ) ); + + /* Create user menu */ + while( pMenu ) + { + AppendMenu( hSysMenu, MF_STRING, pMenu->iEvent, pMenu->lpName ); + pMenu = pMenu->pNext; + } } } if( pWVT->bFullScreen ) @@ -4082,6 +4116,64 @@ static HB_BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) } break; + case HB_GTI_SYSMENUADD: + pInfo->pResult = hb_itemPutL( pInfo->pResult, HB_FALSE ); + if( hb_itemType( pInfo->pNewVal ) & HB_IT_NUMERIC ) + { + iVal = hb_itemGetNI( pInfo->pNewVal ); + if( iVal != 0 ) + { + HB_BOOL fAdd = ( hb_itemType( pInfo->pNewVal2 ) & HB_IT_STRING ) != 0; + PHB_GTWVT_MNU * pMenu = &pWVT->pMenu; + int iEvent = SYS_EV_MARK; + + while( * pMenu ) + { + if( ( * pMenu )->iKey == iVal ) + break; + iEvent = HB_MAX( iEvent, ( * pMenu )->iEvent ); + pMenu = &( * pMenu )->pNext; + } + if( * pMenu ) + { + hb_strfree( ( * pMenu )->hName ); + iEvent = ( * pMenu )->iEvent; + if( ! fAdd ) + { + PHB_GTWVT_MNU pFree = * pMenu; + * pMenu = ( * pMenu )->pNext; + hb_xfree( pFree ); + } + } + else + { + if( fAdd ) + { + * pMenu = ( PHB_GTWVT_MNU ) hb_xgrab( sizeof( HB_GTWVT_MNU ) ); + ( * pMenu )->iKey = iVal; + ( * pMenu )->iEvent = iEvent + 1; + ( * pMenu )->pNext = NULL; + } + iEvent = 0; + } + if( fAdd ) + ( * pMenu )->lpName = HB_ITEMGETSTR( pInfo->pNewVal2, &( * pMenu )->hName, NULL ); + if( pWVT->hWnd ) + { + HMENU hSysMenu = GetSystemMenu( pWVT->hWnd, FALSE ); + if( hSysMenu ) + { + if( iEvent != 0 ) + DeleteMenu( hSysMenu, iEvent, MF_BYCOMMAND ); + if( fAdd ) + AppendMenu( hSysMenu, MF_STRING, ( * pMenu )->iEvent, ( * pMenu )->lpName ); + } + } + pInfo->pResult = hb_itemPutL( pInfo->pResult, fAdd || iEvent != 0 ); + } + } + break; + case HB_GTI_SELECTCOPY: if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING ) { @@ -4095,10 +4187,15 @@ static HB_BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) hb_strfree( pWVT->hSelectCopy ); pWVT->lpSelectCopy = HB_ITEMGETSTR( pInfo->pNewVal, &pWVT->hSelectCopy, NULL ); pWVT->bSelectCopy = HB_TRUE; -#if ! defined( HB_OS_WIN_CE ) /* WinCE does not support ModifyMenu */ if( hSysMenu ) + { +#if defined( HB_OS_WIN_CE ) /* WinCE does not support ModifyMenu */ + DeleteMenu( hSysMenu, SYS_EV_MARK, MF_BYCOMMAND ); + AppendMenu( hSysMenu, MF_STRING, SYS_EV_MARK, pWVT->lpSelectCopy ); +#else ModifyMenu( hSysMenu, SYS_EV_MARK, MF_BYCOMMAND | MF_STRING | MF_ENABLED, SYS_EV_MARK, pWVT->lpSelectCopy ); #endif + } } } } diff --git a/src/rtl/gtwvt/gtwvt.h b/src/rtl/gtwvt/gtwvt.h index 5732ff51ca..dc71d6a75c 100644 --- a/src/rtl/gtwvt/gtwvt.h +++ b/src/rtl/gtwvt/gtwvt.h @@ -252,6 +252,16 @@ #define HB_BOXCH_TRANS_MAX 0xFF +typedef struct _HB_GTWVT_MNU +{ + int iKey; + int iEvent; + void * hName; + LPCTSTR lpName; + struct _HB_GTWVT_MNU * pNext; +} HB_GTWVT_MNU, * PHB_GTWVT_MNU; + + typedef struct { PHB_GT pGT; /* core GT pointer */ @@ -339,6 +349,8 @@ typedef struct void * hSelectCopy; LPCTSTR lpSelectCopy; + PHB_GTWVT_MNU pMenu; + RECT sRectNew; RECT sRectOld;