Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Drawing Problems

MihailVDMihailVD Member Posts: 91
Hello.

Can anyone tell me how can I draw directly on the desktop?
I mean how can draw a circle (for example) on the desktop or copy a hDC of a picturebox and stuff?
Mihail Dimitrov

Comments

  • phph Member Posts: 393
    : Hello.
    :
    : Can anyone tell me how can I draw directly on the desktop?
    : I mean how can draw a circle (for example) on the desktop or copy a hDC of a picturebox and stuff?
    : Mihail Dimitrov
    :

    here is something I tried when i read your post, but im sure can work better once tweaked by a pro (which im not)

    [code]
    'first off put this into a module :
    Public Const GWL_EXSTYLE = (-20)
    Public Const WS_EX_TRANSPARENT = &H20&
    Public Const SWP_FRAMECHANGED = &H20
    Public Const SWP_NOMOVE = &H2
    Public Const SWP_NOSIZE = &H1
    Public Const SWP_SHOWME = SWP_FRAMECHANGED Or _
    SWP_NOMOVE Or SWP_NOSIZE
    Public Const HWND_NOTOPMOST = -2
    Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Declare Function SetWindowPos Lib "user32" _
    (ByVal hwnd As Long, ByVal hWndInsertAfter _
    As Long, ByVal X As Long, ByVal Y As Long, _
    ByVal cx As Long, ByVal cy As Long, _
    ByVal wFlags As Long) As Long
    [/code]

    [code]
    'now put this into a form. no need to add controls, although, make
    'the form automatically maximize when run so it simulates fullscreen.
    'this doesnt actually draw on desktop, it just kinda puts an
    'invisible wall up that u can draw on.

    Private Sub Form_Load()
    'this tells the form to go transparent
    SetWindowLong Me.hwnd, GWL_EXSTYLE, _
    WS_EX_TRANSPARENT
    SetWindowPos Me.hwnd, HWND_NOTOPMOST, _
    0&, 0&, 0&, 0&, SWP_SHOWME

    'just specifies the width of the drawing line
    Form1.DrawWidth = 10
    End Sub

    Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    'keeps the x,y of the forms drawmethod synced with the mouse's x,y
    Form1.CurrentX = X
    Form1.CurrentY = Y
    End Sub

    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    'specifies draw type, position, and color
    Form1.Line -(X, Y), vbBlack
    End Sub
    [/code]

    now run ur app and just drag the mouse around the screen. it SHOULD be drawing on nothing. worked for me. hope this helps :)
    [red]ph[/red][blue][/blue][red]t[/red]
    [red]http://fade.to/phet[/red]
    [blue]12d.hypermart.net[/blue]
    [red]toadthefreak@hotmail.com[/red]

  • AsifAliAsifAli Member Posts: 39
    : : Hello.
    : :
    : : Can anyone tell me how can I draw directly on the desktop?
    : : I mean how can draw a circle (for example) on the desktop or copy a hDC of a picturebox and stuff?
    : : Mihail Dimitrov
    : :
    :

    use this

    Priavate Enum CopyImageEnum
    CPSRCAND = &H8800C6
    CPSRCCOPY = &HCC0020
    CPSRCERASE = &H440328
    CPSRCINVERT = &H660046
    CPSRCPAINT = &HEE0086
    CPNOTSRCCOPY = &H330008
    CPNOTSRCERASE = &H1100A6
    CPMERGECOPY = &HC000CA
    CPMERGEPAINT = &HBB0226
    CPPATCOPY = &HF00021
    CPPATPAINT = &HFB0A09
    CPPATINVERT = &H5A0049
    CPDSTINVERT = &H550009
    CPBLACKNESS = &H42&
    CPWHITENESS = &HFF0062
    End Enum

    Priavate Declare Function GetDesktopWindow Lib "user32" () As Long
    Priavate Declare Function GetWindowDC Lib "user32" (ByVal hWnd As Long) As Long
    Priavate Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
    Priavate Sub CopyImage(SourceDC As Long, SX, SY, WD, HT, DestDC As Long, DX As Integer, DY As Integer, Flage As CopyImageEnum)
    BitBlt DestDC, DX, DY, WD, HT, SourceDC, SX, SY, Flage
    End Sub

    '// use this function HDC copy images..
    Priavate Sub Form_Load()
    CopyImage Me.hdc,0,0,200,200,GetWindowDC(GetDestopWindow),0,0,CPSRCCOPY

    ''' draw what ever on your form..
    :
    End Sub
  • AsifAliAsifAli Member Posts: 39
    : : Hello.
    : :
    : : Can anyone tell me how can I draw directly on the desktop?
    : : I mean how can draw a circle (for example) on the desktop or copy a hDC of a picturebox and stuff?
    : : Mihail Dimitrov
    : :
    :

    use this

    Priavate Enum CopyImageEnum
    CPSRCAND = &H8800C6
    CPSRCCOPY = &HCC0020
    CPSRCERASE = &H440328
    CPSRCINVERT = &H660046
    CPSRCPAINT = &HEE0086
    CPNOTSRCCOPY = &H330008
    CPNOTSRCERASE = &H1100A6
    CPMERGECOPY = &HC000CA
    CPMERGEPAINT = &HBB0226
    CPPATCOPY = &HF00021
    CPPATPAINT = &HFB0A09
    CPPATINVERT = &H5A0049
    CPDSTINVERT = &H550009
    CPBLACKNESS = &H42&
    CPWHITENESS = &HFF0062
    End Enum

    Priavate Declare Function GetDesktopWindow Lib "user32" () As Long
    Priavate Declare Function GetWindowDC Lib "user32" (ByVal hWnd As Long) As Long
    Priavate Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
    Priavate Sub CopyImage(SourceDC As Long, SX, SY, WD, HT, DestDC As Long, DX As Integer, DY As Integer, Flage As CopyImageEnum)
    BitBlt DestDC, DX, DY, WD, HT, SourceDC, SX, SY, Flage
    End Sub

    '// use this function HDC copy images..
    Priavate Sub Form_Load()
    CopyImage Me.hdc,0,0,200,200,GetWindowDC(GetDestopWindow),0,0,CPSRCCOPY

    ''' draw what ever on your form..
    :
    End Sub
  • phph Member Posts: 393
    : : : Hello.
    : : :
    : : : Can anyone tell me how can I draw directly on the desktop?
    : : : I mean how can draw a circle (for example) on the desktop or copy a hDC of a picturebox and stuff?
    : : : Mihail Dimitrov
    : : :
    : :
    :
    : use this
    :
    : Priavate Enum CopyImageEnum
    : CPSRCAND = &H8800C6
    : CPSRCCOPY = &HCC0020
    : CPSRCERASE = &H440328
    : CPSRCINVERT = &H660046
    : CPSRCPAINT = &HEE0086
    : CPNOTSRCCOPY = &H330008
    : CPNOTSRCERASE = &H1100A6
    : CPMERGECOPY = &HC000CA
    : CPMERGEPAINT = &HBB0226
    : CPPATCOPY = &HF00021
    : CPPATPAINT = &HFB0A09
    : CPPATINVERT = &H5A0049
    : CPDSTINVERT = &H550009
    : CPBLACKNESS = &H42&
    : CPWHITENESS = &HFF0062
    : End Enum
    :
    : Priavate Declare Function GetDesktopWindow Lib "user32" () As Long
    : Priavate Declare Function GetWindowDC Lib "user32" (ByVal hWnd As Long) As Long
    : Priavate Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
    : Priavate Sub CopyImage(SourceDC As Long, SX, SY, WD, HT, DestDC As Long, DX As Integer, DY As Integer, Flage As CopyImageEnum)
    : BitBlt DestDC, DX, DY, WD, HT, SourceDC, SX, SY, Flage
    : End Sub
    :
    : '// use this function HDC copy images..
    : Priavate Sub Form_Load()
    : CopyImage Me.hdc,0,0,200,200,GetWindowDC(GetDestopWindow),0,0,CPSRCCOPY
    :
    : ''' draw what ever on your form..
    : :
    : End Sub
    :

    could u go into more detail? this is interesting. like explain what code does what and how to use it
    [red]ph[/red][blue][/blue][red]t[/red]
    [red]http://fade.to/phet[/red]
    [blue]12d.hypermart.net[/blue]
    [red]toadthefreak@hotmail.com[/red]

  • MihailVDMihailVD Member Posts: 91
    Thank you for your help. I will try the 2 methods.
    Mihail Dimitrov

  • Andre YoungAndre Young USAMember Posts: 0

    ______ / http://forcoder.org / free ebooks and video tutorials about ( Ruby R PL/SQL Perl Delphi Objective-C Go Swift PHP C Visual Basic Python Java C# Visual Basic .NET MATLAB JavaScript Scratch Assembly C++ LabVIEW D VBScript Scala ML Dart Rust Logo Apex Transact-SQL ABAP SAS Crystal FoxPro Clojure Awk Erlang Alice F# COBOL Kotlin Hack Julia Fortran Bash Ada Scheme Lua Lisp Prolog ) _____________

Sign In or Register to comment.