From: Robert M. <rm...@po...> - 2005-12-06 23:49:04
|
Hi, Nice to see you here after our exchange in comp.lang.perl.misc. Veli-Pekka T=E4til=E4 wrote: > By the=20 > way, my Win32::GUI version installed with PPM appears to be 1.02=20 > (looking inside the PM file). 1.03 is available for download from SourceForge and is now in=20 ActiveState repository for perl 5.8 > But I'm still worried about the spacing. By looking at dialogs=20 > magnified, I've concluded that there's more than just a bit spacing=20 > between vertically layed out check boxes. What do the Win32 interface=20 > guidelines say about this? 'Official' Microsoft recommendations: http://msdn.microsoft.com/library/default.asp?url=3D/library/en-us/dnwue/= html/ch14e.asp > Lastly, I've been pondering coordinates and spacing too. It would appea= r=20 > to me the Win32::GUI Windows use client coordinates but do the dialogs=20 > use dialog units, then? The Win32 API has a function GetDialogBaseUnits= =20 > but I have not seen it imported in Win32::GUI at all. Win32::GUI currently uses pixel positioning exclusively. Top-level=20 windows in screen-coordinates and child windows in client coordinates.=20 No use of dialog units currently, and you are correct that=20 GetDialogBaseUnits is not currently implemented. The following perl function can be used to do the conversion: ## Dialog Base Units to pixels # - object is a Win32::GUI::Window # - direction is one of: # Horizontal: W(idth), X, L(eft), R(ight) # Vertical : H(eight), Y, T(op), B(ottom) # - dbu is the dialog units to convert # Returns btu converted to pixels # Returns undef when in error sub convDBU { my ($object, ,$direction, $dbu) =3D @_; my %font_metrics =3D Win32::GUI::Font::GetMetrics($object->GetFont()); if (index("WXLR",$direction) !=3D -1) { my $dbuX =3D $font_metrics{-avgwidth}; $dbu =3D ($dbuX * $dbu) / 4; } elsif (index("HYTP",$direction) !=3D -1) { my $dbuY =3D $font_metrics{-height}; $dbu =3D ($dbuY * $dbu) / 8; } else { return undef; } # use int, as we need something that is always too small return int($dbu); } Regards, Rob. |