Solved

Resize the window.

Posted on 1998-06-13
5
351 Views
Last Modified: 2013-11-20
I want to plot a graph on a CView. What I need is when the user is resizing the window, the graph will also be resized. For example, the graph is at the center of the view. When the user enlarges the window using the mouse, the graph is also enlarged and still at the center of the view; when the window becomes narrow, the graph also becomes narrow but still at the center of the view. How to do it? (I can draw lines using CDC->LineTo() function.)
0
Comment
Question by:mchen2
  • 3
  • 2
5 Comments
 

Accepted Solution

by:
wyhjin earned 10 total points
ID: 1317941
The following is how I deal with my View of Histogram in a spllitter Window , the graphics is adaptive with the size of the view size. The size information is contained in the object of CRect.

void CHistView::OnDraw(CDC* pDC)
{
      CHuffcodingDoc* pDoc = GetDocument();
      // TODO: add draw code here

      CRect rect;
      GetClientRect(rect);

              pDC->MoveTo(0,0);
              pDC->LineTo(rect.Width(),rect.Height());
}

Please draw your graphics according to the size.
0
 

Author Comment

by:mchen2
ID: 1317942
Is there any better way?
0
 

Expert Comment

by:wyhjin
ID: 1317943
There is another way to get the size of your view, by using OnSize function. But this is not better at all. I think drawing your graph is much more difficult task, which is not supported by MFC automatically. That is what microsoft is criticized by many programmers. But it is the way Window works, not MFC.
Drawing is always programmer's job.

wyhjin  
0
 

Author Comment

by:mchen2
ID: 1317944
How to use the OnSize function?
0
 

Expert Comment

by:wyhjin
ID: 1317945
1.start class wizard
2.choose a view or any other CWnd derived object.
3. select ON_WM_SIZE message
4. add handler function
5. the size of the view or any other CWnd derived object will be passed in cx & cy        parameters. How to use these depends on your application.

wyhjin

0

Featured Post

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

Join & Write a Comment

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

762 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

21 Experts available now in Live!

Get 1:1 Help Now