Mercurial > dwindows
comparison win/dw.c @ 1400:ccd383e11ff8
Allow removing of tooltips by passing NULL or "" and prevent double tooltips on some platforms.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 27 Nov 2011 20:28:15 +0000 |
parents | 8e569dd09d94 |
children | 20c6d0c50c94 |
comparison
equal
deleted
inserted
replaced
1399:8e569dd09d94 | 1400:ccd383e11ff8 |
---|---|
3527 } | 3527 } |
3528 } | 3528 } |
3529 | 3529 |
3530 void _create_tooltip(HWND handle, char *text) | 3530 void _create_tooltip(HWND handle, char *text) |
3531 { | 3531 { |
3532 HWND hwndTT = 0; | |
3533 HWND oldTT = (HWND)dw_window_get_data(handle, "_dw_tooltip"); | |
3534 | |
3535 if(oldTT) | |
3536 DestroyWindow(oldTT); | |
3532 if(text) | 3537 if(text) |
3533 { | 3538 { |
3539 TOOLINFO ti = { 0 }; | |
3540 | |
3534 /* Create a tooltip. */ | 3541 /* Create a tooltip. */ |
3535 HWND hwndTT = CreateWindowEx(WS_EX_TOPMOST, | 3542 hwndTT = CreateWindowEx(WS_EX_TOPMOST, |
3536 TOOLTIPS_CLASS, NULL, | 3543 TOOLTIPS_CLASS, NULL, |
3537 WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, | 3544 WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, |
3538 CW_USEDEFAULT, CW_USEDEFAULT, | 3545 CW_USEDEFAULT, CW_USEDEFAULT, |
3539 CW_USEDEFAULT, CW_USEDEFAULT, | 3546 CW_USEDEFAULT, CW_USEDEFAULT, |
3540 handle, NULL, DWInstance,NULL); | 3547 handle, NULL, DWInstance,NULL); |
3541 TOOLINFO ti = { 0 }; | |
3542 | 3548 |
3543 SetWindowPos(hwndTT, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); | 3549 SetWindowPos(hwndTT, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); |
3544 | 3550 |
3545 /* Set up "tool" information. | 3551 /* Set up "tool" information. |
3546 * In this case, the "tool" is the entire parent window. | 3552 * In this case, the "tool" is the entire parent window. |
3553 ti.rect.right = ti.rect.bottom = 500; | 3559 ti.rect.right = ti.rect.bottom = 500; |
3554 | 3560 |
3555 /* Associate the tooltip with the "tool" window. */ | 3561 /* Associate the tooltip with the "tool" window. */ |
3556 SendMessage(hwndTT, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti); | 3562 SendMessage(hwndTT, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti); |
3557 } | 3563 } |
3564 dw_window_set_data(handle, "_dw_tooltip", (void *)hwndTT); | |
3558 } | 3565 } |
3559 | 3566 |
3560 #ifndef GDIPLUS | 3567 #ifndef GDIPLUS |
3561 /* This function determines the handle for a supplied image filename | 3568 /* This function determines the handle for a supplied image filename |
3562 */ | 3569 */ |