Thu Nov 13, 2008 1:31 pm
// ****************************************************************************
//
// GIFVIEW.CPP
//
// This sample file demonstrates how to load an animated GIF and a BMP file
// in Windows using the Winimage library.
//
// You should compile & link this file together with:
// WINIMAGE.CPP: Generic classes for raster images (MSWindows specialization)
//
// ----------------------------------------------------------------------------
//
// Copyright © 2000, Juan Soulie <[email protected]>
//
// Permission to use, copy, modify, distribute and sell this software or any
// part thereof and/or its documentation for any purpose is granted without fee
// provided that the above copyright notice and this permission notice appear
// in all copies.
//
// This software is provided "as is" without express or implied warranty of
// any kind. The author shall have no liability with respect to the
// infringement of copyrights or patents that any modification to the content
// of this file or this file itself may incur.
//
// ****************************************************************************
#include <windows.h>
#include "winimage.h"
char szAppName[]="GIF/BMP Loader Example";
LRESULT CALLBACK WndProc (HWND,UINT,WPARAM,LPARAM);
// WinMain (Windows application main function)
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
HWND hwnd;
MSG msg;
WNDCLASSEX wndclass;
// Register the Main Window Class:
wndclass.cbSize=sizeof (wndclass);
wndclass.style=CS_HREDRAW|CS_VREDRAW;
wndclass.lpfnWndProc=WndProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=hInstance;
wndclass.hIcon=LoadIcon (NULL,IDI_APPLICATION);
wndclass.hCursor=LoadCursor (NULL,IDC_ARROW);
wndclass.hbrBackground=(HBRUSH) (COLOR_WINDOW);
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName=szAppName;
wndclass.hIconSm=LoadIcon (NULL,IDI_APPLICATION);
RegisterClassEx (&wndclass);
// Create and Show the Main Window
hwnd=CreateWindow (szAppName,szAppName,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,CW_USEDEFAULT,
CW_USEDEFAULT,CW_USEDEFAULT,
NULL,NULL,hInstance,NULL);
ShowWindow (hwnd,iCmdShow);
UpdateWindow (hwnd);
// Message Loop
while (GetMessage (&msg,NULL,0,0))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
// End Application
return msg.wParam;
}
// WndProc (Main window procedure - Message Processor)
LRESULT CALLBACK WndProc (HWND hwnd,UINT iMsg,WPARAM wParam,LPARAM lParam)
{
static C_Image img;
static C_ImageSet imgset;
static C_AnimationWindow anim, anim2, anim3;
switch (iMsg)
{
case WM_CREATE:
// Load Image files
img.LoadBMP ("logo.bmp");
imgset.LoadGIF ("sample.gif");
// Create 3 Animation Child Windows of the same C_ImageSet object:
// Notice how each one uses its own thread and can be
// paused independently (left-clicking)
anim.Create (hwnd,(HMENU)1000,&imgset);
anim2.Create (hwnd,(HMENU)1001,&imgset);
anim3.Create (hwnd,(HMENU)1002,&imgset);
return 0;
case WM_SIZE:
// Display and Set position of Animation Child Windows (GIF file):
anim.Display (10,10);
anim2.Display (110,10);
anim3.Display (210,10);
return 0;
case WM_PAINT:
// Paint the img object (BMP file):
HDC hdc;
PAINTSTRUCT ps;
hdc=BeginPaint (hwnd,&ps);
img.GDIPaint (hdc,10,100);
EndPaint (hwnd,&ps);
return 0;
case WM_DESTROY:
PostQuitMessage (0);
return 0;
}
return DefWindowProc (hwnd,iMsg,wParam,lParam);
}
|
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.