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

📄 spdialogs.pas

📁 P2P即时通讯源码(DELPHI编写)
💻 PAS
📖 第 1 页 / 共 4 页
字号:
  ButtonHeight := MulDiv(14, DialogUnits.Y, 8);

  with TspSkinButton.Create(Form) do
  begin
    Parent := Form;
    DefaultFont := DefaultButtonFont;
    UseSkinFont := Self.UseSkinFont;
    Caption := SP_MSG_BTN_OK;
    ModalResult := mrOk;
    Default := True;
    SetBounds(MulDiv(38, DialogUnits.X, 4), ButtonTop, ButtonWidth,
              ButtonHeight);
    DefaultHeight := ButtonHeight;
    SkinDataName := FButtonSkinDataName;
    SkinData := CtrlSkinData;
  end;

  with TspSkinButton.Create(Form) do
  begin
    Parent := Form;
    DefaultFont := DefaultButtonFont;
    UseSkinFont := Self.UseSkinFont;
    Caption := SP_MSG_BTN_CANCEL;
    ModalResult := mrCancel;
    Cancel := True;
    SetBounds(MulDiv(92, DialogUnits.X, 4), Edit.Top + Edit.Height + 15,
              ButtonWidth, ButtonHeight);
    DefaultHeight := ButtonHeight;
    SkinDataName := FButtonSkinDataName;
    SkinData := CtrlSkinData;
    Form.ClientHeight := Top + Height + 13;
  end;

  if Form.ShowModal = mrOk
  then
    begin
      Value := Edit.Text;
      Result := True;
    end
  else
    Result := False;

  finally
    Form.Free;
  end;
end;

function TspSkinInputDialog.InputBox(const ACaption, APrompt, ADefault: string): string;
begin
  Result := ADefault;
  InputQuery(ACaption, APrompt, Result);
end;

constructor TspSkinProgressDialog.Create;
begin
  inherited Create(AOwner);

  FShowType := stStayOnTop;

  FAlphaBlend := False;
  FAlphaBlendAnimation := False;
  FAlphaBlendValue := 200;

  Form := nil;
  Gauge := nil;
  FExecute := False;

  FMinValue := 0;
  FMaxValue := 100;
  FValue := 0;

  FCaption := 'Process';
  FLabelCaption := 'Name of process:';
  FShowPercent := True;

  FButtonSkinDataName := 'button';
  FLabelSkinDataName := 'stdlabel';
  FGaugeSkinDataName := 'gauge';

  FDefaultLabelFont := TFont.Create;
  FDefaultButtonFont := TFont.Create;
  FDefaultGaugeFont := TFont.Create;

  FUseSkinFont := True;

  with FDefaultLabelFont do
  begin
    Name := 'Arial';
    Style := [];
    Height := 14;
  end;

  with FDefaultButtonFont do
  begin
    Name := 'Arial';
    Style := [];
    Height := 14;
  end;

  with FDefaultGaugeFont do
  begin
    Name := 'Arial';
    Style := [];
    Height := 14;
  end;
end;

destructor TspSkinProgressDialog.Destroy;
begin
  FDefaultLabelFont.Free;
  FDefaultButtonFont.Free;
  FDefaultGaugeFont.Free;
  inherited;
end;

procedure TspSkinProgressDialog.SetValue(AValue: Integer);
begin
  FValue := AValue;
  if FExecute
  then
    begin
      Gauge.Value := FValue;
      if Gauge.Value = Gauge.MaxValue
      then
        if FShowType = stModal
        then
          Form.ModalResult := mrOk
        else
          Form.Close;  
    end;  
end;

procedure TspSkinProgressDialog.SetDefaultLabelFont;
begin
  FDefaultLabelFont.Assign(Value);
end;

procedure TspSkinProgressDialog.SetDefaultGaugeFont;
begin
  FDefaultGaugeFont.Assign(Value);
end;

