Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi fontänderung eines fensters mit nonvcl (https://www.delphipraxis.net/41457-fontaenderung-eines-fensters-mit-nonvcl.html)

heiopei 3. Mär 2005 14:50


fontänderung eines fensters mit nonvcl
 
hallo,
ich hab folgendes problem:
ich möchte die schriftart meines fensters verändern. jetzt hab ich in luckies tutorial set_font gefunden.
allerdings scheint das nicht auf mein fenster anwendbar zu sein, sondern nur auf andere komponenten!

wie kann ich das machen - die textausgabe mache ich mit textout...

mfg,
heiopei

Luckie 3. Mär 2005 15:06

Re: fontänderung eines fensters mit nonvcl
 
Da du mit TextOut direkt auf dem Canvas deinen Text ausgibst, musst du die Schrift in den DeviceContext des Canvas selektieren mit MSDN-Library durchsuchenSelectObject.

heiopei 5. Mär 2005 10:33

Re: fontänderung eines fensters mit nonvcl
 
hallo,
ich hab jetzt das mit selectobject gemacht - aber die schriftart ist immer noch die gleiche!!
(ich hab das ganze momentan in wm_create drinne )

kann mir jemand helfen und ggf. sogar nen code zeigen?

mfg,
heiopei

heiopei 5. Mär 2005 13:47

Re: fontänderung eines fensters mit nonvcl
 
na gut,
also hier ist jetzt mal mein code, den ich bis jetzt hab:
(hatte davor zeitbedingt keinen zugriff drauf ;-) )

Delphi-Quellcode:
//innerhalb von wm_create...
  myfont := CreateFont(-12, 0, 0, 0, 0, 0, 0, 0, ANSI_CHARSET,
      OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
      DEFAULT_PITCH, 'MS Sans Serif');
  if myfont <> 0 then
    SendMessage(hwnd, WM_SETFONT, Integer(myfont), Integer(true));

//innerhalb von keydown...
  ahdc := GetDC(hWnd);
  SetBkMode(ahdc, TRANSPARENT);
  SetTextColor(ahdc, $0000FF00);
  SelectObject(ahdc, myfont);
  Textout(ahdc, tpos, rpos, PChar(@wparam), SizeOf(1));
  Inc(tpos, 10);
  ReleaseDC(hWnd, ahdc);
bin für schnelle hilfe sehr sehr dankbar!!!

heiopei

heiopei 7. Mär 2005 12:02

Re: fontänderung eines fensters mit nonvcl
 
ja hallo,
also hat da wirklich keiner ne ahnung?!?
ich hab jetzt schon ne gewisse zeit damit verbracht mich in der hilfe schlau zu machen,aber ich kriegs trotzdem nich hin.

hat jemand noch irgend ne idee?!?
(wie gesagt, ich will nur auf mein erzeugtes fenster schreiben können, aber die schriftart verändern!)

mfg,
heiopei

Luckie 7. Mär 2005 13:56

Re: fontänderung eines fensters mit nonvcl
 
So geht es:
Delphi-Quellcode:
    WM_PAINT:
      begin
        Beginpaint(hWnd, ps);
        MyFont := CreateFont(-12, 0, 0, 0, 0, 0, 0, 0, ANSI_CHARSET,
          OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
          DEFAULT_PITCH, 'MS Sans Serif');
        OldFont := SelectObject(ps.hdc, MyFont);
        SetBkMode(ps.hdc, TRANSPARENT);
        TextOut(ps.hdc, 10, 10, 'Hello World', 11);
        EndPaint(hWnd, ps);
      end;
Aber ich würde dir empfehlen auf ein Bitmap im Speicher zu schreiben und bei Bedarf und im OnPaint auf das Fenster mit BitBlt zu kopieren. Sonst ist es nämlich jedes mal weg, wenn dein Fenster neu gezeichnet werden muss.


Alle Zeitangaben in WEZ +1. Es ist jetzt 20:34 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz