K
kimiraikkonen
I got an example from trusted cplusplus.com in order to compile and
see with Dev C++ 5, but i got a lot of "linker errors - undefined
references " or kind of that. I may give the exact source zip link but
somebody says it's illegal or not allowed in group rules, so here is
the code:
The package as winimage.cpp and winimage.h files also.
If you still accept downloading source code to investigate better,
here is the direct link:
http://www.cplusplus.com/src/wingif.zip
#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);
}
Thanks.
see with Dev C++ 5, but i got a lot of "linker errors - undefined
references " or kind of that. I may give the exact source zip link but
somebody says it's illegal or not allowed in group rules, so here is
the code:
The package as winimage.cpp and winimage.h files also.
If you still accept downloading source code to investigate better,
here is the direct link:
http://www.cplusplus.com/src/wingif.zip
#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);
}
Thanks.