解决方法
如果你想以编程方式完成所有事情(也就是说,如果你不想在Delphi表单设计器中设计你的表单),那么你可以写
type TStatusWindowHandle = type HWND; function CreateStatusWindow(const Text: string): TStatusWindowHandle; var FormWidth,FormHeight: integer; begin FormWidth := 400; FormHeight := 164; result := CreateWindow('STATIC',PChar(Text),WS_OVERLAPPED or WS_POPUPWINDOW or WS_THICKFRAME or SS_CENTER or SS_CENTERIMAGE,(Screen.Width - FormWidth) div 2,(Screen.Height - FormHeight) div 2,FormWidth,FormHeight,Application.MainForm.Handle,HInstance,nil); ShowWindow(result,SW_SHOWNORMAL); UpdateWindow(result); end; procedure RemoveStatusWindow(StatusWindow: TStatusWindowHandle); begin DestroyWindow(StatusWindow); end;
procedure TForm3.Button1Click(Sender: TObject); var status: TStatusWindowHandle; begin status := CreateStatusWindow('Please Wait...'); try Sleep(2000); finally RemoveStatusWindow(status); end; end;