AutoHotkey Community

It is currently May 26th, 2012, 2:26 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: getDC
PostPosted: January 21st, 2009, 9:24 am 
Offline

Joined: January 20th, 2009, 9:35 pm
Posts: 16
when using a dllcall to getDC, do you have to release/kill the DC after you are done with it ?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 21st, 2009, 10:22 am 
Offline

Joined: November 4th, 2008, 9:23 am
Posts: 1045
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 21st, 2009, 10:37 am 
Offline

Joined: January 20th, 2009, 9:35 pm
Posts: 16
im not sure what that means :(

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
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 21st, 2009, 10:55 am 
Offline

Joined: November 4th, 2008, 9:23 am
Posts: 1045
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.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: G. Sperotto, poserpro, Yahoo [Bot] and 14 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group