Recent

Author Topic: Very simple component... no longer simple.  (Read 3641 times)

masonwheeler

  • New Member
  • *
  • Posts: 19
Very simple component... no longer simple.
« on: January 09, 2008, 12:38:54 am »
There's a very simple Delphi component I found online: an Unframed Radio Group.  Here's the entirety of its code:
Code: [Select]
unit UnFramedRadioGroup;

interface

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

type
  TUnFramedRadioGroup = class(TRadioGroup)
  private
    { Private declarations }
  protected
    Procedure Paint; override;
      { Protected declarations }
  public
    { Public declarations }
  published
    { Published declarations }
  end;

procedure Register;

implementation

procedure TUnFramedRadioGroup.Paint;
begin
  //Nothing and no inherited
end;

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

end.

What it does is take the normal TRadioGroup and override the Paint method with a blank method so that the frame doesn't get painted.  Unfortunately, in Lazarus, TRadioGroup doesn't have a Paint method, so this component doesn't translate.  What do I need to do to get this running properly?

OnixJr

  • Full Member
  • ***
  • Posts: 172
    • http://www.brlazarus.kit.net
RE: Very simple component... no longer simple.
« Reply #1 on: January 09, 2008, 01:47:19 am »
Hi,
it's must work as you expect:

Code: [Select]

unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, LMessages,
  ExtCtrls, StdCtrls;

type

  { TUnFramedRadioGroup }

  TUnFramedRadioGroup = class(TRadioGroup)
  private
    { Private declarations }
    procedure Paint(var Msg: TLMPaint); message LM_PAINT;
  protected
      { Protected declarations }
  public
    { Public declarations }
  published
    { Published declarations }
  end;

type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    RadioGroup1: TRadioGroup;
    procedure Button1Click(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form1: TForm1;
  CTest: TUnFramedRadioGroup;

implementation

{ TUnFramedRadioGroup }

procedure TUnFramedRadioGroup.Paint(var Msg: TLMPaint);
begin
  ShowMessage('Test?');
end;

{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);
begin
  CTest := TUnFramedRadioGroup.Create(Self);
  CTest.Parent := Self;
end;

initialization
  {$I unit1.lrs}

end.


=)
Portal Lazarus Brasil - http://lazaruspascal.codigolivre.org.br/portal.php
Lazarus BOOK (in portuguese) - http://lazarus-book.blogspot.com
<hipernetjr@yahoo.com.br> - Curitiba/Brazil

 

TinyPortal © 2005-2018