Solved

Resizing Controls at run time

Posted on 2002-07-14
2
160 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
[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
2 Comments
 
LVL 8

Accepted Solution

by:
mnashadka earned 50 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

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

617 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