void ZDrOleClient::OnGetItemPosition( CRect& rPosition ) { ASSERT_VALID( this ); // During in-place activation, ZDrOleClient::OnGetItemPosition // will be called to determine the location of this item. The default // implementation created from AppWizard simply returns a hard-coded // rectangle. Usually, this rectangle would reflect the current // position of the item relative to the view used for activation. // You can obtain the view by calling ZDrOleClient::GetActiveView. // TODO: return correct rectangle (in pixels) in rPosition if ( m_bFullClient ) { CView *pParentView = GetParentView( ); if ( pParentView ) { pParentView->GetClientRect( &rPosition ); rPosition.left = m_pAttr->X; rPosition.top = m_pAttr->Y; } else rPosition = GetRect( ); } else { rPosition = GetRect( ); } }
void opengl_scene::draw( const CView& v ) { opengl_static_scene::draw( ); RECT r; v.GetClientRect(&r); gl_point a(0.0f, 0.0f); gl_point b(((GLfloat)r.right)/2.0f, (GLfloat)r.bottom/2.0f); gl_point c((GLfloat)r.right, 0.0f); color.purple( ); if(rand( ) % 2) s1.draw(gl_triangle(a,b,c)); gl_point _a(0.0f, (GLfloat)r.bottom); gl_point _b(((GLfloat)r.right)/2.0f, (GLfloat)r.bottom/2.0f); gl_point _c((GLfloat)r.right, (GLfloat)r.bottom); color.red( ); if(rand( ) % 2) s2.draw( gl_triangle(_a, _b, _c)); gl_point A(((GLfloat)r.right)/2.0f, (GLfloat)r.bottom/2.0f); gl_point B(((GLfloat)r.right), (GLfloat)r.bottom); gl_point C((GLfloat)r.right, 0.0f); color.lime( ); if(rand( ) % 2) s3.draw( gl_triangle(A, B, C)); }
void CVisualADSView::OnSize(UINT nType, int cx, int cy) { CFODrawView::OnSize(nType, cx, cy); CMainFrame *pMainFrm = (CMainFrame *) AfxGetMainWnd(); if (pMainFrm->m_hWndJava) { CView *pView = (CView *) this; RECT rect, rect2; pView->GetClientRect(&rect); pView->ClientToScreen (&rect); pMainFrm->GetWindowRect(&rect2); rect.left = rect.left - rect2.left - 8; rect.bottom = rect.bottom - rect2.top + 0; rect.right = rect.right - rect2.left - 8; rect.top = rect.top - rect2.top + 0; int nWidht = GetSystemMetrics(SM_CXVSCROLL); int nHeight = GetSystemMetrics(SM_CYVSCROLL); ::MoveWindow(pMainFrm->m_hWndJava, rect.left, rect.top, rect.right - rect.left + nWidht, rect.bottom - rect.top + nHeight, TRUE); //::SetWindowPos(pMainFrm->m_hWndJava, m_hWnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_SHOWWINDOW | SWP_NOACTIVATE); } }
//----------------------------------------------------------------------------- // Purpose: Replaces the current active view with a given view type. // Input : *pViewClass - // Output : CView //----------------------------------------------------------------------------- CView *CChildFrame::ReplaceView(CRuntimeClass *pViewClass) { // // Verify that there is an active view to replace. // CView *pCurrentView = GetActiveView(); if (!pCurrentView) { return(NULL); } // // If we're already displaying this kind of view, no need to go // further. // if ((pCurrentView->IsKindOf(pViewClass)) == TRUE) { return(pCurrentView); } // // Get pointer to CDocument object so that it can be used in the // creation process of the new view. Set flag so that the document // will not be deleted when view is destroyed. // CMapDoc *pDoc = (CMapDoc *)pCurrentView->GetDocument(); BOOL bAutoDelete = pDoc->m_bAutoDelete; pDoc->m_bAutoDelete=FALSE; int iRow = 0, iCol = 0; CRect rect; // Delete existing view if (bUsingSplitter) { pCurrentView->GetClientRect(rect); m_wndSplitter->GetActivePane(&iRow, &iCol); m_wndSplitter->DeleteView(iRow, iCol); } else { pCurrentView->DestroyWindow(); } // Restore the autodelete flag. pDoc->m_bAutoDelete = bAutoDelete; // Create new view and redraw. CCreateContext context; context.m_pNewViewClass = pViewClass; context.m_pCurrentDoc = pDoc; context.m_pNewDocTemplate = NULL; context.m_pLastView = NULL; context.m_pCurrentFrame=this; CView *pNewView = NULL; if (bUsingSplitter) { if (m_wndSplitter->CreateView(iRow, iCol, pViewClass, rect.Size(), &context)) { pNewView = (CView *)m_wndSplitter->GetPane(iRow, iCol); } } else { pNewView = (CView *)pViewClass->CreateObject(); if (pNewView) { CRect r; GetClientRect(r); if (!pNewView->Create(NULL, NULL, AFX_WS_DEFAULT_VIEW, r, this, AFX_IDW_PANE_FIRST, &context)) { pNewView = NULL; } } } if (!pNewView) { TRACE0("Warning: couldn't create view for frame\n"); return(NULL); } pNewView->SendMessage(WM_INITIALUPDATE, 0, 0); if (bUsingSplitter) { m_wndSplitter->RecalcLayout(); } return(pNewView); }
BOOL CSceneEditApp::InitInstance() { // // 如果一个运行在 Windows XP 上的应用程序清单指定要 // // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, // //则需要 InitCommonControlsEx()。否则,将无法创建窗口。 // INITCOMMONCONTROLSEX InitCtrls; // InitCtrls.dwSize = sizeof(InitCtrls); // // 将它设置为包括所有要在应用程序中使用的 // // 公共控件类。 // InitCtrls.dwICC = ICC_WIN95_CLASSES; // InitCommonControlsEx(&InitCtrls); CWinApp::InitInstance(); // EnableTaskbarInteraction(FALSE); // 使用 RichEdit 控件需要 AfxInitRichEdit2() // AfxInitRichEdit2(); // 标准初始化 // 如果未使用这些功能并希望减小 // 最终可执行文件的大小,则应移除下列 // 不需要的特定初始化例程 // 更改用于存储设置的注册表项 // TODO: 应适当修改该字符串, // 例如修改为公司或组织名 SetRegistryKey(_T("应用程序向导生成的本地应用程序")); //初始化OLE OleInitialize(NULL); //初始化GDI+ Gdiplus::GdiplusStartupInput gdiplusStartupInput; GdiplusStartup(&g_gdiplusToken, &gdiplusStartupInput, NULL); CMainFrame* pFrame = new CMainFrame; if (!pFrame) return FALSE; m_pMainWnd = pFrame; // 创建并加载框架及其资源 pFrame->LoadFrame(IDR_MAINFRAME, WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL, NULL); /////////////////////////////////////////// ///////////////////////////初始化主程序 CView* pView = pFrame->GetActiveView(); RECT rect; pView->GetClientRect(&rect); m_app.Init(rect.right-rect.left, rect.bottom-rect.top, pView->GetSafeHwnd(), m_pMainWnd->GetSafeHwnd()); /////////////////////////////////////////// ///////////////////////////初始化编辑器UI if(!pFrame->CreateEditorMainUI()) return FALSE; /////////////////////////////////////////// ///////////////////////////初始化完毕,开始渲染... pFrame->ShowWindow(SW_SHOW); pFrame->UpdateWindow(); //pFrame->SetForegroundWindow(); pFrame->SetTimer(0, (UINT)TIME_PER_FRAME*1000, NULL); return TRUE; }