Resize object by HxW using pixels

D

Dave Peterson

I've never done this, but there are a couple of hints in VBA's help. You may
want to read about PointsToScreenPixelsX and PointsToScreenPixelsY (or maybe
search google groups for hints and tips using those keywords).

Michel Pierron (a very smart API type guy) posted this:

Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowRect Lib "user32" _
(ByVal hwnd As Long, lpRect As RECT) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

Sub Ratio()
Dim hwnd&, R As RECT, msg As String
hwnd = FindWindow(vbNullString, Application.Caption)
GetWindowRect hwnd, R
MsgBox "Points/Pixels Ratio: " _
& Application.Width / (R.Right - R.Left) _
& vbTab & "-> (3/4)" & vbLf & "Pixels" _
& "/Points Ratio: " & Format((R.Right - R.Left) _
/ Application.Width, "0.00") & vbTab & "-> (4/3)", 64
End Sub

Maybe you can get the ratio of points to pixels and use that in your
calculations.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top