Delphi/CB
•  Greatis •  Security •  AppDatabase •  Utilities •  Visual Basic • .NET •  just4fun
Delphi / C++ Builder
Components, utilities and tips for Delphi and C++ Builder developers
More info
Object Inspector FAQ
Object Inspector Home
Delphi Components
See also
Products
Form Designer
Runtime Fusion
Print Suite
Commented Image
Image Editor  new!
Delphi Toys
Ultimate Pack  hot!

FAQs
Form Designer FAQ
Print Suite FAQ
Image Editor FAQ

Links
Software for .NET
Software for VB 6
Delphi Tips & Tricks

Services
Outsourcing
Owner-drawing
TCommonInspector has an owner-drawing feature that allows to draw the name and value area for each property by OnDrawName and OnDrawValue events:
procedure TForm1.CommonInspector1DrawName(Sender: TObject;
  TheIndex: Integer; TheCanvas: TCanvas; TheRect: TRect);
begin
  Inc(TheRect.Left,TheIndex*2+4);
  DrawText(TheCanvas.Handle,
    PChar((Sender as TCommonInspector).Names[TheIndex]),-1,
    TheRect,DT_SINGLELINE or DT_VCENTER);
end;
TCommonInspector has two useful methods: DrawPropertyNameDefault and DrawPropertyValueDefault. These methods draw the property name and value using the passed index, canvas and rectangle and can be used for simplification the drawing. The follow example draws the color rectangle at the left side of the area, modifies the canvas settings and rectangle and calls the DrawPropertyNameDefault for drawing the default text:
var
  BackColors: array[0..3] of TColor = (clNavy,clMaroon,clGreen,clOlive);

...

procedure TForm1.CommonInspector1DrawName(Sender: TObject;
  TheIndex: Integer; TheCanvas: TCanvas; TheRect: TRect);
begin
  with Sender as TCommonInspector,TheCanvas,TheRect do
  begin
    Brush.Color:=BackColors[TheIndex mod 4];
    FillRect(Rect(Left+4,Top+4,Left+4+Bottom-Top-8,Bottom-4));
    Inc(Left,Bottom-Top-12);
    Brush.Style:=bsClear;
    DrawPropertyNameDefault(TheCanvas,TheIndex,TheRect);
  end;
end;

Greatis Software Greatis | Security | AppDatabase | Utilities | Delphi/CB | Visual Basic | .NET | just4fun

Contacts | Add to Favorites | Recommend to a Friend | Privacy Policy | Copyright © 1998-2008 Greatis Software