Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to draw ....?

Posted on 2001-06-04
9
Medium Priority
?
447 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:
Meir Rivkin earned 400 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 400 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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:Meir Rivkin
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

782 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