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

x
?
Solved

Window Resize

Posted on 2009-07-08
3
Medium Priority
?
242 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 60 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 345 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 345 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

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…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

824 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