Solved

Draw text on Windows desktop

Posted on 2001-07-05
5
330 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
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…

809 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