473,785 Members | 2,847 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

96 DPI vs 120 DPI causing many form placement problems

I have a client who foolishly insists on running my application at 120 DPI.
Many of the forms that look quite acceptable in their original 96 DPI design
format have problems with the form's child controls being place below and to
the right of their designed position, sometimes so badly misplaced that they
are completely out of view. I've done the usual things like set AutoSize to
true and AutoScaleMode to Font and so on but nothing seems to fix the
problem. I finally gave up and just simply intercepted the OnSize event and
explicitly place the controls where they are supposed to be. However, there
are a few forms where even this doesn't work. The system is acting at though
ClientRectangle was not returning the number of pixels on the client area of
the form.

Here's a (very simplified) example - a form with a group box. The desired
effect is for the group box to display centered in the dialog. To simplify
things, the code just uses the group box's offset from the form's upper left
corner as the border. The code will not move the group box, just resize it
so that it is centered within the form's client area.

protected override void OnSizeChanged( EventArgs e )
{
base.OnSizeChan ged( e );
int iHBorder = groupBox.Left;
int iVBorder = groupBox.Top;

groupBox.Width = ClientRectangle .Width - 2 * iHBorder;
groupBox.Height = ClientRectangle .Height - 2 * iVBorder;
}

This works perfectly at 96 DPI but the groupbox is way too wide and tall in
120 DPI. How can this be? DPI shouldn't be involved at this point because
the unit of measurement is now pixels, not logical dialog units. Can someone
who has successfully surmounted this problem please tell me what I'm doing
wrong?
--
Richard Lewis Haggard
www.Haggard-And-Associates.com
Mar 12 '07 #1
6 13271
VJ
Have tried using the Dock property to get the location right?. Again using
Dock and AutoSize you have to be careful.

VJ

"Richard Lewis Haggard" <HaggardAtWorld DotStdDotComwro te in message
news:eW******** ******@TK2MSFTN GP06.phx.gbl...
>I have a client who foolishly insists on running my application at 120 DPI.
Many of the forms that look quite acceptable in their original 96 DPI
design format have problems with the form's child controls being place
below and to the right of their designed position, sometimes so badly
misplaced that they are completely out of view. I've done the usual things
like set AutoSize to true and AutoScaleMode to Font and so on but nothing
seems to fix the problem. I finally gave up and just simply intercepted the
OnSize event and explicitly place the controls where they are supposed to
be. However, there are a few forms where even this doesn't work. The system
is acting at though ClientRectangle was not returning the number of pixels
on the client area of the form.

Here's a (very simplified) example - a form with a group box. The desired
effect is for the group box to display centered in the dialog. To simplify
things, the code just uses the group box's offset from the form's upper
left corner as the border. The code will not move the group box, just
resize it so that it is centered within the form's client area.

protected override void OnSizeChanged( EventArgs e )
{
base.OnSizeChan ged( e );
int iHBorder = groupBox.Left;
int iVBorder = groupBox.Top;

groupBox.Width = ClientRectangle .Width - 2 * iHBorder;
groupBox.Height = ClientRectangle .Height - 2 * iVBorder;
}

This works perfectly at 96 DPI but the groupbox is way too wide and tall
in 120 DPI. How can this be? DPI shouldn't be involved at this point
because the unit of measurement is now pixels, not logical dialog units.
Can someone who has successfully surmounted this problem please tell me
what I'm doing wrong?
--
Richard Lewis Haggard
www.Haggard-And-Associates.com

Mar 12 '07 #2
On Tue, 13 Mar 2007 03:03:14 +0800, Richard Lewis Haggard
<HaggardAtWorld DotStdDotComwro te:
I have a client who foolishly insists on running my application at 120
DPI.
Your client's only foolish habit is to continue employing someone who
doesn't respect their desire and right to use their own computer as they
like. Someone who has so little respect for their employer that they
would use the word "foolish" to describe their employer. You could use an
attitude check, IMHO.

For what it's worth the ability to change the font size in Windows is
there for a reason. One size definitely does NOT fit all. People run
their video cards at a variety of resolutions, with a variety of monitor
sizes. The use of "dpi" is a misnomer here, as Windows doesn't really
know or care what the actual physical device dpi is. It's up the user to
select a resolution scale factor that renders the screen readable, while
still using a reasonable amount of display space.

Kudos to you for going ahead and trying to address you client's needs.
That's very admirable, especially in light of your opinion. But a great
big raspberry to you for believing that you shouldn't have to and that
your client is being "foolish".

Pete
Mar 13 '07 #3
On Tue, 13 Mar 2007 11:03:57 +0800, "Peter Duniho"
<Np*********@nn owslpianmk.comw rote:
>Your client's only foolish habit is to continue employing someone who
doesn't respect their desire and right to use their own computer as they
like. Someone who has so little respect for their employer that they
would use the word "foolish" to describe their employer. You could use an
attitude check, IMHO.
I'm pretty sure that was a humorous remark, not a serious one...
--
http://www.kynosarges.de
Mar 13 '07 #4
On Mon, 12 Mar 2007 15:03:14 -0400, "Richard Lewis Haggard"
<HaggardAtWorld DotStdDotComwro te:
>This works perfectly at 96 DPI but the groupbox is way too wide and tall in
120 DPI. How can this be? DPI shouldn't be involved at this point because
the unit of measurement is now pixels, not logical dialog units. Can someone
who has successfully surmounted this problem please tell me what I'm doing
wrong?
The automatic resizing of Windows Forms elements is a horribly
complicated affair that doesn't work very well. If you want to know
details you should read Charles Petzold's Windows Forms books,
"Programmin g MS Windows with C#" and the sequel, "Programmin g Windows
Forms 2005 edition". He has a few sections on this topic.

