1 /*
2 * R : A Computer Language for Statistical Data Analysis
3 * Copyright (C) 1999 Guido Masarotto
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, a copy is available at
17 * https://www.R-project.org/Licenses/
18 */
19
20 /*
21 * Support for tooltip
22 * int addtooltip(obj,char *) (on error return 0)
23 */
24
25 /*
26 This file is an add-on to GraphApp, a cross-platform C graphics library.
27 */
28
29 #include "internal.h"
30 static HWND hwndToolTip = 0;
31 #ifndef TOOLTIPS_CLASS
32 #include "commctrl.h"
33 #endif
34
addtooltip(control c,const char * tp)35 int addtooltip(control c, const char *tp)
36 {
37 TOOLINFO ti;
38 char *cc = (char*) &ti;
39 int i, lim = sizeof (ti);
40 for (i = 0; i++ < lim; *cc++ = 0);
41 if (hwndToolTip == 0) {
42 InitCommonControls();
43 hwndToolTip = CreateWindowEx(
44 0,TOOLTIPS_CLASS,NULL,WS_POPUP|TTS_ALWAYSTIP,
45 CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
46 hwndFrame,NULL,this_instance,NULL);
47 if(!hwndToolTip) return 0;
48 }
49 ti.cbSize = sizeof(ti);
50 ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
51 ti.hwnd = (HWND) c->parent->handle;
52 ti.uId = (UINT_PTR) c->handle;
53 ti.lpszText = (LPSTR) tp;
54 return
55 (SendMessage(hwndToolTip, TTM_ADDTOOL, 0, (LPARAM)&ti)==TRUE)?
56 1:0;
57 }
58
59
60
61