-
Notifications
You must be signed in to change notification settings - Fork 0
/
TOOLTIP_REPO.h
72 lines (59 loc) · 2.5 KB
/
TOOLTIP_REPO.h
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#pragma once
#include <windows.h>
#include <vector>
#include <Shlobj.h>
// Tooltip: small comments when mouseover
class TOOLTIP_REPO
{
public:
/// <summary>
/// Retrieves the current instance of the Tooltip Repo
/// </summary>
static TOOLTIP_REPO& Instance() //https://stackoverflow.com/questions/1008019/c-singleton-design-pattern
{
static TOOLTIP_REPO instance; // Guaranteed to be destroyed.
// Instantiated on first use.
return instance;
}
TOOLTIP_REPO(TOOLTIP_REPO const&) = delete;
void operator=(TOOLTIP_REPO const&) = delete;
/// <summary>
/// Enables or disables tooltips for the whole application
/// </summary>
/// <param name="activate">TRUE enables tooltips, FALSE disables them</param>
void ActivateTooltips(BOOL activate);
/// <summary>
/// Create a tooltip for a control that can manage it, eg buttons, trackbars, static and more
/// <para>For Static controls make sure to add the SS_NOTIFY style</para>
/// </summary>
/// <param name="hWnd">The control that will show the tooltip</param>
/// <param name="messageID">Resource String's ID</param>
/// <returns>The hwnd of the tooltip control</returns>
HWND CreateToolTip(HWND hWnd, WORD messageID);
/// <summary>
/// A hack to create a tooltip for the RECT of a window
/// <para>Use only if CreateToolTip() doesn't work</para>
/// </summary>
HWND CreateToolTipForRect(HWND hwndParent, WORD messageID);
//· Create a tooltip for a tool(control) that cant handle tooltips by itself, inside a parent window
/// <summary>
/// A hack to create a tooltip for a control that can't handle them
/// <para>Basically adds it to the parent and assigns a RECT the size of your control</para>
/// <para>If anything is resized the position of the tooltip will change</para>
/// <para>Use only if CreateToolTip() doesn't work</para>
/// </summary>
HWND CreateToolTipForRect(HWND hwndParent, HWND hwndTool, WORD messageID);
//TODO(fran): I think the hInstance should be obtained from each hwnd
/// <summary>
/// Set the hInstance that will be used by every tooltip to retrieve their corresponding text string
/// </summary>
/// <returns>The previuos hInstance</returns>
HINSTANCE SetHInstance(HINSTANCE hInst);
private:
TOOLTIP_REPO();
~TOOLTIP_REPO();
HINSTANCE hInstance=NULL;//TODO(fran): should we ask for the instance to each control? for now we dont really need it
BOOL active = FALSE;
std::vector<HWND> tooltips;
void AddTooltip(HWND tooltip);
};