minigui之显示gif

/*************************************************************************
	> c File Name: donghua.c
	> c Created Time: 2018年10月17日 星期三 10时18分45秒
 ************************************************************************/
#include 
#include 
#include 
#include 

#include 
#include 
#include 
#include 
#include 

#include "common.h"

static ANIMATION* anim = NULL;

static int AnimationWinProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{

    switch (message) {
    case MSG_CREATE:
    {
        anim = CreateAnimationFromGIF89aFile (HDC_SCREEN,"res/photo/1.gif");
        if (anim == NULL)
            return 1;

        SetWindowAdditionalData (hWnd, (DWORD) anim);
        CreateWindowEx (CTRL_ANIMATION, 
                          "", 
                          WS_VISIBLE | ANS_SCALED |ANS_AUTOLOOP , //ANS_AUTOLOOP 
                          WS_EX_NONE,
                          100, 
                          0, 0, 800, 480, hWnd, (DWORD)anim);
        SendMessage (GetDlgItem (hWnd, 100), ANM_STARTPLAY, 0, 0);
        break;
    }

    case MSG_LBUTTONDOWN:
       SendMessage (GetDlgItem (hWnd, 100), ANM_STOPPLAY, 0, (LPARAM)anim);
	break;

    case MSG_DESTROY:
        DestroyAnimation ((ANIMATION*)GetWindowAdditionalData (hWnd), TRUE);
        DestroyAllControls (hWnd);
        return 0;

    case MSG_CLOSE:
        PostQuitMessage (hWnd);
        DestroyMainWindow (hWnd);
        return 0;
    }

    return DefaultMainWinProc(hWnd, message, wParam, lParam);
}

int AnimationStart(HWND hosting)
{
    MSG Msg;
    HWND hMainWnd;
    MAINWINCREATE CreateInfo;

#ifdef _MGRM_PROCESSES
    JoinLayer(NAME_DEF_LAYER , "animation" , 0 , 0);
#endif

    CreateInfo.dwStyle = WS_NONE;
    CreateInfo.dwExStyle = WS_EX_NONE;
    CreateInfo.spCaption = "";
    CreateInfo.hMenu = 0;
    CreateInfo.hCursor = GetSystemCursor (IDC_ARROW);
    CreateInfo.hIcon = 0;
    CreateInfo.MainWindowProc = AnimationWinProc;
    CreateInfo.lx = 0; 
    CreateInfo.ty = 0;
    CreateInfo.rx = 800;
    CreateInfo.by = 480;
    CreateInfo.iBkColor = PIXEL_lightgray;
    CreateInfo.dwAddData = 0;
    CreateInfo.dwReserved = 0;
    CreateInfo.hHosting = hosting;

    hMainWnd = CreateMainWindow (&CreateInfo);
    if (hMainWnd == HWND_INVALID)
        return -1;

    ShowWindow (hMainWnd, SW_SHOWNORMAL);

    while (GetMessage(&Msg, hMainWnd)) {
        TranslateMessage(&Msg);
        DispatchMessage(&Msg);
    }
	
    MainWindowThreadCleanup (hMainWnd);

    return 0;
}

#ifdef _MGRM_THREADS
#include 
#endif


你可能感兴趣的:(Minugui)