Results 1 to 3 of 3

Thread: Resolved: Picture Box

  1. #1

    Thread Starter
    Frenzied Member yrwyddfa's Avatar
    Join Date
    Aug 2001
    Location
    England
    Posts
    1,253

    Resolved Resolved: Picture Box

    Is there anyway I can derive a picture box's pixel height and width from a hDC?
    Last edited by yrwyddfa; Jun 6th, 2006 at 05:13 AM.
    "As far as the laws of mathematics refer to reality, they are not certain; and as far as they are certain, they do not refer to reality." - Albert Einstein

    It's turtles! And it's all the way down

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

    Re: Picture Box

    VB Code:
    1. Private Declare Function WindowFromDC Lib "user32" ( _
    2.                 ByVal hdc As Long) As Long
    3.                
    4. Private Declare Function GetWindowRect Lib "user32" ( _
    5.                 ByVal hwnd As Long, _
    6.                 lpRect As RECT) As Long
    7.  
    8. Private Type RECT
    9.     Left As Long
    10.     Top As Long
    11.     Right As Long
    12.     Bottom As Long
    13. End Type
    14.  
    15. Private Sub Command1_Click()
    16.     Dim winRECT As RECT
    17.     GetWindowRect WindowFromDC(Picture1.hdc), winRECT
    18.    
    19.     With winRECT
    20.         Debug.Print "Width: " & .Right - .Left
    21.         Debug.Print "Height: " & .Bottom - .Top
    22.     End With
    23. End Sub

  3. #3

    Thread Starter
    Frenzied Member yrwyddfa's Avatar
    Join Date
    Aug 2001
    Location
    England
    Posts
    1,253

    Re: Picture Box

    Thanks
    "As far as the laws of mathematics refer to reality, they are not certain; and as far as they are certain, they do not refer to reality." - Albert Einstein

    It's turtles! And it's all the way down

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