1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
#include <windows.h>
#include <gdiplus.h>
using namespace Gdiplus;
HWND hwnd;
MSG msg;
WNDCLASS bfg;
HDC hdc;
PAINTSTRUCT ps;
GdiplusStartupInput gdipsi;
ULONG_PTR Uptr;
int x=0;
int y=0;
void Ciz(HDC hdc)
{
Graphics ciz(hdc);
Image rsm(L"lifam.bmp");
SolidBrush renk(Gdiplus::Color::DarkTurquoise);
Pen kalem(Color(0,0,0),3);
ciz.DrawRectangle(&kalem,x,y,x+100,x+100);
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT message,WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_CREATE:
SetTimer(hwnd,1,10,0);
break;
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
break;
case WM_TIMER:
x++;
y++;
Ciz(hdc);
break;
case WM_DESTROY:
EndPaint(hwnd, &ps);
KillTimer(hwnd,1);
PostQuitMessage(0);
return 0;
default:
return DefWindowProc(hwnd, message, wParam, lParam);
}
}
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, PSTR, INT iCmdShow)
{
GdiplusStartup(&Uptr, &gdipsi, NULL);
bfg.style = CS_HREDRAW | CS_VREDRAW;
bfg.lpfnWndProc = WndProc;
bfg.hInstance = hInstance;
bfg.hIcon = LoadIcon(NULL, IDI_APPLICATION);
bfg.hCursor = LoadCursor(NULL, IDC_ARROW);
bfg.hbrBackground = (HBRUSH)(COLOR_WINDOW);
bfg.lpszClassName = L"BFG";
RegisterClass(&bfg);
hwnd = CreateWindow(L"BFG",L"Pencere", WS_OVERLAPPEDWINDOW,0,0,600,600,NULL,NULL,hInstance,NULL);
ShowWindow(hwnd, iCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
GdiplusShutdown(Uptr);
return 0;
}
|