diff --git a/Lab_1/Lab_1/Lab_1.cpp b/Lab_1/Lab_1/Lab_1.cpp index e046652..92ea0e9 100644 --- a/Lab_1/Lab_1/Lab_1.cpp +++ b/Lab_1/Lab_1/Lab_1.cpp @@ -1,8 +1,16 @@ #include #include +#include + +#include "resource.h"; + +typedef std::basic_string, + std::allocator > String; LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); + TCHAR WinName[] = _T("Lab_1"); +HINSTANCE hInst; int APIENTRY _tWinMain(HINSTANCE This, HINSTANCE Prev, LPTSTR cmd, int mode) { @@ -21,7 +29,9 @@ int APIENTRY _tWinMain(HINSTANCE This, HINSTANCE Prev, LPTSTR cmd, int mode) wc.cbWndExtra = 0; // No extra window info. // Fill window with white color. - wc.hbrBackground = (HBRUSH)(WHITE_BRUSH); + wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); + + hInst = This; // Class registration if (!RegisterClass(&wc)) @@ -54,8 +64,28 @@ int APIENTRY _tWinMain(HINSTANCE This, HINSTANCE Prev, LPTSTR cmd, int mode) // receives messages from the queue for this application. LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { + PAINTSTRUCT ps; + HDC hdc; + HBITMAP hBitmap; + + static HDC memBitMap; + static BITMAP bm; + switch (message) { + case WM_CREATE: + hBitmap = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_BITMAP1)); + GetObject(hBitmap, sizeof(bm), &bm); + hdc = GetDC(hWnd); + memBitMap = CreateCompatibleDC(hdc); + SelectObject(memBitMap, hBitmap); + ReleaseDC(hWnd, hdc); + break; + case WM_PAINT: + hdc = BeginPaint(hWnd, &ps); + BitBlt(hdc, 0, 0, bm.bmWidth, bm.bmHeight, memBitMap, 0, 0, SRCCOPY); + EndPaint(hWnd, &ps); + break; case WM_DESTROY: PostQuitMessage(0); break; diff --git a/Lab_1/Lab_1/Lab_1.rc b/Lab_1/Lab_1/Lab_1.rc new file mode 100644 index 0000000..38d855f --- /dev/null +++ b/Lab_1/Lab_1/Lab_1.rc @@ -0,0 +1,69 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Bitmap +// + +IDB_BITMAP1 BITMAP "bitmap1.bmp" + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Lab_1/Lab_1/Lab_1.vcxproj b/Lab_1/Lab_1/Lab_1.vcxproj index 89692c7..b848882 100644 --- a/Lab_1/Lab_1/Lab_1.vcxproj +++ b/Lab_1/Lab_1/Lab_1.vcxproj @@ -141,6 +141,15 @@ + + + + + + + + + diff --git a/Lab_1/Lab_1/Lab_1.vcxproj.filters b/Lab_1/Lab_1/Lab_1.vcxproj.filters index 2954ba3..33c5184 100644 --- a/Lab_1/Lab_1/Lab_1.vcxproj.filters +++ b/Lab_1/Lab_1/Lab_1.vcxproj.filters @@ -19,4 +19,19 @@ Source Files + + + Header Files + + + + + Resource Files + + + + + Resource Files + + \ No newline at end of file diff --git a/Lab_1/Lab_1/bitmap1.bmp b/Lab_1/Lab_1/bitmap1.bmp new file mode 100644 index 0000000..6f31407 Binary files /dev/null and b/Lab_1/Lab_1/bitmap1.bmp differ diff --git a/Lab_1/Lab_1/resource.h b/Lab_1/Lab_1/resource.h new file mode 100644 index 0000000..9d29ca6 --- /dev/null +++ b/Lab_1/Lab_1/resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Lab_1.rc +// +#define IDB_BITMAP1 101 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 102 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif