Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

form always visible 1

Status
Not open for further replies.

Flisk

Programmer
Oct 8, 2004
11
SE
hello, i have wrote a simple program that shows some systeminfo on the screen, my form is transparent and does'nt shows on taskbar, and i want it to always stay on desktop, but if i click on 'show desktop' that minimize all active windows, it also minimize my program :/ is it any solution for do this ??

if you don't understand what i really mean, i can say i want it to work like the 'samurize-program' , 'pin to desktop'

btw i'm using borland delphi 7.0
 
unit Unit1;

interface

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

type
TForm1 = class(TForm)
private
procedure CreateParams (var Params: TCreateParams); override;
public
procedure WMSize(var M : TWMSIZE) ;
Message WM_Size;
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.WMSize(var M:TWMSIZE) ;
begin
if M.SizeType=Size_Minimized then
begin
Showwindow(application.MainForm.Handle,SW_RESTORE);
end;
end;


procedure TForm1.CreateParams (var Params: TCreateParams);
begin
inherited CreateParams(Params);
with Params do begin
ExStyle := ExStyle or WS_EX_APPWINDOW;
WndParent := GetDesktopwindow;
end;
with Form1 do
begin
Brush.Style := bsClear;
BorderStyle := bsNone;
WindowState := wsMaximized
end;
end;
 
Change the ExStyle line to read this

ExStyle := ExStyle or WS_EX_APPWINDOW OR WS_EX_TRANSPARENT or WS_EX_TOPMOST;

It will allow for refreshing of the screen but still keep your form on top.
 
This code can add some more fun



procedure TForm1.CreateParams (var Params: TCreateParams);
begin
inherited CreateParams(Params);
with Params do begin
ExStyle := ExStyle or WS_EX_TOPMOST OR WS_EX_TRANSPARENT ;
end;
with Form1 do
begin
Brush.Style := bsClear;
BorderStyle := bsNone;
WindowState := wsMaximized
end;
EnableWindow(FindWindow('Shell_TrayWnd',nil), FALSE);

// ShowWindow(FindWindow ('Shell_TrayWnd',nil), SW_HIDE) ; //Hide the taskbar
end;


procedure TForm1.FormDestroy(Sender: TObject);
begin
// ShowWindow(FindWindow ('Shell_TrayWnd',nil), SW_SHOWNA) ; //Show the taskbar
EnableWindow(FindWindow('Shell_TrayWnd',nil), TRUE);
end;


procedure TForm1.FormCreate(Sender: TObject);

begin
ShowWindow(Application.Handle, SW_HIDE);
SetWindowLong(Application.Handle, GWL_EXSTYLE,
GetWindowLong(Application.Handle, GWL_EXSTYLE)
or WS_EX_TOOLWINDOW );

end;
 
thanks for a fast reply, i'll check this out later :)

/Flisk
 
this is what i have before i asked the question


unit Unit1;

interface

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

type
TForm1 = class(TForm)
private
{ Private declarations }
protected
procedure CreateParams(var Params: TCreateParams); override;
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
if Assigned(Application.MainForm) then
begin
Params.WndParent := GetDesktopWindow;
Params.Style := WS_CHILD;
end;
end;


---------------------------



{this makes so the program disappear on taskbarmthe way i wanted :) }
procedure TForm1.FormShow(Sender: TObject);
begin
ShowWindow(Application.Handle,SW_HIDE);
SetWindowLong(Application.Handle, GWL_EXSTYLE, GetWindowLong(Application.Handle, GWL_EXSTYLE) or WS_EX_TOOLWINDOW and not WS_EX_APPWINDOW);
end;

-------------------------------------------------------
and it works fine, but minimize if press on 'show desktop'-button on taskbar.

i have tried to make a new project with the code you suggested and i put it where it should be, and the result is the program just hanged when i try to run it from delphi :),

so i tried to take a small pieces of it and implent it to program, but it still minimize when i push the btn :/,

 
Try replacing your code with this. This code will hide the app on the task bar and also when minimize eg (showdesktop) will keep your form on top.




procedure TForm1.WMSize(var M:TWMSIZE) ;
begin
if M.SizeType=Size_Minimized then
begin
Showwindow(application.MainForm.Handle,SW_RESTORE);
end;
end;


procedure TForm1.CreateParams (var Params: TCreateParams);
begin
inherited CreateParams(Params);
with Params do begin
ExStyle := ExStyle or WS_EX_TOPMOST;
WndParent := GetDesktopwindow;
end;
end;


procedure TForm1.FormCreate(Sender: TObject);
begin
ShowWindow(Application.Handle, SW_HIDE);
SetWindowLong(Application.Handle, GWL_EXSTYLE,
GetWindowLong(Application.Handle, GWL_EXSTYLE)
or WS_EX_TOOLWINDOW );

end;

procedure TForm1.FormShow(Sender: TObject);
begin

ShowWindow(Application.MainForm.Handle, SW_HIDE);
SetWindowLong(Application.MainForm.Handle, GWL_EXSTYLE,
GetWindowLong(Application.MainForm.Handle, GWL_EXSTYLE)
or WS_EX_TOOLWINDOW );
end;

 
well i have tried your code and it hangs my program big time with some errors. i just have a question about this i wrote earlier

this code should make so the program always shows on background, just for a test , how to call this arguments if i want to do that ?

i am new with 'functions'


this code:


procedure TForm1.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
if Assigned(Application.MainForm) then
begin
Params.WndParent := GetDesktopWindow;
Params.Style := WS_CHILD;
end;
end;


if i want to use that code if i press a button, what to type then ?? :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top