Solved

How to draw ....?

Posted on 2001-06-04
9
419 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 

Author Comment

by:pbtdanh
Comment Utility
this code is only sample.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:pbtdanh
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
hi pbtdanh:

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

-- Dan
0
 
LVL 23

Expert Comment

by:Roshan Davis
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
ODBC Connection Logging, ADO.NET 6 49
How to determine file rename from EventLog ? 2 36
haveThree challenge 22 100
Change to event 1 72
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now