Solved

Resizing Controls at run time

Posted on 2002-07-14
2
158 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
How to create frequencies of a variable from SAS dataset? 10 146
Add content to output file 4 72
bigDiff challenge 17 144
tripleUp challenge 7 97
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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 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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

751 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