Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Github Issue #4: Error every time screen resolution changes #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Mouse Debouncer/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ static uint32_t double_click_threshold_ms = 60;
static uint64_t double_click_threshold;
static uint64_t counts_per_second;
static bool use_qpc;
static bool has_icon_been_shown = false;

int CALLBACK wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ PWSTR lpCmdLine, _In_ int nCmdShow)
{
Expand Down Expand Up @@ -287,7 +288,7 @@ static bool AddNotifyIcon(const HINSTANCE hInstance, const HWND hWnd, const bool
}

// Try to add the icon to the notification area...
if (!Shell_NotifyIcon(NIM_ADD, &notify_icon_data))
if (!Shell_NotifyIcon(NIM_ADD, &notify_icon_data) && has_icon_been_shown == false)
{
ShowErrorMessageBox(L"The notify icon couldn't be added.\nError code: %lu", GetLastError());
return false;
Expand All @@ -300,6 +301,9 @@ static bool AddNotifyIcon(const HINSTANCE hInstance, const HWND hWnd, const bool
return false;
}

// Save that the notify icon has been already added.
has_icon_been_shown = true;

return true;
}

Expand Down