Solved

How to draw ....?

Posted on 2001-06-04
9
425 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

734 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