Solved

Resize the window.

Posted on 1998-06-13
5
357 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
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.
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.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

691 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