diff --git a/Lab_1/Lab_1.sln b/Lab_1/Lab_1.sln index 9b2ea89..c741e69 100644 --- a/Lab_1/Lab_1.sln +++ b/Lab_1/Lab_1.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.30309.148 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Lab_1", "Lab_1\Lab_1.vcxproj", "{1D32933E-0C89-4FAA-8183-F729ABF26DDF}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Lab_1", "Lab_1\Lab_1.vcxproj", "{805D143F-4925-408E-8E98-71A5B106E6DF}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -13,19 +13,19 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {1D32933E-0C89-4FAA-8183-F729ABF26DDF}.Debug|x64.ActiveCfg = Debug|x64 - {1D32933E-0C89-4FAA-8183-F729ABF26DDF}.Debug|x64.Build.0 = Debug|x64 - {1D32933E-0C89-4FAA-8183-F729ABF26DDF}.Debug|x86.ActiveCfg = Debug|Win32 - {1D32933E-0C89-4FAA-8183-F729ABF26DDF}.Debug|x86.Build.0 = Debug|Win32 - {1D32933E-0C89-4FAA-8183-F729ABF26DDF}.Release|x64.ActiveCfg = Release|x64 - {1D32933E-0C89-4FAA-8183-F729ABF26DDF}.Release|x64.Build.0 = Release|x64 - {1D32933E-0C89-4FAA-8183-F729ABF26DDF}.Release|x86.ActiveCfg = Release|Win32 - {1D32933E-0C89-4FAA-8183-F729ABF26DDF}.Release|x86.Build.0 = Release|Win32 + {805D143F-4925-408E-8E98-71A5B106E6DF}.Debug|x64.ActiveCfg = Debug|x64 + {805D143F-4925-408E-8E98-71A5B106E6DF}.Debug|x64.Build.0 = Debug|x64 + {805D143F-4925-408E-8E98-71A5B106E6DF}.Debug|x86.ActiveCfg = Debug|Win32 + {805D143F-4925-408E-8E98-71A5B106E6DF}.Debug|x86.Build.0 = Debug|Win32 + {805D143F-4925-408E-8E98-71A5B106E6DF}.Release|x64.ActiveCfg = Release|x64 + {805D143F-4925-408E-8E98-71A5B106E6DF}.Release|x64.Build.0 = Release|x64 + {805D143F-4925-408E-8E98-71A5B106E6DF}.Release|x86.ActiveCfg = Release|Win32 + {805D143F-4925-408E-8E98-71A5B106E6DF}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {F5EF02C5-75A8-4FCC-86CC-6E324B1EAE71} + SolutionGuid = {571BAF3D-8401-47F0-A299-8FE9B367693D} EndGlobalSection EndGlobal diff --git a/Lab_1/Lab_1/Lab_1.cpp b/Lab_1/Lab_1/Lab_1.cpp index 92ea0e9..847d531 100644 --- a/Lab_1/Lab_1/Lab_1.cpp +++ b/Lab_1/Lab_1/Lab_1.cpp @@ -1,97 +1,76 @@ #include -#include -#include -#include "resource.h"; - -typedef std::basic_string, - std::allocator > String; +constexpr auto WINDOW_NAME = "Lab_1"; +ATOM RegisterWindowClass(HINSTANCE); +BOOL InitWindowInstance(HINSTANCE, int); 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) +int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR cmdLine, int cmdShowMode) { - HWND hWnd; // Window descriptor. - MSG msg; // Structure for storing the message. - WNDCLASS wc; // Window class. - - wc.hInstance = This; - wc.lpszClassName = WinName; // Window name. - wc.lpfnWndProc = WndProc; // Callback window function. - wc.style = CS_HREDRAW | CS_VREDRAW; // Window style. - wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); // Default window icon. - wc.hCursor = LoadCursor(NULL, IDC_ARROW); // Default mouse cursor. - wc.lpszMenuName = NULL; // Window has no menu. - wc.cbClsExtra = 0; // No extra class info. - wc.cbWndExtra = 0; // No extra window info. - - // Fill window with white color. - wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); - - hInst = This; - - // Class registration - if (!RegisterClass(&wc)) - return 0; + UNREFERENCED_PARAMETER(hPrevInstance); + UNREFERENCED_PARAMETER(cmdLine); + + MSG msg; + + RegisterWindowClass(hInstance); - hWnd = CreateWindow(WinName, // Window name. - _T("Lab_1"), // Window title. - WS_OVERLAPPEDWINDOW, // Window style. - CW_USEDEFAULT, // X. - CW_USEDEFAULT, // Y. - CW_USEDEFAULT, // Window width. - CW_USEDEFAULT, // Window height. - HWND_DESKTOP, // Parent window descriptor. - NULL, // Window has no menu. - This, // Application descriptor. - NULL); // No extra info. - - ShowWindow(hWnd, mode); - - // Message processing cycle. - while (GetMessage(&msg, NULL, 0, 0)) { + if (!InitWindowInstance(hInstance, cmdShowMode)) + return FALSE; + + while (GetMessage(&msg, NULL, 0, 0)) + { TranslateMessage(&msg); DispatchMessage(&msg); } - return 0; + return (int)msg.wParam; } -// The window function is called by the operating system and -// receives messages from the queue for this application. -LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +ATOM RegisterWindowClass(HINSTANCE hInstance) +{ + WNDCLASSEX windowClassEx; + + windowClassEx.cbSize = sizeof(WNDCLASSEX); + windowClassEx.style = CS_HREDRAW | CS_VREDRAW; + windowClassEx.lpfnWndProc = WndProc; + windowClassEx.cbClsExtra = 0; + windowClassEx.cbWndExtra = 0; + windowClassEx.hInstance = hInstance; + windowClassEx.hIcon = LoadIcon(0, IDI_WINLOGO);; + windowClassEx.hCursor = LoadCursor(0, IDC_ARROW); + windowClassEx.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); + windowClassEx.lpszMenuName = 0; + windowClassEx.lpszClassName = WINDOW_NAME; + windowClassEx.hIconSm = 0; + + return RegisterClassEx(&windowClassEx); +} + +BOOL InitWindowInstance(HINSTANCE hInstance, int cmdShowMode) { - PAINTSTRUCT ps; - HDC hdc; - HBITMAP hBitmap; + HWND hWnd; + + hWnd = CreateWindow(WINDOW_NAME, WINDOW_NAME, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, + CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); + + if (!hWnd) + return FALSE; - static HDC memBitMap; - static BITMAP bm; + ShowWindow(hWnd, cmdShowMode); + UpdateWindow(hWnd); + + return TRUE; +} +LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ 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: + case WM_DESTROY: PostQuitMessage(0); - break; + return 0; default: return DefWindowProc(hWnd, message, wParam, lParam); } - - return 0; -} \ No newline at end of file +} diff --git a/Lab_1/Lab_1/Lab_1.rc b/Lab_1/Lab_1/Lab_1.rc deleted file mode 100644 index 38d855f..0000000 --- a/Lab_1/Lab_1/Lab_1.rc +++ /dev/null @@ -1,69 +0,0 @@ -// 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 b848882..6bd1f26 100644 --- a/Lab_1/Lab_1/Lab_1.vcxproj +++ b/Lab_1/Lab_1/Lab_1.vcxproj @@ -21,7 +21,7 @@ 16.0 Win32Proj - {1d32933e-0c89-4faa-8183-f729abf26ddf} + {805d143f-4925-408e-8e98-71a5b106e6df} Lab1 10.0 @@ -30,7 +30,7 @@ Application true v142 - Unicode + MultiByte Application @@ -86,7 +86,7 @@ Level3 true - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true @@ -100,11 +100,11 @@ true true true - WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true - Windows + Console true true true @@ -114,11 +114,11 @@ Level3 true - _DEBUG;_WINDOWS;%(PreprocessorDefinitions) + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - Windows + Console true @@ -128,11 +128,11 @@ true true true - NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true - Windows + Console true true true @@ -141,15 +141,6 @@ - - - - - - - - - diff --git a/Lab_1/Lab_1/Lab_1.vcxproj.filters b/Lab_1/Lab_1/Lab_1.vcxproj.filters index 33c5184..2954ba3 100644 --- a/Lab_1/Lab_1/Lab_1.vcxproj.filters +++ b/Lab_1/Lab_1/Lab_1.vcxproj.filters @@ -19,19 +19,4 @@ 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 deleted file mode 100644 index 6f31407..0000000 Binary files a/Lab_1/Lab_1/bitmap1.bmp and /dev/null differ diff --git a/Lab_1/Lab_1/resource.h b/Lab_1/Lab_1/resource.h deleted file mode 100644 index 9d29ca6..0000000 --- a/Lab_1/Lab_1/resource.h +++ /dev/null @@ -1,16 +0,0 @@ -//{{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