回答編集履歴
1
質問事項では無いが、実行中のツールチップについての追記
test
CHANGED
@@ -11,3 +11,323 @@
|
|
11
11
|
0. リビルドして、EXEをタスクバーにピン留めすると「何でもOK」とツールチップに表示される
|
12
12
|
|
13
13
|
![アプリケーションページ](261bbdbeeb59436b600f6b1d8d3e11ae.png)
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
### 実行中のツールチップについての追記
|
18
|
+
|
19
|
+
実行中のツールチップが制御できないじゃんって事でちょっと調べました。
|
20
|
+
|
21
|
+
※Microsoft.WindowsAPICodePack-Shellを使えばプログレスバーやアイコンのオーバーレイなんかはできるんだけど、何故かツールチップは無い
|
22
|
+
|
23
|
+
- 下記コードを「TaskbarAPI.cs」みたいな感じで追加([コピペ元](https://wpf.2000things.com/2014/03/19/1032-show-progress-on-windows-taskbar-icon/))
|
24
|
+
|
25
|
+
```C#
|
26
|
+
|
27
|
+
using System;
|
28
|
+
|
29
|
+
using System.Runtime.InteropServices;
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
namespace TeraTaskBarTooltip {
|
34
|
+
|
35
|
+
internal enum HResult {
|
36
|
+
|
37
|
+
Ok = 0x0000
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
// Add more constants here, if necessary
|
42
|
+
|
43
|
+
}
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
public enum TaskbarProgressBarStatus {
|
48
|
+
|
49
|
+
NoProgress = 0,
|
50
|
+
|
51
|
+
Indeterminate = 0x1,
|
52
|
+
|
53
|
+
Normal = 0x2,
|
54
|
+
|
55
|
+
Error = 0x4,
|
56
|
+
|
57
|
+
Paused = 0x8
|
58
|
+
|
59
|
+
}
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
internal enum ThumbButtonMask {
|
64
|
+
|
65
|
+
Bitmap = 0x1,
|
66
|
+
|
67
|
+
Icon = 0x2,
|
68
|
+
|
69
|
+
Tooltip = 0x4,
|
70
|
+
|
71
|
+
THB_FLAGS = 0x8
|
72
|
+
|
73
|
+
}
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
[Flags]
|
78
|
+
|
79
|
+
internal enum ThumbButtonOptions {
|
80
|
+
|
81
|
+
Enabled = 0x00000000,
|
82
|
+
|
83
|
+
Disabled = 0x00000001,
|
84
|
+
|
85
|
+
DismissOnClick = 0x00000002,
|
86
|
+
|
87
|
+
NoBackground = 0x00000004,
|
88
|
+
|
89
|
+
Hidden = 0x00000008,
|
90
|
+
|
91
|
+
NonInteractive = 0x00000010
|
92
|
+
|
93
|
+
}
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
|
98
|
+
|
99
|
+
internal struct ThumbButton {
|
100
|
+
|
101
|
+
///
|
102
|
+
|
103
|
+
/// WPARAM value for a THUMBBUTTON being clicked.
|
104
|
+
|
105
|
+
///
|
106
|
+
|
107
|
+
internal const int Clicked = 0x1800;
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
[MarshalAs(UnmanagedType.U4)]
|
112
|
+
|
113
|
+
internal ThumbButtonMask Mask;
|
114
|
+
|
115
|
+
internal uint Id;
|
116
|
+
|
117
|
+
internal uint Bitmap;
|
118
|
+
|
119
|
+
internal IntPtr Icon;
|
120
|
+
|
121
|
+
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
|
122
|
+
|
123
|
+
internal string Tip;
|
124
|
+
|
125
|
+
[MarshalAs(UnmanagedType.U4)]
|
126
|
+
|
127
|
+
internal ThumbButtonOptions Flags;
|
128
|
+
|
129
|
+
}
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
internal enum SetTabPropertiesOption {
|
134
|
+
|
135
|
+
None = 0x0,
|
136
|
+
|
137
|
+
UseAppThumbnailAlways = 0x1,
|
138
|
+
|
139
|
+
UseAppThumbnailWhenActive = 0x2,
|
140
|
+
|
141
|
+
UseAppPeekAlways = 0x4,
|
142
|
+
|
143
|
+
UseAppPeekWhenActive = 0x8
|
144
|
+
|
145
|
+
}
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
// using System.Runtime.InteropServices
|
150
|
+
|
151
|
+
[ComImportAttribute()]
|
152
|
+
|
153
|
+
[GuidAttribute("c43dc798-95d1-4bea-9030-bb99e2983a1a")]
|
154
|
+
|
155
|
+
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
|
156
|
+
|
157
|
+
internal interface ITaskbarList4 {
|
158
|
+
|
159
|
+
// ITaskbarList
|
160
|
+
|
161
|
+
[PreserveSig]
|
162
|
+
|
163
|
+
void HrInit();
|
164
|
+
|
165
|
+
[PreserveSig]
|
166
|
+
|
167
|
+
void AddTab(IntPtr hwnd);
|
168
|
+
|
169
|
+
[PreserveSig]
|
170
|
+
|
171
|
+
void DeleteTab(IntPtr hwnd);
|
172
|
+
|
173
|
+
[PreserveSig]
|
174
|
+
|
175
|
+
void ActivateTab(IntPtr hwnd);
|
176
|
+
|
177
|
+
[PreserveSig]
|
178
|
+
|
179
|
+
void SetActiveAlt(IntPtr hwnd);
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
// ITaskbarList2
|
184
|
+
|
185
|
+
[PreserveSig]
|
186
|
+
|
187
|
+
void MarkFullscreenWindow(
|
188
|
+
|
189
|
+
IntPtr hwnd,
|
190
|
+
|
191
|
+
[MarshalAs(UnmanagedType.Bool)] bool fFullscreen);
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
// ITaskbarList3
|
196
|
+
|
197
|
+
[PreserveSig]
|
198
|
+
|
199
|
+
void SetProgressValue(IntPtr hwnd, UInt64 ullCompleted, UInt64 ullTotal);
|
200
|
+
|
201
|
+
[PreserveSig]
|
202
|
+
|
203
|
+
void SetProgressState(IntPtr hwnd, TaskbarProgressBarStatus tbpFlags);
|
204
|
+
|
205
|
+
[PreserveSig]
|
206
|
+
|
207
|
+
void RegisterTab(IntPtr hwndTab, IntPtr hwndMDI);
|
208
|
+
|
209
|
+
[PreserveSig]
|
210
|
+
|
211
|
+
void UnregisterTab(IntPtr hwndTab);
|
212
|
+
|
213
|
+
[PreserveSig]
|
214
|
+
|
215
|
+
void SetTabOrder(IntPtr hwndTab, IntPtr hwndInsertBefore);
|
216
|
+
|
217
|
+
[PreserveSig]
|
218
|
+
|
219
|
+
void SetTabActive(IntPtr hwndTab, IntPtr hwndInsertBefore, uint dwReserved);
|
220
|
+
|
221
|
+
[PreserveSig]
|
222
|
+
|
223
|
+
HResult ThumbBarAddButtons(
|
224
|
+
|
225
|
+
IntPtr hwnd,
|
226
|
+
|
227
|
+
uint cButtons,
|
228
|
+
|
229
|
+
[MarshalAs(UnmanagedType.LPArray)] ThumbButton[] pButtons);
|
230
|
+
|
231
|
+
[PreserveSig]
|
232
|
+
|
233
|
+
HResult ThumbBarUpdateButtons(
|
234
|
+
|
235
|
+
IntPtr hwnd,
|
236
|
+
|
237
|
+
uint cButtons,
|
238
|
+
|
239
|
+
[MarshalAs(UnmanagedType.LPArray)] ThumbButton[] pButtons);
|
240
|
+
|
241
|
+
[PreserveSig]
|
242
|
+
|
243
|
+
void ThumbBarSetImageList(IntPtr hwnd, IntPtr himl);
|
244
|
+
|
245
|
+
[PreserveSig]
|
246
|
+
|
247
|
+
void SetOverlayIcon(
|
248
|
+
|
249
|
+
IntPtr hwnd,
|
250
|
+
|
251
|
+
IntPtr hIcon,
|
252
|
+
|
253
|
+
[MarshalAs(UnmanagedType.LPWStr)] string pszDescription);
|
254
|
+
|
255
|
+
[PreserveSig]
|
256
|
+
|
257
|
+
void SetThumbnailTooltip(
|
258
|
+
|
259
|
+
IntPtr hwnd,
|
260
|
+
|
261
|
+
[MarshalAs(UnmanagedType.LPWStr)] string pszTip);
|
262
|
+
|
263
|
+
[PreserveSig]
|
264
|
+
|
265
|
+
void SetThumbnailClip(
|
266
|
+
|
267
|
+
IntPtr hwnd,
|
268
|
+
|
269
|
+
IntPtr prcClip);
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
// ITaskbarList4
|
274
|
+
|
275
|
+
void SetTabProperties(IntPtr hwndTab, SetTabPropertiesOption stpFlags);
|
276
|
+
|
277
|
+
}
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
[GuidAttribute("56FDF344-FD6D-11d0-958A-006097C9A090")]
|
282
|
+
|
283
|
+
[ClassInterfaceAttribute(ClassInterfaceType.None)]
|
284
|
+
|
285
|
+
[ComImportAttribute()]
|
286
|
+
|
287
|
+
internal class CTaskbarList { }
|
288
|
+
|
289
|
+
}
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
```
|
294
|
+
|
295
|
+
- 使い方(下記はコンソールアプリケーション)
|
296
|
+
|
297
|
+
```C#
|
298
|
+
|
299
|
+
using System;
|
300
|
+
|
301
|
+
using System.Diagnostics;
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
namespace TeraTaskBarTooltip {
|
306
|
+
|
307
|
+
class Program {
|
308
|
+
|
309
|
+
private static ITaskbarList4 _taskbarList;
|
310
|
+
|
311
|
+
static void Main(string[] args) {
|
312
|
+
|
313
|
+
_taskbarList= (ITaskbarList4)new CTaskbarList();
|
314
|
+
|
315
|
+
_taskbarList.HrInit();
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
_taskbarList.SetThumbnailTooltip(Process.GetCurrentProcess().MainWindowHandle, "何でも\nOK");
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
Console.WriteLine("aiueo");
|
324
|
+
|
325
|
+
Console.Read();
|
326
|
+
|
327
|
+
}
|
328
|
+
|
329
|
+
}
|
330
|
+
|
331
|
+
}
|
332
|
+
|
333
|
+
```
|