// ======================================================================== // THIS TECHNICAL INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A // PARTICULAR PURPOSE. // // Copyright 1997-1998 Giuseppe "Jo" Parrello. All Rights Reserved. // // Site : http://space.tin.it/computer/giparrel // E-Mail : joparrel@tin.it, giusparr@tin.it, giparre@tin.it // // Bugs, Tips, and Deepenings. Only for 5.02 users (unless specified). // // May 16, 1998. // // ======================================================================== ----------------------------------------------------------------- ----- TI000008: (BUG on 5.00, 5.01 and 5.02 release) ------- ----------------------------------------------------------------- The TWindow::GetWindowPlacement function has a bug. You must modify the file "WINDOW.H" to solve it. Insert before the line return ::GetWindowPlacement(GetHandle(), place); the following line: place.length = sizeof(WINDOWPLACEMENT); As described on Win32 API Help File. ----------------------------------------------------------------- ----- TI000009: (BUG on 5.00, 5.01 and 5.02 release) ------- ----------------------------------------------------------------- The TWindow::SetWindowPlacement function has a bug. You must modify the file "WINDOW.H" to solve it. Insert before the line return ::SetWindowPlacement(GetHandle(), place); the following line: place.length = sizeof(WINDOWPLACEMENT); As described on Win32 API Help File. ----------------------------------------------------------------- ----- TI000010: (Borland C++ 5.01 e C++ 5.02) ------- ----------------------------------------------------------------- Q. How can I call my application passing it a filename? A. If you've used AppExpert to build your application, you must modify the "ProcessCmdLine" function on TApplication class. The code generated by AppExpert is: void TBUTTONApp::ProcessCmdLine(char * CmdLine) { TCmdLine cmd(CmdLine); while (cmd.Kind != TCmdLine::Done) { if (cmd.Kind == TCmdLine::Option) { if (strnicmp(cmd.Token, "unregister", cmd.TokenLen) == 0) { UnRegisterInfo(); return; } } } RegisterInfo(); } To add a simple command-line parser, you convert the code in this way: void TBUTTONApp::ProcessCmdLine(char * CmdLine) { TCmdLine cmd(CmdLine); char buf[_MAX_PATH]; while (cmd.Kind != TCmdLine::Done) { if (cmd.Kind == TCmdLine::Option) { if (strnicmp(cmd.Token, "unregister", cmd.TokenLen) == 0) { UnRegisterInfo(); return; } } if (cmd.Kind == TCmdLine::Name) { strncpy(buf, cmd.Token, cmd.TokenLen); buf[cmd.TokenLen] = '\0'; TDocTemplate* tpl = GetDocManager()->MatchTemplate(buf); if (tpl) GetDocManager()->CreateDoc(tpl, buf); } cmd.NextToken(true); } RegisterInfo(); } For example, if you pass the following line: myapp apxprev.cpp apxprint.cpp myapp.cpp these three files will be opened in your MDI application. NOTE: the function "ProcessCmdLine" is generated if you've included the AppExpert's "registry support" feature. ----------------------------------------------------------------- ----- TI000011: (Borland C++ 5.01 e C++ 5.02) ------- ----------------------------------------------------------------- Q. I have a maximized main window and I go to Print Preview Page. I maximize the Preview Page Window and when I go back the previous window is not maximized (it's in normal size). How can I solve this problem? A. If you used AppExpert to build your application, the code is: void MyappMDIClient::CmFilePrintPreview() { Myapp* theApp = TYPESAFE_DOWNCAST(GetApplication(), Myapp); if (theApp) { if (!theApp->Printer) theApp->Printer = new TPrinter(GetApplication()); theApp->Printing++; TApxPreviewWin* prevW = new TApxPreviewWin(Parent, theApp->Printer, GetActiveMDIChild()->GetClientWindow(), "Print Preview", new TLayoutWindow(0)); prevW->Create(); TFrameWindow * mainWindow = GetApplication()->GetMainWindow(); TRect r = mainWindow->GetWindowRect(); prevW->MoveWindow(r); prevW->ShowWindow(SW_SHOWNORMAL); mainWindow->ShowWindow(SW_HIDE); GetApplication()->BeginModal(GetApplication()->GetMainWindow()); r = prevW->GetWindowRect(); mainWindow->MoveWindow(r); mainWindow->ShowWindow(SW_SHOWNORMAL); prevW->Destroy(); delete prevW; theApp->Printing--; } } Change the code as follows: void MyappMDIClient::CmFilePrintPreview() { Myapp* theApp = TYPESAFE_DOWNCAST(GetApplication(), Myapp); if (theApp) { if (!theApp->Printer) theApp->Printer = new TPrinter(GetApplication()); theApp->Printing++; TApxPreviewWin* prevW = new TApxPreviewWin(Parent, theApp->Printer, GetActiveMDIChild()->GetClientWindow(), "Print Preview", new TLayoutWindow(0)); prevW->Create(); TFrameWindow * mainWindow = GetApplication()->GetMainWindow(); prevW->SetExStyle(prevW->GetExStyle() | WS_EX_APPWINDOW); WINDOWPLACEMENT mainPos; mainPos.length = sizeof(WINDOWPLACEMENT); // to solve a horrific bug on TWindow class mainWindow->GetWindowPlacement(&mainPos); prevW->SetWindowPlacement(&mainPos); mainWindow->ShowWindow(SW_HIDE); GetApplication()->BeginModal(GetApplication()->GetMainWindow()); mainPos.length = sizeof(WINDOWPLACEMENT); // to solve a horrific bug on TWindow class prevW->GetWindowPlacement(&mainPos); mainWindow->SetWindowPlacement(&mainPos); prevW->Destroy(); delete prevW; theApp->Printing--; } }