From 0d050a763cb4cb3539d0f277e25df9dbe3e52d9e Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Thu, 27 Dec 2018 14:55:29 +0300 Subject: CrashDumper: code cleanning --- plugins/CrashDumper/src/crshdmp.cpp | 7 --- plugins/CrashDumper/src/stdafx.h | 2 +- plugins/CrashDumper/src/ui.cpp | 93 ++++++++++++++++--------------------- 3 files changed, 41 insertions(+), 61 deletions(-) diff --git a/plugins/CrashDumper/src/crshdmp.cpp b/plugins/CrashDumper/src/crshdmp.cpp index 024da9fd36..7d9baf7c23 100644 --- a/plugins/CrashDumper/src/crshdmp.cpp +++ b/plugins/CrashDumper/src/crshdmp.cpp @@ -18,12 +18,9 @@ along with this program. If not, see . #include "stdafx.h" -int OptionsInit(WPARAM wParam, LPARAM); - CMPlugin g_plugin; LCID packlcid; -//HANDLE hCrashLogFolder, hVerInfoFolder; HANDLE hVerInfoFolder; HMODULE hMsftedit; @@ -35,7 +32,6 @@ wchar_t CrashLogFolder[MAX_PATH], VersionInfoFolder[MAX_PATH]; bool servicemode, clsdates, dtsubfldr, catchcrashes, needrestart = 0; -//extern HWND hViewWnd; CDlgBase *pViewDialog = nullptr; ///////////////////////////////////////////////////////////////////////////////////////// @@ -319,7 +315,6 @@ static int ModulesLoaded(WPARAM, LPARAM) static int PreShutdown(WPARAM, LPARAM) { - DestroyAllWindows(); UploadClose(); return 0; } @@ -366,8 +361,6 @@ int CMPlugin::Load() int CMPlugin::Unload() { - DestroyAllWindows(); - if ((catchcrashes && !needrestart) || (!catchcrashes && needrestart)) DestroyExceptionHandler(); diff --git a/plugins/CrashDumper/src/stdafx.h b/plugins/CrashDumper/src/stdafx.h index 911fd55b5d..7799b59a4e 100644 --- a/plugins/CrashDumper/src/stdafx.h +++ b/plugins/CrashDumper/src/stdafx.h @@ -144,7 +144,6 @@ void SetExceptionHandler(void); void RemoveExceptionHandler(void); extern CDlgBase *pViewDialog; -void DestroyAllWindows(void); void UploadInit(void); void UploadClose(void); @@ -155,4 +154,5 @@ void InitIcons(void); HICON LoadIconEx(int iconId, bool big = false); HANDLE GetIconHandle(int iconId); +int OptionsInit(WPARAM wParam, LPARAM); INT_PTR ViewVersionInfo(WPARAM wParam, LPARAM); diff --git a/plugins/CrashDumper/src/ui.cpp b/plugins/CrashDumper/src/ui.cpp index 43f52356aa..5730518fd9 100644 --- a/plugins/CrashDumper/src/ui.cpp +++ b/plugins/CrashDumper/src/ui.cpp @@ -18,50 +18,48 @@ along with this program. If not, see . #include "stdafx.h" -HWND hViewWnd; - -HDWP MyResizeWindow(HDWP hDwp, HWND hwndDlg, HWND hwndCtrl, int nHorizontalOffset, int nVerticalOffset, int nWidthOffset, int nHeightOffset) +class CViewVersionInfo : public CDlgBase { - if (nullptr == hwndDlg) /* Wine fix. */ - return hDwp; - // get current bounding rectangle - RECT rcinit; - GetWindowRect(hwndCtrl, &rcinit); - - // get current top left point - POINT pt; - pt.x = rcinit.left; - pt.y = rcinit.top; - ScreenToClient(hwndDlg, &pt); - - return DeferWindowPos(hDwp, hwndCtrl, nullptr, - pt.x + nHorizontalOffset, - pt.y + nVerticalOffset, - rcinit.right - rcinit.left + nWidthOffset, - rcinit.bottom - rcinit.top + nHeightOffset, - SWP_NOZORDER); -} + DWORD m_flags; -BOOL MyResizeGetOffset(HWND hwndCtrl, int nWidth, int nHeight, int* nDx, int* nDy) -{ - RECT rcinit; + CCtrlButton m_btnCancel, m_btnCopyClip, m_btnCopyFile; + CCtrlRichEdit m_redtViewVersionInfo; - // get current bounding rectangle - GetWindowRect(hwndCtrl, &rcinit); + HDWP MyResizeWindow(HDWP hDwp, HWND hwndCtrl, int nHorizontalOffset, int nVerticalOffset, int nWidthOffset, int nHeightOffset) + { + if (nullptr == m_hwnd) /* Wine fix. */ + return hDwp; + // get current bounding rectangle + RECT rcinit; + GetWindowRect(hwndCtrl, &rcinit); + + // get current top left point + POINT pt; + pt.x = rcinit.left; + pt.y = rcinit.top; + ScreenToClient(m_hwnd, &pt); + + return DeferWindowPos(hDwp, hwndCtrl, nullptr, + pt.x + nHorizontalOffset, + pt.y + nVerticalOffset, + rcinit.right - rcinit.left + nWidthOffset, + rcinit.bottom - rcinit.top + nHeightOffset, + SWP_NOZORDER); + } - // calculate offsets - *nDx = nWidth - (rcinit.right - rcinit.left); - *nDy = nHeight - (rcinit.bottom - rcinit.top); + BOOL MyResizeGetOffset(int nWidth, int nHeight, int* nDx, int* nDy) + { + RECT rcinit; - return rcinit.bottom != rcinit.top && nHeight > 0; -} + // get current bounding rectangle + GetWindowRect(m_redtViewVersionInfo.GetHwnd(), &rcinit); -class CViewVersionInfo : public CDlgBase -{ - DWORD m_flags; + // calculate offsets + *nDx = nWidth - (rcinit.right - rcinit.left); + *nDy = nHeight - (rcinit.bottom - rcinit.top); - CCtrlButton m_btnCancel, m_btnCopyClip, m_btnCopyFile; - CCtrlRichEdit m_redtViewVersionInfo; + return rcinit.bottom != rcinit.top && nHeight > 0; + } public: CViewVersionInfo::CViewVersionInfo(DWORD flags) : @@ -103,7 +101,6 @@ public: bool CViewVersionInfo::OnClose() override { - hViewWnd = nullptr; Window_FreeIcon_IcoLib(m_hwnd); Utils_SaveWindowPosition(m_hwnd, NULL, MODULENAME, "ViewInfo_"); if (pViewDialog == this) @@ -132,12 +129,12 @@ public: GetWindowRect(m_btnCopyFile.GetHwnd(), &rc); int dx, dy; - if (MyResizeGetOffset(m_redtViewVersionInfo.GetHwnd(), LOWORD(m_flags) - 20, HIWORD(m_flags) - 30 - (rc.bottom - rc.top), &dx, &dy)) { + if (MyResizeGetOffset(LOWORD(m_flags) - 20, HIWORD(m_flags) - 30 - (rc.bottom - rc.top), &dx, &dy)) { HDWP hDwp = BeginDeferWindowPos(4); - hDwp = MyResizeWindow(hDwp, m_hwnd, m_btnCopyFile.GetHwnd(), 0, dy, 0, 0); - hDwp = MyResizeWindow(hDwp, m_hwnd, m_btnCopyClip.GetHwnd(), dx / 2, dy, 0, 0); - hDwp = MyResizeWindow(hDwp, m_hwnd, m_btnCancel.GetHwnd(), dx, dy, 0, 0); - hDwp = MyResizeWindow(hDwp, m_hwnd, m_redtViewVersionInfo.GetHwnd(), 0, 0, dx, dy); + hDwp = MyResizeWindow(hDwp, m_btnCopyFile.GetHwnd(), 0, dy, 0, 0); + hDwp = MyResizeWindow(hDwp, m_btnCopyClip.GetHwnd(), dx / 2, dy, 0, 0); + hDwp = MyResizeWindow(hDwp, m_btnCancel.GetHwnd(), dx, dy, 0, 0); + hDwp = MyResizeWindow(hDwp, m_redtViewVersionInfo.GetHwnd(), 0, 0, dx, dy); EndDeferWindowPos(hDwp); } return 0; @@ -211,16 +208,6 @@ INT_PTR ViewVersionInfo(WPARAM wParam, LPARAM) return 0; } -///////////////////////////////////////////////////////////////////////////////////////// - -void DestroyAllWindows(void) -{ - if (hViewWnd != nullptr) { - DestroyWindow(hViewWnd); - hViewWnd = nullptr; - } -} - ///////////////////////////////////////////////////////////////////////////////////////// // options -- cgit v1.2.3