JohnOne Posted February 28, 2013 Share Posted February 28, 2013 Something I'm not certain about with regards this function, if anyone can help. msdn says The SelectObject function selects an object into the specified device context (DC). The new object replaces the previous object of the same type.So does that mean I only need to clean up the original object? Example: HDC hdc = GetDC(NULL); HDC hdcMEM = CreateCompatibleDC(hdc); HBITMAP hBitmap = CreateCompatibleBitmap(hdc, iWidth, iHeight); SelectObject(hdcMEM,hBitmap); DeleteObject(hBitmap); DeleteDC(hdcMEM); Is that sufficient to clean that up, or do I need to assign are variable to SelectObject and clean that up too, or just the new object? HDC hdc = GetDC(NULL); HDC hdcMEM = CreateCompatibleDC(hdc); HBITMAP hBitmap = CreateCompatibleBitmap(hdc, iWidth, iHeight); HANDLE hObj = SelectObject(hdcMEM,hBitmap); DeleteObject(hObj); DeleteDC(hdcMEM); AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Solution trancexx Posted February 28, 2013 Solution Share Posted February 28, 2013 (edited) Usually if you don't have the use for replaced you do this: ::DeleteObject(::SelectObject(hdcMEM,hBitmap)); ... And you should call ReleaseDC for hdc. Edited February 28, 2013 by trancexx JohnOne 1 ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
JohnOne Posted February 28, 2013 Author Share Posted February 28, 2013 Sounds sensible. Thank you kindly ma'am. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
UEZ Posted February 28, 2013 Share Posted February 28, 2013 (edited) Something like that maybe in AutoIt notation: $hDC = _WinAPI_GetDC(0) $hdcMEM = _WinAPI_CreateCompatibleDC($hDC) $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight) _WinAPI_SelectObject ($hdcMEM, $hBitmap) _WinAPI_DeleteObject($hDC) _WinAPI_ReleaseDC(0, $hDC) _WinAPI_DeleteDC($hdcMEM) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hDC) Br, UEZ Edited February 28, 2013 by UEZ JohnOne 1 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
JohnOne Posted February 28, 2013 Author Share Posted February 28, 2013 Are those three operations on $hDC really necessary, or just being thorough? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
UEZ Posted February 28, 2013 Share Posted February 28, 2013 I think thorough but you can create a loop with 1000 calls and leave some off to see whether memory consumption is increasing constantly to check for memory leaks. Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
trancexx Posted February 28, 2013 Share Posted February 28, 2013 (edited) You must not call DeleteDC for hdc. Edited February 28, 2013 by trancexx JohnOne 1 ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
JohnOne Posted February 28, 2013 Author Share Posted February 28, 2013 Thanks UEZ. Just finishing up on "SearchPixel" function I was talking about yesterday AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
forever0donotknowme Posted February 28, 2013 Share Posted February 28, 2013 UEZ & JohnOne had beautiful picture in profile Link to comment Share on other sites More sharing options...
UEZ Posted February 28, 2013 Share Posted February 28, 2013 I'm really a big fan of them - one of the best comedians ever! Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
JohnOne Posted February 28, 2013 Author Share Posted February 28, 2013 One, which one? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now