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.
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
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
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...
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.
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.
-------------------
Chris.