From: Dirk B. <db...@us...> - 2005-04-23 12:43:04
|
Update of /cvsroot/win32forth/win32forth-extsrc/extsrc/w32fConsole In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2339/extsrc/w32fConsole Modified Files: Console.rc Term.cpp Log Message: Fixed the console size bug (after rebuilding the system) Index: Console.rc =================================================================== RCS file: /cvsroot/win32forth/win32forth-extsrc/extsrc/w32fConsole/Console.rc,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Console.rc 12 Mar 2005 09:42:54 -0000 1.5 --- Console.rc 23 Apr 2005 12:42:56 -0000 1.6 *************** *** 55,60 **** VS_VERSION_INFO VERSIONINFO ! FILEVERSION 6,11,0,19 ! PRODUCTVERSION 6,11,0,19 FILEFLAGSMASK 0x3fL #ifdef _DEBUG --- 55,60 ---- VS_VERSION_INFO VERSIONINFO ! FILEVERSION 6,11,0,22 ! PRODUCTVERSION 6,11,0,22 FILEFLAGSMASK 0x3fL #ifdef _DEBUG *************** *** 74,78 **** VALUE "CompanyName", "Win32Forth developer team\0" VALUE "FileDescription", "Win32Forth console\0" ! VALUE "FileVersion", "6, 11, 0, 19\0" VALUE "InternalName", "CONSOLE\0" VALUE "LegalCopyright", "\0" --- 74,78 ---- VALUE "CompanyName", "Win32Forth developer team\0" VALUE "FileDescription", "Win32Forth console\0" ! VALUE "FileVersion", "6, 11, 0, 22\0" VALUE "InternalName", "CONSOLE\0" VALUE "LegalCopyright", "\0" *************** *** 81,85 **** VALUE "PrivateBuild", "\0" VALUE "ProductName", "Win32Forth\0" ! VALUE "ProductVersion", "6, 11, 0, 19\0" VALUE "SpecialBuild", "\0" END --- 81,85 ---- VALUE "PrivateBuild", "\0" VALUE "ProductName", "Win32Forth\0" ! VALUE "ProductVersion", "6, 11, 0, 22\0" VALUE "SpecialBuild", "\0" END Index: Term.cpp =================================================================== RCS file: /cvsroot/win32forth/win32forth-extsrc/extsrc/w32fConsole/Term.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Term.cpp 12 Mar 2005 09:42:54 -0000 1.5 --- Term.cpp 23 Apr 2005 12:42:56 -0000 1.6 *************** *** 942,963 **** case WM_DESTROY: { ! // destroy the console window ! DestroyWindow( hWndConsole ); ! ! // save window position ! WINDOWPLACEMENT wp; ! wp.length = sizeof(WINDOWPLACEMENT); ! if( GetWindowPlacement(hwnd, &wp) && wp.showCmd != SW_SHOWMINIMIZED ) { ! // Only save position if I am not minimized ! RECT rc; ! GetWindowRect(hwnd, &rc); ! char s[512]; ! sprintf(s, "%d,%d,%d,%d\0", rc.left, rc.top, rc.right, rc.bottom); ! HKEY theKey = RegGetKey(); ! RegSetValueEx( theKey, "Console", 0, REG_SZ, (const BYTE *)&s, strlen(s) ); ! RegCloseKey ( theKey ); } --- 942,966 ---- case WM_DESTROY: { ! if( IsWindow( hWndConsole ) ) // only once... { ! // destroy the console window ! DestroyWindow( hWndConsole ); ! // save window position ! WINDOWPLACEMENT wp; ! wp.length = sizeof(WINDOWPLACEMENT); ! if( GetWindowPlacement(hwnd, &wp) && wp.showCmd != SW_SHOWMINIMIZED ) ! { ! // Only save position if I am not minimized ! RECT rc; ! GetWindowRect(hwnd, &rc); ! char s[512]; ! sprintf(s, "%d,%d,%d,%d\0", rc.left, rc.top, rc.right, rc.bottom); ! ! HKEY theKey = RegGetKey(); ! RegSetValueEx( theKey, "Console", 0, REG_SZ, (const BYTE *)&s, strlen(s) ); ! RegCloseKey ( theKey ); ! } } *************** *** 1236,1239 **** --- 1239,1303 ---- //************************************************************************************************* + // GetDefaultConsolePos() + //************************************************************************************************* + RECT GetDefaultConsolePos( void ) + { + RECT rcConsole = { 0, 0, 800, 600 }; + + RECT rcDesktop; + if( SystemParametersInfo( SPI_GETWORKAREA, 0, &rcDesktop, 0 ) ) + rcConsole = rcDesktop; + + return rcConsole; + } + + //************************************************************************************************* + // GetConsolePos() + //************************************************************************************************* + RECT GetConsolePos( void ) + { + RECT rcConsole; + + // get last console pos from registry + char szConsolePos[512] = ""; + RegReadKey( "Console", szConsolePos, sizeof(szConsolePos) ); + if( *szConsolePos ) + { + sscanf( szConsolePos, "%d,%d,%d,%d", &rcConsole.left, &rcConsole.top, &rcConsole.right, &rcConsole.bottom ); + + // Clip the console pos to the size of the work area. + // The work area is the portion of the screen not obscured by the system taskbar + // or by application desktop toolbars. + RECT rcDesktop; + if( SystemParametersInfo( SPI_GETWORKAREA, 0, &rcDesktop, 0 ) ) + { + rcConsole.left = max( rcConsole.left , rcDesktop.left ); + rcConsole.top = max( rcConsole.top , rcDesktop.top ); + rcConsole.right = min( rcConsole.right , rcDesktop.right ); + rcConsole.bottom = min( rcConsole.bottom, rcDesktop.bottom ); + } + } + else + { + // if they have never been set, use defaults + rcConsole = GetDefaultConsolePos(); + } + + if( (rcConsole.right - rcConsole.left) <= 100 ) + { + rcConsole.left = 0; + rcConsole.right = 800; + } + + if( (rcConsole.bottom - rcConsole.top) <= 100 ) + { + rcConsole.top = 0; + rcConsole.bottom = 600; + } + + return rcConsole; + } + + //************************************************************************************************* // init Console I/O //************************************************************************************************* *************** *** 1248,1263 **** // get console window pos from registry ! char s[512] = ""; ! RegReadKey( "Console", s, sizeof(s) ); ! ! RECT pos; memset( &pos, 0, sizeof(pos) ); // bugfix for SF-Request ID 762961 July 2nd, 2003 - 17:51 dbu ! sscanf( (char *)&s, "%d,%d,%d,%d", &pos.left, &pos.top, &pos.right, &pos.bottom ); ! if( pos.bottom == 0 ) // if they have never been set, use defaults ! { ! pos.left = 3; ! pos.top = 3; ! pos.right = 634; ! pos.bottom = 474; ! } // Register main window class --- 1312,1316 ---- // get console window pos from registry ! RECT pos = GetConsolePos(); // Register main window class *************** *** 1296,1307 **** WindowTitle, // window caption WS_OVERLAPPEDWINDOW, // window style ! pos.left, ! pos.top, ! (pos.right - pos.left), ! (pos.bottom - pos.top), NULL, // parent window handle NULL, // window menu handle hInstance, // program instance handle ! NULL) ; // creation parameters return (int)hWndMain; --- 1349,1360 ---- WindowTitle, // window caption WS_OVERLAPPEDWINDOW, // window style ! pos.left, // window x-position ! pos.top, // window y-position ! pos.right - pos.left, // window width ! pos.bottom - pos.top, // window height NULL, // parent window handle NULL, // window menu handle hInstance, // program instance handle ! NULL ); // creation parameters return (int)hWndMain; |