Solved

Window Resize

Posted on 2009-07-08
3
206 Views
Last Modified: 2012-05-07
Hi all,

i am working on some basic window functionality like Menus and Window Messages using "C"-Windows programming.

i want to reSize my main window to a specific size upon Selecting a Menu item.
example:- if i have a menu option " Half", "Full";
if i select "Half" -> Size of main window should be reduced to half.

(1)How can we do that?
(2)Which message should be sent to the WinProc to notify the new Window Size?

Hope you understood .


Thanks
0
Comment
Question by:kishan66
3 Comments
 
LVL 9

Assisted Solution

by:JohnGaby
JohnGaby earned 20 total points
ID: 24809568
The function you use to resize (and move) windows is MoveWindow:

http://msdn.microsoft.com/en-us/library/ms633534(VS.85).aspx
0
 
LVL 33

Accepted Solution

by:
pgnatyuk earned 115 total points
ID: 24811027
BOOL bMove = ::SetWindowPos(m_hWnd, NULL,   left, top,   right - left,   bottom - top,   SWP_NOZORDER);
 In the window procedure you need to handle WM_SIZE, if you changing the window rectangle.
0
 
LVL 39

Assisted Solution

by:itsmeandnobodyelse
itsmeandnobodyelse earned 115 total points
ID: 24812103
To add to above comments:

MoveWindow can move a window and resize it.

SetWindowPos additionally can change the Z-order (means whether it is top to other windows or not).

Both want the coordinates given in *client* coordinates what is relative coordinates to the client rectangle (inner rectangle) of the parent window. If your window is a top level window screen coordinates and client coordinates are same. If not, you best call ScreenToClient function to translate coordinates you got by GetWindowRect to client coordinates.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

680 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