|
-
May 7th, 2001, 04:37 AM
#1
Thread Starter
Member
Draw lines outside a form????
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?
-
May 7th, 2001, 08:15 AM
#2
transcendental analytic
you can use lineto api on the device context you get with getwindowdc(getdesktopwindow)
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 7th, 2001, 06:29 PM
#3
You need the following 4 declarations:
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
Now draw like this:
Code:
dc = GetWindowDC(hWnd_of_window)
MoveToEx dc, x, y, 0
LineTo dc, x2, y2
-
May 7th, 2001, 06:30 PM
#4
[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
-
May 8th, 2001, 02:34 AM
#5
Retired VBF Adm1nistrator
Kedaman, 6,626076*10^-12 is avagadro's number ^ -1 isnt it ?
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
May 8th, 2001, 03:58 AM
#6
Thread Starter
Member
... Erase this line ???
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?
-
May 8th, 2001, 04:20 AM
#7
Retired VBF Adm1nistrator
You draw over the line with the colours that were originally there ...
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
May 8th, 2001, 01:37 PM
#8
Thread Starter
Member
... This works but ...
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!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|