Changeset 65 for trunk/src/helpers/cctl_tooltip.c
- Timestamp:
- Apr 29, 2001, 2:10:31 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/cctl_tooltip.c
r54 r65 96 96 // linked list of all tools which were subclassed for tooltip 97 97 HMTX G_hmtxSubclassedTools = NULLHANDLE; 98 PLINKLIST G_pllSubclassedTools = NULL;// linked list of SUBCLASSEDTOOL items98 LINKLIST G_llSubclassedTools; // linked list of SUBCLASSEDTOOL items 99 99 100 100 /* ****************************************************************** … … 126 126 } 127 127 128 /* ****************************************************************** 129 * 130 * Subclassing 131 * 132 ********************************************************************/ 133 134 /* 135 *@@ LockSubclassedTools: 136 * locks the global list of subclassed tools. 137 * 138 *@@added V0.9.12 (2001-04-28) [umoeller] 139 */ 140 141 BOOL LockSubclassedTools(VOID) 142 { 143 if (!G_hmtxSubclassedTools) 144 { 145 // first call: 146 147 // initialize the list 148 lstInit(&G_llSubclassedTools, 149 TRUE); // auto-free 150 151 // create mutex and request it right away 152 return (!DosCreateMutexSem(NULL, 153 &G_hmtxSubclassedTools, 154 0, 155 TRUE)); // request! 156 } 157 158 return (!WinRequestMutexSem(G_hmtxSubclassedTools, SEM_INDEFINITE_WAIT)); 159 } 160 161 /* 162 *@@ UnlockSubclassedTools: 163 * unlocks the global list of subclassed tools. 164 * 165 *@@added V0.9.12 (2001-04-28) [umoeller] 166 */ 167 168 VOID UnlockSubclassedTools(VOID) 169 { 170 } 171 128 172 /* 129 173 *@@ SUBCLASSEDTOOL: … … 143 187 144 188 /* 145 *@@ ctl_fnwpSubclassedTool: 146 * window procedure for tools which were subclassed 147 * to support tooltips. 148 * 149 *@@added V0.9.0 [umoeller] 189 *@@ FindSubclassedTool: 190 * returns the SUBCLASSEDTOOL struct from the 191 * global list which matches hwndTool or NULL 192 * if not found. 193 * 194 * Preconditions: Caller must hold the subclassed 195 * tools mutex. 196 * 197 *@@added V0.9.12 (2001-04-28) [umoeller] 150 198 */ 151 199 152 MRESULT EXPENTRY ctl_fnwpSubclassedTool(HWND hwndTool, ULONG msg, MPARAM mp1, MPARAM mp2)200 PSUBCLASSEDTOOL FindSubclassedTool(HWND hwndTool) 153 201 { 154 MRESULT mrc = 0; 155 156 PSUBCLASSEDTOOL pst = NULL; 157 158 PLISTNODE pNode = lstQueryFirstNode(G_pllSubclassedTools); 202 PLISTNODE pNode = lstQueryFirstNode(&G_llSubclassedTools); 159 203 while (pNode) 160 204 { … … 162 206 if (pstThis->hwndTool == hwndTool) 163 207 { 164 pst = pstThis; 165 break; 208 return (pstThis); 166 209 } 167 210 pNode = pNode->pNext; 168 211 } 169 212 170 switch (msg) 213 return (NULL); 214 } 215 216 /* 217 *@@ ctl_fnwpSubclassedTool: 218 * window procedure for tools which were subclassed 219 * to support tooltips. 220 * 221 *@@added V0.9.0 [umoeller] 222 *@@changed V0.9.12 (2001-04-28) [umoeller]: added mutex protection 223 */ 224 225 MRESULT EXPENTRY ctl_fnwpSubclassedTool(HWND hwndTool, ULONG msg, MPARAM mp1, MPARAM mp2) 226 { 227 MRESULT mrc = 0; 228 229 PFNWP pfnwpOrig = NULL; 230 231 if (LockSubclassedTools()) 171 232 { 172 case WM_MOUSEMOVE: 173 case WM_BUTTON1DOWN: 174 case WM_BUTTON1UP: 175 case WM_BUTTON2DOWN: 176 case WM_BUTTON2UP: 177 case WM_BUTTON3DOWN: 178 case WM_BUTTON3UP: 233 PSUBCLASSEDTOOL pst = FindSubclassedTool(hwndTool); 234 235 switch (msg) 179 236 { 180 QMSG qmsg; 181 qmsg.hwnd = hwndTool; 182 qmsg.msg = msg; 183 qmsg.mp1 = mp1; 184 qmsg.mp2 = mp2; 185 // _Pmpf((__FUNCTION__ ": sending TTM_RELAYEVENT")); 186 WinSendMsg(pst->hwndTooltip, 187 TTM_RELAYEVENT, 188 (MPARAM)0, 189 (MPARAM)&qmsg); 190 mrc = (pst->pfnwpOrig)(hwndTool, msg, mp1, mp2); 191 break; } 192 193 case WM_DESTROY: 194 lstRemoveItem(G_pllSubclassedTools, pst); // this frees the item 195 if (lstCountItems(G_pllSubclassedTools) == 0) 237 case WM_MOUSEMOVE: 238 case WM_BUTTON1DOWN: 239 case WM_BUTTON1UP: 240 case WM_BUTTON2DOWN: 241 case WM_BUTTON2UP: 242 case WM_BUTTON3DOWN: 243 case WM_BUTTON3UP: 196 244 { 197 // last item: destroy list 198 lstFree(G_pllSubclassedTools); 199 G_pllSubclassedTools = NULL; 200 // _Pmpf((__FUNCTION__ ": removed hwnd 0x%lX", hwndTool)); 201 } 202 mrc = (pst->pfnwpOrig)(hwndTool, msg, mp1, mp2); 203 break; 204 205 default: 206 mrc = (pst->pfnwpOrig)(hwndTool, msg, mp1, mp2); 245 QMSG qmsg; 246 qmsg.hwnd = hwndTool; 247 qmsg.msg = msg; 248 qmsg.mp1 = mp1; 249 qmsg.mp2 = mp2; 250 // _Pmpf((__FUNCTION__ ": sending TTM_RELAYEVENT")); 251 WinSendMsg(pst->hwndTooltip, 252 TTM_RELAYEVENT, 253 (MPARAM)0, 254 (MPARAM)&qmsg); 255 pfnwpOrig = pst->pfnwpOrig; // call default 256 break; } 257 258 case WM_DESTROY: 259 lstRemoveItem(&G_llSubclassedTools, pst); // this frees the item 260 pfnwpOrig = pst->pfnwpOrig; // call default 261 break; 262 263 default: 264 pfnwpOrig = pst->pfnwpOrig; // call default 265 } 266 267 UnlockSubclassedTools(); 207 268 } 269 270 if (pfnwpOrig) 271 mrc = (pfnwpOrig)(hwndTool, msg, mp1, mp2); 208 272 209 273 return (mrc); … … 211 275 212 276 /* 213 *@@ SubclassTool ForToolinfo:277 *@@ SubclassTool: 214 278 * this gets called from ctl_fnwpTooltip if a control 215 279 * is to be subclassed to support mouse messaging 216 280 * (TTF_SUBCLASS flag). 217 281 * 282 * Preconditions: Caller must hold the subclassed 283 * tools mutex. 284 * 218 285 *@@added V0.9.0 [umoeller] 286 *@@changed V0.9.12 (2001-04-28) [umoeller]: renamed from SubclassToolForToolInfo 219 287 */ 220 288 221 BOOL SubclassTool ForToolinfo(HWND hwndTooltip,222 289 BOOL SubclassTool(HWND hwndTooltip, 290 HWND hwndTool) 223 291 { 224 292 BOOL brc = FALSE; 225 PFNWP pfnwpOrig = WinSubclassWindow(hwndTool, 226 ctl_fnwpSubclassedTool); 227 if (pfnwpOrig) 293 294 // make sure the tool is not on the list yet 295 // V0.9.12 (2001-04-28) [umoeller] 296 if (!FindSubclassedTool(hwndTool)) 228 297 { 229 PSUBCLASSEDTOOL pst = (PSUBCLASSEDTOOL)malloc(sizeof(SUBCLASSEDTOOL)); 230 if (pst) 298 PFNWP pfnwpOrig = WinSubclassWindow(hwndTool, 299 ctl_fnwpSubclassedTool); 300 if (pfnwpOrig) 231 301 { 232 pst->pfnwpOrig = pfnwpOrig;233 pst->hwndTooltip = hwndTooltip;234 pst->hwndTool = hwndTool;235 pst->hab = WinQueryAnchorBlock(hwndTool);236 237 if (G_pllSubclassedTools == NULL)238 G_pllSubclassedTools = lstCreate(TRUE); // auto-free items239 240 lstAppendItem(G_pllSubclassedTools, pst);241 // _Pmpf((__FUNCTION__ ": subclassed hwnd 0x%lX", hwndTool));302 PSUBCLASSEDTOOL pst = (PSUBCLASSEDTOOL)malloc(sizeof(SUBCLASSEDTOOL)); 303 if (pst) 304 { 305 pst->pfnwpOrig = pfnwpOrig; 306 pst->hwndTooltip = hwndTooltip; 307 pst->hwndTool = hwndTool; 308 pst->hab = WinQueryAnchorBlock(hwndTool); 309 310 brc = !!lstAppendItem(&G_llSubclassedTools, pst); 311 } 242 312 } 243 313 } 314 244 315 return (brc); 245 316 } 317 318 /* 319 *@@ UnSubclassTool: 320 * un-subclasses a tool previously subclassed by 321 * SubclassToolForToolinfo. 322 * 323 * Preconditions: Caller must hold the subclassed 324 * tools mutex. 325 * 326 *@@added V0.9.12 (2001-04-28) [umoeller] 327 */ 328 329 BOOL UnSubclassTool(HWND hwndTool) 330 { 331 PSUBCLASSEDTOOL pst = FindSubclassedTool(hwndTool); 332 if (pst) 333 { 334 WinSubclassWindow(hwndTool, 335 pst->pfnwpOrig); 336 // orig winproc == un-subclass 337 return (lstRemoveItem(&G_llSubclassedTools, pst)); 338 // this frees the item 339 } 340 341 return (FALSE); 342 } 343 344 /* ****************************************************************** 345 * 346 * Implementation 347 * 348 ********************************************************************/ 246 349 247 350 /* … … 654 757 * 655 758 * To clarify: There is usually one tooltip control, which is hidden 656 * most of the time, for many tools(parts of a visible window).759 * most of the time, for many "tools" (parts of a visible window). 657 760 * When the user puts the cursor on a tool and leaves it there for 658 761 * approximately one-half second, the tooltip control is set up for … … 728 831 * 729 832 *@@added V0.9.0 [umoeller] 833 *@@changed V0.9.12 (2001-04-28) [umoeller]: various fixes WRT subclassing 730 834 */ 731 835 … … 826 930 if (pttd->pszPaintText) 827 931 free(pttd->pszPaintText); 932 933 // un-subclass all tools that we subclassed 934 // V0.9.12 (2001-04-28) [umoeller] 935 if (LockSubclassedTools()) 936 { 937 PLISTNODE pNode; 938 PSUBCLASSEDTOOL pst; 939 for (pNode = lstQueryFirstNode(&pttd->llTools); 940 pNode; 941 pNode = pNode->pNext) 942 { 943 PTOOLINFO pti = (PTOOLINFO)pNode->pItemData; 944 if (pst = FindSubclassedTool(pti->hwndTool)) 945 UnSubclassTool(pti->hwndTool); 946 } 947 948 UnlockSubclassedTools(); 949 } 950 // end V0.9.12 (2001-04-28) [umoeller] 951 828 952 lstClear(&pttd->llTools); 953 829 954 free(pttd); 830 955 … … 963 1088 * rectangular areas within a window's client area. 964 1089 * 965 * -- When you add a tool implemented as a rectangular area, the 966 * "hwndToolOwner" member of TOOLINFO must specify the handle 967 * of the window that contains the area, and the "rect" member must 968 * specify the client coordinates of the area's bounding 969 * rectangle. 970 * 971 * -- When you add a tool implemented as a window, the "hwndTool" 972 * member of TOOLINFO must contain the window handle of the 973 * tool. hwndToolOwner should be the owner of the tool. 1090 * -- When you add a tool implemented as a rectangular 1091 * area, the "hwndToolOwner" member of TOOLINFO must 1092 * specify the handle of the window that contains the 1093 * area, and the "rect" member must specify the client 1094 * coordinates of the area's bounding rectangle. 1095 * 1096 * -- When you add a tool implemented as a window, the 1097 * "hwndTool" member of TOOLINFO must contain the 1098 * window handle of the tool. hwndToolOwner should be 1099 * the owner of the tool. 974 1100 * 975 1101 * When you add a tool to a tooltip control, the "pszText" … … 1004 1130 ptiNew); 1005 1131 1006 if (ptiPassed->ulFlags & TTF_SUBCLASS) 1007 SubclassToolForToolinfo(hwndTooltip, 1008 ptiPassed->hwndTool); 1132 if ( (ptiPassed->ulFlags & TTF_SUBCLASS) 1133 && (LockSubclassedTools()) // V0.9.12 (2001-04-28) [umoeller] 1134 ) 1135 { 1136 // caller wants this tool to be subclassed: 1137 // well, do it then 1138 SubclassTool(hwndTooltip, 1139 ptiPassed->hwndTool); 1140 1141 UnlockSubclassedTools(); 1142 } 1009 1143 1010 1144 mrc = (MPARAM)TRUE; … … 1040 1174 { 1041 1175 // found: 1176 1177 // V0.9.12 (2001-04-28) [umoeller] 1178 // unsubclass if this was subclassed 1179 if (ptiThis->ulFlags & TTF_SUBCLASS) 1180 { 1181 if (LockSubclassedTools()) 1182 { 1183 UnSubclassTool(ptiSearch->hwndTool); 1184 } 1185 } 1186 1187 // remove the tool from the list 1042 1188 lstRemoveNode(&pttd->llTools, pToolNode); 1189 1043 1190 break; 1044 1191 } … … 1072 1219 1073 1220 case TTM_NEWTOOLRECT: 1221 1074 1222 break; 1075 1223 … … 1209 1357 1210 1358 /* 1359 *@@ TTM_GETDELAYTIME: 1360 * returns the current value of the specified 1361 * timeout value. See TTM_SETDELAYTIME. 1362 * 1363 * Parameters: 1364 * 1365 * -- USHORT mp1: timer value to query. One of: 1366 * -- TTDT_AUTOPOP 1367 * -- TTDT_INITIAL 1368 * -- TTDT_RESHOW 1369 * 1370 * Returns: ULONG timeout value. 1371 * 1372 *@@added V0.9.12 (2001-04-28) [umoeller] 1373 */ 1374 1375 case TTM_GETDELAYTIME: 1376 switch ((USHORT)mp1) 1377 { 1378 case TTDT_AUTOPOP: 1379 mrc = (MRESULT)pttd->ulTimeoutAutopop; 1380 break; 1381 1382 case TTDT_INITIAL: 1383 mrc = (MRESULT)pttd->ulTimeoutInitial; 1384 break; 1385 1386 case TTDT_RESHOW: 1387 mrc = (MRESULT)pttd->ulTimeoutReshow; 1388 break; 1389 } 1390 break; 1391 1392 /* 1211 1393 *@@ TTM_SETDELAYTIME: 1212 1394 * overrides a few default timeout values for the … … 1232 1414 * -- USHORT mp1: parameter selection. One of the following: 1233 1415 * -- TTDT_AUTOMATIC: automatically calculates the initial, 1234 * reshow, and autopopup durations based on the value of iDelay.1416 * reshow, and autopopup durations based on the value of mp2. 1235 1417 * -- TTDT_AUTOPOP: sets the length of time before the tooltip 1236 1418 * window is hidden if the cursor remains stationary … … 1279 1461 * Parameters: 1280 1462 * -- mp1: always 0 1281 * -- PTOOLINFO mp2: pointer to a TOOLINFO structure. When sending the 1282 * message, the hwnd and uId members identify a tool. If the tooltip 1283 * control includes the tool, the lpszText member receives the pointer 1284 * to the string. 1463 * -- PTOOLINFO mp2: pointer to a TOOLINFO structure. 1464 * When sending the message, the hwnd and uId members 1465 * identify a tool. If the tooltip control includes 1466 * the tool, the lpszText member receives the pointer 1467 * to the string. 1285 1468 * 1286 1469 * Return value: 0 always. … … 1289 1472 * this sends the TTN_NEEDTEXT notification to TOOLINFO.hwnd. 1290 1473 * 1291 *@@todo add TTFMT_STRINGRES1292 1474 */ 1293 1475 … … 1322 1504 1323 1505 case TTFMT_STRINGRES: 1324 1506 // @@todo 1325 1507 break; 1326 1508 } … … 1334 1516 * Parameters: 1335 1517 * -- mp1: always 0. 1336 * -- PTOOLINFO mp2: pointer to a TOOLINFO structure. The "hinst" 1337 * and "lpszText" members must specify the instance handle and 1338 * the pointer to the text. 1339 * The "hwnd" and "uId" members identify the tool to update. 1518 * -- PTOOLINFO mp2: pointer to a TOOLINFO structure. 1519 * The "hinst" and "lpszText" members must specify 1520 * the instance handle and the pointer to the text. 1521 * The "hwnd" and "uId" members identify the tool 1522 * to update. 1340 1523 */ 1341 1524
Note:
See TracChangeset
for help on using the changeset viewer.