ObjReader Community

SDK programming => 64-bit SDK programming => Topic started by: Patrice Terrier on November 14, 2016, 11:02:47 am

Title: GDIPLUS FLAT API
Post by: Patrice Terrier on November 14, 2016, 11:02:47 am
GDIPLUS FLAT API

This one uses Explicit Linking to bypass the extra OOP class encapsulation.

How to use it:
Just include the attached gdipflat.h file into your project.

In the application main section
call the helper function hGDIplus = GdipStart() to init GDIPLUS,
and
call the helper function GdipEnd(hGDIplus) to shut down GDIPLUS.

Example:

int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) {

    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);
    long nRet = 0;

    LONG_PTR hGDIplus = GdipStart();

    // ALL YOUR CODE GOES THERE

    if (hGDIplus) { GdipEnd(hGDIplus); }

    return nRet;
}


...
Title: GdipCreateHICONFromBitmap
Post by: Patrice Terrier on December 15, 2016, 09:45:05 am
That should do it

Code: [Select]
long GdipCreateHICONFromBitmap (IN LONG_PTR lpImg, OUT HICON &lpIcon) {
    long nRet = -1; // Error
    lpIcon = 0;
    HMODULE hModule = gdiplib();
    if (hModule) {
        long_proc (LONG_PTR, HICON*);
        static zProc hProc;
        if (hProc == 0) { hProc = (zProc) GetProcAddress(hModule, "GdipCreateHICONFromBitmap"); }
        if (hProc) { nRet = hProc(lpImg, &lpIcon); }
    }
    return nRet;
}
Title: Re: GDIPLUS FLAT API
Post by: Patrice Terrier on December 16, 2016, 09:40:22 pm
That should do it.

Code: [Select]
long GdipCreateBitmapFromResource (IN HINSTANCE hInstance, IN WCHAR* sResourceName, OUT LONG_PTR &lpImg) {
    long nRet = -1; // Error
    lpImg = NULL;
    HMODULE hModule = gdiplib();
    if (hModule) {
        long_proc (HINSTANCE, WCHAR*, LONG_PTR*);
        static zProc hProc;
        if (hProc == 0) { hProc = (zProc) GetProcAddress(hModule, "GdipCreateBitmapFromResource"); }
        if (hProc) { nRet = hProc(hInstance, sResourceName, &lpImg); }
    }
    return nRet;
}
Title: Re: GDIPLUS FLAT API
Post by: James Fuller on December 16, 2016, 11:45:28 pm
Patrice,
  Thank you again.

James