xoblite™ / Blackbox for Windows bb5 | RC6 preview | 0.25.2.14
http://xoblite.net/
Tooltips Class Reference

#include <Tooltips.h>

Public Member Functions

 Tooltips ()
 
 ~Tooltips ()
 
void Initialize (HINSTANCE hInstance, HWND hWnd)
 
void CreateTooltipsWindow ()
 
void ToggleTooltips ()
 
void CreateToolTip (unsigned int tipID, RECT tipRect, char tipText[MAX_LINE_LENGTH], int tipType)
 
void DeleteToolTip (unsigned int tipID, int tipType)
 
void DeleteAllTooltips ()
 

Public Attributes

HINSTANCE hOwnerInstance
 
HWND hOwnerWnd
 
HWND hToolTipsWnd
 

Constructor & Destructor Documentation

◆ Tooltips()

Tooltips::Tooltips ( )
40{
41 hToolTipsWnd = NULL;
42}
HWND hToolTipsWnd
Definition Tooltips.h:62

◆ ~Tooltips()

Tooltips::~Tooltips ( )
47{
48 if (hToolTipsWnd) DestroyWindow(hToolTipsWnd);
49}

Member Function Documentation

◆ Initialize()

void Tooltips::Initialize ( HINSTANCE hInstance,
HWND hWnd )
54{
55 hOwnerInstance = hInstance;
56 hOwnerWnd = hWnd;
57
59}
Settings * pSettings
Definition Blackbox.cpp:46
bool taskbarTooltips
Definition Settings.h:227
HWND hOwnerWnd
Definition Tooltips.h:61
void CreateTooltipsWindow()
Definition Tooltips.cpp:66
HINSTANCE hOwnerInstance
Definition Tooltips.h:60

◆ CreateTooltipsWindow()

void Tooltips::CreateTooltipsWindow ( )
67{
68 hToolTipsWnd = CreateWindowEx(
69 WS_EX_TOOLWINDOW | WS_EX_TOPMOST, // window style
70 TOOLTIPS_CLASS, // pre-defined system class for tooltips
71 NULL, // window name
72 WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, // window parameters
73 CW_USEDEFAULT, // x position
74 CW_USEDEFAULT, // y position
75 CW_USEDEFAULT, // window width
76 CW_USEDEFAULT, // window height
77 hOwnerWnd, // owner window
78 NULL, // no menu
79 hOwnerInstance, // hInstance
80 NULL // no window creation data
81 );
82
83 if (!hToolTipsWnd)
84 {
85 MessageBox(0, "Error creating tooltips window!", "BBToolbar", MB_OK | MB_ICONERROR | MB_TOPMOST);
86 Log("Toolbar: Error creating tooltips window!", NULL);
87 return;
88 }
89
90 //====================
91
92 // Set some tooltips configuration parameters...
93 SendMessage(hToolTipsWnd, TTM_SETMAXTIPWIDTH, 0, 300); // -> Sets the maximum width (in pixels) for tooltips, i.e. before breaking the text into multiple lines
94 RECT tipMargin = { 4, 4, 4, 4 };
95 SendMessage(hToolTipsWnd, TTM_SETMARGIN, 0, (LPARAM)&tipMargin); // -> Sets the top, left, bottom, and right margins (in pixels) for tooltips
96 SendMessage(hToolTipsWnd, TTM_SETDELAYTIME, (WPARAM)(DWORD)TTDT_AUTOPOP, (LPARAM)MAKELONG(2000, 0)); // -> Sets the amount of time (in ms) a tooltip remains visible if the pointer is stationary within its bounding rectangle
97 SendMessage(hToolTipsWnd, TTM_SETDELAYTIME, (WPARAM)(DWORD)TTDT_INITIAL, (LPARAM)MAKELONG(100, 0)); // -> Sets the amount of time (in ms) a pointer must remain stationary within the bounding rectangle before the tooltip appears
98 SendMessage(hToolTipsWnd, TTM_SETDELAYTIME, (WPARAM)(DWORD)TTDT_RESHOW, (LPARAM)MAKELONG(10, 0)); // -> Sets the amount of time (in ms) it takes for a subsequent tooltip to appear as the pointer moves from one bounding rectangle to another
99
100 // Set the tooltips colours... (background+text)
101// SendMessage(hToolTipsWnd, TTM_SETTIPBKCOLOR, (WPARAM)pSettings->Toolbar->TextColor, 0);
102// SendMessage(hToolTipsWnd, TTM_SETTIPTEXTCOLOR, (WPARAM)pSettings->Toolbar->Color, 0);
103// SendMessage(hToolTipsWnd, TTM_SETTIPBKCOLOR, (WPARAM)pSettings->ToolbarWindowLabel->Color, 0);
104// SendMessage(hToolTipsWnd, TTM_SETTIPTEXTCOLOR, (WPARAM)pSettings->ToolbarWindowLabel->TextColor, 0);
105 SendMessage(hToolTipsWnd, TTM_SETTIPBKCOLOR, (WPARAM)0x000000, 0); // -> Sets the background color for tooltips
106 SendMessage(hToolTipsWnd, TTM_SETTIPTEXTCOLOR, (WPARAM)0xffffff, 0); // -> Sets the text color for tooltips
107}
void Log(LPCSTR des, LPCSTR line)
Definition BBApi.cpp:638

