diff --git a/CPaintFrame.cpp b/CPaintFrame.cpp new file mode 100644 index 0000000..4528e08 --- /dev/null +++ b/CPaintFrame.cpp @@ -0,0 +1,13 @@ +#include "CPaintFrame.h" + +BEGIN_MESSAGE_MAP(CPaintFrame, CFrameWnd) + ON_WM_CREATE() +END_MESSAGE_MAP() + +int CPaintFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + CFrameWnd::OnCreate(lpCreateStruct); + + m_wndView.Create(nullptr, nullptr, AFX_WS_DEFAULT_VIEW, CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST); + return 0; +} diff --git a/CPaintFrame.h b/CPaintFrame.h new file mode 100644 index 0000000..520708b --- /dev/null +++ b/CPaintFrame.h @@ -0,0 +1,13 @@ +#pragma once + +#include +#include "CPaintView.h" + +class CPaintFrame : public CFrameWnd { +public: + CPaintFrame() {}; + CPaintView m_wndView; +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + DECLARE_MESSAGE_MAP() +}; diff --git a/CPaintView.cpp b/CPaintView.cpp new file mode 100644 index 0000000..992dfbc --- /dev/null +++ b/CPaintView.cpp @@ -0,0 +1,44 @@ +#include "CPaintView.h" +#include "resource.h" + +BEGIN_MESSAGE_MAP(CPaintView, CWnd) + ON_WM_LBUTTONDOWN() + ON_WM_MOUSEMOVE() + ON_WM_LBUTTONUP() +END_MESSAGE_MAP() + +void CPaintView::OnLButtonDown(UINT nFlags, CPoint point) { + TRACE(L"Нажата левая кнопка мыши с %lx флагами и (%d,%d) координатами\n", (long)nFlags, point.y, point.y); + startp = point; + + CWnd::OnLButtonDown(nFlags, point); +} + +void CPaintView::OnMouseMove(UINT nFlags, CPoint point) { + endp = point; + + if (startp.x != -1) { + CClientDC dc(this); + dc.MoveTo(startp); + dc.LineTo(endp); + startp = endp; + } + + CWnd::OnMouseMove(nFlags, point); +} + +void CPaintView::OnLButtonUp(UINT nFlags, CPoint point) { + startp = -1; + + CWnd::OnLButtonUp(nFlags, point); +} + +BOOL CPaintView::PreCreateWindow(CREATESTRUCT& cs) +{ + if (!CWnd::PreCreateWindow(cs)) + return FALSE; + + cs.lpszClass = AfxRegisterWndClass(CS_VREDRAW | CS_HREDRAW, LoadCursor(AfxGetResourceHandle(), MAKEINTRESOURCE(IDC_PENCIL)), CreateSolidBrush(RGB(255, 255, 255))); + + return TRUE; +} diff --git a/CPaintView.h b/CPaintView.h new file mode 100644 index 0000000..379e10c --- /dev/null +++ b/CPaintView.h @@ -0,0 +1,18 @@ +#pragma once + +#include + +class CPaintView : public CWnd { +public: + CPaintView() {}; +protected: + CPoint startp = -1, endp = -1; + + BOOL PreCreateWindow(CREATESTRUCT& cs); + + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + afx_msg void OnMouseMove(UINT nFlags, CPoint point); + afx_msg void OnLButtonUp(UINT nFlags, CPoint point); + + DECLARE_MESSAGE_MAP() +}; diff --git a/ClassDiagram.cd b/ClassDiagram.cd new file mode 100644 index 0000000..4bb8d74 --- /dev/null +++ b/ClassDiagram.cd @@ -0,0 +1,46 @@ + + + + + + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAA= + MyPaint.h + + + + + + AAAAAAAAAAABAAAAAAQAAAAAACAAAAAAAAAAAAAAAAA= + CPaintFrame.h + + + + + + AAAAAAABAAIAAAAgAAAAAABAgBAAAAAAAAAAAAAQAAA= + CPaintView.h + + + + + + 57Zg4NJZMRYwEDOJuKSX1EtlESlJxcwkSSNipVAHtHc= + C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\atlmfc\include\afxwin.h + + + + + + k0yJUpw3ZFmZ0rrIzxMZ3AwUwfcQUHEOZo56pYUD3rA= + C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\atlmfc\include\afxwin.h + + + + + + v977//bff7//b//96f/v/f/97/+e33f39uv7/d///78= + C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\atlmfc\include\afxwin.h + + + + \ No newline at end of file diff --git a/MyPaint.cpp b/MyPaint.cpp new file mode 100644 index 0000000..28cdf26 --- /dev/null +++ b/MyPaint.cpp @@ -0,0 +1,23 @@ +#include "MyPaint.h" +#include "CPaintFrame.h" +#include "resource.h" + +CMyPaint myApp; + +BOOL CMyPaint::InitInstance() { + CWinApp::InitInstance(); + + CPaintFrame* pFrame = new CPaintFrame(); + if (!pFrame) + return FALSE; + m_pMainWnd = pFrame; + + CString pFrameClass = AfxRegisterWndClass(NULL, nullptr, nullptr, LoadIcon(IDI_PENCIL)); + + pFrame->Create(pFrameClass, L"My paint :D"); + + pFrame->ShowWindow(m_nCmdShow); + pFrame->UpdateWindow(); + + return TRUE; +} diff --git a/MyPaint.h b/MyPaint.h new file mode 100644 index 0000000..30ad275 --- /dev/null +++ b/MyPaint.h @@ -0,0 +1,8 @@ +#pragma once + +#include + +class CMyPaint : public CWinApp { +public: + virtual BOOL InitInstance(); +}; diff --git a/MyPaint.rc b/MyPaint.rc new file mode 100644 index 0000000..2e2e74f --- /dev/null +++ b/MyPaint.rc @@ -0,0 +1,79 @@ +// 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 + + +///////////////////////////////////////////////////////////////////////////// +// +// Cursor +// + +IDC_PENCIL CURSOR "pencil.cur" + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_PENCIL ICON "pencil.ico" + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/MyPaint.sln b/MyPaint.sln new file mode 100644 index 0000000..9a7f6ee --- /dev/null +++ b/MyPaint.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32210.238 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MyPaint", "MyPaint.vcxproj", "{6C6D3AE7-369D-4E6E-9FB4-183EE2AD8360}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6C6D3AE7-369D-4E6E-9FB4-183EE2AD8360}.Debug|x64.ActiveCfg = Debug|x64 + {6C6D3AE7-369D-4E6E-9FB4-183EE2AD8360}.Debug|x64.Build.0 = Debug|x64 + {6C6D3AE7-369D-4E6E-9FB4-183EE2AD8360}.Debug|x86.ActiveCfg = Debug|Win32 + {6C6D3AE7-369D-4E6E-9FB4-183EE2AD8360}.Debug|x86.Build.0 = Debug|Win32 + {6C6D3AE7-369D-4E6E-9FB4-183EE2AD8360}.Release|x64.ActiveCfg = Release|x64 + {6C6D3AE7-369D-4E6E-9FB4-183EE2AD8360}.Release|x64.Build.0 = Release|x64 + {6C6D3AE7-369D-4E6E-9FB4-183EE2AD8360}.Release|x86.ActiveCfg = Release|Win32 + {6C6D3AE7-369D-4E6E-9FB4-183EE2AD8360}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {BBC8108F-4286-4CC8-AD42-C981DB644F1A} + EndGlobalSection +EndGlobal diff --git a/MyPaint.vcxproj b/MyPaint.vcxproj new file mode 100644 index 0000000..76474bb --- /dev/null +++ b/MyPaint.vcxproj @@ -0,0 +1,168 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {6c6d3ae7-369d-4e6e-9fb4-183ee2ad8360} + MyPaint + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + Dynamic + + + Application + false + v143 + true + Unicode + Dynamic + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + + + false + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Windows + true + + + + + Level3 + true + true + true + NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MyPaint.vcxproj.filters b/MyPaint.vcxproj.filters new file mode 100644 index 0000000..5a0f4ae --- /dev/null +++ b/MyPaint.vcxproj.filters @@ -0,0 +1,59 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Resource Files + + + + + Resource Files + + + + + + + Resource Files + + + \ No newline at end of file diff --git a/README.md b/README.md index f2a9479..9cb0301 100644 --- a/README.md +++ b/README.md @@ -1 +1,5 @@ -MyPaint \ No newline at end of file +# MyPaint + +Simple MFC application with painting on main view + +![Screenshot: "Hello World!"](./img/screen.jpg) \ No newline at end of file diff --git a/img/screen.jpg b/img/screen.jpg new file mode 100644 index 0000000..de1a7d0 Binary files /dev/null and b/img/screen.jpg differ diff --git a/pencil.bmp b/pencil.bmp new file mode 100644 index 0000000..45fc75c Binary files /dev/null and b/pencil.bmp differ diff --git a/pencil.cur b/pencil.cur new file mode 100644 index 0000000..6ace8c6 Binary files /dev/null and b/pencil.cur differ diff --git a/pencil.ico b/pencil.ico new file mode 100644 index 0000000..925a34a Binary files /dev/null and b/pencil.ico differ diff --git a/resource.h b/resource.h new file mode 100644 index 0000000..5151d0e --- /dev/null +++ b/resource.h @@ -0,0 +1,17 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by MyPaint.rc +// +#define IDI_PENCIL 4 +#define IDC_PENCIL 240 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 108 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1002 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif