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; }
/// <summary>Subclass an owner-drawn static</summary> UtilExport void AFXAPI DDX_OwnerDrawStatic(CDataExchange* pDX, int id, CStatic& ctrl) { DDX_Control(pDX, id, ctrl); // Ensure as OwnerDraw if ((ctrl.GetStyle() & SS_OWNERDRAW) == 0) ctrl.ModifyStyle(0, SS_OWNERDRAW, SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE); }