bool CCpDesktop::FirstInstance() { // Determine if another window with our class name or caption exists... CString strCaption; strCaption.LoadString(GetTitleId()); CWnd* pWndApp = CWnd::FindWindow(NULL, strCaption); if (!pWndApp) return true; // An instance of the app exists // Does it have any popups? CWnd* pPopupWnd = pWndApp->GetLastActivePopup(); // Bring the main window to the top pWndApp->BringWindowToTop(); pWndApp->SetForegroundWindow(); // If iconic, restore the main window if (pWndApp->IsIconic()) pWndApp->ShowWindow(SW_RESTORE); // If there was an active popup, bring it along too if (pPopupWnd && (pPopupWnd != pWndApp)) { pPopupWnd->BringWindowToTop(); pPopupWnd->SetForegroundWindow(); } return false; }
void CInPlaceFrame::RecalcLayout(BOOL bNotify) { if (m_wndResizeBar.m_hWnd != NULL) m_wndResizeBar.BringWindowToTop(); COleIPFrameWndEx::RecalcLayout(bNotify); CWnd* pWnd = GetActiveView(); if (pWnd != NULL) pWnd->BringWindowToTop(); if (m_wndRulerBar.m_hWnd != NULL) m_wndRulerBar.BringWindowToTop(); // at least 12 pt region plus ruler if it exists CDisplayIC dc; CSize size; size.cy = MulDiv(12, dc.GetDeviceCaps(LOGPIXELSY), 72)+1; size.cx = dc.GetDeviceCaps(LOGPIXELSX)/4; // 1/4" size.cx += HORZ_TEXTOFFSET; //adjust for offset size.cy += VERT_TEXTOFFSET; if (m_wndRulerBar.m_hWnd != NULL && m_wndRulerBar.IsVisible()) { CRect rect; m_wndRulerBar.GetWindowRect(&rect); size.cy += rect.Height(); } m_wndResizeBar.SetMinSize(size); }
void CDlgLog::OnBnClickedOk() { m_running = FALSE; CWnd * frm = ::AfxGetMainWnd(); frm->BringWindowToTop(); OnOK(); }
BOOL CWinAppSingle::OnAnotherInstanceMessage( LPMSG pMsg ) { // Get command line arguments (if any) from new instance. BOOL bShellOpen = FALSE; if( pMsg->wParam != NULL ) { ::GlobalGetAtomName( (ATOM)pMsg->wParam, m_lpCmdLine, _MAX_FNAME ); ::GlobalDeleteAtom( (ATOM)pMsg->wParam ); bShellOpen = TRUE; } // If got valid command line then try to open the document - // CDocManager will popup main window itself. Otherwise, we // have to popup the window 'manually' : if( m_pDocManager != NULL && bShellOpen ) { CWaitCursor wait; m_pDocManager->OpenDocumentFile( m_lpCmdLine ); } else if( ::IsWindow( m_pMainWnd->GetSafeHwnd() ) ) { // Does the main window have any popups ? If has, // bring the main window or its popup to the top // before showing: CWnd* pPopupWnd = m_pMainWnd->GetLastActivePopup(); pPopupWnd->BringWindowToTop(); // If window is not visible then show it, else if // it is iconic, restore it: if( !m_pMainWnd->IsWindowVisible() ) m_pMainWnd->ShowWindow( SW_SHOWNORMAL ); else if( m_pMainWnd->IsIconic() ) m_pMainWnd->ShowWindow( SW_RESTORE ); // And finally, bring to top after showing again: pPopupWnd->BringWindowToTop(); pPopupWnd->SetForegroundWindow(); } return TRUE; }
BOOL CMapMgrApp::FirstInstance() { CString strCaption; strCaption.LoadString(AFX_IDS_APP_TITLE); CWnd *pWndFirst = CWnd::FindWindow(NULL,strCaption); if( pWndFirst ) { CWnd *pWndPopup = pWndFirst->GetLastActivePopup(); pWndFirst->BringWindowToTop(); if(pWndFirst->IsIconic()) pWndFirst->ShowWindow(SW_SHOWNORMAL); if(pWndFirst != pWndPopup) pWndPopup->BringWindowToTop(); return FALSE; } return TRUE; }
void CInPlaceFrame::RepositionFrame(LPCRECT lpPosRect, LPCRECT lpClipRect) { CRect rectNew = lpPosRect; rectNew.left -= HORZ_TEXTOFFSET; rectNew.top -= VERT_TEXTOFFSET; m_wndResizeBar.BringWindowToTop(); COleIPFrameWndEx::RepositionFrame(&rectNew, lpClipRect); CWnd* pWnd = GetActiveView(); if (pWnd != NULL) pWnd->BringWindowToTop(); m_wndRulerBar.BringWindowToTop(); }
//----------------------------------------------------------------------------- // Purpose: Automagically bring this bar to the top when the mouse cursor passes // over it. // Input : pWnd - // nHitTest - // message - // Output : Always returns FALSE. //----------------------------------------------------------------------------- BOOL CHammerBar::OnSetCursor(CWnd *pWnd, UINT nHitTest, UINT message) { if (APP()->IsActiveApp()) { // The control bar window is actually our grandparent. CWnd *pwnd = GetParent(); if (pwnd != NULL) { pwnd = pwnd->GetParent(); if (pwnd != NULL) { pwnd->BringWindowToTop(); } } } //this wasn't being called and fixes some minor cursor problems. return CWnd::OnSetCursor( pWnd, nHitTest, message ); }
void CWindowListDlg::OnSelchangeWindowTabs(NMHDR* pNMHDR, LRESULT* pResult) { CWnd* pWnd = GetWnd(m_ctlWindowList.GetCurSel()); if (IsWindow(pWnd->m_hWnd)) { WINDOWPLACEMENT placement = { sizeof(WINDOWPLACEMENT) }; pWnd->GetWindowPlacement(&placement); if (placement.showCmd == SW_HIDE || placement.showCmd == SW_MINIMIZE || placement.showCmd == SW_SHOWMINIMIZED) { pWnd->ShowWindow(SW_SHOWNORMAL); } pWnd->BringWindowToTop(); } *pResult = 0; }
void CEx24dView::OnExceloleExecute() { LPDISPATCH pRange, pWorkbooks; CWnd* pWnd = CWnd::FindWindow("XLMAIN", NULL); if (pWnd != NULL) { TRACE("Excel window found\n"); pWnd->ShowWindow(SW_SHOWNORMAL); pWnd->UpdateWindow(); pWnd->BringWindowToTop(); } m_app.SetSheetsInNewWorkbook(1); VERIFY(pWorkbooks = m_app.GetWorkbooks()); m_workbooks.AttachDispatch(pWorkbooks); LPDISPATCH pWorkbook = NULL; if (m_workbooks.GetCount() == 0) { // Add returns a Workbook pointer, but we // don't have a Workbook class pWorkbook = m_workbooks.Add(); // Save the pointer for // later release } LPDISPATCH pWorksheets = m_app.GetWorksheets(); ASSERT(pWorksheets != NULL); m_worksheets.AttachDispatch(pWorksheets); LPDISPATCH pWorksheet = m_worksheets.GetItem(COleVariant((short) 1)); m_worksheet.AttachDispatch(pWorksheet); m_worksheet.Select(); VERIFY(pRange = m_worksheet.GetRange(COleVariant("A1"))); m_range[0].AttachDispatch(pRange); VERIFY(pRange = m_worksheet.GetRange(COleVariant("A2"))); m_range[1].AttachDispatch(pRange); VERIFY(pRange = m_worksheet.GetRange(COleVariant("A3"))); m_range[2].AttachDispatch(pRange); VERIFY(pRange = m_worksheet.GetRange(COleVariant("A3"), COleVariant("C5"))); m_range[3].AttachDispatch(pRange); VERIFY(pRange = m_worksheet.GetRange(COleVariant("A6"))); m_range[4].AttachDispatch(pRange); m_range[4].SetValue(COleVariant(COleDateTime(1994, 4, 24, 15, 47, 8))); // retrieve the stored date and print it as a string COleVariant vaTimeDate = m_range[4].GetValue(); TRACE("returned date type = %d\n", vaTimeDate.vt); COleVariant vaTemp; vaTemp.ChangeType(VT_BSTR, &vaTimeDate); CString str = vaTemp.bstrVal; TRACE("date = %s\n", (const char*) str); m_range[0].SetValue(COleVariant("test string")); COleVariant vaResult0 = m_range[0].GetValue(); if (vaResult0.vt == VT_BSTR) { CString str = vaResult0.bstrVal; TRACE("vaResult0 = %s\n", (const char*) str); } m_range[1].SetValue(COleVariant(3.14159)); COleVariant vaResult1 = m_range[1].GetValue(); if (vaResult1.vt == VT_R8) { TRACE("vaResult1 = %f\n", vaResult1.dblVal); } m_range[2].SetFormula(COleVariant("=$A2*2.0")); COleVariant vaResult2 = m_range[2].GetValue(); if (vaResult2.vt == VT_R8) { TRACE("vaResult2 = %f\n", vaResult2.dblVal); } COleVariant vaResult2a = m_range[2].GetFormula(); if (vaResult2a.vt == VT_BSTR) { CString str = vaResult2a.bstrVal; TRACE("vaResult2a = %s\n", (const char*) str); } m_range[3].FillRight(); m_range[3].FillDown(); // cleanup if (pWorkbook != NULL) { pWorkbook->Release(); } }
CPrivateChatFrame* CChatWindows::OpenPrivate(GGUID* pGUID, SOCKADDR_IN* pHost, BOOL bMustPush, PROTOCOLID nProtocol, SOCKADDR_IN* pServer) { CPrivateChatFrame* pFrame = NULL; ASSERT ( pHost != NULL ); if ( ( nProtocol == PROTOCOL_BT ) || ( nProtocol == PROTOCOL_FTP ) ) return NULL; if ( ! MyProfile.IsValid() ) { CString strMessage; LoadString( strMessage, IDS_CHAT_NEED_PROFILE ); if ( AfxMessageBox( strMessage, MB_YESNO|MB_ICONQUESTION ) == IDYES ) AfxGetMainWnd()->PostMessage( WM_COMMAND, ID_TOOLS_PROFILE ); return NULL; } if ( nProtocol == PROTOCOL_ED2K ) { CEDClient* pClient; // First, check if it's a low ID user on another server. if ( bMustPush && pServer ) { // It's a firewalled user (Low ID). If they are using another server, we // can't (shouldn't) contact them. (It places a heavy load on the ed2k servers) CSingleLock pLock1( &Network.m_pSection ); if ( ! pLock1.Lock( 250 ) ) return NULL; if ( Neighbours.Get( &pServer->sin_addr ) == NULL ) return NULL; pLock1.Unlock(); } // ED2K chat is handled by the EDClient section. (Transfers) // We need to find (or create) an EDClient to handle this chat session, since everything // on ed2k shares a TCP link. // First, lock the section to prevent a problem with other threads CSingleLock pLock( &Transfers.m_pSection ); if ( ! pLock.Lock( 250 ) ) return NULL; // We need to connect to them, so either find or create an EDClient if ( pServer ) pClient = EDClients.Connect(pHost->sin_addr.S_un.S_addr, pHost->sin_port, &pServer->sin_addr, pServer->sin_port, pGUID ); else pClient = EDClients.Connect(pHost->sin_addr.S_un.S_addr, pHost->sin_port, NULL, 0, pGUID ); // If we weren't able to create a client (Low-id and no server), then exit. if ( ! pClient ) return NULL; // Have it connect (if it isn't) if ( ! pClient->m_bConnected ) pClient->Connect(); // Tell it to start a chat session as soon as it's able pClient->OpenChat(); pLock.Unlock(); // Check for / make active any existing window pFrame = FindPrivate( &pHost->sin_addr ); // Check for an empty frame if ( pFrame == NULL ) { if ( bMustPush ) pFrame = FindED2KFrame( pHost->sin_addr.S_un.S_addr, pServer ); else pFrame = FindED2KFrame( pHost ); } if ( pFrame != NULL ) { // Open window if we found one CWnd* pParent = pFrame->GetParent(); if ( pParent->IsIconic() ) pParent->ShowWindow( SW_SHOWNORMAL ); pParent->BringWindowToTop(); pParent->SetForegroundWindow(); // And exit return pFrame; } // Open an empty (blank) chat frame. This is totally unnecessary- The EDClient will open // one as required, but it looks better to open one here. pFrame = new CPrivateChatFrame(); // Set name (Also used to match incoming connection) if ( bMustPush && pServer ) // Firewalled user (Low ID) { pFrame->m_sNick.Format( _T("%lu@%s:%hu"), pHost->sin_addr.S_un.S_addr, (LPCTSTR)CString( inet_ntoa( pServer->sin_addr ) ), pServer->sin_port ); } else // Regular user (High ID) { pFrame->m_sNick.Format( _T("%s:%hu"), (LPCTSTR)CString( inet_ntoa( pHost->sin_addr ) ), pHost->sin_port ); } // Open window CWnd* pParent = pFrame->GetParent(); if ( pParent->IsIconic() ) pParent->ShowWindow( SW_SHOWNORMAL ); pParent->BringWindowToTop(); pParent->SetForegroundWindow(); // Put a 'connecting' message in the window CString strMessage, strConnecting; LoadString( strConnecting, IDS_CHAT_CONNECTING_TO ); strMessage.Format( strConnecting, pFrame->m_sNick ); pFrame->OnStatusMessage( 0, strMessage ); return pFrame; } if ( pGUID != NULL ) pFrame = FindPrivate( pGUID ); if ( pFrame == NULL ) pFrame = FindPrivate( &pHost->sin_addr ); if ( pFrame == NULL ) { pFrame = new CPrivateChatFrame(); pFrame->Initiate( pGUID, pHost, bMustPush ); } pFrame->PostMessage( WM_COMMAND, ID_CHAT_CONNECT ); CWnd* pParent = pFrame->GetParent(); if ( pParent->IsIconic() ) pParent->ShowWindow( SW_SHOWNORMAL ); pParent->BringWindowToTop(); pParent->SetForegroundWindow(); return pFrame; }
BOOL CInputDoc::doRunProcessors(CRemoteCommand* pRemoteCmd/*=NULL*/) { CWnd* pWnd = getWindow(); if(pWnd) pWnd->BringWindowToTop(); if(IsModified()) // if changed the contents of the file we're processing OnSaveDocument(GetPathName()); CCarlaLanguage *pSourceLang = getProcessingPrefs()->getSrcLang(); // could be null CCarlaLanguage *pTargetLang = getProcessingPrefs()->getTarLang(); // could be null ASSERTX(m_strPathName.GetLength()); #define GOAL getProcessingPrefs()->getGoal() // on remote calls, we can override user prefs. Sorry this is all so ugly if(pRemoteCmd) { getProcessingPrefs()->setGoal(pRemoteCmd->iGoal); pSourceLang = pRemoteCmd->pSourceLang ; if(pSourceLang) getProcessingPrefs()->setSrcLang(pSourceLang); pTargetLang = pRemoteCmd->pTargetLang; if(pTargetLang) getProcessingPrefs()->setTarLang(pTargetLang); SetModifiedFlag(TRUE);// will also fix the title } // make the new status structure, which keeps track of which files have been // created and are in line for processing, among other things if(m_pProcessStatus) delete m_pProcessStatus; m_pProcessStatus = new CProcessStatus(m_strPathName, getProcessingPrefs(), pSourceLang, (pSourceLang!=0)?pSourceLang->getMFS():NULL, pTargetLang, (pTargetLang!=0)?pTargetLang->getMFS():NULL); //----- ask Shoebox, if it is running, to do a save all // note: if this was invoked by a call from CSRemote, then the send will hang us forever // thus, we have this bRemoteCall flag to prevent that. If we are called from // Shoebox, it will have saved everything anyways as part of its batch file command if(!pRemoteCmd) SendMessage(HWND_BROADCAST, wm_RemoteSaveAll, NULL, NULL); //------ SETUP THE TEMP DIRECTORY ---------------------- if( getCanDoAnalysis() || getProcessingPrefs()->getDoTransfer() || getProcessingPrefs()->getDoInterlinearize()) // JDH 5/28/99 Added to allow Interlinearizing ANA files { ASSERTX(pSourceLang); if (!m_pProcessStatus->setupTempDir(pSourceLang->getName())) return FALSE; } else // synthesis only { ASSERTX(pTargetLang); if (!m_pProcessStatus->setupTempDir(pTargetLang->getName())) return FALSE; } // load stuff that processors will commonly need, but which doesn't really // belong conceptually to the mfs into it, so that the processors can avoid // having to know about CCarlaLanguage just to get at the comment character, for example if(pSourceLang) pSourceLang->prepareMFSForProcessors(); if(pTargetLang) pTargetLang->prepareMFSForProcessors(); //---- SETUP PROGRESS BAR if( getCanDoAnalysis()) m_pProcessStatus->expectSequenceWithCount(getSrcLang()->getAnalysisSequence()->getProcessorCount()); if( getProcessingPrefs()->getDoInterlinearize()) m_pProcessStatus->expectSequenceWithCount(getSrcLang()->getInterlinearSequence()->getProcessorCount()); if(getProcessingPrefs()->getDoTransfer()) { CTransferProcessSequence* pTSeq = getSrcLang()->getTransferSequence( pTargetLang); if(pTSeq) m_pProcessStatus->expectSequenceWithCount(pTSeq->getProcessorCount()); } if(getProcessingPrefs()->getDoSynthesis()) // actually, i think you *always* have a synth seq { CSynthesisProcessSequence* pSSeq = getSrcLang()->getSynthesisSequence(); if(pSSeq) m_pProcessStatus->expectSequenceWithCount(pSSeq->getProcessorCount()); } //---- BRING THE CONTROL FILES UP TO DATE ON THE DISK theApp.getProject()->synchronizeExternals(); //---- ANALYSIS ---------------------------------------------------------- BOOL bOK = TRUE; if( getCanDoAnalysis()) { CProcessSequence* pAnalysisSequence = getSrcLang()->getAnalysisSequence(); m_pProcessStatus->setCurrentSequenceFunction(pAnalysisSequence->getFunctionCode()); m_pProcessStatus->setInputLang(pSourceLang); m_pProcessStatus->setOutputLang(NULL); // do the analysis bOK = pAnalysisSequence->continueProcessing(m_pProcessStatus); // copy the analyzed text to the user's directory if(bOK ) { CPathDescriptor newPath(pSourceLang->getMFS()->getOutputDirAnalyzedANA()+m_pProcessStatus->m_sFileNameRoot+".ana"); redirectOutputFile(GOAL, CProcessingPrefs::kSourceAna, m_pProcessStatus->sANAPath, newPath, m_pProcessStatus); } } //---- INTERLINEAR ---------------------------------------------------------- if(bOK && getProcessingPrefs()->getDoInterlinearize()) { ASSERTX(pSourceLang); CProcessSequence* pS = pSourceLang->getInterlinearSequence(); ASSERTX(pS); m_pProcessStatus->setInputLang(pSourceLang); #ifndef hab15a4 m_pProcessStatus->setOutputLang(pSourceLang); // hab 1999.09.17 // a final CC pass will use the Output Language; // it needs to be set to the Source lang here (at least it worked for me...) #else m_pProcessStatus->setOutputLang(NULL); #endif m_pProcessStatus->setCurrentSequenceFunction(pS->getFunctionCode()); bOK = pS->continueProcessing(m_pProcessStatus); if(bOK )//&& GOAL==CProcessingPrefs::kGlossedInterlinear) { CString sDestDir; CPathDescriptor newPath ; if(pRemoteCmd) { switch(pRemoteCmd->eOutputLocation) { case CRemoteCommand::csSameFolderAsInput: sDestDir = ::getDirectory(m_strPathName); break; case CRemoteCommand::csSpecifiedPath: case CRemoteCommand::csReplaceInput: newPath = pRemoteCmd->sDesiredOutputPath; break; default: throw("Unknown OutputLocation setting"); break; } } else if(getProcessingPrefs()->m_dwFlags & CProcessingPrefs::kOutputItxToSameDir) // for morris sDestDir = ::getDirectory(m_strPathName); else // copy to interlinear output dir sDestDir = pSourceLang->getMFS()->getOutputDirInterlinear(); if(newPath.GetLength() == 0) newPath = sDestDir+m_pProcessStatus->m_sFileNameRoot+".itx"; //m_pProcessStatus->sInterlinearPath.copyTo(newPath); redirectOutputFile(GOAL, CProcessingPrefs::kGlossedInterlinear, m_pProcessStatus->sInterlinearPath, newPath, m_pProcessStatus); if(pRemoteCmd) pRemoteCmd->sActualOutputPath=newPath; } } //---- TRANSFER ---------------------------------------------------------- if(bOK && getProcessingPrefs()->getDoTransfer()) { //CCarlaLanguage* pTarget = getProcessingPrefs()->getTarLang(); ASSERTX(pTargetLang); CTransferProcessSequence* pTransferSequence = getSrcLang()->getTransferSequence(pTargetLang); ASSERTX(pTransferSequence); m_pProcessStatus->setInputLang(pSourceLang); m_pProcessStatus->setOutputLang(pTargetLang); m_pProcessStatus->setCurrentSequenceFunction(pTransferSequence->getFunctionCode()); bOK = pTransferSequence->continueProcessing(m_pProcessStatus); if(bOK )//&& GOAL==CProcessingPrefs::kTargetANA) { //CPathDescriptor x = pTargetLang->getMFS()->getOutputDirTransferedANA(); //CString z = "s" + x + "v"; CPathDescriptor newPath(pTargetLang->getMFS()->getOutputDirTransferedANA()+m_pProcessStatus->m_sFileNameRoot+".ana"); redirectOutputFile(GOAL, CProcessingPrefs::kTargetANA, m_pProcessStatus->sANAPath, newPath, m_pProcessStatus); //m_pProcessStatus->sANAPath.copyTo(pTargetLang->getMFS()->getOutputDirTransferedANA()+m_pProcessStatus->m_sFileNameRoot+".ana"); if(pRemoteCmd) pRemoteCmd->sActualOutputPath=newPath; } } //---- SYNTHESIS ---------------------------------------------------------- if(bOK && getProcessingPrefs()->getDoSynthesis()) { ASSERTX(pTargetLang); //CCarlaLanguage* pTarget = getProcessingPrefs()->getTarLang(); CProcessSequence* pS = pTargetLang->getSynthesisSequence(); ASSERTX(pS); #ifndef hab15a4 m_pProcessStatus->setInputLang(pTargetLang); // hab 1999.09.17 // a final CC pass will use the Input Language; // it needs to be set to the Target lang here (at least it worked for me...) #else m_pProcessStatus->setInputLang(NULL); #endif m_pProcessStatus->setOutputLang(pTargetLang); m_pProcessStatus->setCurrentSequenceFunction(pS->getFunctionCode()); bOK = pS->continueProcessing(m_pProcessStatus); // copy the synthesized text to the user's directory if(bOK)// && GOAL==CProcessingPrefs::kTargetText) { CPathDescriptor newPath; CString sDestDir; if(pRemoteCmd) { switch(pRemoteCmd->eOutputLocation) { case CRemoteCommand::csSameFolderAsInput: sDestDir = ::getDirectory(m_strPathName); break; case CRemoteCommand::csSpecifiedPath: newPath = pRemoteCmd->sDesiredOutputPath; break; // this case now allowed by csbridge, but would be if they scripted directly case CRemoteCommand::csReplaceInput: throw("Whoops. You probably didn't mean to say that CStudio should do a transfer that overwrites the initial file."); break; default: throw("Unknown OutputLocation setting"); break; } } else sDestDir = pTargetLang->getMFS()->getOutputDirSynthesizedText(); if(newPath.GetLength() == 0) newPath = sDestDir+m_pProcessStatus->m_sFileNameRoot+"_"+pTargetLang->getAbrev()+".txt"; redirectOutputFile(GOAL, CProcessingPrefs::kTargetText, m_pProcessStatus->sRAWPath, newPath, m_pProcessStatus); if(pRemoteCmd) pRemoteCmd->sActualOutputPath=newPath; } } if(bOK) m_pProcessStatus->finishedProcessing(); storeAvailablePanels(); loadResultPanels(bOK, m_pProcessStatus); // don't warn about missing files if there was an error already reported m_pProcessStatus->closeProgressDialog(); ASSERTX(m_pView); //!!!!!!!WHO'S SETTING THIS? m_pView->updatePanels(); #ifndef rde265 //----- ask Shoebox, to refresh all (if this isn't a remote command) if(!pRemoteCmd) #else //----- ask Shoebox, if it is running, to do a save all #endif // rde265 PostMessage(HWND_BROADCAST, wm_RemoteRefreshAll, NULL, NULL); // don't wait for it to finish that return bOK; }
void CWindowListDlg::OnContextMenu(CWnd*, CPoint point) { CPoint ptClient(point); m_ctlWindowList.ScreenToClient(&ptClient); TCHITTESTINFO info; info.flags = TCHT_ONITEM; info.pt = ptClient; int nIndex = m_ctlWindowList.HitTest(&info); CWnd* pWnd = NULL; if (nIndex != -1) { CMenu menu; menu.LoadMenu(IDR_WNDLIST_RCLICK); CMenu *pMenu = menu.GetSubMenu(0); ASSERT(pMenu != NULL); WINDOWPLACEMENT placement = { sizeof(WINDOWPLACEMENT) }; pWnd = GetWnd(nIndex); pWnd->GetWindowPlacement(&placement); if (placement.showCmd == SW_HIDE) { menu.EnableMenuItem(ID_WNDLIST_CLOSE, MF_BYCOMMAND | MF_GRAYED); } else if (placement.showCmd == SW_SHOWMAXIMIZED) { menu.EnableMenuItem(ID_WNDLIST_MAX, MF_BYCOMMAND | MF_GRAYED); } else if (placement.showCmd == SW_SHOWMINIMIZED) { menu.EnableMenuItem(ID_WNDLIST_MIN, MF_BYCOMMAND | MF_GRAYED); } else if (m_ctlWindowList.GetCurSel() == nIndex) { menu.EnableMenuItem(ID_WNDLIST_SHOW, MF_BYCOMMAND | MF_GRAYED); } pWnd->GetWindowPlacement(&placement); int res = pMenu->TrackPopupMenu( (TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD), point.x, point.y, this); switch(res) { case ID_WNDLIST_CLOSE: pWnd->PostMessage(WM_CLOSE); break; case ID_WNDLIST_MAX: placement.showCmd = SW_SHOWMAXIMIZED; pWnd->SetWindowPlacement(&placement); break; case ID_WNDLIST_MIN: placement.showCmd = SW_SHOWMINIMIZED; pWnd->SetWindowPlacement(&placement); break; case ID_WNDLIST_SHOW: pWnd->ShowWindow(SW_SHOWNORMAL); pWnd->BringWindowToTop(); break; } } }
//--------------------------------------------------------------------------- BOOL ReportView::OnPreparePrinting(CPrintInfo* pInfo) { if(pInfo->m_bPreview) { return this->DoPreparePrinting(pInfo); } //if(!mPrintMultiple) { pInfo->m_bDirect = this->mPrintDirect; this->GetParentFrame()->SetActiveWindow(); this->GetParentFrame()->BringWindowToTop(); //this->SetActiveWindow(); //this->BringWindowToTop(); return this->DoPreparePrinting(pInfo); //} // printing from print multiple reports C_Main_Frame* lMainFramePtr = MainFramePtr(); if (mDibViewPtr == NULL) { mDibViewPtr = lMainFramePtr->Create_Dib_Window(); } CWnd* lFramePtr = this->GetParent(); ASSERT( lFramePtr != NULL ); //--- Save existing placement --- WINDOWPLACEMENT lSavePlacement; lFramePtr->GetWindowPlacement( & lSavePlacement ); //--- Compute and set print placement --- /*lFramePtr->ShowWindow( SW_RESTORE ); this->ResizeParentToFit( FALSE );*/ WINDOWPLACEMENT lPrintPlacement; lFramePtr->GetWindowPlacement( & lPrintPlacement ); // JTK - Commented out to fix print preview issue /*lPrintPlacement.rcNormalPosition.right -= lPrintPlacement.rcNormalPosition.left; lPrintPlacement.rcNormalPosition.bottom -= lPrintPlacement.rcNormalPosition.top ; lPrintPlacement.rcNormalPosition.left = 0; lPrintPlacement.rcNormalPosition.top = 0; lFramePtr->MoveWindow(&lPrintPlacement.rcNormalPosition); lFramePtr->SetWindowPlacement( & lPrintPlacement );*/ //--- Create the DIB --- lFramePtr->SetActiveWindow(); lFramePtr->BringWindowToTop(); lFramePtr->UpdateWindow(); mDibViewPtr->LoadDib(lFramePtr); //--- Call normal printing --- pInfo->m_bDirect = mPrintDirect; BOOL lPrintResult = mDibViewPtr->OnPreparePrinting( pInfo ); //--- Restore the window --- lFramePtr->SetWindowPlacement( & lSavePlacement ); lFramePtr->ShowWindow( lSavePlacement.showCmd ); lFramePtr->UpdateWindow(); return lPrintResult; }