Anyway, what I do is completely disable the built-in autoscaling.
Instead I grab the Height of the font that's used in the dialog and
scale everything else according to that Height -- similar to how we
used the old dialog units in resource files! This works fine in both
96 and 120 dpi settings.
--
http://www.kynosarges.de
Mar 13 '07 #5
On Tue, 13 Mar 2007 16:25:44 +0800, Chris Nahr <di******@kynos arges.de>
wrote:
>
I'm pretty sure that was a humorous remark, not a serious one...
Hmmm. Well, I didn't read it that way, and didn't see any smiley or
anything else to suggest he was kidding.

My apologies if it was meant only in jest.
Mar 13 '07 #6
Silly rabbit, of course it was meant to be humorous! And to confirm my
intentions, here's a link to the root of my corporate web site's humor
section (G rated for the more delicate eyeballs but not entirely politically
correct).

http://www.haggard-and-associates.com/Humor/humor.htm

--
Richard Lewis Haggard
www.Haggard-And-Associates.com

"Peter Duniho" <Np*********@nn owslpianmk.comw rote in message
news:op******** *******@petes-computer.local. ..
On Tue, 13 Mar 2007 16:25:44 +0800, Chris Nahr <di******@kynos arges.de>
wrote:
>>
I'm pretty sure that was a humorous remark, not a serious one...

Hmmm. Well, I didn't read it that way, and didn't see any smiley or
anything else to suggest he was kidding.

My apologies if it was meant only in jest.

Mar 21 '07 #7

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

Similar topics

4
4297
by: Eric | last post by:
Hey Everyone.. I have a form that has approximately 7 text fields and 1 checkbox. Generally when this form is submitted(to itself BTW) it works fine, however, when the checkbox is only field that has been modified/clicked the form doesn't always submit. When it does work, a Stored procedure is passed form variables and updates to the db are made. When it doesn't, its as if the form wasn't submitted, it reloads and resets the page, but...
1
2453
by: googleboy | last post by:
Hi. I am writing up my own web form. I'm a bit of a newb, and read up many different how-tos and examples and documentaion. I finally had it working just great until I decided that I wanted to add some extra logic because there's one form that submits a particular type of information. a little extra validation, and the creation of a list of the values to be mailed in to the site manager. The code below is where I am going wrong...
2
1752
by: nic | last post by:
Hi I am currently having problems getting two forms to behave the way I want. I have two tables Student and Application, and their respective forms. (Tables)Student has StudentID (PK) & an ApplicationID. And Application has ApplicationID as its primary key. With the main Form being the Student_Details form, I have a Button which loads the Application Form. The way I want it to behave is when the Load_AppForm button is clicked the...
0
1459
by: nic | last post by:
Hi I am currently having problems getting two forms to behave the way I want. I have two tables Student and Application, and their respective forms. (Tables)Student has StudentID (PK) & an ApplicationID. And Application has ApplicationID as its primary key. With the main Form being the Student_Details form, I have a Button which loads the Application Form. The way I want it to behave is when the Load_AppForm button is clicked the...
0
1134
by: pei_world | last post by:
Hi, the problem describes as below: 1st question //============== code =================== //= in Parent Form, I create following function: void newForm(Form parent,Form theForm){ foreach(Form subForm in parent.MdiChildren){ if(subForm.Name == theForm.Name){ subForm.Hide(); subForm.Show();
2
4292
by: David W. Fenton | last post by:
I think at various times we've all encountered this problem: A subform is on a main form. From the code of the main form we refer to some property of/control on the child form thus: Me!subForm.Form!txtTextBox and for some reason, in certain contexts, we get the error: Error 2455: You entered an expression that has an invalid reference
4
1813
by: Taylor | last post by:
Hello, This is driving me crazy, but I have a form with a filter button and when it is selected if there are no results then it is supposed to open a subform (error box). Below is my code: Private Sub cmdFilter_Click() Dim db As Database Dim rst As DAO.Recordset Dim qdf As QueryDef
5
3518
by: JasonX | last post by:
Im having problems with my program, in that if I close the main form while my new thread is doing work which involves writing to the main form, then I get an error about a disposed object. To fix this, i have added an event, with the aim the main form subscribes to the event when it is created and unsubscribes as soon as its closed. This approach however has not fixed the problem. When the event is raised, it writes to the form using a...
2
1163
by: koosh34 | last post by:
I'm trying to get my program to run in the bottom right hand corner, how do I do this?
0
9480
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10153
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10093
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8976
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...
0
6740
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4053
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
3654
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2880
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.