forked from crom83/cromfarplugs
-
Notifications
You must be signed in to change notification settings - Fork 10
/
taskbarIcon.cpp
44 lines (38 loc) · 1.13 KB
/
taskbarIcon.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "stdafx.h"
#include "taskbarIcon.h"
#include <plugin.hpp>
TaskBarIcon::TaskBarIcon() : lastState(S_NO_PROGRESS)
{
value.Total = 100;
}
TaskBarIcon::~TaskBarIcon()
{
if (lastState != S_NO_PROGRESS)
fInfo.AdvControl(&MainGuid, ACTL_SETPROGRESSSTATE, TBPS_NOPROGRESS, nullptr);
}
void TaskBarIcon::SetState(State state, double param)
{
switch (state)
{
case S_PROGRESS:
if (param > 1) param = 1;
value.Completed = int(param * 100);
fInfo.AdvControl(&MainGuid, ACTL_SETPROGRESSSTATE, TBPS_NORMAL, nullptr);
fInfo.AdvControl(&MainGuid, ACTL_SETPROGRESSVALUE, 0, &value);
break;
case S_NO_PROGRESS:
fInfo.AdvControl(&MainGuid, ACTL_PROGRESSNOTIFY, 0, nullptr);
fInfo.AdvControl(&MainGuid, ACTL_SETPROGRESSSTATE, TBPS_NOPROGRESS, nullptr);
break;
case S_WORKING:
fInfo.AdvControl(&MainGuid, ACTL_SETPROGRESSSTATE, TBPS_INDETERMINATE, nullptr);
break;
case S_ERROR:
fInfo.AdvControl(&MainGuid, ACTL_SETPROGRESSSTATE, TBPS_ERROR, nullptr);
break;
case S_PAUSED:
fInfo.AdvControl(&MainGuid, ACTL_SETPROGRESSSTATE, TBPS_PAUSED, nullptr);
break;
}
lastState = state;
}