Author Topic: GDIPLUS FLAT API  (Read 9732 times)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1982
    • zapsolution
GDIPLUS FLAT API
« 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;
}


...
« Last Edit: November 14, 2016, 11:11:47 am by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1982
    • zapsolution
GdipCreateHICONFromBitmap
« Reply #1 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;
}
Patrice
(Always working with the latest Windows version available...)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1982
    • zapsolution
Re: GDIPLUS FLAT API
« Reply #2 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;
}
« Last Edit: December 16, 2016, 09:42:52 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

James Fuller

  • Newbie
  • *
  • Posts: 41
Re: GDIPLUS FLAT API
« Reply #3 on: December 16, 2016, 11:45:28 pm »
Patrice,
  Thank you again.

James