procedure TspSkinProgressDialog.SetDefaultButtonFont;
begin
  FDefaultButtonFont.Assign(Value);
end;

procedure TspSkinProgressDialog.Notification;
begin
  inherited Notification(AComponent, Operation);
  if (Operation = opRemove) and (AComponent = FSD) then FSD := nil;
  if (Operation = opRemove) and (AComponent = FCtrlFSD) then FCtrlFSD := nil;
end;

procedure TspSkinProgressDialog.OnFormShow(Sender: TObject);
begin
  if Assigned(FOnShow) then FOnShow(Self);
end;

procedure TspSkinProgressDialog.CancelBtnClick(Sender: TObject);
begin
  Form.Close;
  if Assigned(FOnCancel) then FOnCancel(Self);
end;

procedure TspSkinProgressDialog.OnFormClose;
begin
  FExecute := False;
  Gauge := nil;
  Form := nil;
  if Value <> MaxValue
  then
    if Assigned(FOnCancel) then FOnCancel(Self);
  Action := caFree;
end;

function TspSkinProgressDialog.Execute;
var
  DSF: TspDynamicSkinForm;
  Prompt: TspSkinStdLabel;
  DialogUnits: TPoint;
  ButtonWidth, ButtonHeight: Integer;
begin
  if FExecute
  then
    begin
      Result := False;
      Exit;
    end;
  Form := TForm.Create(Application);
  Form.BorderStyle := bsDialog;
  if FShowType = stStayOnTop
  then
     begin
       Form.FormStyle := fsStayOnTop;
       Form.OnClose := OnFormClose;
     end;
  Form.Caption := FCaption;
  Form.Position := poScreenCenter;
  Form.OnShow := OnFormShow;
  DSF := TspDynamicSkinForm.Create(Form);
  DSF.BorderIcons := [];
  DSF.SkinData := SkinData;
  DSF.MenusSkinData := CtrlSkinData;
  DSF.AlphaBlend := AlphaBlend;
  DSF.AlphaBlendAnimation := AlphaBlendAnimation;
  DSF.AlphaBlendValue := AlphaBlendValue;

  try

  with Form do
  begin
    Canvas.Font := Font;
    DialogUnits := GetAveCharSize(Canvas);
    ClientWidth := MulDiv(180, DialogUnits.X, 4);
  end;

  Prompt := TspSkinStdLabel.Create(Form);
  with Prompt do
  begin
    Parent := Form;
    Left := MulDiv(8, DialogUnits.X, 4);
    Top := MulDiv(8, DialogUnits.Y, 8);
    Constraints.MaxWidth := MulDiv(164, DialogUnits.X, 4);
    WordWrap := False;
    DefaultFont := DefaultLabelFont;
    UseSkinFont := Self.UseSkinFont;
    SkinDataName := FLabelSkinDataName;
    SkinData := CtrlSkinData;
    Caption := FLabelCaption;
  end;

  Gauge := TspSkinGauge.Create(Form);
  with Gauge do
  begin
    Parent := Form;
    MinValue := FMinValue;
    MaxValue := FMaxValue;
    ShowPercent := FShowPercent;
    Value := FValue;
    DefaultFont := DefaultGaugeFont;
    UseSkinFont := Self.UseSkinFont;
    Left := Prompt.Left;
    Top := Prompt.Top + Prompt.Height + 5;
    DefaultWidth := MulDiv(164, DialogUnits.X, 4);
    SkinDataName := FGaugeSkinDataName;
    SkinData := CtrlSkinData;
  end;

  ButtonWidth := MulDiv(50, DialogUnits.X, 4);
  ButtonHeight := MulDiv(14, DialogUnits.Y, 8);

  with TspSkinButton.Create(Form) do
  begin
    Parent := Form;
    DefaultFont := DefaultButtonFont;
    UseSkinFont := Self.UseSkinFont;
    Caption := SP_MSG_BTN_CANCEL;
    if FShowType = stStayOnTop then OnClick := CancelBtnClick;
    ModalResult := mrCancel;
    Cancel := True;
    SetBounds(Gauge.Left + Gauge.Width - ButtonWidth, Gauge.Top + Gauge.Height + 15,
              ButtonWidth, ButtonHeight);
    DefaultHeight := ButtonHeight;
    SkinDataName := FButtonSkinDataName;
    SkinData := CtrlSkinData;
    Form.ClientHeight := Top + Height + 13;
  end;

  FExecute := True;

  if FShowType = stModal
  then
    begin
      if Form.ShowModal = mrOk then Result := True else Result := False;
      FExecute := False;
    end
  else
    begin
      Result := True;
      Form.Show;
    end;

  finally
    if FShowType = stModal
    then
      begin
        Form.Free;
        Gauge := nil;
        Form := nil;
      end;  
  end;
