Changeset 19 for trunk/src/helpers/cctl_tooltip.c
- Timestamp:
- Jan 3, 2001, 10:05:57 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/cctl_tooltip.c
r14 r19 182 182 qmsg.mp1 = mp1; 183 183 qmsg.mp2 = mp2; 184 /* WinQueryMsgPos(pst->hab, 185 &qmsg.ptl); 186 qmsg.time = WinQueryMsgTime(pst->hab); */ 187 // _Pmpf(("ctl_fnwpSubclassedTool: sending TTM_RELAYEVENT")); 184 _Pmpf((__FUNCTION__ ": sending TTM_RELAYEVENT")); 188 185 WinSendMsg(pst->hwndTooltip, 189 186 TTM_RELAYEVENT, … … 194 191 195 192 case WM_DESTROY: 196 mrc = (pst->pfnwpOrig)(hwndTool, msg, mp1, mp2);197 193 lstRemoveItem(G_pllSubclassedTools, pst); // this frees the item 198 194 if (lstCountItems(G_pllSubclassedTools) == 0) … … 201 197 lstFree(G_pllSubclassedTools); 202 198 G_pllSubclassedTools = NULL; 199 _Pmpf((__FUNCTION__ ": removed hwnd 0x%lX", hwndTool)); 203 200 } 201 mrc = (pst->pfnwpOrig)(hwndTool, msg, mp1, mp2); 204 202 break; 205 203 … … 240 238 241 239 lstAppendItem(G_pllSubclassedTools, pst); 240 _Pmpf((__FUNCTION__ ": subclassed hwnd 0x%lX", hwndTool)); 242 241 } 243 242 } … … 284 283 BOOL fIsVisible; // TRUE if tooltip is visible 285 284 286 CHAR szTextBuf[256]; // static buffer for copying/loading strings285 // CHAR szTextBuf[256]; // static buffer for copying/loading strings 287 286 } TOOLTIPDATA, *PTOOLTIPDATA; 288 287 … … 435 434 BOOL fShow) // if TRUE: show, else: HIDE 436 435 { 436 _Pmpf((__FUNCTION__ ": fShow %d", fShow)); 437 437 if (fShow) 438 438 { … … 458 458 ) 459 459 { 460 pttd->pszPaintText = NULL;461 460 // mouse not moved since timer was started: 462 461 // find the current TOOLINFO 462 _Pmpf((__FUNCTION__ ": mouse not moved... pttd->ptiMouseOver 0x%lX", pttd->ptiMouseOver)); 463 463 if (pttd->ptiMouseOver) 464 464 { … … 470 470 (MPARAM)0, 471 471 (MPARAM)&tiTemp); 472 if (tiTemp. lpszText)473 pttd->pszPaintText = strdup(tiTemp. lpszText);472 if (tiTemp.pszText) 473 pttd->pszPaintText = strdup(tiTemp.pszText); 474 474 else 475 475 pttd->pszPaintText = NULL; 476 476 } 477 478 _Pmpf((__FUNCTION__ ": pttd->pszPaintText %s", 479 (pttd->pszPaintText) ? pttd->pszPaintText : "NULL")); 477 480 478 481 if (pttd->pszPaintText) … … 499 502 500 503 // calc x and y pos of tooltip 501 if (pttd->ptiMouseOver->uFlags & TTF_CENTERTIP) 504 if ( (pttd->ptiMouseOver->ulFlags & TTF_CENTERBELOW) 505 || (pttd->ptiMouseOver->ulFlags & TTF_CENTERABOVE) 506 ) 502 507 { 503 508 // center below control: 504 if (pttd->ptiMouseOver->uFlags & TTF_IDISHWND) 505 { 506 SWP swpTool; 507 WinQueryWindowPos(pttd->ptiMouseOver->uId, &swpTool); 508 ptlTooltip.x = swpTool.x; 509 ptlTooltip.y = swpTool.y; 510 // convert x, y to desktop points 511 WinMapWindowPoints(WinQueryWindow(pttd->ptiMouseOver->uId, 512 QW_PARENT), // hwndFrom 513 HWND_DESKTOP, // hwndTo 514 &ptlTooltip, 515 1); 516 ptlTooltip.x += ((swpTool.cx - cx) / 2L); 509 SWP swpTool; 510 WinQueryWindowPos(pttd->ptiMouseOver->hwndTool, &swpTool); 511 ptlTooltip.x = swpTool.x; 512 ptlTooltip.y = swpTool.y; 513 // convert x, y to desktop points 514 WinMapWindowPoints(WinQueryWindow(pttd->ptiMouseOver->hwndTool, 515 QW_PARENT), // hwndFrom 516 HWND_DESKTOP, // hwndTo 517 &ptlTooltip, 518 1); 519 ptlTooltip.x += ((swpTool.cx - cx) / 2L); 520 if (pttd->ptiMouseOver->ulFlags & TTF_CENTERBELOW) 517 521 ptlTooltip.y -= cy; 518 }519 // else xxx rectangle def522 else 523 ptlTooltip.y += swpTool.cy; 520 524 } 521 525 else … … 594 598 TOOLTIP_ID_TIMER_AUTOPOP, 595 599 pttd->ulTimeoutAutopop); 596 } 597 } 600 } // end if (pttd->pszPaintText) 601 } // end if ( (ptlPointer.x == pttd->ptlPointerLast.x)... 598 602 } // end if (mp1) 599 603 else … … 847 851 case TOOLTIP_ID_TIMER_INITIAL: 848 852 // _Pmpf(("WM_TIMER: Stopping initial timer: %d", usTimer)); 853 _Pmpf((__FUNCTION__ ": TOOLTIP_ID_TIMER_INITIAL")); 849 854 WinStopTimer(pttd->hab, 850 855 hwndTooltip, … … 944 949 * the address of a TOOLINFO structure, which provides 945 950 * information the tooltip control needs to display text 946 * for the tool. The cbSize member is required and must 947 * specify the size of the structure. 951 * for the tool. 948 952 * 949 953 * A tooltip control supports tools implemented as windows … … 952 956 * 953 957 * -- When you add a tool implemented as a rectangular area, the 954 * "hwnd " member of TOOLINFO must specify the handle of the955 * window that contains the area, and the "rect" member must958 * "hwndToolOwner" member of TOOLINFO must specify the handle 959 * of the window that contains the area, and the "rect" member must 956 960 * specify the client coordinates of the area's bounding 957 * rectangle. In addition, the "uId" member must specify the 958 * application-defined identifier for the tool. 959 * 960 * -- When you add a tool implemented as a window, the "uId" 961 * rectangle. ### not implemented yet 962 * 963 * -- When you add a tool implemented as a window, the "hwndTool" 961 964 * member of TOOLINFO must contain the window handle of the 962 * tool. Also, the "uFlags" member must specify the TTF_IDISHWND 963 * value, which tells the tooltip control to interpret the "uId" 964 * member as a window handle. 965 * 966 * When you add a tool to a tooltip control, the "lpszText" 967 * member of the TOOLINFO structure must specify the address 968 * of the string to display for the tool. You can change the 969 * text any time after adding the tool by using the 970 * TTM_UPDATETIPTEXT message. 971 * 972 * If the high-order word of lpszText is zero, the low-order 973 * word must be the identifier of a string resource. When 974 * the tooltip control needs the text, the system loads 975 * the specified string resource from the application instance 976 * identified by the "hinst" member of TOOLINFO. 977 * 978 * If you specify the LPSTR_TEXTCALLBACK value in the lpszText 979 * member, the tooltip control notifies the window specified 980 * in the hwnd member of TOOLINFO whenever the tooltip control 981 * needs to display text for the tool. The tooltip control 982 * sends the TTN_NEEDTEXT notification message to the window. 965 * tool. hwndToolOwner should be the owner of the tool. 966 * 967 * When you add a tool to a tooltip control, the "pszText" 968 * member of the TOOLINFO structure must specify the string 969 * to display for the tool. You can change the text any time 970 * after adding the tool by using the TTM_UPDATETIPTEXT message. 971 * 972 * If you specify the PSZ_TEXTCALLBACK value in the pszText 973 * member, whenever the tooltip control needs the text for the 974 * tool, it sends a WM_CONTROL message to hwndToolOwner with 975 * the TTN_NEEDTEXT notification code. 976 * 983 977 * The message includes the address of a TOOLTIPTEXT structure, 984 * which contains the window handle as well as the 985 * application-defined identifier for the tool. The window 986 * examines the structure to determine the tool for which text 987 * is needed, and it fills the appropriate structure members 988 * with information that the tooltip control needs to display 989 * the string. 990 * 991 * Many applications create toolbars containing tools that 992 * correspond to menu commands. For such tools, it is convenient 993 * for the tooltip control to display the same text as the 994 * corresponding menu item. Windows automatically strips the 995 * ampersand (&) accelerator characters from all strings passed 996 * to a tooltip control, unless the control has the TTS_NOPREFIX style. 997 * 998 * OS/2 note: This implementation does this too, but will not 999 * strip the ampersand, but the tilde (~) character. 978 * which contains the window handle of the tool. You can then 979 * fill the TOOLTIPTEXT structure with the tool text. 1000 980 * 1001 981 * To retrieve the text for a tool, use the TTM_GETTEXT message. … … 1010 990 if (ptiNew) 1011 991 { 1012 memcpy(ptiNew, ptiPassed, ptiPassed->cbSize);992 memcpy(ptiNew, ptiPassed, sizeof(TOOLINFO)); 1013 993 lstAppendItem(&pttd->llTools, 1014 994 ptiNew); 1015 995 1016 if (ptiPassed->uFlags & TTF_IDISHWND) 1017 if (ptiPassed->uFlags & TTF_SUBCLASS) 1018 SubclassToolForToolinfo(hwndTooltip, 1019 ptiPassed->uId); 996 if (ptiPassed->ulFlags & TTF_SUBCLASS) 997 SubclassToolForToolinfo(hwndTooltip, 998 ptiPassed->hwndTool); 1020 999 1021 1000 mrc = (MPARAM)TRUE; … … 1046 1025 { 1047 1026 PTOOLINFO ptiThis = (PTOOLINFO)pToolNode->pItemData; 1048 if ( (ptiThis->hwnd == ptiSearch->hwnd)1049 && (ptiThis-> uId == ptiSearch->uId)1027 if ( (ptiThis->hwndToolOwner == ptiSearch->hwndToolOwner) 1028 && (ptiThis->hwndTool == ptiSearch->hwndTool) 1050 1029 ) 1051 1030 { … … 1178 1157 { 1179 1158 PTOOLINFO pti = (PTOOLINFO)pToolNode->pItemData; 1180 if ( (pti->uFlags &TTF_IDISHWND) 1181 && (pti->uId == pqmsg->hwnd) 1182 ) 1159 if (pti->hwndTool == pqmsg->hwnd) 1183 1160 { 1161 _Pmpf((__FUNCTION__ ": found tool")); 1184 1162 pttd->ptiMouseOver = pti; 1185 1163 break; … … 1196 1174 { 1197 1175 // mouse pos changed: 1176 // hide tooltip 1198 1177 WinPostMsg(hwndTooltip, 1199 1178 TTM_SHOWTOOLTIPNOW, … … 1202 1181 memcpy(&pttd->ptlPointerLast, &ptlPointer, sizeof(POINTL)); 1203 1182 1183 _Pmpf((__FUNCTION__ ": pttd->ptiMouseOver: 0x%lX", pttd->ptiMouseOver)); 1184 _Pmpf((__FUNCTION__ ": pttd->fIsActive: 0x%lX", pttd->fIsActive)); 1204 1185 if ( (pttd->ptiMouseOver) 1205 1186 && (pttd->fIsActive) … … 1303 1284 PTOOLINFO pti = (PTOOLINFO)mp2; 1304 1285 1305 if (pti-> lpszText == LPSTR_TEXTCALLBACK)1286 if (pti->pszText == PSZ_TEXTCALLBACK) 1306 1287 { 1307 1288 // TTN_NEEDTEXT notification desired: 1308 1289 // compose values for that msg 1309 TOOLTIPTEXT ttt; 1310 memset(&ttt, 0, sizeof(ttt)); 1311 ttt.hdr.hwndFrom = hwndTooltip; 1312 1313 if (pti->uFlags & TTF_IDISHWND) 1314 // HWND mode: 1315 ttt.uFlags = TTF_IDISHWND; 1316 ttt.hdr.idFrom = pti->uId; // HWND or app-def'd ID 1317 ttt.hdr.code = TTN_NEEDTEXT; 1318 WinSendMsg(pti->hwnd, 1290 TOOLTIPTEXT ttt = {0}; 1291 _Pmpf(("TTM_GETTEXT: LPSTR_TEXTCALLBACK")); 1292 ttt.hwndTooltip = hwndTooltip; 1293 ttt.hwndTool = pti->hwndTool; 1294 WinSendMsg(pti->hwndTool, 1319 1295 WM_CONTROL, 1320 1296 MPFROM2SHORT(pttd->ulTooltipID, // tooltip control wnd ID … … 1324 1300 // in case of error: set lpszText to NULL; this 1325 1301 // is not specified in the docs however. 1326 pti-> lpszText = NULL;1327 1328 if (ttt.szText[0] != 0)1302 pti->pszText = NULL; 1303 1304 switch (ttt.ulFormat) 1329 1305 { 1330 // owner copied string to ttt.szText: 1331 // copy that to our buffer in the window words 1332 // to make it static 1333 strcpy(pttd->szTextBuf, ttt.szText); // maxlen is 80 chars 1334 pti->lpszText = pttd->szTextBuf; 1335 } 1336 else if ( (ttt.lpszText != 0) 1337 && (((ULONG)ttt.lpszText & 0xFFFF0000) != 0) 1338 ) 1339 // owner specified pointer to static buffer somewhere: 1340 pti->lpszText = ttt.lpszText; 1341 else if ((ULONG)ttt.lpszText & 0xFFFF) 1342 { 1343 if (WinLoadString(pttd->hab, 1344 ttt.hinst, 1345 (ULONG)ttt.lpszText, 1346 sizeof(pttd->szTextBuf), // 256 chars 1347 pttd->szTextBuf)) 1348 pti->lpszText = pttd->szTextBuf; 1306 case TTFMT_PSZ: 1307 if (ttt.pszText) 1308 pti->pszText = ttt.pszText; 1309 break; 1310 1311 case TTFMT_STRINGRES: 1312 // ### not supported yet 1313 break; 1349 1314 } 1350 1315 } … … 1440 1405 if (ptiFound) 1441 1406 { 1442 memcpy(ptiTarget, ptiFound, ptiTarget->cbSize);1407 memcpy(ptiTarget, ptiFound, sizeof(TOOLINFO)); 1443 1408 mrc = (MRESULT)TRUE; 1444 1409 } … … 1468 1433 if (pttd->ptiMouseOver) 1469 1434 { 1470 memcpy(ptiTarget, pttd->ptiMouseOver, ptiTarget->cbSize);1435 memcpy(ptiTarget, pttd->ptiMouseOver, sizeof(TOOLINFO)); 1471 1436 mrc = (MPARAM)TRUE; 1472 1437 } … … 1512 1477 { 1513 1478 PTOOLINFO ptiThis = (PTOOLINFO)pToolNode->pItemData; 1514 if ( (ptiThis->hwnd == ptiSearch->hwnd)1515 && (ptiThis-> uId == ptiSearch->uId)1479 if ( (ptiThis->hwndToolOwner == ptiSearch->hwndToolOwner) 1480 && (ptiThis->hwndTool == ptiSearch->hwndTool) 1516 1481 ) 1517 1482 { 1518 1483 // found: 1519 memcpy(ptiSearch, ptiThis, ptiSearch->cbSize);1484 memcpy(ptiSearch, ptiThis, sizeof(TOOLINFO)); 1520 1485 mrc = (MPARAM)TRUE; 1521 1486 break; … … 1555 1520 1556 1521 case TTM_SHOWTOOLTIPNOW: 1522 _Pmpf((__FUNCTION__ ": TTM_SHOWTOOLTIPNOW %d", mp1)); 1557 1523 TtmShowTooltip(hwndTooltip, pttd, (BOOL)mp1); 1558 1524 break;
Note:
See TracChangeset
for help on using the changeset viewer.