Board index » delphi » Controls that are invisible but still work?

Controls that are invisible but still work?

I want to write a program that goes through the controls and replaces them
with bitmaps.  This means i have to hide the controls so they don't get
painted over the bitmaps, but i want the controls to still function.

Is there an easy way of doing this, and are there any source examples of a
component that can do this?

Cheers
Spanner

 

Re:Controls that are invisible but still work?


Create your own descendents to these controls and override the painting
procedure.

Quote
"Spanner" <ben.langri...@btinternet.com> wrote in message

news:88919n$qk0$1@neptunium.btinternet.com...
Quote
> I want to write a program that goes through the controls and replaces them
> with bitmaps.  This means i have to hide the controls so they don't get
> painted over the bitmaps, but i want the controls to still function.

> Is there an easy way of doing this, and are there any source examples of a
> component that can do this?

> Cheers
> Spanner

Re:Controls that are invisible but still work?


Every control is descended from another control, which is ultimately derived
from TComponent.  For example, TEdit is descended from TCustomEdit and so
on.  What you want to do requires you to 1) create your own controls and
paint the controls your own way, or 2) find someone who already did this.
I'd get a book on component creation or check out the Delphi Super Page
first http://sunsite.icm.edu.pl/delphi/

Quote
"Spanner" <ben.langri...@btinternet.com> wrote in message

news:889ohe$als$1@neptunium.btinternet.com...
Quote
> BlueGI wrote in message ...
> >Create your own descendents to these controls and override the painting
> >procedure.

> Not sure i understand... descendents?  could you give me an example?  And
> how do i override the painting procedure?

> Cheers
> Spanner

Re:Controls that are invisible but still work?


If these are controls are for example buttons for example, assign
visible property to false, and add the attached code sample below to
the revelant control events, and set KeyPreview to true, and you will
now be able access the accelerator key of the button, even though it
is not visible.

//##### Code Sample Start #####
procedure TForm1.Button1Click(Sender: TObject);
begin
  messagebox(0, 'Hello World', pchar(application.title), mb_ok);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Form1.KeyPreview := true;
  Button1.visible := false;
  Button1.Caption := '&Button';
end;

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
var
  idx: integer;
begin
  for idx := 0 to ControlCount - 1 do
    if Controls[idx] is TButton then
      if IsAccel(Key, TButton(Controls[idx]).Caption) then
        TButton(Controls[idx]).Click;
end;
//##### Code Sample End #####

As you can see if you now press "Alt+B", you will trigger the Button
onclick event, to show the "Hello World" message.

Chris

On Mon, 14 Feb 2000 13:45:08 -0000, "Spanner"

Quote
<ben.langri...@btinternet.com> wrote:
>I want to write a program that goes through the controls and replaces them
>with bitmaps.  This means i have to hide the controls so they don't get
>painted over the bitmaps, but i want the controls to still function.

>Is there an easy way of doing this, and are there any source examples of a
>component that can do this?

>Cheers
>Spanner

Other Threads