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 Chriss Miller 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
Joined
Jun 7, 2002
Messages
438
Location
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
 
Regarding the NullReferenceException, this exception will always be thrown if you call Form.ActiveForm when there is no form in your application that currently has focus in Windows.

-Scott
 
This may be a year old, but I had the same problem, and I just wanted to mention the solution regarding the VB6 code reblazer was using in case anyone needed it -

changing the Long declarations in the vb6 code to Integer will solve the problem, as VB.NET's integers default to 32 bits, which is required for system calls (the same as a vb6 Long).

So:

Code:
  Private Declare Function GetDesktopWindow Lib "user32" () As Integer
    Private Declare Function GetDC Lib "user32" (ByVal hwnd As Integer) As Integer
    Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Integer, ByVal nIndex As Integer) As Integer
    Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Integer, ByVal hdc As Integer) As Integer

    Private Function ScreenFont() As Integer

        Dim hWndDesk As Integer
        Dim hDCDesk As Integer
        Dim logPix As Integer

        'handle to the desktop window   
        hWndDesk = GetDesktopWindow()

        'handle desktop display context (hDC)   
        hDCDesk = GetDC(hWndDesk)

        'horizontal logical pixels   
        logPix = GetDeviceCaps(hDCDesk, LOGPIXELSX)

        'release the hDC   
        Call ReleaseDC(hWndDesk, hDCDesk)

        Return logPix

    End Function

will work just fine with that slight modification, and return 96 instead of 281474976710656.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top