473,573 Members | 2,908 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4313

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 restoredWindowB ounds, 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 Win32WindowPlac ement
{
public UInt32 length;
public UInt32 flags;
public UInt32 showCmd;
public Win32Point minPosition;
public Win32Point maxPosition;
public Win32Rect normalPosition;

public Win32WindowPlac ement(UInt32 length, UInt32 flags,
UInt32 showCmd, Win32Point minPosition,
Win32Point maxPosition, Win32Rect normalPosition)
{
this.length = length;
this.flags = flags;
this.showCmd = showCmd;
this.minPositio n = minPosition;
this.maxPositio n = maxPosition;
this.normalPosi tion = normalPosition;
}

public Size WindowSize
{
get
{
return new Size(this.norma lPosition.Width ,
this.normalPosi tion.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(Int3 2 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("user 32.dll", SetLastError=tr ue)]
static extern bool GetWindowPlacem ent(IntPtr hDc, out
Win32WindowPlac ement placementInfo);

and then...

IntPtr windowHandle = theForm.Handle;
Win32WindowPlac ement placement;
if (GetWindowPlace ment(windowHand le, out placement))
{
... get form's true size from "placement.Wind owSize" ...
}

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
10123
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? couldn't quite figure it out. -- Ron Vecchi
1
1581
by: alex | last post by:
How to hide the form window when it's minimized? Please help.
0
1627
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 always 34 pixels. I checked the form height and notices that's the ShowWindow API that automatically changes the form size when called. Any idea on...
4
1915
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 them they may run slow. These are winforms, nothing to do with the net. In the enviroment I came from (PowerBuilder) if your form got too big...
3
1566
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 then data shld be loaded according the filled entries in first form,but in that case the form size increase, so i want any other alternatve to...
14
3407
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 PrimaryScreen and the WorkingArea properties. Dim workingRectangle As System.Drawing.Rectangle = _ Screen.PrimaryScreen.WorkingArea ' Set the size...
2
393
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 line BTW I am ahort of form real estate and I know that I can run the form maximized but I want to design it so that no elements are cut off
2
1583
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 the syetm clock etc? Cheers James
2
1739
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 works great. I go through the forms control collection (recurively) and everything resizes as it should. Ok, so the next step is to remember the...
0
7679
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7992
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
6385
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5571
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5281
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3722
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3722
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2183
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1027
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.