全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:2504
推到 Plurk!
推到 Facebook!

如何實現字型樣式預覽?

答題得分者是:hagar
qoo1234
版主


發表:256
回覆:1167
積分:659
註冊:2003-02-24

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-12-18 21:23:23 IP:218.163.xxx.xxx 未訂閱
procedure TForm1.FormShow(Sender: TObject);
begin
 ComboBox1.Items:=Screen.Fonts; //取得Windows字型列表
end;
 
如何做字型樣式預覽? 網海無涯,學無止境!
Fishman
尊榮會員


發表:120
回覆:1949
積分:2163
註冊:2006-10-28

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-12-19 10:17:00 IP:210.65.xxx.xxx 未訂閱
Hi:    Edit1.Font.Name := ComboBox1.Text;    但如果要再 ComboBox 直接可以看到,....要再試試     -------------------------------- 小弟才疏學淺,若有謬誤請不吝指教 --------------------------------
------
Fishman
Fishman
尊榮會員


發表:120
回覆:1949
積分:2163
註冊:2006-10-28

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-12-19 10:25:22 IP:210.65.xxx.xxx 未訂閱
Hi:    也可以直接使用 Dialogs 下的 FontDialog
procedure TForm1.Button17Click(Sender: TObject);
begin
    if FontDialog1.Execute then
        Button17.Font := FontDialog1.Font;
end;
至於 ComboBox,........努力中 -------------------------------- 小弟才疏學淺,若有謬誤請不吝指教 --------------------------------
------
Fishman
qoo1234
版主


發表:256
回覆:1167
積分:659
註冊:2003-02-24

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-12-19 12:04:08 IP:218.163.xxx.xxx 未訂閱
謝謝 Fishman大大 指教!    ComboBox1字型樣式預覽...可以做的跟WORD軟體一樣嗎?    網海無涯,學無止境!
hagar
版主


發表:143
回覆:4056
積分:4445
註冊:2002-04-14

發送簡訊給我
#5 引用回覆 回覆 發表時間:2003-12-19 12:28:52 IP:202.39.xxx.xxx 未訂閱
http://codecentral.borland.com/codecentral/ccweb.exe/listing?id=17197
unit FontComboBx;    interface    uses
  Windows, Messages, SysUtils, Classes, Controls, StdCtrls;    type
  TFontComboBox = class(TCustomComboBox)
  private
    { Private declarations }
  protected
    { Protected declarations }
    procedure DrawItem(Index: Integer; Rect: TRect;
      State: TOwnerDrawState); override;
    procedure CreateWnd; override;
  public
    constructor Create(AOwner: TComponent); override;        { Public declarations }
  published
    property AutoComplete default True;
    property AutoDropDown default False;
    property BevelEdges;
    property BevelInner;
    property BevelKind default bkNone;
    property BevelOuter;
    property Anchors;
    property BiDiMode;
    property CharCase;
    property Color;
    property Constraints;
    property Ctl3D;
    property DragCursor;
    property DragKind;
    property DragMode;
    property DropDownCount;
    property Enabled;
    property Font;
    property ImeMode;
    property ImeName;
    property ItemHeight;
    property ItemIndex default -1;
    property MaxLength;
    property ParentBiDiMode;
    property ParentColor;
    property ParentCtl3D;
    property ParentFont;
    property ParentShowHint;
    property PopupMenu;
    property ShowHint;
    property Sorted;
    property TabOrder;
    property TabStop;
    property Text;
    property Visible;
    property OnChange;
    property OnClick;
    property OnCloseUp;
    property OnContextPopup;
    property OnDblClick;
    property OnDragDrop;
    property OnDragOver;
    property OnDrawItem;
    property OnDropDown;
    property OnEndDock;
    property OnEndDrag;
    property OnEnter;
    property OnExit;
    property OnKeyDown;
    property OnKeyPress;
    property OnKeyUp;
    property OnSelect;
    property OnStartDock;
    property OnStartDrag;
    property Items; { Must be published after OnMeasureItem }
  end;    procedure Register;    implementation    uses Graphics, Forms;    procedure Register;
begin
  RegisterComponents('Custom', [TFontComboBox]);
end;    { TFontComboBox }    constructor TFontComboBox.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  Style := csOwnerDrawVariable;
end;    procedure TFontComboBox.CreateWnd;
var
  I: Integer;
begin
  inherited;
  // Measure each item..
  Items := Screen.Fonts;
  for I := 0 to Items.Count - 1 do
  begin
    Canvas.Font.Name := Items[I];
    Canvas.Font.Size := 0;                 // use font's preferred size
    Perform(CB_SETITEMHEIGHT, I, Canvas.TextHeight(Items[I]));
  end;
end;    procedure TFontComboBox.DrawItem(Index: Integer; Rect: TRect;
  State: TOwnerDrawState);
begin
  Canvas.FillRect(Rect);
  if (Index >= 0) and (Index < Items.Count) then
  begin
    if odSelected in State then
      Canvas.Font.Color := clHighlightText;
    Canvas.Font.Name := Items[Index];
    Canvas.TextRect(Rect, Rect.Left 2, Rect.Top 2, Items[Index]);
  end;
end;    end.
--- Everything I say is a lie.
qoo1234
版主


發表:256
回覆:1167
積分:659
註冊:2003-02-24

發送簡訊給我
#6 引用回覆 回覆 發表時間:2003-12-19 14:13:42 IP:218.163.xxx.xxx 未訂閱
謝謝 hagar 版主  多次賜教~真感動! < src="http://delphi.ktop.com.tw/download/upload\33223_qoo.gif">網海無涯,學無止境!
系統時間:2024-11-23 11:54:04
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!