Delphi 7 and 125 dots per inch
Recently I was asked to modify a program to cope with screen resolutions higher than the standard 98 dpi. Looking on the net, there were lots of dire warnings, but I spotted something that looked helpful. All I needed to do was to switch auto-scroll off and switch auto-size on for each of the forms. I tried it, but it had unexpected consequences. With auto-size on, it trims all the empty screen area around the controls. The result was that my nicely designed layouts looked fairly aweful and really cramped.
I therefore hit on the idea of placing a label, with the caption “.” in the top left and bottom right of each form. This ensured that all the margins around the bits that mattered were preserved. I could have changed the text colour to be the same as the background colour, but did not bother, as you can barely see the dots.
Resizeable forms
The other unexpected consequence is that the forms are no longer re-sizeable. To resolve this, I had to switch back to auto-scroll on and auto-size off, but only after the form had displayed. To do this I use
PostMessage (Handle, WM_SCROLOFF, 0, 0)
which is handled by
procedure TProgEdit.WmScroloff (var mess: Tmessage); begin autoscroll := true; sutosize := false; progmemo.align := alClient; end;
I use PostMessage to ensure that the form has finished displaying before its attributes are reset. In some instances, I have had to change the alignment of a control from alClient to alLeft, to enable me to place the dot labels correctly, and so the alignment is also reset in WmScroloff.
It works for me, and seemed a lot less complicated than some of the stuff I read. One day, perhaps I will change the text colour of the dots to match the background.
Leave a Reply