HBITMAP hBitmap; HDC hdc = GetDC(hWnd); // hWnd is a handle to the window hBitmap = GetNative(hdc); // retrieves the handle to the native bitmap object ReleaseDC(hWnd, hdc); // releases the device context handle
#includeIn this example, the function retrieves the handle of the native GDI bitmap object created by the GDI+ library. The bitmap is loaded from a file and then converted to a native bitmap handle using the GDI+ function GetHBITMAP. The resulting handle is then passed to the GetNative function to manipulate the bitmap using GDI functions. Package library: The GetNative function is part of the WinGDI library, which is included in the Windows SDK.#include using namespace Gdiplus; Bitmap bitmap(L"image.jpg"); HBITMAP hBitmap; Status status = bitmap.GetHBITMAP(Color::Black, &hBitmap); if (status == Ok) { HBITMAP hNativeBitmap = GetNative(hBitmap); // use hNativeBitmap to manipulate the bitmap using GDI functions DeleteObject(hNativeBitmap); // delete the bitmap handle when done }