Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Resizing form based on individal enduser's screen settings 2

Status
Not open for further replies.

RebLazer

Programmer
Jun 7, 2002
438
US
I was all ready to deploy an app onto a couple endusers' machines. I went over to the first one's computer to watch the big launch of my app with the marching band and balloons to celebrate ...well, maybe the band and balloons part is a bit exaggerated. In any case, after she ran the install wizard and my program started up, I saw that some of my controls no longer fit on their respective form. For example, the bottom of each form (including the GO button) was missing.

The reason for this is that their computer is set to 1280 x 1024 screen size with LARGE font size for the display (125% normal size - 120 dpi). My other users have different screen settings.

1) How can I detect what their current settings are? Is there something in [tt]System.Environment[/tt] or something like that?
2) Can I change the screen size and the (system-level) font size from within my app?

Thanks very much!
Lazer
 
I forgot to mention that this is a Windows form app.
-Lazer
 
Try:

Code:
Screen.PrimaryScreen.WorkingArea.Height 
Screen.PrimaryScreen.WorkingArea.Width

- B
 
You might set the form to auto scroll. Or you might place your bottom controls in a panel without a visible border, and dock them to the bottom of your form.
 
Brian - that's what I was looking for!

RiverGuy - Great ideas. I might look into AutoScale, actually - now that you got me looking at those properties...

Thanks very much - stars for both!!!
Lazer
 
Thanks, guys, for your help. One more related question...
When I try to go ahead and resize the form, it doesn't seem to work:

Code:
    Sub screen_size(ByVal form_name As Form)
        If Screen.PrimaryScreen.WorkingArea.Width() = 1280 Then
            'resize form to 90,70
            form_name.Size = New System.Drawing.Size(90, 70)
        End If

What's wrong with my [tt]form_name.Size[/tt]... line?

Thanks!
Lazer
 
Form has two properties

1. MaximumSize and 2. MinimumSize.

See if you have any values specified in there. If yes, then remove them and just put in 0,0. May be this might fix your problem.

-Kris
 
Each form has a scale property. Try:
Code:
    Sub screen_size(ByVal form_name As Form)
        If Screen.PrimaryScreen.WorkingArea.Width() = 1280 Then
            'resize form to 75%
            form_name.Scale(0.75)
        End If
    End Sub

- B
 
Oops... I had these lines reversed when calling my sub:

Code:
menu_form = Me
screen_size(menu_form)

Thanks!
Lazer
 
But one more question on the topic...

Aside from the enduser's 1280 x 1024 screen size - they also have the screen properties set to LARGE font size (125% normal size - 120 dpi).

How do I detect that?

Thanks very much,
Lazer
 
Try:

Code:
MsgBox(Form.ActiveForm.Font.SizeInPoints())

This will tell you the font size used.

-B
 
Brian,

I get a 'System.NullReferenceException' when I use that line.

And just to clarify - I am referring to the screen properties that one sets by right clicking on the Desktop, etc.

Thanks,
Lazer
 
MsgBox(Me.ActiveForm.Font.SizeInPoints())

SELECT * FROM Users WHERE Clue IS NOT NULL
Return: 0
 
Brian,

Wait a second. I think we're on different channels. I am referring to the setting one can change when doing the following:
Right-click on the Desktop (not .NET related at all) then: Properties | Settings | Advanced

You know - the Display Properties for one's computer - there's three choices on the combo box there: Small fonts, LARGE font size (125% normal size - 120 dpi), or Other.

That's what I need to detect.
Lazer
 
This function looks great but always returns FALSE for me. I've got my own Desktop set at 1280 x 1024 with SMALL fonts. That means that is should return TRUE.

Using the debugger, I see the variables have values that seem way, way off:

hWndDesk = 5326858958733322
hDCDesk = -4913328304724832290
logPix = 281474976710656
IsScreenFontSmall = False

So when it goes to execute the line of [tt]IsScreenFontSmall = logPix = 96[/tt] - it is quite false!

Any ideas? Please?!?! Thanks!
Lazer
 
Last night I created a test program with a button on the form. In the buttons click event I put this code:
Code:
MsgBox(Form.ActiveForm.Font.SizeInPoints())

I ran this on my system with the small font setting. It returned 8.25. Then I changed my system to large fonts, rebooted, and reran the test. This time it returned 7.8.

I hope this can help.

SELECT * FROM Users WHERE Clue IS NOT NULL
Return: 0
 
Brian,

Thanks so very much for all of your help on this! It worked and I deployed the project!

Many stars to you!
Lazer
 
Regarding the code on I contacted the author asking him how to get it to work in VB.NET (which it supposedly does), and he replied:

Hmm... you've got me there. I don't develop with .net, so have not tested
the code in that tool. However, I'd be surprised if there was not something
buried in the classes to provide this info without APIs ... though I can't
see it in a fast scan of the MSDN.

Randy Birch
MVP Visual Basic


- Lazer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top