In a recent blog someone pointed out to me that boolean values true and false should be uppercase because they are constants. This made me think, usually I put constants in uppercase, however when I code true and false they are always lowercase, so it raises a question about my code style, should all constants be uppercase? If so then true, false and nil should also always be uppercase, but for me this does not look correct. Should constants not be uppercase? One reason why constants are uppercase is so they stand out from variables, but is this the only reason?
When I develop in C#, I follow the recommendation for constants not to be uppercase, so I am starting to feel that maybe this should be the same in Delphi and constants should be camel case for local constants and pascal case for public ones.
Showing posts with label style. Show all posts
Showing posts with label style. Show all posts
Friday, 27 January 2017
Friday, 19 October 2012
How to put a single line border around a form
Recently I wanted to put a single line border around a form without having a title bar. The way I solved the problem was to set the border style to bsNone and put the following in the OnPaint event of the form.
var
YFrame: Integer;
Rect : TRect;
begin
inherited;
if not(fsModal in FormState) then
begin
YFrame := 1;
Rect.Left := 0;
Rect.Top := 0;
Rect.Right := Width;
Rect.Bottom := Height;
Canvas.Handle := GetWindowDC(Handle);
Canvas.Brush.Color := clBlack;
Canvas.Brush.Style := bsSolid;
Canvas.Rectangle(Rect.Left, Rect.Top, Rect.Right, YFrame);
Canvas.Rectangle(Rect.Left, Rect.Top, YFrame, Rect.Bottom);
Canvas.Rectangle(Rect.Right - YFrame, Rect.Top, Rect.Right, Rect.Bottom);
Canvas.Rectangle(Rect.Left, Rect.Bottom - YFrame, Rect.Right, Rect.Bottom);
end;
end;
var
YFrame: Integer;
Rect : TRect;
begin
inherited;
if not(fsModal in FormState) then
begin
YFrame := 1;
Rect.Left := 0;
Rect.Top := 0;
Rect.Right := Width;
Rect.Bottom := Height;
Canvas.Handle := GetWindowDC(Handle);
Canvas.Brush.Color := clBlack;
Canvas.Brush.Style := bsSolid;
Canvas.Rectangle(Rect.Left, Rect.Top, Rect.Right, YFrame);
Canvas.Rectangle(Rect.Left, Rect.Top, YFrame, Rect.Bottom);
Canvas.Rectangle(Rect.Right - YFrame, Rect.Top, Rect.Right, Rect.Bottom);
Canvas.Rectangle(Rect.Left, Rect.Bottom - YFrame, Rect.Right, Rect.Bottom);
end;
end;
Subscribe to:
Posts (Atom)