CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: number pixel

  1. #1
    Join Date
    Jul 2005
    Posts
    3

    number pixel

    How can I determine number pixel in resolution?

  2. #2
    Join Date
    Aug 2000
    Location
    NY, USA
    Posts
    632

    Re: number pixel

    Try to use Screen.Width and Screen.TwipsPerPixelX
    You'll get needed values.

    Vlad

  3. #3
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: number pixel

    You could also try:
    Code:
    Option Explicit
    'Declarations
    Private Declare Function GetDeviceCaps Lib _
    "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long
    
    Private Const HORZRES = 8 'X axis in pixels
    Private Const VERTRES = 10 'Y axis in pixels
    Private Const BITSPIXEL = 12 'Number of bits per pixel
    
    Dim i As Integer
    
    Private Sub cmdChange_Click() 'access the Desktop Properties Window
    Call Shell("rundll32.exe shell32.dll,Control_RunDLL desk.cpl")
    End Sub
    
    Private Sub Form_Load()
    Dim x, y, bp, ncol As Long
    
    x = GetDeviceCaps(Me.hdc, HORZRES)
    y = GetDeviceCaps(Me.hdc, VERTRES)
    
    MsgBox "Current Resolution is " & x & " X " & y & " Pixels"
    
    If x > 800 And y > 600 Or x < 800 And y < 600 Then
        MsgBox "This Program Is Designed In 600 By 800 Mode, " _
        & "Please Reset Your Resolution Settings To Get The Best Effect"
        End
    End If
    
    bp = GetDeviceCaps(Me.hdc, BITSPIXEL) 'get the bits per pixel
    MsgBox "Current Resolution Has " & bp & " Bits / Pixels"
    
    ncol = 1
    
    For i = 1 To bp 'determine number of colours
        ncol = ncol * 2
    Next
    
    MsgBox "Number Of Colors Is " & ncol
    
    End Sub

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

Featured