471,046 Members | 1,016 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,046 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 4151

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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Ron Vecchi | last post: by
reply views Thread by kurotsuke | last post: by
4 posts views Thread by Woody Splawn | last post: by
14 posts views Thread by Galen Somerville | last post: by
2 posts views Thread by New | last post: by
2 posts views Thread by =?Utf-8?B?VGVycnk=?= | last post: by

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.