zoukankan      html  css  js  c++  java
  • EnableTaskWindows,DisableTaskWindows

    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.

  • 相关阅读:
    Codeforces 1316B String Modification
    Codeforces 1305C Kuroni and Impossible Calculation
    Codeforces 1305B Kuroni and Simple Strings
    Codeforces 1321D Navigation System
    Codeforces 1321C Remove Adjacent
    Codeforces 1321B Journey Planning
    Operating systems Chapter 6
    Operating systems Chapter 5
    Abandoned country HDU
    Computer HDU
  • 原文地址:https://www.cnblogs.com/jspdelphi/p/9395168.html
Copyright © 2011-2022 走看看