Help needed: Make application active

I want to make it so that my application is always the top application
in z order, unless it is minimized. So, I've done as much as I can
think of to make this happen but it's just not working. To test this
I've got a component that correctly notifies when the application is
no longer the "Active" window. When that happens I set a var
(appActive) to False. Then reset it to True when it becomes "Active"
again. So, I have Windows Explorer running, on the desktop, I open my
application, I click on the Explorer window, the code below runs but
my application does not become "Active". Can anyone help me out with
this?

if (not appActive) and
   (frmTools.cbStayOnTop.Checked) and
   (frmMain.WindowState <> wsMinimized) then begin
  SetActiveWindow(application.Handle);
  application.Restore;
  application.BringToFront;
  frmMain.BringToFront;
  frmMain.SetFocus;
  SetActiveWindow(frmMain.Handle);
end;

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----