[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

How to sublass...

Posted on 1998-08-29
3
Medium Priority
?
214 Views
Last Modified: 2010-04-04
I am reasonly new at the object side of Delphi.  Using D3.  I have purchased a 3rd party toolset with source, InfoPower.  They have a class, TwwDBEdit that I wish to make a similar class, but with an underline for a field instead of a complete border.  When I asked InfoPower about this, they said "I suppose you could subclass the component, and set the borderstyle to none, and have the wmpaint method paint the line the way you want..".

This is all fine and well, if I knew what I was doing... <g>. Can someone give me a shove in the right direction.  
-- Code fragments greatly appreciated --

Also, how do I get my new control to show up on the VCL controls panel.

Thanks
0
Comment
Question by:gspears060598
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
viktornet earned 400 total points
ID: 1338096
Start creating a new component and make it descendant from the one you want..in this case TwwDBEdit....
The unit should look something like this,,,,,
------------
unit Component1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

type
  TYourWwDBEdit = class(TwwDBEdit)
  private
    procedure Paint;override;//Only if there is a procedure like this...
  protected
    { Protected declarations }
  public
    constructor Create(AOwner : TComponent);override;
  published
    { Published declarations }
  end;

procedure Register;

implementation
constructor TYourWwDBEdit.Create(AOwner : TComponent);
begin
  Inherited Create(AOwner);
  //If you have any values you want to set by default here is you big chance...
end;
procedure TYourWwDBEdit.Paint;
begin
  //Paint the control......
end;
procedure Register;
begin
  RegisterComponents('Samples', [TwwDBEdit]);//This will show your component on the pallette
end;

end.
--------------

I think that's pretty much it...

Regards,
Viktor Ivanov
0
 

Author Comment

by:gspears060598
ID: 1338097
hi,

Your answer is just about complete.  Can you give me a little help with the wm_paint.  I was told this is what I need to use to draw the line.  I'd like it to be 3D, but I'll take what I can get.  I've tried to look up information, but haven't had a whole lot of luck yet...

0
 
LVL 10

Expert Comment

by:viktornet
ID: 1338098
Here is a code I've tried with the TLabel component.....It is not finished yet, but it will show you how to draw a 3D underlining under the caption of the label....
----------------
unit Label1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TLabel1 = class(TLabel)
  private
    { Private declarations }
  protected
    { Protected declarations }
  public
    procedure Paint;override;
    Constructor Create(AOwner : TComponent);override;
  published
    { Published declarations }
  end;

procedure Register;

implementation
Constructor TLabel1.Create(AOwner : TComponent);
begin
  Inherited Create(AOwner);
end;

procedure TLabel1.Paint;
var
  High : Integer;
begin
  Inherited Paint;
  High := Canvas.TextHeight(Caption) + 1;
  Canvas.Pen.Color := clBtnShadow;
  Canvas.MoveTo(0, High - 1);
  Canvas.LineTo(Canvas.TextWidth(Caption),High - 1);

  Canvas.Pen.Color := clBtnHighLight;
  Canvas.MoveTo(0, High + 1);
  Canvas.LineTo(Canvas.TextWidth(Caption),High + 1);

  Canvas.Pen.Color := Font.Color;
  Canvas.MoveTo(0, High);
  Canvas.LineTo(Canvas.TextWidth(Caption),High);
end;

procedure Register;
begin
  RegisterComponents('Samples', [TLabel1]);
end;

end.
-------------
Hope this helps =)

Regards,
Viktor Ivanov
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question