昨天在DFW上看到一個問題,要求“使程序窗口置于最低層(在桌面上);點擊“顯示桌面”以后還是在桌面上”,琢磨了一下,實現(xiàn)了“讓窗體在執(zhí)行了‘顯示桌面’以后仍舊顯示在桌面上”,代碼如下:
unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms;
type
  TForm1 = class(TForm)
  PRivate
    { Private declarations }
    procedure WndProc(var Message: TMessage); override;  // 重載
  public
    { Public declarations }
  end;
var
  Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.WndProc(var Message: TMessage);
var
  WndPosFlag: Integer;
begin
  if Message.Msg = WM_SHOWWINDOW then
  begin
    if Message.WParam = 0 then
    begin
      Exit;
    end;
  end;
  inherited;
end;
end.
可是。。。。。。有個前提:窗體屬性 FormStyle = fsStayOnTop 這個不可省。。。所以不能呆在所有窗體最后
spy++跟了半天,還是沒想明白為什么FormStyle屬性為fxNormal的時候WM_SHOWWINDOW消息在程序里就截不到。。。而斷點調試時能截到第一次,后面也再截不到了,神奇
不管FormStyle為什么程序明明都收到了WM_SHOWWINDOW消息的(而且消息值也都相同)
汗ing.....
新聞熱點
疑難解答