was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

47 Visitors Online


 
...TFont Eigenschaften von einem Font Handle setzen ?
Autor: P. Below
Homepage: http://www.teamb.com
[ Tip ausdrucken ]  

Tip Bewertung (4):  
     


uses
  
TypInfo;

function MakeFontFromHFont(aHandle: HFONT): TFONT;
var
  
LogFont: TLogFont;
begin
  
Result := TFont.Create;
  FillChar(LogFont, SizeOf(LogFont), 0);
  GetObject(aHandle, SizeOf(logfont), @LogFont);
  with LogFont, Result do
  begin
    
Name   := StrPas(lffaceName);
    Height := -lfHeight;
    if lfWeight FW_MEDIUM then
      
Style := Style + [fsBold];
    if lfItalic 0 then
      
Style := Style + [fsItalic];
    if lfUnderline 0 then
      
Style := Style + [fsUnderline];
    if lfStrikeout 0 then
      
Style := Style + [fsStrikeout];
    case (lfPitchAndFamily and 3) of
      
VARIABLE_PITCH: Pitch := fpVariable;
      FIXED_PITCH: Pitch    := fpFixed;
    end;
  end;
end;


procedure TForm1.Button1Click(Sender: TObject);
var
  
f: TFont;
  s: string;
  st: TFontStyle;
begin
  
f := MakeFontfromHFont(getStockObject(ANSI_FIXED_FONT));
  try
    
memo1.Clear;
    with memo1.Lines do
    begin
      
Add(Format('Name: %s', [f.Name]));
      Add(Format('Size: %d', [f.Size]));
      Add(Format('Height: %d', [f.Height]));
      Add(Format('Pitch: %s', [GetEnumName(TypeInfo(TFontPitch),
        Ord(f.Pitch))]));
      S := 'Style: [ ';
      for st := Low(St) to High(st) do
        if 
st in f.Style then
        begin
          
AppendStr(S, GetEnumName(TypeInfo(TFontStyle), Ord(st)));
          AppendStr(S, ' ');
        end;
      AppendStr(S, ']');
      Add(S);
    end;
  finally
    
f.Handle := 0;
    f.Free;
  end;
end;

 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners