zoukankan      html  css  js  c++  java
  • 一个修改过简化版的InputQuery(简单实用,用到了Canvas)

    主要是觉得在单输入的情况下, 原来InputQuery输入框左边的文本太难看了......

    复制代码
      function _InputQuery(const ACaption: string; const APrompt: string; var AValue: string): Boolean;
      var
        nForm: TForm;
        nEdit: TEdit;
        nTop: Integer;
        nTextMetric: TTextMetric;
      begin
        Result := False;
        nForm := TForm.CreateNew(Application);
        with nForm do
        try
          Canvas.Font := Font;
          BorderStyle := bsDialog;
          Caption := ACaption;
          ClientWidth := 256;
          PopupMode := pmAuto;
          Position := poScreenCenter;
          nEdit := nil;
    
          GetTextMetrics(Canvas.Handle, nTextMetric);
    
          nTop := nTextMetric.tmAscent + 1;
    
          nEdit := TEdit.Create(nForm);
          with nEdit do
          begin
            Parent := nForm;
            Left := 8;
            Top := nTop;
            Width := nForm.ClientWidth - 16;
            MaxLength := 255;
            Text := AValue;
            SelectAll;
            Inc(nTop, Height + 4);
          end;
    
          if APrompt <> '' then
          begin
            with TLabel.Create(nForm) do
            begin
              Parent := nForm;
              AutoSize := False;
              Caption := APrompt;
              Font.Color := clGrayText;
              Left := 8;
              Top := nTop;
              Width := nForm.ClientWidth - 16;
              WordWrap := False;
              Inc(nTop, Height + 15);
            end;
          end;
    
          with TButton.Create(nForm) do
          begin
            Parent := nForm;
            Caption := '确定';
            ModalResult := mrOk;
            Default := True;
            SetBounds(nForm.ClientWidth - Width * 2 - 8 - 4, nTop, Width, Height);
          end;
          with TButton.Create(nForm) do
          begin
            Parent := nForm;
            Caption := '取消';
            ModalResult := mrCancel;
            Cancel := True;
            SetBounds(nForm.ClientWidth - Width - 8, nTop, Width, Height);
            nForm.ClientHeight := Top + Height + nTextMetric.tmAscent;
          end;
          if ShowModal = mrOk then
          begin
            AValue := nEdit.Text;
            Result := True;
          end;
        finally
          nForm.Free;
        end;
      end;
    复制代码

    http://www.cnblogs.com/hs-kill/p/4707744.html

  • 相关阅读:
    最近积累的JS 东西,分享一下
    C#定时任务框架Quartz.NET
    如何成为微软社区MVP以及年终总结
    git 基于某个分支创建分支
    iframe跨域-Js通信的一种方式
    tcp连接建立断开过程及状态变化
    MySQL-InnoDB的事务隔离与锁
    MySQL索引原理总结
    php gd实现简单图片验证码与图片背景文字水印
    php 取post数据的三种方式
  • 原文地址:https://www.cnblogs.com/findumars/p/5812159.html
Copyright © 2011-2022 走看看