标签:控制 begin dal window osi 注意 图片 ram return
EnableTaskWindows
DisableTaskWindows
在Delphi中显示一个窗口有两种方式,模态方式显示(ShowModal)和非模态方式显示(Show),模态方式显示窗口时,必须在自身关闭后才能使父窗口起作用,但有时我们想要实现一个窗口,既要具有模态窗口的特性,但又要能从父窗口中控制它,如显示一个表示处理进行过程的进度框。利用DisableTaskWindows和 EnableTaskWindows 可以达到这一效果。
下面是在程序里中的一个小应用,删除选中数据。可以避免删除过程中,更新选中状态造成的错误。
窗体注意
1. Position = poMainFormCenter
2.CloseQuery事件中控制窗体是否能关闭
==============================================================================
object Fprogress: TFprogress
Left = 756
Top = 497
BorderIcons = []
BorderStyle = bsDialog
Caption = ‘Fprogress‘
ClientHeight = 80
ClientWidth = 262
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = ‘Tahoma‘
Font.Style = []
OldCreateOrder = False
Position = poMainFormCenter
OnCloseQuery = FormCloseQuery
PixelsPerInch = 96
TextHeight = 13
object ProgressBar1: TProgressBar
Left = 29
Top = 34
Width = 209
Height = 17
TabOrder = 0
end
end
=============================================================================
unit pprogress;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls;
type
TFprogress = class(TForm)
ProgressBar1: TProgressBar;
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
private
Fwlist: Pointer;
public
/// <summary>
/// 显示进度窗口
/// </summary>
/// <param name="ACaption">标题</param>
/// <returns>THandle</returns>
class function ShowM(ACaption: string): THandle;
/// <summary>
/// 更新进度条
/// </summary>
/// <param name="value">位置</param>
/// <returns>None</returns>
class procedure Position(value: Integer);
/// <summary>
/// 关闭进度窗口
/// </summary>
/// <returns>None</returns>
class procedure CloseM;
end;
var
Fprogress: TFprogress;
implementation
{$R *.dfm}
var
LcanClose: Boolean = false;
{ TFprogress }
class procedure TFprogress.CloseM;
begin
LcanClose := True;
EnableTaskWindows(Fprogress.Fwlist);
Fprogress.Close;
end;
class procedure TFprogress.Position(value: Integer);
begin
Fprogress.ProgressBar1.Position := value;
end;
class function TFprogress.ShowM(ACaption: string): THandle;
begin
Fprogress := TFprogress.Create(nil);
Fprogress.ProgressBar1.Position := 0;
Fprogress.Caption := ACaption;
LcanClose := False;
Result := Fprogress.Handle;
Fprogress.Fwlist := DisableTaskWindows(Result);
Fprogress.Show;
end;
procedure TFprogress.FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
begin
CanClose := LcanClose;
end;
end.
EnableTaskWindows,DisableTaskWindows
标签:控制 begin dal window osi 注意 图片 ram return
原文地址:https://www.cnblogs.com/jspdelphi/p/9395168.html