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 TextOut-Problem (https://www.delphipraxis.net/15222-textout-problem.html)

Fib 24. Jan 2004 12:19


TextOut-Problem
 
Moin,
ich hoff' mal das gehört hier rein.
Also ich hab folgenden Code:
Code:
procedure TForm1.Button4Click(Sender: TObject);
var
  hwnd : Thandle;
  s : string;
begin
   hwnd := Application.handle;
   s := 'hallo du';
   if TextOut(hwnd, Form1.Left+322, Form1.Top+8, @s, 0) then ShowMessage('ja')
     else ShowMessage('nein');
end;

Das TextOut gibt zwar true zurück es wird aber nichts geschrieben. Der letzte Parameter soll eigentlich die Anzahl der Zeichen in dem String sein, allerdings gibt TextOut immmer False zurück, wenn der anders als null ist.
Was mach ich falsch?

MfG

Problem hat sich schon gelöst.

Daniel 24. Jan 2004 12:34

Re: TextOut-Problem
 
...und wie hast Du es gelöst? ;-) Könnte ja auch mal für Andere interessant sein, falls sie vor dem gleichen Problem stehen.

MaOfDe 24. Jan 2004 13:21

Re: TextOut-Problem
 
Problem ist Application.Handle ist vom Typ HWND, die Funktion TextOut verlangt aber einen Typ HDC.
Diese Typen sind zwar beide abgeleitet von Cardinal, aber entscheidend ist, was sich dahinter für ein Wert/eine Adresse versteckt.
Delphi-Quellcode:
hdc:=GetDC(Application.Handle);
So zeigt sich 100 pro das geforderte 'Ja', doch soweit ich weiß kann man nicht auch Application zeichnen.

Luckie 24. Jan 2004 14:17

Re: TextOut-Problem
 
Delphi-Quellcode:
Form1.Canvas.Handle
Das sollte es tun. Dann landet der Text auf dem Canvas vom Fenster.

Application ist das unsichtbare Fenster der VCL. Da dürfte er nicht allzuviel sehen. ;)


Alle Zeitangaben in WEZ +1. Es ist jetzt 23:12 Uhr.

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