zoukankan      html  css  js  c++  java
  • TFont,TLogFont使用

    TFont,TLogFont使用

    代码
    procedure RotateText(ACanvas:TCanvas);
    var
    LF: TLogFont;
    aFont: TFont;
    begin
    with ACanvas do
    begin
    Font.Name :
    = 'Arial';
    Font.Size :
    = 18;
    aFont :
    = TFont.Create;
    try
    aFont.Assign(Font) ;
    GetObject(aFont.Handle, sizeof(LF), @LF) ;
    LF.lfEscapement :
    = 1800; //360 * 10
    LF.lfOrientation :
    = 0;
    aFont.Handle :
    = CreateFontIndirect(LF) ;
    Font.Assign(aFont) ;
    finally
    aFont.Free;
    end;
    TextOut(
    20, 100, 'Rotated Text!') ;
    end;
    end;

    procedure SetLogicFont(ACanvas: TCanvas);
    var
    LF: TLogFont;
    begin
    with LF,ACanvas.Font do
    begin
    lfHeight :
    = -12;
    lfWidth :
    = 6;
    lfEscapement :
    = 0;
    lfOrientation :
    = 0;
    lfWeight :
    = 400;
    lfItalic :
    = 0;
    lfUnderline :
    = 0;
    lfStrikeOut :
    = 0;
    lfCharSet :
    = 129;
    lfOutPrecision :
    = 0;
    lfClipPrecision :
    = 0;
    lfQuality :
    = 0;
    lfPitchAndFamily :
    = 0;
    lfFaceName :
    = 'Courier New';
    end;
    ACanvas.Font.Handle :
    = CreateFontIndirect(LF);
    end;

    procedure TForm1.btGetFontClick(Sender: TObject);
    var
    h: THandle;
    LF: TLogFont;
    hCurrFont,hNewFont,hOldFont: THandle;
    begin
    h :
    = edtFont.Handle;
    hCurrFont :
    = SendMessage(h, WM_GETFONT, 0, 0);
    if GetObject(hCurrFont,SizeOf(LF),Addr(LF)) > 0 then
    begin
    Memo1.Lines.Add(
    'LF.lfHeight: ' + inttostr(LF.lfHeight));
    Memo1.Lines.Add(
    'LF.lfWidth: ' + inttostr(LF.lfWidth));
    Memo1.Lines.Add(
    'LF.lfEscapement: ' + inttostr(LF.lfEscapement));
    Memo1.Lines.Add(
    'LF.lfOrientation: ' + inttostr(LF.lfOrientation));
    Memo1.Lines.Add(
    'LF.lfWeight: ' + inttostr(LF.lfWeight));
    Memo1.Lines.Add(
    'LF.lfItalic: ' + inttostr(LF.lfItalic));
    Memo1.Lines.Add(
    'LF.lfUnderline: ' + inttostr(LF.lfUnderline));
    Memo1.Lines.Add(
    'LF.lfStrikeOut: ' + inttostr(LF.lfStrikeOut));
    Memo1.Lines.Add(
    'LF.lfCharSet: ' + inttostr(LF.lfCharSet));
    Memo1.Lines.Add(
    'LF.lfOutPrecision: ' + inttostr(LF.lfOutPrecision));
    Memo1.Lines.Add(
    'LF.lfClipPrecision: ' + inttostr(LF.lfClipPrecision));
    Memo1.Lines.Add(
    'LF.lfQuality: ' + inttostr(LF.lfQuality));
    Memo1.Lines.Add(
    'LF.lfPitchAndFamily: ' + inttostr(LF.lfPitchAndFamily));
    Memo1.Lines.Add(
    'LF.lfFaceName: ' + LF.lfFaceName);

    hNewFont :
    = CreateFontIndirect(LF);
    hOldFont :
    = SelectObject(edtTest.Handle, hNewFont);
    SendMessage(edtTest.Handle, WM_SETFONT, hNewFont,
    1);
    DeleteObject(hOldFont);
    //DeleteObject(hNewFont);
    end;
    end;

    procedure TForm1.btnSetFontClick(Sender: TObject);
    var
    aFont: TFont;
    begin
    if FontDialog1.Execute then
    aFont :
    = FontDialog1.Font;
    SendMessage(edtFont.Handle, WM_SETFONT, aFont.Handle,
    0);
    end;

  • 相关阅读:
    bzoj 4361: isn
    bzoj 2560: 串珠子
    bzoj 3622: 已经没有什么好害怕的了
    UOJ #30. 【CF Round #278】Tourists
    Codeforces Round #452 E. New Year and Old Subsequence
    bzoj 2653: middle
    codeforces701C
    codeforces437C
    codeforces518B
    codeforces706C
  • 原文地址:https://www.cnblogs.com/Jekhn/p/1921697.html
Copyright © 2011-2022 走看看