dcsimg
Results 1 to 3 of 3

Thread: Question about getdc and releasedc.

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Posts
    2

    Question Question about getdc and releasedc.

    Hi.Here's the code. Its in a timer but the releasedc doesn't work and i cant figure out why. Please help.
    Code:
       Private Sub Timer1_Tick(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Timer1.Tick
            Dim structCursorPosition As POINTAPI
            Call GetCursorPos(structCursorPosition)
            Dim hdc As IntPtr = GetPixel(GetDC(IntPtr.Zero), structCursorPosition.x, structCursorPosition.y)
    
    
    
            BackColor = System.Drawing.ColorTranslator.FromOle(hdc)
            ReleaseDC(IntPtr.Zero, hdc)
        End Sub
    Last edited by m4r71n85; Oct 11th, 2009 at 12:20 PM.

  2. #2
    Addicted Member ZenDisaster's Avatar
    Join Date
    Dec 2006
    Location
    Bay Area, CA
    Posts
    140

    Re: VB2005: Question about getdc and releasedc.

    GetDC returns a different value than GetPixel yet you're setting the return value of GetPixel to your hdc var. Try separating the calls.

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Posts
    2

    Re: VB2005: Question about getdc and releasedc.

    Here's what i'v managed to do but it doesnt work again. Can u please give example or another hint how to fix the "ram eating"? The weird thing is it takes 5-20 kb of ram only if the pixel's color change, and im using a timer that check 3 times a sec if pixel's color is changed and for about an hour the program stops responding because of this.
    Code:
            hWnd = CLng(0)
            hDC = GetDC(hWnd)
            GP = GetPixel(hDC, 1520, 679)
            Text = GP
            ReleaseDC(hWnd, hDC)
            ReleaseDC(hWnd, GP)
    Last edited by m4r71n85; Oct 11th, 2009 at 09:30 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width