tags:

views:

30

answers:

1

My WPF controls need to expose a MinWidth and MinHeigth for the hosting VB 6 application to consume and honor. What's the most reliable way to convert from one to the other.

(If it will help, I can change the ScaleMode property in VB 6 to whatever.)

+1  A: 
  • VB 6 Twips are in 1/1440 of an inch
  • WPF uses 1 = 1/96th of an inches
  • The ElementHost.Child property needs to be cast to a FrameworkElement
  • The difference between the form's width and the client area width needs to be accounted for

Therfore the formula is

vbForm.Width = (WpfControl.MinWidth / 96 * 1440) + (vbForm.Width - vbForm.ScaleWidth)

Jonathan Allen
+1 Although personally I would write `vbForm.ScaleWidth = (WpfControl.MinWidth * 1440) / 96` It's better to change ScaleWidth directly and also I prefer to use brackets to force evaluation order of `*` and `/`
MarkJ