Search code examples
c++windowsuser-interfacegdiwinapi

How do I know it's a valid gdi region handle?


or other gdi handle, such as pen brush. how do i know is it valid?


Solution

  • You should never get yourself into a situation where you might be holding onto a handle that isn't valid. If necessary, set the handle to NULL after calling DeleteObject() so it is completely obvious. Assuming that a GDI function will give you a FALSE return value because you passed a bad handle isn't safe.