Solved

Draw text on Windows desktop

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…

734 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