Getting the screen resolution

Discussion in 'ASP .Net' started by eagle, Sep 9, 2005.

  1. eagle

    eagle Guest

    How do I get the screen resolution when running an asp.net project. I tried
    the old way, and I get an error on the apiGetWindowRect that says "Object
    reference not set to an instance of an object. "


    Public Structure RECT
    Dim x1 As Long
    Dim y1 As Long
    Dim x2 As Long
    Dim y2 As Long
    End Structure


    Declare Function apiGetDesktopWindow Lib "user32" Alias _
    "GetDesktopWindow" () As Long

    Declare Function apiGetWindowRect Lib "user32" Alias _
    "GetWindowRect" (ByVal hwnd As Long, lpRect As RECT) _
    As Long

    Function GetScreenResolution () as String
    Dim R As new RECT
    Dim hWnd As Long
    hWnd = apiGetDesktopWindow()
    'RetVal = apiGetWindowRect(hWnd, R)
    Dim RetVal As Long = apiGetWindowRect(hWnd, R)
    GetScreenResolution = (R.x2 - R.x1) & "x" & (R.y2 - R.y1)
    End Function
     
    eagle, Sep 9, 2005
    #1
    1. Advertising

  2. eagle

    Marina Guest

    That would only help you get the client resolution of the server, which
    doesn't really help.

    Try looking at the clientHeight and clientWidth properties of the document,
    or the body, using javascript.

    "eagle" <> wrote in message
    news:...
    > How do I get the screen resolution when running an asp.net project. I
    > tried the old way, and I get an error on the apiGetWindowRect that says
    > "Object reference not set to an instance of an object. "
    >
    >
    > Public Structure RECT
    > Dim x1 As Long
    > Dim y1 As Long
    > Dim x2 As Long
    > Dim y2 As Long
    > End Structure
    >
    >
    > Declare Function apiGetDesktopWindow Lib "user32" Alias _
    > "GetDesktopWindow" () As Long
    >
    > Declare Function apiGetWindowRect Lib "user32" Alias _
    > "GetWindowRect" (ByVal hwnd As Long, lpRect As RECT) _
    > As Long
    >
    > Function GetScreenResolution () as String
    > Dim R As new RECT
    > Dim hWnd As Long
    > hWnd = apiGetDesktopWindow()
    > 'RetVal = apiGetWindowRect(hWnd, R)
    > Dim RetVal As Long = apiGetWindowRect(hWnd, R)
    > GetScreenResolution = (R.x2 - R.x1) & "x" & (R.y2 - R.y1)
    > End Function
    >
    >
     
    Marina, Sep 9, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andrew FPGA
    Replies:
    0
    Views:
    976
    Andrew FPGA
    Sep 26, 2005
  2. Jenny

    Screen resolution

    Jenny, Aug 26, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    369
    Ken Schaefer
    Aug 26, 2003
  3. Pat
    Replies:
    5
    Views:
    541
  4. Thomas Morton

    Getting current screen resolution

    Thomas Morton, Jun 9, 2008, in forum: Python
    Replies:
    2
    Views:
    389
    Thomas Morton
    Jun 10, 2008
  5. Felipe Navas
    Replies:
    3
    Views:
    228
Loading...

Share This Page