bool CLogGraph::attach(UINT id, CWnd* pParent) { CStatic wndStatic; CRect r; if (pParent == NULL || !wndStatic.SubclassDlgItem(id, pParent)) return false; wndStatic.GetWindowRect(&r); pParent->ScreenToClient(&r); if ( !CreateEx( wndStatic.GetExStyle(), NULL, NULL, WS_CHILD | WS_VISIBLE | wndStatic.GetStyle(), r, pParent, id, NULL)) { wndStatic.DestroyWindow(); return false; } wndStatic.DestroyWindow(); EnableScrollBarCtrl(SB_HORZ, TRUE); GetClientRect(&m_rectWnd); calcRect(); SetTimer(11839, 1000, NULL); m_bCreated = true; return true; }
////////////////// // Create folder tab control from static control. // Destroys the static control. This is convenient for dialogs // BOOL CFolderTabCtrl::CreateFromStatic(UINT nID, CWnd* pParent) { CStatic wndStatic; if (!wndStatic.SubclassDlgItem(nID, pParent)) return FALSE; CRect rc; wndStatic.GetWindowRect(&rc); pParent->ScreenToClient(&rc); wndStatic.DestroyWindow(); rc.bottom = rc.top + GetDesiredHeight(); return Create(WS_CHILD|WS_VISIBLE, rc, pParent, nID); }
// CefJamCEFHtmlView message handlers BOOL CefJamCEFHtmlView::CreateFromResource(UINT nID, CWnd* pParent,LPCTSTR csControlClass) { CRect rc; CString csCompareClass=csControlClass; if (csCompareClass.CompareNoCase(HTMLVIEW_CONTROL_CLASS_CSTATIC)==0) { CStatic wndStatic; if (!wndStatic.SubclassDlgItem(nID, pParent)) return FALSE; // Get static control rect, convert to parent's client coords. wndStatic.GetWindowRect(&rc); pParent->ScreenToClient(&rc); wndStatic.DestroyWindow(); } else if (csCompareClass.CompareNoCase(HTMLVIEW_CONTROL_CLASS_CEDIT)==0) { CEdit wndEdit; if (!wndEdit.SubclassDlgItem(nID, pParent)) return FALSE; // Get static control rect, convert to parent's client coords. wndEdit.GetWindowRect(&rc); pParent->ScreenToClient(&rc); wndEdit.DestroyWindow(); } else { return FALSE; } // create HTML control (CHtmlView) return Create(NULL, // class name NULL, // title (WS_CHILD | WS_VISIBLE|WS_CLIPCHILDREN ), // style rc, // rectangle pParent, // parent nID, // control ID NULL); // frame/doc context not used }
////////////////// // Create control in same position as an existing static control with // the same ID (could be any kind of control, really) // BOOL CHtmlCtrl::CreateFromStatic(UINT nID, CWnd* pParent) { CStatic wndStatic; if (!wndStatic.SubclassDlgItem(nID, pParent)) return FALSE; // Get static control rect, convert to parent's client coords. CRect rc; wndStatic.GetWindowRect(&rc); pParent->ScreenToClient(&rc); wndStatic.DestroyWindow(); // create HTML control (CHtmlView) return Create(NULL, // class name NULL, // title (WS_CHILD | WS_VISIBLE ), // style rc, // rectangle pParent, // parent nID, // control ID NULL); // frame/doc context not used }