?
Solved

Resize the window.

Posted on 1998-06-13
5
Medium Priority
?
363 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 30 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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

864 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