end;

constructor TspFontDlgForm.Create(AOwner: TComponent);
begin
  inherited CreateNew(AOwner);
  KeyPreview := True;
  BorderStyle := bsDialog;
  Position := poScreenCenter;
  DSF := TspDynamicSkinForm.Create(Self);

  FontColorLabel := TspSkinStdLabel.Create(Self);
  with FontColorLabel do
  begin
    Left := 5;
    Top := 50;
    Caption := SP_FONTDLG_COLOR;
    AutoSize := True;
    Parent := Self;
  end;

  FontColorBox := TspSkinColorComboBox.Create(Self);
  with FontColorBox do
  begin
    Left := 5;
    Top := 65;
    Width := 200;
    DefaultHeight := 21;
    Parent := Self;
    ExStyle := [spcbCustomColor, spcbPrettyNames, spcbStandardColors];
    OnChange := FontColorChange;
  end;

  FontNameLabel := TspSkinStdLabel.Create(Self);
  with FontNameLabel do
  begin
    Left := 5;
    Top := 5;
    Caption := SP_FONTDLG_NAME;
    AutoSize := True;
    Parent := Self;
  end;

  FontNameBox := TspSkinFontComboBox.Create(Self);
  with FontNameBox do
  begin
    Left := 5;
    Top := 20;
    Width := 200;
    DefaultHeight := 21;
    Parent := Self;
    PopulateList;
    TabOrder := 0;
    TabStop := True;
    OnChange := FontNameChange;
  end;

  FontSizeLabel := TspSkinStdLabel.Create(Self);
  with FontSizeLabel do
  begin
    Left := 5;
    Top := 95;
    Caption := SP_FONTDLG_SIZE;
    AutoSize := True;
    Parent := Self;
  end;

  FontSizeEdit := TspSkinSpinEdit.Create(Self);
  with  FontSizeEdit do
  begin
    MinValue := -100;
    MaxValue := 100;
    Left := 5;
    Top := 110;
    Parent := Self;
    Width := 95;
    OnChange := FontSizeChange;
  end;

  FontHeightLabel := TspSkinStdLabel.Create(Self);
  with FontHeightLabel do
  begin
    Left := 110;
    Top := 95;
    Caption := SP_FONTDLG_HEIGHT;
    AutoSize := True;
    Parent := Self;
  end;

  FontHeightEdit := TspSkinSpinEdit.Create(Self);
  with FontHeightEdit do
  begin
    MinValue := -500;
    MaxValue := 500;
    Left := 110;
    Top := 110;
    Width := 95;
    Parent := Self;
    OnChange := FontHeightChange;
  end;

  FontExLabel := TspSkinStdLabel.Create(Self);
  with FontExLabel do
  begin
    Left := 210;
    Top := 50;
    Caption := SP_FONTDLG_EXAMPLE;
    AutoSize := True;
    Parent := Self;
  end;

  FontExamplePanel := TspSkinPanel.Create(Self);
  with FontExamplePanel do
  begin
    Parent := Self;
    BorderStyle := bvFrame;
    Left := 210;
    Top := 65;
    Width := 185;
    Height := 67;
  end;

  FontExampleLabel := TLabel.Create(Self);
  with FontExampleLabel do
  begin
    Parent := FontExamplePanel;
    Transparent := True;
    Align := alClient;
    Caption := 'AaBbYyZz';
  end;

  OkButton := TspSkinButton.Create(Self);
  with OkButton do
  begin
    Caption := SP_MSG_BTN_OK;
    CanFocused := True;
    Left := 230;
    Top := 155;
    Width := 75;
    DefaultHeight := 25;
    Parent := Self;
    ModalResult := mrOk;
  end;

  CancelButton := TspSkinButton.Create(Self);
  with CancelButton do
  begin
    Caption := SP_MSG_BTN_CANCEL;
    CanFocused := True;
    Left := 320;
    Top := 155;
    Width := 75;
    DefaultHeight := 25;
    Parent := Self;
    ModalResult := mrCancel;
    Cancel := True;
  end;

  FontStyleLabel := TspSkinStdLabel.Create(Self);
  with FontStyleLabel do
  begin
    Left := 210;
    Top := 5;
    Caption := SP_FONTDLG_STYLE;
    AutoSize := True;
    Parent := Self;
  end;

  BoldButton := TspSkinSpeedButton.Create(Self);
  with BoldButton do
  begin
    Parent := Self;
    AllowAllUp := True;
    DefaultWidth := 25;
    DefaultHeight := 25;
    SkinDataName := 'toolbutton';
    GroupIndex := 1;
    NumGlyphs := 1;
    Left := 210;
    Top := 20;
    Glyph.LoadFromResourceName(HInstance, 'SP_BOLD');
    OnClick := BoldButtonClick;
  end;

  ItalicButton := TspSkinSpeedButton.Create(Self);
  with ItalicButton do
  begin
    Parent := Self;
    AllowAllUp := True;
    DefaultWidth := 25;
    DefaultHeight := 25;
    SkinDataName := 'toolbutton';
    GroupIndex := 1;
    NumGlyphs := 1;
    Left := 240;
    Top := 20;
    Glyph.LoadFromResourceName(HInstance, 'SP_ITALIC');
    OnClick := ItalicButtonClick;
  end;

  UnderLineButton := TspSkinSpeedButton.Create(Self);
  with UnderLineButton do
  begin
    Parent := Self;
    AllowAllUp := True;
    DefaultWidth := 25;
    DefaultHeight := 25;
    SkinDataName := 'toolbutton';
    GroupIndex := 1;
    NumGlyphs := 1;
    Left := 270;
    Top := 20;
    Glyph.LoadFromResourceName(HInstance, 'SP_UNDERLINE');
    OnClick := UnderLineButtonClick;
  end;

  StrikeOutButton := TspSkinSpeedButton.Create(Self);
  with StrikeOutButton do
  begin
    Parent := Self;
    AllowAllUp := True;
    DefaultWidth := 25;
    DefaultHeight := 25;
    SkinDataName := 'toolbutton';
    GroupIndex := 1;
    NumGlyphs := 1;
    Left := 300;
    Top := 20;
    Glyph.LoadFromResourceName(HInstance, 'SP_STRIKEOUT');
    OnClick := StrikeOutButtonClick;
  end;

end;

procedure TspFontDlgForm.FontSizeChange(Sender: TObject);
begin
  FontExampleLabel.Font.Size := Trunc(FontSizeEdit.Value);
  FontHeightEdit.SimpleSetValue(FontExampleLabel.Font.Height);
end;

procedure TspFontDlgForm.FontHeightChange(Sender: TObject);
begin
  FontExampleLabel.Font.Height := Trunc(FontHeightEdit.Value);
  FontSizeEdit.SimpleSetValue(FontExampleLabel.Font.Size);
end;

⌨️ 快捷键说明

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