AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

getDC

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
ifckladyluck



Joined: 20 Jan 2009
Posts: 16

PostPosted: Wed Jan 21, 2009 8:24 am    Post subject: getDC Reply with quote

when using a dllcall to getDC, do you have to release/kill the DC after you are done with it ?
Back to top
View user's profile Send private message
animeaime



Joined: 04 Nov 2008
Posts: 1045

PostPosted: Wed Jan 21, 2009 9:22 am    Post subject: Reply with quote

Depends.

GetDC docs wrote:
After painting with a common DC, the ReleaseDC function must be called to release the DC. Class and private DCs do not have to be released. ReleaseDC must be called from the same thread that called GetDC. The number of DCs is limited only by available memory.

_________________
As always, if you have any further questions, don't hesitate to ask.

Add OOP to your scripts via the Class Library. Check out my scripts.
Back to top
View user's profile Send private message Send e-mail
ifckladyluck



Joined: 20 Jan 2009
Posts: 16

PostPosted: Wed Jan 21, 2009 9:37 am    Post subject: Reply with quote

im not sure what that means Sad

this is the code I am using, my concern is that since its an infinite loop it will eventually start hogging up too much memory if I dont release it and have to.

loop
{
winget, tableid, id, blah
hDC := dllcall("GetDC", "Uint", id)
pixel := dllcall("GetPixel", "Uint", 30, "Uint", 30)
tooltip pixel
}
Back to top
View user's profile Send private message
animeaime



Joined: 04 Nov 2008
Posts: 1045

PostPosted: Wed Jan 21, 2009 9:55 am    Post subject: Reply with quote

1) That loop NEVER exits.... how come...
2) The handle for the DC shouldn't change. I'm not knowlegable about DC, but I know other handle values don't, so I presume this is the case here. So, you should only have to call getDC once, before the loop.
3) You will need to call ReleaseDC before the code exits. You can do this by using OnExit and putting the function call in the subroutine.
4) All getDC does is return a handle, it doesn't create anything - there is no memory allocated, thus it can't become a memory hog.

Also, why don't you use PixelGetColor instead??
_________________
As always, if you have any further questions, don't hesitate to ask.

Add OOP to your scripts via the Class Library. Check out my scripts.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group