Search Results for 'Pixel'

ATOM Icon

1 POSTS

  1. 2010/05/14 TwipsPerPixel by solarview

TwipsPerPixel

비주얼 베이직 6.0이하에서는 화면의 크기를 트윕(twip)으로 표시한다.
Screen.TwipsPerPixelX
Screen.TwipsPerPixelY


VBA에서는 없기에 다음과 같은 함수를 이용해야 한다. (source : MSDN)
Option Explicit

Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, _
ByVal hdc As Long) As Long
Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, _
ByVal nIndex As Long) As Long

Const HWND_DESKTOP As Long = 0
Const LOGPIXELSX As Long = 88
Const LOGPIXELSY As Long = 90

'--------------------------------------------------
Function TwipsPerPixelX() As Single
'--------------------------------------------------
'Returns the width of a pixel, in twips.
'--------------------------------------------------
Dim lngDC As Long
lngDC = GetDC(HWND_DESKTOP)
TwipsPerPixelX = 1440& / GetDeviceCaps(lngDC, LOGPIXELSX)
ReleaseDC HWND_DESKTOP, lngDC
End Function

'--------------------------------------------------
Function TwipsPerPixelY() As Single
'--------------------------------------------------
'Returns the height of a pixel, in twips.
'--------------------------------------------------
Dim lngDC As Long
lngDC = GetDC(HWND_DESKTOP)
TwipsPerPixelY = 1440& / GetDeviceCaps(lngDC, LOGPIXELSY)
ReleaseDC HWND_DESKTOP, lngDC
End Function


Posted by solarview

2010/05/14 00:55 2010/05/14 00:55
, , ,
Response
No Trackback , No Comment
RSS :
http://www.solarview.net/rss/response/302