да Добавлено @ 22:04 Сам код:
Код | #include <windows.h> #include <windowsx.h>
static HINSTANCE hinst = NULL; LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam);
TCHAR szAppName[] = "D3D"; HWND hMainWindow; HINSTANCE hMainInstance; HBITMAP Bitmap; void Window_OnPaint(HWND hwnd) { int CoordX = 0, CoordY = 0; PAINTSTRUCT PaintStruct; BITMAP bm; HDC PaintDC = BeginPaint(hwnd, &PaintStruct); HDC PicDC = CreateCompatibleDC(PaintDC); HBITMAP OldBitmap = SelectBitmap(PicDC, Bitmap); GetObject(Bitmap, sizeof(BITMAP), &bm); BitBlt(PaintDC, CoordX, CoordY, bm.bmWidth, bm.bmHeight, PicDC, 0, 0, SRCCOPY); SelectObject(PicDC, OldBitmap); DeleteDC(PicDC); EndPaint(hwnd, &PaintStruct); } void Window_OnCreate(HWND hwnd,CREATESTRUCT* pCreateStruct) { Bitmap = LoadBitmap(pCreateStruct->hInstance,"bitmap1"); } void Window_OnDestroy(HWND hwnd) { DeleteObject(Bitmap); PostQuitMessage(0); } ///// int WINAPI WinMain(HINSTANCE hInst,HINSTANCE, LPSTR lpTemplate , int nCmdShow) { MSG Msg; WNDCLASSEX WndClass;
WndClass.cbSize = sizeof(WNDCLASSEX); WndClass.style = 0; WndClass.lpfnWndProc = WndProc; WndClass.cbClsExtra = 0; WndClass.cbWndExtra = 0; WndClass.hInstance = hInst; WndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION); WndClass.hIconSm = LoadIcon(NULL, IDI_APPLICATION); WndClass.hCursor = LoadCursor(NULL, IDC_ARROW); WndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1); WndClass.lpszMenuName = NULL; WndClass.lpszClassName = szAppName;
if (!RegisterClassEx(&WndClass)) return -1;
hMainWindow = CreateWindow(szAppName, szAppName, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInst, NULL);
if (hMainWindow == NULL) return -2;
ShowWindow(hMainWindow, nCmdShow); UpdateWindow(hMainWindow);
while (GetMessage(&Msg, NULL, 0, 0)) { TranslateMessage(&Msg); DispatchMessage(&Msg); }
return (int)Msg.wParam; }
LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) { switch(Message) { case WM_CREATE: Window_OnCreate(hwnd, (CREATESTRUCT*) lParam); break; case WM_PAINT: Window_OnPaint(hwnd); break; case WM_DESTROY: Window_OnDestroy(hwnd); break; default: return DefWindowProc(hwnd, Message, wParam, lParam); }; return 0; }
|
Ресурс:
Код | Bitmap1 BITMAP "1.bmp"
|
|