I want the user to draw lines on the screen to
mark an area, that will be captured.
The capturing-code itself works fine, but how
can I draw lines outside an form?
Is there a way to solve this problem?
Printable View
I want the user to draw lines on the screen to
mark an area, that will be captured.
The capturing-code itself works fine, but how
can I draw lines outside an form?
Is there a way to solve this problem?
you can use lineto api on the device context you get with getwindowdc(getdesktopwindow)
You need the following 4 declarations:
Now draw like this:Code:Private Declare Function GetWindowDC Lib "user32" Alias "GetWindowDC" (ByVal hwnd As Long) As Long
Private Declare Function MoveToEx Lib "gdi32" Alias "MoveToEx" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, lpPoint As POINTAPI) As Long
Private Declare Function LineTo Lib "gdi32" Alias "LineTo" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Code:dc = GetWindowDC(hWnd_of_window)
MoveToEx dc, x, y, 0
LineTo dc, x2, y2
[code]
Private Declare Function GetWindowDC Lib "user32" Alias "GetWindowDC" (ByVal hwnd As Long) As Long
Alias "GetDesktopWindow" () As Long
Private Declare Function MoveToEx Lib "gdi32" Alias "MoveToEx" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, lpPoint As POINTAPI) As Long
Private Declare Function LineTo Lib "gdi32" Alias "LineTo" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
[code]
And you would draw like:
Code:dc = GetwindowDC(hwnd of window)
MoveToEx x, y, 0
LineTo x2, y2
Kedaman, 6,626076*10^-12 is avagadro's number ^ -1 isnt it ?
Thanks for your reply,
in MSDN I've read, to erase the line I have to draw it
twice. This doesn't work ?!? When I draw excatly the same
line again I get a new black line again.
What goes wrong?
You draw over the line with the colours that were originally there ...
OK, I got it using SetROP2, but that all works only inside the IDE.
When I compile that code and start the native EXE the lines will not
be erased an I got plenty of lines drawed on the Desktop. I use
dc = GetWindowDC(GetDesktopWindow)
Call SetROP2(dc, R2_NOT)
So why does this not work outside the IDE?
Every Help is welcome!