Solved

Resizing Controls at run time

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Get filename and folder into excel 7 67
substring method in java 1 79
Doc'in system (example?) BA 7 79
wordcount challenge 11 78
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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 this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

746 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

13 Experts available now in Live!

Get 1:1 Help Now