I've been trying to convert the measurements for Wizards from the Wizard97 specification into pixels for god knows how long now and I can't ever seem to get it to look right at all.
If you see this page on Welcome and Completion Page Layouts, all the measurements are in Dialog Units for some special reason I can't recall at this point in time.
Anyway, after spending a while looking for the stuff todo it, I found the GetDialogBaseUnits() function, made a little wrapper for it and when I try to align the controls on my form to the measurements provided by the specification, they are nowhere near them.
Here's my attempt at wrapping the API up:
VB Code:
Public Class DialogUnits
Private Declare Function GetDialogBaseUnits Lib "user32" () As Integer
Private _Width As Integer
Private _Height As Integer
Public Sub New()
Call CalculateDialogUnits()
End Sub
Public ReadOnly Property Width() As Integer
Get
Return _Width
End Get
End Property
Public ReadOnly Property Height() As Integer
Get
Return _Height
End Get
End Property
Public Function GetHeightInPixels(ByVal dialogUnits As Integer) As Integer
Return (_Height * dialogUnits) / 8
End Function
Public Function GetWidthInPixels(ByVal dialogUnits As Integer) As Integer
Return (_Width * dialogUnits) / 4
End Function
Public ReadOnly Property Size() As SizeF
Get
Return New SizeF(_Width, _Height)
End Get
End Property
Private Sub CalculateDialogUnits()
Dim DialogUnits As Long = GetDialogBaseUnits
_Width = LongManipulation.GetLoWord(DialogUnits)
_Height = LongManipulation.GetHiWord(DialogUnits)
End Sub
End Class
And the LongManipulation class:
VB Code:
Public Class LongManipulation
Public Shared Function GetLoWord(ByVal sourceLong As Long) As Integer
Return (sourceLong / &H10000) And &HFFFF&
End Function
Public Shared Function GetHiWord(ByVal sourceLong As Long) As Integer
Return sourceLong And &HFFFF&
End Function
Public Shared Function IntegersToLong(ByVal loWord As Integer, ByVal hiWord As Integer) As Long
Return (hiWord * &H10000) + (loWord And &HFFFF&)
End Function
End Class
Can someone please show me where I'm going wrong because I got no idea what I'm doing wrong. It seems to be logically correct, but something's a miss.
Last edited by Ideas Man; Apr 14th, 2005 at 01:46 AM.
I use Microsoft Visual Basic 2005. (Therefore, most code samples I provide will be based around the .NET Framework v2.0, unless otherwise specified)
... that doesn't exactly help me . I'm not worried about the IntegersToLong function, that was just something that was tagged on when I found that code, and the KB article didn't help all too much sorry.
I use Microsoft Visual Basic 2005. (Therefore, most code samples I provide will be based around the .NET Framework v2.0, unless otherwise specified)
Nah, see that's too big. Compare the form when you click the button to the picture or any wizard in Windows such as the New Connection Wizard in Windows XP. The inner area is bigger than the entire form for the wizard.
Which makes me think that the numbers are supposed to be some decimal number, not whole integers because when you divide by 4 and 8 for width and height respectivly, you get like 1 & 2 (or 2 & 1, one or the other) which is too big, and when you set it to the size of the dialog units, it's too small.
BTW, the title font is Verdana size 12, Bold.
I use Microsoft Visual Basic 2005. (Therefore, most code samples I provide will be based around the .NET Framework v2.0, unless otherwise specified)