Results 1 to 8 of 8

Thread: Draw lines outside a form????

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2001
    Posts
    36

    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?

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.

  3. #3
    Megatron
    Guest
    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

  4. #4
    Megatron
    Guest
    [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

  5. #5
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Kedaman, 6,626076*10^-12 is avagadro's number ^ -1 isnt it ?
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  6. #6

    Thread Starter
    Member
    Join Date
    Feb 2001
    Posts
    36

    ... 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?

  7. #7
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    You draw over the line with the colours that were originally there ...
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  8. #8

    Thread Starter
    Member
    Join Date
    Feb 2001
    Posts
    36

    ... 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
  •  



Click Here to Expand Forum to Full Width