Link to home
Start Free TrialLog in
Avatar of pbtdanh
pbtdanh

asked on

How to draw ....?

class CFrameDialog : public CDialog
{
}
typedef CTypedPtrList<CObList, CFrameDialog*> CFrameList;




class CFrameDoc : public CDocument
{
public:
CFrameList m_framelist;


void CFrameDoc::Add(CFrameDialog *m_frame)
{
     m_framelist.AddHead(m_frame);
     m_frame->m_pDocument = this;
}
}




class CFrameView:: public CScrollView
{
//there is a function add a framedialog to CScrollView
void CFrameView::OnInsertFrame()
{
     // TODO: Add your command handler code here
     CPropertySheet sheet( _T("Edit Frame") );
     CTypeText dlg;
     dlg.m_framename="";
     sheet.AddPage(&dlg);

     if (sheet.DoModal() != IDOK)
          return;
     else
     {
     CFrameDialog* m_frame = new CFrameDialog();
     m_frame->Create(IDD_DIALOGFRAME,this);
     m_frame->SetWindowPos(NULL,m_point.x,m_point.y,0,0,
                   SWP_DRAWFRAME | SWP_NOSIZE );
     m_frame->SetWindowText(dlg.m_framename);
     GetDocument()->Add(m_frame);
     }
}
}


I do not know how to draw a line from CPoint(0,0) to the top_left of the FrameDialog (all of FrameDialog) in CScrollView?
And when the FrameDialog move, these lines will be redraw.
Thanks

Avatar of GloriousRain
GloriousRain

You can override OnPaint() of CScrollView, and use MoveTo, LineTo of CPaintDC to draw line.
e.g
void CScrollView::OnPaint()
{
   CPaintDC dc(this);
   dc.Moveto(...);
   dc.LineTo(...);
}
ASKER CERTIFIED SOLUTION
Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pbtdanh

ASKER

this code is only sample.
Avatar of pbtdanh

ASKER

I want when I move dialogs, lines will be redrawn from (0,0) to top_left of dialogs (in CSrcollView)
When you say (0,0) perhaps you meed the top left corner of the screen.  If so, that suggests that you want to draw onto the desktop.  

In most Windows programming, you will *very rarely* need to draw using commands such as LineTo(...).  

In any case, when we draw, we draw only into our own window.  While it is possible to get an HWND and/or a DC to the desktop for direct access, doing so is unusual.  Anything you draw will be transient since there will be no program to redraw it when that part of the desktop needs to be refreshed.  Bits and pieces of your lines will remain like mouse droppings on the screen.  Don't do it.

-- Dan
pbtdanh:

in your CDialog add data member which is a pointer to your scrollView.

when u create your dialog send a the view's pointer to the dialog:
CMyScrolView::OnInitDialog()
{
CMyDialog dlg(this);
}
when u moce the dialog use the code below to draw the line:
CRect rect;
GetWindowRect(&rect);
CDC* pDC = m_pView->GetDC();
pDC->MoveTo(0,0);
pDc->LineTo(rect.TopLeft());

good luck
hi pbtdanh:

Do you have any additional questions?  Do any comments need clarification?

-- Dan
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Answered by : DanRollins, sedgwick (points to be split)

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Roshan Davis
EE Cleanup Volunteer