Changeset 180 for trunk/src


Ignore:
Timestamp:
Jun 24, 1999, 6:37:46 PM (26 years ago)
Author:
cbratschi
Message:

Several COMCTL32 changes

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 achimha Exp $ */
     1/* $Id: propsheet.c,v 1.4 1999-06-24 16:37:44 cbratschi Exp $ */
    22/*
    33 * Property Sheets
     
    66 * Copyright 1999 Thuy Nguyen
    77 * Copyright 1999 Achim Hasenmueller
     8 * Copyright 1999 Christoph Bratschi
    89 *
    910 * TODO:
     
    251252      p += lstrlenW( (LPCWSTR)p ) + 1;
    252253      break;
    253   } 
     254  }
    254255
    255256  /* class */
     
    286287  HRSRC hRes;
    287288
    288   if(!(hRes = FindResourceA(COMCTL32_hModule,
     289  if (!(hRes = FindResourceA(COMCTL32_hModule,
    289290                            MAKEINTRESOURCEA(IDD_PROPSHEET),
    290291                            RT_DIALOGA)))
    291292    return FALSE;
    292293
    293   if(!(template = (LPVOID)LoadResource(COMCTL32_hModule, hRes)))
     294  if (!(template = (LPVOID)LoadResource(COMCTL32_hModule, hRes)))
    294295    return FALSE;
    295296
     
    315316/******************************************************************************
    316317 *            PROPSHEET_IsTooSmall
    317  * 
     318 *
    318319 * Verify that the resource property sheet is big enough.
    319320 */
     
    437438  /*
    438439   * Get the size of the property sheet.
    439    */ 
     440   */
    440441  GetClientRect(hwndParent, &rcSheet);
    441442
    442   /* 
     443  /*
    443444   * All buttons will be at this y coordinate.
    444445   */
     
    476477    else
    477478      x = rcSheet.right - (padding.x + buttonWidth);
    478  
     479
    479480    SetWindowPos(hwndButton, 0, x, y, 0, 0,
    480481                 SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
     
    493494  {
    494495    x = rcSheet.right - (padding.x + buttonWidth);
    495  
     496
    496497    SetWindowPos(hwndButton, 0, x, y, 0, 0,
    497498                 SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
     
    613614
    614615  hwndPage = CreateDialogIndirectParamA(ppshpage->hInstance,
    615                                         pTemplate,
    616                                         hwndParent,
    617                                         ppshpage->pfnDlgProc,
    618                                         (LPARAM)ppshpage);
     616                                        pTemplate,
     617                                        hwndParent,
     618                                        ppshpage->pfnDlgProc,
     619                                        (LPARAM)ppshpage);
    619620
    620621  ppInfo[index].hwndPage = hwndPage;
     
    841842    default:
    842843//      FIXME(propsheet, "Invalid button index %d\n", buttonID);
    843         break;
     844        break;
    844845  }
    845846}
     
    10831084  psInfo->proppage = COMCTL32_Alloc(sizeof(PropPageInfo) * psInfo->nPages);
    10841085
    1085   if (index > 0) 
     1086  if (index > 0)
    10861087    memcpy(&psInfo->proppage[0], &oldPages[0], index * sizeof(PropPageInfo));
    10871088
     
    12331234      }
    12341235
    1235       ppshpage = PROPSHEET_GetPSPPage(psInfo, psInfo->active_page);     
     1236      ppshpage = PROPSHEET_GetPSPPage(psInfo, psInfo->active_page);
    12361237      PROPSHEET_CreatePage(hwnd, psInfo->active_page, psInfo, ppshpage, TRUE);
    12371238      SendMessageA(hwndTabCtrl, TCM_SETCURSEL, psInfo->active_page, 0);
     
    13921393    case PSM_REBOOTSYSTEM:
    13931394    {
    1394       PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwnd, 
     1395      PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwnd,
    13951396                                                        PropSheetInfoStr);
    13961397
  • trunk/src/comctl32/toolbar.c

    r110 r180  
    1 /* $Id: toolbar.c,v 1.5 1999-06-16 20:25:43 cbratschi Exp $ */
     1/* $Id: toolbar.c,v 1.6 1999-06-24 16:37:45 cbratschi Exp $ */
    22/*
    33 * Toolbar control
     
    175175    RECT rc;
    176176
    177     if (btnPtr->fsState & TBSTATE_HIDDEN)
    178         return;
     177    if (btnPtr->fsState & TBSTATE_HIDDEN) return;
    179178
    180179    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;
    185185    }
    186186
    187187    /* 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;
    204205    }
    205206
    206207    /* 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;
    213215    }
    214216
     
    229231            ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
    230232                            rc.left+2, rc.top+2, ILD_NORMAL);
    231         else
     233            else
    232234            ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
    233235                            rc.left+2, rc.top+2, ILD_NORMAL);
    234         }
    235         else
     236        } else
    236237            ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
    237238                            rc.left+2, rc.top+2, ILD_NORMAL);
     
    241242
    242243    /* 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;
    251253    }
    252254
    253255    if (dwStyle & TBSTYLE_FLAT)
    254256    {
    255         if(btnPtr->bHot)
    256             DrawEdge (hdc, &rc, BDR_RAISEDINNER,
    257                        BF_RECT | BF_MIDDLE | BF_SOFT);
    258 
    259         if(infoPtr->himlDef != NULL)
    260             ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
    261                             rc.left +2, rc.top +2, ILD_NORMAL);
    262         else
    263             ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
    264                             rc.left +2, rc.top +2, ILD_NORMAL);
    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,
    269271                BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
    270272
    271         ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
    272                         rc.left+1, rc.top+1, ILD_NORMAL);
     273      ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
     274                      rc.left+1, rc.top+1, ILD_NORMAL);
    273275    }
    274276
     
    555557
    556558        /* 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))
    558560        {
    559561            TTTOOLINFOA ti;
    560562
    561             ZeroMemory (&ti, sizeof(TTTOOLINFOA));
     563            ZeroMemory (&ti,sizeof(TTTOOLINFOA));
    562564            ti.cbSize = sizeof(TTTOOLINFOA);
    563565            ti.hwnd = hwnd;
    564566            ti.uId = btnPtr->idCommand;
    565567            ti.rect = btnPtr->rect;
    566             SendMessageA (infoPtr->hwndToolTip, TTM_NEWTOOLRECTA,
    567                             0, (LPARAM)&ti);
     568            SendMessageA(infoPtr->hwndToolTip,TTM_NEWTOOLRECTA,0,(LPARAM)&ti);
    568569        }
    569570
     
    712713    msg.wParam = wParam;
    713714    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);
    719720}
    720721
     
    976977
    977978    /* insert new button data */
    978     for (nCount = 0; nCount < nAddButtons; nCount++) {
     979    for (nCount = 0; nCount < nAddButtons; nCount++)
     980    {
    979981        TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
    980982        btnPtr->iBitmap   = lpTbb[nCount].iBitmap;
     
    986988        btnPtr->bHot      = FALSE;
    987989
    988         if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
     990        if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP))
     991        {
    989992            TTTOOLINFOA ti;
    990993
     
    996999            ti.lpszText = LPSTR_TEXTCALLBACKA;
    9971000
    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);
    10061008
    10071009    return TRUE;
     
    17521754    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    17531755
    1754     if (infoPtr == NULL)
    1755         return 0;
     1756    if (infoPtr == NULL) return 0;
    17561757    return infoPtr->hwndToolTip;
    17571758}
     
    20562057    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    20572058
    2058     if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
    2059         return FALSE;
     2059    if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0)) return FALSE;
    20602060
    20612061    infoPtr->nBitmapWidth = (INT)LOWORD(lParam);
     
    21232123    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    21242124
    2125     if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
    2126         return FALSE;
     2125    if ((LOWORD(lParam) <= 0) || (HIWORD(lParam) <= 0)) return FALSE;
    21272126
    21282127    infoPtr->nButtonWidth = (INT)LOWORD(lParam);
     
    24492448
    24502449    infoPtr->bCaptured = FALSE;
    2451     infoPtr->bUnicode = IsWindowUnicode (hwnd);
     2450    infoPtr->bUnicode = IsWindowUnicode(hwnd);
    24522451    infoPtr->nButtonDown = -1;
    24532452    infoPtr->nOldHit = -1;
     
    24602459    infoPtr->hFont = CreateFontIndirectA (&logFont);
    24612460
    2462     if (dwStyle & TBSTYLE_TOOLTIPS) {
     2461    if (dwStyle & TBSTYLE_TOOLTIPS)
     2462    {
    24632463        /* Create tooltip control */
    24642464        infoPtr->hwndToolTip =
    2465             CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
    2466                                CW_USEDEFAULT, CW_USEDEFAULT,
    2467                                CW_USEDEFAULT, 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);
    24692469
    24702470        /* Send NM_TOOLTIPSCREATED notification */
    2471         if (infoPtr->hwndToolTip) {
     2471        if (infoPtr->hwndToolTip)
     2472        {
    24722473            NMTOOLTIPSCREATED nmttc;
    24732474
     
    26922693
    26932694    if (infoPtr->hwndToolTip)
    2694         TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
    2695                             WM_MOUSEMOVE, wParam, lParam);
     2695        TOOLBAR_RelayEvent (infoPtr->hwndToolTip,hwnd,
     2696                            WM_MOUSEMOVE,wParam,lParam);
    26962697
    26972698    pt.x = (INT)LOWORD(lParam);
    26982699    pt.y = (INT)HIWORD(lParam);
    26992700
    2700     nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
     2701    nHit = TOOLBAR_InternalHitTest(hwnd,&pt);
    27012702
    27022703    if (infoPtr->nOldHit != nHit)
    27032704    {
    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)
    27062710        {
    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)
    27152722        {
    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;
    27422753    }
    27432754    return 0;
     
    28522863    PAINTSTRUCT ps;
    28532864
    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);
    28592869    return 0;
    28602870}
  • trunk/src/comctl32/tooltips.c

    r110 r180  
    1 /* $Id: tooltips.c,v 1.5 1999-06-16 20:25:44 cbratschi Exp $ */
     1/* $Id: tooltips.c,v 1.6 1999-06-24 16:37:45 cbratschi Exp $ */
    22/*
    33 * Tool tip control
     
    1818 */
    1919
     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
    2025#include <string.h>
    2126
     
    5358    UINT uFlags = DT_EXTERNALLEADING;
    5459
    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);
    6063
    6164    /* fill the background */
    62     hBrush = CreateSolidBrush (infoPtr->clrBk);
    63     FillRect (hdc, &rc, hBrush);
    64     DeleteObject (hBrush);
     65    hBrush = CreateSolidBrush(infoPtr->clrBk);
     66    FillRect(hdc,&rc,hBrush);
     67    DeleteObject(hBrush);
    6568
    6669    /* 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);
    7174
    7275    /* 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);
    8082}
    8183
    8284
    8385static VOID
    84 TOOLTIPS_GetTipText (HWND hwnd, TOOLTIPS_INFO *infoPtr, INT nTool)
     86TOOLTIPS_GetTipText(HWND hwnd,TOOLTIPS_INFO *infoPtr,INT nTool)
    8587{
    8688    TTTOOL_INFO *toolPtr = &infoPtr->tools[nTool];
    8789
    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             NMTTDISPINFOA ttnmdi;
    98 
    99             /* fill NMHDR struct */
    100             ZeroMemory (&ttnmdi, sizeof(NMTTDISPINFOA));
    101             ttnmdi.hdr.hwndFrom = hwnd;
    102             ttnmdi.hdr.idFrom = toolPtr->uId;
    103             ttnmdi.hdr.code = TTN_GETDISPINFOA;
    104             ttnmdi.lpszText = (LPSTR)&ttnmdi.szText;
    105             ttnmdi.uFlags = toolPtr->uFlags;
    106             ttnmdi.lParam = toolPtr->lParam;
    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                     toolPtr->hinst = 0;
    125                     toolPtr->lpszText = COMCTL32_Alloc ((len+1)* sizeof(WCHAR));
    126                     lstrcpyAtoW (toolPtr->lpszText, ttnmdi.szText);
    127                 }
    128             }
    129             else if (ttnmdi.lpszText == 0) {
    130                 /* no text available */
    131                 infoPtr->szTipText[0] = L'\0';
    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';
    146148        }
    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';
    156159    }
    157160
     
    159162}
    160163
    161 
    162164static VOID
    163 TOOLTIPS_CalcTipSize (HWND hwnd, TOOLTIPS_INFO *infoPtr, LPSIZE lpSize)
     165TOOLTIPS_CalcTipSize (HWND hwnd,TOOLTIPS_INFO *infoPtr,LPSIZE lpSize)
    164166{
    165167    HDC hdc;
    166168    HFONT hOldFont;
    167169    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         uFlags |= DT_NOPREFIX;
     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;
    176178//    TRACE (tooltips, "\"%s\"\n", debugstr_w(infoPtr->szTipText));
    177179
    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;
    188188}
    189189
     
    198198    NMHDR  hdr;
    199199
    200     if (infoPtr->nTool == -1) {
     200    if (infoPtr->nTool == -1)
     201    {
    201202//      TRACE (tooltips, "invalid tool (-1)!\n");
    202203        return;
     
    207208//    TRACE (tooltips, "Show tooltip pre %d!\n", infoPtr->nTool);
    208209
    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    {
    212214        infoPtr->nCurrentTool = -1;
    213215        return;
     
    220222    hdr.idFrom = toolPtr->uId;
    221223    hdr.code = TTN_SHOW;
    222     SendMessageA (toolPtr->hwnd, WM_NOTIFY,
    223                     (WPARAM)toolPtr->uId, (LPARAM)&hdr);
     224    SendMessageA(toolPtr->hwnd,WM_NOTIFY,
     225                    (WPARAM)toolPtr->uId,(LPARAM)&hdr);
    224226
    225227//    TRACE (tooltips, "\"%s\"\n", debugstr_w(infoPtr->szTipText));
     
    228230//    TRACE (tooltips, "size %d - %d\n", size.cx, size.cy);
    229231
    230     if (toolPtr->uFlags & TTF_CENTERTIP) {
     232    if (toolPtr->uFlags & TTF_CENTERTIP)
     233    {
    231234        RECT rc;
    232235
    233236        if (toolPtr->uFlags & TTF_IDISHWND)
    234237            GetWindowRect ((HWND)toolPtr->uId, &rc);
    235         else {
     238        else
     239        {
    236240            rc = toolPtr->rect;
    237241            MapWindowPoints (toolPtr->hwnd, (HWND)0, (LPPOINT)&rc, 2);
     
    239243        rect.left = (rc.left + rc.right - size.cx) / 2;
    240244        rect.top  = rc.bottom + 2;
    241     }
    242     else {
    243         GetCursorPos ((LPPOINT)&rect);
     245    } else
     246    {
     247        GetCursorPos((LPPOINT)&rect);
    244248        rect.top += 20;
    245249    }
     
    252256    rect.bottom = rect.top + size.cy;
    253257
    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,
    259263                    SWP_SHOWWINDOW | SWP_NOACTIVATE);
    260264
    261265    /* repaint the tooltip */
    262     hdc = GetDC (hwnd);
    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);
    267271}
    268272
     
    303307    NMHDR hdr;
    304308
    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;
    308313    }
    309314
    310315//    TRACE (tooltips, "show tracking tooltip pre %d!\n", infoPtr->nTrackTool);
    311316
    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;
    317323    }
    318324
     
    323329    hdr.idFrom = toolPtr->uId;
    324330    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);
    327332
    328333//    TRACE (tooltips, "\"%s\"\n", debugstr_w(infoPtr->szTipText));
    329334
    330     TOOLTIPS_CalcTipSize (hwnd, infoPtr, &size);
     335    TOOLTIPS_CalcTipSize(hwnd,infoPtr,&size);
    331336//    TRACE (tooltips, "size %d - %d\n", size.cx, size.cy);
    332337
    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;
    364374    }
    365375
    366376//    TRACE (tooltips, "pos %d - %d\n", rect.left, rect.top);
    367377
    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,
    376386                    SWP_SHOWWINDOW | SWP_NOACTIVATE );
    377387
     
    564574
    565575static LRESULT
    566 TOOLTIPS_AddToolA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    567 {
    568     TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
     576TOOLTIPS_AddToolA(HWND hwnd,WPARAM wParam,LPARAM lParam)
     577{
     578    TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(hwnd);
    569579    LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
    570580    TTTOOL_INFO *toolPtr;
    571581
     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
     677static LRESULT
     678TOOLTIPS_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
    572684    if (lpToolInfo == NULL)
    573685        return FALSE;
    574     if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
     686    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
    575687        return FALSE;
    576688
     
    607719    }
    608720    else if (lpToolInfo->lpszText) {
    609         if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA) {
     721        if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKW) {
    610722//          TRACE (tooltips, "add CALLBACK!\n");
    611723            toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
    612724        }
    613725        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));
    616729            toolPtr->lpszText = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
    617             lstrcpyAtoW (toolPtr->lpszText, lpToolInfo->lpszText);
     730            lstrcpyW (toolPtr->lpszText, lpToolInfo->lpszText);
    618731        }
    619732    }
    620733
    621     if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA))
     734    if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW))
    622735        toolPtr->lParam = lpToolInfo->lParam;
    623736
     
    665778
    666779static 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 //          else
    743 //              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             else
    759                 lpttsi->uRefCount++;
    760         }
    761 //      TRACE (tooltips, "subclassing installed!\n");
    762     }
    763 
    764     return TRUE;
    765 }
    766 
    767 
    768 static LRESULT
    769780TOOLTIPS_DelToolA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    770781{
     
    14011412    POINT pt;
    14021413
    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    {
    14091422        case WM_LBUTTONDOWN:
    14101423        case WM_LBUTTONUP:
     
    14141427        case WM_RBUTTONUP:
    14151428            pt = lpMsg->pt;
    1416             ScreenToClient (lpMsg->hwnd, &pt);
     1429            ScreenToClient(lpMsg->hwnd,&pt);
    14171430            infoPtr->nOldTool = infoPtr->nTool;
    1418             infoPtr->nTool = TOOLTIPS_GetToolFromPoint (infoPtr, lpMsg->hwnd, &pt);
     1431            infoPtr->nTool = TOOLTIPS_GetToolFromPoint(infoPtr,lpMsg->hwnd,&pt);
    14191432//          TRACE (tooltips, "tool (%x) %d %d\n",
    14201433//                 hwnd, infoPtr->nOldTool, infoPtr->nTool);
     
    14241437        case WM_MOUSEMOVE:
    14251438            pt = lpMsg->pt;
    1426             ScreenToClient (lpMsg->hwnd, &pt);
     1439            ScreenToClient(lpMsg->hwnd,&pt);
    14271440            infoPtr->nOldTool = infoPtr->nTool;
    1428             infoPtr->nTool = TOOLTIPS_GetToolFromPoint (infoPtr, lpMsg->hwnd, &pt);
     1441            infoPtr->nTool = TOOLTIPS_GetToolFromPoint(infoPtr,lpMsg->hwnd,&pt);
    14291442//          TRACE (tooltips, "tool (%x) %d %d\n",
    14301443//                 hwnd, infoPtr->nOldTool, infoPtr->nTool);
    14311444//          TRACE (tooltips, "WM_MOUSEMOVE (%04x %ld %ld)\n",
    14321445//                 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                 }
     1446infoPtr->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              }
    14431459            }
    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");
    14471464            }
    14481465            break;
     
    16551672    LPTTTOOLINFOA lpToolInfo = (LPTTTOOLINFOA)lParam;
    16561673
    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 //          TRACE (tooltips, "activated!\n");
    1667             infoPtr->bTrackActive = TRUE;
    1668             TOOLTIPS_TrackShow (hwnd, infoPtr);
    1669         }
    1670     }
    1671     else {
    1672         /* deactivate */
    1673         TOOLTIPS_TrackHide (hwnd, infoPtr);
    1674 
    1675         infoPtr->bTrackActive = FALSE;
    1676         infoPtr->nTrackTool = -1;
     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;
    16771694
    16781695//      TRACE (tooltips, "deactivated!\n");
     
    16911708    infoPtr->yTrackPos = (INT)HIWORD(lParam);
    16921709
    1693     if (infoPtr->bTrackActive) {
     1710    if (infoPtr->bTrackActive)
     1711    {
    16941712//      TRACE (tooltips, "[%d %d]\n",
    16951713//             infoPtr->xTrackPos, infoPtr->yTrackPos);
    16961714
    1697         TOOLTIPS_TrackShow (hwnd, infoPtr);
     1715      TOOLTIPS_TrackShow(hwnd,infoPtr);
    16981716    }
    16991717
     
    17221740    INT nTool;
    17231741
    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);
    17301746    if (nTool == -1) return 0;
    17311747
     
    17371753    toolPtr->hinst  = lpToolInfo->hinst;
    17381754
    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;
    17551767        }
     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      }
    17561775    }
    17571776
    17581777    /* 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);
    17631780
    17641781    return 0;
     
    18351852
    18361853    /* allocate memory for info structure */
    1837     infoPtr = (TOOLTIPS_INFO *)COMCTL32_Alloc (sizeof(TOOLTIPS_INFO));
    1838     SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
     1854    infoPtr = (TOOLTIPS_INFO *)COMCTL32_Alloc(sizeof(TOOLTIPS_INFO));
     1855    SetWindowLongA(hwnd,0,(DWORD)infoPtr);
    18391856
    18401857    /* initialize info structure */
    18411858    infoPtr->bActive = TRUE;
    18421859    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
    18451862
    18461863    nclm.cbSize = sizeof(NONCLIENTMETRICSA);
    1847     SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 0, &nclm, 0);
    1848     infoPtr->hFont = CreateFontIndirectA (&nclm.lfStatusFont);
     1864    SystemParametersInfoA(SPI_GETNONCLIENTMETRICS,0,&nclm,0);
     1865    infoPtr->hFont = CreateFontIndirectA(&nclm.lfStatusFont);
    18491866
    18501867    infoPtr->nMaxTipWidth = -1;
     
    18591876    infoPtr->nInitialTime   = 500;
    18601877
    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);
    18631881//    if (nResult == NFR_ANSI)
    18641882//      TRACE (tooltips, " -- WM_NOTIFYFORMAT returns: NFR_ANSI\n");
     
    18681886//      FIXME (tooltips, " -- WM_NOTIFYFORMAT returns: error!\n");
    18691887
    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);
    18711889
    18721890    return 0;
     
    18771895TOOLTIPS_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
    18781896{
    1879     TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd);
     1897    TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr(hwnd);
    18801898    TTTOOL_INFO *toolPtr;
    18811899    INT i;
    18821900
    18831901    /* 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);
    19081910        }
    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);
    19101931    }
    19111932
     
    19141935
    19151936    /* free tool tips info data */
    1916     COMCTL32_Free (infoPtr);
     1937    COMCTL32_Free(infoPtr);
    19171938
    19181939    return 0;
     
    19591980TOOLTIPS_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
    19601981{
    1961     DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
     1982    DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
     1983    DWORD dwExStyle = GetWindowLongA(hwnd,GWL_EXSTYLE);
    19621984
    19631985    dwStyle &= 0x0000FFFF;
    19641986    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);
    19661990
    19671991    return TRUE;
     
    20732097    switch (wParam)
    20742098    {
    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;
    20932118    }
    20942119    return 0;
  • trunk/src/comctl32/trackbar.c

    r145 r180  
    1 /* $Id: trackbar.c,v 1.6 1999-06-21 15:28:44 cbratschi Exp $ */
     1/* $Id: trackbar.c,v 1.7 1999-06-24 16:37:45 cbratschi Exp $ */
    22/*
    33 * Trackbar control
     
    5454#define THUMB_MINLEN 4
    5555
    56 #define CHANNEL_NOSEL_HEIGHT 4
    57 #define CHANNEL_MIN_HEIGHT   4
    58 #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
    5959#define CHANNEL_SPACE        8
    60 #define CHANNEL_SCALE_SPACE  CHANNEL_THUMB_DIFF/2+SCALE_SIZE+SCALE_SPACE+BORDER_SIZE
    61 #define CHANNEL_THUMB_SPACE  CHANNEL_THUMB_DIFF+BORDER_SIZE
     60#define CHANNEL_SCALE_SPACE  SCALE_SIZE+SCALE_SPACE+BORDER_SIZE
     61#define CHANNEL_THUMB_SPACE  BORDER_SIZE
    6262
    6363/* scroll mode */
     
    102102    }
    103103
    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
    107116    {
    108117      COMCTL32_Free(infoPtr->tics);
     
    112121    }
    113122
    114     if (infoPtr->uTicFreq && infoPtr->nRangeMax > infoPtr->nRangeMin && (dwStyle & TBS_AUTOTICKS))
    115     {
    116       //Tics without start and end tic
    117       nrTics = (infoPtr->nRangeMax-infoPtr->nRangeMin)/infoPtr->uTicFreq-1;
    118     } else
    119     {
    120       COMCTL32_Free(infoPtr->tics);
    121       infoPtr->tics = NULL;
    122       infoPtr->uNumTics = 0;
    123       return;
    124     }
    125 
    126123    if (nrTics != infoPtr->uNumTics)
    127124    {
     
    173170    INT channelSize;
    174171    RECT lpRect,*channel = &infoPtr->rcChannel;
     172    INT thumbDiff;
    175173
    176174    GetClientRect(hwnd,&lpRect);
     
    179177    else channelSize = CHANNEL_NOSEL_HEIGHT;
    180178
     179    thumbDiff = (infoPtr->uThumbLen-channelSize)/2;
     180
    181181    if (dwStyle & TBS_VERT)
    182182    {
     
    184184      channel->bottom = lpRect.bottom-CHANNEL_SPACE;
    185185
    186       if (dwStyle & TBS_BOTH)
     186      if (dwStyle & TBS_BOTH || dwStyle & TBS_NOTICKS)
    187187      { //center
    188188        channel->left  = (lpRect.right-channelSize)/2;
     
    190190      } else if (dwStyle & TBS_LEFT)
    191191      {
    192         channel->left  = lpRect.left+CHANNEL_SCALE_SPACE;
     192        channel->left  = lpRect.left+thumbDiff+CHANNEL_SCALE_SPACE;
    193193        channel->right = channel->left+channelSize;
    194194      } else
    195195      { //Right, align left
    196         channel->left = lpRect.left+CHANNEL_THUMB_SPACE;
     196        channel->left = lpRect.left+thumbDiff+CHANNEL_THUMB_SPACE;
    197197        channel->right = channel->left+channelSize;
    198198      }
     
    201201      channel->left = lpRect.left+CHANNEL_SPACE;
    202202      channel->right = lpRect.right-CHANNEL_SPACE;
    203       if (dwStyle & TBS_BOTH)
     203      if (dwStyle & TBS_BOTH || dwStyle & TBS_NOTICKS)
    204204      { //center
    205205        channel->top    = (lpRect.bottom-channelSize)/2;
     
    207207      } else if (dwStyle & TBS_TOP)
    208208      {
    209         channel->top    = lpRect.top+CHANNEL_SCALE_SPACE;
     209        channel->top    = lpRect.top+thumbDiff+CHANNEL_SCALE_SPACE;
    210210        channel->bottom = channel->top+channelSize;
    211211      } else
    212212      { //Bottom, align top
    213         channel->top    = lpRect.top+CHANNEL_THUMB_SPACE;
     213        channel->top    = lpRect.top+thumbDiff+CHANNEL_THUMB_SPACE;
    214214        channel->bottom = channel->top+channelSize;
    215215      }
     
    680680    {
    681681      int ticFlags = dwStyle & 0x0f;
    682       COLORREF clrTic = GetSysColor(COLOR_3DDKSHADOW);
     682      COLORREF clrTic = RGB(0,0,0);//CB: black instead of GetSysColor(COLOR_3DDKSHADOW);
    683683
    684684      for (i = 0;i < infoPtr->uNumTics;i++)
     
    714714   HRGN hrgn,hrgnLast,hrgnNew;
    715715
    716    if (dwStyle & TBS_NOTHUMB) return;
    717 
    718716   //last
    719717   lastRect = infoPtr->rcFullThumb;
    720718
    721719   //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   }
    723725   if (infoPtr->nPos == lastPos) return;
     726
     727   if (dwStyle & TBS_NOTHUMB) return;
    724728
    725729   TRACKBAR_CalcThumb(hwnd,infoPtr);
     
    11311135    TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
    11321136    int newMin,newMax;
     1137    DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
     1138
    11331139    newMin = (INT)LOWORD(lParam);
    11341140    newMax = (INT)HIWORD(lParam);
    11351141
     1142    if (newMin >= newMax) return 0;
    11361143    if (newMin == infoPtr->nRangeMin && newMax == infoPtr->nRangeMax) return 0;
    11371144
     
    11411148    if (infoPtr->nPos < infoPtr->nRangeMin)
    11421149    {
    1143         infoPtr->nPos = infoPtr->nRangeMin;
    1144         infoPtr->flags |= TB_THUMBPOSCHANGED;
    1145     }
    1146 
     1150      infoPtr->nPos = infoPtr->nRangeMin;
     1151      infoPtr->flags |= TB_THUMBPOSCHANGED;
     1152    }
    11471153    if (infoPtr->nPos > infoPtr->nRangeMax)
    11481154    {
    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;
    11511178    }
    11521179
     
    11661193    TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
    11671194
     1195    if ((INT)lParam <= infoPtr->nRangeMin) return 0;
    11681196    if (infoPtr->nRangeMax == (INT)lParam) return 0;
    11691197
     
    11711199    if (infoPtr->nPos > infoPtr->nRangeMax)
    11721200    {
    1173         infoPtr->nPos = infoPtr->nRangeMax;
    1174         infoPtr->flags |=TB_THUMBPOSCHANGED;
     1201      infoPtr->nPos = infoPtr->nRangeMax;
     1202      infoPtr->flags |=TB_THUMBPOSCHANGED;
    11751203    }
    11761204
     
    11901218    TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
    11911219
     1220    if ((INT)lParam >= infoPtr->nRangeMax) return 0;
    11921221    if (infoPtr->nRangeMin == (INT)lParam) return 0;
    11931222
     
    11951224    if (infoPtr->nPos < infoPtr->nRangeMin)
    11961225    {
    1197         infoPtr->nPos = infoPtr->nRangeMin;
    1198         infoPtr->flags |=TB_THUMBPOSCHANGED;
     1226      infoPtr->nPos = infoPtr->nRangeMin;
     1227      infoPtr->flags |=TB_THUMBPOSCHANGED;
    11991228    }
    12001229
     
    12161245    if (infoPtr->uTicFreq == (UINT)wParam) return 0;
    12171246
    1218     if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBS_AUTOTICKS)) return 0;
     1247    if (!(GetWindowLongA(hwnd,GWL_STYLE) & TBS_AUTOTICKS)) return 0;
    12191248
    12201249    infoPtr->uTicFreq = (UINT)wParam;
     
    12291258
    12301259static LRESULT
    1231 TRACKBAR_SetSel (HWND hwnd, WPARAM wParam, LPARAM lParam)
    1232 {
    1233     TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
    1234     INT newMin,newMax;
    1235 
     1260TRACKBAR_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;
    12361267    newMin = (INT)LOWORD(lParam);
    12371268    newMax = (INT)HIWORD(lParam);
     
    12411272    infoPtr->nSelMax = newMax;
    12421273
    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    }
    12541288
    12551289    return 0;
     
    12611295{
    12621296    TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
     1297    INT oldMax;
    12631298
    12641299    if (infoPtr->nSelMax == (INT)lParam) return 0;
    12651300
    1266     if (!GetWindowLongA (hwnd, GWL_STYLE) & TBS_ENABLESELRANGE)
    1267         return 0;
    1268 
     1301    oldMax = infoPtr->nSelMax;
    12691302    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    }
    12761316
    12771317    return 0;
     
    12831323{
    12841324    TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
     1325    INT oldMin;
    12851326
    12861327    if (infoPtr->nSelMin == (INT)lParam) return 0;
    12871328
    1288     if (!GetWindowLongA (hwnd, GWL_STYLE) & TBS_ENABLESELRANGE)
    1289         return 0;
    1290 
     1329    oldMin = infoPtr->nSelMin;
    12911330    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    }
    12981344
    12991345    return 0;
     
    14061452    INT scaleSize;
    14071453
    1408     GetWindowRect(hwnd,&clientRect);
     1454    GetClientRect(hwnd,&clientRect);
    14091455    infoPtr->uThumbLen = THUMB_LEN;   /* initial thumb length */
    14101456
     
    14551501    infoPtr->uTicFreq   = 1;
    14561502    infoPtr->tics       = NULL;
    1457     infoPtr->clrBk      = GetSysColor (COLOR_3DFACE);
    1458     infoPtr->hwndNotify = GetParent (hwnd);
     1503    infoPtr->clrBk      = GetSysColor(COLOR_3DFACE);
     1504    infoPtr->hwndNotify = GetParent(hwnd);
    14591505
    14601506    TRACKBAR_InitializeThumb (hwnd);
    14611507
    14621508    /* 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);
    14941541    }
    14951542
     
    15041551
    15051552    /* 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
    15101558    return 0;
    15111559}
     
    15491597           TTTOOLINFOA ti;
    15501598           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));
    15551603
    15561604           ti.cbSize   = sizeof(TTTOOLINFOA);
    15571605           ti.uId      = 0;
    15581606           ti.hwnd     = (UINT)hwnd;
     1607           ti.hinst = 0;
     1608           sprintf (buf,"%d",infoPtr->nPos);
     1609           ti.lpszText = (LPSTR)buf;
    15591610
    15601611           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);
    15641616         }
    15651617         SetCapture(hwnd);
     
    16341686
    16351687    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);
    16461697    }
    16471698
     
    17921843//    TRACE (trackbar, "%x\n",code);
    17931844
    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    }
    18001852}
    18011853
     
    18051857{
    18061858    TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
    1807     DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
     1859    DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
    18081860    SHORT clickPlace;
    18091861    DOUBLE dragPos;
    1810     char buf[80];
    1811     INT lastDragPos;
    18121862
    18131863//    TRACE (trackbar, "%x\n",wParam);
    18141864
    1815     if (dwStyle & TBS_VERT) clickPlace=(SHORT)HIWORD(lParam);
    1816     else clickPlace=(SHORT)LOWORD(lParam);
    1817 
    18181865    if (!(infoPtr->flags & TB_DRAG_MODE)) return TRUE;
    18191866
    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);
    18231871    if (dragPos > ((INT)dragPos)+0.5) infoPtr->dragPos = dragPos + 1;
    18241872    else infoPtr->dragPos = dragPos;
    18251873
    1826     if (lastDragPos == infoPtr->dragPos) return TRUE; //nothing changed
     1874    if (infoPtr->nPos == infoPtr->dragPos) return TRUE; //nothing changed
    18271875
    18281876    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));
    18301881
    18311882    if (infoPtr->flags & TB_SHOW_TOOLTIP)
    18321883    {
    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    }
    18561905
    18571906    return TRUE;
     
    18621911TRACKBAR_KeyDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
    18631912{
    1864     TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd);
     1913    TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(hwnd);
    18651914    INT pos;
    18661915
    18671916//    TRACE (trackbar, "%x\n",wParam);
    18681917
    1869     pos=infoPtr->nPos;
     1918    if (infoPtr->flags & TB_DRAG_MODE) return TRUE;
     1919
     1920    pos = infoPtr->nPos;
    18701921    switch (wParam) {
    18711922    case VK_LEFT:
     
    19241975TRACKBAR_KeyUp (HWND hwnd, WPARAM wParam)
    19251976{
     1977    TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(hwnd);
     1978
     1979    if (infoPtr->flags & TB_DRAG_MODE) return TRUE;
     1980
    19261981    switch (wParam) {
    19271982    case VK_LEFT:
  • trunk/src/comctl32/updown.c

    r110 r180  
    1 /* $Id: updown.c,v 1.4 1999-06-16 20:25:45 cbratschi Exp $ */
     1/* $Id: updown.c,v 1.5 1999-06-24 16:37:46 cbratschi Exp $ */
    22/*
    33 * Updown control
     
    88 *
    99 * TODO:
    10  *   - subclass the buddy window (in UPDOWN_SetBuddy) to process the
     10 *   - subclass the buddy window (in UPDOWN_SetBuddyHandle) to process the
    1111 *     arrow keys
    1212 *   - I am not sure about the default values for the Min, Max, Pos
     
    3333 */
    3434
     35/* CB: Odin32 problems
     36  - Open32 doesn't look for CS_DBLCLKS -> double clicks always sent
     37*/
     38
    3539#include <stdlib.h>
    3640#include <stdio.h>
     
    7175#define UNKNOWN_PARAM(msg, wParam, lParam)
    7276
    73 #define UPDOWN_GetInfoPtr(hwnd) ((UPDOWN_INFO *)GetWindowLongA (hwnd,0))
     77#define UPDOWN_GetInfoPtr(hwnd) ((UPDOWN_INFO *)GetWindowLongA(hwnd,0))
    7478
    7579
     
    128132  GetClientRect (hwnd, rect);
    129133
    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;
    143144  }
    144145}
     
    191192  int newVal;
    192193
    193   if (!IsWindow(infoPtr->Buddy))
    194     return FALSE;
     194  if (!IsWindow(infoPtr->Buddy)) return FALSE;
    195195
    196196  /*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       return FALSE;
    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  {
    203203    /* 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;
    206205
    207206    sep = UPDOWN_GetThousandSep();
    208207
    209208    /* 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)
    212211        *dst++ = *src;
    213212    *dst = 0;
    214213
    215214    /* 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;
    219217
    220218//    TRACE(updown, "new value(%d) read from buddy (old=%d)\n",
     
    223221
    224222  infoPtr->CurVal = newVal;
     223
    225224  return TRUE;
    226225}
     
    236235static BOOL UPDOWN_SetBuddyInt (HWND hwnd)
    237236{
    238   UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr (hwnd);
    239   char txt1[20], sep;
     237  UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr(hwnd);
     238  char txt1[20],sep;
    240239  int len;
    241240
    242   if (!IsWindow(infoPtr->Buddy))
    243     return FALSE;
     241  if (!IsWindow(infoPtr->Buddy)) return FALSE;
    244242
    245243//  TRACE(updown, "set new value(%d) to buddy.\n",
     
    247245
    248246  /*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);
    254253
    255254    sep = UPDOWN_GetThousandSep();
     
    282281 * Draw the arrows. The background need not be erased.
    283282 */
    284 static void UPDOWN_Draw (HWND hwnd, HDC hdc)
    285 {
    286   UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr (hwnd);
    287   DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
     283static void UPDOWN_Draw(HWND hwnd,HDC hdc)
     284{
     285  UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr(hwnd);
     286  DWORD dwStyle = GetWindowLongA(hwnd, GWL_STYLE);
    288287  BOOL prssed;
    289288  RECT rect;
     
    298297
    299298  /* Draw the space between the buttons */
    300   rect.top = rect.bottom; rect.bottom++;
     299  rect.top = rect.bottom;
     300  rect.bottom++;
    301301  DrawEdge(hdc, &rect, 0, BF_MIDDLE);
    302302
     
    343343
    344344/***********************************************************************
    345  *           UPDOWN_SetBuddy
     345 *           UPDOWN_SetBuddyHandle
    346346 * Tests if 'hwndBud' is a valid window handle. If not, returns FALSE.
    347347 * Else, sets it as a new Buddy.
     
    352352 * the size/pos of the buddy and the control are adjusted accordingly.
    353353 */
    354 static BOOL UPDOWN_SetBuddy (HWND hwnd, HWND hwndBud)
     354static BOOL UPDOWN_SetBuddyHandle (HWND hwnd, HWND hwndBud)
    355355{
    356356  UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr (hwnd);
     
    420420static void UPDOWN_DoAction (HWND hwnd, int delta, BOOL incr)
    421421{
    422   UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr (hwnd);
    423   DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
     422  UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr(hwnd);
     423  DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
    424424  int old_val = infoPtr->CurVal;
    425425  NM_UPDOWN ni;
     
    429429  /* check if we can do the modification first */
    430430  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;
    433432
    434433  /* 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;
    436435  infoPtr->CurVal = old_val;
    437436
     
    440439  ni.iDelta = delta;
    441440  ni.hdr.hwndFrom = hwnd;
    442   ni.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
     441  ni.hdr.idFrom   = GetWindowLongA(hwnd,GWL_ID);
    443442  ni.hdr.code = UDN_DELTAPOS;
    444   if (SendMessageA(GetParent (hwnd), WM_NOTIFY,
    445                    (WPARAM)ni.hdr.idFrom, (LPARAM)&ni))
     443  if (SendMessageA(GetParent(hwnd),WM_NOTIFY,
     444                   (WPARAM)ni.hdr.idFrom,(LPARAM)&ni))
    446445    return; /* we are not allowed to change */
    447446
    448447  /* Now adjust value with (maybe new) delta */
    449   if (!UPDOWN_OffsetVal (hwnd, ni.iDelta))
    450     return;
     448  if (!UPDOWN_OffsetVal (hwnd,ni.iDelta)) return;
    451449
    452450  /* Now take care about our buddy */
     
    455453
    456454
    457   if (dwStyle & UDS_SETBUDDYINT)
    458     UPDOWN_SetBuddyInt (hwnd);
     455  if (dwStyle & UDS_SETBUDDYINT) UPDOWN_SetBuddyInt(hwnd);
    459456
    460457  /* Also, notify it */
     
    529526    case WM_LBUTTONDOWN:  /* Initialise mouse tracking */
    530527      /* 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;
    533529
    534530      /* 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);
    537532
    538533      /* Now see which one is the 'active' arrow */
    539       temp = UPDOWN_GetArrowFromPoint (hwnd, &rect, pt);
     534      temp = UPDOWN_GetArrowFromPoint(hwnd,&rect,pt);
    540535
    541536      /* Update the CurVal if necessary */
    542       if (dwStyle & UDS_SETBUDDYINT)
    543         UPDOWN_GetBuddyInt (hwnd);
     537      if (dwStyle & UDS_SETBUDDYINT) UPDOWN_GetBuddyInt(hwnd);
    544538
    545539      /* 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))
    549543          return;
    550544
     
    558552
    559553      /* process the click */
    560       UPDOWN_DoAction (hwnd, 1, infoPtr->Flags & FLAG_INCR);
     554      UPDOWN_DoAction (hwnd,1,infoPtr->Flags & FLAG_INCR);
    561555
    562556      /* now capture all mouse messages */
     
    564558
    565559      /* and startup the first timer */
    566       SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0);
     560      SetTimer(hwnd,TIMERID1,INITIAL_DELAY,0);
    567561      break;
    568562
    569563    case WM_MOUSEMOVE:
    570564      /* 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;
    573566
    574567      /* save the flags to see if any got modified */
     
    601594}
    602595
     596//Message handling
     597
     598static 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
     607static 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
     633static 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
     646static 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
     656static 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
     697static 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
     710static 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
     729static 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
     747static 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
     766static 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
     775static 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
     793static 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
     803static 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
     818static 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
     829static 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
     851static 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
     860static 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
     874static 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
     884static 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
    603897/***********************************************************************
    604898 *           UpDownWndProc
     
    607901                                LPARAM lParam)
    608902{
    609   UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr (hwnd);
    610   DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
    611   int temp;
    612 
    613903  switch(message)
    614904    {
    615905    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);
    619907
    620908    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);
    636922      break;
    637923
    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);
    681934      }
    682935      break;
    683936
    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);
    686942      break;
    687943
    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 
    722944    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);
    732946
    733947    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);
    747949
    748950    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);
    752952
    753953    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);
    764955
    765956    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);
    769958
    770959    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);
    779961
    780962    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);
    785964
    786965    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);
    803967
    804968    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);
    808970
    809971    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);
    818973
    819974    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);
    825976
    826977    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);
    834979
    835980    default:
     
    837982//      ERR (updown, "unknown msg %04x wp=%04x lp=%08lx\n",
    838983//           message, wParam, lParam);
    839       return DefWindowProcA (hwnd, message, wParam, lParam);
     984      return DefWindowProcA(hwnd,message,wParam,lParam);
    840985    }
    841986
Note: See TracChangeset for help on using the changeset viewer.