Page tree
Skip to end of metadata
Go to start of metadata

Q: I need to write some methods (like VB6 Move) that are using VB6 Twips. So I must translate Twips but in the exact same way you're doing it in WpfSubSystem.

A: For Twips to Pixels: 

Pixels = Twips/15.0 for WPF because geometry is floating point.
Pixels = Twips/15 for WinForms because geometry is integer.
The tool supports metatypes TwipsX and TwipsY.  Changing type="Integer" to type="TwipsX" will cause the tool to modify numeric  constants added/subtracted/assigned to the symbol.  YOu can see many examples in the metalang.   Search for Twips to see.  
One thing you will need to be carefule about is the integer to floating point difference in WinForms and WPF.  The tool was designed for WinForms and the metalang files assume most screen geometry is integer.  Some target code patterns in VB6controls.xml  may still need to be adjusted to Single rather than Integer.  Since type is not something that can vary by subsystem, you may need a custom vbcontrols.xml to do this.  Unfortunately, the tool treats TwipsX/TwipsY as an integer quantity.  So you may need to use a post-edit like "/15" to "/15.0".  A more elegant solution would be nice, but we need a clear problem statement and strategy as well as some details for testing to do that. 
There are a few other adjustments here and there: I know menu bar height has to be adjusted.  We add 20, but probably need to add 24.  
Note that using ScaleMode to change VB6 default scaling from Twips to something else changes the rules and requires either reworking the code or using runtime support that accounts for ScaleMode changes. 
The FileExplorer sample does control sizing at runtime and shows how Twips can be used with FixType to correct Control geometry calculations.  One of my open tasks is to implement a FileExplorerWPF sample using the API.  The latest version of the tool and API can can support that FileExplorer for WinForms.  There were MANY enhancements made to the API for that. 
  • No labels