473,396 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Form.Size when Minimized

Consider a Form with dimension Size=(300,300) that is then minimized.
Subsequent calls to Size return (160,24).

The Form is then restored and Size returns (300,300)

Is there any property or method that returns the size of the form when
restored? (so you can obtain the "real" size of the Form when it is
minimized)

Regards

--
Wal
http://www.vooose.com

*** Sent via Developersdex http://www.developersdex.com ***
Dec 15 '05 #1
5 4290

vooose wrote:
Consider a Form with dimension Size=(300,300) that is then minimized.
Subsequent calls to Size return (160,24).

The Form is then restored and Size returns (300,300)

Is there any property or method that returns the size of the form when
restored? (so you can obtain the "real" size of the Form when it is
minimized)


There's a private Form member called restoredWindowBounds, but that
obviously won't help you.

The easy way to do this is to trap the Resize event, note whether or
not
the form is minimized and keep track of it.

Matt

Dec 15 '05 #2
Thanks Matt...while I was waiting for some feedback I did *exactly*
that. Great minds think alike ;)

--
Wal
http://www.vooose.com

*** Sent via Developersdex http://www.developersdex.com ***
Dec 15 '05 #3
There is a way to get this information by calling base Win32 methods.

/// <summary>
/// The WINDOWPLACEMENT structure for the Win32 interface.
/// See Microsoft documentation for details.
/// </summary>
private struct Win32WindowPlacement
{
public UInt32 length;
public UInt32 flags;
public UInt32 showCmd;
public Win32Point minPosition;
public Win32Point maxPosition;
public Win32Rect normalPosition;

public Win32WindowPlacement(UInt32 length, UInt32 flags,
UInt32 showCmd, Win32Point minPosition,
Win32Point maxPosition, Win32Rect normalPosition)
{
this.length = length;
this.flags = flags;
this.showCmd = showCmd;
this.minPosition = minPosition;
this.maxPosition = maxPosition;
this.normalPosition = normalPosition;
}

public Size WindowSize
{
get
{
return new Size(this.normalPosition.Width,
this.normalPosition.Height);
}
}
}

/// <summary>
/// The POINT structure for the Win32 interface.
/// See Microsoft documentation for details.
/// </summary>
private struct Win32Point
{
public Int32 x;
public Int32 y;
public Win32Point(Int32 x, Int32 y)
{
this.x = x;
this.y = y;
}
}

/// <summary>
/// The RECT structure for the Win32 interface.
/// See Microsoft documentation for details.
/// </summary>
private struct Win32Rect
{
public Int32 left;
public Int32 top;
public Int32 right;
public Int32 bottom;
public Win32Rect(Int32 top, Int32 left, Int32 bottom, Int32 right)
{
this.top = top;
this.left = left;
this.bottom = bottom;
this.right = right;
}

public Int32 Width
{
get { return this.right - this.left; }
}

public Int32 Height
{
get { return this.bottom - this.top; }
}
}
[DllImport("user32.dll", SetLastError=true)]
static extern bool GetWindowPlacement(IntPtr hDc, out
Win32WindowPlacement placementInfo);

and then...

IntPtr windowHandle = theForm.Handle;
Win32WindowPlacement placement;
if (GetWindowPlacement(windowHandle, out placement))
{
... get form's true size from "placement.WindowSize" ...
}

Dec 15 '05 #4
Thanks Bruce - I have used the struct and it gives me the answer i want!
May I ask where you got the struct code from?

Regards

--
Wal
http://www.vooose.com

*** Sent via Developersdex http://www.developersdex.com ***
Dec 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Ron Vecchi | last post by:
I know the math I need to perform on width and height to keep an aspect ratio but where and how would I implement keeping a set aspect ratio on a form when a user resizes it. Override OnResize?...
1
by: alex | last post by:
How to hide the form window when it's minimized? Please help.
0
by: kurotsuke | last post by:
I'm using the ShowWindow API to show a form (I need it to show the form topmost without focus). My form has no titlebar and should have a height of 16 pixel. When the form is shown it's height is...
4
by: Woody Splawn | last post by:
I don't mean to be too wordy but if you will indulge me a moment I need to get something clear in my mind. I am concerned about the size of my forms. I am concerned that if I put too much code in...
3
by: raj | last post by:
hi, I have 4 forms all having 40 fields in datagrid,I have two textBoxes for date and country, according to my requirement if i have set date and country in one form then if i go to another form...
14
by: Galen Somerville | last post by:
My current screen resolution is set to 1024 x 768. My form size always comes up as 1032 x 748. I have tried the help sample ' Retrieve the working rectangle from the Screen class ' using the...
2
by: New | last post by:
This may be a dumb question but what is the largest size you would recommend a form to be if it is designed to work in a 1024 x 768 enviroment since some peopl have the taskbar set greater then one...
2
jamesd0142
by: jamesd0142 | last post by:
Hi all, Wondering if it is possible to hide my app when minimized? The say way task manager works when you click > options > hide when minimized. Or the same way outlook is running next to...
2
by: =?Utf-8?B?VGVycnk=?= | last post by:
Hope someone has some ideas - this is driving me nuts, I am using VS2008 and have a tightly layed out form at 8 pts. The form has a font dialog and when the user changes the font size, everything...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.