// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef BASE_WIN_SCOPED_GDI_OBJECT_H_ #define BASE_WIN_SCOPED_GDI_OBJECT_H_ #include #include "base/scoped_generic.h" namespace base { namespace win { namespace internal { template struct ScopedGDIObjectTraits { static T InvalidValue() { return nullptr; } static void Free(T object) { DeleteObject(object); } }; // An explicit specialization for HICON because we have to call DestroyIcon() // instead of DeleteObject() for HICON. template <> void inline ScopedGDIObjectTraits::Free(HICON icon) { DestroyIcon(icon); } } // namespace internal // Like ScopedHandle but for GDI objects. template using ScopedGDIObject = ScopedGeneric>; // Typedefs for some common use cases. typedef ScopedGDIObject ScopedBitmap; typedef ScopedGDIObject ScopedRegion; typedef ScopedGDIObject ScopedHFONT; typedef ScopedGDIObject ScopedHICON; } // namespace win } // namespace base #endif // BASE_WIN_SCOPED_GDI_OBJECT_H_