⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dialogstaticcontrols.pas

📁 學習資料網上下載
💻 PAS
📖 第 1 页 / 共 2 页
字号:
unit DialogStaticControls;

interface

uses Windows, Classes, SysUtils, cmpDialogEditor, DialogConsts;

type

TStaticControlInfo = class (TStandardControlInfo)
protected
  function GetClassSzOrID : TszOrID; override;
public
  class procedure CreateControlParams (var params : TCreateControlParams); override;
  function GetPropertyCount(kind: TPropertyKind): Integer; override;
  function GetPropertyEnumCount(kind: TPropertyKind; idx: Integer): Integer; override;
  function GetPropertyEnumName(kind: TPropertyKind; idx, enum: Integer): string; override;
  function GetPropertyName(kind: TPropertyKind; idx: Integer): string; override;
  function GetPropertyValue(kind: TPropertyKind; idx: Integer): Variant; override;
  function GetPropertyType(kind: TPropertyKind; idx: Integer): TPropertyType; override;
  procedure SetPropertyValue(kind: TPropertyKind; idx: Integer;const Value: Variant); override;
end;

TPictureControlInfo = class (TStaticControlInfo)
public
  class procedure CreateControlParams (var params : TCreateControlParams); override;
  class function GetDescription : string; override;
  function GetPropertyCount(kind: TPropertyKind): Integer; override;
  function GetPropertyEnumCount(kind: TPropertyKind; idx: Integer): Integer; override;
  function GetPropertyEnumName(kind: TPropertyKind; idx, enum: Integer): string; override;
  function GetPropertyName(kind: TPropertyKind; idx: Integer): string; override;
  function GetPropertyValue(kind: TPropertyKind; idx: Integer): Variant; override;
  function GetPropertyType(kind: TPropertyKind; idx: Integer): TPropertyType; override;
  procedure SetPropertyValue(kind: TPropertyKind; idx: Integer;const Value: Variant); override;
end;

TCaptionedStaticControlInfo = class (TStaticControlInfo)
protected
public
  function GetPropertyCount(kind: TPropertyKind): Integer; override;
  function GetPropertyEnumCount(kind: TPropertyKind; idx: Integer): Integer; override;
  function GetPropertyEnumName(kind: TPropertyKind; idx, enum: Integer): string; override;
  function GetPropertyName(kind: TPropertyKind; idx: Integer): string; override;
  function GetPropertyValue(kind: TPropertyKind; idx: Integer): Variant; override;
  function GetPropertyType(kind: TPropertyKind; idx: Integer): TPropertyType; override;
  procedure SetPropertyValue(kind: TPropertyKind; idx: Integer;const Value: Variant); override;
end;

TStaticTextControlInfo = class (TCaptionedStaticControlInfo)
public
  class function GetDescription : string; override;
end;

implementation

uses cmpDialogBox, variants;

const
  SS_REALSIZECONTROL = $40;

  StaticControlPropertyGeneralCount = 0;
  StaticControlPropertyStyleCount = 1;  // Sunken & Border removed - same as Client Edge & Static Edge
  StaticControlPropertyExtendedCount = 0;
  StaticControlPropertyCount : array [TPropertyKind] of Integer = (StaticControlPropertyGeneralCount, StaticControlPropertyStyleCount, StaticControlPropertyExtendedCount);
//  StaticControlPropertyGeneralName : array [0..StaticControlPropertyGeneralCount - 1] of string = (rstCaption);
  StaticControlPropertyStyleName : array [0..StaticControlPropertyStyleCount - 1] of string = (rstNotify);
//  StaticControlPropertyExtendedName : array [0..StaticControlPropertyExtendedCount - 1] of string = (rstRTLReadingOrder, rstRightAlignedText);
//  StaticControlPropertyGeneralType : array [0..StaticControlPropertyGeneralCount - 1] of TPropertyType = (ptString);
  StaticControlPropertyStyleType : array [0..StaticControlPropertyStyleCount - 1] of TPropertyType = (ptBoolean);
//  StaticControlPropertyExtendedType : array [0..StaticControlPropertyExtendedCount - 1] of TPropertyType = (ptBoolean, ptBoolean);

  PictureControlPropertyGeneralCount = 3;
  PictureControlPropertyStyleCount = 2;
  PictureControlPropertyExtendedCount = 0;
  PictureControlPropertyCount : array [TPropertyKind] of Integer = (PictureControlPropertyGeneralCount, PictureControlPropertyStyleCount, PictureControlPropertyExtendedCount);
  PictureControlPropertyGeneralName : array [0..PictureControlPropertyGeneralCount - 1] of string = (rstColor, rstImageID, rstType);
  PictureControlPropertyStyleName : array [0..PictureControlPropertyStyleCount - 1] of string = (rstImagePositioning, rstRightJustify);
