Solved

Resize the window.

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C++ BOOL WINAPI ReadFile fails on windows 10 when reading from USB cable 9 386
lucky13 challenge 11 125
wordcount challenge 11 110
Way to decrease size of apk file 9 46
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
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.

863 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

27 Experts available now in Live!

Get 1:1 Help Now