Hi.
I wrote a component a while ago and recently found it again. It's for making forms transparent in a manner that allows a PNG image to be placed over it and still both retain their transparency. This is much nicer than the transparency that current windows os's offer as it's a simple on or off state for that. This way I can place a gradiated alpha image on a form and it sits nice and smoothly over whatever's behind the form.
The problem with it is that if I bring another application over my form and then minimize it (rather than click on my form or alt-tab to it etc.) then I can still see the contents of the now minimized window. In short - a refresh or repaint is being triggered when I bring to the application to the front, but not when it becomes the topmost through another application being minimzed.
I'd like to stop this happening.
Thanks in advance,
John.
Here's the component code.....
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
unit ClearForm;
interface
uses WinTypes, WinProcs, Messages, SysUtils, Classes, Controls,
Forms, Graphics;
type
TClearForm = class(TComponent)
private
procedure AutoInitialize;
procedure AutoDestroy;
protected
procedure Loaded; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
end;
procedure Register;
var
MainForm : TForm;
WndProc : Integer;
OldWndProc : Integer;
implementation
procedure Register;
begin
RegisterComponents('JCM', [TClearForm]);
end;
function HookProc(Hwnd, Msg, WParam, LParam: Integer): Integer; Stdcall;
begin
Result:=0;
If Msg<>WM_ERASEBKGND then
Result:=CallWindowProc(Pointer(OldWndProc), Hwnd, Msg, WParam, LParam);
end;
procedure TClearForm.AutoInitialize;
begin
MainForm:=TForm(Owner);
If Not (csDesigning in ComponentState) then
MainForm.BorderStyle:=bsNone;
OldWndProc:=SetWindowLong(MainForm.Handle, GWL_WNDPROC, Integer(@HookProc));
end;
procedure TClearForm.AutoDestroy;
begin
end;
constructor TClearForm.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
AutoInitialize;
end;
destructor TClearForm.Destroy;
begin
AutoDestroy;
inherited Destroy;
end;
procedure TClearForm.Loaded;
begin
inherited Loaded;
end;
end.