Banged my head against this for quite some time. What I really wanted was a fullscreen app that appeared over the taskbar. While it appears that this is simple in XP, in Vista not so much. However, setting the form’s FormStyle to fsStayOnTop and WindowState to wsMaximized in combination with the code below to turn the Taskbar’s auto hide flag on achieves what I needed, and a bit more pleasantly as well (the Taskbar animates nicely out of the way).
Here’s the code from the FormShow event handler (you’ll need ShellAPI in your ‘uses’ statement):
procedure TMainForm.FormShow(Sender: TObject);
var
AppBarData: TAppBarData;
AutoHideOn: boolean;
begin
//check if autohide on already
AppBarData.cbSize := SizeOf(AppBarData) ;
AutoHideOn :=(SHAppBarMessage(ABM_GETSTATE, AppBarData)
and ABS_AUTOHIDE) > 0;
OrigTaskBarParam := -1;
//if it isn't, then we will turn it on temporarily
if not AutoHideOn then
begin
AppBarData.hWnd := FindWindow('SHELL_TRAYWND', nil);
//we'll also save the user's taskbar settings and
//restore them to the way they had them when we close
OrigTaskBarParam := SHAppBarMessage(ABM_GETSTATE, AppBarData);
//now we'll set it the way we want it
AppBarData.lParam := LParam(ABS_ALWAYSONTOP or ABS_AUTOHIDE);
SHAppBarMessage(ABM_SETSTATE, AppBarData);
end;
end;
Now, to be nice we’re saving the user’s original taskbar settings (before we fucked around with them) in a private field (OrigTaskBarParam) of our form. We’ll use this again in the form’s destroy handler:
procedure TMainForm.FormDestroy(Sender: TObject);
var
AppBarData: TAppBarData;
begin
//if we modified this we'll set it back to the original state
if OrigTaskBarParam <> -1 then
begin
AppBarData.cbSize := SizeOf(AppBarData) ;
AppBarData.lParam := OrigTaskBarParam;
AppBarData.hWnd := FindWindow('SHELL_TRAYWND', nil);
SHAppBarMessage(ABM_SETSTATE, AppBarData);
end;
end;
Conservative Andrew Sullivan gives us one of the best live blogs of tonight’s address and he ends with the best summary of the speech and what is to come:
“But look: the politics and rhetoric are superb, but all that matters is whether he can pull this off. The results are all that matter now. He has this moment; it could make him and the rest of us. It could destroy him or us. It’s our job in this crisis to support him and to criticize him constructively. We need to rise to the occasion he is rising to. And maybe most of us will.”
Hopefully we will.