From 22169dced08a33d1c86f7206afdd3613d414cbd9 Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Mon, 9 Jun 2008 03:15:08 +0000 Subject: [PATCH] 2008-06-08 20:12 UTC+0800 Pritpal Bedi (pritpal@vouchcac.com * harbour/source/rtl/gtwvt/gtwvt.c * More fixes on resizing. Now appears to be behaving correctly. Please test. * harbour/tests/wvtext.pr * Formatting and typos. --- harbour/ChangeLog | 7 +++++ harbour/source/rtl/gtwvt/gtwvt.c | 47 ++++++++++++++---------------- harbour/tests/wvtext.prg | 50 -------------------------------- 3 files changed, 29 insertions(+), 75 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index e85ca6d952..3079d439ad 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,13 @@ 2008-12-31 13:59 UTC+0100 Foo Bar */ +2008-06-08 20:12 UTC+0800 Pritpal Bedi (pritpal@vouchcac.com + * harbour/source/rtl/gtwvt/gtwvt.c + * More fixes on resizing. Now appears to be behaving correctly. Please test. + + * harbour/tests/wvtext.pr + * Formatting and typos. + 2008-06-08 16:03 UTC+0800 Pritpal Bedi (pritpal@vouchcac.com * harbour/source/rtl/gtwvt/gtwvt.c * harbour/source/rtl/gtwvt/gtwvt.h diff --git a/harbour/source/rtl/gtwvt/gtwvt.c b/harbour/source/rtl/gtwvt/gtwvt.c index 4234848587..67c3e9eb9c 100644 --- a/harbour/source/rtl/gtwvt/gtwvt.c +++ b/harbour/source/rtl/gtwvt/gtwvt.c @@ -693,11 +693,12 @@ static void hb_gt_wvt_FitSize( PHB_GTWVT pWVT, USHORT mode ) { HDC hdc; HFONT hOldFont, hFont; - USHORT width, height, maxWidth, maxHeight, fontHeight, fontWidth, n; + USHORT fontHeight, fontWidth, n; + LONG width, height, maxWidth, maxHeight; SHORT left, top; TEXTMETRIC tm; RECT wi, ci; -// char buff[ 100 ]; + BOOL bValid = TRUE; HB_SYMBOL_UNUSED( mode ); @@ -711,10 +712,10 @@ static void hb_gt_wvt_FitSize( PHB_GTWVT pWVT, USHORT mode ) GetClientRect( pWVT->hWnd, &ci ); } - if( ci.left >= 0 && ci.top >= 0 ) + if( bValid ) { - maxWidth = ci.right - ci.left; maxHeight = ci.bottom - ci.top ; + maxWidth = ci.right - ci.left ; fontHeight = maxHeight / pWVT->ROWS; fontWidth = maxWidth / pWVT->COLS; @@ -723,13 +724,13 @@ static void hb_gt_wvt_FitSize( PHB_GTWVT pWVT, USHORT mode ) { hdc = GetDC( pWVT->hWnd ); hOldFont = ( HFONT ) SelectObject( hdc, hFont ); - GetTextMetrics( hdc, &tm ); SetTextCharacterExtra( hdc, 0 ); + GetTextMetrics( hdc, &tm ); SelectObject( hdc, hOldFont ); ReleaseDC( pWVT->hWnd, hdc ); - width = (USHORT) ( tm.tmAveCharWidth * pWVT->COLS ); - height = (USHORT) ( tm.tmHeight * pWVT->ROWS ); + width = ( tm.tmAveCharWidth * pWVT->COLS ); + height = ( tm.tmHeight * pWVT->ROWS ); if( width <= maxWidth && height <= maxHeight ) { @@ -744,13 +745,13 @@ static void hb_gt_wvt_FitSize( PHB_GTWVT pWVT, USHORT mode ) pWVT->PTEXTSIZE.x = tm.tmAveCharWidth; pWVT->PTEXTSIZE.y = tm.tmHeight; - #if defined(HB_WINCE) +#if defined(HB_WINCE) pWVT->FixedFont = FALSE; - #else +#else pWVT->FixedFont = !pWVT->Win9X && pWVT->fontWidth >= 0 && ( tm.tmPitchAndFamily & TMPF_FIXED_PITCH ) == 0 && ( pWVT->PTEXTSIZE.x == tm.tmMaxCharWidth ); - #endif +#endif for( n = 0; n < pWVT->COLS; n++ ) { pWVT->FixedSize[ n ] = pWVT->PTEXTSIZE.x; @@ -758,26 +759,22 @@ static void hb_gt_wvt_FitSize( PHB_GTWVT pWVT, USHORT mode ) if( pWVT->bMaximized ) { - left = ( ( ci.right - width ) / 2 ); - top = ( ( ci.bottom - height ) / 2 ); + left = 0; + top = 0; } else { - left = wi.left; - top = wi.top; - width += ( USHORT ) ( wi.right - wi.left - ci.right ); - height += ( USHORT ) ( wi.bottom - wi.top - ci.bottom ); + left = ( wi.left < 0 ? 0 : wi.left ); + top = ( wi.top < 0 ? 0 : wi.top ); + width += ( wi.right - wi.left - ci.right ); + height += ( wi.bottom - wi.top - ci.bottom ); } -//sprintf( buff, "%d %d %d %d", left, top, width, height ); -//OutputDebugString( buff ); - if( ( left >= 0 ) && ( top >= 0 ) ) - { - hb_gt_wvt_KillCaret( pWVT ); - hb_gt_wvt_UpdateCaret( pWVT ); - SetWindowPos( pWVT->hWnd, NULL, left, top, width, height, SWP_NOZORDER ); - HB_GTSELF_EXPOSEAREA( pWVT->pGT, 0, 0, pWVT->ROWS, pWVT->COLS ); - } + hb_gt_wvt_KillCaret( pWVT ); + hb_gt_wvt_UpdateCaret( pWVT ); + + SetWindowPos( pWVT->hWnd, NULL, left, top, width, height, SWP_NOZORDER ); + HB_GTSELF_EXPOSEAREA( pWVT->pGT, 0, 0, pWVT->ROWS, pWVT->COLS ); } } } diff --git a/harbour/tests/wvtext.prg b/harbour/tests/wvtext.prg index 589016784e..9ded0f1810 100644 --- a/harbour/tests/wvtext.prg +++ b/harbour/tests/wvtext.prg @@ -93,11 +93,6 @@ STATIC FUNCTION DispScreen() RETURN NIL -//----------------------------------------------------------------------// -// Comment out this function if you do not want console window be resizable with mouse -// -//FUNCTION Hb_NoResizeableWindow() ; RETURN NIL - //----------------------------------------------------------------------// // Comment out this function if you do not want "Mark and Copy" prompt // available in SysMenu at the left of Title Bar of the application window. @@ -113,48 +108,3 @@ FUNCTION HB_GTSYS() RETURN nil //----------------------------------------------------------------------// -/* -Private Sub SetWindowStyle(ByVal hwnd As Long, ByVal _ - extended_style As Boolean, ByVal style_value As Long, _ - ByVal new_value As Boolean, ByVal brefresh As Boolean) -Dim style_type As Long -Dim style As Long - - If extended_style Then - style_type = GWL_EXSTYLE - Else - style_type = GWL_STYLE - End If - - ' Get the current style. - style = GetWindowLong(hwnd, style_type) - - ' Add or remove the indicated value. - If new_value Then - style = style Or style_value - Else - style = style And Not style_value - End If - - ' Hide Window if Changing ShowInTaskBar - If brefresh Then - ShowWindow hwnd, SW_HIDE - End If - - ' Set the style. - SetWindowLong hwnd, style_type, style - - ' Show Window if Changing ShowInTaskBar - If brefresh Then - ShowWindow hwnd, SW_SHOW - End If - - ' Make the window redraw. - SetWindowPos hwnd, 0, 0, 0, 0, 0, _ - SWP_FRAMECHANGED Or _ - SWP_NOMOVE Or _ - SWP_NOSIZE Or _ - SWP_NOZORDER -End Sub -*/ -//----------------------------------------------------------------------//