Board index » delphi » TPW: How to chg Font in a window $$$

TPW: How to chg Font in a window $$$

Hello,
I'm still trying to successfully change the font in a window.  How do I
do this?

Can someone send me a copy of a very basic program that prints a word in
a large font.

My program compiles and runs, including printing a word to the window,
but the font is still the same.

I'll pay $20.00 for a short, working example.

Thanks

 

Re:TPW: How to chg Font in a window $$$


Quote
Donald Dougherty wrote:

> Hello,
> I'm still trying to successfully change the font in a window.  How do I
> do this?

> Can someone send me a copy of a very basic program that prints a word in
> a large font.

> My program compiles and runs, including printing a word to the window,
> but the font is still the same.

> I'll pay $20.00 for a short, working example.

> Thanks

Here's a simple example in Turbo Pascal/Windows.  The Paint Method
is where you need to define the font and create the text..

Do I get the $20?

-Ed

{****** Program TestFont, TPW Example of using Fonts in a Window *****}
uses WinTypes, WinProcs, WObjects, Strings;

Const
  pAppName:pChar='TestFont';

{====================  The Dialog  ===================}
Const
  aString:pchar='A Test String';

type
  PtestDialog = ^TestDialog;
  TestDialog  = Object(tWindow)
    Procedure Paint(PaintDC:hDC;Var PaintInfo:TPaintStruct);Virtual;
  end;

Procedure TestDialog.Paint(PaintDC:hDC;Var PaintInfo:TPaintStruct);

Var
  AFont: TLogFont;
  UseFont:Hfont;
  ADC:hDC;
begin
  With AFont do
    begin
      lfHeight := 15;     {Height and Width}
      lfWidth:=0;         {0=default}
      lfEscapement:=0;    {Angle line of Text is written at}
      lfOrientation:=0;
      lfWeight:= fw_Thin;
      lfItalic:= 0;
      lfUnderLine:= 0;
      lfStrikeOut:= 0;
      lfCharSet:= ANSI_CharSet;
      lfOutPrecision:= Out_Default_Precis;
      lfClipPrecision:= Clip_Default_Precis;
      lfQuality:=Proof_Quality;
      lfPitchandFamily:= Variable_Pitch and ff_DontCare;
      StrCopy(lfFaceName,'Helv');
    end;
  UseFont := CreateFontIndirect(AFont);
  ADC := GetDC(HWindow);
  SelectObject(ADC,UseFont);
  SetBkMode(ADC,Transparent);             {transparent Backround}
  TextOut(ADC,30,30,Astring,StrLen(Astring));
  DeleteObject(CreateFontIndirect(AFont));
  ReleaseDC(HWindow, ADC);
end;

{********************  The Application ****************************}

type
  TestApp= object(TApplication)
  procedure InitMainWindow; virtual;
end;

var
  MainApp: TestApp;

Procedure TestApp.InitMainWindow;
begin
  MainWindow := New(PtestDialog, Init(Nil,pAppName));
end;

Begin
  MainApp.Init(pAppname);
  MainApp.Run;
  MainApp.Done;
end.

Re:TPW: How to chg Font in a window $$$


In article <4vv48b$...@oac2.hsc.uth.tmc.edu>,
ddoughrt.utmsim...@msi66.msi.uth.tmc.edu says...

Quote

>Hello,
>I'm still trying to successfully change the font in a window.  How do I
>do this?
[...]
>I'll pay $20.00 for a short, working example.

>Thanks

You need to create the font with, say, CreateFontIndirect and then select it
into the DC with SelectObject.  Remember to save the original font and restore
it, and to destroy you own when closing the window, otherwise you'll be eating
resources.
Don't pay $20 - there are plenty of examples in the examples directory.

If this isn't enough help, let me know.
Jochen

Re:TPW: How to chg Font in a window $$$


Quote
Donald Dougherty wrote:

> Hello,
> I'm still trying to successfully change the font in a window.  How do I
> do this?

> Can someone send me a copy of a very basic program that prints a word in
> a large font.

> My program compiles and runs, including printing a word to the window,
> but the font is still the same.

> I'll pay $20.00 for a short, working example.

> Thanks

In Other Words ----I'll Pay Someone $20.00 To Do My Computer Science
Homework!

Re:TPW: How to chg Font in a window $$$


No I'm not a student,  in fact Im a professor in a medical school trying
to write a program for one of my experiments .... How rude

Other Threads