-
Textout
i did this code and it worked fine when i used a forms hwnd but when i try and write on the desktop it doesnt work pls help
------------------code------------------------------------------------------
Private Declare Function TextOut Lib "gdi32.dll" 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 Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Sub Command1_Click()
Dim retval As Long
Dim i As Long
Dim DesktopHwnd As Long
DesktopHwnd = GetDesktopWindow()
i = GetDC(DesktopHwnd)
retval = TextOut(i, 100, 50, "Hello, world!", 13)
End Sub
----------------------------------end of code---------------------------
-
You need to use FindWindowEx to find "ProgMan", and then a window with a type of I think "Sys_ListView32". Then you might be able to paint on that.
-
Use GetWindowDC rather than GetDC and it should work fine. I believe GetDC on the desktop window handle doesn't give the part you're always looking at, but I may be wrong. I've always used GWDC myself, and it's always worked. You should use ReleaseDC on the window handle and DC when you're done too.