- Timestamp:
- Jun 24, 1999, 6:37:46 PM (26 years ago)
- Location:
- trunk/src/comctl32
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/propsheet.c
r94 r180 1 /* $Id: propsheet.c,v 1. 3 1999-06-10 16:22:01 achimhaExp $ */1 /* $Id: propsheet.c,v 1.4 1999-06-24 16:37:44 cbratschi Exp $ */ 2 2 /* 3 3 * Property Sheets … … 6 6 * Copyright 1999 Thuy Nguyen 7 7 * Copyright 1999 Achim Hasenmueller 8 * Copyright 1999 Christoph Bratschi 8 9 * 9 10 * TODO: … … 251 252 p += lstrlenW( (LPCWSTR)p ) + 1; 252 253 break; 253 } 254 } 254 255 255 256 /* class */ … … 286 287 HRSRC hRes; 287 288 288 if (!(hRes = FindResourceA(COMCTL32_hModule,289 if (!(hRes = FindResourceA(COMCTL32_hModule, 289 290 MAKEINTRESOURCEA(IDD_PROPSHEET), 290 291 RT_DIALOGA))) 291 292 return FALSE; 292 293 293 if (!(template = (LPVOID)LoadResource(COMCTL32_hModule, hRes)))294 if (!(template = (LPVOID)LoadResource(COMCTL32_hModule, hRes))) 294 295 return FALSE; 295 296 … … 315 316 /****************************************************************************** 316 317 * PROPSHEET_IsTooSmall 317 * 318 * 318 319 * Verify that the resource property sheet is big enough. 319 320 */ … … 437 438 /* 438 439 * Get the size of the property sheet. 439 */ 440 */ 440 441 GetClientRect(hwndParent, &rcSheet); 441 442 442 /* 443 /* 443 444 * All buttons will be at this y coordinate. 444 445 */ … … 476 477 else 477 478 x = rcSheet.right - (padding.x + buttonWidth); 478 479 479 480 SetWindowPos(hwndButton, 0, x, y, 0, 0, 480 481 SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); … … 493 494 { 494 495 x = rcSheet.right - (padding.x + buttonWidth); 495 496 496 497 SetWindowPos(hwndButton, 0, x, y, 0, 0, 497 498 SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); … … 613 614 614 615 hwndPage = CreateDialogIndirectParamA(ppshpage->hInstance, 615 616 617 618 616 pTemplate, 617 hwndParent, 618 ppshpage->pfnDlgProc, 619 (LPARAM)ppshpage); 619 620 620 621 ppInfo[index].hwndPage = hwndPage; … … 841 842 default: 842 843 // FIXME(propsheet, "Invalid button index %d\n", buttonID); 843 844 break; 844 845 } 845 846 } … … 1083 1084 psInfo->proppage = COMCTL32_Alloc(sizeof(PropPageInfo) * psInfo->nPages); 1084 1085 1085 if (index > 0) 1086 if (index > 0) 1086 1087 memcpy(&psInfo->proppage[0], &oldPages[0], index * sizeof(PropPageInfo)); 1087 1088 … … 1233 1234 } 1234 1235 1235 ppshpage = PROPSHEET_GetPSPPage(psInfo, psInfo->active_page); 1236 ppshpage = PROPSHEET_GetPSPPage(psInfo, psInfo->active_page); 1236 1237 PROPSHEET_CreatePage(hwnd, psInfo->active_page, psInfo, ppshpage, TRUE); 1237 1238 SendMessageA(hwndTabCtrl, TCM_SETCURSEL, psInfo->active_page, 0); … … 1392 1393 case PSM_REBOOTSYSTEM: 1393 1394 { 1394 PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwnd, 1395 PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwnd, 1395 1396 PropSheetInfoStr); 1396 1397 -
trunk/src/comctl32/toolbar.c
r110 r180 1 /* $Id: toolbar.c,v 1. 5 1999-06-16 20:25:43cbratschi Exp $ */1 /* $Id: toolbar.c,v 1.6 1999-06-24 16:37:45 cbratschi Exp $ */ 2 2 /* 3 3 * Toolbar control … … 175 175 RECT rc; 176 176 177 if (btnPtr->fsState & TBSTATE_HIDDEN) 178 return; 177 if (btnPtr->fsState & TBSTATE_HIDDEN) return; 179 178 180 179 rc = btnPtr->rect; 181 if (btnPtr->fsStyle & TBSTYLE_SEP) { 182 if ((dwStyle & TBSTYLE_FLAT) && (btnPtr->idCommand == 0)) 183 TOOLBAR_DrawFlatSeparator (&btnPtr->rect, hdc); 184 return; 180 if (btnPtr->fsStyle & TBSTYLE_SEP) 181 { 182 if ((dwStyle & TBSTYLE_FLAT) && (btnPtr->idCommand == 0)) 183 TOOLBAR_DrawFlatSeparator (&btnPtr->rect, hdc); 184 return; 185 185 } 186 186 187 187 /* disabled */ 188 if (!(btnPtr->fsState & TBSTATE_ENABLED)) { 189 DrawEdge (hdc, &rc, EDGE_RAISED, 190 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 191 192 if (dwStyle & TBSTYLE_FLAT) { 193 /* if (infoPtr->himlDis) */ 194 ImageList_Draw (infoPtr->himlDis, btnPtr->iBitmap, hdc, 195 rc.left+1, rc.top+1, ILD_NORMAL); 196 /* else */ 197 /* TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1); */ 198 } 199 else 200 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1); 201 202 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState); 203 return; 188 if (!(btnPtr->fsState & TBSTATE_ENABLED)) 189 { 190 DrawEdge (hdc, &rc, EDGE_RAISED, 191 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 192 193 if (dwStyle & TBSTYLE_FLAT) 194 { 195 /* if (infoPtr->himlDis) */ 196 ImageList_Draw (infoPtr->himlDis, btnPtr->iBitmap, hdc, 197 rc.left+1, rc.top+1, ILD_NORMAL); 198 /* else */ 199 /* TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1); */ 200 } else 201 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1); 202 203 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState); 204 return; 204 205 } 205 206 206 207 /* pressed TBSTYLE_BUTTON */ 207 if (btnPtr->fsState & TBSTATE_PRESSED) { 208 DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST); 209 ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc, 210 rc.left+2, rc.top+2, ILD_NORMAL); 211 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState); 212 return; 208 if (btnPtr->fsState & TBSTATE_PRESSED) 209 { 210 DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST); 211 ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc, 212 rc.left+2, rc.top+2, ILD_NORMAL); 213 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState); 214 return; 213 215 } 214 216 … … 229 231 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc, 230 232 rc.left+2, rc.top+2, ILD_NORMAL); 231 else233 else 232 234 ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc, 233 235 rc.left+2, rc.top+2, ILD_NORMAL); 234 } 235 else 236 } else 236 237 ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc, 237 238 rc.left+2, rc.top+2, ILD_NORMAL); … … 241 242 242 243 /* indeterminate */ 243 if (btnPtr->fsState & TBSTATE_INDETERMINATE) { 244 DrawEdge (hdc, &rc, EDGE_RAISED, 245 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 246 247 TOOLBAR_DrawPattern (hdc, &rc); 248 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1); 249 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState); 250 return; 244 if (btnPtr->fsState & TBSTATE_INDETERMINATE) 245 { 246 DrawEdge (hdc, &rc, EDGE_RAISED, 247 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 248 249 TOOLBAR_DrawPattern (hdc, &rc); 250 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1); 251 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState); 252 return; 251 253 } 252 254 253 255 if (dwStyle & TBSTYLE_FLAT) 254 256 { 255 256 257 258 259 260 261 262 263 264 265 } 266 else{267 /* normal state */268 DrawEdge (hdc, &rc, EDGE_RAISED,257 if(btnPtr->bHot) 258 DrawEdge (hdc, &rc, BDR_RAISEDINNER, 259 BF_RECT | BF_MIDDLE | BF_SOFT); 260 261 if(infoPtr->himlDef != NULL) 262 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc, 263 rc.left +2, rc.top +2, ILD_NORMAL); 264 else 265 ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc, 266 rc.left +2, rc.top +2, ILD_NORMAL); 267 } else 268 { 269 /* normal state */ 270 DrawEdge (hdc, &rc, EDGE_RAISED, 269 271 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 270 272 271 272 273 ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc, 274 rc.left+1, rc.top+1, ILD_NORMAL); 273 275 } 274 276 … … 555 557 556 558 /* Set the toolTip only for non-hidden, non-separator button */ 557 if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & TBSTYLE_SEP 559 if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & TBSTYLE_SEP)) 558 560 { 559 561 TTTOOLINFOA ti; 560 562 561 ZeroMemory (&ti, 563 ZeroMemory (&ti,sizeof(TTTOOLINFOA)); 562 564 ti.cbSize = sizeof(TTTOOLINFOA); 563 565 ti.hwnd = hwnd; 564 566 ti.uId = btnPtr->idCommand; 565 567 ti.rect = btnPtr->rect; 566 SendMessageA (infoPtr->hwndToolTip, TTM_NEWTOOLRECTA, 567 0, (LPARAM)&ti); 568 SendMessageA(infoPtr->hwndToolTip,TTM_NEWTOOLRECTA,0,(LPARAM)&ti); 568 569 } 569 570 … … 712 713 msg.wParam = wParam; 713 714 msg.lParam = lParam; 714 msg.time = GetMessageTime 715 msg.pt.x = LOWORD(GetMessagePos 716 msg.pt.y = HIWORD(GetMessagePos 717 718 SendMessageA (hwndTip, TTM_RELAYEVENT, 0,(LPARAM)&msg);715 msg.time = GetMessageTime(); 716 msg.pt.x = LOWORD(GetMessagePos()); 717 msg.pt.y = HIWORD(GetMessagePos()); 718 719 SendMessageA(hwndTip,TTM_RELAYEVENT,0,(LPARAM)&msg); 719 720 } 720 721 … … 976 977 977 978 /* insert new button data */ 978 for (nCount = 0; nCount < nAddButtons; nCount++) { 979 for (nCount = 0; nCount < nAddButtons; nCount++) 980 { 979 981 TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount]; 980 982 btnPtr->iBitmap = lpTbb[nCount].iBitmap; … … 986 988 btnPtr->bHot = FALSE; 987 989 988 if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) { 990 if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) 991 { 989 992 TTTOOLINFOA ti; 990 993 … … 996 999 ti.lpszText = LPSTR_TEXTCALLBACKA; 997 1000 998 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA, 999 0, (LPARAM)&ti); 1000 } 1001 } 1002 1003 TOOLBAR_CalcToolbar (hwnd); 1004 1005 InvalidateRect(hwnd, NULL, FALSE); 1001 SendMessageA (infoPtr->hwndToolTip,TTM_ADDTOOLA,0,(LPARAM)&ti); 1002 } 1003 } 1004 1005 TOOLBAR_CalcToolbar(hwnd); 1006 1007 InvalidateRect(hwnd,NULL,FALSE); 1006 1008 1007 1009 return TRUE; … … 1752 1754 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 1753 1755 1754 if (infoPtr == NULL) 1755 return 0; 1756 if (infoPtr == NULL) return 0; 1756 1757 return infoPtr->hwndToolTip; 1757 1758 } … … 2056 2057 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 2057 2058 2058 if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0)) 2059 return FALSE; 2059 if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0)) return FALSE; 2060 2060 2061 2061 infoPtr->nBitmapWidth = (INT)LOWORD(lParam); … … 2123 2123 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 2124 2124 2125 if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0)) 2126 return FALSE; 2125 if ((LOWORD(lParam) <= 0) || (HIWORD(lParam) <= 0)) return FALSE; 2127 2126 2128 2127 infoPtr->nButtonWidth = (INT)LOWORD(lParam); … … 2449 2448 2450 2449 infoPtr->bCaptured = FALSE; 2451 infoPtr->bUnicode = IsWindowUnicode 2450 infoPtr->bUnicode = IsWindowUnicode(hwnd); 2452 2451 infoPtr->nButtonDown = -1; 2453 2452 infoPtr->nOldHit = -1; … … 2460 2459 infoPtr->hFont = CreateFontIndirectA (&logFont); 2461 2460 2462 if (dwStyle & TBSTYLE_TOOLTIPS) { 2461 if (dwStyle & TBSTYLE_TOOLTIPS) 2462 { 2463 2463 /* Create tooltip control */ 2464 2464 infoPtr->hwndToolTip = 2465 CreateWindowExA ( 0, TOOLTIPS_CLASSA, NULL, 0,2466 CW_USEDEFAULT, 2467 CW_USEDEFAULT, 2468 hwnd, 0, 0,0);2465 CreateWindowExA (WS_EX_TOOLWINDOW,TOOLTIPS_CLASSA,NULL,WS_POPUP, 2466 CW_USEDEFAULT,CW_USEDEFAULT, 2467 CW_USEDEFAULT,CW_USEDEFAULT, 2468 hwnd,0,0,0); 2469 2469 2470 2470 /* Send NM_TOOLTIPSCREATED notification */ 2471 if (infoPtr->hwndToolTip) { 2471 if (infoPtr->hwndToolTip) 2472 { 2472 2473 NMTOOLTIPSCREATED nmttc; 2473 2474 … … 2692 2693 2693 2694 if (infoPtr->hwndToolTip) 2694 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, 2695 WM_MOUSEMOVE, wParam,lParam);2695 TOOLBAR_RelayEvent (infoPtr->hwndToolTip,hwnd, 2696 WM_MOUSEMOVE,wParam,lParam); 2696 2697 2697 2698 pt.x = (INT)LOWORD(lParam); 2698 2699 pt.y = (INT)HIWORD(lParam); 2699 2700 2700 nHit = TOOLBAR_InternalHitTest (hwnd,&pt);2701 nHit = TOOLBAR_InternalHitTest(hwnd,&pt); 2701 2702 2702 2703 if (infoPtr->nOldHit != nHit) 2703 2704 { 2704 /* Remove the effect of an old hot button */ 2705 if(infoPtr->nOldHit == infoPtr->nHotItem) 2705 /* Remove the effect of an old hot button */ 2706 if(infoPtr->nOldHit == infoPtr->nHotItem) 2707 { 2708 oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit]; 2709 if (oldBtnPtr->bHot) 2706 2710 { 2707 oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit]; 2708 oldBtnPtr->bHot = FALSE; 2709 2710 InvalidateRect (hwnd, &oldBtnPtr->rect, TRUE); 2711 } 2712 2713 /* It's not a separator or in nowhere. It's a hot button. */ 2714 if (nHit >= 0) 2711 oldBtnPtr->bHot = FALSE; 2712 2713 InvalidateRect (hwnd, &oldBtnPtr->rect, TRUE); 2714 } 2715 } 2716 2717 /* It's not a separator or in nowhere. It's a hot button. */ 2718 if (nHit >= 0) 2719 { 2720 btnPtr = &infoPtr->buttons[nHit]; 2721 if (!btnPtr->bHot) 2715 2722 { 2716 btnPtr = &infoPtr->buttons[nHit]; 2717 btnPtr->bHot = TRUE; 2718 2719 hdc = GetDC (hwnd); 2720 TOOLBAR_DrawButton (hwnd, btnPtr, hdc); 2721 ReleaseDC (hwnd, hdc); 2722 2723 infoPtr->nHotItem = nHit; 2724 } 2725 2726 if (infoPtr->bCaptured) { 2727 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown]; 2728 if (infoPtr->nOldHit == infoPtr->nButtonDown) { 2729 btnPtr->fsState &= ~TBSTATE_PRESSED; 2730 hdc = GetDC (hwnd); 2731 TOOLBAR_DrawButton (hwnd, btnPtr, hdc); 2732 ReleaseDC (hwnd, hdc); 2733 } 2734 else if (nHit == infoPtr->nButtonDown) { 2735 btnPtr->fsState |= TBSTATE_PRESSED; 2736 hdc = GetDC (hwnd); 2737 TOOLBAR_DrawButton (hwnd, btnPtr, hdc); 2738 ReleaseDC (hwnd, hdc); 2739 } 2740 } 2741 infoPtr->nOldHit = nHit; 2723 btnPtr->bHot = TRUE; 2724 2725 hdc = GetDC (hwnd); 2726 TOOLBAR_DrawButton (hwnd, btnPtr, hdc); 2727 ReleaseDC (hwnd, hdc); 2728 2729 infoPtr->nHotItem = nHit; 2730 } 2731 } 2732 2733 if (infoPtr->bCaptured) 2734 { 2735 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown]; 2736 if (infoPtr->nOldHit == infoPtr->nButtonDown) 2737 { 2738 btnPtr->fsState &= ~TBSTATE_PRESSED; 2739 2740 hdc = GetDC (hwnd); 2741 TOOLBAR_DrawButton(hwnd,btnPtr,hdc); 2742 ReleaseDC(hwnd,hdc); 2743 } else if (nHit == infoPtr->nButtonDown) 2744 { 2745 btnPtr->fsState |= TBSTATE_PRESSED; 2746 2747 hdc = GetDC(hwnd); 2748 TOOLBAR_DrawButton(hwnd,btnPtr,hdc); 2749 ReleaseDC(hwnd,hdc); 2750 } 2751 } 2752 infoPtr->nOldHit = nHit; 2742 2753 } 2743 2754 return 0; … … 2852 2863 PAINTSTRUCT ps; 2853 2864 2854 TOOLBAR_CalcToolbar( hwnd ); 2855 hdc = wParam==0 ? BeginPaint (hwnd, &ps) : (HDC)wParam; 2856 TOOLBAR_Refresh (hwnd, hdc); 2857 if (!wParam) 2858 EndPaint (hwnd, &ps); 2865 TOOLBAR_CalcToolbar(hwnd); 2866 hdc = wParam==0 ? BeginPaint(hwnd,&ps) : (HDC)wParam; 2867 TOOLBAR_Refresh(hwnd,hdc); 2868 if (!wParam) EndPaint (hwnd, &ps); 2859 2869 return 0; 2860 2870 } -
trunk/src/comctl32/tooltips.c
r110 r180 1 /* $Id: tooltips.c,v 1. 5 1999-06-16 20:25:44cbratschi Exp $ */1 /* $Id: tooltips.c,v 1.6 1999-06-24 16:37:45 cbratschi Exp $ */ 2 2 /* 3 3 * Tool tip control … … 18 18 */ 19 19 20 /* CB: Odin32 problems 21 - not defined colors: COLOR_INFOBK, COLOR_INFOTEXT 22 - WM_NCCREATE not handled first -> title bar visible if WS_POPUP wasn't set before 23 */ 24 20 25 #include <string.h> 21 26 … … 53 58 UINT uFlags = DT_EXTERNALLEADING; 54 59 55 if (infoPtr->nMaxTipWidth > -1) 56 uFlags |= DT_WORDBREAK; 57 if (GetWindowLongA (hwnd, GWL_STYLE) & TTS_NOPREFIX) 58 uFlags |= DT_NOPREFIX; 59 GetClientRect (hwnd, &rc); 60 if (infoPtr->nMaxTipWidth > -1) uFlags |= DT_WORDBREAK; 61 if (GetWindowLongA(hwnd,GWL_STYLE) & TTS_NOPREFIX) uFlags |= DT_NOPREFIX; 62 GetClientRect(hwnd,&rc); 60 63 61 64 /* fill the background */ 62 hBrush = CreateSolidBrush 63 FillRect (hdc, &rc,hBrush);64 DeleteObject 65 hBrush = CreateSolidBrush(infoPtr->clrBk); 66 FillRect(hdc,&rc,hBrush); 67 DeleteObject(hBrush); 65 68 66 69 /* calculate text rectangle */ 67 rc.left += (2 +infoPtr->rcMargin.left);68 rc.top += (2 +infoPtr->rcMargin.top);69 rc.right -= (2 +infoPtr->rcMargin.right);70 rc.bottom -= (2 +infoPtr->rcMargin.bottom);70 rc.left += (2+infoPtr->rcMargin.left); 71 rc.top += (2+infoPtr->rcMargin.top); 72 rc.right -= (2+infoPtr->rcMargin.right); 73 rc.bottom -= (2+infoPtr->rcMargin.bottom); 71 74 72 75 /* draw text */ 73 oldBkMode = SetBkMode (hdc, TRANSPARENT); 74 SetTextColor (hdc, infoPtr->clrText); 75 hOldFont = SelectObject (hdc, infoPtr->hFont); 76 DrawTextW (hdc, infoPtr->szTipText, -1, &rc, uFlags); 77 SelectObject (hdc, hOldFont); 78 if (oldBkMode != TRANSPARENT) 79 SetBkMode (hdc, oldBkMode); 76 oldBkMode = SetBkMode(hdc,TRANSPARENT); 77 SetTextColor(hdc,infoPtr->clrText); 78 hOldFont = SelectObject(hdc,infoPtr->hFont); 79 DrawTextW(hdc,infoPtr->szTipText,-1,&rc,uFlags); 80 SelectObject(hdc,hOldFont); 81 if (oldBkMode != TRANSPARENT) SetBkMode(hdc,oldBkMode); 80 82 } 81 83 82 84 83 85 static VOID 84 TOOLTIPS_GetTipText (HWND hwnd, TOOLTIPS_INFO *infoPtr,INT nTool)86 TOOLTIPS_GetTipText(HWND hwnd,TOOLTIPS_INFO *infoPtr,INT nTool) 85 87 { 86 88 TTTOOL_INFO *toolPtr = &infoPtr->tools[nTool]; 87 89 88 if ((toolPtr->hinst) && (HIWORD((UINT)toolPtr->lpszText) == 0)) {89 /* load a resource */90 // TRACE (tooltips, "load res string %x %x\n", 91 // toolPtr->hinst,(int)toolPtr->lpszText);92 LoadStringW (toolPtr->hinst, (UINT)toolPtr->lpszText,93 infoPtr->szTipText, INFOTIPSIZE);94 }95 else if (toolPtr->lpszText) {96 if (toolPtr->lpszText == LPSTR_TEXTCALLBACKW){97 98 99 100 ZeroMemory (&ttnmdi,sizeof(NMTTDISPINFOA));101 102 103 104 105 106 107 108 // TRACE (tooltips, "hdr.idFrom = %x\n", ttnmdi.hdr.idFrom);109 SendMessageA (toolPtr->hwnd, WM_NOTIFY, 110 (WPARAM)toolPtr->uId, (LPARAM)&ttnmdi);111 112 if ((ttnmdi.hinst) && (HIWORD((UINT)ttnmdi.szText) == 0)) {113 LoadStringW (ttnmdi.hinst, (UINT)ttnmdi.szText,114 infoPtr->szTipText, INFOTIPSIZE);115 if (ttnmdi.uFlags & TTF_DI_SETITEM) {116 toolPtr->hinst = ttnmdi.hinst;117 toolPtr->lpszText = (LPWSTR)ttnmdi.szText;118 }119 }120 else if (ttnmdi.szText[0]) {121 lstrcpynAtoW (infoPtr->szTipText, ttnmdi.szText, 80);122 if (ttnmdi.uFlags & TTF_DI_SETITEM){123 INT len = lstrlenA(ttnmdi.szText);124 125 toolPtr->lpszText = COMCTL32_Alloc((len+1)* sizeof(WCHAR));126 lstrcpyAtoW (toolPtr->lpszText,ttnmdi.szText);127 128 }129 else if (ttnmdi.lpszText == 0){130 131 132 }133 else if (ttnmdi.lpszText != LPSTR_TEXTCALLBACKA){134 lstrcpynAtoW (infoPtr->szTipText, ttnmdi.lpszText,INFOTIPSIZE);135 if (ttnmdi.uFlags & TTF_DI_SETITEM) {136 INT len = lstrlenA (ttnmdi.lpszText);137 toolPtr->hinst = 0;138 toolPtr->lpszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));139 lstrcpyAtoW (toolPtr->lpszText, ttnmdi.lpszText);140 }141 142 else {143 // ERR (tooltips, "recursive text callback!\n"); 144 infoPtr->szTipText[0] = '\0';145 }90 if ((toolPtr->hinst) && (HIWORD((UINT)toolPtr->lpszText) == 0)) 91 { 92 /* load a resource */ 93 // TRACE (tooltips,"load res string %x %x\n",toolPtr->hinst,(int)toolPtr->lpszText); 94 LoadStringW(toolPtr->hinst,(UINT)toolPtr->lpszText,infoPtr->szTipText,INFOTIPSIZE); 95 } else if (toolPtr->lpszText) 96 { 97 if (toolPtr->lpszText == LPSTR_TEXTCALLBACKW) 98 { 99 NMTTDISPINFOA ttnmdi; 100 101 /* fill NMHDR struct */ 102 ZeroMemory (&ttnmdi,sizeof(NMTTDISPINFOA)); 103 ttnmdi.hdr.hwndFrom = hwnd; 104 ttnmdi.hdr.idFrom = toolPtr->uId; 105 ttnmdi.hdr.code = TTN_GETDISPINFOA; 106 ttnmdi.lpszText = (LPSTR)&ttnmdi.szText; 107 ttnmdi.uFlags = toolPtr->uFlags; 108 ttnmdi.lParam = toolPtr->lParam; 109 // TRACE (tooltips, "hdr.idFrom = %x\n", ttnmdi.hdr.idFrom); 110 SendMessageA (toolPtr->hwnd,WM_NOTIFY,(WPARAM)toolPtr->uId,(LPARAM)&ttnmdi); 111 112 if ((ttnmdi.hinst) && (HIWORD((UINT)ttnmdi.szText) == 0)) 113 { 114 LoadStringW (ttnmdi.hinst,(UINT)ttnmdi.szText,infoPtr->szTipText,INFOTIPSIZE); 115 if (ttnmdi.uFlags & TTF_DI_SETITEM) 116 { 117 toolPtr->hinst = ttnmdi.hinst; 118 toolPtr->lpszText = (LPWSTR)ttnmdi.szText; 119 } 120 } else if (ttnmdi.szText[0]) 121 { 122 lstrcpynAtoW (infoPtr->szTipText,ttnmdi.szText,80); 123 if (ttnmdi.uFlags & TTF_DI_SETITEM) 124 { 125 INT len = lstrlenA(ttnmdi.szText); 126 toolPtr->hinst = 0; 127 toolPtr->lpszText = COMCTL32_Alloc((len+1)* sizeof(WCHAR)); 128 lstrcpyAtoW(toolPtr->lpszText,ttnmdi.szText); 129 } 130 } else if (ttnmdi.lpszText == 0) 131 { 132 /* no text available */ 133 infoPtr->szTipText[0] = L'\0'; 134 } else if (ttnmdi.lpszText != LPSTR_TEXTCALLBACKA) 135 { 136 lstrcpynAtoW(infoPtr->szTipText,ttnmdi.lpszText,INFOTIPSIZE); 137 if (ttnmdi.uFlags & TTF_DI_SETITEM) 138 { 139 INT len = lstrlenA(ttnmdi.lpszText); 140 toolPtr->hinst = 0; 141 toolPtr->lpszText = COMCTL32_Alloc((len+1)*sizeof(WCHAR)); 142 lstrcpyAtoW(toolPtr->lpszText,ttnmdi.lpszText); 143 } 144 } else 145 { 146 // ERR (tooltips, "recursive text callback!\n"); 147 infoPtr->szTipText[0] = '\0'; 146 148 } 147 else { 148 /* the item is a usual (unicode) text */ 149 // lstrcpynW (infoPtr->szTipText, toolPtr->lpszText, INFOTIPSIZE); 150 strncpy(infoPtr->szTipText, toolPtr->lpszText, INFOTIPSIZE); 151 } 152 } 153 else { 154 /* no text available */ 155 infoPtr->szTipText[0] = L'\0'; 149 } else 150 { 151 /* the item is a usual (unicode) text */ 152 lstrcpynW (infoPtr->szTipText,toolPtr->lpszText,INFOTIPSIZE); 153 } 154 } 155 else 156 { 157 /* no text available */ 158 infoPtr->szTipText[0] = L'\0'; 156 159 } 157 160 … … 159 162 } 160 163 161 162 164 static VOID 163 TOOLTIPS_CalcTipSize (HWND hwnd, TOOLTIPS_INFO *infoPtr,LPSIZE lpSize)165 TOOLTIPS_CalcTipSize (HWND hwnd,TOOLTIPS_INFO *infoPtr,LPSIZE lpSize) 164 166 { 165 167 HDC hdc; 166 168 HFONT hOldFont; 167 169 UINT uFlags = DT_EXTERNALLEADING | DT_CALCRECT; 168 RECT rc = {0, 0, 0,0};169 170 if (infoPtr->nMaxTipWidth > -1) {171 rc.right = infoPtr->nMaxTipWidth;172 uFlags |= DT_WORDBREAK;173 }174 if (GetWindowLongA (hwnd, GWL_STYLE) & TTS_NOPREFIX)175 170 RECT rc = {0,0,0,0}; 171 172 if (infoPtr->nMaxTipWidth > -1) 173 { 174 rc.right = infoPtr->nMaxTipWidth; 175 uFlags |= DT_WORDBREAK; 176 } 177 if (GetWindowLongA(hwnd,GWL_STYLE) & TTS_NOPREFIX) uFlags |= DT_NOPREFIX; 176 178 // TRACE (tooltips, "\"%s\"\n", debugstr_w(infoPtr->szTipText)); 177 179 178 hdc = GetDC (hwnd); 179 hOldFont = SelectObject (hdc, infoPtr->hFont); 180 DrawTextW (hdc, infoPtr->szTipText, -1, &rc, uFlags); 181 SelectObject (hdc, hOldFont); 182 ReleaseDC (hwnd, hdc); 183 184 lpSize->cx = rc.right - rc.left + 4 + 185 infoPtr->rcMargin.left + infoPtr->rcMargin.right; 186 lpSize->cy = rc.bottom - rc.top + 4 + 187 infoPtr->rcMargin.bottom + infoPtr->rcMargin.top; 180 hdc = GetDC(hwnd); 181 hOldFont = SelectObject(hdc,infoPtr->hFont); 182 DrawTextW(hdc,infoPtr->szTipText,-1,&rc,uFlags); 183 SelectObject(hdc,hOldFont); 184 ReleaseDC(hwnd,hdc); 185 186 lpSize->cx = rc.right-rc.left+4+infoPtr->rcMargin.left+infoPtr->rcMargin.right; 187 lpSize->cy = rc.bottom-rc.top+4+infoPtr->rcMargin.bottom+infoPtr->rcMargin.top; 188 188 } 189 189 … … 198 198 NMHDR hdr; 199 199 200 if (infoPtr->nTool == -1) { 200 if (infoPtr->nTool == -1) 201 { 201 202 // TRACE (tooltips, "invalid tool (-1)!\n"); 202 203 return; … … 207 208 // TRACE (tooltips, "Show tooltip pre %d!\n", infoPtr->nTool); 208 209 209 TOOLTIPS_GetTipText (hwnd, infoPtr, infoPtr->nCurrentTool); 210 211 if (infoPtr->szTipText[0] == L'\0') { 210 TOOLTIPS_GetTipText(hwnd,infoPtr,infoPtr->nCurrentTool); 211 212 if (infoPtr->szTipText[0] == L'\0') 213 { 212 214 infoPtr->nCurrentTool = -1; 213 215 return; … … 220 222 hdr.idFrom = toolPtr->uId; 221 223 hdr.code = TTN_SHOW; 222 SendMessageA (toolPtr->hwnd,WM_NOTIFY,223 (WPARAM)toolPtr->uId, 224 SendMessageA(toolPtr->hwnd,WM_NOTIFY, 225 (WPARAM)toolPtr->uId,(LPARAM)&hdr); 224 226 225 227 // TRACE (tooltips, "\"%s\"\n", debugstr_w(infoPtr->szTipText)); … … 228 230 // TRACE (tooltips, "size %d - %d\n", size.cx, size.cy); 229 231 230 if (toolPtr->uFlags & TTF_CENTERTIP) { 232 if (toolPtr->uFlags & TTF_CENTERTIP) 233 { 231 234 RECT rc; 232 235 233 236 if (toolPtr->uFlags & TTF_IDISHWND) 234 237 GetWindowRect ((HWND)toolPtr->uId, &rc); 235 else { 238 else 239 { 236 240 rc = toolPtr->rect; 237 241 MapWindowPoints (toolPtr->hwnd, (HWND)0, (LPPOINT)&rc, 2); … … 239 243 rect.left = (rc.left + rc.right - size.cx) / 2; 240 244 rect.top = rc.bottom + 2; 241 } 242 else{243 GetCursorPos 245 } else 246 { 247 GetCursorPos((LPPOINT)&rect); 244 248 rect.top += 20; 245 249 } … … 252 256 rect.bottom = rect.top + size.cy; 253 257 254 AdjustWindowRectEx (&rect, GetWindowLongA(hwnd, GWL_STYLE),255 FALSE, GetWindowLongA(hwnd, GWL_EXSTYLE));256 257 SetWindowPos (hwnd, HWND_TOP, rect.left,rect.top,258 rect.right - rect.left, rect.bottom -rect.top,258 AdjustWindowRectEx (&rect,GetWindowLongA(hwnd, GWL_STYLE), 259 FALSE,GetWindowLongA(hwnd, GWL_EXSTYLE)); 260 261 SetWindowPos (hwnd,HWND_TOP,rect.left,rect.top, 262 rect.right-rect.left,rect.bottom-rect.top, 259 263 SWP_SHOWWINDOW | SWP_NOACTIVATE); 260 264 261 265 /* repaint the tooltip */ 262 hdc = GetDC 263 TOOLTIPS_Refresh (hwnd,hdc);264 ReleaseDC (hwnd,hdc);265 266 SetTimer (hwnd, ID_TIMERPOP, infoPtr->nAutoPopTime,0);266 hdc = GetDC(hwnd); 267 TOOLTIPS_Refresh(hwnd,hdc); 268 ReleaseDC(hwnd,hdc); 269 270 SetTimer (hwnd,ID_TIMERPOP,infoPtr->nAutoPopTime,0); 267 271 } 268 272 … … 303 307 NMHDR hdr; 304 308 305 if (infoPtr->nTrackTool == -1) { 306 // TRACE (tooltips, "invalid tracking tool (-1)!\n"); 307 return; 309 if (infoPtr->nTrackTool == -1) 310 { 311 // TRACE (tooltips, "invalid tracking tool (-1)!\n"); 312 return; 308 313 } 309 314 310 315 // TRACE (tooltips, "show tracking tooltip pre %d!\n", infoPtr->nTrackTool); 311 316 312 TOOLTIPS_GetTipText (hwnd, infoPtr, infoPtr->nTrackTool); 313 314 if (infoPtr->szTipText[0] == L'\0') { 315 infoPtr->nTrackTool = -1; 316 return; 317 TOOLTIPS_GetTipText(hwnd,infoPtr,infoPtr->nTrackTool); 318 319 if (infoPtr->szTipText[0] == L'\0') 320 { 321 infoPtr->nTrackTool = -1; 322 return; 317 323 } 318 324 … … 323 329 hdr.idFrom = toolPtr->uId; 324 330 hdr.code = TTN_SHOW; 325 SendMessageA (toolPtr->hwnd, WM_NOTIFY, 326 (WPARAM)toolPtr->uId, (LPARAM)&hdr); 331 SendMessageA(toolPtr->hwnd,WM_NOTIFY,(WPARAM)toolPtr->uId,(LPARAM)&hdr); 327 332 328 333 // TRACE (tooltips, "\"%s\"\n", debugstr_w(infoPtr->szTipText)); 329 334 330 TOOLTIPS_CalcTipSize (hwnd, infoPtr,&size);335 TOOLTIPS_CalcTipSize(hwnd,infoPtr,&size); 331 336 // TRACE (tooltips, "size %d - %d\n", size.cx, size.cy); 332 337 333 if (toolPtr->uFlags & TTF_ABSOLUTE) { 334 rect.left = infoPtr->xTrackPos; 335 rect.top = infoPtr->yTrackPos; 336 337 if (toolPtr->uFlags & TTF_CENTERTIP) { 338 rect.left -= (size.cx / 2); 339 rect.top -= (size.cy / 2); 340 } 341 } 342 else { 343 RECT rcTool; 344 345 if (toolPtr->uFlags & TTF_IDISHWND) 346 GetWindowRect ((HWND)toolPtr->uId, &rcTool); 347 else { 348 rcTool = toolPtr->rect; 349 MapWindowPoints (toolPtr->hwnd, (HWND)0, (LPPOINT)&rcTool, 2); 350 } 351 352 GetCursorPos ((LPPOINT)&rect); 353 rect.top += 20; 354 355 if (toolPtr->uFlags & TTF_CENTERTIP) { 356 rect.left -= (size.cx / 2); 357 rect.top -= (size.cy / 2); 358 } 359 360 /* smart placement */ 361 if ((rect.left + size.cx > rcTool.left) && (rect.left < rcTool.right) && 362 (rect.top + size.cy > rcTool.top) && (rect.top < rcTool.bottom)) 363 rect.left = rcTool.right; 338 if (toolPtr->uFlags & TTF_ABSOLUTE) 339 { 340 rect.left = infoPtr->xTrackPos; 341 rect.top = infoPtr->yTrackPos; 342 343 if (toolPtr->uFlags & TTF_CENTERTIP) 344 { 345 rect.left -= (size.cx/2); 346 rect.top -= (size.cy/2); 347 } 348 } else 349 { 350 RECT rcTool; 351 352 if (toolPtr->uFlags & TTF_IDISHWND) 353 { 354 GetWindowRect((HWND)toolPtr->uId,&rcTool); //screen coordinates 355 } else 356 { 357 rcTool = toolPtr->rect; 358 MapWindowPoints(toolPtr->hwnd,(HWND)0,(LPPOINT)&rcTool,2); 359 } 360 361 GetCursorPos ((LPPOINT)&rect); 362 rect.top += 20; 363 364 if (toolPtr->uFlags & TTF_CENTERTIP) 365 { 366 rect.left -= (size.cx / 2); 367 rect.top -= (size.cy / 2); 368 } 369 370 /* smart placement */ 371 if ((rect.left + size.cx > rcTool.left) && (rect.left < rcTool.right) && 372 (rect.top + size.cy > rcTool.top) && (rect.top < rcTool.bottom)) 373 rect.left = rcTool.right; 364 374 } 365 375 366 376 // TRACE (tooltips, "pos %d - %d\n", rect.left, rect.top); 367 377 368 rect.right = rect.left +size.cx;369 rect.bottom = rect.top +size.cy;370 371 AdjustWindowRectEx (&rect, GetWindowLongA (hwnd,GWL_STYLE),372 FALSE, GetWindowLongA (hwnd,GWL_EXSTYLE));373 374 SetWindowPos (hwnd, HWND_TOP, rect.left,rect.top,375 rect.right - rect.left, rect.bottom -rect.top,378 rect.right = rect.left+size.cx; 379 rect.bottom = rect.top+size.cy; 380 381 AdjustWindowRectEx (&rect,GetWindowLongA(hwnd,GWL_STYLE), 382 FALSE,GetWindowLongA(hwnd,GWL_EXSTYLE)); 383 384 SetWindowPos (hwnd,HWND_TOP,rect.left,rect.top, 385 rect.right-rect.left,rect.bottom-rect.top, 376 386 SWP_SHOWWINDOW | SWP_NOACTIVATE ); 377 387 … … 564 574 565 575 static LRESULT 566 TOOLTIPS_AddToolA (HWND hwnd, WPARAM wParam,LPARAM lParam)567 { 568 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr 576 TOOLTIPS_AddToolA(HWND hwnd,WPARAM wParam,LPARAM lParam) 577 { 578 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(hwnd); 569 579 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam; 570 580 TTTOOL_INFO *toolPtr; 571 581 582 if (lpToolInfo == NULL) return FALSE; 583 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA) return FALSE; 584 585 // TRACE (tooltips, "add tool (%x) %x %d%s!\n", 586 // hwnd, lpToolInfo->hwnd, lpToolInfo->uId, 587 // (lpToolInfo->uFlags & TTF_IDISHWND) ? " TTF_IDISHWND" : ""); 588 589 if (infoPtr->uNumTools == 0) 590 { 591 infoPtr->tools = COMCTL32_Alloc(sizeof(TTTOOL_INFO)); 592 toolPtr = infoPtr->tools; 593 } else 594 { 595 TTTOOL_INFO *oldTools = infoPtr->tools; 596 597 //CB: check if already exists! 598 599 infoPtr->tools = COMCTL32_Alloc (sizeof(TTTOOL_INFO)*(infoPtr->uNumTools+1)); 600 memcpy (infoPtr->tools,oldTools,infoPtr->uNumTools*sizeof(TTTOOL_INFO)); 601 COMCTL32_Free(oldTools); 602 toolPtr = &infoPtr->tools[infoPtr->uNumTools]; 603 } 604 605 infoPtr->uNumTools++; 606 607 /* copy tool data */ 608 toolPtr->uFlags = lpToolInfo->uFlags; 609 toolPtr->hwnd = lpToolInfo->hwnd; 610 toolPtr->uId = lpToolInfo->uId; 611 toolPtr->rect = lpToolInfo->rect; 612 toolPtr->hinst = lpToolInfo->hinst; 613 614 if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)) 615 { 616 // TRACE (tooltips, "add string id %x!\n", (int)lpToolInfo->lpszText); 617 toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText; 618 } else if (lpToolInfo->lpszText) 619 { 620 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA) 621 { 622 // TRACE (tooltips, "add CALLBACK!\n"); 623 toolPtr->lpszText = LPSTR_TEXTCALLBACKW; 624 } else 625 { 626 INT len = lstrlenA (lpToolInfo->lpszText); 627 // TRACE (tooltips, "add text \"%s\"!\n", lpToolInfo->lpszText); 628 toolPtr->lpszText = COMCTL32_Alloc((len+1)*sizeof(WCHAR)); 629 lstrcpyAtoW (toolPtr->lpszText, lpToolInfo->lpszText); 630 } 631 } else toolPtr->lpszText = NULL; 632 633 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA)) 634 toolPtr->lParam = lpToolInfo->lParam; 635 636 /* install subclassing hook */ 637 if (toolPtr->uFlags & TTF_SUBCLASS) 638 { 639 if (toolPtr->uFlags & TTF_IDISHWND) 640 { 641 LPTT_SUBCLASS_INFO lpttsi = 642 (LPTT_SUBCLASS_INFO)GetPropA((HWND)toolPtr->uId,COMCTL32_aSubclass); 643 if (lpttsi == NULL) 644 { 645 lpttsi = (LPTT_SUBCLASS_INFO)COMCTL32_Alloc(sizeof(TT_SUBCLASS_INFO)); 646 lpttsi->wpOrigProc = 647 (WNDPROC)SetWindowLongA ((HWND)toolPtr->uId, 648 GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc); 649 lpttsi->hwndToolTip = hwnd; 650 lpttsi->uRefCount++; 651 SetPropA ((HWND)toolPtr->uId,COMCTL32_aSubclass,(HANDLE)lpttsi); 652 } 653 // else 654 // WARN (tooltips, "A window tool must only be listed once!\n"); 655 } else 656 { 657 LPTT_SUBCLASS_INFO lpttsi = 658 (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass); 659 if (lpttsi == NULL) 660 { 661 lpttsi = (LPTT_SUBCLASS_INFO)COMCTL32_Alloc(sizeof(TT_SUBCLASS_INFO)); 662 lpttsi->wpOrigProc = 663 (WNDPROC)SetWindowLongA (toolPtr->hwnd, 664 GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc); 665 lpttsi->hwndToolTip = hwnd; 666 lpttsi->uRefCount++; 667 SetPropA(toolPtr->hwnd,COMCTL32_aSubclass,(HANDLE)lpttsi); 668 } else lpttsi->uRefCount++; 669 } 670 // TRACE (tooltips, "subclassing installed!\n"); 671 } 672 673 return TRUE; 674 } 675 676 677 static LRESULT 678 TOOLTIPS_AddToolW (HWND hwnd, WPARAM wParam, LPARAM lParam) 679 { 680 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); 681 LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam; 682 TTTOOL_INFO *toolPtr; 683 572 684 if (lpToolInfo == NULL) 573 685 return FALSE; 574 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZE A)686 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW) 575 687 return FALSE; 576 688 … … 607 719 } 608 720 else if (lpToolInfo->lpszText) { 609 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACK A) {721 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKW) { 610 722 // TRACE (tooltips, "add CALLBACK!\n"); 611 723 toolPtr->lpszText = LPSTR_TEXTCALLBACKW; 612 724 } 613 725 else { 614 INT len = lstrlenA (lpToolInfo->lpszText); 615 // TRACE (tooltips, "add text \"%s\"!\n", lpToolInfo->lpszText); 726 INT len = lstrlenW (lpToolInfo->lpszText); 727 // TRACE (tooltips, "add text \"%s\"!\n", 728 // debugstr_w(lpToolInfo->lpszText)); 616 729 toolPtr->lpszText = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR)); 617 lstrcpy AtoW (toolPtr->lpszText, lpToolInfo->lpszText);730 lstrcpyW (toolPtr->lpszText, lpToolInfo->lpszText); 618 731 } 619 732 } 620 733 621 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFO A))734 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW)) 622 735 toolPtr->lParam = lpToolInfo->lParam; 623 736 … … 665 778 666 779 static LRESULT 667 TOOLTIPS_AddToolW (HWND hwnd, WPARAM wParam, LPARAM lParam)668 {669 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);670 LPTTTOOLINFOW lpToolInfo = (LPTTTOOLINFOW)lParam;671 TTTOOL_INFO *toolPtr;672 673 if (lpToolInfo == NULL)674 return FALSE;675 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)676 return FALSE;677 678 // TRACE (tooltips, "add tool (%x) %x %d%s!\n",679 // hwnd, lpToolInfo->hwnd, lpToolInfo->uId,680 // (lpToolInfo->uFlags & TTF_IDISHWND) ? " TTF_IDISHWND" : "");681 682 if (infoPtr->uNumTools == 0) {683 infoPtr->tools = COMCTL32_Alloc (sizeof(TTTOOL_INFO));684 toolPtr = infoPtr->tools;685 }686 else {687 TTTOOL_INFO *oldTools = infoPtr->tools;688 infoPtr->tools =689 COMCTL32_Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools + 1));690 memcpy (infoPtr->tools, oldTools,691 infoPtr->uNumTools * sizeof(TTTOOL_INFO));692 COMCTL32_Free (oldTools);693 toolPtr = &infoPtr->tools[infoPtr->uNumTools];694 }695 696 infoPtr->uNumTools++;697 698 /* copy tool data */699 toolPtr->uFlags = lpToolInfo->uFlags;700 toolPtr->hwnd = lpToolInfo->hwnd;701 toolPtr->uId = lpToolInfo->uId;702 toolPtr->rect = lpToolInfo->rect;703 toolPtr->hinst = lpToolInfo->hinst;704 705 if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)) {706 // TRACE (tooltips, "add string id %x!\n", (int)lpToolInfo->lpszText);707 toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;708 }709 else if (lpToolInfo->lpszText) {710 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKW) {711 // TRACE (tooltips, "add CALLBACK!\n");712 toolPtr->lpszText = LPSTR_TEXTCALLBACKW;713 }714 else {715 INT len = lstrlenW (lpToolInfo->lpszText);716 // TRACE (tooltips, "add text \"%s\"!\n",717 // debugstr_w(lpToolInfo->lpszText));718 toolPtr->lpszText = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));719 lstrcpyW (toolPtr->lpszText, lpToolInfo->lpszText);720 }721 }722 723 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW))724 toolPtr->lParam = lpToolInfo->lParam;725 726 /* install subclassing hook */727 if (toolPtr->uFlags & TTF_SUBCLASS) {728 if (toolPtr->uFlags & TTF_IDISHWND) {729 LPTT_SUBCLASS_INFO lpttsi =730 (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);731 if (lpttsi == NULL) {732 lpttsi =733 (LPTT_SUBCLASS_INFO)COMCTL32_Alloc (sizeof(TT_SUBCLASS_INFO));734 lpttsi->wpOrigProc =735 (WNDPROC)SetWindowLongA ((HWND)toolPtr->uId,736 GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc);737 lpttsi->hwndToolTip = hwnd;738 lpttsi->uRefCount++;739 SetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass,740 (HANDLE)lpttsi);741 }742 // else743 // WARN (tooltips, "A window tool must only be listed once!\n");744 }745 else {746 LPTT_SUBCLASS_INFO lpttsi =747 (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass);748 if (lpttsi == NULL) {749 lpttsi =750 (LPTT_SUBCLASS_INFO)COMCTL32_Alloc (sizeof(TT_SUBCLASS_INFO));751 lpttsi->wpOrigProc =752 (WNDPROC)SetWindowLongA (toolPtr->hwnd,753 GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc);754 lpttsi->hwndToolTip = hwnd;755 lpttsi->uRefCount++;756 SetPropA (toolPtr->hwnd, COMCTL32_aSubclass, (HANDLE)lpttsi);757 }758 else759 lpttsi->uRefCount++;760 }761 // TRACE (tooltips, "subclassing installed!\n");762 }763 764 return TRUE;765 }766 767 768 static LRESULT769 780 TOOLTIPS_DelToolA (HWND hwnd, WPARAM wParam, LPARAM lParam) 770 781 { … … 1401 1412 POINT pt; 1402 1413 1403 if (lParam == 0) { 1404 // ERR (tooltips, "lpMsg == NULL!\n"); 1405 return 0; 1406 } 1407 1408 switch (lpMsg->message) { 1414 if (lParam == 0) 1415 { 1416 // ERR (tooltips, "lpMsg == NULL!\n"); 1417 return 0; 1418 } 1419 1420 switch (lpMsg->message) 1421 { 1409 1422 case WM_LBUTTONDOWN: 1410 1423 case WM_LBUTTONUP: … … 1414 1427 case WM_RBUTTONUP: 1415 1428 pt = lpMsg->pt; 1416 ScreenToClient (lpMsg->hwnd,&pt);1429 ScreenToClient(lpMsg->hwnd,&pt); 1417 1430 infoPtr->nOldTool = infoPtr->nTool; 1418 infoPtr->nTool = TOOLTIPS_GetToolFromPoint (infoPtr, lpMsg->hwnd,&pt);1431 infoPtr->nTool = TOOLTIPS_GetToolFromPoint(infoPtr,lpMsg->hwnd,&pt); 1419 1432 // TRACE (tooltips, "tool (%x) %d %d\n", 1420 1433 // hwnd, infoPtr->nOldTool, infoPtr->nTool); … … 1424 1437 case WM_MOUSEMOVE: 1425 1438 pt = lpMsg->pt; 1426 ScreenToClient (lpMsg->hwnd,&pt);1439 ScreenToClient(lpMsg->hwnd,&pt); 1427 1440 infoPtr->nOldTool = infoPtr->nTool; 1428 infoPtr->nTool = TOOLTIPS_GetToolFromPoint (infoPtr, lpMsg->hwnd,&pt);1441 infoPtr->nTool = TOOLTIPS_GetToolFromPoint(infoPtr,lpMsg->hwnd,&pt); 1429 1442 // TRACE (tooltips, "tool (%x) %d %d\n", 1430 1443 // hwnd, infoPtr->nOldTool, infoPtr->nTool); 1431 1444 // TRACE (tooltips, "WM_MOUSEMOVE (%04x %ld %ld)\n", 1432 1445 // hwnd, pt.x, pt.y); 1433 if ((infoPtr->bActive) && (infoPtr->nTool != infoPtr->nOldTool)) { 1434 if (infoPtr->nOldTool == -1) { 1435 SetTimer (hwnd, ID_TIMERSHOW, infoPtr->nInitialTime, 0); 1436 // TRACE (tooltips, "timer 1 started!\n"); 1437 } 1438 else { 1439 TOOLTIPS_Hide (hwnd, infoPtr); 1440 SetTimer (hwnd, ID_TIMERSHOW, infoPtr->nReshowTime, 0); 1441 // TRACE (tooltips, "timer 2 started!\n"); 1442 } 1446 infoPtr->bActive = TRUE;//CB: somewhere reset, find it!!! 1447 if (infoPtr->bActive && (infoPtr->nTool != infoPtr->nOldTool)) 1448 { 1449 if (infoPtr->nOldTool == -1) 1450 { 1451 SetTimer(hwnd,ID_TIMERSHOW,infoPtr->nInitialTime,0); 1452 // TRACE (tooltips, "timer 1 started!\n"); 1453 } else 1454 { 1455 TOOLTIPS_Hide(hwnd,infoPtr); 1456 SetTimer (hwnd,ID_TIMERSHOW,infoPtr->nReshowTime,0); 1457 // TRACE (tooltips, "timer 2 started!\n"); 1458 } 1443 1459 } 1444 if (infoPtr->nCurrentTool != -1) { 1445 SetTimer (hwnd, ID_TIMERLEAVE, 100, 0); 1446 // TRACE (tooltips, "timer 3 started!\n"); 1460 if (infoPtr->nCurrentTool != -1) 1461 { 1462 SetTimer(hwnd,ID_TIMERLEAVE,100,0); 1463 // TRACE (tooltips, "timer 3 started!\n"); 1447 1464 } 1448 1465 break; … … 1655 1672 LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam; 1656 1673 1657 if (lpToolInfo == NULL) 1658 return 0;1659 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA) 1660 return FALSE;1661 1662 if ((BOOL)wParam) {1663 /* activate */1664 infoPtr->nTrackTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);1665 if (infoPtr->nTrackTool != -1){1666 // 1667 1668 TOOLTIPS_TrackShow (hwnd,infoPtr);1669 1670 } 1671 else{1672 1673 TOOLTIPS_TrackHide (hwnd,infoPtr);1674 1675 1676 1674 if (lpToolInfo == NULL) return 0; 1675 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA) return FALSE; 1676 1677 if ((BOOL)wParam) 1678 { 1679 /* activate */ 1680 infoPtr->nTrackTool = TOOLTIPS_GetToolFromInfoA(infoPtr,lpToolInfo); 1681 if (infoPtr->nTrackTool != -1) 1682 { 1683 // TRACE (tooltips, "activated!\n"); 1684 infoPtr->bTrackActive = TRUE; 1685 TOOLTIPS_TrackShow(hwnd,infoPtr); 1686 } 1687 } else 1688 { 1689 /* deactivate */ 1690 TOOLTIPS_TrackHide(hwnd,infoPtr); 1691 1692 infoPtr->bTrackActive = FALSE; 1693 infoPtr->nTrackTool = -1; 1677 1694 1678 1695 // TRACE (tooltips, "deactivated!\n"); … … 1691 1708 infoPtr->yTrackPos = (INT)HIWORD(lParam); 1692 1709 1693 if (infoPtr->bTrackActive) { 1710 if (infoPtr->bTrackActive) 1711 { 1694 1712 // TRACE (tooltips, "[%d %d]\n", 1695 1713 // infoPtr->xTrackPos, infoPtr->yTrackPos); 1696 1714 1697 TOOLTIPS_TrackShow (hwnd,infoPtr);1715 TOOLTIPS_TrackShow(hwnd,infoPtr); 1698 1716 } 1699 1717 … … 1722 1740 INT nTool; 1723 1741 1724 if (lpToolInfo == NULL) 1725 return 0; 1726 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA) 1727 return FALSE; 1728 1729 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo); 1742 if (lpToolInfo == NULL) return 0; 1743 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA) return FALSE; 1744 1745 nTool = TOOLTIPS_GetToolFromInfoA(infoPtr,lpToolInfo); 1730 1746 if (nTool == -1) return 0; 1731 1747 … … 1737 1753 toolPtr->hinst = lpToolInfo->hinst; 1738 1754 1739 if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)){ 1740 toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText; 1741 } 1742 else if (lpToolInfo->lpszText) { 1743 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA) 1744 toolPtr->lpszText = LPSTR_TEXTCALLBACKW; 1745 else { 1746 if (toolPtr->lpszText) { 1747 COMCTL32_Free (toolPtr->lpszText); 1748 toolPtr->lpszText = NULL; 1749 } 1750 if (lpToolInfo->lpszText) { 1751 INT len = lstrlenA (lpToolInfo->lpszText); 1752 toolPtr->lpszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR)); 1753 lstrcpyAtoW (toolPtr->lpszText, lpToolInfo->lpszText); 1754 } 1755 if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)) 1756 { 1757 toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText; 1758 } else if (lpToolInfo->lpszText) 1759 { 1760 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA) toolPtr->lpszText = LPSTR_TEXTCALLBACKW; 1761 else 1762 { 1763 if (toolPtr->lpszText) 1764 { 1765 COMCTL32_Free(toolPtr->lpszText); 1766 toolPtr->lpszText = NULL; 1755 1767 } 1768 if (lpToolInfo->lpszText) 1769 { 1770 INT len = lstrlenA(lpToolInfo->lpszText); 1771 toolPtr->lpszText = COMCTL32_Alloc((len+1)*sizeof(WCHAR)); 1772 lstrcpyAtoW(toolPtr->lpszText,lpToolInfo->lpszText); 1773 } 1774 } 1756 1775 } 1757 1776 1758 1777 /* force repaint */ 1759 if (infoPtr->bActive) 1760 TOOLTIPS_Show (hwnd, infoPtr); 1761 else if (infoPtr->bTrackActive) 1762 TOOLTIPS_TrackShow (hwnd, infoPtr); 1778 if (infoPtr->bActive) TOOLTIPS_Show(hwnd,infoPtr); 1779 else if (infoPtr->bTrackActive) TOOLTIPS_TrackShow(hwnd,infoPtr); 1763 1780 1764 1781 return 0; … … 1835 1852 1836 1853 /* allocate memory for info structure */ 1837 infoPtr = (TOOLTIPS_INFO *)COMCTL32_Alloc 1838 SetWindowLongA (hwnd, 0,(DWORD)infoPtr);1854 infoPtr = (TOOLTIPS_INFO *)COMCTL32_Alloc(sizeof(TOOLTIPS_INFO)); 1855 SetWindowLongA(hwnd,0,(DWORD)infoPtr); 1839 1856 1840 1857 /* initialize info structure */ 1841 1858 infoPtr->bActive = TRUE; 1842 1859 infoPtr->bTrackActive = FALSE; 1843 infoPtr->clrBk = GetSysColor (COLOR_INFOBK);1844 infoPtr->clrText = GetSysColor (COLOR_INFOTEXT);1860 infoPtr->clrBk = RGB(0,0,0);//GetSysColor(COLOR_INFOBK);//CB: to change 1861 infoPtr->clrText = RGB(255,255,255);//GetSysColor(COLOR_INFOTEXT);//CB: to change 1845 1862 1846 1863 nclm.cbSize = sizeof(NONCLIENTMETRICSA); 1847 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm,0);1848 infoPtr->hFont = CreateFontIndirectA 1864 SystemParametersInfoA(SPI_GETNONCLIENTMETRICS,0,&nclm,0); 1865 infoPtr->hFont = CreateFontIndirectA(&nclm.lfStatusFont); 1849 1866 1850 1867 infoPtr->nMaxTipWidth = -1; … … 1859 1876 infoPtr->nInitialTime = 500; 1860 1877 1861 nResult = (INT) SendMessageA (GetParent (hwnd), WM_NOTIFYFORMAT, 1862 (WPARAM)hwnd, (LPARAM)NF_QUERY); 1878 SetRectEmpty(&infoPtr->rcMargin); 1879 1880 nResult = (INT)SendMessageA(GetParent(hwnd),WM_NOTIFYFORMAT,(WPARAM)hwnd,(LPARAM)NF_QUERY); 1863 1881 // if (nResult == NFR_ANSI) 1864 1882 // TRACE (tooltips, " -- WM_NOTIFYFORMAT returns: NFR_ANSI\n"); … … 1868 1886 // FIXME (tooltips, " -- WM_NOTIFYFORMAT returns: error!\n"); 1869 1887 1870 SetWindowPos (hwnd, HWND_TOP, 0, 0, 0, 0,SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE);1888 SetWindowPos(hwnd,HWND_TOP,0,0,0,0,SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE); 1871 1889 1872 1890 return 0; … … 1877 1895 TOOLTIPS_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam) 1878 1896 { 1879 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr 1897 TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(hwnd); 1880 1898 TTTOOL_INFO *toolPtr; 1881 1899 INT i; 1882 1900 1883 1901 /* free tools */ 1884 if (infoPtr->tools) { 1885 for (i = 0; i < infoPtr->uNumTools; i++) { 1886 toolPtr = &infoPtr->tools[i]; 1887 if ((toolPtr->hinst) && (toolPtr->lpszText)) { 1888 if (toolPtr->lpszText != LPSTR_TEXTCALLBACKW) 1889 COMCTL32_Free (toolPtr->lpszText); 1890 } 1891 1892 /* remove subclassing */ 1893 if (toolPtr->uFlags & TTF_SUBCLASS) { 1894 LPTT_SUBCLASS_INFO lpttsi; 1895 1896 if (toolPtr->uFlags & TTF_IDISHWND) 1897 lpttsi = (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass); 1898 else 1899 lpttsi = (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass); 1900 1901 if (lpttsi) { 1902 SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC, 1903 (LONG)lpttsi->wpOrigProc); 1904 RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass); 1905 COMCTL32_Free (&lpttsi); 1906 } 1907 } 1902 if (infoPtr->tools) 1903 { 1904 for (i = 0;i < infoPtr->uNumTools;i++) 1905 { 1906 toolPtr = &infoPtr->tools[i]; 1907 if ((toolPtr->hinst) && (toolPtr->lpszText)) 1908 { 1909 if (toolPtr->lpszText != LPSTR_TEXTCALLBACKW) COMCTL32_Free(toolPtr->lpszText); 1908 1910 } 1909 COMCTL32_Free (infoPtr->tools); 1911 1912 /* remove subclassing */ 1913 if (toolPtr->uFlags & TTF_SUBCLASS) 1914 { 1915 LPTT_SUBCLASS_INFO lpttsi; 1916 1917 if (toolPtr->uFlags & TTF_IDISHWND) 1918 lpttsi = (LPTT_SUBCLASS_INFO)GetPropA((HWND)toolPtr->uId,COMCTL32_aSubclass); 1919 else 1920 lpttsi = (LPTT_SUBCLASS_INFO)GetPropA(toolPtr->hwnd,COMCTL32_aSubclass); 1921 1922 if (lpttsi) 1923 { 1924 SetWindowLongA ((HWND)toolPtr->uId,GWL_WNDPROC,(LONG)lpttsi->wpOrigProc); 1925 RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass); 1926 COMCTL32_Free (&lpttsi); 1927 } 1928 } 1929 } 1930 COMCTL32_Free (infoPtr->tools); 1910 1931 } 1911 1932 … … 1914 1935 1915 1936 /* free tool tips info data */ 1916 COMCTL32_Free 1937 COMCTL32_Free(infoPtr); 1917 1938 1918 1939 return 0; … … 1959 1980 TOOLTIPS_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam) 1960 1981 { 1961 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); 1982 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 1983 DWORD dwExStyle = GetWindowLongA(hwnd,GWL_EXSTYLE); 1962 1984 1963 1985 dwStyle &= 0x0000FFFF; 1964 1986 dwStyle |= (WS_POPUP | WS_BORDER | WS_CLIPSIBLINGS); 1965 SetWindowLongA (hwnd, GWL_STYLE, dwStyle); 1987 SetWindowLongA(hwnd,GWL_STYLE,dwStyle); 1988 1989 SetWindowLongA(hwnd,GWL_EXSTYLE,dwExStyle | WS_EX_TOOLWINDOW); 1966 1990 1967 1991 return TRUE; … … 2073 2097 switch (wParam) 2074 2098 { 2075 case ID_TIMERSHOW: 2076 KillTimer (hwnd, ID_TIMERSHOW); 2077 if (TOOLTIPS_CheckTool (hwnd, TRUE) == infoPtr->nTool) 2078 TOOLTIPS_Show (hwnd, infoPtr); 2079 break; 2080 2081 case ID_TIMERPOP: 2082 TOOLTIPS_Hide (hwnd, infoPtr); 2083 break; 2084 2085 case ID_TIMERLEAVE: 2086 KillTimer (hwnd, ID_TIMERLEAVE); 2087 if (TOOLTIPS_CheckTool (hwnd, FALSE) == -1) { 2088 infoPtr->nTool = -1; 2089 infoPtr->nOldTool = -1; 2090 TOOLTIPS_Hide (hwnd, infoPtr); 2091 } 2092 break; 2099 case ID_TIMERSHOW: 2100 KillTimer (hwnd,ID_TIMERSHOW); 2101 if (TOOLTIPS_CheckTool(hwnd,TRUE) == infoPtr->nTool) 2102 TOOLTIPS_Show(hwnd,infoPtr); 2103 break; 2104 2105 case ID_TIMERPOP: 2106 TOOLTIPS_Hide (hwnd, infoPtr); 2107 break; 2108 2109 case ID_TIMERLEAVE: 2110 KillTimer (hwnd,ID_TIMERLEAVE); 2111 if (TOOLTIPS_CheckTool(hwnd,FALSE) == -1) 2112 { 2113 infoPtr->nTool = -1; 2114 infoPtr->nOldTool = -1; 2115 TOOLTIPS_Hide(hwnd,infoPtr); 2116 } 2117 break; 2093 2118 } 2094 2119 return 0; -
trunk/src/comctl32/trackbar.c
r145 r180 1 /* $Id: trackbar.c,v 1. 6 1999-06-21 15:28:44cbratschi Exp $ */1 /* $Id: trackbar.c,v 1.7 1999-06-24 16:37:45 cbratschi Exp $ */ 2 2 /* 3 3 * Trackbar control … … 54 54 #define THUMB_MINLEN 4 55 55 56 #define CHANNEL_NOSEL_HEIGHT 4 57 #define CHANNEL_MIN_HEIGHT 458 #define CHANNEL_THUMB_DIFF 8 56 #define CHANNEL_NOSEL_HEIGHT 4 //min no sel height 57 #define CHANNEL_MIN_HEIGHT 6 //min sel height 58 #define CHANNEL_THUMB_DIFF 8 //sel thumb, channel difference 59 59 #define CHANNEL_SPACE 8 60 #define CHANNEL_SCALE_SPACE CHANNEL_THUMB_DIFF/2+SCALE_SIZE+SCALE_SPACE+BORDER_SIZE61 #define CHANNEL_THUMB_SPACE CHANNEL_THUMB_DIFF+BORDER_SIZE60 #define CHANNEL_SCALE_SPACE SCALE_SIZE+SCALE_SPACE+BORDER_SIZE 61 #define CHANNEL_THUMB_SPACE BORDER_SIZE 62 62 63 63 /* scroll mode */ … … 102 102 } 103 103 104 if (!(dwStyle & TBS_AUTOTICKS)) return; 105 106 if (infoPtr->uTicFreq == 0) 104 if (infoPtr->uTicFreq && infoPtr->nRangeMax > infoPtr->nRangeMin && (dwStyle & TBS_AUTOTICKS)) 105 { 106 //Tics without start and end tic 107 nrTics = (infoPtr->nRangeMax-infoPtr->nRangeMin)/infoPtr->uTicFreq-1; 108 if (nrTics <= 0) 109 { 110 COMCTL32_Free(infoPtr->tics); 111 infoPtr->tics = NULL; 112 infoPtr->uNumTics = 0; 113 return; 114 } 115 } else 107 116 { 108 117 COMCTL32_Free(infoPtr->tics); … … 112 121 } 113 122 114 if (infoPtr->uTicFreq && infoPtr->nRangeMax > infoPtr->nRangeMin && (dwStyle & TBS_AUTOTICKS))115 {116 //Tics without start and end tic117 nrTics = (infoPtr->nRangeMax-infoPtr->nRangeMin)/infoPtr->uTicFreq-1;118 } else119 {120 COMCTL32_Free(infoPtr->tics);121 infoPtr->tics = NULL;122 infoPtr->uNumTics = 0;123 return;124 }125 126 123 if (nrTics != infoPtr->uNumTics) 127 124 { … … 173 170 INT channelSize; 174 171 RECT lpRect,*channel = &infoPtr->rcChannel; 172 INT thumbDiff; 175 173 176 174 GetClientRect(hwnd,&lpRect); … … 179 177 else channelSize = CHANNEL_NOSEL_HEIGHT; 180 178 179 thumbDiff = (infoPtr->uThumbLen-channelSize)/2; 180 181 181 if (dwStyle & TBS_VERT) 182 182 { … … 184 184 channel->bottom = lpRect.bottom-CHANNEL_SPACE; 185 185 186 if (dwStyle & TBS_BOTH )186 if (dwStyle & TBS_BOTH || dwStyle & TBS_NOTICKS) 187 187 { //center 188 188 channel->left = (lpRect.right-channelSize)/2; … … 190 190 } else if (dwStyle & TBS_LEFT) 191 191 { 192 channel->left = lpRect.left+ CHANNEL_SCALE_SPACE;192 channel->left = lpRect.left+thumbDiff+CHANNEL_SCALE_SPACE; 193 193 channel->right = channel->left+channelSize; 194 194 } else 195 195 { //Right, align left 196 channel->left = lpRect.left+ CHANNEL_THUMB_SPACE;196 channel->left = lpRect.left+thumbDiff+CHANNEL_THUMB_SPACE; 197 197 channel->right = channel->left+channelSize; 198 198 } … … 201 201 channel->left = lpRect.left+CHANNEL_SPACE; 202 202 channel->right = lpRect.right-CHANNEL_SPACE; 203 if (dwStyle & TBS_BOTH )203 if (dwStyle & TBS_BOTH || dwStyle & TBS_NOTICKS) 204 204 { //center 205 205 channel->top = (lpRect.bottom-channelSize)/2; … … 207 207 } else if (dwStyle & TBS_TOP) 208 208 { 209 channel->top = lpRect.top+ CHANNEL_SCALE_SPACE;209 channel->top = lpRect.top+thumbDiff+CHANNEL_SCALE_SPACE; 210 210 channel->bottom = channel->top+channelSize; 211 211 } else 212 212 { //Bottom, align top 213 channel->top = lpRect.top+ CHANNEL_THUMB_SPACE;213 channel->top = lpRect.top+thumbDiff+CHANNEL_THUMB_SPACE; 214 214 channel->bottom = channel->top+channelSize; 215 215 } … … 680 680 { 681 681 int ticFlags = dwStyle & 0x0f; 682 COLORREF clrTic = GetSysColor(COLOR_3DDKSHADOW);682 COLORREF clrTic = RGB(0,0,0);//CB: black instead of GetSysColor(COLOR_3DDKSHADOW); 683 683 684 684 for (i = 0;i < infoPtr->uNumTics;i++) … … 714 714 HRGN hrgn,hrgnLast,hrgnNew; 715 715 716 if (dwStyle & TBS_NOTHUMB) return;717 718 716 //last 719 717 lastRect = infoPtr->rcFullThumb; 720 718 721 719 //new 722 if (infoPtr->flags & TB_DRAGPOSVALID) infoPtr->nPos = infoPtr->dragPos; 720 if (infoPtr->flags & TB_DRAGPOSVALID) 721 { 722 infoPtr->nPos = infoPtr->dragPos; 723 infoPtr->flags &= ~TB_DRAGPOSVALID; 724 } 723 725 if (infoPtr->nPos == lastPos) return; 726 727 if (dwStyle & TBS_NOTHUMB) return; 724 728 725 729 TRACKBAR_CalcThumb(hwnd,infoPtr); … … 1131 1135 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd); 1132 1136 int newMin,newMax; 1137 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 1138 1133 1139 newMin = (INT)LOWORD(lParam); 1134 1140 newMax = (INT)HIWORD(lParam); 1135 1141 1142 if (newMin >= newMax) return 0; 1136 1143 if (newMin == infoPtr->nRangeMin && newMax == infoPtr->nRangeMax) return 0; 1137 1144 … … 1141 1148 if (infoPtr->nPos < infoPtr->nRangeMin) 1142 1149 { 1143 infoPtr->nPos = infoPtr->nRangeMin; 1144 infoPtr->flags |= TB_THUMBPOSCHANGED; 1145 } 1146 1150 infoPtr->nPos = infoPtr->nRangeMin; 1151 infoPtr->flags |= TB_THUMBPOSCHANGED; 1152 } 1147 1153 if (infoPtr->nPos > infoPtr->nRangeMax) 1148 1154 { 1149 infoPtr->nPos = infoPtr->nRangeMax; 1150 infoPtr->flags |= TB_THUMBPOSCHANGED; 1155 infoPtr->nPos = infoPtr->nRangeMax; 1156 infoPtr->flags |= TB_THUMBPOSCHANGED; 1157 } 1158 1159 if (infoPtr->nSelMin < infoPtr->nRangeMin) 1160 { 1161 infoPtr->nSelMin = infoPtr->nRangeMin; 1162 infoPtr->flags |= TB_SELECTIONCHANGED; 1163 } 1164 if (infoPtr->nSelMin > infoPtr->nRangeMax) 1165 { 1166 infoPtr->nSelMin = infoPtr->nRangeMax; 1167 infoPtr->flags |= TB_SELECTIONCHANGED; 1168 } 1169 if (infoPtr->nSelMax < infoPtr->nRangeMin) 1170 { 1171 infoPtr->nSelMax = infoPtr->nRangeMin; 1172 infoPtr->flags |= TB_SELECTIONCHANGED; 1173 } 1174 if (infoPtr->nSelMax > infoPtr->nRangeMax) 1175 { 1176 infoPtr->nSelMax = infoPtr->nRangeMax; 1177 infoPtr->flags |= TB_SELECTIONCHANGED; 1151 1178 } 1152 1179 … … 1166 1193 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd); 1167 1194 1195 if ((INT)lParam <= infoPtr->nRangeMin) return 0; 1168 1196 if (infoPtr->nRangeMax == (INT)lParam) return 0; 1169 1197 … … 1171 1199 if (infoPtr->nPos > infoPtr->nRangeMax) 1172 1200 { 1173 1174 1201 infoPtr->nPos = infoPtr->nRangeMax; 1202 infoPtr->flags |=TB_THUMBPOSCHANGED; 1175 1203 } 1176 1204 … … 1190 1218 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd); 1191 1219 1220 if ((INT)lParam >= infoPtr->nRangeMax) return 0; 1192 1221 if (infoPtr->nRangeMin == (INT)lParam) return 0; 1193 1222 … … 1195 1224 if (infoPtr->nPos < infoPtr->nRangeMin) 1196 1225 { 1197 1198 1226 infoPtr->nPos = infoPtr->nRangeMin; 1227 infoPtr->flags |=TB_THUMBPOSCHANGED; 1199 1228 } 1200 1229 … … 1216 1245 if (infoPtr->uTicFreq == (UINT)wParam) return 0; 1217 1246 1218 if (!(GetWindowLongA (hwnd,GWL_STYLE) & TBS_AUTOTICKS)) return 0;1247 if (!(GetWindowLongA(hwnd,GWL_STYLE) & TBS_AUTOTICKS)) return 0; 1219 1248 1220 1249 infoPtr->uTicFreq = (UINT)wParam; … … 1229 1258 1230 1259 static LRESULT 1231 TRACKBAR_SetSel (HWND hwnd, WPARAM wParam, LPARAM lParam) 1232 { 1233 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd); 1234 INT newMin,newMax; 1235 1260 TRACKBAR_SetSel(HWND hwnd,WPARAM wParam,LPARAM lParam) 1261 { 1262 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd); 1263 INT newMin,newMax,oldMin,oldMax; 1264 1265 oldMin = infoPtr->nSelMin; 1266 oldMax = infoPtr->nSelMax; 1236 1267 newMin = (INT)LOWORD(lParam); 1237 1268 newMax = (INT)HIWORD(lParam); … … 1241 1272 infoPtr->nSelMax = newMax; 1242 1273 1243 infoPtr->flags |=TB_SELECTIONCHANGED; 1244 1245 if (!GetWindowLongA (hwnd, GWL_STYLE) & TBS_ENABLESELRANGE) 1246 return 0; 1247 1248 if (infoPtr->nSelMin < infoPtr->nRangeMin) 1249 infoPtr->nSelMin = infoPtr->nRangeMin; 1250 if (infoPtr->nSelMax > infoPtr->nRangeMax) 1251 infoPtr->nSelMax = infoPtr->nRangeMax; 1252 1253 if (wParam) TRACKBAR_Refresh(hwnd); 1274 if (infoPtr->nSelMin < infoPtr->nRangeMin) infoPtr->nSelMin = infoPtr->nRangeMin; 1275 if (infoPtr->nSelMin > infoPtr->nRangeMax) infoPtr->nSelMin = infoPtr->nRangeMax; 1276 if (infoPtr->nSelMax > infoPtr->nRangeMax) infoPtr->nSelMax = infoPtr->nRangeMax; 1277 if (infoPtr->nSelMax < infoPtr->nRangeMin) infoPtr->nSelMax = infoPtr->nRangeMin; 1278 1279 if (infoPtr->nSelMin > infoPtr->nSelMax) infoPtr->nSelMin = infoPtr->nSelMax; 1280 1281 if (!GetWindowLongA(hwnd, GWL_STYLE) & TBS_ENABLESELRANGE) return 0; 1282 1283 if (oldMin != newMin || oldMax != newMax) 1284 { 1285 infoPtr->flags |= TB_SELECTIONCHANGED; 1286 if (wParam) TRACKBAR_Refresh(hwnd); 1287 } 1254 1288 1255 1289 return 0; … … 1261 1295 { 1262 1296 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd); 1297 INT oldMax; 1263 1298 1264 1299 if (infoPtr->nSelMax == (INT)lParam) return 0; 1265 1300 1266 if (!GetWindowLongA (hwnd, GWL_STYLE) & TBS_ENABLESELRANGE) 1267 return 0; 1268 1301 oldMax = infoPtr->nSelMax; 1269 1302 infoPtr->nSelMax = (INT)lParam; 1270 infoPtr->flags |= TB_SELECTIONCHANGED; 1271 1272 if (infoPtr->nSelMax > infoPtr->nRangeMax) 1273 infoPtr->nSelMax = infoPtr->nRangeMax; 1274 1275 if (wParam) TRACKBAR_Refresh(hwnd); 1303 1304 if (infoPtr->nSelMax > infoPtr->nRangeMax) infoPtr->nSelMax = infoPtr->nRangeMax; 1305 if (infoPtr->nSelMax < infoPtr->nRangeMin) infoPtr->nSelMax = infoPtr->nRangeMin; 1306 1307 if (infoPtr->nSelMin > infoPtr->nSelMax) infoPtr->nSelMin = infoPtr->nSelMax; 1308 1309 if (!GetWindowLongA(hwnd,GWL_STYLE) & TBS_ENABLESELRANGE) return 0; 1310 1311 if (oldMax != infoPtr->nSelMax) 1312 { 1313 infoPtr->flags |= TB_SELECTIONCHANGED; 1314 if (wParam) TRACKBAR_Refresh(hwnd); 1315 } 1276 1316 1277 1317 return 0; … … 1283 1323 { 1284 1324 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd); 1325 INT oldMin; 1285 1326 1286 1327 if (infoPtr->nSelMin == (INT)lParam) return 0; 1287 1328 1288 if (!GetWindowLongA (hwnd, GWL_STYLE) & TBS_ENABLESELRANGE) 1289 return 0; 1290 1329 oldMin = infoPtr->nSelMin; 1291 1330 infoPtr->nSelMin = (INT)lParam; 1292 infoPtr->flags |= TB_SELECTIONCHANGED; 1293 1294 if (infoPtr->nSelMin < infoPtr->nRangeMin) 1295 infoPtr->nSelMin = infoPtr->nRangeMin; 1296 1297 if (wParam) TRACKBAR_Refresh(hwnd); 1331 1332 if (infoPtr->nSelMin < infoPtr->nRangeMin) infoPtr->nSelMin = infoPtr->nRangeMin; 1333 if (infoPtr->nSelMin > infoPtr->nRangeMax) infoPtr->nSelMin = infoPtr->nRangeMax; 1334 1335 if (infoPtr->nSelMin > infoPtr->nSelMax) infoPtr->nSelMin = infoPtr->nSelMax; 1336 1337 if (!GetWindowLongA(hwnd,GWL_STYLE) & TBS_ENABLESELRANGE) return 0; 1338 1339 if (oldMin != infoPtr->nSelMin) 1340 { 1341 infoPtr->flags |= TB_SELECTIONCHANGED; 1342 if (wParam) TRACKBAR_Refresh(hwnd); 1343 } 1298 1344 1299 1345 return 0; … … 1406 1452 INT scaleSize; 1407 1453 1408 Get WindowRect(hwnd,&clientRect);1454 GetClientRect(hwnd,&clientRect); 1409 1455 infoPtr->uThumbLen = THUMB_LEN; /* initial thumb length */ 1410 1456 … … 1455 1501 infoPtr->uTicFreq = 1; 1456 1502 infoPtr->tics = NULL; 1457 infoPtr->clrBk = GetSysColor 1458 infoPtr->hwndNotify = GetParent 1503 infoPtr->clrBk = GetSysColor(COLOR_3DFACE); 1504 infoPtr->hwndNotify = GetParent(hwnd); 1459 1505 1460 1506 TRACKBAR_InitializeThumb (hwnd); 1461 1507 1462 1508 /* Create tooltip control */ 1463 if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_TOOLTIPS) { 1464 TTTOOLINFOA ti; 1465 1466 infoPtr->hwndToolTip = 1467 CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0, 1468 CW_USEDEFAULT, CW_USEDEFAULT, 1469 CW_USEDEFAULT, CW_USEDEFAULT, 1470 hwnd, 0, 0, 0); 1471 1472 /* Send NM_TOOLTIPSCREATED notification */ 1473 if (infoPtr->hwndToolTip) { 1474 NMTOOLTIPSCREATED nmttc; 1475 1476 nmttc.hdr.hwndFrom = hwnd; 1477 nmttc.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 1478 nmttc.hdr.code = NM_TOOLTIPSCREATED; 1479 nmttc.hwndToolTips = infoPtr->hwndToolTip; 1480 1481 SendMessageA (GetParent (hwnd), WM_NOTIFY, 1482 (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc); 1483 } 1484 1485 ZeroMemory (&ti, sizeof(TTTOOLINFOA)); 1486 ti.cbSize = sizeof(TTTOOLINFOA); 1487 ti.uFlags = TTF_IDISHWND | TTF_TRACK; 1488 ti.hwnd = hwnd; 1489 ti.uId = 0; 1490 ti.lpszText = "Test"; /* LPSTR_TEXTCALLBACK */ 1491 SetRectEmpty (&ti.rect); 1492 1493 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA, 0, (LPARAM)&ti); 1509 if (GetWindowLongA(hwnd,GWL_STYLE) & TBS_TOOLTIPS) 1510 { 1511 TTTOOLINFOA ti; 1512 1513 infoPtr->hwndToolTip = 1514 CreateWindowExA (WS_EX_TOOLWINDOW,TOOLTIPS_CLASSA,NULL,WS_POPUP, 1515 CW_USEDEFAULT,CW_USEDEFAULT, 1516 CW_USEDEFAULT,CW_USEDEFAULT, 1517 hwnd,0,0,0); 1518 1519 /* Send NM_TOOLTIPSCREATED notification */ 1520 if (infoPtr->hwndToolTip) 1521 { 1522 NMTOOLTIPSCREATED nmttc; 1523 1524 nmttc.hdr.hwndFrom = hwnd; 1525 nmttc.hdr.idFrom = GetWindowLongA(hwnd,GWL_ID); 1526 nmttc.hdr.code = NM_TOOLTIPSCREATED; 1527 nmttc.hwndToolTips = infoPtr->hwndToolTip; 1528 1529 SendMessageA(GetParent(hwnd),WM_NOTIFY,(WPARAM)nmttc.hdr.idFrom,(LPARAM)&nmttc); 1530 } 1531 1532 ZeroMemory(&ti,sizeof(TTTOOLINFOA)); 1533 ti.cbSize = sizeof(TTTOOLINFOA); 1534 ti.uFlags = TTF_TRACK | TTF_CENTERTIP; 1535 ti.hwnd = hwnd; 1536 ti.uId = 0; 1537 ti.lpszText = "Test"; /* LPSTR_TEXTCALLBACK */ 1538 SetRectEmpty(&ti.rect); 1539 1540 SendMessageA(infoPtr->hwndToolTip,TTM_ADDTOOLA,0,(LPARAM)&ti); 1494 1541 } 1495 1542 … … 1504 1551 1505 1552 /* delete tooltip control */ 1506 if (infoPtr->hwndToolTip) 1507 DestroyWindow (infoPtr->hwndToolTip); 1508 1509 COMCTL32_Free (infoPtr); 1553 if (infoPtr->hwndToolTip) DestroyWindow(infoPtr->hwndToolTip); 1554 1555 COMCTL32_Free(infoPtr->tics); 1556 COMCTL32_Free(infoPtr); 1557 1510 1558 return 0; 1511 1559 } … … 1549 1597 TTTOOLINFOA ti; 1550 1598 POINT pt; 1551 1552 GetCursorPos (&pt); 1553 SendMessageA (infoPtr->hwndToolTip, TTM_TRACKPOSITION, 0,1554 (LPARAM)MAKELPARAM(pt.x,pt.y));1599 char buf[80]; 1600 1601 GetCursorPos(&pt); 1602 SendMessageA(infoPtr->hwndToolTip,TTM_TRACKPOSITION,0,(LPARAM)MAKELPARAM(pt.x,pt.y)); 1555 1603 1556 1604 ti.cbSize = sizeof(TTTOOLINFOA); 1557 1605 ti.uId = 0; 1558 1606 ti.hwnd = (UINT)hwnd; 1607 ti.hinst = 0; 1608 sprintf (buf,"%d",infoPtr->nPos); 1609 ti.lpszText = (LPSTR)buf; 1559 1610 1560 1611 infoPtr->flags |= TB_SHOW_TOOLTIP; 1561 SetCapture (hwnd); 1562 SendMessageA (infoPtr->hwndToolTip, TTM_TRACKACTIVATE, 1563 (WPARAM)TRUE, (LPARAM)&ti); 1612 SetCapture(hwnd); 1613 1614 SendMessageA(infoPtr->hwndToolTip,TTM_UPDATETIPTEXTA,0,(LPARAM)&ti); 1615 SendMessageA(infoPtr->hwndToolTip,TTM_TRACKACTIVATE,(WPARAM)TRUE,(LPARAM)&ti); 1564 1616 } 1565 1617 SetCapture(hwnd); … … 1634 1686 1635 1687 if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_TOOLTIPS) 1636 { /* disable tooltip */ 1637 TTTOOLINFOA ti; 1638 1639 ti.cbSize = sizeof(TTTOOLINFOA); 1640 ti.uId = 0; 1641 ti.hwnd = (UINT)hwnd; 1642 1643 infoPtr->flags &= ~TB_SHOW_TOOLTIP; 1644 SendMessageA (infoPtr->hwndToolTip, TTM_TRACKACTIVATE, 1645 (WPARAM)FALSE, (LPARAM)&ti); 1688 { /* disable tooltip */ 1689 TTTOOLINFOA ti; 1690 1691 ti.cbSize = sizeof(TTTOOLINFOA); 1692 ti.uId = 0; 1693 ti.hwnd = (UINT)hwnd; 1694 1695 infoPtr->flags &= ~TB_SHOW_TOOLTIP; 1696 SendMessageA (infoPtr->hwndToolTip,TTM_TRACKACTIVATE,(WPARAM)FALSE,(LPARAM)&ti); 1646 1697 } 1647 1698 … … 1792 1843 // TRACE (trackbar, "%x\n",code); 1793 1844 1794 if (GetWindowLongA (hwnd, GWL_STYLE) & TBS_VERT) 1795 return (BOOL) SendMessageA (GetParent (hwnd), 1796 WM_VSCROLL, (WPARAM)code, (LPARAM)hwnd); 1797 1798 return (BOOL) SendMessageA (GetParent (hwnd), 1799 WM_HSCROLL, (WPARAM)code, (LPARAM)hwnd); 1845 if (GetWindowLongA(hwnd, GWL_STYLE) & TBS_VERT) 1846 { 1847 return (BOOL)SendMessageA(GetParent(hwnd),WM_VSCROLL,(WPARAM)code,(LPARAM)hwnd); 1848 } else 1849 { 1850 return (BOOL)SendMessageA(GetParent(hwnd),WM_HSCROLL,(WPARAM)code,(LPARAM)hwnd); 1851 } 1800 1852 } 1801 1853 … … 1805 1857 { 1806 1858 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd); 1807 DWORD dwStyle = GetWindowLongA (hwnd,GWL_STYLE);1859 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 1808 1860 SHORT clickPlace; 1809 1861 DOUBLE dragPos; 1810 char buf[80];1811 INT lastDragPos;1812 1862 1813 1863 // TRACE (trackbar, "%x\n",wParam); 1814 1864 1815 if (dwStyle & TBS_VERT) clickPlace=(SHORT)HIWORD(lParam);1816 else clickPlace=(SHORT)LOWORD(lParam);1817 1818 1865 if (!(infoPtr->flags & TB_DRAG_MODE)) return TRUE; 1819 1866 1820 lastDragPos = infoPtr->dragPos; 1821 dragPos = TRACKBAR_ConvertPlaceToPosition (infoPtr, clickPlace, 1822 dwStyle & TBS_VERT); 1867 if (dwStyle & TBS_VERT) clickPlace = (SHORT)HIWORD(lParam); 1868 else clickPlace = (SHORT)LOWORD(lParam); 1869 1870 dragPos = TRACKBAR_ConvertPlaceToPosition(infoPtr,clickPlace,dwStyle & TBS_VERT); 1823 1871 if (dragPos > ((INT)dragPos)+0.5) infoPtr->dragPos = dragPos + 1; 1824 1872 else infoPtr->dragPos = dragPos; 1825 1873 1826 if ( lastDragPos == infoPtr->dragPos) return TRUE; //nothing changed1874 if (infoPtr->nPos == infoPtr->dragPos) return TRUE; //nothing changed 1827 1875 1828 1876 infoPtr->flags |= TB_DRAGPOSVALID; 1829 TRACKBAR_SendNotify (hwnd, TB_THUMBTRACK | (infoPtr->nPos>>16)); 1877 1878 TRACKBAR_UpdateThumbPosition(hwnd,infoPtr->nPos); //infoPtr->nPos now set 1879 1880 TRACKBAR_SendNotify(hwnd,TB_THUMBTRACK | (infoPtr->nPos >> 16)); 1830 1881 1831 1882 if (infoPtr->flags & TB_SHOW_TOOLTIP) 1832 1883 { 1833 POINT pt; 1834 TTTOOLINFOA ti; 1835 1836 ti.cbSize = sizeof(TTTOOLINFOA); 1837 ti.hwnd = hwnd; 1838 ti.uId = 0; 1839 ti.hinst=0; 1840 sprintf (buf,"%d",infoPtr->nPos); 1841 ti.lpszText = (LPSTR) buf; 1842 GetCursorPos (&pt); 1843 1844 if (dwStyle & TBS_VERT) { 1845 SendMessageA (infoPtr->hwndToolTip, TTM_TRACKPOSITION, 1846 0, (LPARAM)MAKELPARAM(pt.x+5, pt.y+15)); 1847 } else { 1848 SendMessageA (infoPtr->hwndToolTip, TTM_TRACKPOSITION, 1849 0, (LPARAM)MAKELPARAM(pt.x+15, pt.y+5)); 1850 } 1851 SendMessageA (infoPtr->hwndToolTip, TTM_UPDATETIPTEXTA, 1852 0, (LPARAM)&ti); 1853 } 1854 1855 TRACKBAR_UpdateThumbPosition(hwnd,lastDragPos); 1884 POINT pt; 1885 TTTOOLINFOA ti; 1886 char buf[80]; 1887 1888 ti.cbSize = sizeof(TTTOOLINFOA); 1889 ti.hwnd = hwnd; 1890 ti.uId = 0; 1891 ti.hinst = 0; 1892 sprintf (buf,"%d",infoPtr->nPos); 1893 ti.lpszText = (LPSTR)buf; 1894 GetCursorPos(&pt); 1895 1896 SendMessageA(infoPtr->hwndToolTip,TTM_UPDATETIPTEXTA,0,(LPARAM)&ti); 1897 if (dwStyle & TBS_VERT) 1898 { 1899 SendMessageA(infoPtr->hwndToolTip,TTM_TRACKPOSITION,0,(LPARAM)MAKELPARAM(pt.x+5,pt.y+15)); //CB: optimize 1900 } else 1901 { 1902 SendMessageA(infoPtr->hwndToolTip,TTM_TRACKPOSITION,0,(LPARAM)MAKELPARAM(pt.x+15,pt.y+5)); //CB: optimize 1903 } 1904 } 1856 1905 1857 1906 return TRUE; … … 1862 1911 TRACKBAR_KeyDown (HWND hwnd, WPARAM wParam, LPARAM lParam) 1863 1912 { 1864 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr 1913 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(hwnd); 1865 1914 INT pos; 1866 1915 1867 1916 // TRACE (trackbar, "%x\n",wParam); 1868 1917 1869 pos=infoPtr->nPos; 1918 if (infoPtr->flags & TB_DRAG_MODE) return TRUE; 1919 1920 pos = infoPtr->nPos; 1870 1921 switch (wParam) { 1871 1922 case VK_LEFT: … … 1924 1975 TRACKBAR_KeyUp (HWND hwnd, WPARAM wParam) 1925 1976 { 1977 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(hwnd); 1978 1979 if (infoPtr->flags & TB_DRAG_MODE) return TRUE; 1980 1926 1981 switch (wParam) { 1927 1982 case VK_LEFT: -
trunk/src/comctl32/updown.c
r110 r180 1 /* $Id: updown.c,v 1. 4 1999-06-16 20:25:45cbratschi Exp $ */1 /* $Id: updown.c,v 1.5 1999-06-24 16:37:46 cbratschi Exp $ */ 2 2 /* 3 3 * Updown control … … 8 8 * 9 9 * TODO: 10 * - subclass the buddy window (in UPDOWN_SetBuddy ) to process the10 * - subclass the buddy window (in UPDOWN_SetBuddyHandle) to process the 11 11 * arrow keys 12 12 * - I am not sure about the default values for the Min, Max, Pos … … 33 33 */ 34 34 35 /* CB: Odin32 problems 36 - Open32 doesn't look for CS_DBLCLKS -> double clicks always sent 37 */ 38 35 39 #include <stdlib.h> 36 40 #include <stdio.h> … … 71 75 #define UNKNOWN_PARAM(msg, wParam, lParam) 72 76 73 #define UPDOWN_GetInfoPtr(hwnd) ((UPDOWN_INFO *)GetWindowLongA 77 #define UPDOWN_GetInfoPtr(hwnd) ((UPDOWN_INFO *)GetWindowLongA(hwnd,0)) 74 78 75 79 … … 128 132 GetClientRect (hwnd, rect); 129 133 130 if (GetWindowLongA (hwnd, GWL_STYLE) & UDS_HORZ) { 131 len = rect->right - rect->left; /* compute the width */ 132 if (incr) 133 rect->left = len/2+1; 134 else 135 rect->right = len/2; 136 } 137 else { 138 len = rect->bottom - rect->top; /* compute the height */ 139 if (incr) 140 rect->bottom = len/2; 141 else 142 rect->top = len/2+1; 134 if (GetWindowLongA(hwnd, GWL_STYLE) & UDS_HORZ) 135 { 136 len = rect->right-rect->left; /* compute the width */ 137 if (incr) rect->left = len/2+1; 138 else rect->right = len/2; 139 } else 140 { 141 len = rect->bottom-rect->top; /* compute the height */ 142 if (incr) rect->bottom = len/2; 143 else rect->top = len/2+1; 143 144 } 144 145 } … … 191 192 int newVal; 192 193 193 if (!IsWindow(infoPtr->Buddy)) 194 return FALSE; 194 if (!IsWindow(infoPtr->Buddy)) return FALSE; 195 195 196 196 /*if the buddy is a list window, we must set curr index */ 197 if (!lstrcmpA (infoPtr->szBuddyClass, "ListBox")){198 newVal = SendMessageA(infoPtr->Buddy, LB_GETCARETINDEX, 0, 0);199 if(newVal < 0)200 201 } 202 else{197 if (!lstrcmpA(infoPtr->szBuddyClass,"ListBox")) 198 { 199 newVal = SendMessageA(infoPtr->Buddy,LB_GETCARETINDEX,0,0); 200 if(newVal < 0) return FALSE; 201 } else 202 { 203 203 /* we have a regular window, so will get the text */ 204 if (!GetWindowTextA(infoPtr->Buddy, txt, sizeof(txt))) 205 return FALSE; 204 if (!GetWindowTextA(infoPtr->Buddy,txt,sizeof(txt))) return FALSE; 206 205 207 206 sep = UPDOWN_GetThousandSep(); 208 207 209 208 /* now get rid of the separators */ 210 for(src = dst = txt; *src;src++)211 if (*src != sep)209 for(src = dst = txt;*src;src++) 210 if (*src != sep) 212 211 *dst++ = *src; 213 212 *dst = 0; 214 213 215 214 /* try to convert the number and validate it */ 216 newVal = strtol(txt, &src, infoPtr->Base); 217 if(*src || !UPDOWN_InBounds (hwnd, newVal)) 218 return FALSE; 215 newVal = strtol(txt,&src,infoPtr->Base); 216 if (*src || !UPDOWN_InBounds(hwnd,newVal)) return FALSE; 219 217 220 218 // TRACE(updown, "new value(%d) read from buddy (old=%d)\n", … … 223 221 224 222 infoPtr->CurVal = newVal; 223 225 224 return TRUE; 226 225 } … … 236 235 static BOOL UPDOWN_SetBuddyInt (HWND hwnd) 237 236 { 238 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr 239 char txt1[20], 237 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr(hwnd); 238 char txt1[20],sep; 240 239 int len; 241 240 242 if (!IsWindow(infoPtr->Buddy)) 243 return FALSE; 241 if (!IsWindow(infoPtr->Buddy)) return FALSE; 244 242 245 243 // TRACE(updown, "set new value(%d) to buddy.\n", … … 247 245 248 246 /*if the buddy is a list window, we must set curr index */ 249 if(!lstrcmpA (infoPtr->szBuddyClass, "ListBox")){ 250 SendMessageA(infoPtr->Buddy, LB_SETCURSEL, infoPtr->CurVal, 0); 251 } 252 else{ /* Regular window, so set caption to the number */ 253 len = sprintf(txt1, (infoPtr->Base==16) ? "%X" : "%d", infoPtr->CurVal); 247 if(!lstrcmpA(infoPtr->szBuddyClass, "ListBox")) 248 { 249 SendMessageA(infoPtr->Buddy,LB_SETCURSEL,infoPtr->CurVal,0); 250 } else 251 { /* Regular window, so set caption to the number */ 252 len = sprintf(txt1,(infoPtr->Base == 16) ? "%X" : "%d",infoPtr->CurVal); 254 253 255 254 sep = UPDOWN_GetThousandSep(); … … 282 281 * Draw the arrows. The background need not be erased. 283 282 */ 284 static void UPDOWN_Draw (HWND hwnd,HDC hdc)285 { 286 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr 287 DWORD dwStyle = GetWindowLongA 283 static void UPDOWN_Draw(HWND hwnd,HDC hdc) 284 { 285 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr(hwnd); 286 DWORD dwStyle = GetWindowLongA(hwnd, GWL_STYLE); 288 287 BOOL prssed; 289 288 RECT rect; … … 298 297 299 298 /* Draw the space between the buttons */ 300 rect.top = rect.bottom; rect.bottom++; 299 rect.top = rect.bottom; 300 rect.bottom++; 301 301 DrawEdge(hdc, &rect, 0, BF_MIDDLE); 302 302 … … 343 343 344 344 /*********************************************************************** 345 * UPDOWN_SetBuddy 345 * UPDOWN_SetBuddyHandle 346 346 * Tests if 'hwndBud' is a valid window handle. If not, returns FALSE. 347 347 * Else, sets it as a new Buddy. … … 352 352 * the size/pos of the buddy and the control are adjusted accordingly. 353 353 */ 354 static BOOL UPDOWN_SetBuddy (HWND hwnd, HWND hwndBud)354 static BOOL UPDOWN_SetBuddyHandle (HWND hwnd, HWND hwndBud) 355 355 { 356 356 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr (hwnd); … … 420 420 static void UPDOWN_DoAction (HWND hwnd, int delta, BOOL incr) 421 421 { 422 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr 423 DWORD dwStyle = GetWindowLongA (hwnd,GWL_STYLE);422 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr(hwnd); 423 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 424 424 int old_val = infoPtr->CurVal; 425 425 NM_UPDOWN ni; … … 429 429 /* check if we can do the modification first */ 430 430 delta *= (incr ? 1 : -1) * (infoPtr->MaxVal < infoPtr->MinVal ? -1 : 1); 431 if(!UPDOWN_OffsetVal (hwnd, delta)) 432 return; 431 if(!UPDOWN_OffsetVal(hwnd,delta)) return; 433 432 434 433 /* so, if we can do the change, recompute delta and restore old value */ 435 delta = infoPtr->CurVal -old_val;434 delta = infoPtr->CurVal-old_val; 436 435 infoPtr->CurVal = old_val; 437 436 … … 440 439 ni.iDelta = delta; 441 440 ni.hdr.hwndFrom = hwnd; 442 ni.hdr.idFrom = GetWindowLongA (hwnd,GWL_ID);441 ni.hdr.idFrom = GetWindowLongA(hwnd,GWL_ID); 443 442 ni.hdr.code = UDN_DELTAPOS; 444 if (SendMessageA(GetParent (hwnd),WM_NOTIFY,445 (WPARAM)ni.hdr.idFrom, 443 if (SendMessageA(GetParent(hwnd),WM_NOTIFY, 444 (WPARAM)ni.hdr.idFrom,(LPARAM)&ni)) 446 445 return; /* we are not allowed to change */ 447 446 448 447 /* Now adjust value with (maybe new) delta */ 449 if (!UPDOWN_OffsetVal (hwnd, ni.iDelta)) 450 return; 448 if (!UPDOWN_OffsetVal (hwnd,ni.iDelta)) return; 451 449 452 450 /* Now take care about our buddy */ … … 455 453 456 454 457 if (dwStyle & UDS_SETBUDDYINT) 458 UPDOWN_SetBuddyInt (hwnd); 455 if (dwStyle & UDS_SETBUDDYINT) UPDOWN_SetBuddyInt(hwnd); 459 456 460 457 /* Also, notify it */ … … 529 526 case WM_LBUTTONDOWN: /* Initialise mouse tracking */ 530 527 /* If we are already in the 'clicked' mode, then nothing to do */ 531 if(infoPtr->Flags & FLAG_CLICKED) 532 return; 528 if (infoPtr->Flags & FLAG_CLICKED) return; 533 529 534 530 /* If the buddy is an edit, will set focus to it */ 535 if (!lstrcmpA (infoPtr->szBuddyClass, "Edit")) 536 SetFocus(infoPtr->Buddy); 531 if (!lstrcmpA(infoPtr->szBuddyClass,"Edit")) SetFocus(infoPtr->Buddy); 537 532 538 533 /* Now see which one is the 'active' arrow */ 539 temp = UPDOWN_GetArrowFromPoint (hwnd, &rect,pt);534 temp = UPDOWN_GetArrowFromPoint(hwnd,&rect,pt); 540 535 541 536 /* Update the CurVal if necessary */ 542 if (dwStyle & UDS_SETBUDDYINT) 543 UPDOWN_GetBuddyInt (hwnd); 537 if (dwStyle & UDS_SETBUDDYINT) UPDOWN_GetBuddyInt(hwnd); 544 538 545 539 /* Before we proceed, see if we can spin... */ 546 if (!(dwStyle & UDS_WRAP))547 if (( temp && infoPtr->CurVal==infoPtr->MaxVal) ||548 (!temp && infoPtr->CurVal ==infoPtr->MinVal))540 if (!(dwStyle & UDS_WRAP)) 541 if ((temp && infoPtr->CurVal == infoPtr->MaxVal) || 542 (!temp && infoPtr->CurVal == infoPtr->MinVal)) 549 543 return; 550 544 … … 558 552 559 553 /* process the click */ 560 UPDOWN_DoAction (hwnd, 1,infoPtr->Flags & FLAG_INCR);554 UPDOWN_DoAction (hwnd,1,infoPtr->Flags & FLAG_INCR); 561 555 562 556 /* now capture all mouse messages */ … … 564 558 565 559 /* and startup the first timer */ 566 SetTimer(hwnd, TIMERID1, INITIAL_DELAY,0);560 SetTimer(hwnd,TIMERID1,INITIAL_DELAY,0); 567 561 break; 568 562 569 563 case WM_MOUSEMOVE: 570 564 /* If we are not in the 'clicked' mode, then nothing to do */ 571 if(!(infoPtr->Flags & FLAG_CLICKED)) 572 return; 565 if (!(infoPtr->Flags & FLAG_CLICKED)) return; 573 566 574 567 /* save the flags to see if any got modified */ … … 601 594 } 602 595 596 //Message handling 597 598 static LRESULT UPDOWN_NCCreate(HWND hwnd,WPARAM wParam,LPARAM lParam) 599 { 600 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 601 602 /* get rid of border, if any */ 603 SetWindowLongA(hwnd,GWL_STYLE,dwStyle & ~WS_BORDER); 604 return TRUE; 605 } 606 607 static LRESULT UPDOWN_Create(HWND hwnd,WPARAM wParam,LPARAM lParam) 608 { 609 UPDOWN_INFO *infoPtr; 610 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 611 612 infoPtr = (UPDOWN_INFO*)COMCTL32_Alloc(sizeof(UPDOWN_INFO)); 613 SetWindowLongA (hwnd, 0, (DWORD)infoPtr); 614 615 /* initialize the info struct */ 616 infoPtr->AccelCount = 0; 617 infoPtr->AccelVect = 0; 618 infoPtr->CurVal = 0; 619 infoPtr->MinVal = 0; 620 infoPtr->MaxVal = 100; /*FIXME*/ 621 infoPtr->Base = 10; /* Default to base 10 */ 622 infoPtr->Buddy = 0; /* No buddy window yet */ 623 infoPtr->Flags = 0; /* And no flags */ 624 625 /* Do we pick the buddy win ourselves? */ 626 if (dwStyle & UDS_AUTOBUDDY) UPDOWN_SetBuddyHandle(hwnd,GetWindow(hwnd,GW_HWNDPREV)); 627 628 // TRACE(updown, "UpDown Ctrl creation, hwnd=%04x\n", hwnd); 629 630 return 0; 631 } 632 633 static LRESULT UPDOWN_Destroy(HWND hwnd,WPARAM wParam,LPARAM lParam) 634 { 635 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr(hwnd); 636 637 if(infoPtr->AccelVect) COMCTL32_Free(infoPtr->AccelVect); 638 639 COMCTL32_Free (infoPtr); 640 641 // TRACE(updown, "UpDown Ctrl destruction, hwnd=%04x\n", hwnd); 642 643 return 0; 644 } 645 646 static LRESULT UPDOWN_Enable(HWND hwnd,WPARAM wParam,LPARAM lParam) 647 { 648 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 649 650 if (dwStyle & WS_DISABLED) UPDOWN_CancelMode(hwnd); 651 UPDOWN_Paint(hwnd); 652 653 return 0; 654 } 655 656 static LRESULT UPDOWN_Timer(HWND hwnd,WPARAM wParam,LPARAM lParam) 657 { 658 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr(hwnd); 659 int temp; 660 661 /* if initial timer, kill it and start the repeat timer */ 662 if(wParam == TIMERID1) 663 { 664 KillTimer(hwnd, TIMERID1); 665 /* if no accel info given, used default timer */ 666 if(infoPtr->AccelCount==0 || infoPtr->AccelVect==0) 667 { 668 accelIndex = -1; 669 temp = REPEAT_DELAY; 670 } else 671 { 672 accelIndex = 0; /* otherwise, use it */ 673 temp = infoPtr->AccelVect[accelIndex].nSec * 1000 + 1; 674 } 675 SetTimer(hwnd, TIMERID2, temp, 0); 676 } 677 678 /* now, if the mouse is above us, do the thing...*/ 679 if(infoPtr->Flags & FLAG_MOUSEIN) 680 { 681 temp = accelIndex==-1 ? 1 : infoPtr->AccelVect[accelIndex].nInc; 682 UPDOWN_DoAction(hwnd, temp, infoPtr->Flags & FLAG_INCR); 683 684 if(accelIndex!=-1 && accelIndex < infoPtr->AccelCount-1) 685 { 686 KillTimer(hwnd, TIMERID2); 687 accelIndex++; /* move to the next accel info */ 688 temp = infoPtr->AccelVect[accelIndex].nSec * 1000 + 1; 689 /* make sure we have at least 1ms intervals */ 690 SetTimer(hwnd, TIMERID2, temp, 0); 691 } 692 } 693 694 return 0; 695 } 696 697 static LRESULT UPDOWN_LButtonUp(HWND hwnd,WPARAM wParam,LPARAM lParam) 698 { 699 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr(hwnd); 700 701 if (!UPDOWN_CancelMode(hwnd)) return 0; 702 /*If we released the mouse and our buddy is an edit */ 703 /* we must select all text in it. */ 704 if (!lstrcmpA(infoPtr->szBuddyClass,"Edit")) 705 SendMessageA(infoPtr->Buddy,EM_SETSEL,0,MAKELONG(0,-1)); 706 707 return 0; 708 } 709 710 static LRESULT UPDOWN_KeyDown(HWND hwnd,WPARAM wParam,LPARAM lParam) 711 { 712 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 713 714 if((dwStyle & UDS_ARROWKEYS) && UPDOWN_IsEnabled(hwnd)) 715 { 716 switch(wParam) 717 { 718 case VK_UP: 719 case VK_DOWN: 720 UPDOWN_GetBuddyInt (hwnd); 721 UPDOWN_DoAction (hwnd, 1, wParam==VK_UP); 722 break; 723 } 724 } 725 726 return 0; 727 } 728 729 static LRESULT UPDOWN_GetAccel(HWND hwnd,WPARAM wParam,LPARAM lParam) 730 { 731 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr(hwnd); 732 INT temp; 733 734 if (wParam == 0 && lParam == 0) /*if both zero, */ 735 return infoPtr->AccelCount; /*just return the accel count*/ 736 if (wParam || lParam) 737 { 738 UNKNOWN_PARAM(UDM_GETACCEL,wParam,lParam); 739 return 0; 740 } 741 temp = MIN(infoPtr->AccelCount,wParam); 742 memcpy((void *)lParam,infoPtr->AccelVect,temp*sizeof(UDACCEL)); 743 744 return temp; 745 } 746 747 static LRESULT UPDOWN_SetAccel(HWND hwnd,WPARAM wParam,LPARAM lParam) 748 { 749 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr(hwnd); 750 751 // TRACE(updown, "UpDown Ctrl new accel info, hwnd=%04x\n", hwnd); 752 if(infoPtr->AccelVect) 753 { 754 COMCTL32_Free(infoPtr->AccelVect); 755 infoPtr->AccelCount = 0; 756 infoPtr->AccelVect = 0; 757 } 758 if(wParam == 0) return TRUE; 759 infoPtr->AccelVect = COMCTL32_Alloc(wParam*sizeof(UDACCEL)); 760 if(infoPtr->AccelVect == 0) return FALSE; 761 memcpy(infoPtr->AccelVect,(void*)lParam,wParam*sizeof(UDACCEL)); 762 763 return TRUE; 764 } 765 766 static LRESULT UPDOWN_GetBase(HWND hwnd,WPARAM wParam,LPARAM lParam) 767 { 768 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr(hwnd); 769 770 if (wParam || lParam) UNKNOWN_PARAM(UDM_GETBASE,wParam,lParam); 771 772 return infoPtr->Base; 773 } 774 775 static LRESULT UPDOWN_SetBase(HWND hwnd,WPARAM wParam,LPARAM lParam) 776 { 777 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr(hwnd); 778 INT temp; 779 780 // TRACE(updown, "UpDown Ctrl new base(%d), hwnd=%04x\n", 781 // wParam, hwnd); 782 if (!(wParam==10 || wParam==16) || lParam) UNKNOWN_PARAM(UDM_SETBASE,wParam,lParam); 783 if (wParam==10 || wParam==16) 784 { 785 temp = infoPtr->Base; 786 infoPtr->Base = wParam; 787 return temp; /* return the prev base */ 788 } 789 790 return 0; 791 } 792 793 static LRESULT UPDOWN_GetBuddy(HWND hwnd,WPARAM wParam,LPARAM lParam) 794 { 795 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr(hwnd); 796 797 if (wParam || lParam) UNKNOWN_PARAM(UDM_GETBUDDY,wParam,lParam); 798 799 return infoPtr->Buddy; 800 } 801 802 803 static LRESULT UPDOWN_SetBuddy(HWND hwnd,WPARAM wParam,LPARAM lParam) 804 { 805 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr(hwnd); 806 INT temp; 807 808 if (lParam) UNKNOWN_PARAM(UDM_SETBUDDY,wParam,lParam); 809 temp = infoPtr->Buddy; 810 infoPtr->Buddy = wParam; 811 UPDOWN_SetBuddyHandle(hwnd,wParam); 812 // TRACE(updown, "UpDown Ctrl new buddy(%04x), hwnd=%04x\n", 813 // infoPtr->Buddy, hwnd); 814 815 return temp; 816 } 817 818 static LRESULT UPDOWN_GetPos(HWND hwnd,WPARAM wParam,LPARAM lParam) 819 { 820 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr(hwnd); 821 INT temp; 822 823 if (wParam || lParam) UNKNOWN_PARAM(UDM_GETPOS, wParam, lParam); 824 temp = UPDOWN_GetBuddyInt(hwnd); 825 826 return MAKELONG(infoPtr->CurVal,temp ? 0:1); 827 } 828 829 static LRESULT UPDOWN_SetPos(HWND hwnd,WPARAM wParam,LPARAM lParam) 830 { 831 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr(hwnd); 832 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 833 INT temp; 834 835 if (wParam || HIWORD(lParam)) UNKNOWN_PARAM(UDM_GETPOS,wParam,lParam); 836 temp = SLOWORD(lParam); 837 // TRACE(updown, "UpDown Ctrl new value(%d), hwnd=%04x\n", 838 // temp, hwnd); 839 if (!UPDOWN_InBounds(hwnd, temp)) 840 { 841 if (temp < infoPtr->MinVal) temp = infoPtr->MinVal; 842 if (temp > infoPtr->MaxVal) temp = infoPtr->MaxVal; 843 } 844 wParam = infoPtr->CurVal; /* save prev value */ 845 infoPtr->CurVal = temp; /* set the new value */ 846 if (dwStyle & UDS_SETBUDDYINT) UPDOWN_SetBuddyInt (hwnd); 847 848 return wParam; /* return prev value */ 849 } 850 851 static LRESULT UPDOWN_GetRange(HWND hwnd,WPARAM wParam,LPARAM lParam) 852 { 853 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr(hwnd); 854 855 if (wParam || lParam) UNKNOWN_PARAM(UDM_GETRANGE, wParam, lParam); 856 857 return MAKELONG(infoPtr->MaxVal,infoPtr->MinVal); 858 } 859 860 static LRESULT UPDOWN_SetRange(HWND hwnd,WPARAM wParam,LPARAM lParam) 861 { 862 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr(hwnd); 863 864 if (wParam) UNKNOWN_PARAM(UDM_SETRANGE,wParam,lParam); /* we must have: */ 865 infoPtr->MaxVal = SLOWORD(lParam); /* UD_MINVAL <= Max <= UD_MAXVAL */ 866 infoPtr->MinVal = SHIWORD(lParam); /* UD_MINVAL <= Min <= UD_MAXVAL */ 867 /* |Max-Min| <= UD_MAXVAL */ 868 // TRACE(updown, "UpDown Ctrl new range(%d to %d), hwnd=%04x\n", 869 // infoPtr->MinVal, infoPtr->MaxVal, hwnd); 870 871 return 0; 872 } 873 874 static LRESULT UPDOWN_GetRange32(HWND hwnd,WPARAM wParam,LPARAM lParam) 875 { 876 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr(hwnd); 877 878 if (wParam) *(LPINT)wParam = infoPtr->MinVal; 879 if (lParam) *(LPINT)lParam = infoPtr->MaxVal; 880 881 return 0; 882 } 883 884 static LRESULT UPDOWN_SetRange32(HWND hwnd,WPARAM wParam,LPARAM lParam) 885 { 886 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr(hwnd); 887 888 infoPtr->MinVal = (INT)wParam; 889 infoPtr->MaxVal = (INT)lParam; 890 if (infoPtr->MaxVal <= infoPtr->MinVal) infoPtr->MaxVal = infoPtr->MinVal+1; 891 // TRACE(updown, "UpDown Ctrl new range(%d to %d), hwnd=%04x\n", 892 // infoPtr->MinVal, infoPtr->MaxVal, hwnd); 893 894 return 0; 895 } 896 603 897 /*********************************************************************** 604 898 * UpDownWndProc … … 607 901 LPARAM lParam) 608 902 { 609 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr (hwnd);610 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);611 int temp;612 613 903 switch(message) 614 904 { 615 905 case WM_NCCREATE: 616 /* get rid of border, if any */ 617 SetWindowLongA (hwnd, GWL_STYLE, dwStyle & ~WS_BORDER); 618 return TRUE; 906 return UPDOWN_NCCreate(hwnd,wParam,lParam); 619 907 620 908 case WM_CREATE: 621 infoPtr = (UPDOWN_INFO*)COMCTL32_Alloc (sizeof(UPDOWN_INFO)); 622 SetWindowLongA (hwnd, 0, (DWORD)infoPtr); 623 624 /* initialize the info struct */ 625 infoPtr->AccelCount=0; infoPtr->AccelVect=0; 626 infoPtr->CurVal=0; infoPtr->MinVal=0; infoPtr->MaxVal=100; /*FIXME*/ 627 infoPtr->Base = 10; /* Default to base 10 */ 628 infoPtr->Buddy = 0; /* No buddy window yet */ 629 infoPtr->Flags = 0; /* And no flags */ 630 631 /* Do we pick the buddy win ourselves? */ 632 if (dwStyle & UDS_AUTOBUDDY) 633 UPDOWN_SetBuddy (hwnd, GetWindow (hwnd, GW_HWNDPREV)); 634 635 // TRACE(updown, "UpDown Ctrl creation, hwnd=%04x\n", hwnd); 909 return UPDOWN_Create(hwnd,wParam,lParam); 910 911 case WM_DESTROY: 912 return UPDOWN_Destroy(hwnd,wParam,lParam); 913 914 case WM_ENABLE: 915 return UPDOWN_Enable(hwnd,wParam,lParam); 916 917 case WM_TIMER: 918 return UPDOWN_Timer(hwnd,wParam,lParam); 919 920 case WM_CANCELMODE: 921 UPDOWN_CancelMode(hwnd); 636 922 break; 637 923 638 case WM_DESTROY: 639 if(infoPtr->AccelVect) 640 COMCTL32_Free (infoPtr->AccelVect); 641 642 COMCTL32_Free (infoPtr); 643 644 // TRACE(updown, "UpDown Ctrl destruction, hwnd=%04x\n", hwnd); 645 break; 646 647 case WM_ENABLE: 648 if (dwStyle & WS_DISABLED) 649 UPDOWN_CancelMode (hwnd); 650 UPDOWN_Paint (hwnd); 651 break; 652 653 case WM_TIMER: 654 /* if initial timer, kill it and start the repeat timer */ 655 if(wParam == TIMERID1){ 656 KillTimer(hwnd, TIMERID1); 657 /* if no accel info given, used default timer */ 658 if(infoPtr->AccelCount==0 || infoPtr->AccelVect==0){ 659 accelIndex = -1; 660 temp = REPEAT_DELAY; 661 } 662 else{ 663 accelIndex = 0; /* otherwise, use it */ 664 temp = infoPtr->AccelVect[accelIndex].nSec * 1000 + 1; 665 } 666 SetTimer(hwnd, TIMERID2, temp, 0); 667 } 668 669 /* now, if the mouse is above us, do the thing...*/ 670 if(infoPtr->Flags & FLAG_MOUSEIN){ 671 temp = accelIndex==-1 ? 1 : infoPtr->AccelVect[accelIndex].nInc; 672 UPDOWN_DoAction(hwnd, temp, infoPtr->Flags & FLAG_INCR); 673 674 if(accelIndex!=-1 && accelIndex < infoPtr->AccelCount-1){ 675 KillTimer(hwnd, TIMERID2); 676 accelIndex++; /* move to the next accel info */ 677 temp = infoPtr->AccelVect[accelIndex].nSec * 1000 + 1; 678 /* make sure we have at least 1ms intervals */ 679 SetTimer(hwnd, TIMERID2, temp, 0); 680 } 924 case WM_LBUTTONUP: 925 return UPDOWN_LButtonUp(hwnd,wParam,lParam); 926 927 case WM_LBUTTONDOWN: 928 case WM_MOUSEMOVE: 929 if(UPDOWN_IsEnabled(hwnd)) 930 { 931 POINT pt; 932 CONV_POINT16TO32((POINT16 *)&lParam,&pt); 933 UPDOWN_HandleMouseEvent(hwnd,message,pt); 681 934 } 682 935 break; 683 936 684 case WM_CANCELMODE: 685 UPDOWN_CancelMode (hwnd); 937 case WM_KEYDOWN: 938 return UPDOWN_KeyDown(hwnd,wParam,lParam); 939 940 case WM_PAINT: 941 UPDOWN_Paint(hwnd); 686 942 break; 687 943 688 case WM_LBUTTONUP:689 if(!UPDOWN_CancelMode(hwnd))690 break;691 /*If we released the mouse and our buddy is an edit */692 /* we must select all text in it. */693 if (!lstrcmpA (infoPtr->szBuddyClass, "Edit"))694 SendMessageA(infoPtr->Buddy, EM_SETSEL, 0, MAKELONG(0, -1));695 break;696 697 case WM_LBUTTONDOWN:698 case WM_MOUSEMOVE:699 if(UPDOWN_IsEnabled(hwnd)){700 POINT pt;701 CONV_POINT16TO32( (POINT16 *)&lParam, &pt );702 UPDOWN_HandleMouseEvent (hwnd, message, pt );703 }704 break;705 706 case WM_KEYDOWN:707 if((dwStyle & UDS_ARROWKEYS) && UPDOWN_IsEnabled(hwnd)){708 switch(wParam){709 case VK_UP:710 case VK_DOWN:711 UPDOWN_GetBuddyInt (hwnd);712 UPDOWN_DoAction (hwnd, 1, wParam==VK_UP);713 break;714 }715 }716 break;717 718 case WM_PAINT:719 UPDOWN_Paint (hwnd);720 break;721 722 944 case UDM_GETACCEL: 723 if (wParam==0 && lParam==0) /*if both zero, */ 724 return infoPtr->AccelCount; /*just return the accel count*/ 725 if (wParam || lParam){ 726 UNKNOWN_PARAM(UDM_GETACCEL, wParam, lParam); 727 return 0; 728 } 729 temp = MIN(infoPtr->AccelCount, wParam); 730 memcpy((void *)lParam, infoPtr->AccelVect, temp*sizeof(UDACCEL)); 731 return temp; 945 return UPDOWN_GetAccel(hwnd,wParam,lParam); 732 946 733 947 case UDM_SETACCEL: 734 // TRACE(updown, "UpDown Ctrl new accel info, hwnd=%04x\n", hwnd); 735 if(infoPtr->AccelVect){ 736 COMCTL32_Free (infoPtr->AccelVect); 737 infoPtr->AccelCount = 0; 738 infoPtr->AccelVect = 0; 739 } 740 if(wParam==0) 741 return TRUE; 742 infoPtr->AccelVect = COMCTL32_Alloc (wParam*sizeof(UDACCEL)); 743 if(infoPtr->AccelVect==0) 744 return FALSE; 745 memcpy(infoPtr->AccelVect, (void*)lParam, wParam*sizeof(UDACCEL)); 746 return TRUE; 948 return UPDOWN_SetAccel(hwnd,wParam,lParam); 747 949 748 950 case UDM_GETBASE: 749 if (wParam || lParam) 750 UNKNOWN_PARAM(UDM_GETBASE, wParam, lParam); 751 return infoPtr->Base; 951 return UPDOWN_GetBase(hwnd,wParam,lParam); 752 952 753 953 case UDM_SETBASE: 754 // TRACE(updown, "UpDown Ctrl new base(%d), hwnd=%04x\n", 755 // wParam, hwnd); 756 if ( !(wParam==10 || wParam==16) || lParam) 757 UNKNOWN_PARAM(UDM_SETBASE, wParam, lParam); 758 if (wParam==10 || wParam==16){ 759 temp = infoPtr->Base; 760 infoPtr->Base = wParam; 761 return temp; /* return the prev base */ 762 } 763 break; 954 return UPDOWN_SetBase(hwnd,wParam,lParam); 764 955 765 956 case UDM_GETBUDDY: 766 if (wParam || lParam) 767 UNKNOWN_PARAM(UDM_GETBUDDY, wParam, lParam); 768 return infoPtr->Buddy; 957 return UPDOWN_GetBuddy(hwnd,wParam,lParam); 769 958 770 959 case UDM_SETBUDDY: 771 if (lParam) 772 UNKNOWN_PARAM(UDM_SETBUDDY, wParam, lParam); 773 temp = infoPtr->Buddy; 774 infoPtr->Buddy = wParam; 775 UPDOWN_SetBuddy (hwnd, wParam); 776 // TRACE(updown, "UpDown Ctrl new buddy(%04x), hwnd=%04x\n", 777 // infoPtr->Buddy, hwnd); 778 return temp; 960 return UPDOWN_SetBuddy(hwnd,wParam,lParam); 779 961 780 962 case UDM_GETPOS: 781 if (wParam || lParam) 782 UNKNOWN_PARAM(UDM_GETPOS, wParam, lParam); 783 temp = UPDOWN_GetBuddyInt (hwnd); 784 return MAKELONG(infoPtr->CurVal, temp ? 0 : 1); 963 return UPDOWN_GetPos(hwnd,wParam,lParam); 785 964 786 965 case UDM_SETPOS: 787 if (wParam || HIWORD(lParam)) 788 UNKNOWN_PARAM(UDM_GETPOS, wParam, lParam); 789 temp = SLOWORD(lParam); 790 // TRACE(updown, "UpDown Ctrl new value(%d), hwnd=%04x\n", 791 // temp, hwnd); 792 if(!UPDOWN_InBounds(hwnd, temp)){ 793 if(temp < infoPtr->MinVal) 794 temp = infoPtr->MinVal; 795 if(temp > infoPtr->MaxVal) 796 temp = infoPtr->MaxVal; 797 } 798 wParam = infoPtr->CurVal; /* save prev value */ 799 infoPtr->CurVal = temp; /* set the new value */ 800 if(dwStyle & UDS_SETBUDDYINT) 801 UPDOWN_SetBuddyInt (hwnd); 802 return wParam; /* return prev value */ 966 return UPDOWN_SetPos(hwnd,wParam,lParam); 803 967 804 968 case UDM_GETRANGE: 805 if (wParam || lParam) 806 UNKNOWN_PARAM(UDM_GETRANGE, wParam, lParam); 807 return MAKELONG(infoPtr->MaxVal, infoPtr->MinVal); 969 return UPDOWN_GetRange(hwnd,wParam,lParam); 808 970 809 971 case UDM_SETRANGE: 810 if (wParam) 811 UNKNOWN_PARAM(UDM_SETRANGE, wParam, lParam); /* we must have: */ 812 infoPtr->MaxVal = SLOWORD(lParam); /* UD_MINVAL <= Max <= UD_MAXVAL */ 813 infoPtr->MinVal = SHIWORD(lParam); /* UD_MINVAL <= Min <= UD_MAXVAL */ 814 /* |Max-Min| <= UD_MAXVAL */ 815 // TRACE(updown, "UpDown Ctrl new range(%d to %d), hwnd=%04x\n", 816 // infoPtr->MinVal, infoPtr->MaxVal, hwnd); 817 break; 972 return UPDOWN_SetRange(hwnd,wParam,lParam); 818 973 819 974 case UDM_GETRANGE32: 820 if (wParam) 821 *(LPINT)wParam = infoPtr->MinVal; 822 if (lParam) 823 *(LPINT)lParam = infoPtr->MaxVal; 824 break; 975 return UPDOWN_GetRange32(hwnd,wParam,lParam); 825 976 826 977 case UDM_SETRANGE32: 827 infoPtr->MinVal = (INT)wParam; 828 infoPtr->MaxVal = (INT)lParam; 829 if (infoPtr->MaxVal <= infoPtr->MinVal) 830 infoPtr->MaxVal = infoPtr->MinVal + 1; 831 // TRACE(updown, "UpDown Ctrl new range(%d to %d), hwnd=%04x\n", 832 // infoPtr->MinVal, infoPtr->MaxVal, hwnd); 833 break; 978 return UPDOWN_SetRange32(hwnd,wParam,lParam); 834 979 835 980 default: … … 837 982 // ERR (updown, "unknown msg %04x wp=%04x lp=%08lx\n", 838 983 // message, wParam, lParam); 839 return DefWindowProcA (hwnd, message, wParam,lParam);984 return DefWindowProcA(hwnd,message,wParam,lParam); 840 985 } 841 986
Note:
See TracChangeset
for help on using the changeset viewer.