添加项目文件。
107
CSMQTT/CSMQTT.cpp
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
|
||||||
|
// CSMQTT.cpp: 定义应用程序的类行为。
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "pch.h"
|
||||||
|
#include "framework.h"
|
||||||
|
#include "CSMQTT.h"
|
||||||
|
#include "CSMQTTDlg.h"
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
#define new DEBUG_NEW
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// CCSMQTTApp
|
||||||
|
|
||||||
|
BEGIN_MESSAGE_MAP(CCSMQTTApp, CWinApp)
|
||||||
|
ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
|
||||||
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
|
|
||||||
|
// CCSMQTTApp 构造
|
||||||
|
|
||||||
|
CCSMQTTApp::CCSMQTTApp()
|
||||||
|
{
|
||||||
|
// 支持重新启动管理器
|
||||||
|
m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART;
|
||||||
|
|
||||||
|
// TODO: 在此处添加构造代码,
|
||||||
|
// 将所有重要的初始化放置在 InitInstance 中
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 唯一的 CCSMQTTApp 对象
|
||||||
|
|
||||||
|
CCSMQTTApp theApp;
|
||||||
|
|
||||||
|
|
||||||
|
// CCSMQTTApp 初始化
|
||||||
|
|
||||||
|
BOOL CCSMQTTApp::InitInstance()
|
||||||
|
{
|
||||||
|
// 如果一个运行在 Windows XP 上的应用程序清单指定要
|
||||||
|
// 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
|
||||||
|
//则需要 InitCommonControlsEx()。 否则,将无法创建窗口。
|
||||||
|
INITCOMMONCONTROLSEX InitCtrls;
|
||||||
|
InitCtrls.dwSize = sizeof(InitCtrls);
|
||||||
|
// 将它设置为包括所有要在应用程序中使用的
|
||||||
|
// 公共控件类。
|
||||||
|
InitCtrls.dwICC = ICC_WIN95_CLASSES;
|
||||||
|
InitCommonControlsEx(&InitCtrls);
|
||||||
|
|
||||||
|
CWinApp::InitInstance();
|
||||||
|
|
||||||
|
|
||||||
|
AfxEnableControlContainer();
|
||||||
|
|
||||||
|
// 创建 shell 管理器,以防对话框包含
|
||||||
|
// 任何 shell 树视图控件或 shell 列表视图控件。
|
||||||
|
CShellManager *pShellManager = new CShellManager;
|
||||||
|
|
||||||
|
// 激活“Windows Native”视觉管理器,以便在 MFC 控件中启用主题
|
||||||
|
CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));
|
||||||
|
|
||||||
|
// 标准初始化
|
||||||
|
// 如果未使用这些功能并希望减小
|
||||||
|
// 最终可执行文件的大小,则应移除下列
|
||||||
|
// 不需要的特定初始化例程
|
||||||
|
// 更改用于存储设置的注册表项
|
||||||
|
// TODO: 应适当修改该字符串,
|
||||||
|
// 例如修改为公司或组织名
|
||||||
|
SetRegistryKey(_T("应用程序向导生成的本地应用程序"));
|
||||||
|
|
||||||
|
CCSMQTTDlg dlg;
|
||||||
|
m_pMainWnd = &dlg;
|
||||||
|
INT_PTR nResponse = dlg.DoModal();
|
||||||
|
if (nResponse == IDOK)
|
||||||
|
{
|
||||||
|
// TODO: 在此放置处理何时用
|
||||||
|
// “确定”来关闭对话框的代码
|
||||||
|
}
|
||||||
|
else if (nResponse == IDCANCEL)
|
||||||
|
{
|
||||||
|
// TODO: 在此放置处理何时用
|
||||||
|
// “取消”来关闭对话框的代码
|
||||||
|
}
|
||||||
|
else if (nResponse == -1)
|
||||||
|
{
|
||||||
|
TRACE(traceAppMsg, 0, "警告: 对话框创建失败,应用程序将意外终止。\n");
|
||||||
|
TRACE(traceAppMsg, 0, "警告: 如果您在对话框上使用 MFC 控件,则无法 #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS。\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除上面创建的 shell 管理器。
|
||||||
|
if (pShellManager != nullptr)
|
||||||
|
{
|
||||||
|
delete pShellManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !defined(_AFXDLL) && !defined(_AFX_NO_MFC_CONTROLS_IN_DIALOGS)
|
||||||
|
ControlBarCleanUp();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序,
|
||||||
|
// 而不是启动应用程序的消息泵。
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
32
CSMQTT/CSMQTT.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
|
||||||
|
// CSMQTT.h: PROJECT_NAME 应用程序的主头文件
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef __AFXWIN_H__
|
||||||
|
#error "在包含此文件之前包含 'pch.h' 以生成 PCH"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "resource.h" // 主符号
|
||||||
|
|
||||||
|
|
||||||
|
// CCSMQTTApp:
|
||||||
|
// 有关此类的实现,请参阅 CSMQTT.cpp
|
||||||
|
//
|
||||||
|
|
||||||
|
class CCSMQTTApp : public CWinApp
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CCSMQTTApp();
|
||||||
|
|
||||||
|
// 重写
|
||||||
|
public:
|
||||||
|
virtual BOOL InitInstance();
|
||||||
|
|
||||||
|
// 实现
|
||||||
|
|
||||||
|
DECLARE_MESSAGE_MAP()
|
||||||
|
};
|
||||||
|
|
||||||
|
extern CCSMQTTApp theApp;
|
BIN
CSMQTT/CSMQTT.rc
Normal file
215
CSMQTT/CSMQTT.vcxproj
Normal file
@ -0,0 +1,215 @@
|
|||||||
|
<?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>{C76E066B-BE29-415E-8975-0107C4191EEF}</ProjectGuid>
|
||||||
|
<Keyword>MFCProj</Keyword>
|
||||||
|
<RootNamespace>CSMQTT</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>Static</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>Static</UseOfMfc>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
<UseOfMfc>Static</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>Static</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>0x0804</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>0x0804</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>0x0804</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>0x0804</Culture>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ResourceCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="CSMQTT.h" />
|
||||||
|
<ClInclude Include="CSMQTTDlg.h" />
|
||||||
|
<ClInclude Include="framework.h" />
|
||||||
|
<ClInclude Include="pch.h" />
|
||||||
|
<ClInclude Include="Resource.h" />
|
||||||
|
<ClInclude Include="targetver.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="CSMQTT.cpp" />
|
||||||
|
<ClCompile Include="CSMQTTDlg.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>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ResourceCompile Include="CSMQTT.rc" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="res\CSMQTT.rc2" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Image Include="res\CSMQTT.ico" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
63
CSMQTT/CSMQTT.vcxproj.filters
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="源文件">
|
||||||
|
<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="头文件">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="资源文件">
|
||||||
|
<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="CSMQTT.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="CSMQTTDlg.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="framework.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="targetver.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Resource.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="pch.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="CSMQTT.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="CSMQTTDlg.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="pch.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ResourceCompile Include="CSMQTT.rc">
|
||||||
|
<Filter>资源文件</Filter>
|
||||||
|
</ResourceCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="res\CSMQTT.rc2">
|
||||||
|
<Filter>资源文件</Filter>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Image Include="res\CSMQTT.ico">
|
||||||
|
<Filter>资源文件</Filter>
|
||||||
|
</Image>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
144
CSMQTT/CSMQTTDlg.cpp
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
|
||||||
|
// CSMQTTDlg.cpp: 实现文件
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "pch.h"
|
||||||
|
#include "framework.h"
|
||||||
|
#include "CSMQTT.h"
|
||||||
|
#include "CSMQTTDlg.h"
|
||||||
|
#include "afxdialogex.h"
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
#define new DEBUG_NEW
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// CCSMQTTDlg 对话框
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CCSMQTTDlg::CCSMQTTDlg(CWnd* pParent /*=nullptr*/)
|
||||||
|
: CDialogEx(IDD_CSMQTT_DIALOG, pParent)
|
||||||
|
{
|
||||||
|
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCSMQTTDlg::DoDataExchange(CDataExchange* pDX)
|
||||||
|
{
|
||||||
|
CDialogEx::DoDataExchange(pDX);
|
||||||
|
}
|
||||||
|
|
||||||
|
BEGIN_MESSAGE_MAP(CCSMQTTDlg, CDialogEx)
|
||||||
|
ON_WM_PAINT()
|
||||||
|
ON_WM_QUERYDRAGICON()
|
||||||
|
ON_BN_CLICKED(IDOK, &CCSMQTTDlg::OnBnClickedOk)
|
||||||
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
|
|
||||||
|
// CCSMQTTDlg 消息处理程序
|
||||||
|
|
||||||
|
BOOL CCSMQTTDlg::OnInitDialog()
|
||||||
|
{
|
||||||
|
CDialogEx::OnInitDialog();
|
||||||
|
|
||||||
|
// 设置此对话框的图标。 当应用程序主窗口不是对话框时,框架将自动
|
||||||
|
// 执行此操作
|
||||||
|
SetIcon(m_hIcon, TRUE); // 设置大图标
|
||||||
|
SetIcon(m_hIcon, FALSE); // 设置小图标
|
||||||
|
|
||||||
|
// TODO: 在此添加额外的初始化代码
|
||||||
|
|
||||||
|
server.SetFunc([this](SOCKET sock, int index, char* buf, short len) {CCSMQTTDlg::Process(sock, index, buf, len); });
|
||||||
|
server.CreatServer(1995);
|
||||||
|
|
||||||
|
|
||||||
|
//clien[1].Create();
|
||||||
|
//clien[1].Connect(_T("127.0.0.1"), 1883);
|
||||||
|
//clien[1].SetConnectFun([this](int i) {CCSMQTTDlg::Process(i); });
|
||||||
|
//clien[1].SetFunc([this](int i) {CCSMQTTDlg::Proc(1); }, 1);
|
||||||
|
|
||||||
|
file.Open(_T("D://1.txt"), CFile::modeCreate | CFile::modeReadWrite);
|
||||||
|
|
||||||
|
file1.Open(_T("D://2.txt"), CFile::modeCreate | CFile::modeReadWrite);
|
||||||
|
return TRUE; // 除非将焦点设置到控件,否则返回 TRUE
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果向对话框添加最小化按钮,则需要下面的代码
|
||||||
|
// 来绘制该图标。 对于使用文档/视图模型的 MFC 应用程序,
|
||||||
|
// 这将由框架自动完成。
|
||||||
|
|
||||||
|
void CCSMQTTDlg::OnPaint()
|
||||||
|
{
|
||||||
|
if (IsIconic())
|
||||||
|
{
|
||||||
|
CPaintDC dc(this); // 用于绘制的设备上下文
|
||||||
|
|
||||||
|
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
|
||||||
|
|
||||||
|
// 使图标在工作区矩形中居中
|
||||||
|
int cxIcon = GetSystemMetrics(SM_CXICON);
|
||||||
|
int cyIcon = GetSystemMetrics(SM_CYICON);
|
||||||
|
CRect rect;
|
||||||
|
GetClientRect(&rect);
|
||||||
|
int x = (rect.Width() - cxIcon + 1) / 2;
|
||||||
|
int y = (rect.Height() - cyIcon + 1) / 2;
|
||||||
|
|
||||||
|
// 绘制图标
|
||||||
|
dc.DrawIcon(x, y, m_hIcon);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CDialogEx::OnPaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//当用户拖动最小化窗口时系统调用此函数取得光标
|
||||||
|
//显示。
|
||||||
|
HCURSOR CCSMQTTDlg::OnQueryDragIcon()
|
||||||
|
{
|
||||||
|
return static_cast<HCURSOR>(m_hIcon);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void CCSMQTTDlg::OnBnClickedOk()
|
||||||
|
{
|
||||||
|
// TODO: 在此添加控件通知处理程序代码
|
||||||
|
CDialogEx::OnOK();
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID CCSMQTTDlg::Process(SOCKET sock, int index, char* buf, short len)
|
||||||
|
{
|
||||||
|
if(clien.find(index)== clien.end())
|
||||||
|
{
|
||||||
|
clien[index].Create();
|
||||||
|
clien[index].Connect(_T("127.0.0.1"), 1883);
|
||||||
|
clien[index].SetConnectFun([this](int i) {CCSMQTTDlg::Process(i); });
|
||||||
|
clien[index].SetFunc([this] (){CCSMQTTDlg::Proc(); });
|
||||||
|
}
|
||||||
|
Sleep(100);
|
||||||
|
CStringA str;
|
||||||
|
str.Format("\r\n收到一条消息%d\r\n", index);
|
||||||
|
int l = clien[index].Send(buf, len, 0);
|
||||||
|
file.Write(str, str.GetLength());
|
||||||
|
file.Write(buf, len);
|
||||||
|
//CStringA str = buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID CCSMQTTDlg::Proc(int id)
|
||||||
|
{
|
||||||
|
CStringA str;
|
||||||
|
str.Format("\r\n收到一条消息%d\r\n", id);
|
||||||
|
file1.Write(str, str.GetLength());
|
||||||
|
char* buf;
|
||||||
|
int len;
|
||||||
|
clien[id].GetMsg(&buf,len);
|
||||||
|
len = server.SendTo(id, buf, len);
|
||||||
|
file1.Write(buf, len);
|
||||||
|
delete[]buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID CCSMQTTDlg::Process(int type)
|
||||||
|
{
|
||||||
|
int i = type;
|
||||||
|
}
|
42
CSMQTT/CSMQTTDlg.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
|
||||||
|
// CSMQTTDlg.h: 头文件
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
// CCSMQTTDlg 对话框
|
||||||
|
class CCSMQTTDlg : public CDialogEx
|
||||||
|
{
|
||||||
|
// 构造
|
||||||
|
public:
|
||||||
|
CCSMQTTDlg(CWnd* pParent = nullptr); // 标准构造函数
|
||||||
|
|
||||||
|
// 对话框数据
|
||||||
|
#ifdef AFX_DESIGN_TIME
|
||||||
|
enum { IDD = IDD_CSMQTT_DIALOG };
|
||||||
|
#endif
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
|
||||||
|
|
||||||
|
|
||||||
|
// 实现
|
||||||
|
protected:
|
||||||
|
HICON m_hIcon;
|
||||||
|
|
||||||
|
// 生成的消息映射函数
|
||||||
|
virtual BOOL OnInitDialog();
|
||||||
|
afx_msg void OnPaint();
|
||||||
|
afx_msg HCURSOR OnQueryDragIcon();
|
||||||
|
DECLARE_MESSAGE_MAP()
|
||||||
|
public:
|
||||||
|
afx_msg void OnBnClickedOk();
|
||||||
|
SocketServer server;
|
||||||
|
std::map<int, SocketClien> clien;
|
||||||
|
CFile file,file1;
|
||||||
|
|
||||||
|
VOID Process(SOCKET sock, int index, char* buf, short len); //处理Socket消息
|
||||||
|
VOID Proc(int id); //处理Socket消息
|
||||||
|
VOID Process(int type); //处理Socket消息
|
||||||
|
};
|
49
CSMQTT/framework.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef VC_EXTRALEAN
|
||||||
|
#define VC_EXTRALEAN // 从 Windows 头中排除极少使用的资料
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "targetver.h"
|
||||||
|
|
||||||
|
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 某些 CString 构造函数将是显式的
|
||||||
|
|
||||||
|
// 关闭 MFC 的一些常见且经常可放心忽略的隐藏警告消息
|
||||||
|
#define _AFX_ALL_WARNINGS
|
||||||
|
|
||||||
|
#include <afxwin.h> // MFC 核心组件和标准组件
|
||||||
|
#include <afxext.h> // MFC 扩展
|
||||||
|
|
||||||
|
|
||||||
|
#include <afxdisp.h> // MFC 自动化类
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _AFX_NO_OLE_SUPPORT
|
||||||
|
#include <afxdtctl.h> // MFC 对 Internet Explorer 4 公共控件的支持
|
||||||
|
#endif
|
||||||
|
#ifndef _AFX_NO_AFXCMN_SUPPORT
|
||||||
|
#include <afxcmn.h> // MFC 对 Windows 公共控件的支持
|
||||||
|
#endif // _AFX_NO_AFXCMN_SUPPORT
|
||||||
|
|
||||||
|
#include <afxcontrolbars.h> // MFC 支持功能区和控制条
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#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
|
||||||
|
|
||||||
|
|
5
CSMQTT/pch.cpp
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
// pch.cpp: 与预编译标头对应的源文件
|
||||||
|
|
||||||
|
#include "pch.h"
|
||||||
|
|
||||||
|
// 当使用预编译的头时,需要使用此源文件,编译才能成功。
|
24
CSMQTT/pch.h
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// pch.h: 这是预编译标头文件。
|
||||||
|
// 下方列出的文件仅编译一次,提高了将来生成的生成性能。
|
||||||
|
// 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。
|
||||||
|
// 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。
|
||||||
|
// 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。
|
||||||
|
|
||||||
|
#ifndef PCH_H
|
||||||
|
#define PCH_H
|
||||||
|
|
||||||
|
// 添加要在此处预编译的标头
|
||||||
|
#include "framework.h"
|
||||||
|
|
||||||
|
// 添加要在此处预编译的标头
|
||||||
|
#include "framework.h"
|
||||||
|
|
||||||
|
#include "D:/代码/ToolsLib/ToolsLib/ToolsLib.h"
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
#pragma comment(lib,"D:/代码/ToolsLib/x64/Debug/ToolsLib.lib")
|
||||||
|
#else
|
||||||
|
#pragma comment(lib,"D:/代码/ToolsLib/x64/Release/ToolsLib.lib")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif //PCH_H
|
BIN
CSMQTT/res/CSMQTT.ico
Normal file
After Width: | Height: | Size: 66 KiB |
BIN
CSMQTT/res/CSMQTT.rc2
Normal file
17
CSMQTT/resource.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
//{{NO_DEPENDENCIES}}
|
||||||
|
// Microsoft Visual C++ 生成的包含文件。
|
||||||
|
// 供 CSMQTT.rc 使用
|
||||||
|
//
|
||||||
|
#define IDD_CSMQTT_DIALOG 102
|
||||||
|
#define IDR_MAINFRAME 128
|
||||||
|
|
||||||
|
// Next default values for new objects
|
||||||
|
//
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||||
|
#define _APS_NEXT_RESOURCE_VALUE 129
|
||||||
|
#define _APS_NEXT_COMMAND_VALUE 32771
|
||||||
|
#define _APS_NEXT_CONTROL_VALUE 1000
|
||||||
|
#define _APS_NEXT_SYMED_VALUE 101
|
||||||
|
#endif
|
||||||
|
#endif
|
8
CSMQTT/targetver.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。
|
||||||
|
|
||||||
|
//如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h,并
|
||||||
|
// 将 _WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。
|
||||||
|
|
||||||
|
#include <SDKDDKVer.h>
|
41
aike.sln
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.9.34728.123
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aike", "aike\aike.vcxproj", "{699789E1-D831-4727-88CF-81FB6F000FC8}"
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CSMQTT", "CSMQTT\CSMQTT.vcxproj", "{C76E066B-BE29-415E-8975-0107C4191EEF}"
|
||||||
|
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
|
||||||
|
{699789E1-D831-4727-88CF-81FB6F000FC8}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{699789E1-D831-4727-88CF-81FB6F000FC8}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{699789E1-D831-4727-88CF-81FB6F000FC8}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{699789E1-D831-4727-88CF-81FB6F000FC8}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{699789E1-D831-4727-88CF-81FB6F000FC8}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{699789E1-D831-4727-88CF-81FB6F000FC8}.Release|x64.Build.0 = Release|x64
|
||||||
|
{699789E1-D831-4727-88CF-81FB6F000FC8}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{699789E1-D831-4727-88CF-81FB6F000FC8}.Release|x86.Build.0 = Release|Win32
|
||||||
|
{C76E066B-BE29-415E-8975-0107C4191EEF}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{C76E066B-BE29-415E-8975-0107C4191EEF}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{C76E066B-BE29-415E-8975-0107C4191EEF}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{C76E066B-BE29-415E-8975-0107C4191EEF}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{C76E066B-BE29-415E-8975-0107C4191EEF}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{C76E066B-BE29-415E-8975-0107C4191EEF}.Release|x64.Build.0 = Release|x64
|
||||||
|
{C76E066B-BE29-415E-8975-0107C4191EEF}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{C76E066B-BE29-415E-8975-0107C4191EEF}.Release|x86.Build.0 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {4865F74A-1F88-44A6-9C87-A441502B6F0A}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
558
aike/MyDialog.cpp
Normal file
@ -0,0 +1,558 @@
|
|||||||
|
#include "pch.h"
|
||||||
|
#include "MyDialog.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0) //判断鼠标状态
|
||||||
|
|
||||||
|
|
||||||
|
UINT MyDialog::SetWindowsRect(LPVOID pParam)
|
||||||
|
{
|
||||||
|
MyDialog* dlg = (MyDialog*)pParam;
|
||||||
|
CPoint point;
|
||||||
|
CRect rt;
|
||||||
|
while (KEY_DOWN(VK_LBUTTON))
|
||||||
|
{
|
||||||
|
GetCursorPos(&point);
|
||||||
|
dlg->m_wnd->GetWindowRect(rt);
|
||||||
|
switch (dlg->MouseState)
|
||||||
|
{
|
||||||
|
case 2:
|
||||||
|
rt.OffsetRect(point - dlg->pt);
|
||||||
|
dlg->m_wnd->MoveWindow(rt);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
rt.top = rt.top + point.y - dlg->pt.y;
|
||||||
|
dlg->m_wnd->MoveWindow(rt);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
rt.right = rt.right + point.x - dlg->pt.x;
|
||||||
|
dlg->m_wnd->MoveWindow(rt);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
rt.bottom = rt.bottom + point.y - dlg->pt.y;
|
||||||
|
dlg->m_wnd->MoveWindow(rt);
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
rt.left = rt.left + point.x - dlg->pt.x;
|
||||||
|
dlg->m_wnd->MoveWindow(rt);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
dlg->pt = point;
|
||||||
|
Sleep(50);
|
||||||
|
}
|
||||||
|
dlg->MouseState = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
VOID MyDialog::LBDown(MSG* pMsg)
|
||||||
|
{
|
||||||
|
CArray <int> buttArr;
|
||||||
|
GetPtButton(pMsg->pt, buttArr);
|
||||||
|
clock_t tt = clock();
|
||||||
|
for (int i = 0; i < buttArr.GetCount(); i++)
|
||||||
|
{
|
||||||
|
infoMap[buttArr[i]].State = 2;
|
||||||
|
infoMap[buttArr[i]].lastLD = tt;
|
||||||
|
}
|
||||||
|
PaintDlg();
|
||||||
|
if (buttArr.GetCount() == 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (MouseState == 0)
|
||||||
|
{
|
||||||
|
/*2移动窗口,3、4、5、6窗口向上、右、下、左扩大*/
|
||||||
|
GetCursorPos(&pt);
|
||||||
|
CPoint point = pMsg->pt;
|
||||||
|
m_wnd->ScreenToClient(&point); //转换成屏幕坐标
|
||||||
|
CRect rt;
|
||||||
|
m_wnd->GetWindowRect(rt);
|
||||||
|
if (point.y >= 3 && point.y < 30)
|
||||||
|
{
|
||||||
|
MouseState = 2;
|
||||||
|
}
|
||||||
|
else if (point.y < 3)
|
||||||
|
{
|
||||||
|
MouseState = 3;
|
||||||
|
}
|
||||||
|
else if (point.x > rt.Width() - 3)
|
||||||
|
{
|
||||||
|
MouseState = 4;
|
||||||
|
}
|
||||||
|
else if (point.y > rt.Height() - 3)
|
||||||
|
{
|
||||||
|
MouseState = 5;
|
||||||
|
}
|
||||||
|
else if (point.x < 3)
|
||||||
|
{
|
||||||
|
MouseState = 6;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
AfxBeginThread(SetWindowsRect, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID MyDialog::LBUP(MSG* pMsg)
|
||||||
|
{
|
||||||
|
CArray <int> buttArr;
|
||||||
|
GetPtButton(pMsg->pt, buttArr);
|
||||||
|
clock_t tt = clock();
|
||||||
|
for (int i = 0; i < buttArr.GetCount(); i++)
|
||||||
|
{
|
||||||
|
infoMap[buttArr[i]].State = 1;
|
||||||
|
if (tt - infoMap[buttArr[i]].lastLD < 400 && tt - infoMap[buttArr[i]].lastLU > 300)
|
||||||
|
{
|
||||||
|
if (infoMap[buttArr[i]].LClick != NULL)
|
||||||
|
infoMap[buttArr[i]].LClick(buttArr[i]);
|
||||||
|
}
|
||||||
|
infoMap[buttArr[i]].lastLU = tt;
|
||||||
|
}
|
||||||
|
PaintDlg();
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID MyDialog::RBDown(MSG* pMsg)
|
||||||
|
{
|
||||||
|
CArray <int> buttArr;
|
||||||
|
GetPtButton(pMsg->pt, buttArr);
|
||||||
|
clock_t tt = clock();
|
||||||
|
for (int i = 0; i < buttArr.GetCount(); i++)
|
||||||
|
{
|
||||||
|
infoMap[buttArr[i]].State = 2;
|
||||||
|
infoMap[buttArr[i]].lastRD = tt;
|
||||||
|
}
|
||||||
|
PaintDlg();
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID MyDialog::RBUP(MSG* pMsg)
|
||||||
|
{
|
||||||
|
CArray <int> buttArr;
|
||||||
|
GetPtButton(pMsg->pt, buttArr);
|
||||||
|
clock_t tt = clock();
|
||||||
|
for (int i = 0; i < buttArr.GetCount(); i++)
|
||||||
|
{
|
||||||
|
infoMap[buttArr[i]].State = 1;
|
||||||
|
if (tt - infoMap[buttArr[i]].lastRD < 400 && tt - infoMap[buttArr[i]].lastRU > 300)
|
||||||
|
{
|
||||||
|
if (infoMap[buttArr[i]].RClick != NULL)
|
||||||
|
infoMap[buttArr[i]].RClick(buttArr[i]);
|
||||||
|
}
|
||||||
|
infoMap[buttArr[i]].lastRU = tt;
|
||||||
|
}
|
||||||
|
PaintDlg();
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID MyDialog::MMove(MSG* pMsg)
|
||||||
|
{
|
||||||
|
if (!m_bTracked) //鼠标是否进入窗口
|
||||||
|
{
|
||||||
|
TRACKMOUSEEVENT tme;
|
||||||
|
tme.cbSize = sizeof(tme);
|
||||||
|
tme.dwFlags = TME_LEAVE;
|
||||||
|
tme.dwHoverTime = 0;
|
||||||
|
tme.hwndTrack = m_wnd->m_hWnd;
|
||||||
|
TrackMouseEvent(&tme); // 调用函数
|
||||||
|
m_bTracked = TRUE; // 标记鼠标进入窗口
|
||||||
|
m_wnd->Invalidate(FALSE);
|
||||||
|
}
|
||||||
|
CArray <int> buttArr;
|
||||||
|
GetPtButton(pMsg->pt, buttArr);
|
||||||
|
PaintDlg();
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID MyDialog::MLeave(MSG* pMsg)
|
||||||
|
{
|
||||||
|
m_bTracked = FALSE; // 标记鼠标离开窗口
|
||||||
|
CArray <int> buttArr;
|
||||||
|
GetPtButton(CPoint(-1000, -1000), buttArr);
|
||||||
|
PaintDlg();
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID MyDialog::LDClick(MSG* pMsg)
|
||||||
|
{
|
||||||
|
CArray <int> buttArr;
|
||||||
|
GetPtButton(pMsg->pt, buttArr);
|
||||||
|
for (int i = 0; i < buttArr.GetCount(); i++)
|
||||||
|
{
|
||||||
|
if (infoMap[buttArr[i]].LDClick != NULL)
|
||||||
|
infoMap[buttArr[i]].LDClick(buttArr[i]);
|
||||||
|
}
|
||||||
|
PaintDlg();
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID MyDialog::RDClick(MSG* pMsg)
|
||||||
|
{
|
||||||
|
CArray <int> buttArr;
|
||||||
|
GetPtButton(pMsg->pt, buttArr);
|
||||||
|
for (int i = 0; i < buttArr.GetCount(); i++)
|
||||||
|
{
|
||||||
|
if (infoMap[buttArr[i]].RDClick != NULL)
|
||||||
|
infoMap[buttArr[i]].RDClick(buttArr[i]);
|
||||||
|
}
|
||||||
|
PaintDlg();
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID MyDialog::GetPtButton(CPoint pt, CArray<int>& ButtArr)
|
||||||
|
{
|
||||||
|
m_wnd->ScreenToClient(&pt); //转换成屏幕坐标
|
||||||
|
for (auto i = infoMap.begin(); i != infoMap.end(); i++) //遍历所有按钮
|
||||||
|
{
|
||||||
|
if (i->second.rt.PtInRect(pt))
|
||||||
|
{
|
||||||
|
ButtArr.Add(i->first);
|
||||||
|
if (i->second.State == 0)
|
||||||
|
i->second.State = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
i->second.State = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL MyDialog::CImageCopy(CImage& SrcImg, CImage& DesImg)
|
||||||
|
{
|
||||||
|
if (SrcImg.IsNull())
|
||||||
|
return FALSE;
|
||||||
|
//源图像参数
|
||||||
|
BYTE* srcPtr = (BYTE*)SrcImg.GetBits();
|
||||||
|
int srcBitsCount = SrcImg.GetBPP();
|
||||||
|
int srcWidth = SrcImg.GetWidth();
|
||||||
|
int srcHeight = SrcImg.GetHeight();
|
||||||
|
int srcPitch = SrcImg.GetPitch();
|
||||||
|
//销毁原有图像
|
||||||
|
if (!DesImg.IsNull())
|
||||||
|
{
|
||||||
|
DesImg.Destroy();
|
||||||
|
}
|
||||||
|
//创建新图像
|
||||||
|
if (srcBitsCount == 32) //支持alpha通道
|
||||||
|
{
|
||||||
|
DesImg.Create(srcWidth, srcHeight, srcBitsCount, 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DesImg.Create(srcWidth, srcHeight, srcBitsCount, 0);
|
||||||
|
}
|
||||||
|
//加载调色板
|
||||||
|
if (srcBitsCount <= 8 && DesImg.IsIndexed())//需要调色板
|
||||||
|
{
|
||||||
|
RGBQUAD pal[256];
|
||||||
|
int nColors = SrcImg.GetMaxColorTableEntries();
|
||||||
|
if (nColors > 0)
|
||||||
|
{
|
||||||
|
SrcImg.GetColorTable(0, nColors, pal);
|
||||||
|
DesImg.SetColorTable(0, nColors, pal);//复制调色板程序
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//目标图像参数
|
||||||
|
BYTE* destPtr = (BYTE*)DesImg.GetBits();
|
||||||
|
int destPitch = DesImg.GetPitch();
|
||||||
|
//复制图像数据
|
||||||
|
for (INT i = 0; i < srcHeight; i++)
|
||||||
|
{
|
||||||
|
memcpy(destPtr + i * destPitch, srcPtr + i * srcPitch, abs(srcPitch));
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL MyDialog::CreateStretchImage(const CImage& src, CImage& dest, int stretchWidth, int stretchHeight)
|
||||||
|
{
|
||||||
|
if (src.IsDIBSection())
|
||||||
|
{
|
||||||
|
if (!dest.IsNull())
|
||||||
|
{
|
||||||
|
dest.Destroy();
|
||||||
|
}
|
||||||
|
if (stretchWidth == 0 || stretchHeight == 0)
|
||||||
|
{
|
||||||
|
stretchWidth = src.GetWidth();
|
||||||
|
stretchHeight = src.GetHeight();
|
||||||
|
}
|
||||||
|
if (dest.Create(stretchWidth, stretchHeight, 16))
|
||||||
|
{
|
||||||
|
HDC destDC = dest.GetDC();
|
||||||
|
::SetStretchBltMode(destDC, HALFTONE);
|
||||||
|
src.StretchBlt(destDC, 0, 0, stretchWidth, stretchHeight);
|
||||||
|
dest.ReleaseDC();
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
MyDialog::MyDialog(CWnd* wnd)
|
||||||
|
{
|
||||||
|
m_wnd = wnd;
|
||||||
|
ButtonU.Create(16, 16, 16); //创建图片
|
||||||
|
FillRect(ButtonU.GetDC(), CRect(0, 0, 16, 16), CreateSolidBrush(RGB(125, 125, 125)));
|
||||||
|
ButtonU.ReleaseDC();
|
||||||
|
ButtonF.Create(16, 16, 16); //创建图片
|
||||||
|
FillRect(ButtonF.GetDC(), CRect(0, 0, 16, 16), CreateSolidBrush(RGB(180, 180, 180)));
|
||||||
|
ButtonF.ReleaseDC();
|
||||||
|
ButtonD.Create(16, 16, 16); //创建图片
|
||||||
|
FillRect(ButtonD.GetDC(), CRect(0, 0, 16, 16), CreateSolidBrush(RGB(90, 90, 90)));
|
||||||
|
ButtonD.ReleaseDC();
|
||||||
|
ButtonS.Create(16, 16, 16); //创建图片
|
||||||
|
FillRect(ButtonS.GetDC(), CRect(0, 0, 16, 16), CreateSolidBrush(RGB(50, 50, 50)));
|
||||||
|
ButtonS.ReleaseDC();
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL MyDialog::AddButton(int ID, CRect rt, CImage& ButtonU, CImage& ButtonF, CImage& ButtonD, CImage& ButtonS)
|
||||||
|
{
|
||||||
|
rt.NormalizeRect();
|
||||||
|
if (rt.Width() > 0 && rt.Height() > 0)
|
||||||
|
{
|
||||||
|
if (infoMap.find(ID) == infoMap.end()) //判断按钮是否存在
|
||||||
|
{
|
||||||
|
ButtonInfo info;
|
||||||
|
info.rt = rt;
|
||||||
|
infoMap[ID] = info;
|
||||||
|
if (!ButtonU.IsNull())
|
||||||
|
{
|
||||||
|
if (!CImageCopy(ButtonU, infoMap[ID].ButtonU))
|
||||||
|
{
|
||||||
|
infoMap.erase(ID);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!ButtonF.IsNull())
|
||||||
|
{
|
||||||
|
if (!CImageCopy(ButtonF, infoMap[ID].ButtonF))
|
||||||
|
{
|
||||||
|
infoMap.erase(ID);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!ButtonD.IsNull())
|
||||||
|
{
|
||||||
|
if (!CImageCopy(ButtonD, infoMap[ID].ButtonD))
|
||||||
|
{
|
||||||
|
infoMap.erase(ID);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!ButtonS.IsNull())
|
||||||
|
{
|
||||||
|
if (!CImageCopy(ButtonS, infoMap[ID].ButtonS))
|
||||||
|
{
|
||||||
|
infoMap.erase(ID);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID MyDialog::PTMessage(MSG* pMsg)
|
||||||
|
{
|
||||||
|
switch (pMsg->message)
|
||||||
|
{
|
||||||
|
case WM_RBUTTONDBLCLK: //双击 鼠标右键双击会产生WM_LBUTTONDOWN WM_LBUTTONUP WM_LBUTTONDBLCK WM_LBUTTONUP 四个消息
|
||||||
|
RDClick(pMsg);
|
||||||
|
break;
|
||||||
|
case WM_RBUTTONDOWN: //鼠标右键按下
|
||||||
|
RBDown(pMsg);
|
||||||
|
break;
|
||||||
|
case WM_RBUTTONUP: //鼠标右键抬起
|
||||||
|
RBUP(pMsg);
|
||||||
|
break;
|
||||||
|
case WM_LBUTTONDBLCLK: //双击 鼠标左键双击会产生WM_LBUTTONDOWN WM_LBUTTONUP WM_LBUTTONDBLCK WM_LBUTTONUP 四个消息
|
||||||
|
LDClick(pMsg);
|
||||||
|
break;
|
||||||
|
case WM_LBUTTONDOWN: //鼠标左键按下
|
||||||
|
LBDown(pMsg);
|
||||||
|
break;
|
||||||
|
case WM_LBUTTONUP: //鼠标左键抬起
|
||||||
|
LBUP(pMsg);
|
||||||
|
break;
|
||||||
|
case WM_MOUSEMOVE: //鼠标移动
|
||||||
|
MMove(pMsg);
|
||||||
|
break;
|
||||||
|
case WM_MOUSELEAVE: //鼠标离开窗口
|
||||||
|
MLeave(pMsg);
|
||||||
|
break;
|
||||||
|
case WM_MOUSEWHEEL: //鼠标滑动滚轮
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID MyDialog::PaintDlg()
|
||||||
|
{
|
||||||
|
if (Background.IsNull())
|
||||||
|
{
|
||||||
|
m_wnd->ModifyStyle(GWL_EXSTYLE, WS_CLIPCHILDREN, SWP_FRAMECHANGED); //去除菜单栏并设置画背景和按钮的时候不遮挡MFC控件
|
||||||
|
Background.Create(16, 16, 16); //创建图片
|
||||||
|
FillRect(Background.GetDC(), CRect(0, 0, 16, 16), CreateSolidBrush(RGB(255, 255, 255)));
|
||||||
|
Background.ReleaseDC();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
CDC* m_dc = m_wnd->GetDC(); //获取窗口HDC
|
||||||
|
CRect rt;
|
||||||
|
m_wnd->GetWindowRect(rt);
|
||||||
|
rt.MoveToXY(0, 0);
|
||||||
|
CImage img;
|
||||||
|
if (!CreateStretchImage(Background, img, rt.Width(), rt.Height()))
|
||||||
|
return;
|
||||||
|
HDC hdc = img.GetDC();
|
||||||
|
for (auto i = infoMap.begin(); i != infoMap.end(); i++) //遍历所有按钮
|
||||||
|
{
|
||||||
|
switch (i->second.State)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
if (i->second.ButtonF.IsNull())
|
||||||
|
{
|
||||||
|
ButtonF.Draw(hdc, i->second.rt);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
i->second.ButtonF.Draw(hdc, i->second.rt);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if (i->second.ButtonD.IsNull())
|
||||||
|
{
|
||||||
|
ButtonD.Draw(hdc, i->second.rt);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
i->second.ButtonD.Draw(hdc, i->second.rt);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
if (i->second.ButtonS.IsNull())
|
||||||
|
{
|
||||||
|
ButtonS.Draw(hdc, i->second.rt);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
i->second.ButtonS.Draw(hdc, i->second.rt);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (i->second.ButtonU.IsNull())
|
||||||
|
{
|
||||||
|
ButtonU.Draw(hdc, i->second.rt);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
i->second.ButtonU.Draw(hdc, i->second.rt);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
img.ReleaseDC();
|
||||||
|
::SetStretchBltMode(m_dc->m_hDC, HALFTONE);
|
||||||
|
img.Draw(m_dc->m_hDC, rt);
|
||||||
|
m_wnd->ReleaseDC(m_dc);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID MyDialog::EnableButton(int ID, BOOL Flag)
|
||||||
|
{
|
||||||
|
if (infoMap.find(ID) != infoMap.end()) //判断按钮是否存在
|
||||||
|
{
|
||||||
|
infoMap[ID].State = 3;
|
||||||
|
}
|
||||||
|
PaintDlg();
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL MyDialog::SetBackground(CImage& img)
|
||||||
|
{
|
||||||
|
if (CreateStretchImage(img, Background))
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL MyDialog::SetLClick(int ID, Fun func)
|
||||||
|
{
|
||||||
|
if (infoMap.find(ID) != infoMap.end()) //判断按钮是否存在
|
||||||
|
{
|
||||||
|
infoMap[ID].LClick = func;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL MyDialog::SetLDClick(int ID, Fun func)
|
||||||
|
{
|
||||||
|
if (infoMap.find(ID) != infoMap.end()) //判断按钮是否存在
|
||||||
|
{
|
||||||
|
infoMap[ID].LDClick = func;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL MyDialog::SetRClick(int ID, Fun func)
|
||||||
|
{
|
||||||
|
if (infoMap.find(ID) != infoMap.end()) //判断按钮是否存在
|
||||||
|
{
|
||||||
|
infoMap[ID].RClick = func;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL MyDialog::SetRDClick(int ID, Fun func)
|
||||||
|
{
|
||||||
|
if (infoMap.find(ID) != infoMap.end()) //判断按钮是否存在
|
||||||
|
{
|
||||||
|
infoMap[ID].RDClick = func;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL MyDialog::MoveButton(int ID, CRect rt)
|
||||||
|
{
|
||||||
|
rt.NormalizeRect();
|
||||||
|
if (rt.Width() > 0 && rt.Height() > 0)
|
||||||
|
{
|
||||||
|
if (infoMap.find(ID) != infoMap.end()) //判断按钮是否存在
|
||||||
|
{
|
||||||
|
infoMap[ID].rt = rt;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID MyDialog::DeleteButton(int ID)
|
||||||
|
{
|
||||||
|
infoMap.erase(ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID MyDialog::DeleteAllButton()
|
||||||
|
{
|
||||||
|
infoMap.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
CRect MyDialog::GetButtonRect(int ID)
|
||||||
|
{
|
||||||
|
if (infoMap.find(ID) != infoMap.end()) //判断按钮是否存在
|
||||||
|
{
|
||||||
|
return infoMap[ID].rt;
|
||||||
|
}
|
||||||
|
return CRect(0, 0, 0, 0);
|
||||||
|
}
|
96
aike/MyDialog.h
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <map>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
|
||||||
|
class MyDialog
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
CImage ButtonU; //正常状态时的按钮图片
|
||||||
|
CImage ButtonF; //鼠标悬停的按钮图片
|
||||||
|
CImage ButtonD; //鼠标按下时的按钮图片
|
||||||
|
CImage ButtonS; //按钮失效后的图片
|
||||||
|
static UINT SetWindowsRect(LPVOID pParam);
|
||||||
|
typedef std::function<void(int)> Fun;
|
||||||
|
struct ButtonInfo //单个按钮信息
|
||||||
|
{
|
||||||
|
CImage ButtonU; //正常状态时的按钮图片
|
||||||
|
CImage ButtonF; //鼠标悬停的按钮图片
|
||||||
|
CImage ButtonD; //鼠标按下时的按钮图片
|
||||||
|
CImage ButtonS; //按钮失效后的图片
|
||||||
|
CRect rt; //按钮位置
|
||||||
|
Fun LClick = NULL; //鼠标左键单击回调函数
|
||||||
|
Fun LDClick = NULL; //鼠标左键双击回调函数
|
||||||
|
Fun RClick = NULL; //鼠标右键单击回调函数
|
||||||
|
Fun RDClick = NULL; //鼠标右键双击回调函数
|
||||||
|
short State = 0; //当前状态确定显示那张图片
|
||||||
|
clock_t lastLD = 0; //上次左键按下的时间
|
||||||
|
clock_t lastRD = 0; //上次右键按下的时间
|
||||||
|
clock_t lastLU = 0; //上次左键抬起的时间
|
||||||
|
clock_t lastRU = 0; //上次右键抬起的时间
|
||||||
|
void operator = (ButtonInfo& info)
|
||||||
|
{
|
||||||
|
rt = info.rt;
|
||||||
|
LClick = info.LClick;
|
||||||
|
LDClick = info.LDClick;
|
||||||
|
RClick = info.RClick;
|
||||||
|
RDClick = info.RDClick;
|
||||||
|
State = info.State;
|
||||||
|
CreateStretchImage(info.ButtonU, ButtonU);
|
||||||
|
CreateStretchImage(info.ButtonF, ButtonF);
|
||||||
|
CreateStretchImage(info.ButtonD, ButtonD);
|
||||||
|
CreateStretchImage(info.ButtonS, ButtonS);
|
||||||
|
}
|
||||||
|
~ButtonInfo()
|
||||||
|
{
|
||||||
|
ButtonU.Destroy();
|
||||||
|
ButtonF.Destroy();
|
||||||
|
ButtonD.Destroy();
|
||||||
|
ButtonS.Destroy();
|
||||||
|
|
||||||
|
LClick = NULL; //鼠标左键单击回调函数
|
||||||
|
LDClick = NULL; //鼠标左键双击回调函数
|
||||||
|
RClick = NULL; //鼠标右键单击回调函数
|
||||||
|
RDClick = NULL; //鼠标右键双击回调函数
|
||||||
|
}
|
||||||
|
};
|
||||||
|
std::map<int, ButtonInfo> infoMap; //存放所有按钮
|
||||||
|
CImage Background; //背景图片
|
||||||
|
BOOL m_bTracked = FALSE; //鼠标是否在窗口内
|
||||||
|
CWnd* m_wnd; //调用的窗口
|
||||||
|
BOOL imgRect = FALSE; //窗口是否用图片大小显示
|
||||||
|
int MouseState = 0; //鼠标状态确定窗口是移动还是改变大小 2移动窗口,3、4、5、6窗口向上、右、下、左扩大
|
||||||
|
CPoint pt; //鼠标上次的位置
|
||||||
|
VOID LBDown(MSG* pMsg); //鼠标左键按下
|
||||||
|
VOID LBUP(MSG* pMsg); //鼠标左键抬起
|
||||||
|
VOID RBDown(MSG* pMsg); //鼠标左键按下
|
||||||
|
VOID RBUP(MSG* pMsg); //鼠标左键按下
|
||||||
|
VOID MMove(MSG* pMsg); //鼠标移动
|
||||||
|
VOID MLeave(MSG* pMsg); //鼠标离开窗口
|
||||||
|
VOID LDClick(MSG* pMsg); //鼠标左键双击
|
||||||
|
VOID RDClick(MSG* pMsg); //鼠标右键双击
|
||||||
|
VOID GetPtButton(CPoint pt, CArray<int>& ButtArr); //获取该位置有多少按钮并设置其他按钮设置成默认状态
|
||||||
|
public:
|
||||||
|
static BOOL CreateStretchImage(const CImage& src, CImage& dest, int stretchWidth = 0, int stretchHeight = 0); //创建并拉伸图片
|
||||||
|
BOOL CImageCopy(CImage& SrcImg, CImage& DesImg);
|
||||||
|
MyDialog(CWnd* wnd);
|
||||||
|
BOOL AddButton(int ID, CRect rt, CImage& ButtonU = CImage(), CImage& ButtonF = CImage(), CImage& ButtonD = CImage(), CImage& ButtonS = CImage()); //添加按钮
|
||||||
|
VOID PTMessage(MSG* pMsg); //处理窗口消息
|
||||||
|
VOID PaintDlg(); //重绘消息
|
||||||
|
VOID EnableButton(int ID, BOOL Flag); //启用或禁用按钮
|
||||||
|
BOOL SetBackground(CImage& img); //设置背景图片
|
||||||
|
BOOL SetLClick(int ID, Fun func); //设置鼠标左键单击函数
|
||||||
|
BOOL SetLDClick(int ID, Fun func); //设置鼠标左键双击函数
|
||||||
|
BOOL SetRClick(int ID, Fun func); //设置鼠标右键单击函数
|
||||||
|
BOOL SetRDClick(int ID, Fun func); //设置鼠标右键双击函数
|
||||||
|
BOOL MoveButton(int ID, CRect rt); //移动按钮
|
||||||
|
VOID DeleteButton(int ID); //删除按钮
|
||||||
|
VOID DeleteAllButton(); //删除按钮
|
||||||
|
|
||||||
|
CRect GetButtonRect(int ID); //获取按钮位置
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
123
aike/aike.cpp
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
|
||||||
|
// aike.cpp: 定义应用程序的类行为。
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "pch.h"
|
||||||
|
#include "framework.h"
|
||||||
|
#include "aike.h"
|
||||||
|
#include "aikeDlg.h"
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
#define new DEBUG_NEW
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// CaikeApp
|
||||||
|
|
||||||
|
BEGIN_MESSAGE_MAP(CaikeApp, CWinApp)
|
||||||
|
ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
|
||||||
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
|
|
||||||
|
// CaikeApp 构造
|
||||||
|
|
||||||
|
CaikeApp::CaikeApp()
|
||||||
|
{
|
||||||
|
// 支持重新启动管理器
|
||||||
|
m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART;
|
||||||
|
|
||||||
|
// TODO: 在此处添加构造代码,
|
||||||
|
// 将所有重要的初始化放置在 InitInstance 中
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 唯一的 CaikeApp 对象
|
||||||
|
|
||||||
|
CaikeApp theApp;
|
||||||
|
|
||||||
|
|
||||||
|
// CaikeApp 初始化
|
||||||
|
|
||||||
|
BOOL CaikeApp::InitInstance()
|
||||||
|
{
|
||||||
|
// 如果一个运行在 Windows XP 上的应用程序清单指定要
|
||||||
|
// 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
|
||||||
|
//则需要 InitCommonControlsEx()。 否则,将无法创建窗口。
|
||||||
|
INITCOMMONCONTROLSEX InitCtrls;
|
||||||
|
InitCtrls.dwSize = sizeof(InitCtrls);
|
||||||
|
// 将它设置为包括所有要在应用程序中使用的
|
||||||
|
// 公共控件类。
|
||||||
|
InitCtrls.dwICC = ICC_WIN95_CLASSES;
|
||||||
|
InitCommonControlsEx(&InitCtrls);
|
||||||
|
|
||||||
|
CWinApp::InitInstance();
|
||||||
|
|
||||||
|
|
||||||
|
CreateMutex(NULL, TRUE, TEXT("aike宾馆软件客户端")); //避免程序的多开 xxxx为信号量的名字 可随意
|
||||||
|
if (GetLastError() == ERROR_ALREADY_EXISTS)
|
||||||
|
{
|
||||||
|
CWnd* cwnd = CWnd::FindWindow(NULL, TEXT("爱客宾馆软件"));//windowname为你的主窗体的标题,当然你也可以通过进程来找到主窗体。
|
||||||
|
if (cwnd)//显示原先的主界面
|
||||||
|
{
|
||||||
|
cwnd->ShowWindow(SW_SHOWNORMAL);
|
||||||
|
cwnd->SetForegroundWindow();
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AfxEnableControlContainer();
|
||||||
|
|
||||||
|
// 创建 shell 管理器,以防对话框包含
|
||||||
|
// 任何 shell 树视图控件或 shell 列表视图控件。
|
||||||
|
CShellManager *pShellManager = new CShellManager;
|
||||||
|
|
||||||
|
// 激活“Windows Native”视觉管理器,以便在 MFC 控件中启用主题
|
||||||
|
CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));
|
||||||
|
|
||||||
|
// 标准初始化
|
||||||
|
// 如果未使用这些功能并希望减小
|
||||||
|
// 最终可执行文件的大小,则应移除下列
|
||||||
|
// 不需要的特定初始化例程
|
||||||
|
// 更改用于存储设置的注册表项
|
||||||
|
// TODO: 应适当修改该字符串,
|
||||||
|
// 例如修改为公司或组织名
|
||||||
|
SetRegistryKey(_T("应用程序向导生成的本地应用程序"));
|
||||||
|
|
||||||
|
CaikeDlg dlg;
|
||||||
|
m_pMainWnd = &dlg;
|
||||||
|
INT_PTR nResponse = dlg.DoModal();
|
||||||
|
if (nResponse == IDOK)
|
||||||
|
{
|
||||||
|
// TODO: 在此放置处理何时用
|
||||||
|
// “确定”来关闭对话框的代码
|
||||||
|
}
|
||||||
|
else if (nResponse == IDCANCEL)
|
||||||
|
{
|
||||||
|
// TODO: 在此放置处理何时用
|
||||||
|
// “取消”来关闭对话框的代码
|
||||||
|
}
|
||||||
|
else if (nResponse == -1)
|
||||||
|
{
|
||||||
|
TRACE(traceAppMsg, 0, "警告: 对话框创建失败,应用程序将意外终止。\n");
|
||||||
|
TRACE(traceAppMsg, 0, "警告: 如果您在对话框上使用 MFC 控件,则无法 #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS。\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除上面创建的 shell 管理器。
|
||||||
|
if (pShellManager != nullptr)
|
||||||
|
{
|
||||||
|
delete pShellManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !defined(_AFXDLL) && !defined(_AFX_NO_MFC_CONTROLS_IN_DIALOGS)
|
||||||
|
ControlBarCleanUp();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序,
|
||||||
|
// 而不是启动应用程序的消息泵。
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
32
aike/aike.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
|
||||||
|
// aike.h: PROJECT_NAME 应用程序的主头文件
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef __AFXWIN_H__
|
||||||
|
#error "在包含此文件之前包含 'pch.h' 以生成 PCH"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "resource.h" // 主符号
|
||||||
|
|
||||||
|
|
||||||
|
// CaikeApp:
|
||||||
|
// 有关此类的实现,请参阅 aike.cpp
|
||||||
|
//
|
||||||
|
|
||||||
|
class CaikeApp : public CWinApp
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CaikeApp();
|
||||||
|
|
||||||
|
// 重写
|
||||||
|
public:
|
||||||
|
virtual BOOL InitInstance();
|
||||||
|
|
||||||
|
// 实现
|
||||||
|
|
||||||
|
DECLARE_MESSAGE_MAP()
|
||||||
|
};
|
||||||
|
|
||||||
|
extern CaikeApp theApp;
|
BIN
aike/aike.rc
Normal file
217
aike/aike.vcxproj
Normal file
@ -0,0 +1,217 @@
|
|||||||
|
<?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>{699789E1-D831-4727-88CF-81FB6F000FC8}</ProjectGuid>
|
||||||
|
<Keyword>MFCProj</Keyword>
|
||||||
|
<RootNamespace>aike</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>Static</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>Static</UseOfMfc>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
<UseOfMfc>Static</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>Static</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>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
|
<Midl>
|
||||||
|
<MkTypLibCompatible>false</MkTypLibCompatible>
|
||||||
|
<ValidateAllParameters>true</ValidateAllParameters>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
</Midl>
|
||||||
|
<ResourceCompile>
|
||||||
|
<Culture>0x0804</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>0x0804</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>0x0804</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>0x0804</Culture>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ResourceCompile>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="aike.h" />
|
||||||
|
<ClInclude Include="aikeDlg.h" />
|
||||||
|
<ClInclude Include="framework.h" />
|
||||||
|
<ClInclude Include="pch.h" />
|
||||||
|
<ClInclude Include="Resource.h" />
|
||||||
|
<ClInclude Include="targetver.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="aike.cpp" />
|
||||||
|
<ClCompile Include="aikeDlg.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>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ResourceCompile Include="aike.rc" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="res\aike.rc2" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Image Include="res\aike.ico" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
63
aike/aike.vcxproj.filters
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="源文件">
|
||||||
|
<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="头文件">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="资源文件">
|
||||||
|
<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="aike.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="aikeDlg.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="framework.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="targetver.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Resource.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="pch.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="aike.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="aikeDlg.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="pch.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ResourceCompile Include="aike.rc">
|
||||||
|
<Filter>资源文件</Filter>
|
||||||
|
</ResourceCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="res\aike.rc2">
|
||||||
|
<Filter>资源文件</Filter>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Image Include="res\aike.ico">
|
||||||
|
<Filter>资源文件</Filter>
|
||||||
|
</Image>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
372
aike/aikeDlg.cpp
Normal file
@ -0,0 +1,372 @@
|
|||||||
|
|
||||||
|
// aikeDlg.cpp: 实现文件
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "pch.h"
|
||||||
|
#include "framework.h"
|
||||||
|
#include "aike.h"
|
||||||
|
#include "aikeDlg.h"
|
||||||
|
#include "afxdialogex.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
#define new DEBUG_NEW
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define WM_TRAYICON_MSG (WM_USER + 100) //创建托盘图标消息
|
||||||
|
|
||||||
|
// CaikeDlg 对话框
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CaikeDlg::CaikeDlg(CWnd* pParent /*=nullptr*/)
|
||||||
|
: CDialogEx(IDD_AIKE_DIALOG, pParent)
|
||||||
|
,MyDialog(this)
|
||||||
|
{
|
||||||
|
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CaikeDlg::DoDataExchange(CDataExchange* pDX)
|
||||||
|
{
|
||||||
|
CDialogEx::DoDataExchange(pDX);
|
||||||
|
}
|
||||||
|
|
||||||
|
BEGIN_MESSAGE_MAP(CaikeDlg, CDialogEx)
|
||||||
|
ON_WM_PAINT()
|
||||||
|
ON_WM_QUERYDRAGICON()
|
||||||
|
ON_WM_SIZE()
|
||||||
|
ON_WM_GETMINMAXINFO()
|
||||||
|
ON_MESSAGE(WM_TRAYICON_MSG, OnTrayCallBackMsg) //点击了托盘图标
|
||||||
|
ON_WM_DESTROY()
|
||||||
|
ON_COMMAND(ID_SHOW_MENU, &CaikeDlg::OnShowMenu)
|
||||||
|
ON_COMMAND(ID_CLONE_MENU, &CaikeDlg::OnCloneMenu)
|
||||||
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
|
|
||||||
|
// CaikeDlg 消息处理程序
|
||||||
|
|
||||||
|
BOOL CaikeDlg::OnInitDialog()
|
||||||
|
{
|
||||||
|
CDialogEx::OnInitDialog();
|
||||||
|
Initialize();
|
||||||
|
|
||||||
|
return TRUE; // 除非将焦点设置到控件,否则返回 TRUE
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果向对话框添加最小化按钮,则需要下面的代码
|
||||||
|
// 来绘制该图标。 对于使用文档/视图模型的 MFC 应用程序,
|
||||||
|
// 这将由框架自动完成。
|
||||||
|
|
||||||
|
void CaikeDlg::OnPaint()
|
||||||
|
{
|
||||||
|
if (!IsIconic())
|
||||||
|
{
|
||||||
|
PaintDlg();
|
||||||
|
CDialogEx::OnPaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//当用户拖动最小化窗口时系统调用此函数取得光标
|
||||||
|
//显示。
|
||||||
|
HCURSOR CaikeDlg::OnQueryDragIcon()
|
||||||
|
{
|
||||||
|
return static_cast<HCURSOR>(m_hIcon);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//截获窗口消息
|
||||||
|
BOOL CaikeDlg::PreTranslateMessage(MSG* pMsg)
|
||||||
|
{
|
||||||
|
// TODO: 在此添加专用代码和/或调用基类
|
||||||
|
PTMessage(pMsg);
|
||||||
|
return __super::PreTranslateMessage(pMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
//窗口大小发生改变
|
||||||
|
void CaikeDlg::OnSize(UINT nType, int cx, int cy)
|
||||||
|
{
|
||||||
|
__super::OnSize(nType, cx, cy);
|
||||||
|
CRect rt, tt;
|
||||||
|
GetWindowRect(rt);
|
||||||
|
tt = { 0,0,25,25 };
|
||||||
|
tt.MoveToX(rt.Width() - 75);
|
||||||
|
MoveButton(1, tt);
|
||||||
|
tt.MoveToX(rt.Width() - 50);
|
||||||
|
MoveButton(2, tt);
|
||||||
|
MoveButton(3, tt);
|
||||||
|
tt.MoveToX(rt.Width() - 25);
|
||||||
|
MoveButton(4, tt);
|
||||||
|
// TODO: 在此处添加消息处理程序代码
|
||||||
|
}
|
||||||
|
|
||||||
|
//设置窗口最大和最小范围
|
||||||
|
void CaikeDlg::OnGetMinMaxInfo(MINMAXINFO* lpMMI)
|
||||||
|
{
|
||||||
|
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
||||||
|
lpMMI->ptMaxSize.y = GetSystemMetrics(SM_CYFULLSCREEN) + GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYDLGFRAME);
|
||||||
|
__super::OnGetMinMaxInfo(lpMMI);
|
||||||
|
}
|
||||||
|
|
||||||
|
//按下回车
|
||||||
|
void CaikeDlg::OnOK()
|
||||||
|
{
|
||||||
|
// TODO: 在此添加专用代码和/或调用基类
|
||||||
|
|
||||||
|
//__super::OnOK();
|
||||||
|
}
|
||||||
|
|
||||||
|
//窗口即将销毁
|
||||||
|
void CaikeDlg::OnDestroy()
|
||||||
|
{
|
||||||
|
__super::OnDestroy();
|
||||||
|
|
||||||
|
// TODO: 在此处添加消息处理程序代码
|
||||||
|
TrayMylcon(FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
//显示窗口(托盘消息)
|
||||||
|
void CaikeDlg::OnShowMenu()
|
||||||
|
{
|
||||||
|
// TODO: 在此添加命令处理程序代码
|
||||||
|
ShowWindow(SW_SHOWNORMAL);
|
||||||
|
SetForegroundWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
//关闭窗口(托盘消息)
|
||||||
|
void CaikeDlg::OnCloneMenu()
|
||||||
|
{
|
||||||
|
// TODO: 在此添加命令处理程序代码
|
||||||
|
CDialogEx::OnCancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
//初始化
|
||||||
|
VOID CaikeDlg::Initialize()
|
||||||
|
{
|
||||||
|
//获取程序路径
|
||||||
|
HMODULE module = GetModuleHandle(0);
|
||||||
|
TCHAR path[MAX_PATH] = { 0 };
|
||||||
|
GetModuleFileName(module, path, MAX_PATH); //获取本程序绝对路径
|
||||||
|
m_Path = path;
|
||||||
|
m_Path = m_Path.Left(m_Path.ReverseFind('\\') + 1);
|
||||||
|
|
||||||
|
//添加按钮
|
||||||
|
CImage img, img1;
|
||||||
|
img.Load(_T("../aike/res/background.jpg"));
|
||||||
|
SetBackground(img);
|
||||||
|
AddButton(1, CRect(0, 0, 25, 25));
|
||||||
|
SetLClick(1, [this](int i) {MinClick(i); });
|
||||||
|
AddButton(2, CRect(0, 0, 25, 25));
|
||||||
|
SetLClick(2, [this](int i) {MaxClick(i); });
|
||||||
|
AddButton(3, GetButtonRect(2));
|
||||||
|
SetLClick(3, [this](int i) {ReductionClick(i); });
|
||||||
|
AddButton(4, CRect(0, 0, 25, 25));
|
||||||
|
SetLClick(4, [this](int i) {CloseClick(i); });
|
||||||
|
|
||||||
|
CRect rt = { 0, 0, 180, 180 };
|
||||||
|
rt.MoveToXY(100, 100);
|
||||||
|
img.Destroy();
|
||||||
|
img.Load(_T("../aike/res/business.jpg"));
|
||||||
|
img1.Load(_T("../aike/res/business1.jpg"));
|
||||||
|
AddButton(10, rt, img, img1, img1, img1);
|
||||||
|
SetLClick(10, [this](int i) {text(i); });
|
||||||
|
|
||||||
|
|
||||||
|
rt.MoveToXY(300, 100);
|
||||||
|
img.Destroy();
|
||||||
|
img1.Destroy();
|
||||||
|
img.Load(_T("../aike/res/member.jpg"));
|
||||||
|
img1.Load(_T("../aike/res/member1.jpg"));
|
||||||
|
AddButton(11, rt, img, img1, img1, img1);
|
||||||
|
|
||||||
|
rt.MoveToXY(500, 100);
|
||||||
|
img.Destroy();
|
||||||
|
img1.Destroy();
|
||||||
|
img.Load(_T("../aike/res/report.jpg"));
|
||||||
|
img1.Load(_T("../aike/res/report1.jpg"));
|
||||||
|
AddButton(12, rt, img, img1, img1, img1);
|
||||||
|
|
||||||
|
rt.MoveToXY(100, 300);
|
||||||
|
img.Destroy();
|
||||||
|
img1.Destroy();
|
||||||
|
img.Load(_T("../aike/res/Booking.jpg"));
|
||||||
|
img1.Load(_T("../aike/res/Booking1.jpg"));
|
||||||
|
AddButton(13, rt, img, img1, img1, img1);
|
||||||
|
EnableButton(3, FALSE);
|
||||||
|
|
||||||
|
rt.MoveToXY(300, 300);
|
||||||
|
img.Destroy();
|
||||||
|
img1.Destroy();
|
||||||
|
img.Load(_T("../aike/res/inventory.jpg"));
|
||||||
|
img1.Load(_T("../aike/res/inventory1.jpg"));
|
||||||
|
AddButton(14, rt, img, img1, img1, img1);
|
||||||
|
EnableButton(3, FALSE);
|
||||||
|
|
||||||
|
rt.MoveToXY(500, 300);
|
||||||
|
img.Destroy();
|
||||||
|
img1.Destroy();
|
||||||
|
img.Load(_T("../aike/res/basis.jpg"));
|
||||||
|
img1.Load(_T("../aike/res/basis1.jpg"));
|
||||||
|
AddButton(15, rt, img, img1, img1, img1);
|
||||||
|
EnableButton(3, FALSE);
|
||||||
|
MaxClick(0);
|
||||||
|
|
||||||
|
//连接服务器
|
||||||
|
//SClien.Create();
|
||||||
|
//SClien.SetConnectFun([this](int i) {TCPState(i); });
|
||||||
|
//SClien.SetFunc([this]() {Process(); });
|
||||||
|
//SClien.Connect(ServerIP, ServerProt);
|
||||||
|
|
||||||
|
//连接数据库
|
||||||
|
if (!AdoSql.ConnectSQL(ServerIP, DataBase, UserName, AdoPass))
|
||||||
|
{
|
||||||
|
MessageBox(_T("数据库连接失败"), _T("温馨提示"));
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
TrayMylcon(TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
//添加系统托盘
|
||||||
|
BOOL CaikeDlg::TrayMylcon(BOOL bAdd)
|
||||||
|
{
|
||||||
|
BOOL bRet = FALSE;
|
||||||
|
NOTIFYICONDATA tnd;
|
||||||
|
tnd.cbSize = sizeof(NOTIFYICONDATA);
|
||||||
|
tnd.hWnd = m_hWnd;
|
||||||
|
tnd.uID = IDR_MAINFRAME; //设置要加载的图标
|
||||||
|
if (bAdd == TRUE)
|
||||||
|
{
|
||||||
|
tnd.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
|
||||||
|
tnd.uCallbackMessage = WM_TRAYICON_MSG; //给主对话框发送自定义消息
|
||||||
|
tnd.hIcon = LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_MAINFRAME));
|
||||||
|
_tcscpy_s(tnd.szTip, sizeof(tnd.szTip), _T("爱客宾馆软件客户端"));
|
||||||
|
bRet = Shell_NotifyIcon(NIM_ADD, &tnd);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetForegroundWindow();
|
||||||
|
bRet = Shell_NotifyIcon(NIM_DELETE, &tnd);
|
||||||
|
}
|
||||||
|
return bRet;
|
||||||
|
}
|
||||||
|
|
||||||
|
//点击系统托盘响应事件
|
||||||
|
LRESULT CaikeDlg::OnTrayCallBackMsg(WPARAM wparam, LPARAM lparam)
|
||||||
|
{
|
||||||
|
switch (lparam)
|
||||||
|
{
|
||||||
|
case WM_RBUTTONUP: //是右击
|
||||||
|
{
|
||||||
|
CMenu mMenu, * pMenu = NULL;
|
||||||
|
CPoint pt;
|
||||||
|
mMenu.LoadMenu(IDR_TRAY_MENU); //加载右击弹出的菜单
|
||||||
|
pMenu = mMenu.GetSubMenu(0);
|
||||||
|
GetCursorPos(&pt);
|
||||||
|
SetForegroundWindow();
|
||||||
|
pMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, this);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case WM_LBUTTONDBLCLK: //鼠标左键双击
|
||||||
|
if (IsIconic() == TRUE) //获取是否是最小化
|
||||||
|
{
|
||||||
|
ShowWindow(SW_SHOWNORMAL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ShowWindow(SW_SHOW);
|
||||||
|
}
|
||||||
|
SetForegroundWindow();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return LRESULT();
|
||||||
|
}
|
||||||
|
|
||||||
|
//最小化窗口
|
||||||
|
VOID CaikeDlg::MinClick(int id)
|
||||||
|
{
|
||||||
|
ShowWindow(SW_HIDE);
|
||||||
|
}
|
||||||
|
|
||||||
|
//最大化窗口
|
||||||
|
VOID CaikeDlg::MaxClick(int id)
|
||||||
|
{
|
||||||
|
ShowWindow(SW_MAXIMIZE);
|
||||||
|
ShowButton(2,FALSE);
|
||||||
|
ShowButton(3, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
//还原窗口
|
||||||
|
VOID CaikeDlg::ReductionClick(int id)
|
||||||
|
{
|
||||||
|
ShowWindow(SW_RESTORE);
|
||||||
|
ShowButton(2, TRUE);
|
||||||
|
ShowButton(3, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
//关闭窗口
|
||||||
|
VOID CaikeDlg::CloseClick(int id)
|
||||||
|
{
|
||||||
|
if (MessageBox(_T("确定退出本软件?"), _T("温馨提示"), MB_OKCANCEL) == IDOK)
|
||||||
|
{
|
||||||
|
CDialogEx::OnCancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//TCP连接状态
|
||||||
|
VOID CaikeDlg::TCPState(int type)
|
||||||
|
{
|
||||||
|
CStringA str = "nihao";
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case -1: //连接失败
|
||||||
|
MessageBox(_T("连接失败"));
|
||||||
|
break;
|
||||||
|
case 0: //连接成功
|
||||||
|
//SClien.Send(str, str.GetLength());
|
||||||
|
break;
|
||||||
|
case 1: //连接中断
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//处理SOCKET消息
|
||||||
|
VOID CaikeDlg::Process()
|
||||||
|
{
|
||||||
|
//CStringA str;
|
||||||
|
//CString tmp;
|
||||||
|
//SClien.GetMsg(str);
|
||||||
|
//Json json;
|
||||||
|
//int lenth = json.parse(str);
|
||||||
|
//while (lenth != -1)
|
||||||
|
//{
|
||||||
|
// SClien.RemoveMsg(lenth);
|
||||||
|
// Process(json);
|
||||||
|
// if (str.GetLength() == lenth)
|
||||||
|
// {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// SClien.GetMsg(str);
|
||||||
|
// lenth = json.parse(str);
|
||||||
|
//}
|
||||||
|
//return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//处理SOCKET消息
|
||||||
|
VOID CaikeDlg::Process(Json json)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID CaikeDlg::text(int id)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
64
aike/aikeDlg.h
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
|
||||||
|
// aikeDlg.h: 头文件
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
// CaikeDlg 对话框
|
||||||
|
class CaikeDlg : public CDialogEx,MyDialog
|
||||||
|
{
|
||||||
|
// 构造
|
||||||
|
public:
|
||||||
|
CaikeDlg(CWnd* pParent = nullptr); // 标准构造函数
|
||||||
|
|
||||||
|
// 对话框数据
|
||||||
|
#ifdef AFX_DESIGN_TIME
|
||||||
|
enum { IDD = IDD_AIKE_DIALOG };
|
||||||
|
#endif
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
|
||||||
|
|
||||||
|
|
||||||
|
// 实现
|
||||||
|
protected:
|
||||||
|
HICON m_hIcon;
|
||||||
|
|
||||||
|
// 生成的消息映射函数
|
||||||
|
virtual BOOL OnInitDialog();
|
||||||
|
afx_msg void OnPaint();
|
||||||
|
afx_msg HCURSOR OnQueryDragIcon();
|
||||||
|
DECLARE_MESSAGE_MAP()
|
||||||
|
public:
|
||||||
|
//变量
|
||||||
|
ADOSQL AdoSql; //连接数据库
|
||||||
|
SocketClien SClien; //连接服务器
|
||||||
|
CString m_Path; //本程序路径
|
||||||
|
CString ServerIP = _T("sr.nceissoft.com"); //服务器IP
|
||||||
|
UINT ServerProt = 1995; //服务器端口
|
||||||
|
CString DataBase = _T("aike"); //数据库名称
|
||||||
|
CString UserName = _T("sa"); //数据库用户名
|
||||||
|
CString AdoPass = _T("Ncsr88352518"); //数据库密码
|
||||||
|
|
||||||
|
//MFC回调函数
|
||||||
|
virtual BOOL PreTranslateMessage(MSG* pMsg); //截获窗口消息
|
||||||
|
afx_msg void OnSize(UINT nType, int cx, int cy); //窗口大小发生改变
|
||||||
|
afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI); //设置窗口最大和最小范围
|
||||||
|
virtual void OnOK(); //按下回车
|
||||||
|
afx_msg void OnDestroy(); //窗口即将销毁
|
||||||
|
afx_msg void OnShowMenu(); //显示窗口(托盘消息)
|
||||||
|
afx_msg void OnCloneMenu(); //关闭窗口(托盘消息)
|
||||||
|
|
||||||
|
//自己创建的函数
|
||||||
|
VOID Initialize(); //初始化
|
||||||
|
BOOL TrayMylcon(BOOL bAdd); //添加系统托盘
|
||||||
|
LRESULT OnTrayCallBackMsg(WPARAM wparam, LPARAM lparam); //点击系统托盘响应事件
|
||||||
|
VOID MinClick(int id); //最小化窗口
|
||||||
|
VOID MaxClick(int id); //最大化窗口
|
||||||
|
VOID ReductionClick(int id); //还原窗口
|
||||||
|
VOID CloseClick(int id); //关闭窗口
|
||||||
|
VOID TCPState(int type); //TCP连接状态
|
||||||
|
VOID Process(); //处理SOCKET消息
|
||||||
|
VOID Process(Json json); //处理SOCKET消息
|
||||||
|
VOID text(int id);
|
||||||
|
};
|
49
aike/framework.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef VC_EXTRALEAN
|
||||||
|
#define VC_EXTRALEAN // 从 Windows 头中排除极少使用的资料
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "targetver.h"
|
||||||
|
|
||||||
|
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 某些 CString 构造函数将是显式的
|
||||||
|
|
||||||
|
// 关闭 MFC 的一些常见且经常可放心忽略的隐藏警告消息
|
||||||
|
#define _AFX_ALL_WARNINGS
|
||||||
|
|
||||||
|
#include <afxwin.h> // MFC 核心组件和标准组件
|
||||||
|
#include <afxext.h> // MFC 扩展
|
||||||
|
|
||||||
|
|
||||||
|
#include <afxdisp.h> // MFC 自动化类
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _AFX_NO_OLE_SUPPORT
|
||||||
|
#include <afxdtctl.h> // MFC 对 Internet Explorer 4 公共控件的支持
|
||||||
|
#endif
|
||||||
|
#ifndef _AFX_NO_AFXCMN_SUPPORT
|
||||||
|
#include <afxcmn.h> // MFC 对 Windows 公共控件的支持
|
||||||
|
#endif // _AFX_NO_AFXCMN_SUPPORT
|
||||||
|
|
||||||
|
#include <afxcontrolbars.h> // MFC 支持功能区和控制条
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#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
|
||||||
|
|
||||||
|
|
5
aike/pch.cpp
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
// pch.cpp: 与预编译标头对应的源文件
|
||||||
|
|
||||||
|
#include "pch.h"
|
||||||
|
|
||||||
|
// 当使用预编译的头时,需要使用此源文件,编译才能成功。
|
23
aike/pch.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// pch.h: 这是预编译标头文件。
|
||||||
|
// 下方列出的文件仅编译一次,提高了将来生成的生成性能。
|
||||||
|
// 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。
|
||||||
|
// 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。
|
||||||
|
// 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。
|
||||||
|
|
||||||
|
#ifndef PCH_H
|
||||||
|
#define PCH_H
|
||||||
|
|
||||||
|
// 添加要在此处预编译的标头
|
||||||
|
#include "framework.h"
|
||||||
|
|
||||||
|
#include "D:/代码/ToolsLib/ToolsLib/ToolsLib.h"
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
#pragma comment(lib,"D:/代码/ToolsLib/x64/Debug/ToolsLib.lib")
|
||||||
|
#else
|
||||||
|
#pragma comment(lib,"D:/代码/ToolsLib/x64/Release/ToolsLib.lib")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif //PCH_H
|
BIN
aike/res/0.jpg
Normal file
After Width: | Height: | Size: 858 B |
BIN
aike/res/1.jpg
Normal file
After Width: | Height: | Size: 859 B |
BIN
aike/res/Booking.jpg
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
aike/res/Booking1.jpg
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
aike/res/aike.ico
Normal file
After Width: | Height: | Size: 66 KiB |
BIN
aike/res/aike.rc2
Normal file
BIN
aike/res/background.jpg
Normal file
After Width: | Height: | Size: 7.4 KiB |
BIN
aike/res/basis.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
aike/res/basis1.jpg
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
aike/res/business.jpg
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
aike/res/business1.jpg
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
aike/res/inventory.jpg
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
aike/res/inventory1.jpg
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
aike/res/member.jpg
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
aike/res/member1.jpg
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
aike/res/report.jpg
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
aike/res/report1.jpg
Normal file
After Width: | Height: | Size: 2.3 KiB |
22
aike/resource.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
//{{NO_DEPENDENCIES}}
|
||||||
|
// Microsoft Visual C++ 生成的包含文件。
|
||||||
|
// 供 aike.rc 使用
|
||||||
|
//
|
||||||
|
#define IDR_TRAY_MENU 1
|
||||||
|
#define IDD_AIKE_DIALOG 102
|
||||||
|
#define IDR_MAINFRAME 128
|
||||||
|
#define ID_32771 32771
|
||||||
|
#define ID_32772 32772
|
||||||
|
#define ID_SHOW_MENU 32773
|
||||||
|
#define ID_CLONE_MENU 32774
|
||||||
|
|
||||||
|
// Next default values for new objects
|
||||||
|
//
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||||
|
#define _APS_NEXT_RESOURCE_VALUE 132
|
||||||
|
#define _APS_NEXT_COMMAND_VALUE 32775
|
||||||
|
#define _APS_NEXT_CONTROL_VALUE 1000
|
||||||
|
#define _APS_NEXT_SYMED_VALUE 101
|
||||||
|
#endif
|
||||||
|
#endif
|
8
aike/targetver.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。
|
||||||
|
|
||||||
|
//如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h,并
|
||||||
|
// 将 _WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。
|
||||||
|
|
||||||
|
#include <SDKDDKVer.h>
|