Problem with Graphics & CEdit scrolling
-
I have a CEdit control on a dialog box and I'm creating a dynamic rectangle on the CEdit but it doesn't scroll vertically when I put the rectangle on the bottom of the CEdit?!! I've set the multiline+ vertical scroll parameters Please help me! my code has come below: CRect rc, statusRect; GetDlgItem(IDC_GRAPH_EDIT)->GetWindowRect(rc); CWnd* pWnd = GetDlgItem(IDC_GRAPH_EDIT); ScreenToClient(rc); statusRect.top = rc.bottom - 40; statusRect.bottom = statusRect.top + 20; statusRect.left = rc.Width()/2 - 40; statusRect.right = statusRect.left + 80; m_dynamic = new CButton; m_dynamic->Create("Dynamic",WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|BS_OWNERDRAW|BS_MULTILINE,statusRect,pWnd,2000); m_dynamic->SetFont(fontGeorgia); m_dynamic->SetColor(BLUE, LBLUE); m_dynamic->ShowWindow(SW_SHOW); I've tried the following codes but it didn't help: ((CEdit *)(GetDlgItem(IDC_GRAPH_EDIT)))->SetSel(GetWindowTextLength(),-1); or ((CEdit *)(GetDlgItem(IDC_GRAPH_EDIT)))->PostMessage(WM_VSCROLL, SB_BOTTOM); UpdateData(TRUE); or ((CEdit *)(GetDlgItem(IDC_GRAPH_EDIT)))->LineScroll(2); Any idea or suggestion will be appreciated. thanks
-
I have a CEdit control on a dialog box and I'm creating a dynamic rectangle on the CEdit but it doesn't scroll vertically when I put the rectangle on the bottom of the CEdit?!! I've set the multiline+ vertical scroll parameters Please help me! my code has come below: CRect rc, statusRect; GetDlgItem(IDC_GRAPH_EDIT)->GetWindowRect(rc); CWnd* pWnd = GetDlgItem(IDC_GRAPH_EDIT); ScreenToClient(rc); statusRect.top = rc.bottom - 40; statusRect.bottom = statusRect.top + 20; statusRect.left = rc.Width()/2 - 40; statusRect.right = statusRect.left + 80; m_dynamic = new CButton; m_dynamic->Create("Dynamic",WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|BS_OWNERDRAW|BS_MULTILINE,statusRect,pWnd,2000); m_dynamic->SetFont(fontGeorgia); m_dynamic->SetColor(BLUE, LBLUE); m_dynamic->ShowWindow(SW_SHOW); I've tried the following codes but it didn't help: ((CEdit *)(GetDlgItem(IDC_GRAPH_EDIT)))->SetSel(GetWindowTextLength(),-1); or ((CEdit *)(GetDlgItem(IDC_GRAPH_EDIT)))->PostMessage(WM_VSCROLL, SB_BOTTOM); UpdateData(TRUE); or ((CEdit *)(GetDlgItem(IDC_GRAPH_EDIT)))->LineScroll(2); Any idea or suggestion will be appreciated. thanks
CEdit represents a simple text editor, even if you subclassed the control I dought you could do it. The edit-control client area does not actualy scroll, that's an illusion. When you scroll the text it just changes the position of the upper left courner character, where drawing is to start. The edit-control would have to think that your custom-control is part of the text. If you need to insert an object into an edit type control then you should be using CRichEditCtrl, and even then it may need to be an OLE control. INTP "The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes." Andrew W. Troelsen
-
CEdit represents a simple text editor, even if you subclassed the control I dought you could do it. The edit-control client area does not actualy scroll, that's an illusion. When you scroll the text it just changes the position of the upper left courner character, where drawing is to start. The edit-control would have to think that your custom-control is part of the text. If you need to insert an object into an edit type control then you should be using CRichEditCtrl, and even then it may need to be an OLE control. INTP "The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes." Andrew W. Troelsen
Well.....actually I'm going to draw a graph (some colored rectangles that are connected by some colored arrows) on a dialog. Since the display sould be always like a single vertical line of boxes with a scrolling feature, I though CEdit might be a good choice. Now.. I'm waiting for your suggestion for such an implementation :) Thanks a lot
-
Well.....actually I'm going to draw a graph (some colored rectangles that are connected by some colored arrows) on a dialog. Since the display sould be always like a single vertical line of boxes with a scrolling feature, I though CEdit might be a good choice. Now.. I'm waiting for your suggestion for such an implementation :) Thanks a lot
If you have not already visited controls section of CP, then give it a shot. There are two graph controls at CP that I know of (one is it ATL/COM section). The other two choice would be to: look into how to use a view (CScrollView) in a dialog box or write your own code to handle the scrolling. INTP "The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes." Andrew W. Troelsen