19 |
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
20 |
* |
* |
21 |
*/ |
*/ |
22 |
|
|
23 |
#ifdef HAVE_CONFIG_H |
#ifdef HAVE_CONFIG_H |
24 |
#include <config.h> |
#include <config.h> |
25 |
#endif |
#endif |
26 |
|
|
27 |
#include <windows.h> |
#include <windows.h> |
28 |
|
#include <stdio.h> |
29 |
|
|
30 |
#include "wptW32API.h" |
#include "wptW32API.h" |
31 |
|
#include "wptTypes.h" |
32 |
|
|
33 |
#define PD_WINDOWNAME "WinPT_TrayPop" |
#define PD_WINDOWNAME "WinPT_TrayPop" |
34 |
#define PD_TIMER_IDENTIFIER 23 |
#define PD_TIMER_IDENTIFIER 23 |
56 |
static void |
static void |
57 |
paint_alert (HDC *p_hdc, PAINTSTRUCT *p_ps) |
paint_alert (HDC *p_hdc, PAINTSTRUCT *p_ps) |
58 |
{ |
{ |
59 |
|
RECT recttext; |
60 |
|
HFONT hOldFont; |
61 |
|
HFONT hFont; |
62 |
|
UINT dtFormat; |
63 |
|
int text_height; |
64 |
|
|
65 |
SetBkMode(*p_hdc, TRANSPARENT); |
SetBkMode(*p_hdc, TRANSPARENT); |
66 |
HFONT hFont = CreateFont( |
hFont = CreateFont( |
67 |
13, // height of font (in css px-style) |
13, // height of font (in css px-style) |
68 |
0, // average character width |
0, // average character width |
69 |
0, // angle of escapement |
0, // angle of escapement |
80 |
FF_DONTCARE, // pitch and family |
FF_DONTCARE, // pitch and family |
81 |
"Tahoma" // typeface name |
"Tahoma" // typeface name |
82 |
); |
); |
83 |
|
hOldFont = (HFONT) SelectObject (*p_hdc, hFont); |
84 |
HFONT hOldFont = (HFONT) SelectObject (*p_hdc, hFont); |
|
|
RECT recttext; |
|
85 |
recttext.top = 0; |
recttext.top = 0; |
86 |
recttext.bottom = PD_TRAYPOP_HEIGHT - 2; |
recttext.bottom = PD_TRAYPOP_HEIGHT - 2; |
87 |
recttext.left = 10; |
recttext.left = 10; |
93 |
LineTo (*p_hdc, 0, PD_TRAYPOP_HEIGHT - 3); |
LineTo (*p_hdc, 0, PD_TRAYPOP_HEIGHT - 3); |
94 |
LineTo (*p_hdc, 0, 0); |
LineTo (*p_hdc, 0, 0); |
95 |
|
|
96 |
UINT dtFormat = DT_END_ELLIPSIS | DT_NOPREFIX | DT_WORDBREAK; |
dtFormat = DT_END_ELLIPSIS | DT_NOPREFIX | DT_WORDBREAK; |
97 |
|
|
98 |
/* determine text height */ |
/* determine text height */ |
99 |
int text_height = DrawText (*p_hdc, store_text (NULL), |
text_height = DrawText (*p_hdc, store_text (NULL), |
100 |
-1, &recttext, |
-1, &recttext, |
101 |
dtFormat | DT_CENTER | DT_CALCRECT); |
dtFormat | DT_CENTER | DT_CALCRECT); |
102 |
|
|
103 |
/* vertically center text in the box */ |
/* vertically center text in the box */ |
104 |
recttext.top = PD_TRAYPOP_HEIGHT/2 - text_height/2 - 5; |
recttext.top = PD_TRAYPOP_HEIGHT/2 - text_height/2 - 5; |
181 |
show_msg (HWND hParentWnd, int millis, LPCTSTR string) |
show_msg (HWND hParentWnd, int millis, LPCTSTR string) |
182 |
{ |
{ |
183 |
RECT parent; |
RECT parent; |
|
int nWndWidth = PD_TRAYPOP_WIDTH; |
|
|
int nWndHeight = PD_TRAYPOP_HEIGHT; |
|
184 |
MSG msg; |
MSG msg; |
185 |
HWND hWnd; |
HWND hWnd; |
186 |
UINT_PTR timer; |
UINT_PTR timer; |
187 |
WNDCLASS wClass; |
WNDCLASS wClass; |
188 |
|
int nWndWidth = PD_TRAYPOP_WIDTH; |
189 |
|
int nWndHeight = PD_TRAYPOP_HEIGHT; |
190 |
|
|
191 |
store_text (string); |
store_text (string); |
192 |
GetWindowRect (hParentWnd, &parent); |
GetWindowRect (hParentWnd, &parent); |
|
|
|
193 |
init_wclass (&wClass, glob_hinst); |
init_wclass (&wClass, glob_hinst); |
194 |
RegisterClass (&wClass); |
RegisterClass (&wClass); |
195 |
|
|
196 |
hWnd = CreateWindowEx (WS_EX_TOOLWINDOW | WS_EX_TOPMOST, |
hWnd = CreateWindowEx (WS_EX_TOOLWINDOW | WS_EX_TOPMOST, |
197 |
PD_WINDOWNAME, PD_WINDOWNAME, |
PD_WINDOWNAME, PD_WINDOWNAME, |
198 |
WS_POPUP, |
WS_POPUP, |
200 |
(parent.bottom + parent.top) / 2, |
(parent.bottom + parent.top) / 2, |
201 |
nWndWidth - 2, nWndHeight - 2, |
nWndWidth - 2, nWndHeight - 2, |
202 |
NULL, NULL, glob_hinst, NULL); |
NULL, NULL, glob_hinst, NULL); |
203 |
if (hWnd == NULL) |
if (!hWnd) |
204 |
return 0; |
BUG (NULL); |
205 |
else { /* Ensure parent never loses focus. */ |
else { /* Ensure parent never loses focus. */ |
206 |
ShowWindow (hWnd, SW_SHOW); |
ShowWindow (hWnd, SW_SHOW); |
207 |
UpdateWindow (hWnd); |
UpdateWindow (hWnd); |