//  PictureControlPropertyExtendedName : array [0..PictureControlPropertyExtendedCount - 1] of string = (rstRTLReadingOrder, rstRightAlignedText);
  PictureControlPropertyGeneralType : array [0..PictureControlPropertyGeneralCount - 1] of TPropertyType = (ptEnum, ptInteger, ptEnum);
  PictureControlPropertyStyleType : array [0..PictureControlPropertyStyleCount - 1] of TPropertyType = (ptEnum, ptBoolean);
//  PictureControlPropertyExtendedType : array [0..PictureControlPropertyExtendedCount - 1] of TPropertyType = (ptBoolean, ptBoolean);

  CaptionedStaticControlPropertyGeneralCount = 1;
  CaptionedStaticControlPropertyStyleCount = 6;
  CaptionedStaticControlPropertyExtendedCount = 2;
  CaptionedStaticControlPropertyCount : array [TPropertyKind] of Integer = (CaptionedStaticControlPropertyGeneralCount, CaptionedStaticControlPropertyStyleCount, CaptionedStaticControlPropertyExtendedCount);
  CaptionedStaticControlPropertyGeneralName : array [0..CaptionedStaticControlPropertyGeneralCount - 1] of string = (rstCaption);
  CaptionedStaticControlPropertyStyleName : array [0..CaptionedStaticControlPropertyStyleCount - 1] of string = (rstAlign, rstEllipsis, rstCenterVertically, rstNoPrefix, rstNoWrap, rstSimple);
  CaptionedStaticControlPropertyExtendedName : array [0..CaptionedStaticControlPropertyExtendedCount - 1] of string = (rstRTLReadingOrder, rstRightAlignedText);
  CaptionedStaticControlPropertyGeneralType : array [0..CaptionedStaticControlPropertyGeneralCount - 1] of TPropertyType = (ptString);
  CaptionedStaticControlPropertyStyleType : array [0..CaptionedStaticControlPropertyStyleCount - 1] of TPropertyType = (ptEnum, ptEnum, ptBoolean, ptBoolean, ptBoolean, ptBoolean);
  CaptionedStaticControlPropertyExtendedType : array [0..CaptionedStaticControlPropertyExtendedCount - 1] of TPropertyType = (ptBoolean, ptBoolean);

{ TStaticControlInfo }

class procedure TStaticControlInfo.CreateControlParams (var params : TCreateControlParams);
begin
  inherited;
  params.Style := params.Style or WS_GROUP
end;

function TStaticControlInfo.GetClassSzOrID: TszOrID;
begin
  Result.isID := True;
  Result.id := STATIC_ID;
end;

function TStaticControlInfo.GetPropertyCount(kind: TPropertyKind): Integer;
begin
  Result := inherited GetPropertyCount (kind) + StaticControlPropertyCount [kind]
end;

function TStaticControlInfo.GetPropertyEnumCount(kind: TPropertyKind;
  idx: Integer): Integer;
begin
  if idx < inherited GetPropertyCount (kind) then
    Result := inherited GetPropertyEnumCount (kind, idx)
  else
  begin
//    Dec (idx, inherited GetPropertyCount (kind));
    Result := 0;
  end
end;

function TStaticControlInfo.GetPropertyEnumName(kind: TPropertyKind; idx,
  enum: Integer): string;
begin
  if idx < inherited GetPropertyCount (kind) then
    Result := inherited GetPropertyEnumName (kind, idx, enum)
  else
  begin
//    Dec (idx, inherited GetPropertyCount (kind));
    Result := '';
  end
end;

function TStaticControlInfo.GetPropertyName(kind: TPropertyKind;
  idx: Integer): string;
begin
  if idx < inherited GetPropertyCount (kind) then
    Result := inherited GetPropertyName (kind, idx)
  else
  begin
    Dec (idx, inherited GetPropertyCount (kind));
    Result := '';
    case kind of
//      pkGeneral : Result := StaticControlPropertyGeneralName [idx];
      pkStyle   : Result := StaticControlPropertyStyleName [idx];
//      pkExtended : Result := StaticControlPropertyExtendedName [idx];
    end
  end
end;

function TStaticControlInfo.GetPropertyType(kind: TPropertyKind;
  idx: Integer): TPropertyType;
begin
  if idx < inherited GetPropertyCount (kind) then
    Result := inherited GetPropertyType (kind, idx)
  else
  begin
    Dec (idx, inherited GetPropertyCount (kind));
    Result := ptInteger;
    case kind of
//      pkGeneral : Result := StaticControlPropertyGeneralType [idx];
      pkStyle   : Result := StaticControlPropertyStyleType [idx];
//      pkExtended : Result := StaticControlPropertyExtendedType [idx];
    end
  end
end;

function TStaticControlInfo.GetPropertyValue(kind: TPropertyKind;
  idx: Integer): Variant;
begin
  if idx < inherited GetPropertyCount (kind) then
    Result := inherited GetPropertyValue (kind, idx)
  else
  begin
    Dec (idx, inherited GetPropertyCount (kind));

    case kind of
      pkStyle :
        case idx of
//          0 : Result := HasStyle [WS_BORDER];  Same as 'Client Edge'
          0 : Result := HasStyle [SS_NOTIFY];
