Solved

Draw text on Windows desktop

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

707 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