Skip to content

Commit

Permalink
修bug:窗口完全初始化之前无法取得正确窗口尺寸
Browse files Browse the repository at this point in the history
  • Loading branch information
jark006 committed Oct 6, 2024
1 parent 110fb3b commit ec94adb
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions jarkViewer/src/jarkViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ struct CurImageParameter {
zoomList.push_back(zoomFitWindow);
else {
if (zoomIndex >= zoomList.size())
zoomIndex = zoomList.size() - 1;
zoomIndex = (int)zoomList.size() - 1;
}
std::sort(zoomList.begin(), zoomList.end());
}
Expand Down Expand Up @@ -143,6 +143,7 @@ class JarkViewerApp : public D2D1App {
Cood mousePos, mousePressPos;
int winWidth = 800;
int winHeight = 600;
bool hasInitWinSize = false;

ImageDatabase imgDB;

Expand Down Expand Up @@ -234,13 +235,10 @@ class JarkViewerApp : public D2D1App {
}

curPar.framesPtr = imgDB.getPtr(imgFileList[curFileIdx]);
if (m_pD2DDeviceContext) {
D2D1_SIZE_U displaySize = m_pD2DDeviceContext->GetPixelSize();
curPar.Init(displaySize.width, displaySize.height);
}
else {
curPar.Init(800, 600);
Utils::log("m_pD2DDeviceContext nullptr");

if (m_pD2DDeviceContext == nullptr) {
MessageBoxW(NULL, L"窗口创建失败!", L"错误", MB_ICONERROR);
exit(-1);
}

return hr;
Expand Down Expand Up @@ -498,7 +496,13 @@ class JarkViewerApp : public D2D1App {
CreateWindowSizeDependentResources();
}

curPar.handleNewSize(winWidth, winHeight);
if (hasInitWinSize) {
curPar.handleNewSize(winWidth, winHeight);
}
else {
hasInitWinSize = true;
curPar.Init(winWidth, winHeight);
}
} break;

case ActionENUM::preImg: {
Expand Down

0 comments on commit ec94adb

Please sign in to comment.