News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

CreateSolidBrush

Started by xroot, June 19, 2011, 03:38:39 PM

Previous topic - Next topic

jj2007

It depends probably on the type of handle. If what you get is a pointer to a resource that Windows has to create and maintain, then deleting the object the handle points to is an invitation for an access violation. If instead you get an entry to some global structure that Windows maintains anyway - like fonts -, you might get away with "deleting" the pointer to the font table because the fonts are still around after you marked the reference as bad via DeleteObject.

Having said that: After a while my deleted fonts stop working...

MichaelW

I think the point was for your last SelectObject call to always restore the default.

eschew obfuscation

hutch--

 :bg

many of you guys missed out on the sheer fun of writing Win16 code. Software multitasking meant that all of Windows was one running program and if your app made a mess of memory, it took out the entire operating system. On the bright side, Win16 used to boot a lot faster than the 32 bit versions. Win32 at least restricts the messups to the running process so if you make a mess of memory you trash your own app, not everything else as well.

The test for a memory leak with GDI objects is reasonably simple, put the output in a loop and run task manager, if you have got it wrong you will see memory usage continually going up.

Magic rule is "Observe the SelectObject/DeleteObject rules" or watch it go BANG !
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

dedndave

"Bang" - i think that'll be the name for my next project   :P

Twister

I don't understand why you need to delete your drawing objects and brushes after drawing. I always thought of it as borrowing art supplies from the system, then giving them back after the program is done, or when you want to get some supplies off hand due to memory concerns.