Skip to content

Commit

Permalink
Merge pull request #130 from chrdavis/user/chris/remember_width_and_h…
Browse files Browse the repository at this point in the history
…eight

Persist width and height of UIForETW
  • Loading branch information
randomascii authored Jan 24, 2019
2 parents 6641d85 + 54710c2 commit 5db617a
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ Kristof Mattei
Alexander Riccio
Bradley Grainger
Michael Winterberg
Suresh Kumar Ponnusamy
Suresh Kumar Ponnusamy
Chris Davis
2 changes: 1 addition & 1 deletion UIforETW/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Most important tasks:
- [ ] Handle the duplicate copies of etwproviders.man.
- [ ] Add some unit tests.
- [ ] Translate the error codes on starting tracing into English, and give advice.
- [ ] Remember window height
- [X] Remember window height

To-do eventually:
- [ ] Should have the option to run arbitrary scripts after each trace is recorded.
Expand Down
2 changes: 2 additions & 0 deletions UIforETW/Support.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ void CUIforETWDlg::TransferSettings(bool saving)
// settings, to avoid privacy problems.
{ L"InputTracing", reinterpret_cast<int*>(&InputTracing_), kKeyLoggerOff, kKeyLoggerAnonymized },
{ L"TracingMode", reinterpret_cast<int*>(&tracingMode_), kTracingToMemory, kHeapTracingToFile },
{ L"PreviousWidth", &previousWidth_, minWidth_, maxWidth_ },
{ L"PreviousHeight", &previousHeight_, minHeight_, maxHeight_ },
};

for (auto& m : ints)
Expand Down
21 changes: 19 additions & 2 deletions UIforETW/UIforETWDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,19 @@ BOOL CUIforETWDlg::OnInitDialog()

CRect windowRect;
GetWindowRect(&windowRect);
initialWidth_ = lastWidth_ = windowRect.Width();
initialHeight_ = lastHeight_ = windowRect.Height();
initialWidth_ = minWidth_ = lastWidth_ = windowRect.Width();
initialHeight_ = minHeight_ = lastHeight_ = windowRect.Height();

// Ensure previousWidth_ and previousHeight_ are valid
if (previousWidth_ < initialWidth_)
{
previousWidth_ = initialWidth_;
}

if (previousHeight_ < initialHeight_)
{
previousHeight_ = initialHeight_;
}

// Win+Ctrl+R is used to trigger recording of traces. This is compatible with
// wprui. If this is changed then be sure to change the text on *both* buttons
Expand Down Expand Up @@ -689,6 +700,10 @@ BOOL CUIforETWDlg::OnInitDialog()
if (bVersionChecks_)
versionCheckerThread_.StartVersionCheckerThread(this);

const UINT flags = SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOACTIVATE;
// Resize our window per the previous dimensions if we have them
SetWindowPos(nullptr, 0, 0, previousWidth_, previousHeight_, flags);

return TRUE; // return TRUE unless you set the focus to a control
}

Expand Down Expand Up @@ -1734,8 +1749,10 @@ void CUIforETWDlg::OnSize(UINT nType, int /*cx*/, int /*cy*/)
GetWindowRect(&windowRect);
const int xDelta = windowRect.Width() - lastWidth_;
lastWidth_ += xDelta;
previousWidth_ = lastWidth_;
const int yDelta = windowRect.Height() - lastHeight_;
lastHeight_ += yDelta;
previousHeight_ = lastHeight_;

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

Expand Down
7 changes: 7 additions & 0 deletions UIforETW/UIforETWDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,13 @@ class CUIforETWDlg : public CDialog
int initialHeight_ = 0;
int lastWidth_ = 0;
int lastHeight_ = 0;
int minWidth_ = 0;
int minHeight_ = 0;
const int maxWidth_ = 3000;
const int maxHeight_ = 3000;
// Width and height persisted to settings
int previousWidth_ = 0;
int previousHeight_ = 0;

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

0 comments on commit 5db617a

Please sign in to comment.