Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to draw the caption of a TForm programmatically Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
28-Oct-02
Category
VCL-Forms
Language
Delphi 2.x
Views
128
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius

I need to be able to draw the text in a TForm's caption area manually, without 
using WM_SETTEXT (setting the TForm's Caption property, or using the API call 
SetWindowText, both use this method so they are unsuitable). I need functionality 
similar to DrawText where the text is drawn directly rather than sent to a message 
handler. Can anyone help?

Answer:

1   unit Unit1;
2   
3   interface
4   
5   uses
6     Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
7   
8   type
9     TForm1 = class(TForm)
10      procedure WMPaint(var message: TWMPaint); message WM_PAINT;
11      procedure FormShow(Sender: TObject);
12    private
13      { Private declarations }
14    public
15      { Public declarations }
16    end;
17  
18  var
19    Form1: TForm1;
20  
21  implementation
22  
23  {$R *.DFM}
24  
25  procedure WriteTexttoDC(WinHandle: HWND; Text: string; X, Y: Integer);
26  var
27    DC: HDC;
28  begin
29    DC := GetWindowDC(WinHandle);
30    ExtTextOut(DC, 1, 1, ETO_CLIPPED, nil, PChar(Text), Length(Text), nil);
31    ReleaseDC(WinHandle, DC);
32  end;
33  
34  procedure TForm1.WMPaint(var message: TWMPaint);
35  begin
36    WriteTexttoDC(Handle, 'Is it OK?', 5, 5);
37  end;
38  
39  procedure TForm1.FormShow(Sender: TObject);
40  begin
41    WriteTexttoDC(Handle, 'Is it OK?', 5, 5);
42  end;
43  
44  end.


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC