Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Draw text on Windows desktop

Posted on 2001-07-05
5
Medium Priority
?
347 Views
Last Modified: 2008-02-01
Hello everyone.

How can I draw text directly on to the Windows desktop? Presumably there is an API function to do this?

Thanks
0
Comment
Question by:DapperDan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 7

Expert Comment

by:Inteqam
ID: 6255142
no i don't think so, but you need to get the bmp file and then write on it, and refresh the desktop (I think).
0
 
LVL 5

Expert Comment

by:rkot2000
ID: 6255391
yes it's possible(i did it), you need to use api functions, let me find my code samples. (desktop - is a window so you can use api functions to work with it).
0
 
LVL 7

Expert Comment

by:Inteqam
ID: 6255404
mmmmmmmmm... seems true.
actually it should be true, not always you have a wallpaper.
0
 
LVL 5

Accepted Solution

by:
rkot2000 earned 400 total points
ID: 6255481
found it ....
just add a commnad button name : cmdpaint and common dialog control - name : dialog

best books on api functions :
http://www.desaware.com/PuzzleBookL2.htm
http://www.desaware.com/VBPGWin32APIL2.htm


Option Explicit
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Private Declare Function SetTextColor Lib "gdi32" (ByVal hdc As Long, ByVal crColor As Long) As Long
Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long


Private Sub cmdpaint_Click()
Dim sText As String
Dim x As Long
Dim y As Long
Dim lcolor As Long

sText = InputBox$("Give me the string")
Form1.Dialog.Action = 3
x = 100
y = 100

Call ShowText(x, y, sText)
End Sub



Public Sub ShowText(x As Long, y As Long, sText As String)
Dim lcolor As Long
Dim hdc As Long
Dim hW As Long
hW = GetDesktopWindow()
hdc = GetWindowDC(hW)
lcolor = SetTextColor(hdc, Form1.Dialog.Color) 'RGB(255, 0, 0))
Call TextOut(hdc, x, y, sText, Len(sText))
Call SetTextColor(hdc, lcolor)
Call ReleaseDC(hW, hdc)
End Sub
0
 

Author Comment

by:DapperDan
ID: 6255837
Thanks for that. That works great. :o)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question