//          2 : Result := HasStyle [SS_SUNKEN];  Same as 'Static Edge'
        end
    end
  end
end;

procedure TStaticControlInfo.SetPropertyValue(kind: TPropertyKind;
  idx: Integer; const Value: Variant);
begin
  if idx < inherited GetPropertyCount (kind) then
    inherited SetPropertyValue (kind, idx, Value)
  else
  begin
    Dec (idx, inherited GetPropertyCount (kind));

    case kind of
      pkStyle :
        case idx of
//          0 : begin HasStyle [WS_BORDER] := Value; recreateRequired := True end;
          0 : HasStyle [SS_NOTIFY] := Value;
//          2 : begin HasStyle [SS_SUNKEN] := Value; recreateRequired := True; end;
        end
    end
  end
end;

{ TPictureControlInfo }

class procedure TPictureControlInfo.CreateControlParams (var params : TCreateControlParams);
begin
  inherited;
  params.Style := (params.Style and not WS_GROUP) or SS_BITMAP;
  params.cx := 20;
  params.cy := 20
end;

class function TPictureControlInfo.GetDescription: string;
begin
  Result := rstPicture
end;

function TPictureControlInfo.GetPropertyCount(
  kind: TPropertyKind): Integer;
begin
  Result := inherited GetPropertyCount (kind) + PictureControlPropertyCount [kind];
end;

function TPictureControlInfo.GetPropertyEnumCount(kind: TPropertyKind;
  idx: Integer): Integer;
begin
  if idx < inherited GetPropertyCount (kind) then
    Result := inherited GetPropertyEnumCount (kind, idx)
  else
  begin
    Dec (idx, inherited GetPropertyCount (kind));
    Result := 0;

    case kind of
      pkGeneral :
        case idx of
          0 : if GetPropertyValue (kind, inherited GetPropertyCount (kind) + 2) = 0 then
                result := 4
              else
                result := 3;
          2 : result := 5
        end;

      pkStyle :
        case idx of
          0 : Result := 4
        end
    end
  end
end;

function TPictureControlInfo.GetPropertyEnumName(kind: TPropertyKind; idx,
  enum: Integer): string;
begin
  if idx < inherited GetPropertyCount (kind) then
    Result := inherited GetPropertyEnumName (kind, idx, enum)
  else
  begin
    Dec (idx, inherited GetPropertyCount (kind));
    Result := '';

    case kind of
      pkGeneral :
        case idx of
          0 :
            case enum of
              0 : result := rstBlack;
              1 : result := rstGrey;
              2 : result := rstWhite;
              3 : result := rstEtched;
            end;

          2 :
            case enum of
              0 : result := rstFrame;
              1 : result := rstRectangle;
              2 : result := rstIcon;
              3 : result := rstBitmap;
              4 : result := rstEnhancedMetaFile
            end
        end;
      pkStyle :
        case idx of
          0 :
            case enum of
              0 : Result := rstNone;
              1 : Result := rstCenterImage;
              2 : Result := rstRealSizeImage;
              3 : Result := rstRealSizeControl
            end
        end
    end
  end
end;

function TPictureControlInfo.GetPropertyName(kind: TPropertyKind;
  idx: Integer): string;
begin
  if idx < inherited GetPropertyCount (kind) then
    Result := inherited GetPropertyName (kind, idx)
  else
  begin
    Dec (idx, inherited GetPropertyCount (kind));
    Result := '';
    case kind of
      pkGeneral : Result := PictureControlPropertyGeneralName [idx];
      pkStyle   : Result := PictureControlPropertyStyleName [idx];
//      pkExtended : Result := PictureControlPropertyExtendedName [idx];
    end
  end
end;

function TPictureControlInfo.GetPropertyType(kind: TPropertyKind;
  idx: Integer): TPropertyType;
begin
  if idx < inherited GetPropertyCount (kind) then
    Result := inherited GetPropertyType (kind, idx)
  else
  begin
    Dec (idx, inherited GetPropertyCount (kind));
    result := ptInteger;
    case kind of
      pkGeneral : Result := PictureControlPropertyGeneralType [idx];
      pkStyle   : Result := PictureControlPropertyStyleType [idx];
//      pkExtended : Result := PictureControlPropertyExtendedType [idx];
    end
  end
end;

function TPictureControlInfo.GetPropertyValue(kind: TPropertyKind;
  idx: Integer): Variant;
var
  tp : Integer;
  s : Integer;
begin
  if idx < inherited GetPropertyCount (kind) then
    Result := inherited GetPropertyValue (kind, idx)
  else
  begin
    Dec (idx, inherited GetPropertyCount (kind));

    case kind of
      pkGeneral:
        begin
          tp := style and SS_TYPEMASK;
          result := Unassigned;

          case idx of
            0 :
              case tp of
                SS_BLACKRECT, SS_BLACKFRAME : result := 0;
                SS_GRAYRECT, SS_GRAYFRAME : result := 1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -