BOOL CPictureWnd::CreatePicWnd(CWnd* pParent, const RECT& rect) { CMagneticApp* pApp = (CMagneticApp*)AfxGetApp(); m_pMagneticWnd = pParent; BOOL bCreate = CreateEx(0,AfxRegisterWndClass(0),"Magnetic", WS_CAPTION|WS_VISIBLE|WS_SYSMENU,rect,pParent,0,NULL); if (bCreate == FALSE) return FALSE; SetIcon(pApp->LoadIcon(IDR_MAINFRAME),TRUE); // Get the horizontal and vertical border sizes CRect r1, r2; GetWindowRect(r1); GetClientRect(r2); m_Borders.cx = r1.Width() - r2.Width(); m_Borders.cy = r1.Height() - r2.Height(); return TRUE; }
BOOL CScrollBackDlg::OnInitDialog() { BaseDialog::OnInitDialog(); CMagneticApp* pApp = (CMagneticApp*)AfxGetApp(); // Subclass the text control if (m_RichEdit.SubclassDlgItem(IDC_TEXT,this) == FALSE) return FALSE; // Get the relative position of the top of the text control CRect size; m_RichEdit.GetWindowRect(size); ScreenToClient(size); m_TextTop = size.top; // Change the window icon SetIcon(pApp->LoadIcon(IDR_MAINFRAME),TRUE); // Resize the dialog BaseDialog::MoveWindow(m_DialogRect); // Set the control to format the text so that it fits // into the window m_RichEdit.SetTargetDevice(NULL,0); // Set the background colour m_RichEdit.SetBackgroundColor(FALSE,GetSysColor(COLOR_3DFACE)); // Put the text into the control m_RichEdit.SetWindowText(m_strScrollback); // Put the cursor at the end of the buffer m_RichEdit.SetSel(-1,-1); m_RichEdit.SendMessage(EM_SCROLLCARET); return TRUE; }