// walk up two parents for MDIFrame that owns MDIChild (skip MDIClient) CMDIFrameWnd* CMDIChildWnd::GetMDIFrame() { ASSERT_KINDOF(CMDIChildWnd, this); ASSERT(m_hWnd != NULL); HWND hWndMDIClient = ::GetParent(m_hWnd); ASSERT(hWndMDIClient != NULL); CMDIFrameWnd* pMDIFrame; pMDIFrame = (CMDIFrameWnd*)CWnd::FromHandle(::GetParent(hWndMDIClient)); ASSERT(pMDIFrame != NULL); ASSERT_KINDOF(CMDIFrameWnd, pMDIFrame); ASSERT(pMDIFrame->m_hWndMDIClient == hWndMDIClient); ASSERT_VALID(pMDIFrame); return pMDIFrame; }
void CLibraryMetaPanel::OnLButtonUp(UINT nFlags, CPoint point) { point.y += GetScrollPos( SB_VERT ); if ( m_nSelected > 0 && m_rcFolder.PtInRect( point ) ) { CQuickLock oLock( Library.m_pSection ); if ( CLibraryFolder* pFolder = LibraryFolders.GetFolder( m_sFolder ) ) { if ( Settings.Library.ShowVirtual ) { CLibraryFrame* pFrame = (CLibraryFrame*)GetOwner(); ASSERT_KINDOF(CLibraryFrame, pFrame ); pFrame->Display( pFolder ); } else if ( LibraryFolders.CheckFolder( pFolder, TRUE ) ) { ShellExecute( AfxGetMainWnd()->GetSafeHwnd(), NULL, m_sFolder, NULL, NULL, SW_SHOWNORMAL ); } } } else if ( m_nSelected > 0 && m_rcRating.PtInRect( point ) ) { CLibraryListPtr pList( GetViewSelection() ); if ( pList && pList->GetCount() > 0 ) { CFilePropertiesSheet dlg; dlg.Add( pList ); dlg.DoModal( 2 ); } } else if ( CMetaItem* pItem = m_pMetadata->HitTest( point, TRUE ) ) { CQuickLock oLock( Library.m_pSection ); if ( CAlbumFolder* pFolder = pItem->GetLinkTarget() ) { CLibraryFrame* pFrame = (CLibraryFrame*)GetOwner(); ASSERT_KINDOF(CLibraryFrame, pFrame ); pFrame->Display( pFolder ); } } CPanelCtrl::OnLButtonUp( nFlags, point ); }
BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) { ASSERT(pContext != NULL && pContext->m_pNewViewClass != NULL); if (!splitter_.CreateStatic(this, 1, 5)) { AfxMessageBox("Failed to create splitter."); return FALSE; } // We create with 5 columns then delete all except one, which means only one (for // hex view) is shown but 4 more can be added (template, aerial, preview and compare views). splitter_.DelColumn(4); splitter_.DelColumn(3); splitter_.DelColumn(2); splitter_.DelColumn(1); if (!splitter_.CreateView(0, 0, RUNTIME_CLASS(CHexTabView), CSize(0, 0), pContext)) { AfxMessageBox("Failed to create splitter view."); return FALSE; } ptv_ = (CHexTabView *)splitter_.GetPane(0, 0); ASSERT_KINDOF(CHexTabView, ptv_); return TRUE; }
STDMETHODIMP COleUILinkInfo::UpdateLink( DWORD dwLink, BOOL /*fErrorMessage*/, BOOL /*fErrorAction*/) { COleClientItem* pItem = (COleClientItem*)dwLink; ASSERT_VALID(pItem); ASSERT_KINDOF(COleClientItem, pItem); SCODE sc; TRY { // link not up-to-date, attempt to update it if (!pItem->UpdateLink()) AfxThrowOleException(pItem->GetLastStatus()); pItem->m_bLinkUnavail = FALSE; sc = S_OK; } CATCH_ALL(e) { pItem->m_bLinkUnavail = TRUE; sc = COleException::Process(e); pItem->ReportError(sc); DELETE_EXCEPTION(e); } END_CATCH_ALL return sc; }
////////////////// // Handle WM_NCACTIVATE for main window // BOOL CCaptionPainter::OnNcActivate(BOOL bActive) { ASSERT_VALID(m_pParentDlg); CDialog& dlg = *((CDialog*)m_pParentDlg); ASSERT_KINDOF(CDialog, &dlg); /* // Turn WS_VISIBLE off before calling DefWindowProc, // so DefWindowProc won't paint and thereby cause flicker. // DWORD dwStyle = dlg.GetStyle(); if (dwStyle & WS_VISIBLE) ::SetWindowLong(dlg, GWL_STYLE, (dwStyle & ~ WS_VISIBLE)); MSG& msg = AfxGetThreadState()->m_lastSentMsg; msg.wParam = bActive; Default(); if (dwStyle & WS_VISIBLE) ::SetWindowLong(frame, GWL_STYLE, dwStyle); */ // At this point, nothing has happened (since WS_VISIBLE was off). // Now it's time to paint. // m_bActive = bActive; // update state dlg.SendMessage(WM_NCPAINT); // paint non-client area (frame too) return TRUE; // done OK }
LRESULT COleIPFrameWnd::OnResizeChild(WPARAM, LPARAM lParam) { // notify the container that the rectangle has changed! COleServerDoc* pDoc = (COleServerDoc*)GetActiveDocument(); if (pDoc == NULL) return 0; ASSERT_KINDOF(COleServerDoc, pDoc); // get new rect and parent CRect rectNew; rectNew.CopyRect((LPCRECT)lParam); CWnd* pParentWnd = GetParent(); ASSERT_VALID(pParentWnd); // convert rectNew relative to pParentWnd ClientToScreen(&rectNew); pParentWnd->ScreenToClient(&rectNew); // adjust the new rectangle for the current control bars CWnd* pLeftOver = GetDlgItem(AFX_IDW_PANE_FIRST); ASSERT(pLeftOver != NULL); CRect rectCur = m_rectPos; pLeftOver->CalcWindowRect(&rectCur, CWnd::adjustOutside); rectNew.left += m_rectPos.left - rectCur.left; rectNew.top += m_rectPos.top - rectCur.top; rectNew.right -= rectCur.right - m_rectPos.right; rectNew.bottom -= rectCur.bottom - m_rectPos.bottom; OnRequestPositionChange(rectNew); return 0; }
BOOL CGlobalObj::bOpenFunctioneditorfile(CString omStrNewCFileName) { BOOL bFileFound = TRUE; CFunctionEditorDoc* pDoc = CFunctionEditorBase::pCreateNewDocument(m_eBus); // file-attribute information if (pDoc != nullptr) { CEditFrameWnd::sm_eBus = m_eBus; struct _tfinddata_t fileinfo; // Check if file exists if (_tfindfirst( omStrNewCFileName.GetBuffer(MAX_PATH), &fileinfo) == -1L) { bFileFound = pDoc->bCreateNewDocument(omStrNewCFileName); } if (bFileFound == TRUE) { //// Now open the selected file pDoc->OnOpenDocument(omStrNewCFileName); CMultiDocTemplate* pTemplate = m_pEditorDocTemplate; m_pEditFrameWnd = (CEditFrameWnd*)(pTemplate->CreateNewFrame(pDoc, nullptr)); //If null is passed as parameter the m_pdoc->GetNextView(pos) will // give null value if (m_pEditFrameWnd != nullptr) { ASSERT_KINDOF(CEditFrameWnd, m_pEditFrameWnd); pTemplate->InitialUpdateFrame(m_pEditFrameWnd, /*nullptr*/pDoc); } } } return bFileFound; }
void CBasePropertySheet::AddPage(CPropertyPage* pPage) { ASSERT_VALID(this); ASSERT(pPage != NULL); ASSERT_KINDOF(CPropertyPage, pPage); ASSERT_VALID(pPage); // add page to internal list m_pages.Add(pPage); // add page externally if (m_hWnd != NULL) { // build new prop page array AFX_OLDPROPSHEETPAGE *ppsp = new AFX_OLDPROPSHEETPAGE[m_pages.GetSize()]; memcpy(ppsp, m_psh.ppsp, sizeof(AFX_OLDPROPSHEETPAGE) * (m_pages.GetSize()-1)); delete[] (PROPSHEETPAGE*)m_psh.ppsp; m_psh.ppsp = (PROPSHEETPAGE*)ppsp; ppsp += m_pages.GetSize()-1; // copy processed PROPSHEETPAGE struct to end memcpy(ppsp, &pPage->m_psp, sizeof(pPage->m_psp)); // pPage->PreProcessPageTemplate((PROPSHEETPAGE&)*ppsp, IsWizard()); CPropertyPage_PreProcessPageTemplate((_CCPropertyPage*)pPage, (PROPSHEETPAGE&)*ppsp, IsWizard()); HPROPSHEETPAGE hPSP = CreatePropertySheetPage((PROPSHEETPAGE*)ppsp); if (hPSP == NULL) AfxThrowMemoryException(); if (!SendMessage(PSM_ADDPAGE, 0, (LPARAM)hPSP)) { DestroyPropertySheetPage(hPSP); AfxThrowMemoryException(); } } }
CBenubirdAutoProxy::CBenubirdAutoProxy() { g_strDBG.Empty(); g_strDBG.Format(_T("------------------------------------- start AutoProxy %X"),this); OutputDebugString(g_strDBG); EnableAutomation(); // To keep the application running as long as an automation // object is active, the constructor calls AfxOleLockApp. AfxOleLockApp(); // Get access to the dialog through the application's // main window pointer. Set the proxy's internal pointer // to point to the dialog, and set the dialog's back pointer to // this proxy. ASSERT_VALID(AfxGetApp()->m_pMainWnd); if (AfxGetApp()->m_pMainWnd) { ASSERT_KINDOF(CMainFrame, AfxGetApp()->m_pMainWnd); if (AfxGetApp()->m_pMainWnd->IsKindOf(RUNTIME_CLASS(CMainFrame))) { m_pDialog = reinterpret_cast<CMainFrame*>(AfxGetApp()->m_pMainWnd); m_pDialog->m_pAutoProxy = this; } } }
void CListViewWalkerPropertySheet::InsertPage(int iIndex, CPropertyPage* pPage) { ASSERT_VALID( this ); ASSERT( pPage != NULL ); ASSERT_KINDOF( CPropertyPage, pPage ); ASSERT_VALID( pPage ); m_pages.InsertAt(iIndex, pPage); BuildPropPageArray(); if (m_hWnd != NULL) { PROPSHEETPAGE* ppsp = const_cast<PROPSHEETPAGE*>(m_psh.ppsp); for (UINT i = 0; i < m_psh.nPages; i++) { if (i == (UINT)iIndex) break; (BYTE*&)ppsp += ppsp->dwSize; } HPROPSHEETPAGE hPSP = CreatePropertySheetPage(ppsp); if (hPSP == NULL) AfxThrowMemoryException(); if (!SendMessage(PSM_INSERTPAGE, iIndex, (LPARAM)hPSP)) { DestroyPropertySheetPage(hPSP); AfxThrowMemoryException(); } } }
void CServerDoc::OnSetItemRects(LPCRECT lpPosRect, LPCRECT lpClipRect) { // get first view of document POSITION pos = GetFirstViewPosition(); ASSERT(pos != NULL); CServerView* pView = (CServerView*)GetNextView(pos); ASSERT_KINDOF(CServerView, pView); ASSERT_VALID(pView); CSize sizeNum(lpPosRect->right - lpPosRect->left, lpPosRect->bottom - lpPosRect->top); // for denom -- get extent in device // create a view dc CServerDC dc(pView); // set zoom to 100% dc.SetViewportExt(CSize(1,1)); dc.SetWindowExt(CSize(1,1)); // get extents in device CSize sizeDenom = pView->CalcActualItemSize(m_pRoot, &dc); // notify first view of potential zoom factor change! pView->SetZoomFactor(sizeNum, sizeDenom); // resize the window COleServerDoc::OnSetItemRects(lpPosRect, lpClipRect); // set scrollbar state (if necessary) pView->SetScrollInfo(); }
///////////////////////////////////////////////////////////////////////////// // CNewProjectEndPage message handlers BOOL CNewProjectEndPage::OnSetActive() { CPropertySheet* pSheet = (CPropertySheet*)GetParent(); ASSERT_KINDOF(CPropertySheet, pSheet); pSheet->SetWizardButtons(PSWIZB_FINISH); return CPropertyPageEx::OnSetActive(); }
void CDrawObj::Serialize(CArchive& ar) { CObject::Serialize(ar); if (ar.IsStoring()) { ar << m_position; ar << (WORD)m_bPen; ar.Write(&m_logpen, sizeof(LOGPEN)); ar << (WORD)m_bBrush; ar.Write(&m_logbrush, sizeof(LOGBRUSH)); } else { // get the document back pointer from the archive m_pDocument = (CDrawDoc*)ar.m_pDocument; ASSERT_VALID(m_pDocument); ASSERT_KINDOF(CDrawDoc, m_pDocument); WORD wTemp; ar >> m_position; ar >> wTemp; m_bPen = (BOOL)wTemp; ar.Read(&m_logpen,sizeof(LOGPEN)); ar >> wTemp; m_bBrush = (BOOL)wTemp; ar.Read(&m_logbrush, sizeof(LOGBRUSH)); } }
BOOL CBCGPDropDownToolBar::OnSendCommand(const CBCGPToolbarButton* pButton) { ASSERT_VALID (pButton); if ((pButton->m_nStyle & TBBS_DISABLED) != 0 || pButton->m_nID == 0 || pButton->m_nID == (UINT)-1) { return FALSE; } CBCGPDropDownFrame* pParent = (CBCGPDropDownFrame*)GetParent(); ASSERT_KINDOF(CBCGPDropDownFrame, pParent); pParent->m_pParentBtn->SetDefaultCommand (pButton->m_nID); //---------------------------------- // Send command to the parent frame: //---------------------------------- CFrameWnd* pParentFrame = GetParentFrame (); ASSERT_VALID (pParentFrame); GetOwner()->PostMessage(WM_COMMAND, pButton->m_nID); pParentFrame->DestroyWindow (); return TRUE; }
BOOL CLicenseDlg::OnSetActive() { if (!CheckWindowsVersion()) { CPropertyPage::EndDialog(IDCANCEL); } CPropertySheet* pSheet = (CPropertySheet*)GetParent(); ASSERT_KINDOF(CPropertySheet, pSheet); if (m_FirstTime) { m_FirstTime = FALSE; // Disable everything until the user scrolls the license text CButton *radio_all = (CButton *) GetDlgItem(IDC_DISAGREE); radio_all->SetCheck(1); CButton *understand = (CButton *) GetDlgItem(IDC_UNDERSTAND); understand->SetCheck(BST_UNCHECKED); OnUnderstand(); understand->EnableWindow(FALSE); pSheet->SetWizardButtons(0); UpdateData(FALSE); // write to screen } else { pSheet->SetWizardButtons(PSWIZB_NEXT); } return CPropertyPage::OnSetActive(); }
LRESULT CDibView::OnDoRealize(WPARAM wParam, LPARAM) { ASSERT(wParam != NULL); CDibDoc* pDoc = GetDocument(); if (pDoc->GetHDIB() == NULL) return 0L; // must be a new document CPalette* pPal = pDoc->GetDocPalette(); if (pPal != NULL) { CMainFrame* pAppFrame = (CMainFrame*) AfxGetApp()->m_pMainWnd; ASSERT_KINDOF(CMainFrame, pAppFrame); CClientDC appDC(pAppFrame); // All views but one should be a background palette. // wParam contains a handle to the active view, so the SelectPalette // bForceBackground flag is FALSE only if wParam == m_hWnd (this view) CPalette* oldPalette = appDC.SelectPalette(pPal, ((HWND)wParam) != m_hWnd); if (oldPalette != NULL) { UINT nColorsChanged = appDC.RealizePalette(); if (nColorsChanged > 0) pDoc->UpdateAllViews(NULL); appDC.SelectPalette(oldPalette, TRUE); } else { TRACE0("\tSelectPalette failed in CDibView::OnPaletteChanged\n"); } } return 0L; }
UINT CThread::ThreadProc(LPVOID pObject) { ASSERT(pObject); ASSERT_KINDOF(CThread, (CObject *)pObject); CThread *pThread = (CThread *)pObject; // initialisieren, ausführen, aufräumen if (pThread->InitInstance()) pThread->Run(); UINT nResult = pThread->ExitInstance(); // den tatsächlich gelieferten Exit-Code setzen pThread->SetExitCode(nResult); pThread->m_pWinThread = NULL; // zerstört sich selbst HANDLE hThreadStoppedEvent = pThread->m_hThreadStoppedEvent; // Thread-Objekt ggf. automatisch zerstören if (pThread->m_bAutoDelete) delete pThread; // Beendigungs-Event setzen; setzt alle Threads fort, die in Join() warten VERIFY(SetEvent(hThreadStoppedEvent)); return nResult; }
void OTag::Serialize(CArchive& ar) { if (ar.IsStoring()) { ar << name; ar << description; ar << enableProcessing; ar << nativeType; ar << active; ar.SerializeClass(RUNTIME_CLASS(OAnalogData)); pProcess->Serialize(ar); } else { UINT version = ar.m_nObjectSchema; ASSERT_KINDOF( CDoc, ar.m_pDocument ); ar >> name; ar >> description; ar >> enableProcessing; ar >> nativeType; ar >> active; value.ChangeType( nativeType ); ar.SerializeClass(RUNTIME_CLASS(OAnalogData)); pProcess->Serialize(ar); } }
void CImageView::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default //SetCapture();viewfeatures==true CImageDoc*pDoc=GetDocument(); CString rid,rs,rnc; if(pDoc->m_HC.GetSetSize()) { CClientDC dc(this); OnPrepareDC(&dc); dc.DPtoLP(&point); int miss=pDoc->lookregion(point.x,point.y,1); // pDoc->curRegion=miss; rid.Format("ID:%d",miss); // rs.Format("%d",pDoc->m_HC.S[miss].size); // rnc.Format("%d",pDoc->m_HC.S[miss].perim); } CMainFrame* pMainFrame= (CMainFrame*)( AfxGetApp()->m_pMainWnd); ASSERT_KINDOF(CMainFrame, pMainFrame); pMainFrame->m_wndStatusBar.SetPaneText(PANE_REGION_ID, rid); // pMainFrame->m_wndStatusBar.SetPaneText(PANE_REGION_SIZE, rs); // pMainFrame->m_wndStatusBar.SetPaneText(PANE_RN_COUNT, rnc); CScrollView::OnLButtonDown(nFlags, point); Invalidate(); }
///////////////////////////////////////////////////////////////////////////// // CSettingsDialog::CreateWnd(CWnd *pWnd, CCreateContext *pContext /* = NULL */) // Description: Create generic CWnd based Window of a page // Return value: TRUE if successful, NULL if failed // BOOL CSettingsDialog::CreateWnd(CWnd *pWnd, CCreateContext *pContext /* = NULL */) { CCreateContext context; if (pContext == NULL) { // If no context specified, generate one from the currently selected // client if possible context.m_pCurrentFrame = (CFrameWnd*) this; context.m_pCurrentDoc = NULL; context.m_pNewViewClass = NULL; pContext = &context; } ASSERT_KINDOF(CWnd, pWnd); ASSERT(pWnd->m_hWnd == NULL); // Not yet created DWORD dwStyle = AFX_WS_DEFAULT_VIEW; CRect rect; // Create with the right size and position if (!pWnd->Create(NULL, NULL, dwStyle, rect, this, 0, pContext)) { TRACE0("Warning: couldn't create wnd in CSettingsDialog.\n"); // pWnd will be cleaned up by PostNcDestroy return FALSE; } return(TRUE); }
void AFXAPI _AfxAppendFilterSuffix(CString& filter, OPENFILENAME& ofn, CDocTemplate* pTemplate, CString* pstrDefaultExt) { ASSERT_VALID(pTemplate); ASSERT_KINDOF(CDocTemplate, pTemplate); CString strFilterExt, strFilterName; if (pTemplate->GetDocString(strFilterExt, CDocTemplate::filterExt) && !strFilterExt.IsEmpty() && pTemplate->GetDocString(strFilterName, CDocTemplate::filterName) && !strFilterName.IsEmpty()) { // a file based document template - add to filter list ASSERT(strFilterExt[0] == '.'); if (pstrDefaultExt != NULL) { // set the default extension *pstrDefaultExt = ((LPCTSTR)strFilterExt) + 1; // skip the '.' ofn.lpstrDefExt = (LPTSTR)(LPCTSTR)(*pstrDefaultExt); ofn.nFilterIndex = ofn.nMaxCustFilter + 1; // 1 based number } // add to filter filter += strFilterName; ASSERT(!filter.IsEmpty()); // must have a file type name filter += (TCHAR)'\0'; // next string please filter += (TCHAR)'*'; filter += strFilterExt; filter += (TCHAR)'\0'; // next string please ofn.nMaxCustFilter++; } }
CMDIChildWnd* CMDIFrameWnd::CreateNewChild(CRuntimeClass* pClass, UINT nResources, HMENU hMenu /* = NULL */, HACCEL hAccel /* = NULL */) { ASSERT(pClass != NULL); CMDIChildWnd* pFrame = (CMDIChildWnd*) pClass->CreateObject(); ASSERT_KINDOF(CMDIChildWnd, pFrame); // load the frame CCreateContext context; context.m_pCurrentFrame = this; pFrame->SetHandles(hMenu, hAccel); if (!pFrame->LoadFrame(nResources, WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL, &context)) { TRACE(traceAppMsg, 0, "Couldn't load frame window.\n"); return NULL; } CString strFullString, strTitle; if (strFullString.LoadString(nResources)) AfxExtractSubString(strTitle, strFullString, CDocTemplate::docName); // redraw the frame and parent pFrame->SetTitle(strTitle); pFrame->InitialUpdateFrame(NULL, TRUE); return pFrame; }
BOOL CEncryptWiz_3::OnSetActive() { // TODO: Add your specialized code here and/or call the base class CPropertySheet* pSheet = (CPropertySheet*)GetParent(); ASSERT_KINDOF(CPropertySheet, pSheet); pSheet->SetWizardButtons(PSWIZB_BACK | PSWIZB_FINISH); (pSheet->GetDlgItem(IDCANCEL))->GetWindowText(m_strTextCancel); CString strEncrypt; strEncrypt.LoadString(IDS_ENCRYPT); (pSheet->GetDlgItem(ID_WIZFINISH))->SetWindowText(strEncrypt); CString strClose; strClose.LoadString(IDS_CLOSE); (pSheet->GetDlgItem(IDCANCEL))->SetWindowText(strClose); (pSheet->GetDlgItem(IDHELP))->ShowWindow(FALSE); //if (g_bCreateSelfExtractFile) { // m_btnOption.EnableWindow(FALSE); //} return CPropertyPage::OnSetActive(); }
void CxEditDoc::Serialize(CArchive& ar) { POSITION pos = GetFirstViewPosition(); CxEditView* pView = (CxEditView*)GetNextView(pos); ASSERT_KINDOF(CxEditView, pView); pView->SerializeRaw(ar); }
BOOL CInterior2::OnSetActive() { CPropertySheet* pSheet = (CPropertySheet*)GetParent(); ASSERT_KINDOF(CPropertySheet, pSheet); pSheet->SetWizardButtons( PSWIZB_BACK | PSWIZB_NEXT); return CResizablePageEx::OnSetActive(); }
void CShortcutBarView::OnMenuEvent_Del() { CListCtrl& rList = GetListCtrl(); //首先判断选中的是哪个pane CMainFrame* pFrameWnd = (CMainFrame*)GetParentFrame(); ASSERT_KINDOF (CMainFrame, pFrameWnd); if( pFrameWnd->m_wndShortcutBar.GetSelectedItem() == pFrameWnd->m_pItemFolder) { if (6 == MessageBox("您确定删除该条记录?","词汇管理",MB_YESNO | MB_ICONWARNING)) { //确定删除 int nItem = rList.GetSelectionMark(); CString strDelKeyword = rList.GetItemText(nItem, 2); rList.DeleteItem(nItem); //删除数据库 sloMysqlAgent::GetInstance()->DelKeyword(strDelKeyword.GetBuffer(0)); } }else { //选中的是网址pane if (6 == MessageBox("您确定删除该条记录?","网址管理",MB_YESNO | MB_ICONWARNING)) { //确定删除 int nItem = rList.GetSelectionMark(); CString strDelKeyword = rList.GetItemText(nItem, 2); rList.DeleteItem(nItem); //删除数据库 sloMysqlAgent::GetInstance()->DelWebsite(strDelKeyword.GetBuffer(0)); } } }
STDMETHODIMP COleUILinkInfo::GetLinkUpdateOptions( DWORD dwLink, DWORD* lpdwUpdateOpt) { COleClientItem* pItem = (COleClientItem*)dwLink; ASSERT_VALID(pItem); ASSERT_KINDOF(COleClientItem, pItem); SCODE sc; TRY { if (pItem->GetType() == OT_LINK) *lpdwUpdateOpt = pItem->GetLinkUpdateOptions(); else *lpdwUpdateOpt = OLEUPDATE_ALWAYS; // make believe it is auto-link sc = S_OK; } CATCH_ALL(e) { sc = COleException::Process(e); DELETE_EXCEPTION(e); } END_CATCH_ALL return sc; }
OSErr PASCAL _AfxOleAutoHandler(AppleEvent* pae, AppleEvent*, long lRefcon) { CWinApp* pApp; OSErr err; DescType dtT; Size lT; err = AEGetAttributePtr(pae, keyMissedKeywordAttr, typeWildCard, &dtT, NULL, 0, &lT); if (err == errAEDescNotFound) { pApp = (CWinApp*) lRefcon; ASSERT_VALID(pApp); ASSERT_KINDOF(CWinApp, pApp); if(COleObjectFactory::RegisterAll()) { return noErr; } else { return errAEEventNotHandled; } } else if (err == noErr) return errAEEventNotHandled; else return err; }
STDMETHODIMP COleUILinkInfo::CancelLink(DWORD dwLink) { COleClientItem* pItem = (COleClientItem*)dwLink; ASSERT_VALID(pItem); ASSERT_KINDOF(COleClientItem, pItem); ASSERT(pItem->GetType() == OT_LINK); SCODE sc = E_FAIL; TRY { if (pItem->FreezeLink()) sc = S_OK; } CATCH_ALL(e) { sc = COleException::Process(e); DELETE_EXCEPTION(e); } END_CATCH_ALL // report error if (sc != S_OK) pItem->ReportError(sc); return S_OK; }
// All child frame's will have exactly one CHexEditView (unless in print preview?). This returns it. CHexEditView *CChildFrame::GetHexEditView() const { CView *pv = GetActiveView(); if (pv != NULL) // May be NULL if print preview { if (pv->IsKindOf(RUNTIME_CLASS(CHexEditView))) return (CHexEditView *)pv; else if (pv->IsKindOf(RUNTIME_CLASS(CDataFormatView))) return ((CDataFormatView *)pv)->phev_; else if (pv->IsKindOf(RUNTIME_CLASS(CAerialView))) return ((CAerialView *)pv)->phev_; else if (pv->IsKindOf(RUNTIME_CLASS(CCompareView))) return ((CCompareView *)pv)->phev_; else if (pv->IsKindOf(RUNTIME_CLASS(CPrevwView))) return ((CPrevwView *)pv)->phev_; else if (pv->IsKindOf(RUNTIME_CLASS(CHexTabView))) { // Find the hex view (left-most tab) CHexTabView *ptv = (CHexTabView *)pv; ptv->SetActiveView(0); // hex view is always left-most (index 0) ASSERT_KINDOF(CHexEditView, ptv->GetActiveView()); return (CHexEditView *)ptv->GetActiveView(); } } return NULL; }