Jump to content

Converting dialog template units to twips


c.haslam
 Share

Recommended Posts

I am working on Rich Edit UDFs, specifically EM_SETTABSTOPS. MSDN says that tab stops are specified in dialog template units. But I wish to give the user the opportunity to enter them in twips, inches or centimeters. (EM_SETPARAFORMAT PFM_TABSTOPS expects twips.)

So: how does one convert from twips to dialog template units?

I experimented: when, calling _SendMessage, I ask for every 100 template dialog units, and stream out to a file, Word tells me that tabstops are set every 1.30 inches. When I look at the file using TextPad, the RTF includes \tx1875 . 1.30 times 1440 twips/inch = 1875 twips: great!

But why is 100 template dialog units = 1875 twips?

I tried:

$hDc = _misc_GetDC(0)
$iPixPerLU =  _MISC_GetDeviceCaps($hDc,$LOGPIXELSX)

and as expected, got 96 pixels per inch.

...chris

Edited by c.haslam
Spoiler

CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard

 

Link to comment
Share on other sites

I am working on Rich Edit UDFs, specifically EM_SETTABSTOPS. MSDN says that tab stops are specified in dialog template units. But I wish to give the user the opportunity to enter them in twips, inches or centimeters.

So: how does one convert from twips to dialog template units?

I experimented: when, calling _SendMessage, I ask for every 100 template dialog units, and stream out to a file, Word tells me that tabstops are set every 1.30 inches. When I look at the file using TextPad, the RTF includes \tx1875 . 1.30 times 1440 twips/inch = 1875 twips: great!

But why is 100 template dialog units = 1875 twips?

I tried:

$hDc = _misc_GetDC(0)
$iPixPerLU =  _MISC_GetDeviceCaps($hDc,$LOGPIXELSX)

and as expected, got 96 pixels per inch.

...chris

I think a horizontal dialog unit is 1/4 of the average character width of the font used in the dialog. That means that the average width of the font would be

1.3*96*4/100

which is 4.99 pixels

Doesn't sound very likely does it?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

I think a horizontal dialog unit is 1/4 of the average character width of the font used in the dialog. That means that the average width of the font would be

1.3*96*4/100

which is 4.99 pixels

Doesn't sound very likely does it?

No. But I have read that 1/4 stuff somewhere on MSDN.

Spoiler

CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...