Create StraightLine
This commit is contained in:
1 parent
3f0d741b27
commit
5c0d6acba1
26 files changed
+1370
No files matched your search
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Visual Studio: Start Debugging",
|
||||
"type": "cppvsdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}\\x64\\Debug\\${workspaceFolderBasename}.exe",
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceFolder}",
|
||||
"console": "integratedTerminal",
|
||||
"preLaunchTask": "Visual Studio: Build Solution",
|
||||
"internalConsoleOptions": "neverOpen"
|
||||
}
|
||||
],
|
||||
"version": "0.2.0"
|
||||
}
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"git.openRepositoryInParentFolders": "never"
|
||||
}
|
||||
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"tasks": [
|
||||
{
|
||||
"type": "shell",
|
||||
"label": "Visual Studio: Build Solution",
|
||||
"command": "msbuild",
|
||||
"args": [
|
||||
"${workspaceFolder}\\${workspaceFolderBasename}.sln",
|
||||
"/p:Configuration=Debug",
|
||||
"/p:Platform=x64"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
"problemMatcher": [
|
||||
"$msCompile"
|
||||
],
|
||||
"group": "build",
|
||||
"detail": "Task generated by Debugger."
|
||||
}
|
||||
],
|
||||
"version": "2.0.0"
|
||||
}
|
||||
@@ -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}") = "StraightLine", "StraightLine\StraightLine.vcxproj", "{FDAC309B-67DC-4CD1-A242-9E04425745D1}"
|
||||
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
|
||||
{FDAC309B-67DC-4CD1-A242-9E04425745D1}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{FDAC309B-67DC-4CD1-A242-9E04425745D1}.Debug|x64.Build.0 = Debug|x64
|
||||
{FDAC309B-67DC-4CD1-A242-9E04425745D1}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{FDAC309B-67DC-4CD1-A242-9E04425745D1}.Debug|x86.Build.0 = Debug|Win32
|
||||
{FDAC309B-67DC-4CD1-A242-9E04425745D1}.Release|x64.ActiveCfg = Release|x64
|
||||
{FDAC309B-67DC-4CD1-A242-9E04425745D1}.Release|x64.Build.0 = Release|x64
|
||||
{FDAC309B-67DC-4CD1-A242-9E04425745D1}.Release|x86.ActiveCfg = Release|Win32
|
||||
{FDAC309B-67DC-4CD1-A242-9E04425745D1}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {6641C81C-B090-4E08-B982-7F2D4543AC69}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,96 @@
|
||||
|
||||
// MainFrm.cpp : implementation of the CMainFrame class
|
||||
//
|
||||
|
||||
#include "pch.h"
|
||||
#include "framework.h"
|
||||
#include "StraightLine.h"
|
||||
|
||||
#include "MainFrm.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
// CMainFrame
|
||||
|
||||
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
|
||||
|
||||
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
|
||||
ON_WM_CREATE()
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
static UINT indicators[] =
|
||||
{
|
||||
ID_SEPARATOR, // status line indicator
|
||||
ID_INDICATOR_CAPS,
|
||||
ID_INDICATOR_NUM,
|
||||
ID_INDICATOR_SCRL,
|
||||
};
|
||||
|
||||
// CMainFrame construction/destruction
|
||||
|
||||
CMainFrame::CMainFrame() noexcept
|
||||
{
|
||||
// TODO: add member initialization code here
|
||||
}
|
||||
|
||||
CMainFrame::~CMainFrame()
|
||||
{
|
||||
}
|
||||
|
||||
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))
|
||||
{
|
||||
TRACE0("Failed to create toolbar\n");
|
||||
return -1; // fail to create
|
||||
}
|
||||
|
||||
if (!m_wndStatusBar.Create(this))
|
||||
{
|
||||
TRACE0("Failed to create status bar\n");
|
||||
return -1; // fail to create
|
||||
}
|
||||
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) )
|
||||
return FALSE;
|
||||
// TODO: Modify the Window class or styles here by modifying
|
||||
// the CREATESTRUCT cs
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// CMainFrame diagnostics
|
||||
|
||||
#ifdef _DEBUG
|
||||
void CMainFrame::AssertValid() const
|
||||
{
|
||||
CFrameWnd::AssertValid();
|
||||
}
|
||||
|
||||
void CMainFrame::Dump(CDumpContext& dc) const
|
||||
{
|
||||
CFrameWnd::Dump(dc);
|
||||
}
|
||||
#endif //_DEBUG
|
||||
|
||||
|
||||
// CMainFrame message handlers
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
|
||||
// MainFrm.h : interface of the CMainFrame class
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
class CMainFrame : public CFrameWnd
|
||||
{
|
||||
|
||||
protected: // create from serialization only
|
||||
CMainFrame() noexcept;
|
||||
DECLARE_DYNCREATE(CMainFrame)
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
|
||||
// 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;
|
||||
#endif
|
||||
|
||||
protected: // control bar embedded members
|
||||
CToolBar m_wndToolBar;
|
||||
CStatusBar m_wndStatusBar;
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by StraightLine.rc
|
||||
//
|
||||
#define IDD_ABOUTBOX 100
|
||||
#define IDP_OLE_INIT_FAILED 100
|
||||
#define IDR_MAINFRAME 128
|
||||
#define IDR_StraightLineTYPE 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.
@@ -0,0 +1,184 @@
|
||||
|
||||
// StraightLine.cpp : Defines the class behaviors for the application.
|
||||
//
|
||||
|
||||
#include "pch.h"
|
||||
#include "framework.h"
|
||||
#include "afxwinappex.h"
|
||||
#include "afxdialogex.h"
|
||||
#include "StraightLine.h"
|
||||
#include "MainFrm.h"
|
||||
|
||||
#include "StraightLineDoc.h"
|
||||
#include "StraightLineView.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
|
||||
// CStraightLineApp
|
||||
|
||||
BEGIN_MESSAGE_MAP(CStraightLineApp, CWinApp)
|
||||
ON_COMMAND(ID_APP_ABOUT, &CStraightLineApp::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()
|
||||
|
||||
|
||||
// CStraightLineApp construction
|
||||
|
||||
CStraightLineApp::CStraightLineApp() noexcept
|
||||
{
|
||||
|
||||
// support Restart Manager
|
||||
m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_ALL_ASPECTS;
|
||||
#ifdef _MANAGED
|
||||
// If the application is built using Common Language Runtime support (/clr):
|
||||
// 1) This additional setting is needed for Restart Manager support to work properly.
|
||||
// 2) In your project, you must add a reference to System.Windows.Forms in order to build.
|
||||
System::Windows::Forms::Application::SetUnhandledExceptionMode(System::Windows::Forms::UnhandledExceptionMode::ThrowException);
|
||||
#endif
|
||||
|
||||
// TODO: replace application ID string below with unique ID string; recommended
|
||||
// format for string is CompanyName.ProductName.SubProduct.VersionInformation
|
||||
SetAppID(_T("StraightLine.AppID.NoVersion"));
|
||||
|
||||
// TODO: add construction code here,
|
||||
// Place all significant initialization in InitInstance
|
||||
}
|
||||
|
||||
// The one and only CStraightLineApp object
|
||||
|
||||
CStraightLineApp theApp;
|
||||
|
||||
|
||||
// CStraightLineApp initialization
|
||||
|
||||
BOOL CStraightLineApp::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.
|
||||
INITCOMMONCONTROLSEX InitCtrls;
|
||||
InitCtrls.dwSize = sizeof(InitCtrls);
|
||||
// Set this to include all the common control classes you want to use
|
||||
// in your application.
|
||||
InitCtrls.dwICC = ICC_WIN95_CLASSES;
|
||||
InitCommonControlsEx(&InitCtrls);
|
||||
|
||||
CWinApp::InitInstance();
|
||||
|
||||
|
||||
// Initialize OLE libraries
|
||||
if (!AfxOleInit())
|
||||
{
|
||||
AfxMessageBox(IDP_OLE_INIT_FAILED);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
AfxEnableControlContainer();
|
||||
|
||||
EnableTaskbarInteraction(FALSE);
|
||||
|
||||
// AfxInitRichEdit2() is required to use RichEdit control
|
||||
// AfxInitRichEdit2();
|
||||
|
||||
// Standard initialization
|
||||
// If you are not using these features and wish to reduce the size
|
||||
// of your final executable, you should remove from the following
|
||||
// the specific initialization routines you do not need
|
||||
// Change the registry key under which our settings are stored
|
||||
// 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)
|
||||
|
||||
|
||||
// Register the application's document templates. Document templates
|
||||
// serve as the connection between documents, frame windows and views
|
||||
CSingleDocTemplate* pDocTemplate;
|
||||
pDocTemplate = new CSingleDocTemplate(
|
||||
IDR_MAINFRAME,
|
||||
RUNTIME_CLASS(CStraightLineDoc),
|
||||
RUNTIME_CLASS(CMainFrame), // main SDI frame window
|
||||
RUNTIME_CLASS(CStraightLineView));
|
||||
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))
|
||||
return FALSE;
|
||||
|
||||
// The one and only window has been initialized, so show and update it
|
||||
m_pMainWnd->ShowWindow(SW_SHOW);
|
||||
m_pMainWnd->UpdateWindow();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int CStraightLineApp::ExitInstance()
|
||||
{
|
||||
//TODO: handle additional resources you may have added
|
||||
AfxOleTerm(FALSE);
|
||||
|
||||
return CWinApp::ExitInstance();
|
||||
}
|
||||
|
||||
// CStraightLineApp message handlers
|
||||
|
||||
|
||||
// CAboutDlg dialog used for App About
|
||||
|
||||
class CAboutDlg : public CDialogEx
|
||||
{
|
||||
public:
|
||||
CAboutDlg() noexcept;
|
||||
|
||||
// Dialog Data
|
||||
#ifdef AFX_DESIGN_TIME
|
||||
enum { IDD = IDD_ABOUTBOX };
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
CAboutDlg::CAboutDlg() noexcept : CDialogEx(IDD_ABOUTBOX)
|
||||
{
|
||||
}
|
||||
|
||||
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialogEx::DoDataExchange(pDX);
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
// App command to run the dialog
|
||||
void CStraightLineApp::OnAppAbout()
|
||||
{
|
||||
CAboutDlg aboutDlg;
|
||||
aboutDlg.DoModal();
|
||||
}
|
||||
|
||||
// CStraightLineApp message handlers
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
|
||||
// StraightLine.h : main header file for the StraightLine application
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#ifndef __AFXWIN_H__
|
||||
#error "include 'pch.h' before including this file for PCH"
|
||||
#endif
|
||||
|
||||
#include "resource.h" // main symbols
|
||||
|
||||
|
||||
// CStraightLineApp:
|
||||
// See StraightLine.cpp for the implementation of this class
|
||||
//
|
||||
|
||||
class CStraightLineApp : public CWinApp
|
||||
{
|
||||
public:
|
||||
CStraightLineApp() noexcept;
|
||||
|
||||
|
||||
// Overrides
|
||||
public:
|
||||
virtual BOOL InitInstance();
|
||||
virtual int ExitInstance();
|
||||
|
||||
// Implementation
|
||||
afx_msg void OnAppAbout();
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
extern CStraightLineApp theApp;
|
||||
Binary file not shown.
@@ -0,0 +1,221 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>17.0</VCProjectVersion>
|
||||
<ProjectGuid>{FDAC309B-67DC-4CD1-A242-9E04425745D1}</ProjectGuid>
|
||||
<Keyword>MFCProj</Keyword>
|
||||
<RootNamespace>StraightLine</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<UseOfMfc>Dynamic</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<UseOfMfc>Dynamic</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<UseOfMfc>Dynamic</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<UseOfMfc>Dynamic</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
</Link>
|
||||
<Midl>
|
||||
<MkTypLibCompatible>false</MkTypLibCompatible>
|
||||
<ValidateAllParameters>true</ValidateAllParameters>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</Midl>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0409</Culture>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ResourceCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
</Link>
|
||||
<Midl>
|
||||
<MkTypLibCompatible>false</MkTypLibCompatible>
|
||||
<ValidateAllParameters>true</ValidateAllParameters>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</Midl>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0409</Culture>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ResourceCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
<Midl>
|
||||
<MkTypLibCompatible>false</MkTypLibCompatible>
|
||||
<ValidateAllParameters>true</ValidateAllParameters>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</Midl>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0409</Culture>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ResourceCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
<Midl>
|
||||
<MkTypLibCompatible>false</MkTypLibCompatible>
|
||||
<ValidateAllParameters>true</ValidateAllParameters>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</Midl>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0409</Culture>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ResourceCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="framework.h" />
|
||||
<ClInclude Include="MainFrm.h" />
|
||||
<ClInclude Include="pch.h" />
|
||||
<ClInclude Include="Resource.h" />
|
||||
<ClInclude Include="StraightLine.h" />
|
||||
<ClInclude Include="StraightLineDoc.h" />
|
||||
<ClInclude Include="StraightLineView.h" />
|
||||
<ClInclude Include="targetver.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="MainFrm.cpp" />
|
||||
<ClCompile Include="pch.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="StraightLine.cpp" />
|
||||
<ClCompile Include="StraightLineDoc.cpp" />
|
||||
<ClCompile Include="StraightLineView.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="StraightLine.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="res\StraightLine.rc2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="res\StraightLine.ico" />
|
||||
<Image Include="res\StraightLineDoc.ico" />
|
||||
<Image Include="res\Toolbar.bmp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,81 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="StraightLine.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="framework.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="targetver.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="MainFrm.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="StraightLineDoc.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="StraightLineView.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Resource.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="pch.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="StraightLine.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MainFrm.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="StraightLineDoc.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="StraightLineView.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="pch.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="StraightLine.rc">
|
||||
<Filter>Resource Files</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="res\StraightLine.rc2">
|
||||
<Filter>Resource Files</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="res\StraightLineDoc.ico">
|
||||
<Filter>Resource Files</Filter>
|
||||
</Image>
|
||||
<Image Include="res\StraightLine.ico">
|
||||
<Filter>Resource Files</Filter>
|
||||
</Image>
|
||||
<Image Include="res\Toolbar.bmp">
|
||||
<Filter>Resource Files</Filter>
|
||||
</Image>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<RESOURCE_FILE>StraightLine.rc</RESOURCE_FILE>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,138 @@
|
||||
|
||||
// StraightLineDoc.cpp : implementation of the CStraightLineDoc 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 "StraightLine.h"
|
||||
#endif
|
||||
|
||||
#include "StraightLineDoc.h"
|
||||
|
||||
#include <propkey.h>
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
// CStraightLineDoc
|
||||
|
||||
IMPLEMENT_DYNCREATE(CStraightLineDoc, CDocument)
|
||||
|
||||
BEGIN_MESSAGE_MAP(CStraightLineDoc, CDocument)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
// CStraightLineDoc construction/destruction
|
||||
|
||||
CStraightLineDoc::CStraightLineDoc() noexcept
|
||||
{
|
||||
// TODO: add one-time construction code here
|
||||
|
||||
}
|
||||
|
||||
CStraightLineDoc::~CStraightLineDoc()
|
||||
{
|
||||
}
|
||||
|
||||
BOOL CStraightLineDoc::OnNewDocument()
|
||||
{
|
||||
if (!CDocument::OnNewDocument())
|
||||
return FALSE;
|
||||
|
||||
// TODO: add reinitialization code here
|
||||
// (SDI documents will reuse this document)
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// CStraightLineDoc serialization
|
||||
|
||||
void CStraightLineDoc::Serialize(CArchive& ar)
|
||||
{
|
||||
if (ar.IsStoring())
|
||||
{
|
||||
// TODO: add storing code here
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: add loading code here
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SHARED_HANDLERS
|
||||
|
||||
// Support for thumbnails
|
||||
void CStraightLineDoc::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));
|
||||
pDefaultGUIFont->GetLogFont(&lf);
|
||||
lf.lfHeight = 36;
|
||||
|
||||
CFont fontDraw;
|
||||
fontDraw.CreateFontIndirect(&lf);
|
||||
|
||||
CFont* pOldFont = dc.SelectObject(&fontDraw);
|
||||
dc.DrawText(strText, lprcBounds, DT_CENTER | DT_WORDBREAK);
|
||||
dc.SelectObject(pOldFont);
|
||||
}
|
||||
|
||||
// Support for Search Handlers
|
||||
void CStraightLineDoc::InitializeSearchContent()
|
||||
{
|
||||
CString strSearchContent;
|
||||
// Set search contents from document's data.
|
||||
// The content parts should be separated by ";"
|
||||
|
||||
// For example: strSearchContent = _T("point;rectangle;circle;ole object;");
|
||||
SetSearchContent(strSearchContent);
|
||||
}
|
||||
|
||||
void CStraightLineDoc::SetSearchContent(const CString& value)
|
||||
{
|
||||
if (value.IsEmpty())
|
||||
{
|
||||
RemoveChunk(PKEY_Search_Contents.fmtid, PKEY_Search_Contents.pid);
|
||||
}
|
||||
else
|
||||
{
|
||||
CMFCFilterChunkValueImpl *pChunk = nullptr;
|
||||
ATLTRY(pChunk = new CMFCFilterChunkValueImpl);
|
||||
if (pChunk != nullptr)
|
||||
{
|
||||
pChunk->SetTextValue(PKEY_Search_Contents, value, CHUNK_TEXT);
|
||||
SetChunkValue(pChunk);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // SHARED_HANDLERS
|
||||
|
||||
// CStraightLineDoc diagnostics
|
||||
|
||||
#ifdef _DEBUG
|
||||
void CStraightLineDoc::AssertValid() const
|
||||
{
|
||||
CDocument::AssertValid();
|
||||
}
|
||||
|
||||
void CStraightLineDoc::Dump(CDumpContext& dc) const
|
||||
{
|
||||
CDocument::Dump(dc);
|
||||
}
|
||||
#endif //_DEBUG
|
||||
|
||||
|
||||
// CStraightLineDoc commands
|
||||
@@ -0,0 +1,48 @@
|
||||
|
||||
// StraightLineDoc.h : interface of the CStraightLineDoc class
|
||||
//
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
class CStraightLineDoc : public CDocument
|
||||
{
|
||||
protected: // create from serialization only
|
||||
CStraightLineDoc() noexcept;
|
||||
DECLARE_DYNCREATE(CStraightLineDoc)
|
||||
|
||||
// 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 ~CStraightLineDoc();
|
||||
#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
|
||||
};
|
||||
@@ -0,0 +1,299 @@
|
||||
|
||||
// StraightLineView.cpp : implementation of the CStraightLineView 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 "StraightLine.h"
|
||||
#endif
|
||||
|
||||
#include "StraightLineDoc.h"
|
||||
#include "StraightLineView.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
// CStraightLineView
|
||||
|
||||
IMPLEMENT_DYNCREATE(CStraightLineView, CView)
|
||||
|
||||
BEGIN_MESSAGE_MAP(CStraightLineView, 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_LBUTTONDOWN()
|
||||
ON_WM_MOUSEMOVE()
|
||||
ON_WM_LBUTTONUP()
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
// CStraightLineView construction/destruction
|
||||
|
||||
CStraightLineView::CStraightLineView() noexcept {
|
||||
// TODO: add construction code here
|
||||
m_bDraw = FALSE;
|
||||
}
|
||||
|
||||
CStraightLineView::~CStraightLineView() {
|
||||
}
|
||||
|
||||
BOOL CStraightLineView::PreCreateWindow(CREATESTRUCT &cs) {
|
||||
// TODO: Modify the Window class or styles here by modifying
|
||||
// the CREATESTRUCT cs
|
||||
|
||||
return CView::PreCreateWindow(cs);
|
||||
}
|
||||
|
||||
// CStraightLineView drawing
|
||||
|
||||
void CStraightLineView::OnDraw(CDC *pDC) {
|
||||
CStraightLineDoc *pDoc = GetDocument();
|
||||
ASSERT_VALID(pDoc);
|
||||
if (!pDoc)
|
||||
return;
|
||||
|
||||
// 获取客户端矩形区域
|
||||
GetClientRect(&m_rect);
|
||||
|
||||
// 创建内存设备上下文和兼容位图
|
||||
CDC memDC;
|
||||
memDC.CreateCompatibleDC(pDC);
|
||||
CBitmap NewBitmap, *pOldBitmap;
|
||||
NewBitmap.CreateCompatibleBitmap(pDC, m_rect.Width(), m_rect.Height());
|
||||
pOldBitmap = memDC.SelectObject(&NewBitmap);
|
||||
|
||||
// 设置内存设备上下文的映射模式和视口
|
||||
memDC.SetMapMode(MM_ANISOTROPIC);
|
||||
memDC.SetWindowExt(m_rect.Width(), m_rect.Height());
|
||||
memDC.SetViewportExt(m_rect.Width(), -m_rect.Height());
|
||||
memDC.SetViewportOrg(m_rect.Width() / 2, m_rect.Height() / 2);
|
||||
m_rect.OffsetRect(-m_rect.Width() / 2, -m_rect.Height() / 2);
|
||||
|
||||
// 填充背景颜色并绘制坐标轴
|
||||
memDC.FillSolidRect(&m_rect, RGB(255, 255, 255));
|
||||
memDC.MoveTo(-m_rect.Width() / 2, 0);
|
||||
memDC.LineTo(m_rect.Width() / 2, 0);
|
||||
memDC.LineTo(m_rect.Width() / 2 - 10, -5);
|
||||
memDC.MoveTo(m_rect.Width() / 2, 0);
|
||||
memDC.LineTo(m_rect.Width() / 2 - 10, 5);
|
||||
memDC.MoveTo(0, -m_rect.Height() / 2);
|
||||
memDC.LineTo(0, m_rect.Height() / 2);
|
||||
memDC.LineTo(-5, m_rect.Height() / 2 - 10);
|
||||
memDC.MoveTo(0, m_rect.Height() / 2);
|
||||
memDC.LineTo(5, m_rect.Height() / 2 - 10);
|
||||
|
||||
// 绘制坐标轴标签
|
||||
memDC.TextOutW(10, 25, _T("O"));
|
||||
memDC.TextOutW(m_rect.Width() / 2 - 10, 25, _T("x"));
|
||||
memDC.TextOutW(10, m_rect.Height() / 2, _T("y"));
|
||||
|
||||
// 调用Bresenham算法绘制直线
|
||||
BresenhamLine(&memDC);
|
||||
|
||||
// 再次获取客户端矩形区域并设置设备上下文的映射模式和视口
|
||||
pDC->SetMapMode(MM_ANISOTROPIC);
|
||||
pDC->SetWindowExt(m_rect.Width(), m_rect.Height());
|
||||
pDC->SetViewportExt(m_rect.Width(), -m_rect.Height());
|
||||
pDC->SetViewportOrg(m_rect.Width() / 2, m_rect.Height() / 2);
|
||||
|
||||
// 将内存设备上下文中的位图拷贝到设备上下文中
|
||||
pDC->BitBlt(-m_rect.Width() / 2, -m_rect.Height() / 2, m_rect.Width(), m_rect.Height(), &memDC, -m_rect.Width() / 2, -m_rect.Height() / 2, SRCCOPY);
|
||||
|
||||
// 恢复旧位图并删除对象
|
||||
memDC.SelectObject(pOldBitmap);
|
||||
NewBitmap.DeleteObject();
|
||||
memDC.DeleteDC();
|
||||
}
|
||||
|
||||
// CStraightLineView printing
|
||||
|
||||
BOOL CStraightLineView::OnPreparePrinting(CPrintInfo *pInfo) {
|
||||
// default preparation
|
||||
return DoPreparePrinting(pInfo);
|
||||
}
|
||||
|
||||
void CStraightLineView::OnBeginPrinting(CDC * /*pDC*/, CPrintInfo * /*pInfo*/) {
|
||||
// TODO: add extra initialization before printing
|
||||
}
|
||||
|
||||
void CStraightLineView::OnEndPrinting(CDC * /*pDC*/, CPrintInfo * /*pInfo*/) {
|
||||
// TODO: add cleanup after printing
|
||||
}
|
||||
|
||||
// CStraightLineView diagnostics
|
||||
|
||||
#ifdef _DEBUG
|
||||
void CStraightLineView::AssertValid() const {
|
||||
CView::AssertValid();
|
||||
}
|
||||
|
||||
void CStraightLineView::Dump(CDumpContext &dc) const {
|
||||
CView::Dump(dc);
|
||||
}
|
||||
|
||||
CStraightLineDoc *CStraightLineView::GetDocument() const // non-debug version is inline
|
||||
{
|
||||
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CStraightLineDoc)));
|
||||
return (CStraightLineDoc *)m_pDocument;
|
||||
}
|
||||
#endif //_DEBUG
|
||||
|
||||
// CStraightLineView message handlers
|
||||
|
||||
void CStraightLineView::BresenhamLine(CDC *pDC) {
|
||||
// 定义起始颜色和结束颜色
|
||||
COLORREF startColor = RGB(0, 82, 217);
|
||||
COLORREF endColor = RGB(236, 189, 101);
|
||||
|
||||
// 获取起点和终点坐标
|
||||
CPoint ptOrigin = m_ptOrigin, ptEnd = m_ptEnd, ptTemp;
|
||||
LONG dx = ptEnd.x - ptOrigin.x, dy = ptEnd.y - ptOrigin.y;
|
||||
int totalSteps = max(abs(dx), abs(dy));
|
||||
|
||||
// 定义颜色插值函数
|
||||
auto interpolateColor = [](COLORREF start, COLORREF end, double factor) -> COLORREF {
|
||||
BYTE r = static_cast<BYTE>(GetRValue(start) + factor * (GetRValue(end) - GetRValue(start)));
|
||||
BYTE g = static_cast<BYTE>(GetGValue(start) + factor * (GetGValue(end) - GetGValue(start)));
|
||||
BYTE b = static_cast<BYTE>(GetBValue(start) + factor * (GetBValue(end) - GetBValue(start)));
|
||||
return RGB(r, g, b);
|
||||
};
|
||||
|
||||
// 处理垂直线的情况
|
||||
if (ptOrigin.x == ptEnd.x) {
|
||||
if (ptOrigin.y > ptEnd.y) {
|
||||
ptTemp = ptOrigin;
|
||||
ptOrigin = ptEnd;
|
||||
ptEnd = ptTemp;
|
||||
}
|
||||
for (int y = ptOrigin.y; y <= ptEnd.y; y++) {
|
||||
double factor = (double)(y - ptOrigin.y) / totalSteps;
|
||||
COLORREF color = interpolateColor(startColor, endColor, factor);
|
||||
pDC->SetPixel(ptOrigin.x, y, color);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// 计算斜率
|
||||
DOUBLE k = (DOUBLE)dy / dx;
|
||||
DOUBLE d;
|
||||
|
||||
// 处理斜率在[0, 1]之间的情况
|
||||
if (k >= 0 && k <= 1) {
|
||||
d = 0.5 - k;
|
||||
if (ptOrigin.x > ptEnd.x) {
|
||||
ptTemp = ptOrigin;
|
||||
ptOrigin = ptEnd;
|
||||
ptEnd = ptTemp;
|
||||
}
|
||||
for (ptTemp = ptOrigin; ptTemp.x <= ptEnd.x; ptTemp.x++) {
|
||||
double factor = (double)(ptTemp.x - ptOrigin.x) / totalSteps;
|
||||
COLORREF color = interpolateColor(startColor, endColor, factor);
|
||||
pDC->SetPixel(ptTemp.x, ptTemp.y, color);
|
||||
if (d < 0) {
|
||||
d += 1 - k;
|
||||
ptTemp.y++;
|
||||
}
|
||||
else {
|
||||
d -= k;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 处理斜率大于1的情况
|
||||
else if (k > 1) {
|
||||
d = 0.5 - 1 / k;
|
||||
if (ptOrigin.y > ptEnd.y) {
|
||||
ptTemp = ptOrigin;
|
||||
ptOrigin = ptEnd;
|
||||
ptEnd = ptTemp;
|
||||
}
|
||||
for (ptTemp = ptOrigin; ptTemp.y <= ptEnd.y; ptTemp.y++) {
|
||||
double factor = (double)(ptTemp.y - ptOrigin.y) / totalSteps;
|
||||
COLORREF color = interpolateColor(startColor, endColor, factor);
|
||||
pDC->SetPixel(ptTemp.x, ptTemp.y, color);
|
||||
if (d < 0) {
|
||||
d += 1 - 1 / k;
|
||||
ptTemp.x++;
|
||||
}
|
||||
else {
|
||||
d -= 1 / k;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 处理斜率在[-1, 0]之间的情况
|
||||
else if (k < 0 && k >= -1) {
|
||||
d = 0.5 + k;
|
||||
if (ptOrigin.x > ptEnd.x) {
|
||||
ptTemp = ptOrigin;
|
||||
ptOrigin = ptEnd;
|
||||
ptEnd = ptTemp;
|
||||
}
|
||||
for (ptTemp = ptOrigin; ptTemp.x <= ptEnd.x; ptTemp.x++) {
|
||||
double factor = (double)(ptTemp.x - ptOrigin.x) / totalSteps;
|
||||
COLORREF color = interpolateColor(startColor, endColor, factor);
|
||||
pDC->SetPixel(ptTemp.x, ptTemp.y, color);
|
||||
if (d < 0) {
|
||||
d += 1 + k;
|
||||
ptTemp.y--;
|
||||
}
|
||||
else {
|
||||
d += k;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 处理斜率小于-1的情况
|
||||
else {
|
||||
d = 0.5 + 1 / k;
|
||||
if (ptOrigin.y < ptEnd.y) {
|
||||
ptTemp = ptOrigin;
|
||||
ptOrigin = ptEnd;
|
||||
ptEnd = ptTemp;
|
||||
}
|
||||
for (ptTemp = ptOrigin; ptTemp.y >= ptEnd.y; ptTemp.y--) {
|
||||
double factor = (double)(ptOrigin.y - ptTemp.y) / totalSteps;
|
||||
COLORREF color = interpolateColor(startColor, endColor, factor);
|
||||
pDC->SetPixel(ptTemp.x, ptTemp.y, color);
|
||||
if (d < 0) {
|
||||
d += 1 + 1 / k;
|
||||
ptTemp.x++;
|
||||
}
|
||||
else {
|
||||
d += 1 / k;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CStraightLineView::OnLButtonDown(UINT nFlags, CPoint point) {
|
||||
// 记录起点坐标并转换为视图坐标系
|
||||
m_ptOrigin = CPoint(point.x - m_rect.Width() / 2, m_rect.Height() / 2 - point.y);
|
||||
// 设置绘制标志为真
|
||||
m_bDraw = TRUE;
|
||||
|
||||
CView::OnLButtonDown(nFlags, point);
|
||||
}
|
||||
|
||||
void CStraightLineView::OnMouseMove(UINT nFlags, CPoint point) {
|
||||
// 如果正在绘制,更新终点坐标并转换为视图坐标系
|
||||
if (m_bDraw) {
|
||||
m_ptEnd = CPoint(point.x - m_rect.Width() / 2, m_rect.Height() / 2 - point.y);
|
||||
// 使视图无效以触发重绘
|
||||
Invalidate(FALSE);
|
||||
}
|
||||
|
||||
CView::OnMouseMove(nFlags, point);
|
||||
}
|
||||
|
||||
void CStraightLineView::OnLButtonUp(UINT nFlags, CPoint point) {
|
||||
// 设置绘制标志为假
|
||||
m_bDraw = FALSE;
|
||||
// 更新终点坐标并转换为视图坐标系
|
||||
m_ptEnd = CPoint(point.x - m_rect.Width() / 2, m_rect.Height() / 2 - point.y);
|
||||
// 使视图无效以触发重绘
|
||||
Invalidate(FALSE);
|
||||
|
||||
CView::OnLButtonUp(nFlags, point);
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
|
||||
// StraightLineView.h : interface of the CStraightLineView class
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
class CStraightLineView : public CView {
|
||||
protected: // create from serialization only
|
||||
CStraightLineView() noexcept;
|
||||
DECLARE_DYNCREATE(CStraightLineView)
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
CStraightLineDoc *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 ~CStraightLineView();
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext &dc) const;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
// Generated message map functions
|
||||
protected:
|
||||
DECLARE_MESSAGE_MAP()
|
||||
private:
|
||||
void BresenhamLine(CDC *pDC);
|
||||
CRect m_rect;
|
||||
CPoint m_ptOrigin, m_ptEnd;
|
||||
BOOL m_bDraw;
|
||||
|
||||
public:
|
||||
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
|
||||
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
|
||||
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
|
||||
};
|
||||
|
||||
#ifndef _DEBUG // debug version in StraightLineView.cpp
|
||||
inline CStraightLineDoc *CStraightLineView::GetDocument() const { return reinterpret_cast<CStraightLineDoc *>(m_pDocument); }
|
||||
#endif
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
// pch.cpp: source file corresponding to the pre-compiled header
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
// When you are using pre-compiled headers, this source file is necessary for compilation to succeed.
|
||||
@@ -0,0 +1,13 @@
|
||||
// pch.h: This is a precompiled header file.
|
||||
// Files listed below are compiled only once, improving build performance for future builds.
|
||||
// This also affects IntelliSense performance, including code completion and many code browsing features.
|
||||
// However, files listed here are ALL re-compiled if any one of them is updated between builds.
|
||||
// Do not add files here that you will be updating frequently as this negates the performance advantage.
|
||||
|
||||
#ifndef PCH_H
|
||||
#define PCH_H
|
||||
|
||||
// add headers that you want to pre-compile here
|
||||
#include "framework.h"
|
||||
|
||||
#endif //PCH_H
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 66 KiB |
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 4.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
// Including SDKDDKVer.h defines the highest available Windows platform.
|
||||
|
||||
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
|
||||
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
|
||||
|
||||
#include <SDKDDKVer.h>
|
||||
Reference in new issue
Block a user