Solved

Resize the window.

Posted on 1998-06-13
5
353 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

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

Suggested Solutions

Title # Comments Views Activity
Running shell command from Access 3 72
Detect CR LF to each line 12 158
sumHeights2  challenge 7 102
My project did see openJDK that I installed. What could be the problem 7 140
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…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

806 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