From 24dbd429702759025b093c774e97e86250febaf0 Mon Sep 17 00:00:00 2001 From: Haibo Date: Thu, 3 May 2018 22:21:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8D=E5=86=8D=E8=87=AA=E5=8A=A8=E5=85=B3?= =?UTF-8?q?=E9=97=AD=E6=8E=A7=E5=88=B6=E5=8F=B0=EF=BC=9B=E4=B8=8D=E5=86=8D?= =?UTF-8?q?=E7=A6=81=E7=94=A8Circle=E5=92=8CEllipse=E7=9A=84=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=AE=BD=E9=AB=98=E5=87=BD=E6=95=B0=EF=BC=9B=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E5=B7=A5=E7=A8=8B=E6=96=87=E4=BB=B6=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/Base/Window.cpp | 32 +++++++++++++-------------- core/Tool/Path.cpp | 8 +++---- core/e2dbase.h | 2 +- core/e2dshape.h | 20 ----------------- project/vs2012/Easy2D.vcxproj | 2 ++ project/vs2012/Easy2D.vcxproj.filters | 6 +++++ project/vs2013/Easy2D.vcxproj | 2 ++ project/vs2013/Easy2D.vcxproj.filters | 6 +++++ 8 files changed, 36 insertions(+), 42 deletions(-) diff --git a/core/Base/Window.cpp b/core/Base/Window.cpp index 882d9d95..8d383c0a 100644 --- a/core/Base/Window.cpp +++ b/core/Base/Window.cpp @@ -5,8 +5,6 @@ // 窗口句柄 static HWND s_HWnd = nullptr; -// 是否打开控制台 -static bool s_bShowConsole = false; bool e2d::Window::__init() @@ -72,18 +70,12 @@ bool e2d::Window::__init() { // 禁用输入法 Window::setTypewritingEnable(false); - // 查找是否存在控制台 - HWND hwnd = ::GetConsoleWindow(); - if (hwnd) + // 禁用控制台关闭按钮 + HWND consoleHWnd = ::GetConsoleWindow(); + if (consoleHWnd) { - // 禁用控制台关闭按钮 - HMENU hmenu = ::GetSystemMenu(hwnd, FALSE); + HMENU hmenu = ::GetSystemMenu(consoleHWnd, FALSE); ::RemoveMenu(hmenu, SC_CLOSE, MF_BYCOMMAND); - // 默认隐藏控制台 - if (!s_bShowConsole) - { - ::ShowWindow(hwnd, SW_HIDE); - } } } else @@ -204,9 +196,8 @@ e2d::String e2d::Window::getTitle() return wszTitle; } -void e2d::Window::showConsole(bool show /* = true */) +void e2d::Window::showConsole(bool show) { - s_bShowConsole = show; // 查找已存在的控制台句柄 HWND hwnd = ::GetConsoleWindow(); // 关闭控制台 @@ -271,9 +262,11 @@ void e2d::Window::setTypewritingEnable(bool bEnable) LRESULT e2d::Window::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { LRESULT result = 0; + bool hasHandled = false; switch (message) { + // 处理窗口大小变化消息 case WM_SIZE: { @@ -294,6 +287,7 @@ LRESULT e2d::Window::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar InvalidateRect(hWnd, NULL, FALSE); } result = 0; + hasHandled = true; break; // 重绘窗口 @@ -303,6 +297,7 @@ LRESULT e2d::Window::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar ValidateRect(hWnd, NULL); } result = 0; + hasHandled = true; break; // 窗口关闭消息 @@ -315,21 +310,24 @@ LRESULT e2d::Window::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar } } result = 0; + hasHandled = true; break; + // 窗口销毁消息 case WM_DESTROY: { PostQuitMessage(0); } result = 1; + hasHandled = true; break; - default: + } + + if (!hasHandled) { result = DefWindowProc(hWnd, message, wParam, lParam); } - } - return result; } \ No newline at end of file diff --git a/core/Tool/Path.cpp b/core/Tool/Path.cpp index 6fdbadf6..d977d472 100644 --- a/core/Tool/Path.cpp +++ b/core/Tool/Path.cpp @@ -133,12 +133,12 @@ e2d::String e2d::Path::getFileExtension(String filePath) { String fileExtension; // 找到文件名中的最后一个 '.' 的位置 - int pos = filePath.getWString().find_last_of(L'.'); - // 判断 pos 是否是个有效位置 - if (pos != -1) + size_t pos = filePath.getWString().find_last_of(L'.'); + // 判断 pos 是否是有效位置 + if (pos != std::wstring::npos) { // 截取扩展名 - fileExtension = filePath.subtract(pos); + fileExtension = filePath.subtract(static_cast(pos)); // 转换为小写字母 fileExtension = fileExtension.toLower(); } diff --git a/core/e2dbase.h b/core/e2dbase.h index 68a5d6f1..ce746453 100644 --- a/core/e2dbase.h +++ b/core/e2dbase.h @@ -87,7 +87,7 @@ public: // 打开/隐藏控制台 static void showConsole( - bool bShow = true + bool show ); // 是否允许响应输入法 diff --git a/core/e2dshape.h b/core/e2dshape.h index aa96481f..7f50a573 100644 --- a/core/e2dshape.h +++ b/core/e2dshape.h @@ -200,16 +200,6 @@ public: double radius ); -public: - // 禁用的函数 - void setWidth() {} - - // 禁用的函数 - void setHeight() {} - - // 禁用的函数 - void setSize() {} - protected: // 渲染轮廓 virtual void _renderLine() override; @@ -265,16 +255,6 @@ public: double radiusY ); -public: - // 禁用的函数 - void setWidth() {} - - // 禁用的函数 - void setHeight() {} - - // 禁用的函数 - void setSize() {} - protected: // 渲染轮廓 virtual void _renderLine() override; diff --git a/project/vs2012/Easy2D.vcxproj b/project/vs2012/Easy2D.vcxproj index a5006f03..098fedef 100644 --- a/project/vs2012/Easy2D.vcxproj +++ b/project/vs2012/Easy2D.vcxproj @@ -20,6 +20,7 @@ + @@ -76,6 +77,7 @@ + diff --git a/project/vs2012/Easy2D.vcxproj.filters b/project/vs2012/Easy2D.vcxproj.filters index 39bc7437..ad2f2a8b 100644 --- a/project/vs2012/Easy2D.vcxproj.filters +++ b/project/vs2012/Easy2D.vcxproj.filters @@ -213,6 +213,12 @@ Custom + + Action + + + Transition + diff --git a/project/vs2013/Easy2D.vcxproj b/project/vs2013/Easy2D.vcxproj index e0688492..aff6613a 100644 --- a/project/vs2013/Easy2D.vcxproj +++ b/project/vs2013/Easy2D.vcxproj @@ -164,6 +164,7 @@ + @@ -220,6 +221,7 @@ + diff --git a/project/vs2013/Easy2D.vcxproj.filters b/project/vs2013/Easy2D.vcxproj.filters index 45d94251..51219103 100644 --- a/project/vs2013/Easy2D.vcxproj.filters +++ b/project/vs2013/Easy2D.vcxproj.filters @@ -213,6 +213,12 @@ Custom + + Action + + + Transition +