Skip to main content
Thoughts from David Cornelius

Category

In the old DOS days, things were simple. You had 25 rows and 80 columns of text. Period. Well, if you knew the right tricks, you could double the rows or columns, but still it was pretty limited. This made programming fairly easy--you knew how much space you had to deal with. With a GUI, or Graphical User Interface, things can get stretched out, you can have larger fonts, and you can have themes on or off. So knowing how much space you have to display stuff isn't quite as cut and dried. But I'm going to look at just one aspect that can be surprising: themes.

In Windows XP, you could turn themes on to get rounded corners and a 3D effect on buttons. But it didn't affect the size of the controls or the width of the programs. But in Vista and in Windows 7, the new Aero Graphics increases the width of applications as shown in these screen shots.

Windows XP with themes OFF

Windows XP with themes ON

Windows Vista with themes OFF

Windows Vista with themes ON

I don't profess to have any answers here. There have been many discussions over the years about themes and fonts and scaling and so forth. A quick search will reveal many entries on the subject. But it is something to be aware of and plan for.

One thing that makes it easier in Delphi 2006 and newer are two new components, TFlowPanel and TGridPanel. With TFlowPanel, your controls automatically wrap as the screen gets narrower. If you want more control than that, use TGridPanel where you specify how many rows and columns make up an invisible grid on the panel and the controls stay within those boundaries.

By the way, the code used to display the widths in the above Delphi program is right here:


procedure TfrmWidthTest.ReportWidth;
begin
  StatusBar.Panels[0].Text := 'Width: ' + IntToStr(Width);
  StatusBar.Panels[1].Text := 'ClientWidth: ' + IntToStr(ClientWidth);
  StatusBar.Panels[2].Text := 'CmbWidth: ' + IntToStr(ComboBox.Width);
 
  sbSystem.Panels[0].Text := 'DlgWidth: ' + IntToStr(GetSystemMetrics(SM_CXDLGFRAME));
  sbSystem.Panels[1].Text := 'BorderWidth: ' + IntToStr(GetSystemMetrics(SM_CXBORDER));
  sbSystem.Panels[2].Text := 'EdgeWidth: ' + IntToStr(GetSystemMetrics(SM_CXEDGE));
end;