Solved

Window Resize

Posted on 2009-07-08
3
205 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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
valid enum? 6 75
Line meaning 9 87
How to convert MFC::CString to UTF8 wchar_t* 10 277
Need some help with Microsoft Visual Studio C++ 2003 5 63
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

840 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