Skip to content
This repository was archived by the owner on May 29, 2025. It is now read-only.

Commit 1339ade

Browse files
committed
Implement feature to remember width and height of UIForETW Dialog
This implements the requested feature to persist the window width and height to the app settings and respect it at launch.
1 parent df8ca8a commit 1339ade

File tree

5 files changed

+29
-2
lines changed

5 files changed

+29
-2
lines changed

CONTRIBUTORS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ Kristof Mattei
1414
Alexander Riccio
1515
Bradley Grainger
1616
Michael Winterberg
17-
Suresh Kumar Ponnusamy
17+
Suresh Kumar Ponnusamy
18+
Chris Davis

UIforETW/ReadMe.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ Most important tasks:
8686
- [ ] Handle the duplicate copies of etwproviders.man.
8787
- [ ] Add some unit tests.
8888
- [ ] Translate the error codes on starting tracing into English, and give advice.
89-
- [ ] Remember window height
89+
- [X] Remember window height
9090

9191
To-do eventually:
9292
- [ ] Should have the option to run arbitrary scripts after each trace is recorded.

UIforETW/Support.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ void CUIforETWDlg::TransferSettings(bool saving)
9191
// settings, to avoid privacy problems.
9292
{ L"InputTracing", reinterpret_cast<int*>(&InputTracing_), kKeyLoggerOff, kKeyLoggerAnonymized },
9393
{ L"TracingMode", reinterpret_cast<int*>(&tracingMode_), kTracingToMemory, kHeapTracingToFile },
94+
{ L"PreviousWidth", &previousWidth_, minWidth_, maxWidth_ },
95+
{ L"PreviousHeight", &previousHeight_, minHeight_, maxHeight_ },
9496
};
9597

9698
for (auto& m : ints)

UIforETW/UIforETWDlg.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,17 @@ BOOL CUIforETWDlg::OnInitDialog()
354354
initialWidth_ = lastWidth_ = windowRect.Width();
355355
initialHeight_ = lastHeight_ = windowRect.Height();
356356

357+
// Ensure previousWidth_ and previousHeight_ are valid
358+
if (previousWidth_ < initialWidth_)
359+
{
360+
previousWidth_ = initialWidth_;
361+
}
362+
363+
if (previousHeight_ < initialHeight_)
364+
{
365+
previousHeight_ = initialHeight_;
366+
}
367+
357368
// Win+Ctrl+R is used to trigger recording of traces. This is compatible with
358369
// wprui. If this is changed then be sure to change the text on *both* buttons
359370
// in the main window.
@@ -689,6 +700,10 @@ BOOL CUIforETWDlg::OnInitDialog()
689700
if (bVersionChecks_)
690701
versionCheckerThread_.StartVersionCheckerThread(this);
691702

703+
const UINT flags = SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOACTIVATE;
704+
// Resize our window per the previous dimensions if we have them
705+
SetWindowPos(nullptr, 0, 0, previousWidth_, previousHeight_, flags);
706+
692707
return TRUE; // return TRUE unless you set the focus to a control
693708
}
694709

@@ -1734,8 +1749,10 @@ void CUIforETWDlg::OnSize(UINT nType, int /*cx*/, int /*cy*/)
17341749
GetWindowRect(&windowRect);
17351750
const int xDelta = windowRect.Width() - lastWidth_;
17361751
lastWidth_ += xDelta;
1752+
previousWidth_ = lastWidth_;
17371753
const int yDelta = windowRect.Height() - lastHeight_;
17381754
lastHeight_ += yDelta;
1755+
previousHeight_ = lastHeight_;
17391756

17401757
const UINT flags = SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOACTIVATE;
17411758

UIforETW/UIforETWDlg.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,13 @@ class CUIforETWDlg : public CDialog
211211
int initialHeight_ = 0;
212212
int lastWidth_ = 0;
213213
int lastHeight_ = 0;
214+
const int minWidth_ = 870;
215+
const int minHeight_ = 398;
216+
const int maxWidth_ = 3000;
217+
const int maxHeight_ = 3000;
218+
// Width and height persisted to settings
219+
int previousWidth_ = 0;
220+
int previousHeight_ = 0;
214221

215222
void SetSymbolPath();
216223
// Call this to retrieve a directory from an environment variable, or use

0 commit comments

Comments
 (0)