Results 1 to 15 of 15

Thread: [RESOLVED] Screen Resolution

  1. #1

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Resolved [RESOLVED] Screen Resolution

    Dear Team.
    My Program will work Effectively in 1024*768.Now I want to check wheather the this computer supports this screen resolution and supports 32 bit also.How can I ?
    Last edited by danasegarane; Sep 12th, 2006 at 07:02 AM.

  2. #2
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Screen Resolution

    is your program a game?

    if not then make sure your app supports their resolution - not the other way round...

  3. #3

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Screen Resolution

    MY Program is not a game.I want to check the resollution .If the machine doesn't support the 1024*768, i have to end the program.How can I check the screen resolution.

  4. #4
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Screen Resolution

    there are several ways - here's just one:
    VB Code:
    1. Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
    2. Private Const SM_CXSCREEN = 0
    3. Private Const SM_CYSCREEN = 1
    4.  
    5. Private Sub Command1_Click()
    6.     Debug.Print GetSystemMetrics(SM_CXSCREEN) & " x " & GetSystemMetrics(SM_CYSCREEN)
    7. End Sub

  5. #5

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Screen Resolution

    Dear Bushmobile.
    Thanks for the post.Will is return only 1024*768 or some other.

  6. #6

  7. #7

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Screen Resolution

    Will it return only 1024 * 768 or some other display modes? or 800*600 also.

  8. #8
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Screen Resolution

    if the screen's width is 800 and it's height in 600 then it will return 800 x 600.

    resolution is just the number of pixels that are on the screen

  9. #9

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Screen Resolution

    Please explain how to loop through the Resolution schme and check for the 1024*768 mode.Thanks in advance.

  10. #10
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Screen Resolution

    VB Code:
    1. Option Explicit
    2.  
    3. Const ENUM_CURRENT_SETTINGS As Long = -1&
    4. Const CCDEVICENAME = 32
    5. Const CCFORMNAME = 32
    6.  
    7. Private Type DEVMODE
    8.     dmDeviceName As String * CCDEVICENAME
    9.     dmSpecVersion As Integer
    10.     dmDriverVersion As Integer
    11.     dmSize As Integer
    12.     dmDriverExtra As Integer
    13.     dmFields As Long
    14.     dmOrientation As Integer
    15.     dmPaperSize As Integer
    16.     dmPaperLength As Integer
    17.     dmPaperWidth As Integer
    18.     dmScale As Integer
    19.     dmCopies As Integer
    20.     dmDefaultSource As Integer
    21.     dmPrintQuality As Integer
    22.     dmColor As Integer
    23.     dmDuplex As Integer
    24.     dmYResolution As Integer
    25.     dmTTOption As Integer
    26.     dmCollate As Integer
    27.     dmFormName As String * CCFORMNAME
    28.     dmUnusedPadding As Integer
    29.     dmBitsPerPel As Integer
    30.     dmPelsWidth As Long
    31.     dmPelsHeight As Long
    32.     dmDisplayFlags As Long
    33.     dmDisplayFrequency As Long
    34. End Type
    35.  
    36. Private Declare Function EnumDisplaySettings Lib "user32" Alias "EnumDisplaySettingsA" ( _
    37.     ByVal lpszDeviceName As Long, ByVal iModeNum As Long, lpDevMode As Any) As Boolean
    38.  
    39. Private Sub Command1_Click()
    40.     Dim DevM As DEVMODE, lEnum As Long
    41.    
    42.     EnumDisplaySettings 0&, ENUM_CURRENT_SETTINGS, DevM
    43.     Debug.Print "Currently: " & DevM.dmPelsWidth; " x " & DevM.dmPelsHeight & " at " & DevM.dmBitsPerPel & " bits/pixel"
    44.    
    45.     Debug.Print vbCrLf & "Available:"
    46.     Do While EnumDisplaySettings(0&, lEnum, DevM)
    47.         Debug.Print DevM.dmPelsWidth & " x " & DevM.dmPelsHeight & " at " & DevM.dmBitsPerPel & " bits/pixel"
    48.         lEnum = lEnum + 1
    49.     Loop
    50. End Sub
    based on the example at AllAPI.net

    why do you need to bother tho - check if the resolution isn't the same as your ideal using the code in post #4 and then flash up a msgBox saying "best viewed in X by Y"

  11. #11

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Screen Resolution

    I am doing for Internet Explore viewing.I have to restrict to user to 1024*768.So only i need to end my application if the system doesn't support that resolution

  12. #12

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Screen Resolution

    Thanks Bushmobile,
    Its working.Can you help me in getting the bit format of the system like 32 bit , 16 bit or 64 bit?

  13. #13

  14. #14

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Screen Resolution

    That doen't give the bit size?

  15. #15
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Screen Resolution

    nope - it gives you OS version, from which you can derive the bit-version

    i'm not sure if you can just get the bit-version - perhaps start a new thread (people will be more likely to look at it).

    Are you sure you mean the bit-version of the system and not the screen bit depth?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width