Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Resizing Controls at run time

Posted on 2002-07-14
2
Medium Priority
?
170 Views
Last Modified: 2013-11-20
I need to resize the window controls like CStatic, CButton etc. at run time. Is there any way to do it?

Thanks.
0
Comment
Question by:theExpert
2 Comments
 
LVL 8

Accepted Solution

by:
mnashadka earned 150 total points
ID: 7153383
You can use the "MoveWindow" member function of CWnd after GetClientRect and Client To Screen.  For instance:

   CRect buttonRect;
   m_button.GetClientRect(&buttonRect);

   m_button.ClientToScreen(buttonRect);

   // Make it 20 px wider
   buttonRect.left -= 10;
   buttonRect.right += 10;

   m_button.MoveWindow(buttonRect.left, buttonRect.top,
      buttonRect.Width(), buttonRect.Height());
0
 

Expert Comment

by:Nanos
ID: 7156834
CRect Rect;

<yourControl>.GetWindowRect(&Rect);
<yourControl>.SetWindowPos(NULL,0,0,Rect.Width(),211,SWP_NOMOVE | SWP_NOZORDER);

The SetWindowPos Function takes width and height parameters. these will enable you to change the size and location of your controls.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

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…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

927 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