Solved

Window Resize

Posted on 2009-07-08
3
200 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

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ā€¦
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to useā€¦
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

763 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

10 Experts available now in Live!

Get 1:1 Help Now