Create Windmill

This commit is contained in:
xixu-me committed 2024-09-12 01:33:35 +08:00
1 parent 7b3e8ce071
commit 7e0874c08e
38 files changed
+602 -421

No files matched your search

Binary file not shown.
Binary file not shown.
-12
View File
@@ -1,12 +0,0 @@
{
"Version": 1,
"WorkspaceRootPath": "C:\\Users\\xixu\\Desktop\\Computer-Graphics\\Test\\",
"Documents": [],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": []
}
]
}
Binary file not shown.
-31
View File
@@ -1,31 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.11.35222.181
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test", "Test\Test.vcxproj", "{61C69A24-AFCE-489B-B0B9-CF00D8F0C6D3}"
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
{61C69A24-AFCE-489B-B0B9-CF00D8F0C6D3}.Debug|x64.ActiveCfg = Debug|x64
{61C69A24-AFCE-489B-B0B9-CF00D8F0C6D3}.Debug|x64.Build.0 = Debug|x64
{61C69A24-AFCE-489B-B0B9-CF00D8F0C6D3}.Debug|x86.ActiveCfg = Debug|Win32
{61C69A24-AFCE-489B-B0B9-CF00D8F0C6D3}.Debug|x86.Build.0 = Debug|Win32
{61C69A24-AFCE-489B-B0B9-CF00D8F0C6D3}.Release|x64.ActiveCfg = Release|x64
{61C69A24-AFCE-489B-B0B9-CF00D8F0C6D3}.Release|x64.Build.0 = Release|x64
{61C69A24-AFCE-489B-B0B9-CF00D8F0C6D3}.Release|x86.ActiveCfg = Release|Win32
{61C69A24-AFCE-489B-B0B9-CF00D8F0C6D3}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4572A883-0B15-4A35-8CFA-98F7FC74ABEA}
EndGlobalSection
EndGlobal
-19
View File
@@ -1,19 +0,0 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by Test.rc
//
#define IDD_ABOUTBOX 100
#define IDP_OLE_INIT_FAILED 100
#define IDR_MAINFRAME 128
#define IDR_TestTYPE 130
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 310
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 310
#define _APS_NEXT_COMMAND_VALUE 32771
#endif
#endif
-30
View File
@@ -1,30 +0,0 @@
// Test.h : main header file for the Test application
//
#pragma once
#ifndef __AFXWIN_H__
#error "include 'pch.h' before including this file for PCH"
#endif
#include "resource.h" // main symbols
// CTestApp:
// See Test.cpp for the implementation of this class
//
class CTestApp : public CWinApp {
public:
CTestApp() noexcept;
// Overrides
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
// Implementation
afx_msg void OnAppAbout();
DECLARE_MESSAGE_MAP()
};
extern CTestApp theApp;
-42
View File
@@ -1,42 +0,0 @@
// TestDoc.h : interface of the CTestDoc class
//
#pragma once
class CTestDoc : public CDocument {
protected: // create from serialization only
CTestDoc() noexcept;
DECLARE_DYNCREATE(CTestDoc)
// Attributes
public:
// Operations
public:
// Overrides
public:
virtual BOOL OnNewDocument();
virtual void Serialize(CArchive &ar);
#ifdef SHARED_HANDLERS
virtual void InitializeSearchContent();
virtual void OnDrawThumbnail(CDC &dc, LPRECT lprcBounds);
#endif // SHARED_HANDLERS
// Implementation
public:
virtual ~CTestDoc();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext &dc) const;
#endif
protected:
// Generated message map functions
protected:
DECLARE_MESSAGE_MAP()
#ifdef SHARED_HANDLERS
// Helper function that sets search content for a Search Handler
void SetSearchContent(const CString &value);
#endif // SHARED_HANDLERS
};
-91
View File
@@ -1,91 +0,0 @@
// TestView.cpp : implementation of the CTestView class
//
#include "pch.h"
#include "framework.h"
// SHARED_HANDLERS can be defined in an ATL project implementing preview, thumbnail
// and search filter handlers and allows sharing of document code with that project.
#ifndef SHARED_HANDLERS
#include "Test.h"
#endif
#include "TestDoc.h"
#include "TestView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CTestView
IMPLEMENT_DYNCREATE(CTestView, CView)
BEGIN_MESSAGE_MAP(CTestView, CView)
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CView::OnFilePrintPreview)
END_MESSAGE_MAP()
// CTestView construction/destruction
CTestView::CTestView() noexcept {
// TODO: add construction code here
}
CTestView::~CTestView() {
}
BOOL CTestView::PreCreateWindow(CREATESTRUCT &cs) {
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
// CTestView drawing
void CTestView::OnDraw(CDC * /*pDC*/) {
CTestDoc *pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
// TODO: add draw code for native data here
}
// CTestView printing
BOOL CTestView::OnPreparePrinting(CPrintInfo *pInfo) {
// default preparation
return DoPreparePrinting(pInfo);
}
void CTestView::OnBeginPrinting(CDC * /*pDC*/, CPrintInfo * /*pInfo*/) {
// TODO: add extra initialization before printing
}
void CTestView::OnEndPrinting(CDC * /*pDC*/, CPrintInfo * /*pInfo*/) {
// TODO: add cleanup after printing
}
// CTestView diagnostics
#ifdef _DEBUG
void CTestView::AssertValid() const {
CView::AssertValid();
}
void CTestView::Dump(CDumpContext &dc) const {
CView::Dump(dc);
}
CTestDoc *CTestView::GetDocument() const // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTestDoc)));
return (CTestDoc *)m_pDocument;
}
#endif //_DEBUG
// CTestView message handlers
-44
View File
@@ -1,44 +0,0 @@
// TestView.h : interface of the CTestView class
//
#pragma once
class CTestView : public CView {
protected: // create from serialization only
CTestView() noexcept;
DECLARE_DYNCREATE(CTestView)
// Attributes
public:
CTestDoc *GetDocument() const;
// Operations
public:
// Overrides
public:
virtual void OnDraw(CDC *pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT &cs);
protected:
virtual BOOL OnPreparePrinting(CPrintInfo *pInfo);
virtual void OnBeginPrinting(CDC *pDC, CPrintInfo *pInfo);
virtual void OnEndPrinting(CDC *pDC, CPrintInfo *pInfo);
// Implementation
public:
virtual ~CTestView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext &dc) const;
#endif
protected:
// Generated message map functions
protected:
DECLARE_MESSAGE_MAP()
};
#ifndef _DEBUG // debug version in TestView.cpp
inline CTestDoc *CTestView::GetDocument() const { return reinterpret_cast<CTestDoc *>(m_pDocument); }
#endif
-36
View File
@@ -1,36 +0,0 @@
#pragma once
#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif
#include "targetver.h"
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
// turns off MFC's hiding of some common and often safely ignored warning messages
#define _AFX_ALL_WARNINGS
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation classes
#ifndef _AFX_NO_OLE_SUPPORT
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#endif
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <afxcontrolbars.h> // MFC support for ribbons and control bars
#ifdef _UNICODE
#if defined _M_IX86
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_X64
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#else
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#endif
#endif
File renamed without changes.
File renamed without changes.
File renamed without changes.
+31
View File
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.11.35303.130
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Windmill", "Windmill\Windmill.vcxproj", "{FD3385C2-45C6-4496-83E7-770D53CB9873}"
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
{FD3385C2-45C6-4496-83E7-770D53CB9873}.Debug|x64.ActiveCfg = Debug|x64
{FD3385C2-45C6-4496-83E7-770D53CB9873}.Debug|x64.Build.0 = Debug|x64
{FD3385C2-45C6-4496-83E7-770D53CB9873}.Debug|x86.ActiveCfg = Debug|Win32
{FD3385C2-45C6-4496-83E7-770D53CB9873}.Debug|x86.Build.0 = Debug|Win32
{FD3385C2-45C6-4496-83E7-770D53CB9873}.Release|x64.ActiveCfg = Release|x64
{FD3385C2-45C6-4496-83E7-770D53CB9873}.Release|x64.Build.0 = Release|x64
{FD3385C2-45C6-4496-83E7-770D53CB9873}.Release|x86.ActiveCfg = Release|Win32
{FD3385C2-45C6-4496-83E7-770D53CB9873}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {60452FB6-59AF-4CBC-812A-C07393086B5F}
EndGlobalSection
EndGlobal
@@ -4,7 +4,7 @@
#include "pch.h"
#include "framework.h"
#include "Test.h"
#include "Windmill.h"
#include "MainFrm.h"
@@ -17,11 +17,12 @@
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
ON_WM_CREATE()
ON_WM_CREATE()
END_MESSAGE_MAP()
static UINT indicators[] = {
ID_SEPARATOR, // status line indicator
static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
@@ -29,39 +30,46 @@ static UINT indicators[] = {
// CMainFrame construction/destruction
CMainFrame::CMainFrame() noexcept {
CMainFrame::CMainFrame() noexcept
{
// TODO: add member initialization code here
}
CMainFrame::~CMainFrame() {
CMainFrame::~CMainFrame()
{
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) {
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) {
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
return -1; // fail to create
}
if (!m_wndStatusBar.Create(this)) {
if (!m_wndStatusBar.Create(this))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
return -1; // fail to create
}
m_wndStatusBar.SetIndicators(indicators, sizeof(indicators) / sizeof(UINT));
m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT));
// TODO: Delete these three lines if you don't want the toolbar to be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT &cs) {
if (!CFrameWnd::PreCreateWindow(cs))
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
@@ -72,13 +80,17 @@ BOOL CMainFrame::PreCreateWindow(CREATESTRUCT &cs) {
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const {
void CMainFrame::AssertValid() const
{
CFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext &dc) const {
void CMainFrame::Dump(CDumpContext& dc) const
{
CFrameWnd::Dump(dc);
}
#endif //_DEBUG
// CMainFrame message handlers
@@ -4,34 +4,40 @@
#pragma once
class CMainFrame : public CFrameWnd {
class CMainFrame : public CFrameWnd
{
protected: // create from serialization only
CMainFrame() noexcept;
DECLARE_DYNCREATE(CMainFrame)
// Attributes
// Attributes
public:
// Operations
public:
// Overrides
public:
virtual BOOL PreCreateWindow(CREATESTRUCT &cs);
// Implementation
// Operations
public:
// Overrides
public:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
// Implementation
public:
virtual ~CMainFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext &dc) const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected: // control bar embedded members
CToolBar m_wndToolBar;
CStatusBar m_wndStatusBar;
protected: // control bar embedded members
CToolBar m_wndToolBar;
CStatusBar m_wndStatusBar;
// Generated message map functions
// Generated message map functions
protected:
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
DECLARE_MESSAGE_MAP()
};
+19
View File
@@ -0,0 +1,19 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by Windmill.rc
//
#define IDD_ABOUTBOX 100
#define IDP_OLE_INIT_FAILED 100
#define IDR_MAINFRAME 128
#define IDR_WindmillTYPE 130
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 310
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 310
#define _APS_NEXT_COMMAND_VALUE 32771
#endif
#endif
Binary file not shown.
@@ -1,35 +1,38 @@
// Test.cpp : Defines the class behaviors for the application.
// Windmill.cpp : Defines the class behaviors for the application.
//
#include "pch.h"
#include "framework.h"
#include "afxwinappex.h"
#include "afxdialogex.h"
#include "Test.h"
#include "Windmill.h"
#include "MainFrm.h"
#include "TestDoc.h"
#include "TestView.h"
#include "WindmillDoc.h"
#include "WindmillView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CTestApp
BEGIN_MESSAGE_MAP(CTestApp, CWinApp)
ON_COMMAND(ID_APP_ABOUT, &CTestApp::OnAppAbout)
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, &CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, &CWinApp::OnFileOpen)
// Standard print setup command
ON_COMMAND(ID_FILE_PRINT_SETUP, &CWinApp::OnFilePrintSetup)
// CWindmillApp
BEGIN_MESSAGE_MAP(CWindmillApp, CWinApp)
ON_COMMAND(ID_APP_ABOUT, &CWindmillApp::OnAppAbout)
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, &CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, &CWinApp::OnFileOpen)
// Standard print setup command
ON_COMMAND(ID_FILE_PRINT_SETUP, &CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()
// CTestApp construction
CTestApp::CTestApp() noexcept {
// CWindmillApp construction
CWindmillApp::CWindmillApp() noexcept
{
// support Restart Manager
m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_ALL_ASPECTS;
@@ -42,19 +45,21 @@ CTestApp::CTestApp() noexcept {
// TODO: replace application ID string below with unique ID string; recommended
// format for string is CompanyName.ProductName.SubProduct.VersionInformation
SetAppID(_T("Test.AppID.NoVersion"));
SetAppID(_T("Windmill.AppID.NoVersion"));
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
// The one and only CTestApp object
// The one and only CWindmillApp object
CTestApp theApp;
CWindmillApp theApp;
// CTestApp initialization
BOOL CTestApp::InitInstance() {
// CWindmillApp initialization
BOOL CWindmillApp::InitInstance()
{
// InitCommonControlsEx() is required on Windows XP if an application
// manifest specifies use of ComCtl32.dll version 6 or later to enable
// visual styles. Otherwise, any window creation will fail.
@@ -67,8 +72,10 @@ BOOL CTestApp::InitInstance() {
CWinApp::InitInstance();
// Initialize OLE libraries
if (!AfxOleInit()) {
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
@@ -88,24 +95,28 @@ BOOL CTestApp::InitInstance() {
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(4); // Load standard INI file options (including MRU)
LoadStdProfileSettings(4); // Load standard INI file options (including MRU)
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views
CSingleDocTemplate *pDocTemplate;
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CTestDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CTestView));
RUNTIME_CLASS(CWindmillDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CWindmillView));
if (!pDocTemplate)
return FALSE;
AddDocTemplate(pDocTemplate);
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line. Will return FALSE if
// app was launched with /RegServer, /Register, /Unregserver or /Unregister.
if (!ProcessShellCommand(cmdInfo))
@@ -117,18 +128,21 @@ BOOL CTestApp::InitInstance() {
return TRUE;
}
int CTestApp::ExitInstance() {
// TODO: handle additional resources you may have added
int CWindmillApp::ExitInstance()
{
//TODO: handle additional resources you may have added
AfxOleTerm(FALSE);
return CWinApp::ExitInstance();
}
// CTestApp message handlers
// CWindmillApp message handlers
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialogEx {
class CAboutDlg : public CDialogEx
{
public:
CAboutDlg() noexcept;
@@ -138,17 +152,19 @@ public:
#endif
protected:
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
// Implementation
// Implementation
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() noexcept : CDialogEx(IDD_ABOUTBOX) {
CAboutDlg::CAboutDlg() noexcept : CDialogEx(IDD_ABOUTBOX)
{
}
void CAboutDlg::DoDataExchange(CDataExchange *pDX) {
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}
@@ -156,9 +172,13 @@ BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx)
END_MESSAGE_MAP()
// App command to run the dialog
void CTestApp::OnAppAbout() {
void CWindmillApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
// CTestApp message handlers
// CWindmillApp message handlers
+33
View File
@@ -0,0 +1,33 @@
// Windmill.h : main header file for the Windmill application
//
#pragma once
#ifndef __AFXWIN_H__
#error "include 'pch.h' before including this file for PCH"
#endif
#include "resource.h" // main symbols
// CWindmillApp:
// See Windmill.cpp for the implementation of this class
//
class CWindmillApp : public CWinApp
{
public:
CWindmillApp() noexcept;
// Overrides
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
// Implementation
afx_msg void OnAppAbout();
DECLARE_MESSAGE_MAP()
};
extern CWindmillApp theApp;
Binary file not shown.
@@ -20,9 +20,9 @@
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>17.0</VCProjectVersion>
<ProjectGuid>{61C69A24-AFCE-489B-B0B9-CF00D8F0C6D3}</ProjectGuid>
<ProjectGuid>{FD3385C2-45C6-4496-83E7-770D53CB9873}</ProjectGuid>
<Keyword>MFCProj</Keyword>
<RootNamespace>Test</RootNamespace>
<RootNamespace>Windmill</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
@@ -46,7 +46,7 @@
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc>
<UseOfMfc>Static</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
@@ -188,9 +188,9 @@
<ClInclude Include="pch.h" />
<ClInclude Include="Resource.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="Test.h" />
<ClInclude Include="TestDoc.h" />
<ClInclude Include="TestView.h" />
<ClInclude Include="Windmill.h" />
<ClInclude Include="WindmillDoc.h" />
<ClInclude Include="WindmillView.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="MainFrm.cpp" />
@@ -200,20 +200,20 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="Test.cpp" />
<ClCompile Include="TestDoc.cpp" />
<ClCompile Include="TestView.cpp" />
<ClCompile Include="Windmill.cpp" />
<ClCompile Include="WindmillDoc.cpp" />
<ClCompile Include="WindmillView.cpp" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Test.rc" />
<ResourceCompile Include="Windmill.rc" />
</ItemGroup>
<ItemGroup>
<None Include="res\Test.rc2" />
<None Include="res\Windmill.rc2" />
</ItemGroup>
<ItemGroup>
<Image Include="res\Test.ico" />
<Image Include="res\TestDoc.ico" />
<Image Include="res\Toolbar.bmp" />
<Image Include="res\Windmill.ico" />
<Image Include="res\WindmillDoc.ico" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
@@ -15,7 +15,7 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Test.h">
<ClInclude Include="Windmill.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="framework.h">
@@ -27,10 +27,10 @@
<ClInclude Include="MainFrm.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="TestDoc.h">
<ClInclude Include="WindmillDoc.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="TestView.h">
<ClInclude Include="WindmillView.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Resource.h">
@@ -41,16 +41,16 @@
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Test.cpp">
<ClCompile Include="Windmill.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MainFrm.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="TestDoc.cpp">
<ClCompile Include="WindmillDoc.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="TestView.cpp">
<ClCompile Include="WindmillView.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="pch.cpp">
@@ -58,20 +58,20 @@
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Test.rc">
<ResourceCompile Include="Windmill.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<None Include="res\Test.rc2">
<None Include="res\Windmill.rc2">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
<ItemGroup>
<Image Include="res\TestDoc.ico">
<Image Include="res\WindmillDoc.ico">
<Filter>Resource Files</Filter>
</Image>
<Image Include="res\Test.ico">
<Image Include="res\Windmill.ico">
<Filter>Resource Files</Filter>
</Image>
<Image Include="res\Toolbar.bmp">
@@ -1,4 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
<PropertyGroup>
<RESOURCE_FILE>Windmill.rc</RESOURCE_FILE>
</PropertyGroup>
</Project>
@@ -1,5 +1,5 @@
// TestDoc.cpp : implementation of the CTestDoc class
// WindmillDoc.cpp : implementation of the CWindmillDoc class
//
#include "pch.h"
@@ -7,10 +7,10 @@
// SHARED_HANDLERS can be defined in an ATL project implementing preview, thumbnail
// and search filter handlers and allows sharing of document code with that project.
#ifndef SHARED_HANDLERS
#include "Test.h"
#include "Windmill.h"
#endif
#include "TestDoc.h"
#include "WindmillDoc.h"
#include <propkey.h>
@@ -18,23 +18,28 @@
#define new DEBUG_NEW
#endif
// CTestDoc
// CWindmillDoc
IMPLEMENT_DYNCREATE(CTestDoc, CDocument)
IMPLEMENT_DYNCREATE(CWindmillDoc, CDocument)
BEGIN_MESSAGE_MAP(CTestDoc, CDocument)
BEGIN_MESSAGE_MAP(CWindmillDoc, CDocument)
END_MESSAGE_MAP()
// CTestDoc construction/destruction
CTestDoc::CTestDoc() noexcept {
// CWindmillDoc construction/destruction
CWindmillDoc::CWindmillDoc() noexcept
{
// TODO: add one-time construction code here
}
CTestDoc::~CTestDoc() {
CWindmillDoc::~CWindmillDoc()
{
}
BOOL CTestDoc::OnNewDocument() {
BOOL CWindmillDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
@@ -44,13 +49,19 @@ BOOL CTestDoc::OnNewDocument() {
return TRUE;
}
// CTestDoc serialization
void CTestDoc::Serialize(CArchive &ar) {
if (ar.IsStoring()) {
// CWindmillDoc serialization
void CWindmillDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
}
else {
else
{
// TODO: add loading code here
}
}
@@ -58,27 +69,29 @@ void CTestDoc::Serialize(CArchive &ar) {
#ifdef SHARED_HANDLERS
// Support for thumbnails
void CTestDoc::OnDrawThumbnail(CDC &dc, LPRECT lprcBounds) {
void CWindmillDoc::OnDrawThumbnail(CDC& dc, LPRECT lprcBounds)
{
// Modify this code to draw the document's data
dc.FillSolidRect(lprcBounds, RGB(255, 255, 255));
CString strText = _T("TODO: implement thumbnail drawing here");
LOGFONT lf;
CFont *pDefaultGUIFont = CFont::FromHandle((HFONT)GetStockObject(DEFAULT_GUI_FONT));
CFont* pDefaultGUIFont = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT));
pDefaultGUIFont->GetLogFont(&lf);
lf.lfHeight = 36;
CFont fontDraw;
fontDraw.CreateFontIndirect(&lf);
CFont *pOldFont = dc.SelectObject(&fontDraw);
CFont* pOldFont = dc.SelectObject(&fontDraw);
dc.DrawText(strText, lprcBounds, DT_CENTER | DT_WORDBREAK);
dc.SelectObject(pOldFont);
}
// Support for Search Handlers
void CTestDoc::InitializeSearchContent() {
void CWindmillDoc::InitializeSearchContent()
{
CString strSearchContent;
// Set search contents from document's data.
// The content parts should be separated by ";"
@@ -87,14 +100,18 @@ void CTestDoc::InitializeSearchContent() {
SetSearchContent(strSearchContent);
}
void CTestDoc::SetSearchContent(const CString &value) {
if (value.IsEmpty()) {
void CWindmillDoc::SetSearchContent(const CString& value)
{
if (value.IsEmpty())
{
RemoveChunk(PKEY_Search_Contents.fmtid, PKEY_Search_Contents.pid);
}
else {
else
{
CMFCFilterChunkValueImpl *pChunk = nullptr;
ATLTRY(pChunk = new CMFCFilterChunkValueImpl);
if (pChunk != nullptr) {
if (pChunk != nullptr)
{
pChunk->SetTextValue(PKEY_Search_Contents, value, CHUNK_TEXT);
SetChunkValue(pChunk);
}
@@ -103,16 +120,19 @@ void CTestDoc::SetSearchContent(const CString &value) {
#endif // SHARED_HANDLERS
// CTestDoc diagnostics
// CWindmillDoc diagnostics
#ifdef _DEBUG
void CTestDoc::AssertValid() const {
void CWindmillDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CTestDoc::Dump(CDumpContext &dc) const {
void CWindmillDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
// CTestDoc commands
// CWindmillDoc commands
+48
View File
@@ -0,0 +1,48 @@
// WindmillDoc.h : interface of the CWindmillDoc class
//
#pragma once
class CWindmillDoc : public CDocument
{
protected: // create from serialization only
CWindmillDoc() noexcept;
DECLARE_DYNCREATE(CWindmillDoc)
// Attributes
public:
// Operations
public:
// Overrides
public:
virtual BOOL OnNewDocument();
virtual void Serialize(CArchive& ar);
#ifdef SHARED_HANDLERS
virtual void InitializeSearchContent();
virtual void OnDrawThumbnail(CDC& dc, LPRECT lprcBounds);
#endif // SHARED_HANDLERS
// Implementation
public:
virtual ~CWindmillDoc();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
DECLARE_MESSAGE_MAP()
#ifdef SHARED_HANDLERS
// Helper function that sets search content for a Search Handler
void SetSearchContent(const CString& value);
#endif // SHARED_HANDLERS
};
+192
View File
@@ -0,0 +1,192 @@
// WindmillView.cpp : implementation of the CWindmillView class
//
#include "pch.h"
#include "framework.h"
// SHARED_HANDLERS can be defined in an ATL project implementing preview, thumbnail
// and search filter handlers and allows sharing of document code with that project.
#ifndef SHARED_HANDLERS
#include "Windmill.h"
#endif
#include "WindmillDoc.h"
#include "WindmillView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
#ifndef PI
#define PI 3.14159265358979323846
#endif
// CWindmillView
IMPLEMENT_DYNCREATE(CWindmillView, CView)
BEGIN_MESSAGE_MAP(CWindmillView, CView)
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CView::OnFilePrintPreview)
ON_WM_TIMER()
END_MESSAGE_MAP()
// CWindmillView construction/destruction
CWindmillView::CWindmillView() noexcept {
// TODO: add construction code here
m_nAngle = 0;
}
CWindmillView::~CWindmillView() {
}
BOOL CWindmillView::PreCreateWindow(CREATESTRUCT &cs) {
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
// CWindmillView drawing
void CWindmillView::OnDraw(CDC *pDC) {
CWindmillDoc *pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
// TODO: add draw code for native data here
// 设置定时器
SetTimer(1, 20, NULL);
// 获取客户端区域并设置坐标系
CRect rect;
GetClientRect(&rect);
pDC->SetMapMode(MM_ANISOTROPIC);
pDC->SetWindowExt(rect.Width(), rect.Height());
pDC->SetViewportExt(rect.Width(), -rect.Height());
pDC->SetViewportOrg(rect.Width() / 2, rect.Height() / 2);
// 定义画笔和画刷
CPen NewPen, *pOldPen;
CBrush NewBrush, *pOldBrush;
// 定义风车叶片和底座的参数
float fAngle = m_nAngle * PI / 180;
int R = 300, r = 50, h = 10;
int baseWidthTop = 100;
int baseWidthBottom = 300;
int baseHeight = 400;
int bias = 65;
POINT pt[4]{
{ -baseWidthTop / 2, h + bias },
{ baseWidthTop / 2, h + bias },
{ baseWidthBottom / 2, h + bias - baseHeight },
{ -baseWidthBottom / 2, h + bias - baseHeight }
};
// 绘制风车底座
NewPen.CreatePen(PS_SOLID, 1, RGB(109, 104, 106));
pOldPen = pDC->SelectObject(&NewPen);
NewBrush.CreateSolidBrush(RGB(109, 104, 106));
pOldBrush = pDC->SelectObject(&NewBrush);
pDC->Polygon(pt, 4);
pDC->SelectObject(pOldBrush);
NewBrush.DeleteObject();
pDC->SelectObject(pOldPen);
NewPen.DeleteObject();
// 绘制风车叶片(蓝色部分)
NewPen.CreatePen(PS_SOLID, 500, RGB(0, 82, 217));
pOldPen = pDC->SelectObject(&NewPen);
NewBrush.CreateSolidBrush(RGB(0, 82, 217));
pOldBrush = pDC->SelectObject(&NewBrush);
pDC->BeginPath();
pDC->MoveTo(0, h);
pDC->LineTo(R * cos(fAngle), R * sin(fAngle) + h);
pDC->LineTo(R * cos(fAngle) + r * sin(fAngle), R * sin(fAngle) + h - r * cos(fAngle));
pDC->LineTo(r * sqrt(2) * cos(fAngle - PI / 4), r * sqrt(2) * sin(fAngle - PI / 4) + h);
pDC->LineTo(r * cos(fAngle), r * sin(fAngle) + h);
pDC->MoveTo(0, h);
pDC->LineTo(R * cos(fAngle + PI), R * sin(fAngle + PI) + h);
pDC->LineTo(R * cos(fAngle + PI) + r * sin(fAngle + PI), R * sin(fAngle + PI) + h - r * cos(fAngle + PI));
pDC->LineTo(r * sqrt(2) * cos(fAngle + PI - PI / 4), r * sqrt(2) * sin(fAngle + PI - PI / 4) + h);
pDC->LineTo(r * cos(fAngle + PI), r * sin(fAngle + PI) + h);
pDC->EndPath();
pDC->FillPath();
pDC->SelectObject(pOldBrush);
NewBrush.DeleteObject();
pDC->SelectObject(pOldPen);
NewPen.DeleteObject();
// 绘制风车叶片(黄色部分)
NewPen.CreatePen(PS_SOLID, 500, RGB(236, 189, 101));
pOldPen = pDC->SelectObject(&NewPen);
NewBrush.CreateSolidBrush(RGB(236, 189, 101));
pOldBrush = pDC->SelectObject(&NewBrush);
pDC->BeginPath();
pDC->MoveTo(0, h);
pDC->LineTo(R * cos(fAngle + PI / 2), R * sin(fAngle + PI / 2) + h);
pDC->LineTo(R * cos(fAngle + PI / 2) + r * sin(fAngle + PI / 2), R * sin(fAngle + PI / 2) + h - r * cos(fAngle + PI / 2));
pDC->LineTo(r * sqrt(2) * cos(fAngle + PI / 2 - PI / 4), r * sqrt(2) * sin(fAngle + PI / 2 - PI / 4) + h);
pDC->LineTo(r * cos(fAngle + PI / 2), r * sin(fAngle + PI / 2) + h);
pDC->MoveTo(0, h);
pDC->LineTo(R * cos(fAngle - PI / 2), R * sin(fAngle - PI / 2) + h);
pDC->LineTo(R * cos(fAngle - PI / 2) + r * sin(fAngle - PI / 2), R * sin(fAngle - PI / 2) + h - r * cos(fAngle - PI / 2));
pDC->LineTo(r * sqrt(2) * cos(fAngle - PI / 2 - PI / 4), r * sqrt(2) * sin(fAngle - PI / 2 - PI / 4) + h);
pDC->LineTo(r * cos(fAngle - PI / 2), r * sin(fAngle - PI / 2) + h);
pDC->EndPath();
pDC->FillPath();
pDC->SelectObject(pOldBrush);
NewBrush.DeleteObject();
pDC->SelectObject(pOldPen);
NewPen.DeleteObject();
}
// CWindmillView printing
BOOL CWindmillView::OnPreparePrinting(CPrintInfo *pInfo) {
// default preparation
return DoPreparePrinting(pInfo);
}
void CWindmillView::OnBeginPrinting(CDC * /*pDC*/, CPrintInfo * /*pInfo*/) {
// TODO: add extra initialization before printing
}
void CWindmillView::OnEndPrinting(CDC * /*pDC*/, CPrintInfo * /*pInfo*/) {
// TODO: add cleanup after printing
}
// CWindmillView diagnostics
#ifdef _DEBUG
void CWindmillView::AssertValid() const {
CView::AssertValid();
}
void CWindmillView::Dump(CDumpContext &dc) const {
CView::Dump(dc);
}
CWindmillDoc *CWindmillView::GetDocument() const // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CWindmillDoc)));
return (CWindmillDoc *)m_pDocument;
}
#endif //_DEBUG
// CWindmillView message handlers
void CWindmillView::OnTimer(UINT_PTR nIDEvent) {
// TODO: Add your message handler code here and/or call default
m_nAngle += 5;
if (m_nAngle >= 360)
m_nAngle = 0;
Invalidate();
CView::OnTimer(nIDEvent);
}
+54
View File
@@ -0,0 +1,54 @@
// WindmillView.h : interface of the CWindmillView class
//
#pragma once
class CWindmillView : public CView
{
protected: // create from serialization only
CWindmillView() noexcept;
DECLARE_DYNCREATE(CWindmillView)
// Attributes
public:
CWindmillDoc* GetDocument() const;
// Operations
public:
// Overrides
public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
// Implementation
public:
virtual ~CWindmillView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnTimer(UINT_PTR nIDEvent);
private:
int m_nAngle;
};
#ifndef _DEBUG // debug version in WindmillView.cpp
inline CWindmillDoc* CWindmillView::GetDocument() const
{ return reinterpret_cast<CWindmillDoc*>(m_pDocument); }
#endif
+49
View File
@@ -0,0 +1,49 @@
#pragma once
#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif
#include "targetver.h"
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
// turns off MFC's hiding of some common and often safely ignored warning messages
#define _AFX_ALL_WARNINGS
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation classes
#ifndef _AFX_NO_OLE_SUPPORT
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#endif
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <afxcontrolbars.h> // MFC support for ribbons and control bars
#ifdef _UNICODE
#if defined _M_IX86
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_X64
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#else
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#endif
#endif
File renamed without changes.
+1 -1
View File
@@ -10,4 +10,4 @@
// add headers that you want to pre-compile here
#include "framework.h"
#endif // PCH_H
#endif //PCH_H
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.