Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to initialize the column width from pixels. Pixel to Char conversion
Hi,
Programmatically I try to initialize the column width from a pixel value I have. I found a conversion function but doesn't function quite accurate. In below code, GetScreenXPI returns 96 on my computer. My default width is 8.43 char (64 pixel). PioxToCharX in this case would return 8 char for 64 pixels. What am I missing? Any help would be appreciated. Reto www.xcellery.com ' Conversion code '********************* Public Const TWIPS_PER_INCH = 1440 ' number TWIP units per inch Public Const TWIPS_PER_CHAR_X = 120 ' number TWIP units per logical character Public Function PixToCharX(ByVal pixels As Long) As Long PixToCharX = ((pixels / GetScreenXDPI) * TWIPS_PER_INCH) / TWIPS_PER_CHAR_X End Function Function GetScreenXDPI() As Long Dim hdc As Long hdc = CreateICA("DISPLAY", vbNullString, vbNullString, 0) If (hdc < 0) Then GetScreenXDPI = GetDeviceCaps(hdc, 88) 'screen res x DeleteDC (hdc) End If End Function |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how can we change units of column width to pixels? | Excel Discussion (Misc queries) | |||
column pixels vs column width | Excel Discussion (Misc queries) | |||
Open JPG and determine pixel width in VB? | Excel Programming | |||
with same font and pixel number different column width | Setting up and Configuration of Excel | |||
Column width in pixels how? | Excel Programming |