473,804 Members | 2,173 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Windows 7 - Reported Form size is wrong

tlhintoq
3,525 Recognized Expert Specialist
I'm running Window7 64bit, RTM.
To give this application the ability to switch between a moveable frame and no frame I am using the following methods
Expand|Select|Wrap|Line Numbers
  1.         void Fixed()
  2.         {
  3.             Point pBefore = this.Location;
  4.             Size sBefore = this.Size;
  5.             FormBorderStyle = FormBorderStyle.None;
  6.             this.BackColor = Color.FromKnownColor(KnownColor.Black);
  7.             this.Location = pBefore;
  8.             this.Size = sBefore;
  9.         }
  10.         void Moveable()
  11.         {
  12.             Point pBefore = this.Location;
  13.             Size sBefore = this.Size;
  14.             FormBorderStyle = FormBorderStyle.Sizable;
  15.             this.BackColor = Color.FromKnownColor(KnownColor.Control);
  16.             this.Location = pBefore;
  17.             this.Size = sBefore;
  18.         }
  19.  
One would expect that the size and location to remain constant, but they don't.
If I make the form Moveable(), then click maximize the form should now be 1920x1200 (Dell 24" widescreen)

But when I then make the form Fixed(), this.size() returns as 1936x1216. The reported size has grown by 16 pixel on each axis. Furthermore the location has shifted from 0,0 to -8,-8 which would be half of that 16 pixel difference.

My thinking is that since Windows7 has fancy effects like a feathered drop shadow all around the form, that the form technically extends to the edge of the drop shadow. Then when you click Maximize Windows7 is cheating and making it 16 pixels too big and offsetting by 8.

Does anyone have any better guess? Or know a way to check if there is a drop shadow visual effect so I take that into account in my size calculations?
Nov 10 '09 #1
3 5111
tlhintoq
3,525 Recognized Expert Specialist
Update:
SystemInformati on has a couple new (at least to me) properties.
PrimaryMonitorM aximizedWindowS ize = 1936x1216
PrimaryMonitorW indowSize = 1920x1200

That would be good if I could count on always being on the Primary Monitor, but that's not right. I guess the Maximized dimension less the Windows size, divided by two shows the drop shadow width

Or I could trust FrameBorderSize = 8, 8

I guess I just have to handle the third condition not just of resized but of maximized. I love complications.
Nov 10 '09 #2
Plater
7,872 Recognized Expert Expert
The size of your form reported in .Size changes depending on the form border style. Does that effect you?
Nov 10 '09 #3
tlhintoq
3,525 Recognized Expert Specialist
Of course. But since they are forms that I'm creating I have some control over that. I'm switching between .None and .Sizeable.

I filter the "before" sizes depending on whether or not the form went maximized
Expand|Select|Wrap|Line Numbers
  1. if (WindowState == FormWindowState.Maximized)
  2. {
  3.     pBefore = new Point(this.Location.X + SystemInformation.FrameBorderSize.Width, this.Location.Y + SystemInformation.FrameBorderSize.Height);
  4.     sBefore = new Size(this.Size.Width - SystemInformation.FrameBorderSize.Width * 2, this.Size.Height - SystemInformation.FrameBorderSize.Height * 2);
  5. }
  6. else
  7. {
  8.     pBefore = this.Location;
  9.     sBefore = this.Size;
  10. }
  11.  

Then when resizing some of the interior components I take into account the boarder dynamically
Expand|Select|Wrap|Line Numbers
  1. SystemInformation.CaptionHeight * (FormBorderStyle == FormBorderStyle.None ? 0:1) -
  2. SystemInformation.FrameBorderSize.Height * (FormBorderStyle == FormBorderStyle.None ? 0:1);
If the border style is none then ? returns 0, meaning border width times zero is still zero. If there is a border we take that times 1 for the bottom and the caption height times 1 for the top.
Nov 10 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

9
2827
by: Rajat Tandon | last post by:
Hello there, I am relatively new to the newsgroups and C#. I have never been disappointed with the groups and always got the prompt replies to my queries.This is yet another strange issue, I am facing. Please please help me to solve this as soon as possible. So here we go ... I am not able to take the screen shot of the windows form based "Smart
7
2015
by: Christian Blackburn | last post by:
Hi Gang, I just thought you might all get a kick out of this enormous rounding bug in Windows Explorer (Win2K Pro Sp4). You see my 6 byte document is listed as 1KB instead of 0KB which is what it would of course round to. 6 bytes is 6 spaces from 0KB or 994 from 1KB you tell me which should it round to? http://www.rawsacramento.org/~christian/misc/1%20KB%20My%20Ass.gif Cheers, Christian
1
3456
by: Scott Davies | last post by:
Hi, I'm looking for some help on a small program that I'm trying to develop in VB.NET. I'm having trouble getting the code that I've written to work, can anyone shed some light as to where I'm going wrong. The program has been written to do the following tasks: - Select remote server - Select from two specific services
4
3541
by: James | last post by:
I have a VB windows forms application that accesses a Microsoft Access database that has been secured using user-level security. The application is being deployed using No-Touch deployment. The objective in utilizing this new deployment method is to reduce the maintenance overhead as well as making it easier for my users to setup and run the application initially. I have VS 2002, Windows XP, Access XP(2000 format). He is my problem....
0
3062
by: James | last post by:
I have a VB windows forms application that accesses a Microsoft Access database that has been secured using user-level security. The application is being deployed using No-Touch deployment. The objective in utilizing this new deployment method is to reduce the maintenance overhead as well as making it easier for my users to setup and run the application initially. I have VS 2002, Windows XP, Access XP(2000 format). He is my problem....
3
7490
by: Chris Paul | last post by:
I'm having trouble with PHP & PostgreSQL/OpenLDAP/Apache on Windows. I've set this up countless times on BSD (piece of cake) but I'm trying to do this on Windows now so that my developer can work on her local machine. Everything looks pretty good. OpenLDAP/cygwin works great. PostgreSQL works great. Apache runs. PHP runs. But when I try to connect to my PostgreSQL server using PHPPgAdmin, I
1
2344
by: Rune Jacobsen | last post by:
Hi all, I have an application with one particular form that lists a number of items in a listview. In addition to the listview, there is a panel on top with some simple controls to go back and forth to the next and previous day. Since the number of items in the list can vary from day to day - from zero one day to thirty another, and five the third - my users like the option to have the Window resize itself to exactly fit the number of
1
7853
by: mfunkmann | last post by:
Hi, I recently got an error and I don't know how to fix it: Error 1 'System.Data.DataColumn' does not contain a definition for 'Windows' C:\c#\CsharpPRO\Form1.Designer.cs 304 77 CsharpPRO I am note sure what to do because all propertiers work, except the System.Data.DataColumn.. I didn't write any code by hand and used the visual studio to set the properties..
1
1950
by: gnue | last post by:
When I install my application built using VS2008 C#, the application size is reported incorrectly. The application is actually 40 Meg in size. When you click on "Add Remove Programs" from the Control Panel my application appears in the list of installed programs but the size incorrectly is reported as 2.9 Gig. Where does Windows get the information on the application size and how do I get it to return the correct size? Thanks
0
9711
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10595
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10088
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9169
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7633
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5668
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4306
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
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.