Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Transparent Form / Pass Through Clicks

135 views
Skip to first unread message

UK Chris

unread,
Feb 17, 2004, 3:54:32 PM2/17/04
to
While I realize this is a little bit of an odd request please give it
a moments though.

I would like to create a transparent form that is always on top and is
full-screen. My expectation is that I could see other apps "through"
the form and by adjusting the transparency alter the visible
brightness. I would also like any click to be applied to the
underlying application, not my transparent form.

The reasoning is that I have a TFT screen and I need to be able to
adjust the broghtness dynamically for use at night. The drivers do not
support altering the gamma ramp or brightness through code so I am
running out of options. I'd like to be able to switch between day and
night modes as easily as possible.

Any suggestions welcome.

Chris.


Peter Below (TeamB)

unread,
Feb 18, 2004, 5:16:48 AM2/18/04
to
In article <40327fb4$1...@newsgroups.borland.com>, UK Chris wrote:
> While I realize this is a little bit of an odd request please give it
> a moments though.
>
> I would like to create a transparent form that is always on top and is
> full-screen. My expectation is that I could see other apps "through"
> the form and by adjusting the transparency alter the visible
> brightness. I would also like any click to be applied to the
> underlying application, not my transparent form.

Well, if i read the docs correctly, and if you are using Win2K or XP,
using a topmost, layered window with the WS_EX_TRANSPARENT extended
window style should work for you. The WS_EX_TRANSPARENT style will make
mouse messages go to the window beneath (your transparent window would
never get any of them).

Add an overriden CreateParams method to your form, and a handler for the
OnCreate event.

procedure TForm1.CreateParams(var Params: TCreateParams); // override;
begin
inherited;
params.exstyle := params.ExStyle or WS_EX_TRANSPARENT;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
{ Next five properties can also be set at design-time }
Borderstyle := bsNone;
AlphaBlend := true;
AlphaBlendvalue := 25;
Color := clBlack;
Formstyle := fsStayOnTop;

Boundsrect := Screen.DesktopRect;
end;

A word of warning: using the WS_EX_TRANSPARENT style on an older
platform that does not support it will cause the form creation to fail
with an API error. But as said the whole scheme only works on 2K and XP
anyway, since only those platforms have support for layered windows.

--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be


Asseri Lintanen

unread,
Feb 18, 2004, 10:54:02 AM2/18/04
to
You did not say what display adapter / drivers you use, but atleast in
my ATI Radeon 9700 / Catalyst 4.2 one can change between different
Gamma/Contrast/Brighness presets with hotkeys. Easy enough.

Maybe you could diy a sensor device from an old joystic and a light
sensitive resistor to trigger the hotkey automatically when night falls :)

- Asseri

UK Chris

unread,
Feb 18, 2004, 10:59:54 AM2/18/04
to
Triggering is not an issue, it is a Chips & Tech 69000 driver which is
integrated into the motherboard for a kiosk PC with integrated touchscreen,
hence changing adaptor is not really an option.

The frustrating thing is that the driver has gamma correction in it's
advanced properties which works, but they do not work with adjustment
through software it seems.

Chris.

"Asseri Lintanen" <Asseri....@takethisaway.netsonic.fi> wrote in
message news:40338a37$1...@newsgroups.borland.com...

UK Chris

unread,
Feb 18, 2004, 11:15:12 AM2/18/04
to
Peter,

Thanks much for the reply, I have tried your suggestion with partial
success. Please excuse me if I am making silly mistakes, I am far from being
a guru.

I am using Delphi 6, in my form I have what is shown below. By altering the
AlphaBlend it dims my screen (on WinXP) beautifully, it also stays on top.
However mouse clicks do not go "through". I can switch to another app
(ALT+TAB) and manipulate it with the keyboard but no mouse clicks work.

I was wondering if I had missed something or if anything else might spring
to mind.

thanks again,

Chris.

Code (I had to try to figure out the override, did I do it right?)
:
unit Unit1;

interface

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

type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

type
TSubForm = class(TForm)
protected
procedure CreateParams(var Params: TCreateParams); override;
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TSubForm.CreateParams(var Params: TCreateParams); // override;


begin
inherited;
params.exstyle := params.ExStyle or WS_EX_TRANSPARENT;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
{ Next five properties can also be set at design-time }
Borderstyle := bsNone;
AlphaBlend := true;

AlphaBlendvalue := 180;


Color := clBlack;
Formstyle := fsStayOnTop;

Boundsrect := Screen.DesktopRect;
end;

end.


Alan Garny

unread,
Feb 18, 2004, 11:45:18 AM2/18/04
to
"UK Chris" <ukc...@hotmail.com> wrote in message
news:40338fb3$1...@newsgroups.borland.com...

> Code (I had to try to figure out the override, did I do it right?)

Nope, you didn't... See below...

Alan.

-------------------
unit Unit1;

interface

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

type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }

procedure CreateParams(var Params: TCreateParams); override;

public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.CreateParams(var Params: TCreateParams); // override;


begin
inherited;
params.exstyle := params.ExStyle or WS_EX_TRANSPARENT;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
{ Next five properties can also be set at design-time }
Borderstyle := bsNone;
AlphaBlend := true;
AlphaBlendvalue := 180;
Color := clBlack;
Formstyle := fsStayOnTop;

Boundsrect := Screen.DesktopRect;
end;

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

UK Chris

unread,
Feb 18, 2004, 12:16:39 PM2/18/04
to
Awesome, thanks Alan and Peter, it is working! It really is a great solution
to my problem! Thank you, thank you, thank you!

Chris.


0 new messages