Skip to content

Commit

Permalink
Fix bug: #3
Browse files Browse the repository at this point in the history
  • Loading branch information
wang606 committed Feb 24, 2024
1 parent c25301d commit be8d378
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
32 changes: 19 additions & 13 deletions src/WmaskImage.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "WmaskImage.h"

std::vector<std::wstring> globImagePaths(std::wstring dirPath);
std::vector<std::wstring> _GlobImagePaths(std::wstring dirPath);
Rect _GetImageGeometry(int parentW, int parentH, int imageW, int imageH, const WmaskConfig* pWC);
bool wmaskImageUpdateResource(HWND hwnd);
bool wmaskImageUpdateSize(HWND hwnd);
Expand Down Expand Up @@ -30,7 +30,7 @@ HWND CreateWmaskImageWindow(HWND parent, const WmaskConfig* pWC) {
WmaskImageData* pData = new WmaskImageData();
pData->wc = pWC;
pData->parentHwnd = parent;
pData->imagePaths = globImagePaths(pWC->dirpath);
pData->imagePaths = _GlobImagePaths(pWC->dirpath);
if (pData->imagePaths.size() < 1) {
// MessageBox(NULL, (L"no image found under directory: " + pWC->dirpath).c_str(), L"Error", MB_ICONERROR | MB_OK);
delete pData;
Expand All @@ -50,7 +50,7 @@ HWND CreateWmaskImageWindow(HWND parent, const WmaskConfig* pWC) {
return hwnd;
}

std::vector<std::wstring> globImagePaths(std::wstring dirPath) {
std::vector<std::wstring> _GlobImagePaths(std::wstring dirPath) {
std::vector<std::wstring> imagePaths;
std::wstring imagePath, imageFileName;
WIN32_FIND_DATA fileData;
Expand Down Expand Up @@ -155,7 +155,12 @@ bool wmaskImageUpdateSize(HWND hwnd) {
RECT parentRect;
GetClientRect(pData->parentHwnd, &parentRect);
pData->hwndRect = _GetImageGeometry(parentRect.right, parentRect.bottom, pData->curImage->GetWidth(), pData->curImage->GetHeight(), &pData->wc);
return SetWindowPos(hwnd, HWND_TOP, 0, 0, pData->hwndRect.Width, pData->hwndRect.Height, SWP_NOMOVE);
BOOL a = SetWindowPos(hwnd, HWND_TOP, 0, 0, pData->hwndRect.Width, pData->hwndRect.Height, SWP_NOMOVE);
a = SetWindowPos(hwnd, HWND_TOP, 0, 0, pData->hwndRect.Width, pData->hwndRect.Height, SWP_NOMOVE);
a = SetWindowPos(hwnd, HWND_TOP, 0, 0, pData->hwndRect.Width, pData->hwndRect.Height, SWP_NOMOVE);
a = SetWindowPos(hwnd, HWND_TOP, 0, 0, pData->hwndRect.Width, pData->hwndRect.Height, SWP_NOMOVE);
a = SetWindowPos(hwnd, HWND_TOP, 0, 0, pData->hwndRect.Width, pData->hwndRect.Height, SWP_NOMOVE);
return a;
}

bool wmaskImageUpdateImage(HWND hwnd) {
Expand Down Expand Up @@ -210,17 +215,18 @@ bool wmaskImageOnTimeout(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRE
needUpdateImage = true;
}
// check for size change.
WINDOWPLACEMENT wndpl = { 0 };
wndpl.length = sizeof(WINDOWPLACEMENT);
GetWindowPlacement(pData->parentHwnd, &wndpl);
RECT parentRect;
GetClientRect(pData->parentHwnd, &parentRect);
if (pData->parentCmdShow != wndpl.showCmd || parentRect.right != pData->parentW || parentRect.bottom != pData->parentH) {
pData->parentCmdShow = wndpl.showCmd;
pData->parentW = parentRect.right;
pData->parentH = parentRect.bottom;
needUpdateSize = true;
needUpdateImage = true;
if (parentRect.right != pData->parentW || parentRect.bottom != pData->parentH) {
pData->parentW = parentRect.right;
pData->parentH = parentRect.bottom;
WINDOWPLACEMENT wndpl = { 0 };
wndpl.length = sizeof(WINDOWPLACEMENT);
GetWindowPlacement(pData->parentHwnd, &wndpl);
if (wndpl.showCmd != 2) {
needUpdateSize = true;
needUpdateImage = true;
}
}
if (needUpdateResource) result &= wmaskImageUpdateResource(hwnd);
if (needUpdateSize) result &= wmaskImageUpdateSize(hwnd);
Expand Down
2 changes: 1 addition & 1 deletion src/WmaskMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void RegisterWmaskMainClass() {

HWND CreateWmaskMainWindow() {
// UI init
HWND wmaskMainHwnd = CreateWindowEx(NULL, L"WmaskMain", L"Wmask win32 v1.0.0", WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU, CW_USEDEFAULT, CW_USEDEFAULT, 640, 480, NULL, NULL, gHINSTANCE, NULL);
HWND wmaskMainHwnd = CreateWindowEx(NULL, L"WmaskMain", L"Wmask win32 v1.0.1", WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU, CW_USEDEFAULT, CW_USEDEFAULT, 640, 480, NULL, NULL, gHINSTANCE, NULL);
configListHwnd = CreateWindow(L"LISTBOX", NULL, WS_VISIBLE | WS_CHILD | LBS_STANDARD | LBS_DISABLENOSCROLL, 10, 10, 320, 430, wmaskMainHwnd, (HMENU)ID_ConfigList, gHINSTANCE, NULL);
CreateWindow(L"BUTTON", L"New", WS_VISIBLE | WS_CHILD, 348, 430 - 24 - 4, 80, 24, wmaskMainHwnd, (HMENU)ID_New, gHINSTANCE, NULL);
CreateWindow(L"BUTTON", L"Setting", WS_VISIBLE | WS_CHILD, 348 + 80 + 10, 430 - 24 - 4, 80, 24, wmaskMainHwnd, (HMENU)ID_Setting, gHINSTANCE, NULL);
Expand Down
4 changes: 4 additions & 0 deletions 更新日志.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@
- 改善了内存回收,解决了使用过久可能会造成的explorer响应迟钝问题
- 去除了淡入淡出功能
- 改进了explorer上方菜单栏挡住图片的问题

## Release v1.0.1 (2024.02.24)

- Fix bug: [#3](https://github.com/wang606/Wmask/issues/3)

0 comments on commit be8d378

Please sign in to comment.