Solved

Draw text on Windows desktop

Posted on 2001-07-05
5
328 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
  • 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 100 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

746 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now