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.

  • 相关阅读:
    ios开发遇到的问题
    getopt()——命令行参数分析
    浅谈Samsung Exynos4412处理器
    TTL电平,CMOS电平,232/485电平,OC门,OD门基础知识
    (转载)跟Classic ARM 处理器说拜拜——Atmel SAMA5D3 Xplained开发板评测
    (转载)Quartus II中FPGA的管脚分配保存方法(Quartus II)
    DE2资源集锦
    收到DE2+LCM+ D5M套件,拾回DE2,努力,奋进!
    windows 服务器时间同步失败处理方法
    机械加工仿真软件-----三维弯管机仿真系统
  • 原文地址:https://www.cnblogs.com/jspdelphi/p/9395168.html
Copyright © 2011-2022 走看看