◆ ToggleTooltips()

void Tooltips::ToggleTooltips ( )
115{
116 // Should we enable or disable taskbar tooltips?
118 {
119 pSettings->taskbarTooltips = false;
121 if (hToolTipsWnd) DestroyWindow(hToolTipsWnd);
122 hToolTipsWnd = NULL;
123 }
124 else
125 {
128 pToolbar->UpdateToolbarWindow(); // This will also create taskbar tooltips if/as applicable...
129 }
130
131 // Save the new setting to xoblite.rc...
132 WriteBool(pSettings->xobrcFile, "xoblite.taskbar.tooltips:", pSettings->taskbarTooltips);
133}
void WriteBool(LPCSTR fp, LPCSTR keyword, bool value)
Definition BBApi.cpp:3131
Toolbar * pToolbar
Definition Blackbox.cpp:48
char xobrcFile[MAX_LINE_LENGTH]
Definition Settings.h:405
void UpdateToolbarWindow()
Definition Toolbar.cpp:883
void DeleteAllTooltips()
Definition Tooltips.cpp:190

◆ CreateToolTip()

void Tooltips::CreateToolTip ( unsigned int tipID,
RECT tipRect,
char tipText[MAX_LINE_LENGTH],
int tipType )
141{
142 if (!hToolTipsWnd) return;
143
144 // Fill in the basics of the TOOLINFO structure...
145 TOOLINFO ti;
146 ZeroMemory(&ti, sizeof(ti));
147 ti.cbSize = sizeof(TOOLINFO);
148 ti.hwnd = pToolbar->hToolbarWnd;
149 ti.uId = tipID;
150
151 // Check to see if the tooltip exists...
152 bool exists = SendMessage(hToolTipsWnd, TTM_GETTOOLINFO, 0, (LPARAM)(LPTOOLINFO)&ti) ? true : false;
153
154 // Complete the rest of the TOOLINFO structure...
155 ti.uFlags = TTF_SUBCLASS | TTF_CENTERTIP; // -> Center the tooltip below the item...
156 ti.hinst = pToolbar->hToolbarInstance;
157 ti.lpszText = tipText;
158 ti.rect = tipRect;
159
160 // If it exists, modify the tooltip, if not, add it...
161 if (exists) SendMessage(hToolTipsWnd, TTM_SETTOOLINFO, 0, (LPARAM)(LPTOOLINFO)&ti);
162 else SendMessage(hToolTipsWnd, TTM_ADDTOOL, 0, (LPARAM)&ti);
163}
HWND hToolbarWnd
Definition Toolbar.h:89
HINSTANCE hToolbarInstance
Definition Toolbar.h:87

◆ DeleteToolTip()

void Tooltips::DeleteToolTip ( unsigned int tipID,
int tipType )
171{
172 if (!hToolTipsWnd) return;
173
174 // Fill in the basics of the TOOLINFO structure...
175 TOOLINFO ti;
176 ZeroMemory(&ti, sizeof(ti));
177 ti.cbSize = sizeof(TOOLINFO);
178 ti.hwnd = pToolbar->hToolbarWnd;
179 ti.uId = tipID;
180
181 // Check to see if the tooltip exists, and if so delete it...
182// bool exists = SendMessage(hToolTipsWnd, TTM_GETTOOLINFO, 0, (LPARAM)(LPTOOLINFO)&ti) ? true : false;
183// if (exists) SendMessage(hToolTipsWnd, TTM_DELTOOL, 0, (LPARAM)(LPTOOLINFO)&ti);
184 SendMessage(hToolTipsWnd, TTM_DELTOOL, 0, (LPARAM)(LPTOOLINFO)&ti);
185}

◆ DeleteAllTooltips()

void Tooltips::DeleteAllTooltips ( )
191{
192 // Delete any existing taskbar tooltips...
193 for (int i=0; i < (int)pTaskbar->taskList.size(); i++)
194 {
196 }
197}
Taskbar * pTaskbar
Definition Blackbox.cpp:47
#define TOOLTIP_TYPE_TASK
Definition Tooltips.h:39
vector< taskListItem * > taskList
Definition Taskbar.h:148
void DeleteToolTip(unsigned int tipID, int tipType)
Definition Tooltips.cpp:170

Member Data Documentation

◆ hOwnerInstance

HINSTANCE Tooltips::hOwnerInstance

◆ hOwnerWnd

HWND Tooltips::hOwnerWnd

◆ hToolTipsWnd

HWND Tooltips::hToolTipsWnd