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 85 86 87 88 89 90 91
|
#include <windows.h>
LRESULT CALLBACK Mainwndproc(HWND, UINT, WPARAM, LPARAM);
char szClassName[] = "ClassName";
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE xxx, LPSTR lpszArg, int nCmdShow)
{
HWND hwnd;
MSG msg;
WNDCLASSEX wclx;
wclx.cbClsExtra = 0;
wclx.cbSize = sizeof(WNDCLASSEX);
wclx.cbWndExtra = 0;
wclx.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
wclx.hCursor = LoadCursor(NULL, IDC_ARROW);
wclx.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wclx.hIconSm= LoadIcon(NULL, IDI_APPLICATION);
wclx.hInstance = hInstance;
wclx.lpfnWndProc= Mainwndproc;
wclx.lpszClassName= szClassName;
wclx.lpszMenuName = NULL;
wclx.style = CS_DBLCLKS;
if(!RegisterClassEx(&wclx))
return 0;
hwnd = CreateWindowEx(0, /* Extended possibilites for variation */
szClassName, /* Classname */
"TetGame", /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
544, /* The programs width */
375, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);
ShowWindow(hwnd, nCmdShow);
while(GetMessage(&msg, hwnd,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK Mainwndproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hDC, hMemDC;
PAINTSTRUCT paint;
HBITMAP bitmap;
switch(message)
{
case WM_CREATE:
{
bitmap=(HBITMAP)LoadImage(NULL,"C:\\Users\\Owner\\Desktop\\TetrisGame\\bitmap.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
}
break;
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
}
break;
case WM_PAINT:
hDC= BeginPaint(hwnd, &paint);
::SelectObject(hMemDC,bitmap);
BitBlt(hDC,0,0,200,400,hMemDC,0,0,SRCCOPY);
::DeleteDC(hMemDC) ;
EndPaint(hwnd, &paint);
default:
return DefWindowProc(hwnd,message,wParam,lParam);
}
return 0;
}
|