Zmiana czccionki w msg box

0

Witam,

w jaki sposób zmienić czcionkę w (msg) box?

Dziękuję

0
XVC napisał(a)

Witam,

w jaki sposób zmienić czcionkę w (msg) box?

Dziękuję

Oczywiście chodziło mi o InputBox.

0

może klasa dziedziczącą z InputBox'a i w niej zmienić czcionkę?

0
Potwoor_ napisał(a)

może klasa dziedziczącą z InputBox'a i w niej zmienić czcionkę?

hmm, niewiele mi to mówi niestety,

mam taką procedurę:
procedure TForm1.Button1Click(Sender: TObject);
var a : Double;
begin

a:= StrToFloat(InputBox('Sumowanie', 'Podaj liczbę', '0'));

Edit1.Text:= FloatToStr( (StrToFloat(Edit1.Text) + a));
activecontrol:=Edit1;

end;

i chce zmienic czcionke na Times w tekście: 'Podaj liczbę'.

0

InputBox to forma jak każda inna, jakbyś zrobił klasę dziedziczącą ze standardowego InputBox, to mógłbyś zrobić własną wersję tworzenia InputBox'a gdzie w trakcie była by zmieniana czcionka, zaraz się tym pobawię i wrzucę tu to co wybredzę =]

a co to ma być to activecontrol ?

0

activecontrol - po tej procedurze powyzej, aktywne okno to edit1

0

pole edycyjne aktywnym oknem O.o ? //już dopadłem co to jest =D

a zresztą łap

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Consts;

type
  TForm1 = class(TForm)
    Button1: TButton;
    FontDialog1: TFontDialog;
    procedure Button1Click(Sender: TObject);
    function MyInputBox(const ACaption, APrompt, ADefault: string; AFont: TFont): string;
    function MyInputQuery(const ACaption, APrompt: string; var Value: string; AFont: TFont): Boolean;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

// skopiowane z modulu Dialogs
// dziadostwo nie chcialo dzialac na odleglosc
function GetAveCharSize(Canvas: TCanvas): TPoint;
var
  I: Integer;
  Buffer: array[0..51] of Char;
begin
  for I := 0 to 25 do Buffer[I] := Chr(I + Ord('A'));
  for I := 0 to 25 do Buffer[I + 26] := Chr(I + Ord('a'));
  GetTextExtentPoint(Canvas.Handle, Buffer, 52, TSize(Result));
  Result.X := Result.X div 52;
end;

// dodalem -> AFont: TFont
function TForm1.MyInputQuery(const ACaption, APrompt: string;
  var Value: string; AFont: TFont): Boolean;
var
  Form: TForm;
  Prompt: TLabel;
  Edit: TEdit;
  DialogUnits: TPoint;
  ButtonTop, ButtonWidth, ButtonHeight: Integer;
begin
  Result := False;
  Form := TForm.Create(Application);
  with Form do
    try
      Canvas.Font := Font;
      DialogUnits := GetAveCharSize(Canvas);
      BorderStyle := bsDialog;
      Caption := ACaption;
      ClientWidth := MulDiv(180, DialogUnits.X, 4);
      Position := poScreenCenter;
      Prompt := TLabel.Create(Form);
      with Prompt do
      begin
        Parent := Form;
        Caption := APrompt;
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        Font:=AFont; // zmiana czcionki
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        Left := MulDiv(8, DialogUnits.X, 4);
        Top := MulDiv(8, DialogUnits.Y, 8);
        Constraints.MaxWidth := MulDiv(164, DialogUnits.X, 4);
        WordWrap := True;
      end;
      Edit := TEdit.Create(Form);
      with Edit do
      begin
        Parent := Form;
        Left := Prompt.Left;
        Top := Prompt.Top + Prompt.Height + 5;
        Width := MulDiv(164, DialogUnits.X, 4);
        MaxLength := 255;
        Text := Value;
        SelectAll;
      end;
      ButtonTop := Edit.Top + Edit.Height + 15;
      ButtonWidth := MulDiv(50, DialogUnits.X, 4);
      ButtonHeight := MulDiv(14, DialogUnits.Y, 8);
      with TButton.Create(Form) do
      begin
        Parent := Form;
        Caption := SMsgDlgOK;
        ModalResult := mrOk;
        Default := True;
        SetBounds(MulDiv(38, DialogUnits.X, 4), ButtonTop, ButtonWidth,
          ButtonHeight);
      end;
      with TButton.Create(Form) do
      begin
        Parent := Form;
        Caption := SMsgDlgCancel;
        ModalResult := mrCancel;
        Cancel := True;
        SetBounds(MulDiv(92, DialogUnits.X, 4), Edit.Top + Edit.Height + 15,
          ButtonWidth, ButtonHeight);
        Form.ClientHeight := Top + Height + 13;          
      end;
      if ShowModal = mrOk then
      begin
        Value := Edit.Text;
        Result := True;
      end;
    finally
      Form.Free;
    end;
end;

// dodalem -> Font: TFont
function TForm1.MyInputBox(const ACaption, APrompt, ADefault: string; AFont: TFont): string;
begin
  Result := ADefault;
  MyInputQuery(ACaption, APrompt, Result, AFont);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin

  if FontDialog1.Execute then
    MyInputBox('ble','dziab','boo',FontDialog1.Font);

end;

end.

na formę wrzucasz przycisk i FontDialog, podmieniasz kod
i masz programik który pyta się o czcionkę a później daną czcionką pyta się ciebie o coś innego =]

0

Dzięki!

1 użytkowników online, w tym zalogowanych: 0, gości: 1