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

Show form without changing Zorder

207 views
Skip to first unread message

Brian Matchey

unread,
Aug 17, 2004, 5:17:31 PM8/17/04
to
I want to show a form that serves as a progress bar for some process.
I would like this progress bar to not intrude on work I'm doing in other
applications while this application is processing.

The particular form that pops up is within a DLL that is called several
times while processing. What happens now is that every time the DLL
function is called, it calls frmProgress.Show, which brings the progress bar
form to the top of the zorder. If I'm working in another application at the
time, I am interupted and have to click back to the application I'm working
on.

How can I show a form without changing the ZOrder of the current active
application?


Brian Matchey

unread,
Aug 17, 2004, 5:59:02 PM8/17/04
to
From a different thread in this group (GetForegroundWindow mess up.), I got
a partial answer.
To make it work, I also had to add Exclude( FFormState, fsVisible ); in
OnFormCreate.

I still have a problem. The form is not active, but it still shows on top
of other windows. How do I get it to show "in the background" somewhere or
at topmost minus one?


procedure TfrmProgress.FormCreate(Sender: TObject);
begin
// Exclude visible so that we can call ShowNotActive;
Exclude( FFormState, fsVisible );
end;

procedure TfrmProgress.ShowNotActive;
begin
// Show the progress dialog, but do not activate the window.
ShowWindow( handle, SW_SHOWNA );
Visible := True;
end;


"Brian Matchey" <brianm...@mi-assistant.com> wrote in message
news:412275ea$1...@newsgroups.borland.com...

Peter Below (TeamB)

unread,
Aug 18, 2004, 6:20:22 AM8/18/04
to
In article <4122...@newsgroups.borland.com>, Brian Matchey wrote:
> From a different thread in this group (GetForegroundWindow mess up.), I got
> a partial answer.
> To make it work, I also had to add Exclude( FFormState, fsVisible ); in
> OnFormCreate.
>
> I still have a problem. The form is not active, but it still shows on top
> of other windows. How do I get it to show "in the background" somewhere or
> at topmost minus one?

See SetWindowPos, it allows you to place the form in the Z order relative to
some other window, e.g. the one returned from GetForegroundWindow before your
form is shown.


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


Brian Matchey

unread,
Aug 18, 2004, 11:17:44 AM8/18/04
to
Thx Peter.
Here is the finished product that works as desired.
One more question: Is the call to ShowWindow still necessary or is it
redundant?

procedure TfrmProgress.ShowNotActive( AWindowTitle:string );
var
ZOrder:HWND;
ForeGroundWindow:HWND;


begin
// Show the progress dialog, but do not activate the window.
ShowWindow( handle, SW_SHOWNA );

ForeGroundWindow := GetForegroundWindow;
// If the program doing the processing is foremost, then show the progress
bar on top.
if ForeGroundWindow=GetHandleFromPartialWindowTitle( AWindowTitle ) then
ZOrder := HWND_TOP
else
ZOrder := ForeGroundWindow;

SetWindowPos(Handle, // handle to window
ZOrder, // placement-order handle.
Left, // horizontal position
Top, // vertical position
Width,
Height,
// window-positioning options
SWP_NOACTIVATE or SWP_NOMOVE or SWP_NOSIZE);

Visible := True;
end;

"Peter Below (TeamB)" <10011...@compuXXserve.com> wrote in message
news:VA.0000b1b...@nomail.please...

Peter Below (TeamB)

unread,
Aug 19, 2004, 5:36:25 AM8/19/04
to
In article <41237318$1...@newsgroups.borland.com>, Brian Matchey wrote:
> Here is the finished product that works as desired.
> One more question: Is the call to ShowWindow still necessary or is it
> redundant?

I would leave it in. You can try to live without it but that would mean you
have to add SWP_SHOWWINDOW to the flag set.

0 new messages