Solved

How to draw ....?

Posted on 2001-06-04
9
421 Views
Last Modified: 2013-11-20
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

0
Comment
Question by:pbtdanh
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 2

Expert Comment

by:GloriousRain
ID: 6155296
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(...);
}
0
 
LVL 42

Accepted Solution

by:
sedgwick earned 100 total points
ID: 6155805
pass a pointer of the view to your CFrameDialog class and override OnSize of the Dialog.
use GetDC() to retrieve the device context of the view and use MoveTo(CPoint(0,0)) and LineTo(cx, cy) to draw the line between point(0,0) and the top-left point of the dialog
0
 
LVL 49

Assisted Solution

by:DanRollins
DanRollins earned 100 total points
ID: 6158178
I can't make any sense out of the question.  CPoint(0,0) *is* the top left corner.

Please describe what you are trying to do.  If you want to have a vertical or horizontal line appear in a dialog box, there are much easier ways.  So what is the goal here?

-- Dan
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

Author Comment

by:pbtdanh
ID: 6159713
this code is only sample.
0
 

Author Comment

by:pbtdanh
ID: 6159730
I want when I move dialogs, lines will be redrawn from (0,0) to top_left of dialogs (in CSrcollView)
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6161009
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
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 6163265
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
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6320323
hi pbtdanh:

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

-- Dan
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 9484569
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
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question