Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

display text on the screen (no form) 1

Status
Not open for further replies.

DelphiAaron

Programmer
Jul 4, 2002
826
0
16
AU
does anyone know how to dispay text with no form.
i want to create an app to monitor the media buttons on the keyboard and show text messages on the screen when buttons are pressed ..
 
Like, paint to the screen? Something like this might work:

var d: hdc;
begin
d:=GetWindowDC(GetDesktopWindow);
textout(d, 1,1, 'sometext', 8);
ReleaseDC(GetDesktopWindow, d);
end;
TealWren
 
hi TealWren,

very nice thing.
Do you also have an idea how to change the font or height of the text to be written ?

Rod
 
To change the font with the windows API you have to create the font that you want, select it and then print your text. You can change the font height by the first parameter and the font typeface by the last parameter. More details available in your API help. :) Afterward you should always set the font back to what it was. I haven't compiled it but probably something like this:


var hFont: THandle;
hOldFont: THandle;
d: hdc;
begin
d:=GetWindowDC(GetDesktopWindow);
hFont := CreateFont(-15, 0, 0, 0, 400, 0, 0, 0,
DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH or FF_DONTCARE, 'MS Sans Serif');
hOldFont := SelectObject(d, hFont);
TextOut(d, 1,1, 'sometext', 8);
SelectObject(d, hOldFont);
ReleaseDC(GetDesktopWindow, d);
end;



TealWren
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top