Changeset 9370 for trunk/src


Ignore:
Timestamp:
Oct 29, 2002, 1:19:36 PM (23 years ago)
Author:
sandervl
Message:

Wine resync

Location:
trunk/src/comctl32
Files:
5 added
5 deleted
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/comctl32/comboex.c

    r8382 r9370  
    2020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    2121 *
    22  * FIXME:
    23  *  1. Implement following extended styles:
    24  *           CBES_EX_PATHWORDBREAKPROC
    25  *           CBES_EX_NOSIZELIMIT
    26  *           CBES_EX_CASESENSITIVE
    27  *  2. Notify CBEN_DRAGBEGIN is not implemented.
    28  *
     22 * NOTE
     23 *
     24 * This code was audited for completeness against the documented features
     25 * of Comctl32.dll version 6.0 on Sep. 9, 2002, by Dimitrie O. Paun.
     26 *
     27 * Unless otherwise noted, we belive this code to be complete, as per
     28 * the specification mentioned above.
     29 * If you discover missing features, or bugs, please note them below.
     30 *
    2931 */
    3032
     
    7476
    7577/* internal flags in the COMBOEX_INFO structure */
    76 #define  WCBE_ACTEDIT           0x00000001     /* Edit active i.e.
     78#define  WCBE_ACTEDIT           0x00000001  /* Edit active i.e.
    7779                                             * CBEN_BEGINEDIT issued
    7880                                             * but CBEN_ENDEDIT{A|W}
    7981                                             * not yet issued. */
    80 #define  WCBE_EDITCHG           0x00000002     /* Edit issued EN_CHANGE */
     82#define  WCBE_EDITCHG           0x00000002  /* Edit issued EN_CHANGE */
    8183#define  WCBE_EDITHASCHANGED    (WCBE_ACTEDIT | WCBE_EDITCHG)
    82 #define  WCBE_EDITFOCUSED       0x00000004     /* Edit control has focus */
    83 
     84#define  WCBE_EDITFOCUSED       0x00000004  /* Edit control has focus */
     85#define  WCBE_MOUSECAPTURED     0x00000008  /* Combo has captured mouse */
     86#define  WCBE_MOUSEDRAGGED      0x00000010  /* User has dragged in combo */
    8487
    8588#define ID_CB_EDIT              1001
     
    8891/*
    8992 * Special flag set in DRAWITEMSTRUCT itemState field. It is set by
    90  * the ComboEx version of the Combo Window Proc so that when the 
    91  * WM_DRAWITEM message is then passed to ComboEx, we know that this 
     93 * the ComboEx version of the Combo Window Proc so that when the
     94 * WM_DRAWITEM message is then passed to ComboEx, we know that this
    9295 * particular WM_DRAWITEM message is for listbox only items. Any messasges
    9396 * without this flag is then for the Edit control field.
    9497 *
    95  * We really cannot use the ODS_COMBOBOXEDIT flag because MSDN states that 
     98 * We really cannot use the ODS_COMBOBOXEDIT flag because MSDN states that
    9699 * only version 4.0 applications will have ODS_COMBOBOXEDIT set.
    97100 */
     
    121124static LRESULT WINAPI
    122125COMBOEX_ComboWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
     126static int CALLBACK
     127COMBOEX_PathWordBreakProc(LPWSTR lpch, int ichCurrent, int cch, int code);
    123128static LRESULT COMBOEX_Destroy (COMBOEX_INFO *infoPtr);
     129
     130#ifdef __WIN32OS2__
     131#undef inline
     132#define inline
     133
     134typedef INT (* WINAPI cmp_func_t)(LPCWSTR, LPCWSTR);
     135#else
     136typedef INT (WINAPI *cmp_func_t)(LPCWSTR, LPCWSTR);
     137#endif
    124138
    125139inline static BOOL is_textW(LPCWSTR str)
     
    164178inline static CBE_ITEMDATA *get_item_data(COMBOEX_INFO *infoPtr, INT index)
    165179{
    166     return (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo, CB_GETITEMDATA, 
     180    return (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo, CB_GETITEMDATA,
    167181                                         (WPARAM)index, 0);
    168182}
    169183
     184inline static cmp_func_t get_cmp_func(COMBOEX_INFO *infoPtr)
     185{
     186    return infoPtr->dwExtStyle & CBES_EX_CASESENSITIVE ? lstrcmpW : lstrcmpiW;
     187}
    170188
    171189static INT COMBOEX_Notify (COMBOEX_INFO *infoPtr, INT code, NMHDR *hdr)
     
    207225        else if (code == CBEN_GETDISPINFOW) code = CBEN_GETDISPINFOA;
    208226        else if (code == CBEN_DRAGBEGINW) code = CBEN_DRAGBEGINA;
    209        
     227
    210228        ret = COMBOEX_Notify (infoPtr, code, (NMHDR *)hdr);
    211229
    212230        if (astr && hdr->ceItem.pszText == (LPWSTR)astr)
    213231            hdr->ceItem.pszText = wstr;
    214        
     232
    215233        if (astr) COMCTL32_Free(astr);
    216        
     234
    217235        return ret;
    218236    }
     
    228246    } else {
    229247        NMCBEENDEDITA neea;
    230        
     248
    231249        memcpy (&neea.hdr, &neew->hdr, sizeof(NMHDR));
    232250        neea.fChanged = neew->fChanged;
     
    240258
    241259
     260static void COMBOEX_NotifyDragBegin(COMBOEX_INFO *infoPtr, LPCWSTR wstr)
     261{
     262    /* Change the Text item from Unicode to ANSI if necessary for NOTIFY */
     263    if (infoPtr->NtfUnicode) {
     264        NMCBEDRAGBEGINW ndbw;
     265
     266        ndbw.iItemid = -1;
     267        lstrcpynW(ndbw.szText, wstr, CBEMAXSTRLEN);
     268        COMBOEX_Notify (infoPtr, CBEN_DRAGBEGINW, &ndbw.hdr);
     269    } else {
     270        NMCBEDRAGBEGINA ndba;
     271
     272        ndba.iItemid = -1;
     273        WideCharToMultiByte (CP_ACP, 0, wstr, -1, ndba.szText, CBEMAXSTRLEN, 0, 0);
     274
     275        COMBOEX_Notify (infoPtr, CBEN_DRAGBEGINA, &ndba.hdr);
     276    }
     277}
     278
     279
    242280static void COMBOEX_FreeText (CBE_ITEMDATA *item)
    243281{
     
    254292    LPWSTR text, buf;
    255293    INT len;
    256    
    257     if (item->pszText != LPSTR_TEXTCALLBACKW) 
     294
     295    if (item->pszText != LPSTR_TEXTCALLBACKW)
    258296        return item->pszText;
    259    
     297
    260298    ZeroMemory(&nmce, sizeof(nmce));
    261299    nmce.ceItem.mask = CBEIF_TEXT;
     
    277315    } else
    278316        text = nmce.ceItem.pszText;
    279    
     317
    280318    if (nmce.ceItem.mask & CBEIF_DI_SETITEM)
    281319        item->pszText = text;
     
    290328
    291329    mydc = GetDC (0); /* why the entire screen???? */
    292     nfont = SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
     330    nfont = (HFONT)SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
    293331    ofont = (HFONT) SelectObject (mydc, nfont);
    294332    GetTextExtentPointA (mydc, "A", 1, size);
    295333    SelectObject (mydc, ofont);
    296334    ReleaseDC (0, mydc);
    297     TRACE("selected font hwnd=%08x, height=%ld\n", nfont, size->cy);
     335    TRACE("selected font hwnd=%p, height=%ld\n", nfont, size->cy);
    298336}
    299337
     
    376414    }
    377415    SendMessageW (infoPtr->hwndSelf, CB_SETITEMHEIGHT, (WPARAM)-1, (LPARAM)cy);
    378     if (infoPtr->hwndCombo)
     416    if (infoPtr->hwndCombo) {
    379417        SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT,
    380418                      (WPARAM) 0, (LPARAM) cy);
     419        if ( !(infoPtr->flags & CBES_EX_NOSIZELIMIT)) {
     420            RECT comboRect;
     421            if (GetWindowRect(infoPtr->hwndCombo, &comboRect)) {
     422                RECT ourRect;
     423                if (GetWindowRect(infoPtr->hwndSelf, &ourRect)) {
     424                    if (comboRect.bottom > ourRect.bottom) {
     425                        POINT pt = { ourRect.left, ourRect.top };
     426                        if (ScreenToClient(infoPtr->hwndSelf, &pt))
     427                            MoveWindow( infoPtr->hwndSelf, pt.x, pt.y, ourRect.right - ourRect.left,
     428                                        comboRect.bottom - comboRect.top, FALSE);
     429                    }
     430                }
     431            }
     432        }
     433    }
    381434}
    382435
     
    396449}
    397450
    398  
     451
    399452static CBE_ITEMDATA * COMBOEX_FindItem(COMBOEX_INFO *infoPtr, INT index)
    400453{
     
    424477static inline BOOL COMBOEX_HasEdit(COMBOEX_INFO *infoPtr)
    425478{
    426     return infoPtr->hwndEdit;
    427 }
    428  
     479    return infoPtr->hwndEdit ? TRUE : FALSE;
     480}
     481
    429482
    430483/* ***  CBEM_xxx message support  *** */
     
    481534
    482535    if (is_textW(tmpcit.pszText) && cit->pszText)
    483         WideCharToMultiByte (CP_ACP, 0, tmpcit.pszText, -1, 
     536        WideCharToMultiByte (CP_ACP, 0, tmpcit.pszText, -1,
    484537                             cit->pszText, cit->cchTextMax, NULL, NULL);
    485538    else if (cit->pszText) cit->pszText[0] = 0;
     
    520573    /* get zero-filled space and chain it in */
    521574    if(!(item = (CBE_ITEMDATA *)COMCTL32_Alloc (sizeof(*item)))) return -1;
    522    
     575
    523576    /* locate position to insert new item in */
    524577    if (index == infoPtr->nb_items) {
     
    576629    if (TRACE_ON(comboex)) COMBOEX_DumpItem (item);
    577630
    578     SendMessageW (infoPtr->hwndCombo, CB_INSERTSTRING, 
     631    SendMessageW (infoPtr->hwndCombo, CB_INSERTSTRING,
    579632                  (WPARAM)cit->iItem, (LPARAM)item);
    580633
     
    602655        citW.pszText = wstr;
    603656    }
    604     ret = COMBOEX_InsertItemW(infoPtr, &citW);;
    605    
     657    ret = COMBOEX_InsertItemW(infoPtr, &citW);
     658
    606659    if (wstr) COMCTL32_Free(wstr);
    607    
     660
    608661    return ret;
    609662}
    610663
    611664
    612 static DWORD 
     665static DWORD
    613666COMBOEX_SetExtendedStyle (COMBOEX_INFO *infoPtr, DWORD mask, DWORD style)
    614667{
     
    618671
    619672    dwTemp = infoPtr->dwExtStyle;
    620 
    621     if (style &  (CBES_EX_PATHWORDBREAKPROC |
    622                   CBES_EX_NOSIZELIMIT |
    623                   CBES_EX_CASESENSITIVE))
    624         FIXME("Extended style not implemented %08lx\n", style);
    625673
    626674    if (mask)
     
    628676    else
    629677        infoPtr->dwExtStyle = style;
     678
     679    /* see if we need to change the word break proc on the edit */
     680    if ((infoPtr->dwExtStyle ^ dwTemp) & CBES_EX_PATHWORDBREAKPROC) {
     681        SendMessageW(infoPtr->hwndEdit, EM_SETWORDBREAKPROC, 0,
     682                     (infoPtr->dwExtStyle & CBES_EX_PATHWORDBREAKPROC) ?
     683                         (LPARAM)COMBOEX_PathWordBreakProc : 0);
     684    }
    630685
    631686    /* test if the control's appearance has changed */
     
    676731    if (!(item = COMBOEX_FindItem(infoPtr, index))) return FALSE;
    677732
    678     /* add/change stuff to the internal item structure */ 
     733    /* add/change stuff to the internal item structure */
    679734    item->mask |= cit->mask;
    680735    if (cit->mask & CBEIF_TEXT) {
     
    726781        citW.pszText = wstr;
    727782    }
    728     ret = COMBOEX_SetItemW(infoPtr, &citW);;
     783    ret = COMBOEX_SetItemW(infoPtr, &citW);
    729784
    730785    if (wstr) COMCTL32_Free(wstr);
     
    749804
    750805static INT
    751 COMBOEX_FindStringExact (COMBOEX_INFO *infoPtr, INT start, LPCSTR str)
    752 {
    753     INT i, count;
    754     CBE_ITEMDATA *item;
    755     LPWSTR desired = NULL;
    756 
    757     i = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
    758     if (i > 0) {
    759         desired = (LPWSTR)COMCTL32_Alloc ((i + 1)*sizeof(WCHAR));
    760         if (!desired) return CB_ERR;
    761         MultiByteToWideChar (CP_ACP, 0, str, -1, desired, i);
    762     }
    763 
    764     count = SendMessageW (infoPtr->hwndCombo, CB_GETCOUNT, 0, 0);
     806COMBOEX_FindStringExact (COMBOEX_INFO *infoPtr, INT start, LPCWSTR str)
     807{
     808    INT i;
     809    cmp_func_t cmptext = get_cmp_func(infoPtr);
     810    INT count = SendMessageW (infoPtr->hwndCombo, CB_GETCOUNT, 0, 0);
    765811
    766812    /* now search from after starting loc and wrapping back to start */
    767813    for(i=start+1; i<count; i++) {
    768         item = get_item_data(infoPtr, i);
    769         if (lstrcmpiW(COMBOEX_GetText(infoPtr, item), desired) == 0) {
    770             COMCTL32_Free (desired);
    771             return i;
    772         }
     814        CBE_ITEMDATA *item = get_item_data(infoPtr, i);
     815        if (cmptext(COMBOEX_GetText(infoPtr, item), str) == 0) return i;
    773816    }
    774817    for(i=0; i<=start; i++) {
    775         item = get_item_data(infoPtr, i);
    776         if (lstrcmpiW(COMBOEX_GetText(infoPtr, item), desired) == 0) {
    777             COMCTL32_Free (desired);
    778             return i;
    779         }
    780     }
    781     COMCTL32_Free(desired);
     818        CBE_ITEMDATA *item = get_item_data(infoPtr, i);
     819        if (cmptext(COMBOEX_GetText(infoPtr, item), str) == 0) return i;
     820    }
    782821    return CB_ERR;
    783822}
     
    857896    GetWindowRect (infoPtr->hwndSelf, &cbx_wrect);
    858897    GetClientRect (infoPtr->hwndSelf, &cbx_crect);
    859     /* the height of comboex as height of the combo + comboex border */ 
     898    /* the height of comboex as height of the combo + comboex border */
    860899    height = cb_wrect.bottom-cb_wrect.top
    861900             + cbx_wrect.bottom-cbx_wrect.top
     
    884923    WCHAR NIL[] = { 0 };
    885924    COMBOEX_INFO *infoPtr;
    886     DWORD dwComboStyle;
    887925    LOGFONTW mylogfont;
    888926    RECT wnrc1, clrc1, cmbwrc;
     
    895933    /* initialize info structure */
    896934    /* note that infoPtr is allocated zero-filled */
    897    
     935
    898936    infoPtr->hwndSelf = hwnd;
    899937    infoPtr->selected = -1;
     
    901939    infoPtr->unicode = IsWindowUnicode (hwnd);
    902940
    903     i = SendMessageW(GetParent (hwnd), WM_NOTIFYFORMAT, hwnd, NF_QUERY);
     941    i = SendMessageW(GetParent (hwnd), WM_NOTIFYFORMAT, (WPARAM)hwnd, NF_QUERY);
    904942    if ((i != NFR_ANSI) && (i != NFR_UNICODE)) {
    905943        WARN("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", i);
     
    911949
    912950    /* create combo box */
    913     dwComboStyle = GetWindowLongW (hwnd, GWL_STYLE) &
    914                         (CBS_SIMPLE|CBS_DROPDOWN|CBS_DROPDOWNLIST|WS_CHILD);
    915 
    916951    GetWindowRect(hwnd, &wnrc1);
    917952    GetClientRect(hwnd, &clrc1);
     
    919954          wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
    920955          clrc1.left, clrc1.top, clrc1.right, clrc1.bottom);
    921     TRACE("combo style=%08lx, adding style=%08lx\n", dwComboStyle,
    922           WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VSCROLL |
    923           CBS_NOINTEGRALHEIGHT | CBS_DROPDOWNLIST |
    924           WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED);
    925956
    926957    /* Native version of ComboEx creates the ComboBox with DROPDOWNLIST */
     
    934965                         /* following line added to match native */
    935966                         WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VSCROLL |
    936                          CBS_NOINTEGRALHEIGHT | CBS_DROPDOWNLIST | 
     967                         CBS_NOINTEGRALHEIGHT | CBS_DROPDOWNLIST |
    937968                         /* was base and is necessary */
    938                          WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED | dwComboStyle,
     969                         WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED |
     970                         GetWindowLongW (hwnd, GWL_STYLE),
    939971                         cs->y, cs->x, cs->cx, cs->cy, hwnd,
    940972                         (HMENU) GetWindowLongW (hwnd, GWL_ID),
    941                          GetWindowLongW (hwnd, GWL_HINSTANCE), NULL);
    942 
    943     /* 
     973                         (HINSTANCE)GetWindowLongW (hwnd, GWL_HINSTANCE), NULL);
     974
     975    /*
    944976     * native does the following at this point according to trace:
    945977     *  GetWindowThreadProcessId(hwndCombo,0)
     
    950982
    951983    /*
    952      * Setup a property to hold the pointer to the COMBOBOXEX 
     984     * Setup a property to hold the pointer to the COMBOBOXEX
    953985     * data structure.
    954986     */
    955987    SetPropA(infoPtr->hwndCombo, COMBOEX_SUBCLASS_PROP, hwnd);
    956     infoPtr->prevComboWndProc = (WNDPROC)SetWindowLongW(infoPtr->hwndCombo, 
     988    infoPtr->prevComboWndProc = (WNDPROC)SetWindowLongW(infoPtr->hwndCombo,
    957989                                GWL_WNDPROC, (LONG)COMBOEX_ComboWndProc);
    958     infoPtr->font = SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
     990    infoPtr->font = (HFONT)SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
    959991
    960992
     
    967999                    WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | ES_AUTOHSCROLL,
    9681000                    0, 0, 0, 0,  /* will set later */
    969                     infoPtr->hwndCombo, 
     1001                    infoPtr->hwndCombo,
    9701002                    (HMENU) GetWindowLongW (hwnd, GWL_ID),
    971                     GetWindowLongW (hwnd, GWL_HINSTANCE),
    972                     NULL);
     1003                    (HINSTANCE)GetWindowLongW (hwnd, GWL_HINSTANCE), NULL);
    9731004
    9741005        /* native does the following at this point according to trace:
     
    9801011
    9811012        /*
    982          * Setup a property to hold the pointer to the COMBOBOXEX 
     1013         * Setup a property to hold the pointer to the COMBOBOXEX
    9831014         * data structure.
    9841015         */
    9851016        SetPropA(infoPtr->hwndEdit, COMBOEX_SUBCLASS_PROP, hwnd);
    986         infoPtr->prevEditWndProc = (WNDPROC)SetWindowLongW(infoPtr->hwndEdit, 
     1017        infoPtr->prevEditWndProc = (WNDPROC)SetWindowLongW(infoPtr->hwndEdit,
    9871018                                 GWL_WNDPROC, (LONG)COMBOEX_EditWndProc);
    988         infoPtr->font = SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
     1019        infoPtr->font = (HFONT)SendMessageW(infoPtr->hwndCombo, WM_GETFONT, 0, 0);
    9891020    }
    9901021
     
    9941025     */
    9951026    if (!infoPtr->font) {
    996         SystemParametersInfoW (SPI_GETICONTITLELOGFONT, sizeof(mylogfont), 
     1027        SystemParametersInfoW (SPI_GETICONTITLELOGFONT, sizeof(mylogfont),
    9971028                               &mylogfont, 0);
    9981029        infoPtr->font = infoPtr->defaultFont = CreateFontIndirectW (&mylogfont);
     
    10151046          clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
    10161047          cmbwrc.left, cmbwrc.top, cmbwrc.right, cmbwrc.bottom);
    1017     SetWindowPos(infoPtr->hwndCombo, HWND_TOP, 
     1048    SetWindowPos(infoPtr->hwndCombo, HWND_TOP,
    10181049                 0, 0, wnrc1.right-wnrc1.left, wnrc1.bottom-wnrc1.top,
    10191050                 SWP_NOACTIVATE | SWP_NOREDRAW);
     
    10221053    TRACE("CB window=(%d,%d)-(%d,%d)\n",
    10231054          cmbwrc.left, cmbwrc.top, cmbwrc.right, cmbwrc.bottom);
    1024     SetWindowPos(hwnd, HWND_TOP, 
     1055    SetWindowPos(hwnd, HWND_TOP,
    10251056                 0, 0, cmbwrc.right-cmbwrc.left, cmbwrc.bottom-cmbwrc.top,
    10261057                 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE);
     
    10291060
    10301061    /*
    1031      * Create an item structure to represent the data in the 
     1062     * Create an item structure to represent the data in the
    10321063     * EDIT control. It is allocated zero-filled.
    10331064     */
     
    10611092        ShowWindow (infoPtr->hwndEdit, SW_HIDE);
    10621093        return SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf);
    1063        
     1094
    10641095    case CBN_CLOSEUP:
    10651096        SendMessageW (parent, WM_COMMAND, wParam, (LPARAM)infoPtr->hwndSelf);
    10661097        /*
    1067          * from native trace of first dropdown after typing in URL in IE4 
     1098         * from native trace of first dropdown after typing in URL in IE4
    10681099         *  CB_GETCURSEL(Combo)
    10691100         *  GetWindowText(Edit)
     
    10751106         *  CB_SETCURSEL(COMBOEX, n)
    10761107         *  SetFocus(Combo)
    1077          * the rest is supposition 
     1108         * the rest is supposition
    10781109         */
    10791110        ShowWindow (infoPtr->hwndEdit, SW_SHOW);
     
    10821113        cursel = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
    10831114        if (cursel == -1) {
     1115            cmp_func_t cmptext = get_cmp_func(infoPtr);
    10841116            /* find match from edit against those in Combobox */
    10851117            GetWindowTextW (infoPtr->hwndEdit, wintext, 520);
     
    10881120                item = get_item_data(infoPtr, cursel);
    10891121                if ((INT)item == CB_ERR) break;
    1090                 if (!lstrcmpiW(COMBOEX_GetText(infoPtr, item), wintext)) break;
     1122                if (!cmptext(COMBOEX_GetText(infoPtr, item), wintext)) break;
    10911123            }
    10921124            if ((cursel == n) || ((INT)item == CB_ERR)) {
     
    11551187
    11561188    case CBN_SELENDOK:
    1157         /* 
     1189        /*
    11581190         * We have to change the handle since we are the control
    11591191         * issuing the message. IE4 depends on this.
     
    11891221
    11901222    default:
    1191         /* 
     1223        /*
    11921224         * We have to change the handle since we are the control
    11931225         * issuing the message. IE4 depends on this.
     
    12101242    INT i;
    12111243
    1212     TRACE("CtlType=%08x, CtlID=%08x, itemID=%08x, hwnd=%x, data=%08lx\n",
     1244    TRACE("CtlType=%08x, CtlID=%08x, itemID=%08x, hwnd=%p, data=%08lx\n",
    12131245          dis->CtlType, dis->CtlID, dis->itemID, dis->hwndItem, dis->itemData);
    12141246
     
    12641296    if (!IsWindowEnabled(infoPtr->hwndCombo)) return 0;
    12651297
    1266     TRACE("DRAWITEMSTRUCT: CtlType=0x%08x CtlID=0x%08x\n", 
     1298    TRACE("DRAWITEMSTRUCT: CtlType=0x%08x CtlID=0x%08x\n",
    12671299          dis->CtlType, dis->CtlID);
    1268     TRACE("itemID=0x%08x itemAction=0x%08x itemState=0x%08x\n", 
     1300    TRACE("itemID=0x%08x itemAction=0x%08x itemState=0x%08x\n",
    12691301          dis->itemID, dis->itemAction, dis->itemState);
    1270     TRACE("hWnd=0x%04x hDC=0x%04x (%d,%d)-(%d,%d) itemData=0x%08lx\n",
    1271           dis->hwndItem, dis->hDC, dis->rcItem.left, 
    1272           dis->rcItem.top, dis->rcItem.right, dis->rcItem.bottom, 
     1302    TRACE("hWnd=%p hDC=%p (%d,%d)-(%d,%d) itemData=0x%08lx\n",
     1303          dis->hwndItem, dis->hDC, dis->rcItem.left,
     1304          dis->rcItem.top, dis->rcItem.right, dis->rcItem.bottom,
    12731305          dis->itemData);
    12741306
     
    12861318    if (dis->itemID == 0xffffffff) {
    12871319        if ( ( (dis->itemAction & ODA_FOCUS) && (dis->itemState & ODS_SELECTED)) ||
    1288              ( (dis->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)) && (dis->itemState & ODS_FOCUS) ) ) { 
     1320             ( (dis->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)) && (dis->itemState & ODS_FOCUS) ) ) {
    12891321
    12901322            TRACE("drawing item -1 special focus, rect=(%d,%d)-(%d,%d)\n",
     
    12921324                  dis->rcItem.right, dis->rcItem.bottom);
    12931325        }
    1294         else if ((dis->CtlType == ODT_COMBOBOX) && 
     1326        else if ((dis->CtlType == ODT_COMBOBOX) &&
    12951327                 (dis->itemAction == ODA_DRAWENTIRE)) {
    12961328            /* draw of edit control data */
     
    13341366                if (item->pszText)
    13351367                    GetWindowTextW(infoPtr->hwndEdit, item->pszText, len+1);
    1336            
    1337                TRACE("edit control hwndEdit=%0x, text len=%d str=%s\n",
     1368
     1369               TRACE("edit control hwndEdit=%p, text len=%d str=%s\n",
    13381370                     infoPtr->hwndEdit, len, debugstr_txt(item->pszText));
    13391371            }
     
    13821414        /* drawing combo/edit entry */
    13831415        if (IsWindowVisible(infoPtr->hwndEdit)) {
    1384             /* if we have an edit control, the slave the 
    1385              * selection state to the Edit focus state 
     1416            /* if we have an edit control, the slave the
     1417             * selection state to the Edit focus state
    13861418             */
    13871419            if (infoPtr->flags & WCBE_EDITFOCUSED) {
     
    13911423            }
    13921424        } else {
    1393             /* if we don't have an edit control, use 
     1425            /* if we don't have an edit control, use
    13941426             * the requested state.
    13951427             */
     
    14151447    len = strlenW (str);
    14161448    GetTextExtentPoint32W (dis->hDC, str, len, &txtsize);
    1417    
     1449
    14181450    if (dis->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)) {
    14191451        int overlay = item->iOverlay;
    1420        
     1452
    14211453        if (drawimage == I_IMAGECALLBACK) {
    14221454            NMCOMBOBOXEXW nmce;
     
    14421474            overlay = nmce.ceItem.iOverlay;
    14431475        }
    1444    
    1445         if (drawimage >= 0 && 
     1476
     1477        if (drawimage >= 0 &&
    14461478            !(infoPtr->dwExtStyle & (CBES_EX_NOEDITIMAGE | CBES_EX_NOEDITIMAGEINDENT))) {
    14471479            if (overlay > 0) ImageList_SetOverlayImage (infoPtr->himl, overlay, 1);
    1448             ImageList_Draw (infoPtr->himl, drawimage, dis->hDC, xbase, dis->rcItem.top, 
     1480            ImageList_Draw (infoPtr->himl, drawimage, dis->hDC, xbase, dis->rcItem.top,
    14491481                            drawstate | (overlay > 0 ? INDEXTOOVERLAYMASK(1) : 0));
    14501482        }
     
    14731505        }
    14741506    }
    1475    
     1507
    14761508    if (dis->itemAction & ODA_FOCUS) {
    14771509        rect.left = xbase + xioff - 1;
     
    15091541    }
    15101542
    1511     if (infoPtr->defaultFont) 
     1543    if (infoPtr->defaultFont)
    15121544        DeleteObject (infoPtr->defaultFont);
    15131545
     
    15291561    mis->itemHeight = mysize.cy + CBE_EXTRA;
    15301562
    1531     TRACE("adjusted height hwnd=%08x, height=%d\n",
     1563    TRACE("adjusted height hwnd=%p, height=%d\n",
    15321564          infoPtr->hwndSelf, mis->itemHeight);
    15331565
     
    15561588    if (lParam == NF_REQUERY) {
    15571589        INT i = SendMessageW(GetParent (infoPtr->hwndSelf),
    1558                          WM_NOTIFYFORMAT, infoPtr->hwndSelf, NF_QUERY);
     1590                         WM_NOTIFYFORMAT, (WPARAM)infoPtr->hwndSelf, NF_QUERY);
    15591591        infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
    15601592    }
     
    15651597static LRESULT COMBOEX_Size (COMBOEX_INFO *infoPtr, INT width, INT height)
    15661598{
    1567     TRACE("(width=%d, height=%d)\n", width, height); 
     1599    TRACE("(width=%d, height=%d)\n", width, height);
    15681600
    15691601    MoveWindow (infoPtr->hwndCombo, 0, 0, width, height, TRUE);
     
    15861618    /* width is winpos value + border width of comboex */
    15871619    width = wp->cx
    1588             + (cbx_wrect.right-cbx_wrect.left) 
    1589             - (cbx_crect.right-cbx_crect.left); 
     1620            + (cbx_wrect.right-cbx_wrect.left)
     1621            - (cbx_crect.right-cbx_crect.left);
    15901622
    15911623    TRACE("winpos=(%d,%d %dx%d) flags=0x%08x\n",
     
    16181650}
    16191651
     1652static inline int is_delimiter(WCHAR c)
     1653{
     1654    switch(c) {
     1655        case '/':
     1656        case '\\':
     1657        case '.':
     1658            return TRUE;
     1659    }
     1660    return FALSE;
     1661}
     1662
     1663static int CALLBACK
     1664COMBOEX_PathWordBreakProc(LPWSTR lpch, int ichCurrent, int cch, int code)
     1665{
     1666    if (code == WB_ISDELIMITER) {
     1667        return is_delimiter(lpch[ichCurrent]);
     1668    } else {
     1669        int dir = (code == WB_LEFT) ? -1 : 1;
     1670        for(; 0 <= ichCurrent && ichCurrent < cch; ichCurrent += dir)
     1671            if (is_delimiter(lpch[ichCurrent])) return ichCurrent;
     1672    }
     1673    return ichCurrent;
     1674}
    16201675
    16211676static LRESULT WINAPI
     
    16311686    LRESULT lret;
    16321687
    1633     TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx, info_ptr=%p\n",
     1688    TRACE("hwnd=%p msg=%x wparam=%x lParam=%lx, info_ptr=%p\n",
    16341689          hwnd, uMsg, wParam, lParam, infoPtr);
    16351690
     
    16431698            if (wParam == VK_RETURN) return 0;
    16441699            /* all other characters pass into the real Edit */
    1645             return CallWindowProcW (infoPtr->prevEditWndProc, 
     1700            return CallWindowProcW (infoPtr->prevEditWndProc,
    16461701                                   hwnd, uMsg, wParam, lParam);
    16471702
    16481703        case WM_ERASEBKGND:
    16491704            /*
    1650              * The following was determined by traces of the native 
     1705             * The following was determined by traces of the native
    16511706             */
    16521707            hDC = (HDC) wParam;
     
    16571712            ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0);
    16581713            SetBkColor (hDC, obkc);
    1659             return CallWindowProcW (infoPtr->prevEditWndProc, 
     1714            return CallWindowProcW (infoPtr->prevEditWndProc,
    16601715                                   hwnd, uMsg, wParam, lParam);
    16611716
     
    16721727                 *   CB_GETCURSEL to Combo rets -1              x
    16731728                 *   WM_NOTIFY to COMBOEX parent (rebar)        x
    1674                  *     (CBEN_ENDEDIT{A|W} 
     1729                 *     (CBEN_ENDEDIT{A|W}
    16751730                 *      fChanged = FALSE                        x
    16761731                 *      inewSelection = -1                      x
     
    17011756                    break;
    17021757                }
    1703                 infoPtr->selected = oldItem;             
     1758                infoPtr->selected = oldItem;
    17041759                COMBOEX_SetEditText (infoPtr, item);
    1705                 RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE | 
     1760                RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE |
    17061761                              RDW_INVALIDATE);
    17071762                break;
     
    17131768                 *   CB_GETCURSEL to Combo  rets -1             x
    17141769                 *   CB_GETCOUNT to Combo  rets 0
    1715                  *   if >0 loop 
     1770                 *   if >0 loop
    17161771                 *       CB_GETITEMDATA to match
    1717                  * *** above 3 lines simulated by FindItem      x 
     1772                 * *** above 3 lines simulated by FindItem      x
    17181773                 *   WM_NOTIFY to COMBOEX parent (rebar)        x
    17191774                 *     (CBEN_ENDEDIT{A|W}                       x
     
    17381793
    17391794                if (selected != -1) {
     1795                    cmp_func_t cmptext = get_cmp_func(infoPtr);
    17401796                    item = COMBOEX_FindItem (infoPtr, selected);
    17411797                    TRACE("handling VK_RETURN, selected = %d, selected_text=%s\n",
     
    17431799                    TRACE("handling VK_RETURN, edittext=%s\n",
    17441800                          debugstr_w(edit_text));
    1745                     if (lstrcmpiW (COMBOEX_GetText(infoPtr, item), edit_text)) {
     1801                    if (cmptext (COMBOEX_GetText(infoPtr, item), edit_text)) {
    17461802                        /* strings not equal -- indicate edit has changed */
    17471803                        selected = -1;
     
    17501806
    17511807                cbeend.iNewSelection = selected;
    1752                 cbeend.fChanged = TRUE; 
     1808                cbeend.fChanged = TRUE;
    17531809                cbeend.iWhy = CBENF_RETURN;
    17541810                if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) {
     
    17561812                    TRACE("Notify requested abort of change\n");
    17571813                    COMBOEX_SetEditText (infoPtr, infoPtr->edit);
    1758                     RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE | 
     1814                    RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE |
    17591815                                  RDW_INVALIDATE);
    17601816                    return 0;
     
    17631819                if (oldItem != -1) {
    17641820                    /* if something is selected, then deselect it */
    1765                     SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL, 
     1821                    SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL,
    17661822                                  (WPARAM)-1, 0);
    17671823                }
     
    17871843        case WM_SETFOCUS:
    17881844            /* remember the focus to set state of icon */
    1789             lret = CallWindowProcW (infoPtr->prevEditWndProc, 
     1845            lret = CallWindowProcW (infoPtr->prevEditWndProc,
    17901846                                   hwnd, uMsg, wParam, lParam);
    17911847            infoPtr->flags |= WCBE_EDITFOCUSED;
     
    17931849
    17941850        case WM_KILLFOCUS:
    1795             /* 
     1851            /*
    17961852             * do NOTIFY CBEN_ENDEDIT with CBENF_KILLFOCUS
    17971853             */
     
    18111867
    18121868        default:
    1813             return CallWindowProcW (infoPtr->prevEditWndProc, 
     1869            return CallWindowProcW (infoPtr->prevEditWndProc,
    18141870                                   hwnd, uMsg, wParam, lParam);
    18151871    }
     
    18291885    HWND focusedhwnd;
    18301886    RECT rect;
     1887    POINT pt;
    18311888    WCHAR edit_text[260];
    18321889
    1833     TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx, info_ptr=%p\n",
     1890    TRACE("hwnd=%p msg=%x wparam=%x lParam=%lx, info_ptr=%p\n",
    18341891          hwnd, uMsg, wParam, lParam, infoPtr);
    18351892
     
    18381895    switch (uMsg)
    18391896    {
    1840 
    1841     case CB_FINDSTRINGEXACT:
    1842             return COMBOEX_FindStringExact (infoPtr, (INT)wParam, (LPCSTR)lParam);
    18431897
    18441898    case WM_DRAWITEM:
     
    18491903             */
    18501904            ((DRAWITEMSTRUCT *)lParam)->itemState |= ODS_COMBOEXLBOX;
    1851             return CallWindowProcW (infoPtr->prevComboWndProc, 
     1905            return CallWindowProcW (infoPtr->prevComboWndProc,
    18521906                                   hwnd, uMsg, wParam, lParam);
    18531907
    18541908    case WM_ERASEBKGND:
    18551909            /*
    1856              * The following was determined by traces of the native 
     1910             * The following was determined by traces of the native
    18571911             */
    18581912            hDC = (HDC) wParam;
     
    18631917            ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0);
    18641918            SetBkColor (hDC, obkc);
    1865             return CallWindowProcW (infoPtr->prevComboWndProc, 
     1919            return CallWindowProcW (infoPtr->prevComboWndProc,
    18661920                                   hwnd, uMsg, wParam, lParam);
    18671921
     
    18781932            nmmse.dwHitInfo = lParam;
    18791933            COMBOEX_Notify (infoPtr, NM_SETCURSOR, (NMHDR *)&nmmse);
    1880             return CallWindowProcW (infoPtr->prevComboWndProc, 
     1934            return CallWindowProcW (infoPtr->prevComboWndProc,
    18811935                                   hwnd, uMsg, wParam, lParam);
     1936
     1937    case WM_LBUTTONDOWN:
     1938            GetClientRect (hwnd, &rect);
     1939            rect.bottom = rect.top + SendMessageW(infoPtr->hwndSelf,
     1940                                                  CB_GETITEMHEIGHT, -1, 0);
     1941            rect.left = rect.right - GetSystemMetrics(SM_CXVSCROLL);
     1942            POINTSTOPOINT(pt, MAKEPOINTS(lParam));
     1943            if (PtInRect(&rect, pt))
     1944                return CallWindowProcW (infoPtr->prevComboWndProc,
     1945                                        hwnd, uMsg, wParam, lParam);
     1946            infoPtr->flags |= WCBE_MOUSECAPTURED;
     1947            SetCapture(hwnd);
     1948            break;
     1949
     1950    case WM_LBUTTONUP:
     1951            if (!(infoPtr->flags & WCBE_MOUSECAPTURED))
     1952                return CallWindowProcW (infoPtr->prevComboWndProc,
     1953                                        hwnd, uMsg, wParam, lParam);
     1954            ReleaseCapture();
     1955            infoPtr->flags &= ~WCBE_MOUSECAPTURED;
     1956            if (infoPtr->flags & WCBE_MOUSEDRAGGED) {
     1957                infoPtr->flags &= ~WCBE_MOUSEDRAGGED;
     1958            } else {
     1959                SendMessageW(hwnd, CB_SHOWDROPDOWN, TRUE, 0);
     1960            }
     1961            break;
     1962
     1963    case WM_MOUSEMOVE:
     1964            if ( (infoPtr->flags & WCBE_MOUSECAPTURED) &&
     1965                !(infoPtr->flags & WCBE_MOUSEDRAGGED)) {
     1966                GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
     1967                COMBOEX_NotifyDragBegin(infoPtr, edit_text);
     1968                infoPtr->flags |= WCBE_MOUSEDRAGGED;
     1969            }
     1970            return CallWindowProcW (infoPtr->prevComboWndProc,
     1971                                    hwnd, uMsg, wParam, lParam);
    18821972
    18831973    case WM_COMMAND:
     
    19182008                if (focusedhwnd)
    19192009                    SendMessageW (infoPtr->hwndCombo, WM_KILLFOCUS,
    1920                                   (WPARAM)focusedhwnd, 0); 
     2010                                  (WPARAM)focusedhwnd, 0);
    19212011                return 0;
    19222012
    19232013            case EN_SETFOCUS: {
    1924                 /* 
     2014                /*
    19252015                 * For EN_SETFOCUS this issues the same calls and messages
    19262016                 *  as the native seems to do.
     
    19482038
    19492039            case EN_CHANGE: {
    1950                 /* 
     2040                /*
    19512041                 * For EN_CHANGE this issues the same calls and messages
    19522042                 *  as the native seems to do.
     
    19542044                WCHAR edit_text[260];
    19552045                LPCWSTR lastwrk;
    1956                 INT selected;
    1957                 CBE_ITEMDATA *item;
    1958 
    1959                 selected = SendMessageW (infoPtr->hwndCombo,
    1960                                          CB_GETCURSEL, 0, 0);
     2046                cmp_func_t cmptext = get_cmp_func(infoPtr);
     2047
     2048                INT selected = SendMessageW (infoPtr->hwndCombo,
     2049                                             CB_GETCURSEL, 0, 0);
    19612050
    19622051                /* lstrlenA( lastworkingURL ) */
     
    19672056                }
    19682057                else {
    1969                     item = COMBOEX_FindItem (infoPtr, selected);
     2058                    CBE_ITEMDATA *item = COMBOEX_FindItem (infoPtr, selected);
    19702059                    lastwrk = COMBOEX_GetText(infoPtr, item);
    19712060                }
     
    19762065                      debugstr_w(edit_text));
    19772066
    1978                 /* lstrcmpiW is between lastworkingURL and GetWindowText */
    1979                 if (lstrcmpiW (lastwrk, edit_text)) {
     2067                /* cmptext is between lastworkingURL and GetWindowText */
     2068                if (cmptext (lastwrk, edit_text)) {
    19802069                    /* strings not equal -- indicate edit has changed */
    19812070                    infoPtr->flags |= WCBE_EDITCHG;
     
    19842073                               MAKEWPARAM(GetDlgCtrlID (infoPtr->hwndSelf),
    19852074                                          CBN_EDITCHANGE),
    1986                                infoPtr->hwndSelf);
     2075                               (LPARAM)infoPtr->hwndSelf);
    19872076                return 0;
    19882077                }
     
    20242113            }/* fall through */
    20252114    default:
    2026             return CallWindowProcW (infoPtr->prevComboWndProc, 
     2115            return CallWindowProcW (infoPtr->prevComboWndProc,
    20272116                                   hwnd, uMsg, wParam, lParam);
    20282117    }
     
    20362125    COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    20372126
    2038     TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx\n", hwnd, uMsg, wParam, lParam);
     2127    TRACE("hwnd=%p msg=%x wparam=%x lParam=%lx\n", hwnd, uMsg, wParam, lParam);
    20392128
    20402129    if (!infoPtr) {
     
    20522141
    20532142        case CBEM_GETCOMBOCONTROL:
    2054             return infoPtr->hwndCombo;
     2143            return (LRESULT)infoPtr->hwndCombo;
    20552144
    20562145        case CBEM_GETEDITCONTROL:
    2057             return infoPtr->hwndEdit;
     2146            return (LRESULT)infoPtr->hwndEdit;
    20582147
    20592148        case CBEM_GETEXTENDEDSTYLE:
     
    20992188        /*case CBEM_SETWINDOWTHEME:
    21002189            FIXME("CBEM_SETWINDOWTHEME: stub\n");*/
     2190
     2191        case WM_SETTEXT:
     2192        case WM_GETTEXT:
     2193            return SendMessageW(infoPtr->hwndEdit, uMsg, wParam, lParam);
    21012194
    21022195/*   Combo messages we are not sure if we need to process or just forward */
     
    21092202        case CB_RESETCONTENT:
    21102203        case CB_SELECTSTRING:
    2111         case WM_SETTEXT:
    2112         case WM_GETTEXT:
    2113             FIXME("(0x%x 0x%x 0x%lx): possibly missing function\n",
    2114                   uMsg, wParam, lParam);
    21152204
    21162205/*   Combo messages OK to just forward to the regular COMBO */
    2117         case CB_GETCOUNT:       
     2206        case CB_GETCOUNT:
    21182207        case CB_GETCURSEL:
    21192208        case CB_GETDROPPEDSTATE:
     
    21252214/*   Combo messages we need to process specially */
    21262215        case CB_FINDSTRINGEXACT:
    2127             return COMBOEX_FindStringExact (infoPtr, (INT)wParam, (LPCSTR)lParam);
     2216            return COMBOEX_FindStringExact (infoPtr, (INT)wParam, (LPCWSTR)lParam);
    21282217
    21292218        case CB_GETITEMDATA:
     
    21752264
    21762265        default:
    2177             if (uMsg >= WM_USER)
     2266            if ((uMsg >= WM_USER) && (uMsg < WM_APP))
    21782267                ERR("unknown msg %04x wp=%08x lp=%08lx\n",uMsg,wParam,lParam);
    21792268            return DefWindowProcW (hwnd, uMsg, wParam, lParam);
     
    21952284    wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
    21962285    wndClass.lpszClassName = WC_COMBOBOXEXW;
    2197  
     2286
    21982287    RegisterClassW (&wndClass);
    21992288}
     
    22042293    UnregisterClassW (WC_COMBOBOXEXW, (HINSTANCE)NULL);
    22052294}
    2206 
  • trunk/src/comctl32/comctl32.def

    r8382 r9370  
    1 ; $Id: comctl32.def,v 1.26 2002-05-08 11:24:59 sandervl Exp $
     1; $Id: comctl32.def,v 1.27 2002-10-29 12:18:25 sandervl Exp $
    22LIBRARY COMCTL32 INITINSTANCE
    33DESCRIPTION 'Odin32 System DLL - ComCtl32 - Common Controls Library'
     
    193193                        _COMCTL32_415@20           @415 NONAME
    194194
     195                        _COMCTL32_417@32           @417 NONAME
    195196                        _COMCTL32_419@16           @419 NONAME
    196197
     198
     199; These are only available in comctrl 6
     200  DefSubclassProc      = _DefSubclassProc@16        @500
     201  GetWindowSubclass    = _GetWindowSubclass@16      @501
     202  RemoveWindowSubclass = _RemoveWindowSubclass@12   @502
     203  SetWindowSubclass    = _SetWindowSubclass@16      @503
  • trunk/src/comctl32/comctl32.h

    r8524 r9370  
    11/******************************************************************************
    2  * 
     2 *
    33 * Common definitions (resource ids and global variables)
    44 *
    55 * Copyright 1999 Thuy Nguyen
    66 * Copyright 1999 Eric Kohl
     7 * Copyright 2002 Dimitrie O. Paun
    78 *
    89 * This library is free software; you can redistribute it and/or
     
    2425#define __WINE_COMCTL32_H
    2526
    26 #ifdef __WIN32OS2__
    27 #include <heapstring.h>
    28 #endif
     27#include "commctrl.h"
    2928
    3029extern HMODULE COMCTL32_hModule;
     
    8584#define IDM_GOTODAY                    4164
    8685
    87 /* Treeview Checboxes */
     86/* Treeview Checkboxes */
    8887
    8988#define IDT_CHECK        401
     
    9493#define IDC_DIVIDEROPEN                 107
    9594
    96 #ifdef __WIN32OS2__
    97 /* Header filter bitmap */
    98 #define IDB_HEADER_FILTER   140
    99 
    100 #define IDC_COMCTL32_DRAGHLINE     106
    101 #define IDC_COMCTL32_SPLITHLINE    107
    102 
    103 #endif
    10495
    10596/* DragList icon */
    10697#define IDI_DRAGARROW                   150
    10798
    108 typedef struct
     99
     100/* HOTKEY internal strings */
     101#define HKY_NONE                        2048
     102
     103typedef struct
    109104{
    110105    COLORREF clrBtnHighlight;       /* COLOR_BTNHIGHLIGHT                  */
     
    134129BOOL Str_SetPtrAtoW (LPWSTR *lppDest, LPCSTR lpSrc);
    135130
    136 #define COMCTL32_VERSION_MINOR 0 
     131#define COMCTL32_VERSION_MINOR 0
    137132#define WINE_FILEVERSION 5, COMCTL32_VERSION_MINOR, 0, 0
    138133#define WINE_FILEVERSIONSTR "5.00"
    139134
     135/* Notification support */
     136
     137#ifndef RC_INVOKED
     138
    140139#ifdef __WIN32OS2__
     140#include <heapstring.h>
     141
     142#ifndef __cplusplus
     143#undef inline
     144#define inline
     145#endif
     146#endif
     147
     148inline static LRESULT send_notify(HWND hwnd, UINT code, NMHDR *hdr)
     149{
     150    hdr->hwndFrom = hwnd;
     151    hdr->idFrom = GetWindowLongW (hwnd, GWL_ID);
     152    hdr->code = code;
     153
     154    return SendMessageW (GetParent(hwnd), WM_NOTIFY, hdr->idFrom, (LPARAM)hdr);
     155}
     156
     157
     158inline static LRESULT hwnd_notify(HWND hwnd, UINT code)
     159{
     160    NMHDR hdr;
     161
     162    return send_notify(hwnd, code, &hdr);
     163}
     164
     165inline static BOOL hwnd_notify_char(HWND hwnd, UINT ch, DWORD prev, DWORD next)
     166{
     167    NMCHAR nmch;
     168
     169    nmch.ch = ch;
     170    nmch.dwItemPrev = prev;
     171    nmch.dwItemNext = next;
     172    return (BOOL)send_notify(hwnd, NM_CHAR, &nmch.hdr);
     173}
     174
     175inline static BOOL hwnd_notify_keydown(HWND hwnd, UINT nVKey, UINT uFlags)
     176{
     177    NMKEY nmk;
     178
     179    nmk.nVKey = nVKey;
     180    nmk.uFlags = uFlags;
     181    return (BOOL)send_notify(hwnd, NM_KEYDOWN, &nmk.hdr);
     182}
     183
     184inline static DWORD hwnd_notify_mouse(HWND hwnd, UINT code, DWORD spec, DWORD data, POINT *pt, LPARAM dwHitInfo)
     185{
     186    NMMOUSE nmm;
     187
     188    nmm.dwItemSpec = spec;
     189    nmm.dwItemData = data;
     190    nmm.pt.x = pt->x;
     191    nmm.pt.y = pt->y;
     192    nmm.dwHitInfo = dwHitInfo;
     193    return send_notify(hwnd, code, &nmm.hdr);
     194}
     195
     196#define DEFINE_CHAR_NOTIFICATION(CTRLINFO, hwndSelf) \
     197    inline static BOOL notify_char(CTRLINFO *infoPtr, UINT ch, DWORD prev, DWORD next) \
     198        { return hwnd_notify_char(infoPtr->hwndSelf, ch, prev, next); }
     199
     200#define DEFINE_CLICK_NOTIFICATION(CTRLINFO, hwndSelf) \
     201    inline static void notify_click(CTRLINFO *infoPtr) \
     202        { hwnd_notify(infoPtr->hwndSelf, NM_CLICK); }
     203
     204#define DEFINE_DBLCLK_NOTIFICATION(CTRLINFO, hwndSelf) \
     205    inline static void notify_dblclk(CTRLINFO *infoPtr) \
     206        { hwnd_notify(infoPtr->hwndSelf, NM_DBLCLK); }
     207
     208#define DEFINE_HOVER_NOTIFICATION(CTRLINFO, hwndSelf) \
     209    inline static BOOL notify_hover(CTRLINFO *infoPtr) \
     210        { return hwnd_notify(infoPtr->hwndSelf, NM_HOVER); }
     211
     212#define DEFINE_KEYDOWN_NOTIFICATION(CTRLINFO, hwndSelf) \
     213    inline static BOOL notify_keydown(CTRLINFO *infoPtr, UINT nVKey, UINT uFlags) \
     214        { return hwnd_notify_keydown(infoPtr->hwndSelf, nVKey, uFlags); }
     215
     216#define DEFINE_KILLFOCUS_NOTIFICATION(CTRLINFO, hwndSelf) \
     217    inline static void notify_killfocus(CTRLINFO *infoPtr) \
     218        { hwnd_notify(infoPtr->hwndSelf, NM_KILLFOCUS); }
     219
     220#define DEFINE_NCHITTEST_NOTIFICATION(CTRLINFO, hwndSelf) \
     221    inline static DWORD notify_nchittest(CTRLINFO *infoPtr, DWORD spec, DWORD data, POINT *pt, LPARAM dwHitInfo) \
     222        { return hwnd_notify_mouse(infoPtr->hwndSelf, NM_NCHITTEST, spec, data, pt, dwHitInfo); }
     223
     224#define DEFINE_OUTOFMEMORY_NOTIFICATION(CTRLINFO, hwndSelf) \
     225    inline static void notify_outofmemory(CTRLINFO *infoPtr) \
     226        { hwnd_notify(infoPtr->hwndSelf, NM_OUTOFMEMORY); }
     227
     228#define DEFINE_RCLICK_NOTIFICATION(CTRLINFO, hwndSelf) \
     229    inline static BOOL notify_rclick(CTRLINFO *infoPtr) \
     230        { return hwnd_notify(infoPtr->hwndSelf, NM_RCLICK); }
     231
     232#define DEFINE_RDBLCLK_NOTIFICATION(CTRLINFO, hwndSelf) \
     233    inline static void notify_rdblclk(CTRLINFO *infoPtr) \
     234        { hwnd_notify(infoPtr->hwndSelf, NM_RDBLCLK); }
     235
     236#define DEFINE_RELEASEDCAPTURE_NOTIFICATION(CTRLINFO, hwndSelf) \
     237    inline static void notify_releasedcapture(CTRLINFO *infoPtr) \
     238        { hwnd_notify(infoPtr->hwndSelf, NM_RELEASEDCAPTURE); }
     239
     240#define DEFINE_RETURN_NOTIFICATION(CTRLINFO, hwndSelf) \
     241    inline static void notify_return(CTRLINFO *infoPtr) \
     242        { hwnd_notify(infoPtr->hwndSelf, NM_RETURN); }
     243
     244#define DEFINE_SETCURSOR_NOTIFICATION(CTRLINFO, hwndSelf) \
     245    inline static BOOL notify_setcursor(CTRLINFO *infoPtr, DWORD spec, DWORD data, POINT *pt, LPARAM dwHitInfo) \
     246        { return hwnd_notify_mouse(infoPtr->hwndSelf, NM_SETCURSOR, spec, data, pt, dwHitInfo); }
     247
     248#define DEFINE_SETFOCUS_NOTIFICATION(CTRLINFO, hwndSelf) \
     249    inline static void notify_setfocus(CTRLINFO *infoPtr) \
     250        { hwnd_notify(infoPtr->hwndSelf, NM_SETFOCUS); }
     251
     252#define DEFINE_TOOLTIPSCREATED_NOTIFICATION(CTRLINFO, hwndSelf) \
     253    inline static void notify_tooltipscreated(CTRLINFO *infoPtr) \
     254        { hwnd_notify(infoPtr->hwndSelf, NM_TOOLTIPSCREATED); }
     255
     256#define DEFINE_COMMON_NOTIFICATIONS(CTRLINFO, hwndSelf) \
     257    DEFINE_CHAR_NOTIFICATION(CTRLINFO, hwndSelf) \
     258    DEFINE_CLICK_NOTIFICATION(CTRLINFO, hwndSelf) \
     259    DEFINE_DBLCLK_NOTIFICATION(CTRLINFO, hwndSelf) \
     260    DEFINE_HOVER_NOTIFICATION(CTRLINFO, hwndSelf) \
     261    DEFINE_KEYDOWN_NOTIFICATION(CTRLINFO, hwndSelf) \
     262    DEFINE_KILLFOCUS_NOTIFICATION(CTRLINFO, hwndSelf) \
     263    DEFINE_NCHITTEST_NOTIFICATION(CTRLINFO, hwndSelf) \
     264    DEFINE_OUTOFMEMORY_NOTIFICATION(CTRLINFO, hwndSelf) \
     265    DEFINE_RCLICK_NOTIFICATION(CTRLINFO, hwndSelf) \
     266    DEFINE_RDBLCLK_NOTIFICATION(CTRLINFO, hwndSelf) \
     267    DEFINE_RELEASEDCAPTURE_NOTIFICATION(CTRLINFO, hwndSelf) \
     268    DEFINE_RETURN_NOTIFICATION(CTRLINFO, hwndSelf) \
     269    DEFINE_SETCURSOR_NOTIFICATION(CTRLINFO, hwndSelf) \
     270    DEFINE_SETFOCUS_NOTIFICATION(CTRLINFO, hwndSelf) \
     271    DEFINE_TOOLTIPSCREATED_NOTIFICATION(CTRLINFO, hwndSelf) \
     272    struct __forward_dummy_struc_dec_to_catch_missing_semicolon
     273
     274#endif //#ifndef RC_INVOKED
     275
     276/* Our internal stack structure of the window procedures to subclass */
     277typedef struct
     278{
     279   struct {
     280      SUBCLASSPROC subproc;
     281      UINT_PTR id;
     282      DWORD_PTR ref;
     283   } SubclassProcs[31];
     284   int stackpos;
     285   int stacknum;
     286   int stacknew;
     287   WNDPROC origproc;
     288} SUBCLASS_INFO, *LPSUBCLASS_INFO;
     289
     290#ifdef __WIN32OS2__
     291
     292/* Header filter bitmap */
     293#define IDB_HEADER_FILTER   140
     294
     295#define IDC_COMCTL32_DRAGHLINE     106
     296#define IDC_COMCTL32_SPLITHLINE    107
     297
    141298#define swprintf   wsprintfW
     299
    142300#ifdef __cplusplus
    143301extern "C" {
     
    189347}
    190348#endif
     349
    191350#endif
    192351
  • trunk/src/comctl32/comctl32dbg.def

    r8382 r9370  
    1 ; $Id: comctl32dbg.def,v 1.2 2002-05-08 11:24:59 sandervl Exp $
     1; $Id: comctl32dbg.def,v 1.3 2002-10-29 12:18:25 sandervl Exp $
    22LIBRARY COMCTL32 INITINSTANCE
    33DESCRIPTION 'Odin32 System DLL - ComCtl32 - Common Controls Library'
     
    190190                        _COMCTL32_415@20           @415 NONAME
    191191
     192                        _COMCTL32_417@32           @417 NONAME
    192193                        _COMCTL32_419@16           @419 NONAME
    193194
     195; These are only available in comctrl 6
     196  DefSubclassProc      = _DefSubclassProc@16        @500
     197  GetWindowSubclass    = _GetWindowSubclass@16      @501
     198  RemoveWindowSubclass = _RemoveWindowSubclass@12   @502
     199  SetWindowSubclass    = _SetWindowSubclass@16      @503
  • trunk/src/comctl32/comctl32undoc.c

    r8382 r9370  
    7474typedef HRESULT (CALLBACK *DPALOADPROC)(LPLOADDATA,IStream*,LPARAM);
    7575#endif
    76 
    77 INT __cdecl _wtoi(LPWSTR string);
    7876
    7977/**************************************************************************
     
    283281        }
    284282        nResult = (pfnCompare)(*pWork1, *pWork2, lParam);
    285         TRACE("compare result=%d, dpa1.cnt=%d, dpa2.cnt=%d\n", 
     283        TRACE("compare result=%d, dpa1.cnt=%d, dpa2.cnt=%d\n",
    286284              nResult, nIndex, nCount);
    287285
     
    532530
    533531    /* open the sub key */
    534     if ((err = RegOpenKeyExW( mp->extview.hKey, mp->extview.lpszSubKey, 
     532    if ((err = RegOpenKeyExW( mp->extview.hKey, mp->extview.lpszSubKey,
    535533                              0, KEY_WRITE, &newkey))) {
    536534        /* not present - what to do ??? */
     
    552550    if (mp->wineFlags & WMRUF_CHANGED) {
    553551        mp->wineFlags &= ~WMRUF_CHANGED;
    554         err = RegSetValueExA(newkey, "MRUList", 0, REG_SZ, 
     552        err = RegSetValueExA(newkey, "MRUList", 0, REG_SZ,
    555553                             mp->realMRU, strlen(mp->realMRU) + 1);
    556554        if (err) {
     
    565563            witem->itemFlag &= ~WMRUIF_CHANGED;
    566564            realname[0] = 'a' + i;
    567             err = RegSetValueExW(newkey, realname, 0, 
    568                                  (mp->extview.dwFlags & MRUF_BINARY_LIST) ? 
     565            err = RegSetValueExW(newkey, realname, 0,
     566                                 (mp->extview.dwFlags & MRUF_BINARY_LIST) ?
    569567                                 REG_BINARY : REG_SZ,
    570568                                 &witem->datastart, witem->size);
     
    611609/**************************************************************************
    612610 *                  FindMRUData [COMCTL32.169]
    613  * 
     611 *
    614612 * Searches binary list for item that matches lpData of length cbData.
    615613 * Returns position in list order 0 -> MRU and if lpRegNum != NULL then value
     
    646644    for(i=0; i<mp->cursize; i++) {
    647645        if (mp->extview.dwFlags & MRUF_BINARY_LIST) {
    648             if (!mp->extview.lpfnCompare(lpData, &mp->array[i]->datastart, 
     646            if (!mp->extview.lpfnCompare(lpData, &mp->array[i]->datastart,
    649647                                         cbData))
    650648                break;
     
    679677        *lpRegNum = 'a' + i;
    680678
    681     TRACE("(%08x, %p, %ld, %p) returning %d\n",
     679    TRACE("(%p, %p, %ld, %p) returning %d\n",
    682680           hList, lpData, cbData, lpRegNum, ret);
    683681
     
    688686/**************************************************************************
    689687 *              AddMRUData [COMCTL32.167]
    690  * 
     688 *
    691689 * Add item to MRU binary list.  If item already exists in list then it is
    692690 * simply moved up to the top of the list and not added again.  If list is
     
    728726
    729727    /* Allocate space for new item and move in the data */
    730     mp->array[replace] = witem = (LPWINEMRUITEM)COMCTL32_Alloc(cbData + 
     728    mp->array[replace] = witem = (LPWINEMRUITEM)COMCTL32_Alloc(cbData +
    731729                                                               sizeof(WINEMRUITEM));
    732730    witem->itemFlag |= WMRUIF_CHANGED;
     
    740738    }
    741739    mp->realMRU[0] = replace + 'a';
    742     TRACE("(%08x, %p, %ld) adding data, /%c/ now most current\n",
     740    TRACE("(%p, %p, %ld) adding data, /%c/ now most current\n",
    743741          hList, lpData, cbData, replace+'a');
    744742    ret = replace;
     
    754752/**************************************************************************
    755753 *              AddMRUStringW [COMCTL32.401]
    756  * 
     754 *
    757755 * Add item to MRU string list.  If item already exists in list them it is
    758756 * simply moved up to the top of the list and not added again.  If list is
     
    770768AddMRUStringW(HANDLE hList, LPCWSTR lpszString)
    771769{
    772     FIXME("(%08x, %s) empty stub!\n", hList, debugstr_w(lpszString));
     770    FIXME("(%p, %s) empty stub!\n", hList, debugstr_w(lpszString));
    773771
    774772    return 0;
     
    781779AddMRUStringA(HANDLE hList, LPCSTR lpszString)
    782780{
    783     FIXME("(%08x, %s) empty stub!\n", hList, debugstr_a(lpszString));
     781    FIXME("(%p, %s) empty stub!\n", hList, debugstr_a(lpszString));
    784782
    785783    return 0;
     
    801799DelMRUString(HANDLE hList, INT nItemPos)
    802800{
    803     FIXME("(%08x, %d): stub\n", hList, nItemPos);
     801    FIXME("(%p, %d): stub\n", hList, nItemPos);
    804802    return TRUE;
    805803}
     
    817815/**************************************************************************
    818816 *                  FindMRUStringA [COMCTL32.155]
    819  * 
     817 *
    820818 * Searches string list for item that matches lpszString.
    821819 * Returns position in list order 0 -> MRU and if lpRegNum != NULL then value
     
    868866
    869867    /* open the sub key */
    870     if ((err = RegCreateKeyExW( mp->extview.hKey, mp->extview.lpszSubKey, 
     868    if ((err = RegCreateKeyExW( mp->extview.hKey, mp->extview.lpszSubKey,
    871869                                0,
    872870                                emptyW,
    873                                 REG_OPTION_NON_VOLATILE, 
     871                                REG_OPTION_NON_VOLATILE,
    874872                                KEY_READ | KEY_WRITE,
    875873                                0,
     
    887885    if (newkey) {
    888886        datasize = mp->extview.nMaxItems + 1;
    889         if((err=RegQueryValueExA( newkey, "MRUList", 0, &type, mp->realMRU, 
     887        if((err=RegQueryValueExA( newkey, "MRUList", 0, &type, mp->realMRU,
    890888                                  &datasize))) {
    891889            /* not present - set size to 1 (will become 0 later) */
     
    907905                ERR("Key %s not found 1\n", debugstr_w(realname));
    908906            }
    909             mp->array[i] = witem = (LPWINEMRUITEM)COMCTL32_Alloc(datasize + 
     907            mp->array[i] = witem = (LPWINEMRUITEM)COMCTL32_Alloc(datasize +
    910908                                                                 sizeof(WINEMRUITEM));
    911909            witem->size = datasize;
    912             if(RegQueryValueExW( newkey, realname, 0, &type, 
     910            if(RegQueryValueExW( newkey, realname, 0, &type,
    913911                                 &witem->datastart, &datasize)) {
    914912                /* not present - what to do ??? */
     
    949947    mp->isUnicode = TRUE;
    950948
    951     return CreateMRUListLazy_common(mp);   
     949    return CreateMRUListLazy_common(mp);
    952950}
    953951
     
    10181016 *    of list returns -1.
    10191017 *    If lpBuffer == NULL or nItemPos is -ve return value is no. of items in
    1020  *    the list. 
     1018 *    the list.
    10211019 */
    10221020INT WINAPI EnumMRUListW(HANDLE hList, INT nItemPos, LPVOID lpBuffer,
     
    10331031    TRACE("nItemPos=%d, desired=%d\n", nItemPos, desired);
    10341032    witem = mp->array[desired];
    1035     datasize = min( witem->size, nBufferSize ); 
     1033    datasize = min( witem->size, nBufferSize );
    10361034    memcpy( lpBuffer, &witem->datastart, datasize);
    1037     TRACE("(%08x, %d, %p, %ld): returning len=%d\n",
     1035    TRACE("(%p, %d, %p, %ld): returning len=%d\n",
    10381036          hList, nItemPos, lpBuffer, nBufferSize, datasize);
    10391037    return datasize;
     
    10421040/**************************************************************************
    10431041 *                EnumMRUListA [COMCTL32.154]
    1044  * 
     1042 *
    10451043 */
    10461044INT WINAPI EnumMRUListA(HANDLE hList, INT nItemPos, LPVOID lpBuffer,
     
    10591057    witem = mp->array[desired];
    10601058    if(mp->extview.dwFlags & MRUF_BINARY_LIST) {
    1061         datasize = min( witem->size, nBufferSize ); 
     1059        datasize = min( witem->size, nBufferSize );
    10621060        memcpy( lpBuffer, &witem->datastart, datasize);
    10631061    } else {
     
    10681066                            lpBuffer, datasize, NULL, NULL);
    10691067    }
    1070     TRACE("(%08x, %d, %p, %ld): returning len=%d\n",
     1068    TRACE("(%p, %d, %p, %ld): returning len=%d\n",
    10711069          hList, nItemPos, lpBuffer, nBufferSize, datasize);
    10721070    return datasize;
    10731071}
    1074  
     1072
    10751073
    10761074/**************************************************************************
     
    11281126{
    11291127    TRACE("(%p %p)\n", lppDest, lpSrc);
    1130  
     1128
    11311129    if (lpSrc) {
    11321130        LPSTR ptr = COMCTL32_ReAlloc (*lppDest, strlen (lpSrc) + 1);
     
    12011199{
    12021200    TRACE("(%p %p)\n", lppDest, lpSrc);
    1203  
     1201
    12041202    if (lpSrc) {
    12051203        INT len = strlenW (lpSrc) + 1;
     
    13731371
    13741372/**************************************************************************
    1375  * DSA_GetItem [COMCTL32.322] 
     1373 * DSA_GetItem [COMCTL32.322]
    13761374 *
    13771375 * PARAMS
     
    13911389
    13921390    TRACE("(%p %d %p)\n", hdsa, nIndex, pDest);
    1393    
     1391
    13941392    if (!hdsa)
    13951393        return FALSE;
     
    14051403
    14061404/**************************************************************************
    1407  * DSA_GetItemPtr [COMCTL32.323] 
     1405 * DSA_GetItemPtr [COMCTL32.323]
    14081406 *
    14091407 * Retrieves a pointer to the specified item.
     
    14311429
    14321430    pSrc = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
    1433    
     1431
    14341432    TRACE("-- ret=%p\n", pSrc);
    14351433
     
    14391437
    14401438/**************************************************************************
    1441  * DSA_SetItem [COMCTL32.325] 
     1439 * DSA_SetItem [COMCTL32.325]
    14421440 *
    14431441 * Sets the contents of an item in the array.
     
    14581456    INT  nSize, nNewItems;
    14591457    LPVOID pDest, lpTemp;
    1460    
     1458
    14611459    TRACE("(%p %d %p)\n", hdsa, nIndex, pSrc);
    14621460
    14631461    if ((!hdsa) || nIndex < 0)
    14641462        return FALSE;
    1465      
     1463
    14661464    if (hdsa->nItemCount <= nIndex) {
    14671465        /* within the old array */
     
    14831481            hdsa->nItemCount = nIndex + 1;
    14841482            hdsa->pData = lpTemp;
    1485         }   
     1483        }
    14861484    }
    14871485
     
    14971495
    14981496/**************************************************************************
    1499  * DSA_InsertItem [COMCTL32.324] 
     1497 * DSA_InsertItem [COMCTL32.324]
    15001498 *
    15011499 * PARAMS
     
    15141512    INT   nNewItems, nSize;
    15151513    LPVOID  lpTemp, lpDest;
    1516    
     1514
    15171515    TRACE("(%p %d %p)\n", hdsa, nIndex, pSrc);
    15181516
     
    15341532
    15351533        hdsa->nMaxCount = nNewItems;
    1536         hdsa->pData = lpTemp;         
     1534        hdsa->pData = lpTemp;
    15371535    }
    15381536
     
    15591557
    15601558/**************************************************************************
    1561  * DSA_DeleteItem [COMCTL32.326] 
     1559 * DSA_DeleteItem [COMCTL32.326]
    15621560 *
    15631561 * PARAMS
     
    15751573    LPVOID lpDest,lpSrc;
    15761574    INT  nSize;
    1577    
     1575
    15781576    TRACE("(%p %d)\n", hdsa, nIndex);
    15791577
     
    15921590        memmove (lpDest, lpSrc, nSize);
    15931591    }
    1594    
     1592
    15951593    hdsa->nItemCount--;
    1596    
     1594
    15971595    /* free memory ? */
    15981596    if ((hdsa->nMaxCount - hdsa->nItemCount) >= hdsa->nGrow) {
     
    16291627    TRACE("(%p)\n", hdsa);
    16301628
    1631     if (!hdsa) 
     1629    if (!hdsa)
    16321630        return FALSE;
    16331631    if (hdsa->pData && (!COMCTL32_Free (hdsa->pData)))
     
    18551853    INT i;
    18561854
    1857     if (!hdpa->ptrs)
     1855    if (!hdpa || !hdpa->ptrs)
    18581856        return -1;
    18591857
     
    18851883DPA_InsertPtr (const HDPA hdpa, INT i, LPVOID p)
    18861884{
    1887     INT   nNewItems, nSize, nIndex = 0;
    1888     LPVOID  *lpTemp, *lpDest;
    1889 
    18901885    TRACE("(%p %d %p)\n", hdpa, i, p);
    18911886
    1892     if ((!hdpa) || (i < 0))
    1893         return -1;
    1894 
    1895     if (!hdpa->ptrs) {
    1896         hdpa->ptrs =
    1897             (LPVOID*)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
    1898                                 2 * hdpa->nGrow * sizeof(LPVOID));
    1899         if (!hdpa->ptrs)
    1900             return -1;
    1901         hdpa->nMaxCount = hdpa->nGrow * 2;
    1902         nIndex = 0;
    1903     }
    1904     else {
    1905         if (hdpa->nItemCount >= hdpa->nMaxCount) {
    1906             TRACE("-- resizing\n");
    1907             nNewItems = hdpa->nMaxCount + hdpa->nGrow;
    1908             nSize = nNewItems * sizeof(LPVOID);
    1909 
    1910             lpTemp = (LPVOID*)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
    1911                                            hdpa->ptrs, nSize);
    1912             if (!lpTemp)
    1913                 return -1;
    1914             hdpa->nMaxCount = nNewItems;
    1915             hdpa->ptrs = lpTemp;
    1916         }
    1917 
    1918         if (i >= hdpa->nItemCount) {
    1919             nIndex = hdpa->nItemCount;
    1920             TRACE("-- appending at %d\n", nIndex);
    1921         }
    1922         else {
    1923             TRACE("-- inserting at %d\n", i);
    1924             lpTemp = hdpa->ptrs + i;
    1925             lpDest = lpTemp + 1;
    1926             nSize  = (hdpa->nItemCount - i) * sizeof(LPVOID);
    1927             TRACE("-- move dest=%p src=%p size=%x\n",
    1928                    lpDest, lpTemp, nSize);
    1929             memmove (lpDest, lpTemp, nSize);
    1930             nIndex = i;
    1931         }
    1932     }
    1933 
    1934     /* insert item */
    1935     hdpa->nItemCount++;
    1936     hdpa->ptrs[nIndex] = p;
    1937 
    1938     return nIndex;
    1939 }
    1940 
     1887    if (!hdpa || i < 0) return -1;
     1888
     1889    if (i >= 0x7fff)
     1890        i = hdpa->nItemCount;
     1891
     1892    if (i >= hdpa->nItemCount)
     1893        return DPA_SetPtr(hdpa, i, p) ? i : -1;
     1894
     1895    /* create empty spot at the end */
     1896    if (!DPA_SetPtr(hdpa, hdpa->nItemCount, 0)) return -1;
     1897    memmove (hdpa->ptrs + i + 1, hdpa->ptrs + i, (hdpa->nItemCount - i - 1) * sizeof(LPVOID));
     1898    hdpa->ptrs[i] = p;
     1899    return i;
     1900}
    19411901
    19421902/**************************************************************************
     
    19591919{
    19601920    LPVOID *lpTemp;
    1961    
     1921
    19621922    TRACE("(%p %d %p)\n", hdpa, i, p);
    19631923
    1964     if ((!hdpa) || i < 0)
     1924    if (!hdpa || i < 0 || i > 0x7fff)
    19651925        return FALSE;
    1966      
     1926
    19671927    if (hdpa->nItemCount <= i) {
    19681928        /* within the old array */
    1969         if (hdpa->nMaxCount > i) {
    1970             /* within the allocated space, set a new boundary */
    1971             hdpa->nItemCount = i+1;
    1972         }
    1973         else {
     1929        if (hdpa->nMaxCount <= i) {
    19741930            /* resize the block of memory */
    19751931            INT nNewItems =
     
    19771933            INT nSize = nNewItems * sizeof(LPVOID);
    19781934
    1979             lpTemp = (LPVOID*)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
    1980                                            hdpa->ptrs, nSize);
     1935            if (hdpa->ptrs)
     1936                lpTemp = (LPVOID*)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY, hdpa->ptrs, nSize);
     1937            else
     1938                lpTemp = (LPVOID*)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY, nSize);
     1939           
    19811940            if (!lpTemp)
    19821941                return FALSE;
    19831942
    1984             hdpa->nItemCount = nNewItems;
    1985             hdpa->ptrs = lpTemp;       
    1986         }   
     1943            hdpa->nMaxCount = nNewItems;
     1944            hdpa->ptrs = lpTemp;
     1945        }
     1946        hdpa->nItemCount = i+1;
    19871947    }
    19881948
     
    20131973    LPVOID *lpDest, *lpSrc, lpTemp = NULL;
    20141974    INT  nSize;
    2015    
     1975
    20161976    TRACE("(%p %d)\n", hdpa, i);
    20171977
     
    20301990        memmove (lpDest, lpSrc, nSize);
    20311991    }
    2032    
     1992
    20331993    hdpa->nItemCount --;
    2034    
     1994
    20351995    /* free memory ?*/
    20361996    if ((hdpa->nMaxCount - hdpa->nItemCount) >= hdpa->nGrow) {
     
    20432003
    20442004        hdpa->nMaxCount = nNewItems;
    2045         hdpa->ptrs = (LPVOID*)lpDest;         
     2005        hdpa->ptrs = (LPVOID*)lpDest;
    20462006    }
    20472007
     
    20682028    TRACE("(%p)\n", hdpa);
    20692029
    2070     if (!hdpa) 
     2030    if (!hdpa)
    20712031        return FALSE;
    20722032
     
    21072067
    21082068    TRACE("l=%i r=%i\n", l, r);
    2109  
     2069
    21102070    if (l==r)    /* one element is always sorted */
    21112071        return;
     
    21202080
    21212081    /* join the two sides */
    2122     while( (l<=m) && (m<r) ) 
     2082    while( (l<=m) && (m<r) )
    21232083    {
    21242084        if(pfnCompare(lpPtrs[l],lpPtrs[m+1],lParam)>0)
     
    22382198
    22392199        TRACE("linear search\n");
    2240        
     2200
    22412201        nIndex = (nStart == -1)? 0 : nStart;
    22422202        lpPtr = hdpa->ptrs;
     
    22732233    HDPA hdpa;
    22742234
    2275     TRACE("(%d 0x%x)\n", nGrow, hHeap);
     2235    TRACE("(%d %p)\n", nGrow, hHeap);
    22762236
    22772237    if (hHeap)
     
    23212281    UINT idFrom = 0;
    23222282
    2323     TRACE("(0x%04x 0x%04x %d %p 0x%08lx)\n",
     2283    TRACE("(%p %p %d %p 0x%08lx)\n",
    23242284           lpNotify->hwndFrom, lpNotify->hwndTo, uCode, lpHdr,
    23252285           lpNotify->dwParam5);
     
    23282288        return 0;
    23292289
    2330     if (lpNotify->hwndFrom == -1) {
     2290    if (lpNotify->hwndFrom == (HWND)-1) {
    23312291        lpNmh = lpHdr;
    23322292        idFrom = lpHdr->idFrom;
     
    23742334    NOTIFYDATA notify;
    23752335
    2376     TRACE("(0x%04x 0x%04x %d %p)\n",
     2336    TRACE("(%p %p %d %p)\n",
    23772337           hwndTo, hwndFrom, uCode, lpHdr);
    23782338
     
    24082368    HWND hwndNotify;
    24092369
    2410     TRACE("(0x%04x 0x%04x %d %p 0x%08lx)\n",
     2370    TRACE("(%p %p %d %p 0x%08lx)\n",
    24112371           hwndFrom, hwndTo, uCode, lpHdr, dwParam5);
    24122372
     
    24912451COMCTL32_StrToIntW (LPWSTR lpString)
    24922452{
    2493     return _wtoi(lpString);
     2453    return atoiW(lpString);
    24942454}
    24952455
     
    25032463 *     hdpa     [I] handle to the dynamic pointer array
    25042464 *     enumProc [I]
    2505  *     lParam   [I] 
     2465 *     lParam   [I]
    25062466 *
    25072467 * RETURNS
     
    26842644        if (dbcs && lpStart[1] != HIBYTE(wMatch)) continue;
    26852645        lpGotIt = lpStart;
    2686     }   
     2646    }
    26872647    return (LPSTR)lpGotIt;
    26882648}
     
    27382698    if( strchrW(lpSet, *(WORD*)lpLoop))
    27392699      return (INT)(lpLoop-lpStr);
    2740  
     2700
    27412701  return (INT)(lpLoop-lpStr);
    27422702}
     
    27512711BOOL WINAPI COMCTL32_410( HWND hw, DWORD b, DWORD c, DWORD d) {
    27522712
    2753    FIXME("(%x, %lx, %lx, %lx): stub!\n", hw, b, c, d);
     2713   FIXME("(%p, %lx, %lx, %lx): stub!\n", hw, b, c, d);
    27542714
    27552715   return TRUE;
     
    27652725BOOL WINAPI COMCTL32_411( HWND hw, DWORD b, DWORD c) {
    27662726
    2767    FIXME("(%x, %lx, %lx): stub!\n", hw, b, c);
     2727   FIXME("(%p, %lx, %lx): stub!\n", hw, b, c);
    27682728
    27692729   return TRUE;
     
    27792739BOOL WINAPI COMCTL32_412( HWND hwnd, DWORD b, DWORD c)
    27802740{
    2781     FIXME("(%x, %lx, %lx): stub!\n", hwnd, b, c);
     2741    FIXME("(%p, %lx, %lx): stub!\n", hwnd, b, c);
    27822742
    27832743    if (IsWindow (hwnd) == FALSE)
     
    28002760BOOL WINAPI COMCTL32_413( HWND hw, DWORD b, DWORD c, DWORD d) {
    28012761
    2802    FIXME("(%x, %lx, %lx, %lx): stub!\n", hw, b, c, d);
     2762   FIXME("(%p, %lx, %lx, %lx): stub!\n", hw, b, c, d);
    28032763
    28042764   return TRUE;
     
    28162776{
    28172777
    2818    FIXME("(%x, %lx, %lx, %lx, %lx): stub!\n", hwnd, b, c, d, e);
     2778   FIXME("(%p, %lx, %lx, %lx, %lx): stub!\n", hwnd, b, c, d, e);
    28192779
    28202780   return TRUE;
     
    28222782
    28232783/**************************************************************************
     2784 * @ [COMCTL32.417]
     2785 *
     2786 */
     2787BOOL WINAPI COMCTL32_417(HDC hdc, INT x, INT y, UINT flags, const RECT *lprect,
     2788                         LPCWSTR str, UINT count, const INT *lpDx)
     2789{
     2790    return ExtTextOutW(hdc, x, y, flags, lprect, str, count, lpDx);
     2791}
     2792
     2793/**************************************************************************
    28242794 * @ [COMCTL32.419]
    28252795 *
  • trunk/src/comctl32/commctrl.c

    r8382 r9370  
    1 /*             
     1/*
    22 * Common controls functions
    33 *
     
    1818 * License along with this library; if not, write to the Free Software
    1919 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     20 *
     21 * NOTES
     22 *
     23 * This code was audited for completeness against the documented features
     24 * of Comctl32.dll version 6.0 on Oct. 21, 2002, by Christian Neumair.
     25 *
     26 * Unless otherwise noted, we belive this code to be complete, as per
     27 * the specification mentioned above.
     28 * If you discover missing features, or bugs, please note them below.
     29 *
     30 * TODO
     31 *   -- implement GetMUILanguage + InitMUILanguage
     32 *   -- LibMain => DLLMain ("DLLMain takes over the functionality of both the
     33 *                           LibMain and the WEP function.", MSDN)
     34 *   -- finish NOTES for MenuHelp, GetEffectiveClientRect and GetStatusTextW
     35 *   -- FIXMEs + BUGS (search for them)
     36 *
     37 * Control Classes
     38 *   -- ICC_ANIMATE_CLASS
     39 *   -- ICC_BAR_CLASSES
     40 *   -- ICC_COOL_CLASSES
     41 *   -- ICC_DATE_CLASSES
     42 *   -- ICC_HOTKEY_CLASS
     43 *   -- ICC_INTERNET_CLASSES
     44 *   -- ICC_LINK_CLASS (not yet implemented)
     45 *   -- ICC_LISTVIEW_CLASSES
     46 *   -- ICC_NATIVEFNTCTL_CLASS
     47 *   -- ICC_PAGESCROLLER_CLASS
     48 *   -- ICC_PROGRESS_CLASS
     49 *   -- ICC_STANDARD_CLASSES (not yet implemented)
     50 *   -- ICC_TAB_CLASSES
     51 *   -- ICC_TREEVIEW_CLASSES
     52 *   -- ICC_UPDOWN_CLASS
     53 *   -- ICC_USEREX_CLASSES
     54 *   -- ICC_WIN95_CLASSES
    2055 */
    2156
     
    108143COMCTL32_LibMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
    109144{
    110     TRACE("%x,%lx,%p\n", hinstDLL, fdwReason, lpvReserved);
     145    TRACE("%p,%lx,%p\n", hinstDLL, fdwReason, lpvReserved);
    111146
    112147    switch (fdwReason) {
     
    116151            /* create private heap */
    117152            COMCTL32_hHeap = HeapCreate (0, 0x10000, 0);
    118             TRACE("Heap created: 0x%x\n", COMCTL32_hHeap);
     153            TRACE("Heap created: %p\n", COMCTL32_hHeap);
    119154
    120155            /* add global subclassing atom (used by 'tooltip' and 'updown') */
     
    181216            /* destroy private heap */
    182217            HeapDestroy (COMCTL32_hHeap);
    183             TRACE("Heap destroyed: 0x%x\n", COMCTL32_hHeap);
     218            TRACE("Heap destroyed: %p\n", COMCTL32_hHeap);
    184219            COMCTL32_hHeap = (HANDLE)NULL;
    185220            break;
     
    219254VOID WINAPI
    220255MenuHelp (UINT uMsg, WPARAM wParam, LPARAM lParam, HMENU hMainMenu,
    221           HINSTANCE hInst, HWND hwndStatus, LPUINT lpwIDs)
     256          HINSTANCE hInst, HWND hwndStatus, UINT* lpwIDs)
    222257{
    223258    UINT uMenuID = 0;
     
    275310
    276311/***********************************************************************
    277  * ShowHideMenuCtl [COMCTL32.3] 
     312 * ShowHideMenuCtl [COMCTL32.3]
    278313 *
    279314 * Shows or hides controls and updates the corresponding menu item.
     
    309344    LPINT lpMenuId;
    310345
    311     TRACE("%x, %x, %p\n", hwnd, uFlags, lpInfo);
     346    TRACE("%p, %x, %p\n", hwnd, uFlags, lpInfo);
    312347
    313348    if (lpInfo == NULL)
     
    322357        lpMenuId += 2;
    323358
    324     if (GetMenuState (lpInfo[1], uFlags, MF_BYCOMMAND) & MFS_CHECKED) {
     359    if (GetMenuState ((HMENU)lpInfo[1], uFlags, MF_BYCOMMAND) & MFS_CHECKED) {
    325360        /* uncheck menu item */
    326         CheckMenuItem (lpInfo[0], *lpMenuId, MF_BYCOMMAND | MF_UNCHECKED);
     361        CheckMenuItem ((HMENU)lpInfo[0], *lpMenuId, MF_BYCOMMAND | MF_UNCHECKED);
    327362
    328363        /* hide control */
     
    333368    else {
    334369        /* check menu item */
    335         CheckMenuItem (lpInfo[0], *lpMenuId, MF_BYCOMMAND | MF_CHECKED);
     370        CheckMenuItem ((HMENU)lpInfo[0], *lpMenuId, MF_BYCOMMAND | MF_CHECKED);
    336371
    337372        /* show control */
     
    361396 *
    362397 *     lpInfo
    363  *     (will be written...)
     398 *     (will be written ...)
    364399 */
    365400
     
    395430
    396431/***********************************************************************
    397  * DrawStatusTextW [COMCTL32.28]
     432 * DrawStatusTextW [COMCTL32.@]
    398433 *
    399434 * Draws text with borders, like in a status bar.
     
    439474        r.left += 3;
    440475        if (style & SBT_RTLREADING)
    441             FIXME("Usupported RTL style!");
     476            FIXME("Unsupported RTL style!\n");
    442477        DrawTextW (hdc, text, -1, &r, align|DT_VCENTER|DT_SINGLELINE);
    443478        SetBkMode(hdc, oldbkmode);
     
    447482
    448483/***********************************************************************
    449  * DrawStatusText  [COMCTL32.27]
     484 * DrawStatusText  [COMCTL32.@]
    450485 * DrawStatusTextA [COMCTL32.5]
    451486 *
     
    479514
    480515/***********************************************************************
    481  * CreateStatusWindow  [COMCTL32.21]
     516 * CreateStatusWindow  [COMCTL32.@]
    482517 * CreateStatusWindowA [COMCTL32.6]
    483518 *
     
    498533CreateStatusWindowA (INT style, LPCSTR text, HWND parent, UINT wid)
    499534{
    500     return CreateWindowA(STATUSCLASSNAMEA, text, style, 
     535    return CreateWindowA(STATUSCLASSNAMEA, text, style,
    501536                           CW_USEDEFAULT, CW_USEDEFAULT,
    502                            CW_USEDEFAULT, CW_USEDEFAULT, 
    503                            parent, wid, 0, 0);
    504 }
    505 
    506 
    507 /***********************************************************************
    508  * CreateStatusWindowW [COMCTL32.22] Creates a status bar control
     537                           CW_USEDEFAULT, CW_USEDEFAULT,
     538                           parent, (HMENU)wid, 0, 0);
     539}
     540
     541
     542/***********************************************************************
     543 * CreateStatusWindowW [COMCTL32.@] Creates a status bar control
    509544 *
    510545 * PARAMS
     
    525560                           CW_USEDEFAULT, CW_USEDEFAULT,
    526561                           CW_USEDEFAULT, CW_USEDEFAULT,
    527                            parent, wid, 0, 0);
     562                           parent, (HMENU)wid, 0, 0);
    528563}
    529564
     
    558593    HWND hUD =
    559594        CreateWindowA (UPDOWN_CLASSA, 0, style, x, y, cx, cy,
    560                          parent, id, inst, 0);
     595                         parent, (HMENU)id, inst, 0);
    561596    if (hUD) {
    562         SendMessageA (hUD, UDM_SETBUDDY, buddy, 0);
     597        SendMessageA (hUD, UDM_SETBUDDY, (WPARAM)buddy, 0);
    563598        SendMessageA (hUD, UDM_SETRANGE, 0, MAKELONG(maxVal, minVal));
    564         SendMessageA (hUD, UDM_SETPOS, 0, MAKELONG(curVal, 0));     
     599        SendMessageA (hUD, UDM_SETPOS, 0, MAKELONG(curVal, 0));
    565600    }
    566601
     
    593628
    594629/***********************************************************************
    595  * InitCommonControlsEx [COMCTL32.84]
     630 * InitCommonControlsEx [COMCTL32.@]
    596631 *
    597632 * Registers the common controls.
     
    607642 *     Only the additional common controls are registered by this function.
    608643 *     The Win95 controls are registered at the DLL's initialization.
     644 *
     645 * FIXME
     646 *     implement the following control classes:
     647 *       ICC_LINK_CLASS
     648 *       ICC_STANDARD_CLASSES
    609649 */
    610650
     
    676716
    677717/***********************************************************************
    678  * CreateToolbarEx [COMCTL32.23] Creates a tool bar window
     718 * CreateToolbarEx [COMCTL32.@] Creates a tool bar window
    679719 *
    680720 * PARAMS
     
    897937
    898938/***********************************************************************
    899  * DllGetVersion [COMCTL32.25]
     939 * DllGetVersion [COMCTL32.@]
    900940 *
    901941 * Retrieves version information of the 'COMCTL32.DLL'
     
    933973
    934974/***********************************************************************
    935  *              DllInstall (COMCTL32.26)
     975 *              DllInstall (COMCTL32.@)
    936976 */
    937977HRESULT WINAPI COMCTL32_DllInstall(BOOL bInstall, LPCWSTR cmdline)
    938978{
    939   FIXME("(%s, %s): stub\n", bInstall?"TRUE":"FALSE", 
     979  FIXME("(%s, %s): stub\n", bInstall?"TRUE":"FALSE",
    940980        debugstr_w(cmdline));
    941981
     
    944984
    945985/***********************************************************************
    946  * _TrackMouseEvent [COMCTL32.91]
     986 * _TrackMouseEvent [COMCTL32.@]
    947987 *
    948988 * Requests notification of mouse events
     
    9741014
    9751015/*************************************************************************
    976  * GetMUILanguage [COMCTL32.39]
    977  *
    978  * FIXME: What's this supposed to do?  Apparently some i18n thing.
     1016 * GetMUILanguage [COMCTL32.@]
     1017 *
     1018 * FIXME: "Returns the language currently in use by the common controls
     1019 * for a particular process." (MSDN)
    9791020 *
    9801021 */
     
    9861027
    9871028/*************************************************************************
    988  * InitMUILanguage [COMCTL32.85]
    989  *
    990  * FIXME: What's this supposed to do?  Apparently some i18n thing.
     1029 * InitMUILanguage [COMCTL32.@]
     1030 *
     1031 * FIXME: "Enables an application to specify a language to be used with
     1032 * the common controls that is different than the system language." (MSDN)
    9911033 *
    9921034 */
     
    9951037{
    9961038   COMCTL32_uiLang = uiLang;
     1039}
     1040
     1041
     1042/***********************************************************************
     1043 * SetWindowSubclass [COMCTL32.@]
     1044 *
     1045 * Starts a window subclass
     1046 *
     1047 * PARAMS
     1048 *     hWnd [in] handle to window subclass.
     1049 *     pfnSubclass [in] Pointer to new window procedure.
     1050 *     uIDSubclass [in] Unique identifier of sublass together with pfnSubclass.
     1051 *     dwRef [in] Reference data to pass to window procedure.
     1052 *
     1053 * RETURNS
     1054 *     Success: non-zero
     1055 *     Failure: zero
     1056 *
     1057 * BUGS
     1058 *     If an application manually subclasses a window after subclassing it with
     1059 *     this API and then with this API again, then none of the previous
     1060 *     subclasses get called or the origional window procedure.
     1061 */
     1062
     1063BOOL WINAPI SetWindowSubclass (HWND hWnd, SUBCLASSPROC pfnSubclass,
     1064                        UINT_PTR uIDSubclass, DWORD_PTR dwRef)
     1065{
     1066   LPSUBCLASS_INFO stack;
     1067   int newnum, n;
     1068
     1069   TRACE ("(%p, %p, %x, %lx)\n", hWnd, pfnSubclass, uIDSubclass, dwRef);
     1070
     1071   /* Since the window procedure that we set here has two additional arguments,
     1072    * we can't simply set it as the new window procedure of the window. So we
     1073    * set our own window procedure and then calculate the other two arguments
     1074    * from there. */
     1075
     1076   /* See if we have been called for this window */
     1077   stack = (LPSUBCLASS_INFO)GetPropA (hWnd, COMCTL32_aSubclass);
     1078   if (!stack) {
     1079      /* allocate stack */
     1080      stack = (LPSUBCLASS_INFO)HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY,
     1081                                         sizeof(SUBCLASS_INFO));
     1082      if (!stack) {
     1083         ERR ("Failed to allocate our Subclassing stack");
     1084         return FALSE;
     1085      }
     1086      SetPropA (hWnd, COMCTL32_aSubclass, (HANDLE)stack);
     1087
     1088      /* set window procedure to our own and save the current one */
     1089      if (IsWindowUnicode (hWnd))
     1090         stack->origproc = (WNDPROC)SetWindowLongW (hWnd, GWL_WNDPROC,
     1091                                                   (LONG)DefSubclassProc);
     1092      else
     1093         stack->origproc = (WNDPROC)SetWindowLongA (hWnd, GWL_WNDPROC,
     1094                                                   (LONG)DefSubclassProc);
     1095   } else {
     1096      WNDPROC current;
     1097      if (IsWindowUnicode (hWnd))
     1098         current = (WNDPROC)GetWindowLongW (hWnd, GWL_WNDPROC);
     1099      else
     1100         current = (WNDPROC)GetWindowLongA (hWnd, GWL_WNDPROC);
     1101
     1102      if (current != DefSubclassProc) {
     1103         ERR ("Application has subclassed with our procedure, then manually, then with us again.  The current implementation can't handle this.\n");
     1104         return FALSE;
     1105      }
     1106   }
     1107
     1108   /* Check to see if we have called this function with the same uIDSubClass
     1109    * and pfnSubclass */
     1110   for (n = 0; n <= stack->stacknum + stack->stacknew - 1; n++)
     1111      if ((stack->SubclassProcs[n].id == uIDSubclass) &&
     1112         (stack->SubclassProcs[n].subproc == pfnSubclass)) {
     1113         stack->SubclassProcs[n].ref = dwRef;
     1114         return TRUE;
     1115      }
     1116
     1117   if ((stack->stacknum + stack->stacknew) >= 32) {
     1118      ERR ("We have a Subclass stack overflow, please increment size");
     1119      return FALSE;
     1120   }
     1121
     1122   /* we can't simply increment both stackpos and stacknum because there might
     1123    * be a window procedure running lower in the stack, we can only get them
     1124    * up to date once the last window procedure has run */
     1125   if (stack->stacknum == stack->stackpos) {
     1126      stack->stacknum++;
     1127      stack->stackpos++;
     1128   } else
     1129      stack->stacknew++;
     1130
     1131   newnum = stack->stacknew + stack->stacknum - 1;
     1132
     1133   stack->SubclassProcs[newnum].subproc = pfnSubclass;
     1134   stack->SubclassProcs[newnum].ref = dwRef;
     1135   stack->SubclassProcs[newnum].id = uIDSubclass;
     1136   
     1137   return TRUE;
     1138}
     1139
     1140
     1141/***********************************************************************
     1142 * GetWindowSubclass [COMCTL32.@]
     1143 *
     1144 * Gets the Reference data from a subclass.
     1145 *
     1146 * PARAMS
     1147 *     hWnd [in] Handle to window which were subclassing
     1148 *     pfnSubclass [in] Pointer to the subclass procedure
     1149 *     iID [in] Unique indentifier of the subclassing procedure
     1150 *     pdwRef [out] Pointer to the reference data
     1151 *
     1152 * RETURNS
     1153 *     Success: non-sero
     1154 *     Failure: zero
     1155 */
     1156
     1157BOOL WINAPI GetWindowSubclass (HWND hWnd, SUBCLASSPROC pfnSubclass,
     1158                              UINT_PTR uID, DWORD_PTR *pdwRef)
     1159{
     1160   LPSUBCLASS_INFO stack;
     1161   int n;
     1162
     1163   TRACE ("(%p, %p, %x, %p)\n", hWnd, pfnSubclass, uID, pdwRef);
     1164
     1165   /* See if we have been called for this window */
     1166   stack = (LPSUBCLASS_INFO)GetPropA (hWnd, COMCTL32_aSubclass);
     1167   if (!stack)
     1168      return FALSE;
     1169
     1170   for (n = 0; n <= stack->stacknum + stack->stacknew - 1; n++)
     1171      if ((stack->SubclassProcs[n].id == uID) &&
     1172         (stack->SubclassProcs[n].subproc == pfnSubclass)) {
     1173         *pdwRef = stack->SubclassProcs[n].ref;
     1174         return TRUE;
     1175      }
     1176
     1177   return FALSE;
     1178}
     1179
     1180
     1181/***********************************************************************
     1182 * RemoveWindowSubclass [COMCTL32.@]
     1183 *
     1184 * Removes a window subclass.
     1185 *
     1186 * PARAMS
     1187 *     hWnd [in] Handle to the window were subclassing
     1188 *     pfnSubclass [in] Pointer to the subclass procedure
     1189 *     uID [in] Unique identifier of this subclass
     1190 *
     1191 * RETURNS
     1192 *     Success: non-zero
     1193 *     Failure: zero
     1194 */
     1195
     1196BOOL WINAPI RemoveWindowSubclass(HWND hWnd, SUBCLASSPROC pfnSubclass, UINT_PTR uID)
     1197{
     1198   LPSUBCLASS_INFO stack;
     1199   int n;
     1200
     1201   TRACE ("(%p, %p, %x)\n", hWnd, pfnSubclass, uID);
     1202
     1203   /* Find the Subclass to remove */
     1204   stack = (LPSUBCLASS_INFO)GetPropA (hWnd, COMCTL32_aSubclass);
     1205   if (!stack)
     1206      return FALSE;
     1207
     1208   if ((stack->stacknum == stack->stackpos == 1) && !stack->stacknew) {
     1209      TRACE("Last Subclass removed, cleaning up\n");
     1210      /* clean up our heap and reset the origional window procedure */
     1211      if (IsWindowUnicode (hWnd))
     1212         SetWindowLongW (hWnd, GWL_WNDPROC, (LONG)stack->origproc);
     1213      else
     1214         SetWindowLongA (hWnd, GWL_WNDPROC, (LONG)stack->origproc);
     1215      HeapFree (GetProcessHeap (), 0, stack);
     1216      RemovePropA( hWnd, COMCTL32_aSubclass );
     1217      return TRUE;
     1218   }
     1219 
     1220   for (n = stack->stacknum + stack->stacknew - 1; n >= 0; n--)
     1221      if ((stack->SubclassProcs[n].id == uID) &&
     1222         (stack->SubclassProcs[n].subproc == pfnSubclass)) {
     1223         if (n != (stack->stacknum + stack->stacknew))
     1224            /* Fill the hole in the stack */
     1225            memmove (&stack->SubclassProcs[n], &stack->SubclassProcs[n + 1],
     1226                    sizeof(stack->SubclassProcs[0]) * (stack->stacknew + stack->stacknum - n));
     1227         stack->SubclassProcs[n].subproc = NULL;
     1228         stack->SubclassProcs[n].ref = 0;
     1229         stack->SubclassProcs[n].id = 0;
     1230
     1231         /* If we are currently running a window procedure we have to manipulate
     1232          * the stack position pointers so that we don't corrupt the stack */
     1233         if ((n < stack->stackpos) || (stack->stackpos == stack->stacknum)) {
     1234            stack->stacknum--;
     1235            stack->stackpos--;
     1236         } else if (n >= stack->stackpos)
     1237            stack->stacknew--;
     1238         return TRUE;
     1239      }
     1240
     1241   return FALSE;
     1242}
     1243
     1244
     1245/***********************************************************************
     1246 * DefSubclassProc [COMCTL32.@]
     1247 *
     1248 * Calls the next window procedure (ie. the one before this subclass)
     1249 *
     1250 * PARAMS
     1251 *     hWnd [in] The window that we're subclassing
     1252 *     uMsg [in] Message
     1253 *     wParam [in] WPARAM
     1254 *     lParam [in] LPARAM
     1255 *
     1256 * RETURNS
     1257 *     Success: non-zero
     1258 *     Failure: zero
     1259 */
     1260
     1261LRESULT WINAPI DefSubclassProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
     1262{
     1263   LPSUBCLASS_INFO stack;
     1264   int stackpos;
     1265   LRESULT ret;
     1266
     1267   /* retrieve our little stack from the Properties */
     1268   stack = (LPSUBCLASS_INFO)GetPropA (hWnd, COMCTL32_aSubclass);
     1269   if (!stack) {
     1270      ERR ("Our sub classing stack got erased for %p!! Nothing we can do\n", hWnd);
     1271      return 0;
     1272   }
     1273
     1274   /* If we are at pos 0 then we have to call the origional window procedure */
     1275   if (stack->stackpos == 0) {
     1276      if (IsWindowUnicode (hWnd))
     1277         return CallWindowProcW (stack->origproc, hWnd, uMsg, wParam, lParam);
     1278      else
     1279         return CallWindowProcA (stack->origproc, hWnd, uMsg, wParam, lParam);
     1280   }
     1281
     1282   stackpos = --stack->stackpos;
     1283   /* call the Subclass procedure from the stack */
     1284   ret = stack->SubclassProcs[stackpos].subproc (hWnd, uMsg, wParam, lParam,
     1285         stack->SubclassProcs[stackpos].id, stack->SubclassProcs[stackpos].ref);
     1286   stack->stackpos++;
     1287
     1288   if ((stack->stackpos == stack->stacknum) && stack->stacknew) {
     1289      stack->stacknum += stack->stacknew;
     1290      stack->stackpos += stack->stacknew;
     1291      stack->stacknew = 0;
     1292   }
     1293
     1294   /* If we removed the last entry in our stack while a window procedure was
     1295    * running then we have to clean up */
     1296   if (stack->stackpos == stack->stacknum == 0) {
     1297      TRACE("Last Subclass removed, cleaning up\n");
     1298      /* clean up our heap and reset the origional window procedure */
     1299      if (IsWindowUnicode (hWnd))
     1300         SetWindowLongW (hWnd, GWL_WNDPROC, (LONG)stack->origproc);
     1301      else
     1302         SetWindowLongA (hWnd, GWL_WNDPROC, (LONG)stack->origproc);
     1303      HeapFree (GetProcessHeap (), 0, stack);
     1304      RemovePropA( hWnd, COMCTL32_aSubclass );
     1305      return TRUE;
     1306   }
     1307
     1308   return ret;
    9971309}
    9981310
     
    10111323 *     Failure: NULL
    10121324 */
     1325
    10131326HWND
    10141327COMCTL32_CreateToolTip(HWND hwndOwner)
     
    10531366 *     none
    10541367 */
     1368
    10551369VOID
    10561370COMCTL32_RefreshSysColors(void)
  • trunk/src/comctl32/flatsb.c

    r8382 r9370  
    4747
    4848/***********************************************************************
    49  *              InitializeFlatSB (COMCTL32.86)
     49 *              InitializeFlatSB (COMCTL32.@)
    5050 *
    5151 *      returns nonzero if successful, zero otherwise
     
    5454BOOL WINAPI InitializeFlatSB(HWND hwnd)
    5555{
    56     TRACE("[%04x]\n", hwnd);
     56    TRACE("[%p]\n", hwnd);
    5757    FIXME("stub\n");
    5858    return FALSE;
     
    6060
    6161/***********************************************************************
    62  *              UninitializeFlatSB (COMCTL32.90)
     62 *              UninitializeFlatSB (COMCTL32.@)
    6363 *
    6464 *      returns:
     
    7070HRESULT WINAPI UninitializeFlatSB(HWND hwnd)
    7171{
    72     TRACE("[%04x]\n", hwnd);
     72    TRACE("[%p]\n", hwnd);
    7373    FIXME("stub\n");
    7474    return S_FALSE;
     
    7676
    7777/***********************************************************************
    78  *              FlatSB_GetScrollProp (COMCTL32.32)
     78 *              FlatSB_GetScrollProp (COMCTL32.@)
    7979 *
    8080 *      Returns nonzero if successful, or zero otherwise. If index is WSB_PROP_HSTYLE,
    8181 *      the return is nonzero if InitializeFlatSB has been called for this window, or
    82  *      zero otherwise. 
    83  *
    84  */
    85 BOOL WINAPI 
     82 *      zero otherwise.
     83 *
     84 */
     85BOOL WINAPI
    8686FlatSB_GetScrollProp(HWND hwnd, INT propIndex, LPINT prop)
    8787{
    88     TRACE("[%04x] propIndex=%d\n", hwnd, propIndex);
     88    TRACE("[%p] propIndex=%d\n", hwnd, propIndex);
    8989    FIXME("stub\n");
    9090    return FALSE;
     
    9292
    9393/***********************************************************************
    94  *              FlatSB_SetScrollProp (COMCTL32.36)
    95  */
    96 BOOL WINAPI 
     94 *              FlatSB_SetScrollProp (COMCTL32.@)
     95 */
     96BOOL WINAPI
    9797FlatSB_SetScrollProp(HWND hwnd, UINT index, INT newValue, BOOL flag)
    9898{
    99     TRACE("[%04x] index=%u newValue=%d flag=%d\n", hwnd, index, newValue, flag);
     99    TRACE("[%p] index=%u newValue=%d flag=%d\n", hwnd, index, newValue, flag);
    100100    FIXME("stub\n");
    101101    return FALSE;
     
    110110 *
    111111 *      So, if we just call the standard functions until we implement
    112  *      the flat scroll bar functions, flat scroll bars will show up and 
     112 *      the flat scroll bar functions, flat scroll bars will show up and
    113113 *      behave properly, as though they had simply not been setup to
    114114 *      have flat properties.
     
    119119
    120120/***********************************************************************
    121  *              FlatSB_EnableScrollBar (COMCTL32.29)
    122  */
    123 BOOL WINAPI 
     121 *              FlatSB_EnableScrollBar (COMCTL32.@)
     122 */
     123BOOL WINAPI
    124124FlatSB_EnableScrollBar(HWND hwnd, int nBar, UINT flags)
    125125{
     
    128128
    129129/***********************************************************************
    130  *              FlatSB_ShowScrollBar (COMCTL32.38)
    131  */
    132 BOOL WINAPI 
     130 *              FlatSB_ShowScrollBar (COMCTL32.@)
     131 */
     132BOOL WINAPI
    133133FlatSB_ShowScrollBar(HWND hwnd, int nBar, BOOL fShow)
    134134{
     
    137137
    138138/***********************************************************************
    139  *              FlatSB_GetScrollRange (COMCTL32.33)
    140  */
    141 BOOL WINAPI 
     139 *              FlatSB_GetScrollRange (COMCTL32.@)
     140 */
     141BOOL WINAPI
    142142FlatSB_GetScrollRange(HWND hwnd, int nBar, LPINT min, LPINT max)
    143143{
     
    146146
    147147/***********************************************************************
    148  *              FlatSB_GetScrollInfo (COMCTL32.30)
    149  */
    150 BOOL WINAPI 
     148 *              FlatSB_GetScrollInfo (COMCTL32.@)
     149 */
     150BOOL WINAPI
    151151FlatSB_GetScrollInfo(HWND hwnd, int nBar, LPSCROLLINFO info)
    152152{
     
    155155
    156156/***********************************************************************
    157  *              FlatSB_GetScrollPos (COMCTL32.31)
    158  */
    159 INT WINAPI 
     157 *              FlatSB_GetScrollPos (COMCTL32.@)
     158 */
     159INT WINAPI
    160160FlatSB_GetScrollPos(HWND hwnd, int nBar)
    161161{
     
    164164
    165165/***********************************************************************
    166  *              FlatSB_SetScrollPos (COMCTL32.35)
    167  */
    168 INT WINAPI 
     166 *              FlatSB_SetScrollPos (COMCTL32.@)
     167 */
     168INT WINAPI
    169169FlatSB_SetScrollPos(HWND hwnd, int nBar, INT pos, BOOL bRedraw)
    170170{
     
    173173
    174174/***********************************************************************
    175  *              FlatSB_SetScrollInfo (COMCTL32.34)
    176  */
    177 INT WINAPI 
     175 *              FlatSB_SetScrollInfo (COMCTL32.@)
     176 */
     177INT WINAPI
    178178FlatSB_SetScrollInfo(HWND hwnd, int nBar, LPSCROLLINFO info, BOOL bRedraw)
    179179{
     
    182182
    183183/***********************************************************************
    184  *              FlatSB_SetScrollRange (COMCTL32.37)
    185  */
    186 INT WINAPI 
     184 *              FlatSB_SetScrollRange (COMCTL32.@)
     185 */
     186INT WINAPI
    187187FlatSB_SetScrollRange(HWND hwnd, int nBar, INT min, INT max, BOOL bRedraw)
    188188{
     
    194194FlatSB_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
    195195{
    196     TRACE("[%04x] wParam=%04x lParam=%08lx\n", hwnd, wParam, lParam);
     196    TRACE("[%p] wParam=%04x lParam=%08lx\n", hwnd, wParam, lParam);
    197197    return 0;
    198198}
     
    202202FlatSB_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
    203203{
    204     TRACE("[%04x] wParam=%04x lParam=%08lx\n", hwnd, wParam, lParam);
     204    TRACE("[%p] wParam=%04x lParam=%08lx\n", hwnd, wParam, lParam);
    205205    return 0;
    206206}
     
    212212    if (!FlatSB_GetInfoPtr(hwnd) && (uMsg != WM_CREATE))
    213213        return DefWindowProcA( hwnd, uMsg, wParam, lParam );
    214    
     214
    215215    switch (uMsg)
    216216    {
     
    222222
    223223        default:
    224             if (uMsg >= WM_USER)
     224            if ((uMsg >= WM_USER) && (uMsg < WM_APP))
    225225                ERR("unknown msg %04x wp=%08x lp=%08lx\n",
    226226                    uMsg, wParam, lParam);
     
    244244    wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
    245245    wndClass.lpszClassName = FLATSB_CLASSA;
    246  
     246
    247247    RegisterClassA (&wndClass);
    248248}
     
    254254    UnregisterClassA (FLATSB_CLASSA, (HINSTANCE)NULL);
    255255}
    256 
  • trunk/src/comctl32/imagelist.c

    r8520 r9370  
    33 *
    44 *  Copyright 1998 Eric Kohl
    5  *            2000 Jason Mawdsley.
    6  *            2001 Michael Stefaniuc
    7  *            2001 Charles Loep for CodeWeavers
     5 *  Copyright 2000 Jason Mawdsley
     6 *  Copyright 2001 Michael Stefaniuc
     7 *  Copyright 2001 Charles Loep for CodeWeavers
     8 *  Copyright 2002 Dimitrie O. Paun
    89 *
    910 * This library is free software; you can redistribute it and/or
     
    2122 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    2223 *
     24 * NOTE
     25 *
     26 * This code was audited for completeness against the documented features
     27 * of Comctl32.dll version 6.0 on Sep. 12, 2002, by Dimitrie O. Paun.
     28 *
     29 * Unless otherwise noted, we belive this code to be complete, as per
     30 * the specification mentioned above.
     31 * If you discover missing features, or bugs, please note them below.
     32 *
    2333 *  TODO:
    24  *    - Fix ImageList_DrawIndirect (xBitmap, yBitmap, rgbFg, rgbBk, dwRop).
    25  *    - Fix ImageList_GetIcon.
    26  *    - Fix ImageList_SetFilter (undocumented).
    27  *      BTW does anybody know anything about this function???
    28  *        - It removes 12 Bytes from the stack (3 Parameters).
    29  *        - First parameter SHOULD be a HIMAGELIST.
    30  *        - Second parameter COULD be an index?????
    31  *        - Third parameter.... ?????????????????????
    32  *
    33  *  Comments:
    34  *    - ImageList_Draw, ImageList_DrawEx and ImageList_GetIcon use
    35  *      ImageList_DrawIndirect. Since ImageList_DrawIndirect is still
    36  *      partially implemented, the functions mentioned above will be
    37  *      limited in functionality too.
    38  *
     34 *    - Add support for ILD_PRESERVEALPHA, ILD_SCALE, ILD_DPISCALE
     35 *    - Add support for ILS_GLOW, ILS_SHADOW, ILS_SATURATE, ILS_ALPHA
     36 *
     37 *  FIXME:
    3938 *    - Hotspot handling still not correct. The Hotspot passed to BeginDrag
    4039 *      is the offset of the image position relative to the actual mouse pointer
     
    8180
    8281/*************************************************************************
    83  * IMAGELIST_InternalExpandBitmaps [Internal] 
     82 * IMAGELIST_InternalExpandBitmaps [Internal]
    8483 *
    8584 * Expands the bitmaps of an image list by the given number of images.
     
    9594 *     This function can NOT be used to reduce the number of images.
    9695 */
    97 static VOID
     96static void
    9897IMAGELIST_InternalExpandBitmaps (HIMAGELIST himl, INT nImageCount, INT cx, INT cy)
    9998{
     
    128127
    129128    if (himl->hbmMask) {
    130         hbmNewBitmap = 
     129        hbmNewBitmap =
    131130            CreateBitmap (nNewWidth, cy, 1, 1, NULL);
    132131
     
    150149
    151150/*************************************************************************
    152  * IMAGELIST_InternalDraw [Internal]
    153  *
    154  * Draws the image in the ImageList (without the mask)
    155  *
    156  * PARAMS
    157  *     pimldp        [I] pointer to IMAGELISTDRAWPARAMS structure.
    158  *     cx            [I] the width of the image to display
    159  *     cy............[I] the height of the image to display
    160  *
    161  * RETURNS
    162  *     nothing
    163  *
    164  * NOTES
    165  *     This function is used by ImageList_DrawIndirect, when it is
    166  *     required to draw only the Image (without the mask) to the screen.
    167  *
    168  *     Blending and Overlays styles are accomplished by another function
    169  */
    170 static VOID
    171 IMAGELIST_InternalDraw(IMAGELISTDRAWPARAMS *pimldp, INT cx, INT cy)
    172 {
    173     HDC hImageDC;
    174     HBITMAP hOldBitmap;
    175 
    176     hImageDC = CreateCompatibleDC(0);
    177     hOldBitmap = SelectObject(hImageDC, pimldp->himl->hbmImage);
    178     BitBlt(pimldp->hdcDst,
    179         pimldp->x, pimldp->y, cx, cy,
    180         hImageDC,
    181         pimldp->himl->cx * pimldp->i, 0,
    182         SRCCOPY);
    183 
    184     SelectObject(hImageDC, hOldBitmap);
    185     DeleteDC(hImageDC);
    186 }
    187 
    188 
    189 /*************************************************************************
    190  * IMAGELIST_InternalDrawMask [Internal]
    191  *
    192  * Draws the image in the ImageList with the mask
    193  *
    194  * PARAMS
    195  *     pimldp        [I] pointer to IMAGELISTDRAWPARAMS structure.
    196  *     cx            [I] the width of the image to display
    197  *     cy............[I] the height of the image to display
    198  *
    199  * RETURNS
    200  *     nothing
    201  *
    202  * NOTES
    203  *     This function is used by ImageList_DrawIndirect, when it is
    204  *     required to draw the Image with the mask to the screen.
    205  *
    206  *     Blending and Overlays styles are accomplished by another function.
    207  */
    208 static VOID
    209 IMAGELIST_InternalDrawMask(IMAGELISTDRAWPARAMS *pimldp, INT cx, INT cy)
    210 {
    211     BOOL bUseCustomBackground, bBlendFlag;
    212     HBRUSH hBrush, hOldBrush;
    213     HDC     hMaskDC, hImageDC;
    214     HBITMAP hOldBitmapImage, hOldBitmapMask;
    215     HIMAGELIST himlLocal = pimldp->himl;
    216     COLORREF oldBkColor, oldFgColor;
    217     UINT fStyle = pimldp->fStyle & (~ILD_OVERLAYMASK);
    218 
    219     /*
    220      * We need a dc and bitmap to draw on that is
    221      * not on the screen.
    222      */
    223     HDC hOffScreenDC = 0;
    224     HBITMAP hOffScreenBmp = 0;
    225 
    226     bUseCustomBackground = (himlLocal->clrBk != CLR_NONE);
    227     bBlendFlag = (fStyle & ILD_BLEND50 ) || (fStyle & ILD_BLEND25);
    228 
    229     hImageDC = CreateCompatibleDC(0);
    230     hMaskDC = CreateCompatibleDC(0);
    231 
    232     /* Create a compatible DC. */
    233     hOffScreenDC = CreateCompatibleDC( pimldp->hdcDst );
    234 
    235     if ( hOffScreenDC )
    236     {
    237         hOffScreenBmp = CreateCompatibleBitmap( pimldp->hdcDst, cx, cy );
    238 
    239         if ( hOffScreenBmp )
    240             SelectObject( hOffScreenDC, hOffScreenBmp  );
    241         else
    242             goto cleanup;
    243     }
    244     else
    245         goto cleanup;
    246 
    247     hOldBitmapImage = SelectObject(hImageDC, himlLocal->hbmImage);
    248     hOldBitmapMask = SelectObject(hMaskDC, himlLocal->hbmMask);
    249    
    250     /*
    251      * Get a copy of the image for the masking operations.
    252      * We will use the copy, and this dc for all the various
    253      * blitting, and then do one final blit to the screen dc.
    254      * This should clean up most of the flickering.
    255      */
    256     BitBlt( hOffScreenDC, 0, 0, cx, cy, pimldp->hdcDst, pimldp->x,
    257             pimldp->y, SRCCOPY);
    258 
    259     /*
    260      * Draw the Background for the appropriate Styles
    261      */
    262     if( bUseCustomBackground && (fStyle == ILD_NORMAL || fStyle & ILD_IMAGE
    263          || bBlendFlag) )
    264     {
    265        
    266         hBrush = CreateSolidBrush (himlLocal->clrBk);
    267         hOldBrush = SelectObject (pimldp->hdcDst, hBrush);
    268        
    269         PatBlt( hOffScreenDC, pimldp->x, pimldp->y, cx, cy, PATCOPY );
    270 
    271         DeleteObject (SelectObject (pimldp->hdcDst, hOldBrush));
    272     }
    273 
    274     /*
    275      * Draw Image Transparently over the current background
    276      */
    277     if(fStyle == ILD_NORMAL || (fStyle & ILD_TRANSPARENT) ||
    278        ((fStyle & ILD_IMAGE) && bUseCustomBackground) || bBlendFlag)
    279     {   /*
    280          * To obtain a transparent look, background color should be set
    281          * to white and foreground color to black when blting the
    282          * monochrome mask.
    283          */
    284        
    285         oldBkColor = SetBkColor( hOffScreenDC, RGB( 0xff, 0xff, 0xff ) );
    286         oldFgColor = SetTextColor( hOffScreenDC, RGB( 0, 0, 0 ) );
    287 
    288         BitBlt( hOffScreenDC, 0, 0, cx, cy,hMaskDC, himlLocal->cx * pimldp->i,
    289                 0, SRCAND );
    290 
    291         BitBlt( hOffScreenDC, 0, 0, cx, cy, hImageDC,himlLocal->cx * pimldp->i,
    292                 0, SRCPAINT );
    293    
    294     }
    295    
    296     /*
    297      * Draw the image when no Background is specified
    298      */
    299     else if((fStyle & ILD_IMAGE) && !bUseCustomBackground)
    300     {
    301         BitBlt( hOffScreenDC, 0, 0, cx, cy, hImageDC,
    302                 himlLocal->cx * pimldp->i, 0, SRCCOPY);
    303     }
    304     /*
    305      * Draw the mask with or without a background
    306      */
    307     else if(fStyle & ILD_MASK)
    308     {
    309         BitBlt( hOffScreenDC, 0, 0, cx, cy, hMaskDC, himlLocal->cx * pimldp->i,
    310                 0, bUseCustomBackground ? SRCCOPY : SRCAND);
    311     }
    312    
    313     /*
    314      * Blit the bitmap to the screen now.
    315      */
    316     BitBlt( pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy,
    317             hOffScreenDC, 0, 0, SRCCOPY);
    318 
    319    
    320     SelectObject(hImageDC, hOldBitmapImage);
    321     SelectObject(hMaskDC, hOldBitmapMask);
    322    
    323 cleanup:
    324    
    325     DeleteDC(hImageDC);
    326     DeleteDC(hMaskDC);
    327    
    328     DeleteDC( hOffScreenDC );
    329     DeleteObject( hOffScreenBmp );
    330    
    331     return;
    332 }
    333 
    334 /*************************************************************************
    335  * IMAGELIST_InternalDrawBlend [Internal]
    336  *
    337  * Draws the Blend over the current image
    338  *
    339  * PARAMS
    340  *     pimldp        [I] pointer to IMAGELISTDRAWPARAMS structure.
    341  *     cx            [I] the width of the image to display
    342  *     cy............[I] the height of the image to display
    343  *
    344  * RETURNS
    345  *     nothing
    346  *
    347  * NOTES
    348  *     This functions is used by ImageList_DrawIndirect, when it is
    349  *     required to add the blend to the current image. 
    350  *     
    351  */
    352 static VOID
    353 IMAGELIST_InternalDrawBlend(IMAGELISTDRAWPARAMS *pimldp, INT cx, INT cy)
    354 {
    355 
    356     HDC         hBlendMaskDC,hMaskDC;
    357     HBRUSH      hBlendColorBrush, hBlendBrush, hOldBrush;
    358     HBITMAP     hBlendMaskBitmap, hOldBitmap;
    359     COLORREF    clrBlend, OldTextColor, OldBkColor;
    360     HIMAGELIST  himlLocal = pimldp->himl;
    361 
    362     clrBlend = GetSysColor (COLOR_HIGHLIGHT);
    363     if (!(pimldp->rgbFg == CLR_DEFAULT))
    364     {
    365         clrBlend = pimldp->rgbFg;
    366     }
    367     /* Create the blend Mask
    368     */
    369     hBlendMaskDC = CreateCompatibleDC(0);
    370     hBlendBrush = pimldp->fStyle & ILD_BLEND50 ?
    371         himlLocal->hbrBlend50 : himlLocal->hbrBlend25;
    372 
    373     hBlendMaskBitmap = CreateBitmap(cx, cy, 1, 1, NULL);
    374     hOldBitmap = SelectObject(hBlendMaskDC, hBlendMaskBitmap);
    375 
    376     hOldBrush = (HBRUSH) SelectObject(hBlendMaskDC, hBlendBrush);
    377     PatBlt(hBlendMaskDC, 0, 0, cx, cy, PATCOPY);
    378     SelectObject(hBlendMaskDC, hOldBrush);
    379 
    380     /* Modify the blend mask if an Image Mask exist
    381     */
    382     if(pimldp->himl->hbmMask != 0)
    383     {
    384         HBITMAP hOldMaskBitmap;
    385         hMaskDC = CreateCompatibleDC(0);
    386         hOldMaskBitmap = (HBITMAP) SelectObject(hMaskDC, himlLocal->hbmMask);
    387 
    388         BitBlt(hBlendMaskDC,
    389             0,0, cx, cy,
    390             hMaskDC,
    391             himlLocal->cx * pimldp->i,0,
    392             0x220326); /* NOTSRCAND */
    393 
    394         BitBlt(hBlendMaskDC,
    395             0,0, cx, cy,
    396             hBlendMaskDC,
    397             0,0,
    398             NOTSRCCOPY);
    399 
    400         SelectObject(hMaskDC, hOldMaskBitmap);
    401         DeleteDC(hMaskDC);
    402 
    403     }
    404     /* Apply blend to the current image given the BlendMask
    405     */
    406     OldTextColor = SetTextColor(pimldp->hdcDst, 0);
    407     OldBkColor = SetBkColor(pimldp->hdcDst, RGB(255,255,255));
    408     hBlendColorBrush = CreateSolidBrush(clrBlend);
    409     hOldBrush = (HBRUSH) SelectObject (pimldp->hdcDst, hBlendColorBrush);
    410 
    411     BitBlt (pimldp->hdcDst,
    412         pimldp->x, pimldp->y, cx, cy,
    413         hBlendMaskDC,
    414         0, 0,
    415         0xB8074A); /* PSDPxax */
    416 
    417     SelectObject(pimldp->hdcDst, hOldBrush);
    418     SetTextColor(pimldp->hdcDst, OldTextColor);
    419     SetBkColor(pimldp->hdcDst, OldBkColor);
    420     SelectObject(hBlendMaskDC, hOldBitmap);
    421     DeleteDC(hBlendMaskDC);
    422     DeleteObject(hBlendMaskBitmap);
    423     DeleteObject(hBlendColorBrush);
    424 }
    425 
    426 /*************************************************************************
    427  * IMAGELIST_InternalDrawOverlay [Internal]
    428  *
    429  * Draws the overlay image
    430  *
    431  * PARAMS
    432  *     pimldp        [I] pointer to IMAGELISTDRAWPARAMS structure.
    433  *     cx            [I] the width of the image to display
    434  *     cy............[I] the height of the image to display
    435  *
    436  * RETURNS
    437  *     nothing
    438  *
    439  * NOTES
    440  *     This functions is used by ImageList_DrawIndirect, when it is
    441  *     required to draw the overlay
    442  *
    443  *     
    444  */
    445 static VOID
    446 IMAGELIST_InternalDrawOverlay(IMAGELISTDRAWPARAMS *pimldp, INT cx, INT cy)
    447 {
    448     INT     nOvlIdx;
    449     HDC     hImageDC;
    450     HBITMAP hOldBitmap;
    451 
    452     nOvlIdx = (pimldp->fStyle & ILD_OVERLAYMASK) >> 8;
    453     if ((nOvlIdx >= 1) && (nOvlIdx <= MAX_OVERLAYIMAGE))
    454     {
    455         nOvlIdx = pimldp->himl->nOvlIdx[nOvlIdx - 1];
    456         if ((nOvlIdx >= 0) && (nOvlIdx <= pimldp->himl->cCurImage))
    457         {
    458             hImageDC = CreateCompatibleDC(0);
    459             if (pimldp->himl->hbmMask)
    460             {
    461                 hOldBitmap = (HBITMAP) SelectObject (hImageDC,
    462                     pimldp->himl->hbmMask);
    463 
    464                 BitBlt (pimldp->hdcDst,
    465                     pimldp->x, pimldp->y, cx, cy,
    466                     hImageDC, pimldp->himl->cx * nOvlIdx, 0,
    467                     SRCAND);
    468 
    469                 SelectObject(hImageDC, hOldBitmap);
    470             }
    471             hOldBitmap = (HBITMAP) SelectObject (hImageDC,
    472                 pimldp->himl->hbmImage);
    473 
    474             BitBlt (pimldp->hdcDst,
    475                 pimldp->x, pimldp->y, cx, cy,
    476                 hImageDC,
    477                 pimldp->himl->cx * nOvlIdx, 0,
    478                 SRCPAINT);
    479 
    480             SelectObject(hImageDC, hOldBitmap);
    481             DeleteDC(hImageDC);
    482         }
    483     }
    484 }
    485 
    486 
    487 /*************************************************************************
    488  * ImageList_Add [COMCTL32.40]
     151 * ImageList_Add [COMCTL32.@]
    489152 *
    490153 * Add an image or images to an image list.
     
    509172    HBITMAP hOldBitmapImage, hOldBitmap;
    510173
    511     TRACE("himl=%p hbmimage=%x hbmmask=%x\n", himl, hbmImage, hbmMask);
     174    TRACE("himl=%p hbmimage=%p hbmmask=%p\n", himl, hbmImage, hbmMask);
    512175    if (!himl || !hbmImage)
    513176        return -1;
     
    533196    if(himl->hbmMask)
    534197    {
    535         HDC hdcMask, hdcTemp, hOldBitmapMask, hOldBitmapTemp;
     198        HDC hdcMask, hdcTemp;
     199        HBITMAP hOldBitmapMask, hOldBitmapTemp;
    536200
    537201        hdcMask   = CreateCompatibleDC (0);
    538202        hdcTemp   = CreateCompatibleDC(0);
    539         hOldBitmapMask = (HBITMAP) SelectObject(hdcMask, himl->hbmMask);
    540         hOldBitmapTemp = (HBITMAP) SelectObject(hdcTemp, hbmMask);
    541 
    542         BitBlt (hdcMask, 
     203        hOldBitmapMask = SelectObject(hdcMask, himl->hbmMask);
     204        hOldBitmapTemp = SelectObject(hdcTemp, hbmMask);
     205
     206        BitBlt (hdcMask,
    543207            nStartX, 0, bmp.bmWidth, bmp.bmHeight,
    544             hdcTemp, 
    545             0, 0, 
     208            hdcTemp,
     209            0, 0,
    546210            SRCCOPY);
    547211
     
    551215        /* Remove the background from the image
    552216        */
    553         BitBlt (hdcImage, 
     217        BitBlt (hdcImage,
    554218            nStartX, 0, bmp.bmWidth, bmp.bmHeight,
    555             hdcMask, 
    556             nStartX, 0, 
     219            hdcMask,
     220            nStartX, 0,
    557221            0x220326); /* NOTSRCAND */
    558222
     
    574238
    575239/*************************************************************************
    576  * ImageList_AddIcon [COMCTL32.41]
     240 * ImageList_AddIcon [COMCTL32.@]
    577241 *
    578242 * Adds an icon to an image list.
     
    595259
    596260/*************************************************************************
    597  * ImageList_AddMasked [COMCTL32.42]
     261 * ImageList_AddMasked [COMCTL32.@]
    598262 *
    599263 * Adds an image or images to an image list and creates a mask from the
     
    620284    COLORREF bkColor;
    621285
    622     TRACE("himl=%p hbitmap=%x clrmask=%lx\n", himl, hBitmap, clrMask);
     286    TRACE("himl=%p hbitmap=%p clrmask=%lx\n", himl, hBitmap, clrMask);
    623287    if (himl == NULL)
    624288        return -1;
     
    660324        GetPixel (hdcBitmap, 0, 0);
    661325    SetBkColor (hdcBitmap, bkColor);
    662     BitBlt (hdcMask, 
     326    BitBlt (hdcMask,
    663327        nMaskXOffset, 0, bmp.bmWidth, bmp.bmHeight,
    664         hdcBitmap, 0, 0, 
     328        hdcBitmap, 0, 0,
    665329        SRCCOPY);
    666330
     
    677341        This is here in case some apps rely on this bug
    678342    */
    679     BitBlt(hdcBitmap, 
     343    BitBlt(hdcBitmap,
    680344        0, 0, bmp.bmWidth, bmp.bmHeight,
    681         hdcMask, 
    682         nMaskXOffset, 0, 
     345        hdcMask,
     346        nMaskXOffset, 0,
    683347        0x220326); /* NOTSRCAND */
    684348    /* Copy result to the imagelist
    685349    */
    686     BitBlt (hdcImage, 
     350    BitBlt (hdcImage,
    687351        nIndex * himl->cx, 0, bmp.bmWidth, bmp.bmHeight,
    688         hdcBitmap, 
    689         0, 0, 
     352        hdcBitmap,
     353        0, 0,
    690354        SRCCOPY);
    691355    /* Clean up
     
    707371
    708372/*************************************************************************
    709  * ImageList_BeginDrag [COMCTL32.43]
     373 * ImageList_BeginDrag [COMCTL32.@]
    710374 *
    711375 * Creates a temporary image list that contains one image. It will be used
     
    744408    InternalDrag.himl = ImageList_Create (cx, cy, himlTrack->flags, 1, 1);
    745409    if (InternalDrag.himl == NULL) {
    746         ERR("Error creating drag image list!\n");
     410        WARN("Error creating drag image list!\n");
    747411        return FALSE;
    748412    }
     
    775439
    776440/*************************************************************************
    777  * ImageList_Copy [COMCTL32.44]
    778  *
    779  *  Copies an image of the source image list to an image of the 
     441 * ImageList_Copy [COMCTL32.@]
     442 *
     443 *  Copies an image of the source image list to an image of the
    780444 *  destination image list. Images can be copied or swapped.
    781445 *
     
    801465                INT iSrc, INT uFlags)
    802466{
    803     HDC hdcSrc, hdcDst;   
     467    HDC hdcSrc, hdcDst;
    804468
    805469    TRACE("iDst=%d  iSrc=%d\n", iDst, iSrc);
     
    903567
    904568/*************************************************************************
    905  * ImageList_Create [COMCTL32.45]  Creates a new image list.
     569 * ImageList_Create [COMCTL32.@]  Creates a new image list.
    906570 *
    907571 * PARAMS
     
    925589    INT      nCount;
    926590    HBITMAP  hbmTemp;
    927     static WORD aBitBlend25[] = 
     591    static WORD aBitBlend25[] =
    928592        {0xAA, 0x00, 0x55, 0x00, 0xAA, 0x00, 0x55, 0x00};
    929593
     
    968632    else
    969633        himl->hbmImage = 0;
    970    
    971     if ( (himl->cMaxImage > 0) && (himl->flags & ILC_MASK)) {
    972         himl->hbmMask = CreateBitmap (himl->cx * himl->cMaxImage, himl->cy,
     634
     635    if ( (himl->flags & ILC_MASK)) {
     636        int images = himl->cMaxImage;
     637        if (images <= 0)
     638            images = 1;
     639
     640        himl->hbmMask = CreateBitmap (himl->cx * images, himl->cy,
    973641                                        1, 1, NULL);
    974642        if (himl->hbmMask == 0) {
     
    997665
    998666/*************************************************************************
    999  * ImageList_Destroy [COMCTL32.46]
     667 * ImageList_Destroy [COMCTL32.@]
    1000668 *
    1001669 * Destroys an image list.
     
    1011679BOOL WINAPI
    1012680ImageList_Destroy (HIMAGELIST himl)
    1013 { 
     681{
    1014682    if (!himl)
    1015683        return FALSE;
     
    1026694    if (himl->hbrBlend50)
    1027695        DeleteObject (himl->hbrBlend50);
    1028        
     696
    1029697    COMCTL32_Free (himl);
    1030698
     
    1034702
    1035703/*************************************************************************
    1036  * ImageList_DragEnter [COMCTL32.47]
     704 * ImageList_DragEnter [COMCTL32.@]
    1037705 *
    1038706 * Locks window update and displays the drag image at the given position.
     
    1055723ImageList_DragEnter (HWND hwndLock, INT x, INT y)
    1056724{
    1057     TRACE("(hwnd=%#x x=%d y=%d)\n", hwndLock, x, y);
     725    TRACE("(hwnd=%p x=%d y=%d)\n", hwndLock, x, y);
    1058726
    1059727    if (InternalDrag.himl == NULL)
     
    1078746
    1079747/*************************************************************************
    1080  * ImageList_DragLeave [COMCTL32.48]
     748 * ImageList_DragLeave [COMCTL32.@]
    1081749 *
    1082750 * Unlocks window update and hides the drag image.
     
    1111779
    1112780/*************************************************************************
    1113  * ImageList_DragMove [COMCTL32.49]
     781 * ImageList_InternalDragDraw [Internal]
     782 *
     783 * Draws the drag image.
     784 *
     785 * PARAMS
     786 *     hdc [I] device context to draw into.
     787 *     x   [I] X position of the drag image.
     788 *     y   [I] Y position of the drag image.
     789 *
     790 * RETURNS
     791 *     Success: TRUE
     792 *     Failure: FALSE
     793 *
     794 * NOTES
     795 *     The position of the drag image is relative to the window, not
     796 *     the client area.
     797 *
     798 */
     799
     800static inline void
     801ImageList_InternalDragDraw (HDC hdc, INT x, INT y)
     802{
     803    IMAGELISTDRAWPARAMS imldp;
     804
     805    ZeroMemory (&imldp, sizeof(imldp));
     806    imldp.cbSize  = sizeof(imldp);
     807    imldp.himl    = InternalDrag.himl;
     808    imldp.i       = 0;
     809    imldp.hdcDst  = hdc,
     810    imldp.x       = x;
     811    imldp.y       = y;
     812    imldp.rgbBk   = CLR_DEFAULT;
     813    imldp.rgbFg   = CLR_DEFAULT;
     814    imldp.fStyle  = ILD_NORMAL;
     815    imldp.fState  = ILS_ALPHA;
     816    imldp.Frame   = 128;
     817
     818    /* FIXME: instead of using the alpha blending, we should
     819     * create a 50% mask, and draw it semitransparantly that way */
     820    ImageList_DrawIndirect (&imldp);
     821}
     822
     823/*************************************************************************
     824 * ImageList_DragMove [COMCTL32.@]
    1114825 *
    1115826 * Moves the drag image.
     
    1150861        INT origRegX, origRegY;
    1151862        INT sizeRegX, sizeRegY;
    1152        
     863
    1153864
    1154865        /* calculate the update region */
     
    1182893               hdcOffScreen, origNewX - origRegX, origNewY - origRegY, SRCCOPY);
    1183894        /* draw the image */
    1184         /* FIXME: image should be drawn semitransparent */
    1185         ImageList_Draw(InternalDrag.himl, 0, hdcOffScreen, origNewX - origRegX,
    1186                        origNewY - origRegY, ILD_NORMAL);
     895        ImageList_InternalDragDraw(hdcOffScreen, origNewX - origRegX,
     896                                   origNewY - origRegY);
    1187897        /* draw the update region to the screen */
    1188898        BitBlt(hdcDrag, origRegX, origRegY, sizeRegX, sizeRegY,
     
    1204914
    1205915/*************************************************************************
    1206  * ImageList_DragShowNolock [COMCTL32.50]
     916 * ImageList_DragShowNolock [COMCTL32.@]
    1207917 *
    1208918 * Shows or hides the drag image.
     
    1249959    }
    1250960    SelectObject(hdcBg, InternalDrag.hbmBg);
    1251    
     961
    1252962    if (bShow) {
    1253963        /* save the background */
     
    1255965               hdcDrag, x, y, SRCCOPY);
    1256966        /* show the image */
    1257         /* FIXME: this should be drawn semitransparent */
    1258         ImageList_Draw(InternalDrag.himl, 0, hdcDrag, x, y, ILD_NORMAL);
    1259     } else {
     967        ImageList_InternalDragDraw(hdcDrag, x, y);
     968    } else {
    1260969        /* hide the image */
    1261970        BitBlt(hdcDrag, x, y, InternalDrag.himl->cx, InternalDrag.himl->cy,
     
    1272981
    1273982/*************************************************************************
    1274  * ImageList_Draw [COMCTL32.51] Draws an image.
     983 * ImageList_Draw [COMCTL32.@] Draws an image.
    1275984 *
    1276985 * PARAMS
     
    1286995 *     Failure: FALSE
    1287996 *
    1288  * NOTES
    1289  *     Calls ImageList_DrawIndirect.
    1290  *
    1291997 * SEE
    1292  *     ImageList_DrawIndirect.
     998 *     ImageList_DrawEx.
    1293999 */
    12941000
    12951001BOOL WINAPI
    1296 ImageList_Draw (HIMAGELIST himl, INT i, HDC hdc,
    1297                 INT x, INT y, UINT fStyle)
    1298 {
    1299     IMAGELISTDRAWPARAMS imldp;
    1300 
    1301     imldp.cbSize  = sizeof(IMAGELISTDRAWPARAMS);
    1302     imldp.himl    = himl;
    1303     imldp.i       = i;
    1304     imldp.hdcDst  = hdc,
    1305     imldp.x       = x;
    1306     imldp.y       = y;
    1307     imldp.cx      = 0;
    1308     imldp.cy      = 0;
    1309     imldp.xBitmap = 0;
    1310     imldp.yBitmap = 0;
    1311     imldp.rgbBk   = CLR_DEFAULT;
    1312     imldp.rgbFg   = CLR_DEFAULT;
    1313     imldp.fStyle  = fStyle;
    1314     imldp.dwRop   = 0;
    1315 
    1316     return ImageList_DrawIndirect (&imldp);
    1317 }
    1318 
    1319 
    1320 /*************************************************************************
    1321  * ImageList_DrawEx [COMCTL32.52]
     1002ImageList_Draw (HIMAGELIST himl, INT i, HDC hdc, INT x, INT y, UINT fStyle)
     1003{
     1004    return ImageList_DrawEx (himl, i, hdc, x, y, 0, 0,
     1005                             CLR_DEFAULT, CLR_DEFAULT, fStyle);
     1006}
     1007
     1008
     1009/*************************************************************************
     1010 * ImageList_DrawEx [COMCTL32.@]
    13221011 *
    13231012 * Draws an image and allows to use extended drawing features.
     
    13291018 *     x      [I] X position
    13301019 *     y      [I] Y position
    1331  *     xOffs  [I] X offset
    1332  *     yOffs  [I] Y offset
     1020 *     dx     [I] X offset
     1021 *     dy     [I] Y offset
    13331022 *     rgbBk  [I] background color
    13341023 *     rgbFg  [I] foreground color
     
    13531042    IMAGELISTDRAWPARAMS imldp;
    13541043
    1355     imldp.cbSize  = sizeof(IMAGELISTDRAWPARAMS);
     1044    ZeroMemory (&imldp, sizeof(imldp));
     1045    imldp.cbSize  = sizeof(imldp);
    13561046    imldp.himl    = himl;
    13571047    imldp.i       = i;
     
    13611051    imldp.cx      = dx;
    13621052    imldp.cy      = dy;
    1363     imldp.xBitmap = 0;
    1364     imldp.yBitmap = 0;
    13651053    imldp.rgbBk   = rgbBk;
    13661054    imldp.rgbFg   = rgbFg;
    13671055    imldp.fStyle  = fStyle;
    1368     imldp.dwRop   = 0;
    13691056
    13701057    return ImageList_DrawIndirect (&imldp);
     
    13731060
    13741061/*************************************************************************
    1375  * ImageList_DrawIndirect [COMCTL32.53]
     1062 * ImageList_DrawIndirect [COMCTL32.@]
    13761063 *
    13771064 * Draws an image using ...
     
    13881075ImageList_DrawIndirect (IMAGELISTDRAWPARAMS *pimldp)
    13891076{
    1390     INT      cx, cy;   
    1391     /*
    1392         Do some Error Checking
    1393     */
    1394     if (pimldp == NULL)
    1395         return FALSE;
    1396     if (pimldp->cbSize < sizeof(IMAGELISTDRAWPARAMS))
    1397         return FALSE;
    1398     if (pimldp->himl == NULL)
    1399         return FALSE;
    1400     if ((pimldp->i < 0) || (pimldp->i >= pimldp->himl->cCurImage)) {
    1401         ERR("%d not within range (max %d)\n",pimldp->i,pimldp->himl->cCurImage-1);
    1402         return FALSE;
    1403     }
     1077    INT cx, cy, nOvlIdx;
     1078    DWORD fState, dwRop;
     1079    UINT fStyle;
     1080    COLORREF clrBk, oldImageBk, oldImageFg;
     1081    HDC hImageDC, hImageListDC, hMaskListDC;
     1082    HBITMAP hImageBmp, hOldImageBmp, hOldImageListBmp, hOldMaskListBmp, hBlendMaskBmp;
     1083    BOOL bIsTransparent, bBlend, bResult = FALSE;
     1084    const HIMAGELIST himl = pimldp->himl;
     1085    const INT lx = himl->cx * pimldp->i + pimldp->xBitmap;
     1086    const INT ly = pimldp->yBitmap;
     1087   
     1088    if (!pimldp || !himl) return FALSE;
     1089    if ((pimldp->i < 0) || (pimldp->i >= himl->cCurImage)) return FALSE;
     1090   
     1091    fState = pimldp->cbSize < sizeof(IMAGELISTDRAWPARAMS) ? ILS_NORMAL : pimldp->fState;
     1092    fStyle = pimldp->fStyle & ~ILD_OVERLAYMASK;
     1093    cx = (pimldp->cx == 0) ? himl->cx : pimldp->cx;
     1094    cy = (pimldp->cy == 0) ? himl->cy : pimldp->cy;
     1095    clrBk = (pimldp->rgbBk == CLR_DEFAULT) ? himl->clrBk : pimldp->rgbBk;
     1096    bIsTransparent = (fStyle & ILD_TRANSPARENT) || clrBk == CLR_NONE;
     1097    bBlend = fStyle & (ILD_BLEND25 | ILD_BLEND50);
     1098
     1099    TRACE("hbmMask(%p) iImage(%d) x(%d) y(%d) cx(%d) cy(%d)\n",
     1100          himl->hbmMask, pimldp->i, pimldp->x, pimldp->y, cx, cy);
     1101
     1102    /* we will use these DCs to access the images and masks in the ImageList */
     1103    hImageListDC = CreateCompatibleDC(0);
     1104    hMaskListDC = himl->hbmMask ? CreateCompatibleDC(0) : 0;
     1105
     1106    /* these will accumulate the image and mask for the image we're drawing */
     1107    hImageDC = CreateCompatibleDC( pimldp->hdcDst );
     1108    hImageBmp = CreateCompatibleBitmap( pimldp->hdcDst, cx, cy );
     1109    hBlendMaskBmp = bBlend ? CreateBitmap(cx, cy, 1, 1, NULL) : 0;
     1110
     1111    /* Create a compatible DC. */
     1112    if (!hImageListDC || !hImageDC || !hImageBmp ||
     1113        (bBlend && !hBlendMaskBmp) || (himl->hbmMask && !hMaskListDC))
     1114        goto cleanup;
     1115   
     1116    hOldImageListBmp = SelectObject(hImageListDC, himl->hbmImage);
     1117    hOldImageBmp = SelectObject(hImageDC, hImageBmp);
     1118    hOldMaskListBmp = hMaskListDC ? SelectObject(hMaskListDC, himl->hbmMask) : 0;
     1119 
    14041120    /*
    1405         Get the Height and Width to display
    1406     */
    1407     cx = (pimldp->cx == 0) ? pimldp->himl->cx : pimldp->cx;
    1408     cy = (pimldp->cy == 0) ? pimldp->himl->cy : pimldp->cy;
     1121     * To obtain a transparent look, background color should be set
     1122     * to white and foreground color to black when blting the
     1123     * monochrome mask.
     1124     */
     1125    oldImageFg = SetTextColor( hImageDC, RGB( 0, 0, 0 ) );
     1126    oldImageBk = SetBkColor( hImageDC, RGB( 0xff, 0xff, 0xff ) );
     1127
    14091128    /*
    1410         Draw the image
    1411     */
    1412     if(pimldp->himl->hbmMask != 0)
    1413     {
    1414         IMAGELIST_InternalDrawMask(pimldp, cx, cy);
    1415     }
    1416     else
    1417     {
    1418         IMAGELIST_InternalDraw(pimldp, cx, cy);
    1419     }
    1420     /*
    1421         Apply the blend if needed to the Image
    1422     */
    1423     if((pimldp->fStyle & ILD_BLEND50)
    1424         || (pimldp->fStyle & ILD_BLEND25))
    1425     {
    1426         IMAGELIST_InternalDrawBlend(pimldp, cx, cy);
    1427     }
    1428     /*
    1429         Apply the Overlay if needed
    1430     */
    1431     if (pimldp->fStyle & ILD_OVERLAYMASK)
    1432     {
    1433         IMAGELIST_InternalDrawOverlay(pimldp, cx, cy);
    1434     }
    1435 
    1436     return TRUE;
    1437 }
    1438 
    1439 
    1440 /*************************************************************************
    1441  * ImageList_Duplicate [COMCTL32.54] Duplicates an image list.
     1129     * Draw the initial image
     1130     */
     1131    if(fStyle & ILD_MASK) {
     1132        if (himl->hbmMask) {
     1133            BitBlt(hImageDC, 0, 0, cx, cy, hMaskListDC, lx, ly, SRCCOPY);
     1134        } else {
     1135            HBRUSH hOldBrush = SelectObject (hImageDC, GetStockObject(BLACK_BRUSH));
     1136            PatBlt( hImageDC, 0, 0, cx, cy, PATCOPY);
     1137            SelectObject(hImageDC, hOldBrush);
     1138        }
     1139    } else if (himl->hbmMask && !bIsTransparent) {
     1140        /* blend the image with the needed solid background */
     1141        HBRUSH hOldBrush = SelectObject (hImageDC, CreateSolidBrush (clrBk));
     1142        PatBlt( hImageDC, 0, 0, cx, cy, PATCOPY );
     1143        BitBlt( hImageDC, 0, 0, cx, cy, hMaskListDC, lx, ly, SRCAND );
     1144        BitBlt( hImageDC, 0, 0, cx, cy, hImageListDC, lx, ly, SRCPAINT );
     1145        DeleteObject (SelectObject (hImageDC, hOldBrush));
     1146    } else {
     1147        /* start off with the image, if we have a mask, we'll use it later */
     1148        BitBlt( hImageDC, 0, 0, cx, cy, hImageListDC, lx, ly, SRCCOPY);
     1149    }
     1150 
     1151    /* Time for blending, if required */
     1152    if (bBlend) {
     1153        HBRUSH hBlendBrush, hOldBrush;
     1154        COLORREF clrBlend = pimldp->rgbFg;
     1155        HDC hBlendMaskDC = hImageListDC;
     1156        HBITMAP hOldBitmap;
     1157
     1158        /* Create the blend Mask */
     1159        hOldBitmap = SelectObject(hBlendMaskDC, hBlendMaskBmp);
     1160        hBlendBrush = fStyle & ILD_BLEND50 ? himl->hbrBlend50 : himl->hbrBlend25;
     1161        hOldBrush = (HBRUSH) SelectObject(hBlendMaskDC, hBlendBrush);
     1162        PatBlt(hBlendMaskDC, 0, 0, cx, cy, PATCOPY);
     1163        SelectObject(hBlendMaskDC, hOldBrush);
     1164
     1165        /* Modify the blend mask if an Image Mask exist */
     1166        if(himl->hbmMask) {
     1167            BitBlt(hBlendMaskDC, 0, 0, cx, cy, hMaskListDC, lx, ly, 0x220326); /* NOTSRCAND */
     1168            BitBlt(hBlendMaskDC, 0, 0, cx, cy, hBlendMaskDC, 0, 0, NOTSRCCOPY);
     1169        }
     1170       
     1171        /* now apply blend to the current image given the BlendMask */
     1172        if (clrBlend == CLR_DEFAULT) clrBlend = GetSysColor (COLOR_HIGHLIGHT);
     1173        else if (clrBlend == CLR_NONE) clrBlend = GetTextColor (pimldp->hdcDst);
     1174        hOldBrush = (HBRUSH) SelectObject (hImageDC, CreateSolidBrush(clrBlend));
     1175        BitBlt (hImageDC, 0, 0, cx, cy, hBlendMaskDC, 0, 0, 0xB8074A); /* PSDPxax */
     1176        DeleteObject(SelectObject(hImageDC, hOldBrush));
     1177        SelectObject(hBlendMaskDC, hOldBitmap);
     1178    }
     1179   
     1180    /* Now do the overlay image, if any */
     1181    nOvlIdx = (pimldp->fStyle & ILD_OVERLAYMASK) >> 8;
     1182    if ( (nOvlIdx >= 1) && (nOvlIdx <= MAX_OVERLAYIMAGE)) {
     1183        nOvlIdx = himl->nOvlIdx[nOvlIdx - 1];
     1184        if ((nOvlIdx >= 0) && (nOvlIdx < himl->cCurImage)) {
     1185            const INT ox = himl->cx * nOvlIdx + pimldp->xBitmap;
     1186            if (himl->hbmMask && !(fStyle & ILD_IMAGE))
     1187                BitBlt (hImageDC, 0, 0, cx, cy, hMaskListDC, ox, ly, SRCAND);
     1188            BitBlt (hImageDC, 0, 0, cx, cy, hImageListDC, ox, ly, SRCPAINT);
     1189        }
     1190    }
     1191
     1192    if (fState & ILS_SATURATE) FIXME("ILS_SATURATE: unimplemented!\n");
     1193    if (fState & ILS_GLOW) FIXME("ILS_GLOW: unimplemented!\n");
     1194    if (fState & ILS_SHADOW) FIXME("ILS_SHADOW: unimplemented!\n");
     1195    if (fState & ILS_ALPHA) FIXME("ILS_SHADOW: unimplemented!\n");
     1196
     1197    if (fStyle & ILD_PRESERVEALPHA) FIXME("ILD_PRESERVEALPHA: unimplemented!\n");
     1198    if (fStyle & ILD_SCALE) FIXME("ILD_SCALE: unimplemented!\n");
     1199    if (fStyle & ILD_DPISCALE) FIXME("ILD_DPISCALE: unimplemented!\n");
     1200   
     1201    /* now copy the image to the screen */
     1202    dwRop = SRCCOPY;
     1203    if (himl->hbmMask && bIsTransparent && !(fStyle & ILD_MASK)) {
     1204        COLORREF oldDstFg = SetTextColor(pimldp->hdcDst, RGB( 0, 0, 0 ) );
     1205        COLORREF oldDstBk = SetBkColor(pimldp->hdcDst, RGB( 0xff, 0xff, 0xff ));
     1206        BitBlt (pimldp->hdcDst, pimldp->x,  pimldp->y, cx, cy, hMaskListDC, lx, ly, SRCAND);
     1207        SetBkColor(pimldp->hdcDst, oldDstBk);
     1208        SetTextColor(pimldp->hdcDst, oldDstFg);
     1209        dwRop = SRCPAINT;
     1210    }
     1211    if (fStyle & ILD_ROP) dwRop = pimldp->dwRop;
     1212    BitBlt (pimldp->hdcDst, pimldp->x,  pimldp->y, cx, cy, hImageDC, 0, 0, dwRop);
     1213
     1214    bResult = TRUE;
     1215   
     1216    /* cleanup the mess */
     1217    SetBkColor(hImageDC, oldImageBk);
     1218    SetTextColor(hImageDC, oldImageFg);
     1219    SelectObject(hImageDC, hOldImageBmp);
     1220    SelectObject(hImageListDC, hOldImageListBmp);
     1221    if (hMaskListDC) SelectObject(hMaskListDC, hOldMaskListBmp);
     1222cleanup:
     1223    DeleteObject(hBlendMaskBmp);
     1224    DeleteObject(hImageBmp);
     1225    DeleteObject(hImageDC);
     1226    DeleteObject(hImageListDC);
     1227    DeleteObject(hMaskListDC);
     1228
     1229    return bResult;
     1230}
     1231
     1232
     1233/*************************************************************************
     1234 * ImageList_Duplicate [COMCTL32.@] Duplicates an image list.
    14421235 *
    14431236 * PARAMS
     
    14911284
    14921285/*************************************************************************
    1493  * ImageList_EndDrag [COMCTL32.55] Finishes a drag operation.
     1286 * ImageList_EndDrag [COMCTL32.@] Finishes a drag operation.
    14941287 *
    14951288 * Finishes a drag operation.
     
    15241317
    15251318/*************************************************************************
    1526  * ImageList_GetBkColor [COMCTL32.56]
     1319 * ImageList_GetBkColor [COMCTL32.@]
    15271320 *
    15281321 * Returns the background color of an image list.
     
    15391332ImageList_GetBkColor (HIMAGELIST himl)
    15401333{
    1541     if (himl == NULL)
    1542         return CLR_NONE;
    1543 
    1544     return himl->clrBk;
    1545 }
    1546 
    1547 
    1548 /*************************************************************************
    1549  * ImageList_GetDragImage [COMCTL32.57]
     1334    return himl ? himl->clrBk : CLR_NONE;
     1335}
     1336
     1337
     1338/*************************************************************************
     1339 * ImageList_GetDragImage [COMCTL32.@]
    15501340 *
    15511341 * Returns the handle to the internal drag image list.
     
    15801370
    15811371/*************************************************************************
    1582  * ImageList_GetFlags [COMCTL32.58]
     1372 * ImageList_GetFlags [COMCTL32.@]
    15831373 *
    15841374 * BUGS
     
    15951385
    15961386/*************************************************************************
    1597  * ImageList_GetIcon [COMCTL32.59]
     1387 * ImageList_GetIcon [COMCTL32.@]
    15981388 *
    15991389 * Creates an icon from a masked image of an image list.
     
    16131403{
    16141404    ICONINFO ii;
    1615     HICON  hIcon;
    1616     HBITMAP hOldSrcBitmap,hOldDstBitmap;
    1617     HDC    hdcSrc, hdcDst;
    1618 
    1619     if ((himl == NULL) || (i < 0) || (i >= himl->cCurImage)) {
    1620         FIXME("(%p,%d,%x), params out of range!\n",himl,i,fStyle);
    1621         return 0;
    1622    }
    1623 
    1624     hdcSrc = CreateCompatibleDC(0);
     1405    HICON hIcon;
     1406    HBITMAP hOldDstBitmap;
     1407    HDC hdcDst;
     1408
     1409    if ((himl == NULL) || (i < 0) || (i >= himl->cCurImage)) return 0;
     1410
    16251411    hdcDst = CreateCompatibleDC(0);
    16261412
    16271413    ii.fIcon = TRUE;
     1414
     1415    /* draw mask*/
    16281416    ii.hbmMask  = CreateCompatibleBitmap (hdcDst, himl->cx, himl->cy);
    1629 
    1630     /* draw mask*/
    16311417    hOldDstBitmap = (HBITMAP)SelectObject (hdcDst, ii.hbmMask);
    1632     if (himl->hbmMask) {
    1633         SelectObject (hdcSrc, himl->hbmMask);
    1634         BitBlt (hdcDst, 0, 0, himl->cx, himl->cy,
    1635                   hdcSrc, i * himl->cx, 0, SRCCOPY);
    1636     }
    1637     else
    1638         PatBlt (hdcDst, 0, 0, himl->cx, himl->cy, BLACKNESS);
     1418    ImageList_Draw(himl, i, hdcDst, 0, 0, ILD_MASK);
    16391419
    16401420    /* draw image*/
    1641     hOldSrcBitmap = (HBITMAP)SelectObject (hdcSrc, himl->hbmImage);
    1642     ii.hbmColor = CreateCompatibleBitmap (hdcSrc, himl->cx, himl->cy);
     1421    SelectObject (hdcDst, himl->hbmImage);
     1422    ii.hbmColor = CreateCompatibleBitmap (hdcDst, himl->cx, himl->cy);
    16431423    SelectObject (hdcDst, ii.hbmColor);
    1644     BitBlt (hdcDst, 0, 0, himl->cx, himl->cy,
    1645               hdcSrc, i * himl->cx, 0, SRCCOPY);
     1424    ImageList_Draw(himl, i, hdcDst, 0, 0, fStyle);
    16461425
    16471426    /*
    16481427     * CreateIconIndirect requires us to deselect the bitmaps from
    1649      * the DCs before calling 
     1428     * the DCs before calling
    16501429     */
    1651     SelectObject(hdcSrc, hOldSrcBitmap);
    16521430    SelectObject(hdcDst, hOldDstBitmap);
    16531431
    1654     hIcon = CreateIconIndirect (&ii);   
    1655 
    1656     DeleteDC (hdcSrc);
    1657     DeleteDC (hdcDst);
     1432    hIcon = CreateIconIndirect (&ii);
     1433
    16581434    DeleteObject (ii.hbmMask);
    16591435    DeleteObject (ii.hbmColor);
     1436    DeleteDC (hdcDst);
    16601437
    16611438    return hIcon;
     
    16641441
    16651442/*************************************************************************
    1666  * ImageList_GetIconSize [COMCTL32.60]
     1443 * ImageList_GetIconSize [COMCTL32.@]
    16671444 *
    16681445 * Retrieves the size of an image in an image list.
     
    16991476
    17001477/*************************************************************************
    1701  * ImageList_GetImageCount [COMCTL32.61]
     1478 * ImageList_GetImageCount [COMCTL32.@]
    17021479 *
    17031480 * Returns the number of images in an image list.
     
    17221499
    17231500/*************************************************************************
    1724  * ImageList_GetImageInfo [COMCTL32.62]
     1501 * ImageList_GetImageInfo [COMCTL32.@]
    17251502 *
    17261503 * Returns information about an image in an image list.
     
    17461523    pImageInfo->hbmImage = himl->hbmImage;
    17471524    pImageInfo->hbmMask  = himl->hbmMask;
    1748    
     1525
    17491526    pImageInfo->rcImage.top    = 0;
    17501527    pImageInfo->rcImage.bottom = himl->cy;
    17511528    pImageInfo->rcImage.left   = i * himl->cx;
    17521529    pImageInfo->rcImage.right  = (i+1) * himl->cx;
    1753    
     1530
    17541531    return TRUE;
    17551532}
     
    17571534
    17581535/*************************************************************************
    1759  * ImageList_GetImageRect [COMCTL32.63]
     1536 * ImageList_GetImageRect [COMCTL32.@]
    17601537 *
    17611538 * Retrieves the rectangle of the specified image in an image list.
     
    17921569
    17931570/*************************************************************************
    1794  * ImageList_LoadImage  [COMCTL32.64]
    1795  * ImageList_LoadImageA [COMCTL32.65]
     1571 * ImageList_LoadImage  [COMCTL32.@]
     1572 * ImageList_LoadImageA [COMCTL32.@]
    17961573 *
    17971574 * Creates an image list from a bitmap, icon or cursor.
     
    18561633        GetIconInfo (handle, &ii);
    18571634        GetObjectA (ii.hbmColor, sizeof(BITMAP), (LPVOID)&bmp);
    1858         himl = ImageList_Create (bmp.bmWidth, bmp.bmHeight, 
     1635        himl = ImageList_Create (bmp.bmWidth, bmp.bmHeight,
    18591636                                 ILC_MASK | ILC_COLOR, 1, cGrow);
    18601637        ImageList_Add (himl, ii.hbmColor, ii.hbmMask);
     
    18641641
    18651642    DeleteObject (handle);
    1866    
     1643
    18671644    return himl;
    18681645}
     
    18701647
    18711648/*************************************************************************
    1872  * ImageList_LoadImageW [COMCTL32.66]
     1649 * ImageList_LoadImageW [COMCTL32.@]
    18731650 *
    18741651 * Creates an image list from a bitmap, icon or cursor.
     
    19331710        GetIconInfo (handle, &ii);
    19341711        GetObjectA (ii.hbmMask, sizeof(BITMAP), (LPVOID)&bmp);
    1935         himl = ImageList_Create (bmp.bmWidth, bmp.bmHeight, 
     1712        himl = ImageList_Create (bmp.bmWidth, bmp.bmHeight,
    19361713                                 ILC_MASK | ILC_COLOR, 1, cGrow);
    19371714        ImageList_Add (himl, ii.hbmColor, ii.hbmMask);
     
    19411718
    19421719    DeleteObject (handle);
    1943    
     1720
    19441721    return himl;
    19451722}
     
    19471724
    19481725/*************************************************************************
    1949  * ImageList_Merge [COMCTL32.67]
     1726 * ImageList_Merge [COMCTL32.@]
    19501727 *
    19511728 * Creates a new image list that contains a merged image from the specified
     
    20311808        nX1 = i1 * himl1->cx;
    20321809        nX2 = i2 * himl2->cx;
    2033        
     1810
    20341811        /* copy image */
    20351812        SelectObject (hdcSrcImage, himl1->hbmImage);
    20361813        SelectObject (hdcDstImage, himlDst->hbmImage);
    2037         BitBlt (hdcDstImage, 0, 0, cxDst, cyDst, 
     1814        BitBlt (hdcDstImage, 0, 0, cxDst, cyDst,
    20381815                  hdcSrcImage, 0, 0, BLACKNESS);
    2039         BitBlt (hdcDstImage, xOff1, yOff1, himl1->cx, himl1->cy, 
     1816        BitBlt (hdcDstImage, xOff1, yOff1, himl1->cx, himl1->cy,
    20401817                  hdcSrcImage, nX1, 0, SRCCOPY);
    20411818
    20421819        SelectObject (hdcSrcImage, himl2->hbmMask);
    2043         BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 
     1820        BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy,
    20441821                  hdcSrcImage, nX2, 0, SRCAND);
    20451822
    20461823        SelectObject (hdcSrcImage, himl2->hbmImage);
    2047         BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 
     1824        BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy,
    20481825                  hdcSrcImage, nX2, 0, SRCPAINT);
    20491826
     
    20511828        SelectObject (hdcSrcImage, himl1->hbmMask);
    20521829        SelectObject (hdcDstImage, himlDst->hbmMask);
    2053         BitBlt (hdcDstImage, 0, 0, cxDst, cyDst, 
     1830        BitBlt (hdcDstImage, 0, 0, cxDst, cyDst,
    20541831                  hdcSrcImage, 0, 0, WHITENESS);
    2055         BitBlt (hdcDstImage, xOff1, yOff1, himl1->cx, himl1->cy, 
     1832        BitBlt (hdcDstImage, xOff1, yOff1, himl1->cx, himl1->cy,
    20561833                  hdcSrcImage, nX1, 0, SRCCOPY);
    20571834
    20581835        SelectObject (hdcSrcImage, himl2->hbmMask);
    2059         BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 
     1836        BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy,
    20601837                  hdcSrcImage, nX2, 0, SRCAND);
    20611838
     
    20641841        himlDst->cCurImage = 1;
    20651842    }
    2066    
     1843
    20671844    return himlDst;
    20681845}
     
    21791956
    21801957/*************************************************************************
    2181  * ImageList_Read [COMCTL32.68]
     1958 * ImageList_Read [COMCTL32.@]
    21821959 *
    21831960 * Reads an image list from a stream.
     
    21941971 *
    21951972 * for the color image part:
    2196  *      BITMAPFILEHEADER        bmfh; 
     1973 *      BITMAPFILEHEADER        bmfh;
    21971974 *      BITMAPINFOHEADER        bmih;
    21981975 * only if it has a palette:
    2199  *      RGBQUAD         rgbs[nr_of_paletted_colors]; 
     1976 *      RGBQUAD         rgbs[nr_of_paletted_colors];
    22001977 *
    22011978 *      BYTE                    colorbits[imagesize];
     
    22051982 *      BITMAPINFOHEADER        bmih_mask;
    22061983 * only if it has a palette (it usually does not):
    2207  *      RGBQUAD         rgbs[nr_of_paletted_colors]; 
     1984 *      RGBQUAD         rgbs[nr_of_paletted_colors];
    22081985 *
    22091986 *      BYTE                    maskbits[imagesize];
     
    22752052
    22762053/*************************************************************************
    2277  * ImageList_Remove [COMCTL32.69] Removes an image from an image list
     2054 * ImageList_Remove [COMCTL32.@] Removes an image from an image list
    22782055 *
    22792056 * PARAMS
     
    22932070    INT     cxNew, nCount;
    22942071
     2072    TRACE("(himl=%p i=%d)\n", himl, i);
     2073
    22952074    if (himl == NULL) {
    22962075        ERR("Invalid image list handle!\n");
    22972076        return FALSE;
    22982077    }
    2299    
     2078
    23002079    if ((i < -1) || (i >= himl->cCurImage)) {
    23012080        ERR("index out of range! %d\n", i);
     
    23032082    }
    23042083
    2305     if (himl->cCurImage == 0) {
    2306         ERR("image list is already empty!\n");
    2307         return FALSE;
    2308     }
    2309 
    23102084    if (i == -1) {
    23112085        /* remove all */
    2312         TRACE("remove all!\n");
     2086        if (himl->cCurImage == 0) {
     2087            /* remove all on empty ImageList is allowed */
     2088            TRACE("remove all on empty ImageList!\n");
     2089            return TRUE;
     2090        }
    23132091
    23142092        himl->cMaxImage = himl->cInitial + himl->cGrow;
     
    23402118        TRACE(" - Max. number of images: %d / %d (Old/New)\n",
    23412119                 himl->cMaxImage, himl->cCurImage + himl->cGrow - 1);
    2342        
     2120
    23432121        hbmNewImage =
    23442122            CreateBitmap (cxNew, himl->cy, 1, himl->uBitsPixel, NULL);
     
    23552133        if (i > 0) {
    23562134            TRACE("Pre image copy: Copy %d images\n", i);
    2357        
     2135
    23582136            SelectObject (hdcSrc, himl->hbmImage);
    23592137            SelectObject (hdcDst, hbmNewImage);
     
    24062184
    24072185/*************************************************************************
    2408  * ImageList_Replace [COMCTL32.70]
     2186 * ImageList_Replace [COMCTL32.@]
    24092187 *
    24102188 * Replaces an image in an image list with a new image.
     
    24282206    BITMAP bmp;
    24292207
     2208    TRACE("%p %d %p %p\n", himl, i, hbmImage, hbmMask);
     2209
    24302210    if (himl == NULL) {
    24312211        ERR("Invalid image list handle!\n");
    24322212        return FALSE;
    24332213    }
    2434    
     2214
    24352215    if ((i >= himl->cMaxImage) || (i < 0)) {
    24362216        ERR("Invalid image index!\n");
     
    24622242        */
    24632243        SelectObject (hdcImageList, himl->hbmImage);
    2464         StretchBlt (hdcImageList, 
     2244        StretchBlt (hdcImageList,
    24652245            i*himl->cx, 0, himl->cx, himl->cy,
    2466             hdcImage, 
    2467             0, 0, bmp.bmWidth, bmp.bmHeight, 
     2246            hdcImage,
     2247            0, 0, bmp.bmWidth, bmp.bmHeight,
    24682248            0x220326); /* NOTSRCAND */
    24692249    }
     
    24772257
    24782258/*************************************************************************
    2479  * ImageList_ReplaceIcon [COMCTL32.75]
     2259 * ImageList_ReplaceIcon [COMCTL32.@]
    24802260 *
    24812261 * Replaces an image in an image list using an icon.
     
    25012281    BITMAP  bmp;
    25022282
    2503     TRACE("(0x%lx 0x%x 0x%x)\n", (DWORD)himl, i, hIcon);
     2283    TRACE("(0x%lx 0x%x %p)\n", (DWORD)himl, i, hIcon);
    25042284
    25052285    if (himl == NULL)
     
    25092289
    25102290    hBestFitIcon = CopyImage(
    2511         hIcon, IMAGE_ICON, 
    2512         himl->cx, himl->cy, 
     2291        hIcon, IMAGE_ICON,
     2292        himl->cx, himl->cy,
    25132293        LR_COPYFROMRESOURCE);
    25142294
     
    25312311
    25322312    hdcImageList = CreateCompatibleDC (0);
    2533     TRACE("hdcImageList=0x%x!\n", hdcImageList);
     2313    TRACE("hdcImageList=%p!\n", hdcImageList);
    25342314    if (hdcImageList == 0)
    25352315        ERR("invalid hdcImageList!\n");
    25362316
    25372317    hdcImage = CreateCompatibleDC (0);
    2538     TRACE("hdcImage=0x%x!\n", hdcImage);
     2318    TRACE("hdcImage=%p!\n", hdcImage);
    25392319    if (hdcImage == 0)
    25402320        ERR("invalid hdcImage!\n");
     
    25732353
    25742354/*************************************************************************
    2575  * ImageList_SetBkColor [COMCTL32.76]
     2355 * ImageList_SetBkColor [COMCTL32.@]
    25762356 *
    25772357 * Sets the background color of an image list.
     
    26012381
    26022382/*************************************************************************
    2603  * ImageList_SetDragCursorImage [COMCTL32.77]
     2383 * ImageList_SetDragCursorImage [COMCTL32.@]
    26042384 *
    26052385 * Combines the specified image with the current drag image
     
    26832463
    26842464/*************************************************************************
    2685  * ImageList_SetFilter [COMCTL32.78]
     2465 * ImageList_SetFilter [COMCTL32.@]
    26862466 *
    26872467 * Sets a filter (or does something completely different)!!???
    2688  *
    2689  * PARAMS
    2690  *     himl     [I] handle to image list
    2691  *     i        [I] ???
     2468 * It removes 12 Bytes from the stack (3 Parameters).
     2469 *
     2470 * PARAMS
     2471 *     himl     [I] SHOULD be a handle to image list
     2472 *     i        [I] COULD be an index?
    26922473 *     dwFilter [I] ???
    26932474 *
     
    27042485ImageList_SetFilter (HIMAGELIST himl, INT i, DWORD dwFilter)
    27052486{
    2706     FIXME("(%p 0x%x 0x%lx):empty stub!\n",
    2707            himl, i, dwFilter);
     2487    FIXME("(%p 0x%x 0x%lx):empty stub!\n", himl, i, dwFilter);
    27082488
    27092489    return FALSE;
     
    27122492
    27132493/*************************************************************************
    2714  * ImageList_SetFlags [COMCTL32.79]
     2494 * ImageList_SetFlags [COMCTL32.@]
    27152495 *
    27162496 * BUGS
     
    27272507
    27282508/*************************************************************************
    2729  * ImageList_SetIconSize [COMCTL32.80]
     2509 * ImageList_SetIconSize [COMCTL32.@]
    27302510 *
    27312511 * Sets the image size of the bitmap and deletes all images.
     
    27762556
    27772557/*************************************************************************
    2778  * ImageList_SetImageCount [COMCTL32.81]
     2558 * ImageList_SetImageCount [COMCTL32.@]
    27792559 *
    27802560 * Resizes an image list to the specified number of images.
     
    27952575    HBITMAP hbmNewBitmap;
    27962576    INT     nNewCount, nCopyCount;
     2577
     2578    TRACE("%p %d\n",himl,iImageCount);
    27972579
    27982580    if (!himl)
     
    28012583        return FALSE;
    28022584    if (himl->cMaxImage > iImageCount)
     2585    {
     2586        himl->cCurImage = iImageCount;
    28032587        return TRUE;
     2588    }
    28042589
    28052590    nNewCount = iImageCount + himl->cGrow;
     
    28232608        SetBkColor (hdcBitmap, RGB(255, 255, 255));
    28242609        SetTextColor (hdcBitmap, RGB(0, 0, 0));
    2825         PatBlt (hdcBitmap,  nCopyCount * himl->cx, 0, 
     2610        PatBlt (hdcBitmap,  nCopyCount * himl->cx, 0,
    28262611                  (nNewCount - nCopyCount) * himl->cx, himl->cy, BLACKNESS);
    28272612#endif
     
    28482633            SetBkColor (hdcBitmap, RGB(255, 255, 255));
    28492634            SetTextColor (hdcBitmap, RGB(0, 0, 0));
    2850             PatBlt (hdcBitmap,  nCopyCount * himl->cx, 0, 
     2635            PatBlt (hdcBitmap,  nCopyCount * himl->cx, 0,
    28512636                      (nNewCount - nCopyCount) * himl->cx, himl->cy, BLACKNESS);
    28522637#endif
     
    28632648    /* Update max image count and current image count */
    28642649    himl->cMaxImage = nNewCount;
    2865     if (himl->cCurImage > nCopyCount)
    2866         himl->cCurImage = nCopyCount;
     2650    himl->cCurImage = iImageCount;
    28672651
    28682652    return TRUE;
     
    28712655
    28722656/*************************************************************************
    2873  * ImageList_SetOverlayImage [COMCTL32.82]
     2657 * ImageList_SetOverlayImage [COMCTL32.@]
    28742658 *
    28752659 * Assigns an overlay mask index to an existing image in an image list.
     
    29002684
    29012685
    2902 /* helper for ImageList_Write - write bitmap to pstm 
     2686/* helper for ImageList_Write - write bitmap to pstm
    29032687 * currently everything is written as 24 bit RGB, except masks
    29042688 */
    2905 static BOOL 
     2689static BOOL
    29062690_write_bitmap(HBITMAP hBitmap, LPSTREAM pstm, int cx, int cy)
    29072691{
     
    29182702    xdc = GetDC(0);
    29192703    GetObjectA(hBitmap, sizeof(BITMAP), (LPVOID)&bm);
    2920    
     2704
    29212705    /* XXX is this always correct? */
    29222706    icount = bm.bmWidth / cx;
     
    29602744
    29612745    lpBitsOrg = (LPBYTE)LocalAlloc(LMEM_ZEROINIT, nsizeImage);
    2962     if(!GetDIBits(xdc, hBitmap, 0, bm.bmHeight, lpBitsOrg, 
     2746    if(!GetDIBits(xdc, hBitmap, 0, bm.bmHeight, lpBitsOrg,
    29632747                  (BITMAPINFO *)bmih, DIB_RGB_COLORS))
    29642748        goto failed;
     
    29672751        int obpl = (((bm.bmWidth*bitCount+31) & ~31)>>3);
    29682752        int nbpl = (((nwidth*bitCount+31) & ~31)>>3);
    2969                
     2753
    29702754        for(i = 0; i < nheight; i++) {
    29712755            int ooff = ((nheight-1-i)%cy) * obpl + ((i/cy) * nbpl);
     
    29742758        }
    29752759    }
    2976    
     2760
    29772761    bmih->biWidth  = nwidth;
    29782762    bmih->biHeight = nheight;
     
    29992783
    30002784/*************************************************************************
    3001  * ImageList_Write [COMCTL32.83]
     2785 * ImageList_Write [COMCTL32.@]
    30022786 *
    30032787 * Writes an image list to a stream.
     
    30522836    return TRUE;
    30532837}
    3054 
  • trunk/src/comctl32/ipaddress.c

    r8382 r9370  
    2222 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    2323 *
     24 * NOTE
     25 *
     26 * This code was audited for completeness against the documented features
     27 * of Comctl32.dll version 6.0 on Sep. 9, 2002, by Dimitrie O. Paun.
     28 *
     29 * Unless otherwise noted, we belive this code to be complete, as per
     30 * the specification mentioned above.
     31 * If you discover missing features, or bugs, please note them below.
     32 *
    2433 */
    2534
     
    2938#include <string.h>
    3039
    31 #include "ntddk.h"
    3240#include "winbase.h"
    3341#include "commctrl.h"
     42#include "wine/unicode.h"
    3443#include "wine/debug.h"
    35 #ifdef __WIN32OS2__
    36 #include "comctl32.h"
    37 #endif
    3844
    3945WINE_DEFAULT_DEBUG_CHANNEL(ipaddress);
     
    6874{
    6975    HWND hwnd = infoPtr->Self;
    70    
     76
    7177    TRACE("(command=%x)\n", command);
    72    
     78
    7379    return SendMessageW (GetParent (hwnd), WM_COMMAND,
    7480             MAKEWPARAM (GetWindowLongW (hwnd, GWL_ID), command), (LPARAM)hwnd);
     
    8086
    8187    TRACE("(field=%x, value=%d)\n", field, value);
    82    
     88
    8389    nmip.hdr.hwndFrom = infoPtr->Self;
    8490    nmip.hdr.idFrom   = GetWindowLongW (infoPtr->Self, GWL_ID);
     
    9298
    9399    TRACE("<-- %d\n", nmip.iValue);
    94    
     100
    95101    return nmip.iValue;
    96102}
     
    100106{
    101107    int i;
    102    
    103     TRACE("(hwnd=%x)\n", hwnd);
    104    
    105     for (i = 0; i < 4; i++) 
     108
     109    TRACE("(hwnd=%p)\n", hwnd);
     110
     111    for (i = 0; i < 4; i++)
    106112        if (infoPtr->Part[i].EditHwnd == hwnd) return i;
    107    
    108     ERR("We subclassed the wrong window! (hwnd=%x)\n", hwnd);
     113
     114    ERR("We subclassed the wrong window! (hwnd=%p)\n", hwnd);
    109115    return -1;
    110116}
     
    118124
    119125    TRACE("\n");
    120    
     126
    121127    GetClientRect (infoPtr->Self, &rect);
    122128    DrawEdge (hdc, &rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
     
    126132        pt.x = rcPart.right;
    127133        ScreenToClient(infoPtr->Self, &pt);
    128         rect.left = pt.x;       
     134        rect.left = pt.x;
    129135        GetWindowRect (infoPtr->Part[i+1].EditHwnd, &rcPart);
    130136        pt.x = rcPart.left;
     
    146152
    147153    TRACE("\n");
    148    
     154
    149155    SetWindowLongW (hwnd, GWL_STYLE,
    150156                    GetWindowLongW(hwnd, GWL_STYLE) & ~WS_BORDER);
    151    
     157
    152158    infoPtr = (IPADDRESS_INFO *)COMCTL32_Alloc (sizeof(IPADDRESS_INFO));
    153159    if (!infoPtr) return -1;
     
    162168
    163169    infoPtr->Self = hwnd;
    164  
     170
    165171    for (i = 0; i < 4; i++) {
    166172        IPPART_INFO* part = &infoPtr->Part[i];
    167        
     173
    168174        part->LowerLimit = 0;
    169175        part->UpperLimit = 255;
     
    172178        part->EditHwnd =
    173179                CreateWindowW (EDIT, NULL, WS_CHILD | WS_VISIBLE | ES_CENTER,
    174                                edit.left, edit.top, edit.right - edit.left, 
    175                                edit.bottom - edit.top, hwnd, (HMENU) 1, 
    176                                GetWindowLongW (hwnd, GWL_HINSTANCE), NULL);
     180                               edit.left, edit.top, edit.right - edit.left,
     181                               edit.bottom - edit.top, hwnd, (HMENU) 1,
     182                               (HINSTANCE)GetWindowLongW(hwnd, GWL_HINSTANCE), NULL);
    177183        SetPropA(part->EditHwnd, IP_SUBCLASS_PROP, hwnd);
    178184        part->OrigProc = (WNDPROC)
    179                 SetWindowLongW (part->EditHwnd, GWL_WNDPROC, 
     185                SetWindowLongW (part->EditHwnd, GWL_WNDPROC,
    180186                                (LONG)IPADDRESS_SubclassProc);
    181187    }
     
    190196
    191197    TRACE("\n");
    192    
     198
    193199    for (i = 0; i < 4; i++) {
    194200        IPPART_INFO* part = &infoPtr->Part[i];
     
    207213
    208214    TRACE("\n");
    209    
     215
    210216    if (hdc) return IPADDRESS_Draw (infoPtr, hdc);
    211  
     217
    212218    hdc = BeginPaint (infoPtr->Self, &ps);
    213219    IPADDRESS_Draw (infoPtr, hdc);
     
    240246    for (i = 0; i < 4; i++) {
    241247        ip_addr *= 256;
    242         if (GetWindowTextW (infoPtr->Part[i].EditHwnd, field, 4)) 
    243             ip_addr += wcstol(field, 0, 10);
     248        if (GetWindowTextW (infoPtr->Part[i].EditHwnd, field, 4))
     249            ip_addr += atolW(field);
    244250        else
    245251            invalid++;
     
    271277    TRACE("\n");
    272278
    273     for (i = 0; i < 4; i++) 
     279    for (i = 0; i < 4; i++)
    274280        SetWindowTextW (infoPtr->Part[i].EditHwnd, nil);
    275281}
     
    287293        int value = ip_address & 0xff;
    288294        if ( (value >= part->LowerLimit) && (value <= part->UpperLimit) ) {
    289             swprintf (buf, fmt, value);
     295            wsprintfW (buf, fmt, value);
    290296            SetWindowTextW (part->EditHwnd, buf);
    291297            IPADDRESS_Notify (infoPtr, EN_CHANGE);
     
    301307{
    302308    TRACE("(index=%d)\n", index);
    303  
     309
    304310    if (index > 3) {
    305311        for (index = 0; index < 4; index++)
     
    307313    }
    308314    if (index < 9 || index > 3) index = 0;
    309        
     315
    310316    SetFocus (infoPtr->Part[index].EditHwnd);
    311317}
     
    321327
    322328    if (currentfield < 0 || currentfield > 3) return FALSE;
    323  
     329
    324330    if (!GetWindowTextW (part->EditHwnd, field, 4)) return FALSE;
    325    
    326     curValue = wcstol(field, 0, 10);
     331
     332    curValue = atoiW(field);
    327333    TRACE("  curValue=%d\n", curValue);
    328    
     334
    329335    newValue = IPADDRESS_IPNotify(infoPtr, currentfield, curValue);
    330336    TRACE("  newValue=%d\n", newValue);
     
    332338    if (newValue < part->LowerLimit) newValue = part->LowerLimit;
    333339    if (newValue > part->UpperLimit) newValue = part->UpperLimit;
    334    
     340
    335341    if (newValue == curValue) return FALSE;
    336    
    337     swprintf (field, fmt, newValue);
     342
     343    wsprintfW (field, fmt, newValue);
    338344    TRACE("  field='%s'\n", debugstr_w(field));
    339345    return SetWindowTextW (part->EditHwnd, field);
     
    347353    if(cur >= -1 && cur < 4) {
    348354        IPADDRESS_ConstrainField(infoPtr, cur);
    349        
     355
    350356        if(cur < 3) {
    351357            IPPART_INFO *next = &infoPtr->Part[cur + 1];
     
    361367            return TRUE;
    362368        }
    363                  
     369
    364370    }
    365371    return FALSE;
     
    376382 * alpha characters: completely ignored
    377383 *
    378  * digits: accepted when field text length < 2 ignored otherwise. 
    379  *         when 3 numbers have been entered into the field the value 
    380  *         of the field is checked, if the field value exceeds the 
    381  *         maximum value and is changed the field remains the current 
    382  *         field, otherwise focus moves to the field to the right 
    383  *
    384  * tab: change focus from the current ipaddress control to the next 
    385  *      control in the tab order 
    386  *
    387  * right arrow: move to the field on the right to the left most 
    388  *              position in that field if no text is selected, 
    389  *              we are in the right most position in the field, 
    390  *              we are not in the right most field 
    391  *
    392  * left arrow: move to the field on the left to the right most 
    393  *             position in that field if no text is selected, 
    394  *             we are in the left most position in the current field 
    395  *             and we are not in the left most field 
    396  *
    397  * backspace: delete the character to the left of the cursor position, 
    398  *            if none are present move to the field on the left if 
    399  *            we are not in the left most field and delete the right 
    400  *            most digit in that field while keeping the cursor 
    401  *            on the right side of the field 
     384 * digits: accepted when field text length < 2 ignored otherwise.
     385 *         when 3 numbers have been entered into the field the value
     386 *         of the field is checked, if the field value exceeds the
     387 *         maximum value and is changed the field remains the current
     388 *         field, otherwise focus moves to the field to the right
     389 *
     390 * tab: change focus from the current ipaddress control to the next
     391 *      control in the tab order
     392 *
     393 * right arrow: move to the field on the right to the left most
     394 *              position in that field if no text is selected,
     395 *              we are in the right most position in the field,
     396 *              we are not in the right most field
     397 *
     398 * left arrow: move to the field on the left to the right most
     399 *             position in that field if no text is selected,
     400 *             we are in the left most position in the current field
     401 *             and we are not in the left most field
     402 *
     403 * backspace: delete the character to the left of the cursor position,
     404 *            if none are present move to the field on the left if
     405 *            we are not in the left most field and delete the right
     406 *            most digit in that field while keeping the cursor
     407 *            on the right side of the field
    402408 */
    403409LRESULT CALLBACK
     
    410416    IPPART_INFO *part;
    411417
    412     TRACE("(hwnd=0x%x msg=0x%x wparam=0x%x lparam=0x%lx)\n", hwnd, uMsg, wParam, lParam);
     418    TRACE("(hwnd=%p msg=0x%x wparam=0x%x lparam=0x%lx)\n", hwnd, uMsg, wParam, lParam);
    413419
    414420    if ( (index = IPADDRESS_GetPartIndex(infoPtr, hwnd)) < 0) return 0;
     
    418424        len = GetWindowTextLengthW (hwnd);
    419425        SendMessageW(hwnd, EM_GETSEL, (WPARAM)&startsel, (LPARAM)&endsel);
    420     }   
     426    }
    421427    switch (uMsg) {
    422         case WM_CHAR: 
     428        case WM_CHAR:
    423429            if(isdigit(c)) {
    424430                if(len == 2 && startsel==endsel && endsel==len) {
    425431                    /* process the digit press before we check the field */
    426432                    int return_val = CallWindowProcW (part->OrigProc, hwnd, uMsg, wParam, lParam);
    427          
     433
    428434                    /* if the field value was changed stay at the current field */
    429435                    if(!IPADDRESS_ConstrainField(infoPtr, index))
     
    433439                } else if (len == 3 && startsel==endsel && endsel==len)
    434440                    IPADDRESS_GotoNextField (infoPtr, index, POS_SELALL);
    435                 else if (len < 3) break; 
     441                else if (len < 3) break;
    436442            } else if(c == '.' || c == ' ') {
    437443                if(len && startsel==endsel && startsel != 0) {
    438                     IPADDRESS_GotoNextField(infoPtr, index, POS_SELALL); 
     444                    IPADDRESS_GotoNextField(infoPtr, index, POS_SELALL);
    439445                }
    440446            } else if (c == VK_BACK) break;
    441447            return 0;
    442        
     448
    443449        case WM_KEYDOWN:
    444450            switch(c) {
     
    459465                        IPPART_INFO *prev = &infoPtr->Part[index-1];
    460466                        WCHAR val[10];
    461                        
     467
    462468                        if(GetWindowTextW(prev->EditHwnd, val, 5)) {
    463469                            val[lstrlenW(val) - 1] = 0;
    464470                            SetWindowTextW(prev->EditHwnd, val);
    465471                        }
    466                                
     472
    467473                        IPADDRESS_GotoNextField(infoPtr, index - 2, POS_RIGHT);
    468474                        return 0;
    469475                    }
    470476                    break;
    471             }               
     477            }
    472478            break;
    473479        case WM_KILLFOCUS:
     
    488494{
    489495    IPADDRESS_INFO *infoPtr = IPADDRESS_GetInfoPtr (hwnd);
    490  
    491     TRACE("(hwnd=0x%x msg=0x%x wparam=0x%x lparam=0x%lx)\n", hwnd, uMsg, wParam, lParam);
    492  
     496
     497    TRACE("(hwnd=%p msg=0x%x wparam=0x%x lparam=0x%lx)\n", hwnd, uMsg, wParam, lParam);
     498
    493499    if (!infoPtr && (uMsg != WM_CREATE))
    494500        return DefWindowProcW (hwnd, uMsg, wParam, lParam);
    495  
     501
    496502    switch (uMsg)
    497503    {
     
    537543
    538544        default:
    539             if (uMsg >= WM_USER)
     545            if ((uMsg >= WM_USER) && (uMsg < WM_APP))
    540546                ERR("unknown msg %04x wp=%08x lp=%08lx\n", uMsg, wParam, lParam);
    541547            return DefWindowProcW (hwnd, uMsg, wParam, lParam);
     
    557563    wndClass.hbrBackground = GetStockObject(WHITE_BRUSH);
    558564    wndClass.lpszClassName = WC_IPADDRESSW;
    559  
     565
    560566    RegisterClassW (&wndClass);
    561567}
  • trunk/src/comctl32/listview.c

    r9247 r9370  
    7676#include <heapstring.h>
    7777#include "ccbase.h"
    78 #include "header.h"
    7978
    8079typedef struct
     
    1010810107  RECT rect;
    1010910108
    10110   if (HEADER_GetItemRect(infoPtr->hwndHeader,(WPARAM)nSubItem,(LPARAM)&rect))
     10109  if (Header_GetItemRect(infoPtr->hwndHeader,(WPARAM)nSubItem,(LPARAM)&rect))
    1011110110  {
    1011210111    lpptPosition->x = rect.left+REPORT_MARGINX;
     
    1014810147
    1014910148  nSubItem = lprc->top;
    10150   if ((nSubItem < 0) || (nSubItem >= HEADER_GetItemCount(infoPtr->hwndHeader))) return FALSE;
     10149  if ((nSubItem < 0) || (nSubItem >= Header_GetItemCount(infoPtr->hwndHeader))) return FALSE;
    1015110150  if (!LISTVIEW_GetSubItemPosition(hwnd, infoPtr,nItem,nSubItem,&ptItem)) return FALSE;
    1015210151
     
    1034710346  if (checkSubItems && (uView == LVS_REPORT))
    1034810347  {
    10349     INT nColumnCount = HEADER_GetItemCount(infoPtr->hwndHeader);
     10348    INT nColumnCount = Header_GetItemCount(infoPtr->hwndHeader);
    1035010349    INT xDiff = -infoPtr->lefttop.x*infoPtr->scrollStep.x;
    1035110350
     
    1035610355      RECT rcColumn;
    1035710356
    10358       HEADER_GetItemRect(infoPtr->hwndHeader,(WPARAM)x,(LPARAM)&rcColumn);
     10357      Header_GetItemRect(infoPtr->hwndHeader,(WPARAM)x,(LPARAM)&rcColumn);
    1035910358      rcItem.left = xDiff+REPORT_MARGINX+rcColumn.left;
    1036010359      rcItem.right = xDiff+rcColumn.right-REPORT_MARGINX;
  • trunk/src/comctl32/pager.c

    r8382 r9370  
    4545    INT    nPos;       /* scroll position */
    4646    INT    nWidth;     /* from child wnd's response to PGN_CALCSIZE */
    47     INT    nHeight;    /* from child wnd's response to PGN_CALCSIZE */ 
     47    INT    nHeight;    /* from child wnd's response to PGN_CALCSIZE */
    4848    BOOL   bForward;   /* forward WM_MOUSEMOVE msgs to the contained wnd */
     49    BOOL   bCapture;   /* we have captured the mouse  */
    4950    INT    TLbtnState; /* state of top or left btn */
    5051    INT    BRbtnState; /* state of bottom or right btn */
     
    6364#define REPEAT_DELAY     50
    6465
    65 /* the horizontal arrows are: 
     66/* the horizontal arrows are:
    6667 *
    6768 * 01234    01234
     
    7273 * 5 **      **
    7374 * 6  *      *
    74  * 7 
     75 * 7
    7576 *
    7677 */
     
    7980{
    8081    INT x, y, w, h;
    81     HPEN hOldPen;
    82    
     82    HPEN hPen, hOldPen;
     83
    8384    w = r.right - r.left + 1;
    8485    h = r.bottom - r.top + 1;
     
    8687        return;  /* refuse to draw partial arrow */
    8788
    88     hOldPen = SelectObject ( hdc, GetSysColorPen (colorRef));
     89    if (!(hPen = CreatePen( PS_SOLID, 1, GetSysColor( colorRef )))) return;
     90    hOldPen = SelectObject ( hdc, hPen );
    8991    if (left)
    9092    {
     
    111113
    112114    SelectObject( hdc, hOldPen );
    113 }
    114 
    115 /* the vertical arrows are:
     115    DeleteObject( hPen );
     116}
     117
     118/* the vertical arrows are:
    116119 *
    117120 * 01234567    01234567
    118  * 1******        ** 
     121 * 1******        **
    119122 * 2 ****        ****
    120123 * 3  **        ******
     
    126129{
    127130    INT x, y, w, h;
    128     HPEN hOldPen;
    129    
     131    HPEN hPen, hOldPen;
     132
    130133    w = r.right - r.left + 1;
    131134    h = r.bottom - r.top + 1;
     
    133136        return;  /* refuse to draw partial arrow */
    134137
    135     hOldPen = SelectObject ( hdc, GetSysColorPen (colorRef));
     138    if (!(hPen = CreatePen( PS_SOLID, 1, GetSysColor( colorRef )))) return;
     139    hOldPen = SelectObject ( hdc, hPen );
    136140    if (up)
    137141    {
     
    158162
    159163    SelectObject( hdc, hOldPen );
     164    DeleteObject( hPen );
    160165}
    161166
     
    171176
    172177    if ((rc.right - rc.left <= 0) || (rc.bottom - rc.top <= 0))
    173         return; 
     178        return;
    174179
    175180    hBrush = CreateSolidBrush(clrBk);
     
    178183    FillRect(hdc, &rc, hBrush);
    179184
    180     if (btnState == PGF_HOT) 
     185    if (btnState == PGF_HOT)
    181186    {
    182187       DrawEdge( hdc, &rc, BDR_RAISEDINNER, BF_RECT);
     
    186191           PAGER_DrawVertArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft);
    187192    }
    188     else if (btnState == PGF_NORMAL) 
     193    else if (btnState == PGF_NORMAL)
    189194    {
    190195       DrawEdge (hdc, &rc, BDR_OUTER, BF_FLAT);
     
    194199           PAGER_DrawVertArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft);
    195200    }
    196     else if (btnState == PGF_DEPRESSED) 
     201    else if (btnState == PGF_DEPRESSED)
    197202    {
    198203       DrawEdge( hdc, &rc, BDR_SUNKENOUTER, BF_RECT);
     
    202207           PAGER_DrawVertArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft);
    203208    }
    204     else if (btnState == PGF_GRAYED) 
     209    else if (btnState == PGF_GRAYED)
    205210    {
    206211       DrawEdge (hdc, &rc, BDR_OUTER, BF_FLAT);
     
    223228}
    224229
     230static void PAGER_CaptureandTrack(PAGER_INFO *infoPtr, HWND hwnd)
     231{
     232    TRACKMOUSEEVENT trackinfo;
     233
     234    TRACE("[%p] SetCapture\n", hwnd);
     235    SetCapture(hwnd);
     236    infoPtr->bCapture = TRUE;
     237
     238    trackinfo.cbSize = sizeof(TRACKMOUSEEVENT);
     239    trackinfo.dwFlags = TME_QUERY;
     240    trackinfo.hwndTrack = hwnd;
     241    trackinfo.dwHoverTime = HOVER_DEFAULT;
     242
     243    /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
     244    _TrackMouseEvent(&trackinfo);
     245
     246    /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */
     247    if(!(trackinfo.dwFlags & TME_LEAVE)) {
     248        trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */
     249
     250        /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
     251        /* and can properly deactivate the hot button */
     252        _TrackMouseEvent(&trackinfo);
     253    }
     254}
     255
     256
    225257/* << PAGER_GetDropTarget >> */
    226258
     
    229261{
    230262    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
    231     TRACE("[%04x]\n", hwnd);
     263    TRACE("[%p]\n", hwnd);
    232264
    233265    infoPtr->bForward = (BOOL)wParam;
     
    239271PAGER_GetButtonState (HWND hwnd, WPARAM wParam, LPARAM lParam)
    240272{
    241     PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 
     273    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
    242274    LRESULT btnState = PGF_INVISIBLE;
    243275    INT btn = (INT)lParam;
    244     TRACE("[%04x]\n", hwnd);
     276    TRACE("[%p]\n", hwnd);
    245277
    246278    if (btn == PGB_TOPORLEFT)
     
    256288PAGER_GetPos(HWND hwnd)
    257289{
    258     PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 
    259     TRACE("[%04x] returns %d\n", hwnd, infoPtr->nPos);
     290    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
     291    TRACE("[%p] returns %d\n", hwnd, infoPtr->nPos);
    260292    return (LRESULT)infoPtr->nPos;
    261293}
     
    264296PAGER_GetButtonSize(HWND hwnd)
    265297{
    266     PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 
    267     TRACE("[%04x] returns %d\n", hwnd, infoPtr->nButtonSize);
     298    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
     299    TRACE("[%p] returns %d\n", hwnd, infoPtr->nButtonSize);
    268300    return (LRESULT)infoPtr->nButtonSize;
    269301}
     
    272304PAGER_GetBorder(HWND hwnd)
    273305{
    274     PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 
    275     TRACE("[%04x] returns %d\n", hwnd, infoPtr->nBorder);
     306    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
     307    TRACE("[%p] returns %d\n", hwnd, infoPtr->nBorder);
    276308    return (LRESULT)infoPtr->nBorder;
    277309}
     
    280312PAGER_GetBkColor(HWND hwnd)
    281313{
    282     PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 
    283     TRACE("[%04x] returns %06lx\n", hwnd, infoPtr->clrBk);
     314    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
     315    TRACE("[%p] returns %06lx\n", hwnd, infoPtr->clrBk);
    284316    return (LRESULT)infoPtr->clrBk;
    285317}
    286318
    287 static void 
    288 PAGER_CalcSize (HWND hwnd, INT* size, BOOL getWidth) 
     319static void
     320PAGER_CalcSize (HWND hwnd, INT* size, BOOL getWidth)
    289321{
    290322    NMPGCALCSIZE nmpgcs;
     
    301333    *size = getWidth ? nmpgcs.iWidth : nmpgcs.iHeight;
    302334
    303     TRACE("[%04x] PGN_CALCSIZE returns %s=%d\n", hwnd,
     335    TRACE("[%p] PGN_CALCSIZE returns %s=%d\n", hwnd,
    304336                  getWidth ? "width" : "height", *size);
    305337}
     
    325357                infoPtr->nWidth = wndSize;
    326358
    327             TRACE("[%04x] SWP %dx%d at (%d,%d)\n", hwnd,
     359            TRACE("[%p] SWP %dx%d at (%d,%d)\n", hwnd,
    328360                         infoPtr->nWidth, infoPtr->nHeight,
    329361                         -nPos, 0);
     
    339371                infoPtr->nHeight = wndSize;
    340372
    341             TRACE("[%04x] SWP %dx%d at (%d,%d)\n", hwnd,
     373            TRACE("[%p] SWP %dx%d at (%d,%d)\n", hwnd,
    342374                         infoPtr->nWidth, infoPtr->nHeight,
    343375                         0, -nPos);
     
    381413    }
    382414
    383     TRACE("[%04x] returns %d\n", hwnd, scrollRange);
     415    TRACE("[%p] returns %d\n", hwnd, scrollRange);
    384416    return scrollRange;
    385417}
    386418
    387 static void 
     419static void
    388420PAGER_GrayAndRestoreBtns(PAGER_INFO* infoPtr, INT scrollRange,
    389421                         BOOL* needsResize, BOOL* needsRepaint)
     
    422454
    423455
    424 static void 
     456static void
    425457PAGER_NormalizeBtns(PAGER_INFO* infoPtr, BOOL* needsRepaint)
    426458{
     
    438470}
    439471
    440 static void 
     472static void
    441473PAGER_HideGrayBtns(PAGER_INFO* infoPtr, BOOL* needsResize)
    442474{
     
    470502
    471503    if (resizeClient) /* initiate NCCalcSize to resize client wnd */ {
    472         SetWindowPos(hwnd, 0,0,0,0,0, 
     504        SetWindowPos(hwnd, 0,0,0,0,0,
    473505                     SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE |
    474506                     SWP_NOZORDER | SWP_NOACTIVATE);
     
    476508
    477509    if (repaintBtns)
    478         SendMessageA(hwnd, WM_NCPAINT, 0, 0); 
    479 }
    480 
    481 static LRESULT 
     510        SendMessageA(hwnd, WM_NCPAINT, 0, 0);
     511}
     512
     513static LRESULT
    482514PAGER_SetPos(HWND hwnd, INT newPos, BOOL fromBtnPress)
    483515{
     
    493525        infoPtr->nPos = newPos;
    494526
    495     TRACE("[%04x] pos=%d\n", hwnd, infoPtr->nPos);
     527    TRACE("[%p] pos=%d, oldpos=%d\n", hwnd, infoPtr->nPos, oldPos);
    496528
    497529    if (infoPtr->nPos != oldPos)
     
    537569}
    538570
    539 static INT 
     571static INT
    540572PAGER_SetFixedWidth(HWND hwnd, PAGER_INFO* infoPtr)
    541573{
     
    562594    h = wndRect.bottom - wndRect.top + infoPtr->nButtonSize;
    563595
    564     TRACE("[%04x] infoPtr->nWidth set to %d\n",
     596    TRACE("[%p] infoPtr->nWidth set to %d\n",
    565597               hwnd, infoPtr->nWidth);
    566598
     
    568600}
    569601
    570 static INT 
     602static INT
    571603PAGER_SetFixedHeight(HWND hwnd, PAGER_INFO* infoPtr)
    572604{
     
    593625    w = wndRect.right - wndRect.left + infoPtr->nButtonSize;
    594626
    595     TRACE("[%04x] infoPtr->nHeight set to %d\n",
     627    TRACE("[%p] infoPtr->nHeight set to %d\n",
    596628               hwnd, infoPtr->nHeight);
    597629
     
    616648    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
    617649
    618     TRACE("[%04x]\n", hwnd);
     650    TRACE("[%p]\n", hwnd);
    619651
    620652    if (infoPtr->hwndChild)
     
    627659            PAGER_SetPos(hwnd, 0, FALSE);
    628660        }
    629         else 
     661        else
    630662        {
    631663            PAGER_UpdateBtns(hwnd, infoPtr, scrollRange, TRUE);
     
    645677
    646678    infoPtr->clrBk = (COLORREF)lParam;
    647     TRACE("[%04x] %06lx\n", hwnd, infoPtr->clrBk);
     679    TRACE("[%p] %06lx\n", hwnd, infoPtr->clrBk);
    648680
    649681    /* the native control seems to do things this way */
    650     SetWindowPos(hwnd, 0,0,0,0,0, 
     682    SetWindowPos(hwnd, 0,0,0,0,0,
    651683                 SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE |
    652684                 SWP_NOZORDER | SWP_NOACTIVATE);
     
    665697
    666698    infoPtr->nBorder = (INT)lParam;
    667     TRACE("[%04x] %d\n", hwnd, infoPtr->nBorder);
     699    TRACE("[%p] %d\n", hwnd, infoPtr->nBorder);
    668700
    669701    PAGER_RecalcSize(hwnd);
     
    680712
    681713    infoPtr->nButtonSize = (INT)lParam;
    682     TRACE("[%04x] %d\n", hwnd, infoPtr->nButtonSize);
     714    TRACE("[%p] %d\n", hwnd, infoPtr->nButtonSize);
    683715
    684716    PAGER_RecalcSize(hwnd);
     
    698730    if (infoPtr->hwndChild)
    699731    {
    700         TRACE("[%04x] hwndChild=%04x\n", hwnd, infoPtr->hwndChild);
     732        TRACE("[%p] hwndChild=%p\n", hwnd, infoPtr->hwndChild);
    701733
    702734        if (PAGER_IsHorizontal(hwnd)) {
    703735            hw = PAGER_SetFixedHeight(hwnd, infoPtr);
    704736            /* adjust non-scrollable dimension to fit the child */
    705             SetWindowPos(hwnd, 0, 0,0, hw, infoPtr->nHeight, 
     737            SetWindowPos(hwnd, 0, 0,0, hw, infoPtr->nHeight,
    706738                         SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER |
    707739                         SWP_NOSIZE | SWP_NOACTIVATE);
     
    710742            hw = PAGER_SetFixedWidth(hwnd, infoPtr);
    711743            /* adjust non-scrollable dimension to fit the child */
    712             SetWindowPos(hwnd, 0, 0,0, infoPtr->nWidth, hw, 
     744            SetWindowPos(hwnd, 0, 0,0, infoPtr->nWidth, hw,
    713745                         SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER |
    714746                         SWP_NOSIZE | SWP_NOACTIVATE);
     
    741773        nmpgScroll.hdr.code = PGN_SCROLL;
    742774
    743         GetWindowRect(hwnd, &rcWnd); 
    744         GetClientRect(hwnd, &nmpgScroll.rcParent); 
     775        GetWindowRect(hwnd, &rcWnd);
     776        GetClientRect(hwnd, &nmpgScroll.rcParent);
    745777        nmpgScroll.iXpos = nmpgScroll.iYpos = 0;
    746778        nmpgScroll.iDir = dir;
     
    757789        }
    758790        nmpgScroll.iScroll -= 2*infoPtr->nButtonSize;
    759  
    760         SendMessageA (hwnd, WM_NOTIFY,
     791
     792        SendMessageA (GetParent(hwnd), WM_NOTIFY,
    761793                    (WPARAM)nmpgScroll.hdr.idFrom, (LPARAM)&nmpgScroll);
    762  
    763         TRACE("[%04x] PGN_SCROLL returns iScroll=%d\n", hwnd, nmpgScroll.iScroll);
     794
     795        TRACE("[%p] PGN_SCROLL returns iScroll=%d\n", hwnd, nmpgScroll.iScroll);
    764796
    765797        if (nmpgScroll.iScroll > 0)
     
    783815
    784816    /* initiate NCCalcSize to resize client wnd and get size */
    785     SetWindowPos(hwnd, 0, 0,0,0,0, 
     817    SetWindowPos(hwnd, 0, 0,0,0,0,
    786818                 SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE |
    787819                 SWP_NOZORDER | SWP_NOACTIVATE);
    788820
    789     SetWindowPos(infoPtr->hwndChild, 0, 
    790                  0,0,infoPtr->nWidth,infoPtr->nHeight, 
     821    SetWindowPos(infoPtr->hwndChild, 0,
     822                 0,0,infoPtr->nWidth,infoPtr->nHeight,
    791823                 0);
    792824
     
    814846    infoPtr->nHeight = 0;
    815847    infoPtr->bForward = FALSE;
     848    infoPtr->bCapture = FALSE;
    816849    infoPtr->TLbtnState = PGF_INVISIBLE;
    817850    infoPtr->BRbtnState = PGF_INVISIBLE;
    818851    infoPtr->direction = -1;
    819852
    820     if (dwStyle & PGS_AUTOSCROLL)
    821         FIXME("[%04x] Autoscroll style is not implemented yet.\n", hwnd);
    822853    if (dwStyle & PGS_DRAGNDROP)
    823         FIXME("[%04x] Drag and Drop style is not implemented yet.\n", hwnd);
     854        FIXME("[%p] Drag and Drop style is not implemented yet.\n", hwnd);
    824855    /*
    825856         * If neither horizontal nor vertical style specified, default to vertical.
     
    852883    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
    853884    LPRECT lpRect = (LPRECT)lParam;
    854     RECT rcChildw, rcmyw, wnrc, lbrc, rbrc;
     885    RECT rcChildw, rcmyw, wnrc, ltrc, rbrc;
    855886    POINT cursor;
    856887    BOOL resizeClient = FALSE;
     
    860891    /*
    861892     * lParam points to a RECT struct.  On entry, the struct
    862      * contains the proposed wnd rectangle for the window. 
     893     * contains the proposed wnd rectangle for the window.
    863894     * On exit, the struct should contain the screen
    864895     * coordinates of the corresponding window's client area.
    865896     */
    866        
     897
    867898    DefWindowProcA (hwnd, WM_NCCALCSIZE, wParam, lParam);
    868899
     
    882913        scrollRange = infoPtr->nWidth - (rcmyw.right - rcmyw.left);
    883914
    884         TRACE("nPos=%d, scrollrange=%d, nWidth=%d, myw=(%d,%d)-(%d,%d)\n",
    885               infoPtr->nPos, scrollRange, infoPtr->nWidth,
    886               rcmyw.left, rcmyw.top, rcmyw.right, rcmyw.bottom);
     915        TRACE("nPos=%d, scrollrange=%d, nHeigth=%d, myw=(%d,%d)-(%d,%d), cursor=(%ld,%ld)\n",
     916              infoPtr->nPos, scrollRange, infoPtr->nHeight,
     917              rcmyw.left, rcmyw.top,
     918              rcmyw.right, rcmyw.bottom,
     919              cursor.x, cursor.y);
    887920        PAGER_GrayAndRestoreBtns(infoPtr, scrollRange, &resizeClient, &repaintBtns);
    888921        PAGER_HideGrayBtns(infoPtr, &resizeClient);
     
    890923        if (PtInRect (&rcmyw, cursor)) {
    891924            GetWindowRect (hwnd, &wnrc);
    892             lbrc = wnrc;
    893             lbrc.right = lbrc.left + infoPtr->nButtonSize;
     925            ltrc = wnrc;
     926            ltrc.right = ltrc.left + infoPtr->nButtonSize;
    894927            rbrc = wnrc;
    895928            rbrc.left = rbrc.right - infoPtr->nButtonSize;
    896             TRACE("horz lb rect=(%d,%d)-(%d,%d), rb rect=(%d,%d)-(%d,%d)\n",
    897                   lbrc.left, lbrc.top, lbrc.right, lbrc.bottom,
     929            TRACE("horz lt rect=(%d,%d)-(%d,%d), rb rect=(%d,%d)-(%d,%d)\n",
     930                  ltrc.left, ltrc.top, ltrc.right, ltrc.bottom,
    898931                  rbrc.left, rbrc.top, rbrc.right, rbrc.bottom);
    899             if (PtInRect (&lbrc, cursor) && infoPtr->TLbtnState)
     932            if (PtInRect (&ltrc, cursor) && infoPtr->TLbtnState)
    900933                RedrawWindow (hwnd, 0, 0, RDW_INVALIDATE | RDW_ERASE);
    901934            if (PtInRect (&rbrc, cursor) && infoPtr->BRbtnState)
     
    909942    else
    910943    {
    911         /* native does: (from trace of IE4 opening "Favorites" frame) 
     944        /* native does: (from trace of IE4 opening "Favorites" frame)
    912945         *        DefWindowProc
    913946         *        WM_NOITFY  PGN_CALCSIZE w/ dwFlag=2
     
    929962        scrollRange = infoPtr->nHeight - (rcmyw.bottom - rcmyw.top);
    930963
    931         TRACE("nPos=%d, scrollrange=%d, nHeigth=%d, myw=(%d,%d)-(%d,%d)\n",
     964        TRACE("nPos=%d, scrollrange=%d, nHeigth=%d, myw=(%d,%d)-(%d,%d), cursor=(%ld,%ld)\n",
    932965              infoPtr->nPos, scrollRange, infoPtr->nHeight,
    933966              rcmyw.left, rcmyw.top,
    934               rcmyw.right, rcmyw.bottom);
     967              rcmyw.right, rcmyw.bottom,
     968              cursor.x, cursor.y);
    935969        PAGER_GrayAndRestoreBtns(infoPtr, scrollRange, &resizeClient, &repaintBtns);
    936970        PAGER_HideGrayBtns(infoPtr, &resizeClient);
     
    949983
    950984            GetWindowRect (hwnd, &wnrc);
    951             lbrc = wnrc;
    952             lbrc.right = lbrc.left + infoPtr->nButtonSize;
     985            ltrc = wnrc;
     986            ltrc.right = ltrc.left + infoPtr->nButtonSize;
    953987            rbrc = wnrc;
    954988            rbrc.left = rbrc.right - infoPtr->nButtonSize;
    955             TRACE("vert lb rect=(%d,%d)-(%d,%d), rb rect=(%d,%d)-(%d,%d)\n",
    956                   lbrc.left, lbrc.top, lbrc.right, lbrc.bottom,
     989            TRACE("vert lt rect=(%d,%d)-(%d,%d), rb rect=(%d,%d)-(%d,%d)\n",
     990                  ltrc.left, ltrc.top, ltrc.right, ltrc.bottom,
    957991                  rbrc.left, rbrc.top, rbrc.right, rbrc.bottom);
    958             if (PtInRect (&lbrc, cursor) && infoPtr->TLbtnState)
     992            if (PtInRect (&ltrc, cursor) && infoPtr->TLbtnState)
    959993                RedrawWindow (hwnd, 0, 0, RDW_INVALIDATE | RDW_ERASE);
    960994            if (PtInRect (&rbrc, cursor) && infoPtr->BRbtnState)
     
    9701004    }
    9711005
    972     TRACE("[%04x] client rect set to %dx%d at (%d,%d) BtnState[%d,%d]\n",
     1006    TRACE("[%p] client rect set to %dx%d at (%d,%d) BtnState[%d,%d]\n",
    9731007          hwnd, lpRect->right-lpRect->left, lpRect->bottom-lpRect->top,
    9741008          lpRect->left, lpRect->top,
     
    10131047                     bHorizontal, TRUE, infoPtr->TLbtnState);
    10141048    PAGER_DrawButton(hdc, infoPtr->clrBk, rcBottomRight,
    1015                      bHorizontal, FALSE, infoPtr->BRbtnState); 
     1049                     bHorizontal, FALSE, infoPtr->BRbtnState);
    10161050
    10171051    ReleaseDC( hwnd, hdc );
     
    10191053}
    10201054
    1021 static INT 
     1055static INT
    10221056PAGER_HitTest (HWND hwnd, LPPOINT pt)
    10231057{
     
    10301064    if (PtInRect(&clientRect, *pt))
    10311065    {
    1032        /* TRACE("HTCLIENT\n"); */
     1066        TRACE("HTCLIENT\n");
    10331067        return HTCLIENT;
    10341068    }
     
    10401074            if (pt->x < clientRect.left)
    10411075            {
    1042                 /* TRACE("HTLEFT\n"); */
     1076                TRACE("HTLEFT\n");
    10431077                return HTLEFT;
    10441078            }
     
    10481082            if (pt->y < clientRect.top)
    10491083            {
    1050                 /* TRACE("HTTOP\n"); */
     1084                TRACE("HTTOP\n");
    10511085                return HTTOP;
    10521086            }
     
    10601094            if (pt->x > clientRect.right)
    10611095            {
    1062                 /* TRACE("HTRIGHT\n"); */
     1096                TRACE("HTRIGHT\n");
    10631097                return HTRIGHT;
    10641098            }
     
    10681102            if (pt->y > clientRect.bottom)
    10691103            {
    1070                /* TRACE("HTBOTTOM\n"); */
     1104                TRACE("HTBOTTOM\n");
    10711105                return HTBOTTOM;
    10721106            }
     
    10741108    }
    10751109
    1076     /* TRACE("HTNOWHERE\n"); */
     1110    TRACE("HTNOWHERE\n");
    10771111    return HTNOWHERE;
    10781112}
     
    10811115PAGER_NCHitTest (HWND hwnd, WPARAM wParam, LPARAM lParam)
    10821116{
    1083     POINT pt = { SLOWORD(lParam), SHIWORD(lParam) };
     1117    POINT pt;
     1118
     1119    pt.x = SLOWORD(lParam);
     1120    pt.y = SHIWORD(lParam);
     1121
    10841122    ScreenToClient (hwnd, &pt);
    10851123    return PAGER_HitTest(hwnd, &pt);
     
    11101148    if (notCaptured)
    11111149    {
    1112         TRACKMOUSEEVENT trackinfo;
    1113 
    1114         TRACE("[%04x] SetCapture\n", hwnd);
    1115         SetCapture(hwnd);
    1116 
    1117         trackinfo.cbSize = sizeof(TRACKMOUSEEVENT);
    1118         trackinfo.dwFlags = TME_QUERY;
    1119         trackinfo.hwndTrack = hwnd;
    1120         trackinfo.dwHoverTime = HOVER_DEFAULT;
    1121 
    1122         /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
    1123         _TrackMouseEvent(&trackinfo);
    1124 
    1125         /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */
    1126         if(!(trackinfo.dwFlags & TME_LEAVE)) {
    1127             trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */
    1128  
    1129            /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
    1130            /* and can properly deactivate the hot button */
    1131            _TrackMouseEvent(&trackinfo);
    1132         }
    1133 
    1134         SendMessageA(hwnd, WM_NCPAINT, 0, 0);
     1150        PAGER_CaptureandTrack(infoPtr, hwnd);
     1151
     1152        SendMessageA(hwnd, WM_NCPAINT, 0, 0);
    11351153    }
    11361154
     
    11461164    KillTimer (hwnd, TIMERID2);
    11471165
    1148     TRACE("[%04x] ReleaseCapture\n", hwnd);
     1166    TRACE("[%p] ReleaseCapture\n", hwnd);
    11491167    ReleaseCapture();
     1168    infoPtr->bCapture = FALSE;
    11501169
    11511170    /* Notify parent of released mouse capture */
     
    11671186
    11681187static LRESULT
     1188PAGER_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
     1189{
     1190    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
     1191    POINT clpt, pt;
     1192    RECT wnrect, TLbtnrect, BRbtnrect, *btnrect = NULL;
     1193    DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
     1194    BOOL topLeft = FALSE;
     1195    INT btnstate = 0;
     1196    INT hit;
     1197    HDC hdc;
     1198
     1199    pt.x = SLOWORD(lParam);
     1200    pt.y = SHIWORD(lParam);
     1201
     1202    TRACE("[%p] to (%ld,%ld)\n", hwnd, pt.x, pt.y);
     1203    ClientToScreen(hwnd, &pt);
     1204    GetWindowRect(hwnd, &wnrect);
     1205    if (PtInRect(&wnrect, pt)) {
     1206        TLbtnrect = wnrect;
     1207        BRbtnrect = wnrect;
     1208        if (dwStyle & PGS_HORZ) {
     1209            TLbtnrect.right = TLbtnrect.left + infoPtr->nButtonSize;
     1210            BRbtnrect.left = BRbtnrect.right - infoPtr->nButtonSize;
     1211        }
     1212        else {
     1213            TLbtnrect.bottom = TLbtnrect.top + infoPtr->nButtonSize;
     1214            BRbtnrect.top = BRbtnrect.bottom - infoPtr->nButtonSize;
     1215        }
     1216
     1217        clpt = pt;
     1218        MapWindowPoints(0, hwnd, &clpt, 1);
     1219        hit = PAGER_HitTest(hwnd, &clpt);
     1220        if (hit == HTLEFT || hit == HTTOP) {
     1221            topLeft = TRUE;
     1222            btnrect = &TLbtnrect;
     1223            infoPtr->TLbtnState = PGF_DEPRESSED;
     1224            btnstate = infoPtr->TLbtnState;
     1225        }
     1226        else if (hit == HTRIGHT || hit == HTBOTTOM) {
     1227            topLeft = FALSE;
     1228            btnrect = &BRbtnrect;
     1229            infoPtr->BRbtnState = PGF_DEPRESSED;
     1230            btnstate = infoPtr->BRbtnState;
     1231        }
     1232
     1233        /* If in one of the buttons the capture and draw buttons */
     1234        if (btnrect) {
     1235            TRACE("[%p] draw btn (%d,%d)-(%d,%d), Capture %s, style %08lx\n",
     1236                  hwnd, btnrect->left, btnrect->top,
     1237                  btnrect->right, btnrect->bottom,
     1238                  (infoPtr->bCapture) ? "TRUE" : "FALSE",
     1239                  dwStyle);
     1240            if (!infoPtr->bCapture)
     1241                PAGER_CaptureandTrack(infoPtr, hwnd);
     1242            if (dwStyle & PGS_AUTOSCROLL)
     1243                SetTimer(hwnd, TIMERID1, 0x3e, 0);
     1244            MapWindowPoints(0, hwnd, (LPPOINT)btnrect, 2);
     1245            hdc = GetWindowDC(hwnd);
     1246            /* OffsetRect(wnrect, 0 | 1, 0 | 1) */
     1247            PAGER_DrawButton(hdc, infoPtr->clrBk, *btnrect,
     1248                             PAGER_IsHorizontal(hwnd), topLeft, btnstate);
     1249            ReleaseDC(hwnd, hdc);
     1250            return DefWindowProcA (hwnd, WM_MOUSEMOVE, wParam, lParam);
     1251        }
     1252    }
     1253
     1254    /* If we think we are captured, then do release */
     1255    if (infoPtr->bCapture) {
     1256        infoPtr->bCapture = FALSE;
     1257
     1258        if (GetCapture() == hwnd) {
     1259            ReleaseCapture();
     1260            /* Notify parent of released mouse capture */
     1261            {
     1262                NMHDR nmhdr;
     1263                ZeroMemory (&nmhdr, sizeof (NMHDR));
     1264                nmhdr.hwndFrom = hwnd;
     1265                nmhdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
     1266                nmhdr.code = NM_RELEASEDCAPTURE;
     1267                SendMessageA (GetParent(hwnd), WM_NOTIFY,
     1268                              (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
     1269            }
     1270        }
     1271        if (IsWindow(hwnd))
     1272            KillTimer(hwnd, TIMERID1);
     1273    }
     1274    return DefWindowProcA (hwnd, WM_MOUSEMOVE, wParam, lParam);
     1275}
     1276
     1277static LRESULT
    11691278PAGER_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
    11701279{
    11711280    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
    11721281    BOOL repaintBtns = FALSE;
    1173     POINT pt = { SLOWORD(lParam), SHIWORD(lParam) };
     1282    POINT pt;
    11741283    INT hit;
    11751284
    1176     TRACE("[%04x]\n", hwnd);
    1177        
     1285    pt.x = SLOWORD(lParam);
     1286    pt.y = SHIWORD(lParam);
     1287
     1288    TRACE("[%p] at (%d,%d)\n", hwnd, SLOWORD(lParam), SHIWORD(lParam));
     1289
    11781290    hit = PAGER_HitTest(hwnd, &pt);
    11791291
     
    11831295        repaintBtns = infoPtr->TLbtnState != PGF_DEPRESSED;
    11841296        infoPtr->TLbtnState = PGF_DEPRESSED;
    1185         SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0); 
     1297        SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0);
    11861298    }
    11871299    else if (hit == HTRIGHT || hit == HTBOTTOM)
     
    11891301        repaintBtns = infoPtr->BRbtnState != PGF_DEPRESSED;
    11901302        infoPtr->BRbtnState = PGF_DEPRESSED;
    1191         SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0); 
     1303        SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0);
    11921304    }
    11931305
    11941306    if (repaintBtns)
    1195         SendMessageA(hwnd, WM_NCPAINT, 0, 0); 
     1307        SendMessageA(hwnd, WM_NCPAINT, 0, 0);
    11961308
    11971309    switch(hit)
    11981310    {
    11991311    case HTLEFT:
    1200         TRACE("[%04x] PGF_SCROLLLEFT\n", hwnd);
     1312        TRACE("[%p] PGF_SCROLLLEFT\n", hwnd);
    12011313        PAGER_Scroll(hwnd, PGF_SCROLLLEFT);
    12021314        break;
    12031315    case HTTOP:
    1204         TRACE("[%04x] PGF_SCROLLUP\n", hwnd);
     1316        TRACE("[%p] PGF_SCROLLUP\n", hwnd);
    12051317        PAGER_Scroll(hwnd, PGF_SCROLLUP);
    12061318        break;
    12071319    case HTRIGHT:
    1208         TRACE("[%04x] PGF_SCROLLRIGHT\n", hwnd);
     1320        TRACE("[%p] PGF_SCROLLRIGHT\n", hwnd);
    12091321        PAGER_Scroll(hwnd, PGF_SCROLLRIGHT);
    12101322        break;
    12111323    case HTBOTTOM:
    1212         TRACE("[%04x] PGF_SCROLLDOWN\n", hwnd);
     1324        TRACE("[%p] PGF_SCROLLDOWN\n", hwnd);
    12131325        PAGER_Scroll(hwnd, PGF_SCROLLDOWN);
    12141326        break;
     
    12241336{
    12251337    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
    1226     TRACE("[%04x]\n", hwnd);
     1338    TRACE("[%p]\n", hwnd);
    12271339
    12281340    KillTimer (hwnd, TIMERID1);
     
    12321344    PAGER_UpdateBtns(hwnd, infoPtr, -1, FALSE);
    12331345
     1346    return 0;
     1347}
     1348
     1349static LRESULT
     1350PAGER_NCLButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
     1351{
     1352    POINT pt;
     1353
     1354    pt.x = SLOWORD(lParam);
     1355    pt.y = SHIWORD(lParam);
     1356
     1357    TRACE("[%p] at (%d,%d)\n", hwnd, SLOWORD(lParam), SHIWORD(lParam));
     1358    MapWindowPoints(0, hwnd, &pt, 1);
     1359    lParam = MAKELONG(pt.x, pt.y);
     1360    return PAGER_LButtonDown (hwnd, wParam, lParam);
     1361}
     1362
     1363static LRESULT
     1364PAGER_Timer (HWND hwnd, WPARAM wParam)
     1365{
     1366    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
     1367    DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
     1368    INT dir;
     1369
     1370    /* if initial timer, kill it and start the repeat timer */
     1371    if (wParam == TIMERID1) {
     1372        if (PAGER_IsHorizontal(hwnd)) {
     1373            dir = (infoPtr->TLbtnState & PGF_DEPRESSED) ?
     1374                PGF_SCROLLLEFT : PGF_SCROLLRIGHT;
     1375        }
     1376        else {
     1377            dir = (infoPtr->TLbtnState & PGF_DEPRESSED) ?
     1378                PGF_SCROLLUP : PGF_SCROLLDOWN;
     1379        }
     1380        TRACE("[%p] TIMERID1: style=%08lx, dir=%d\n", hwnd, dwStyle, dir);
     1381        KillTimer(hwnd, TIMERID1);
     1382        SetTimer(hwnd, TIMERID1, REPEAT_DELAY, 0);
     1383        if (dwStyle & PGS_AUTOSCROLL) {
     1384            PAGER_Scroll(hwnd, dir);
     1385            SetWindowPos(hwnd, 0,0,0,0,0,
     1386                         SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE |
     1387                         SWP_NOZORDER | SWP_NOACTIVATE);
     1388        }
     1389        return 0;
     1390
     1391    }
     1392
     1393    TRACE("[%p] TIMERID2: dir=%d\n", hwnd, infoPtr->direction);
     1394    KillTimer(hwnd, TIMERID2);
     1395    if (infoPtr->direction > 0) {
     1396        PAGER_Scroll(hwnd, infoPtr->direction);
     1397        SetTimer(hwnd, TIMERID2, REPEAT_DELAY, 0);
     1398    }
    12341399    return 0;
    12351400}
     
    12881453
    12891454    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
    1290     TRACE("[%04x] %dx%d\n", hwnd, LOWORD(lParam), HIWORD(lParam));
     1455    TRACE("[%p] %dx%d\n", hwnd, SLOWORD(lParam), SHIWORD(lParam));
    12911456
    12921457    if (PAGER_IsHorizontal(hwnd))
    1293         infoPtr->nHeight = HIWORD(lParam);
     1458        infoPtr->nHeight = SHIWORD(lParam);
    12941459    else
    1295         infoPtr->nWidth = LOWORD(lParam);
     1460        infoPtr->nWidth = SLOWORD(lParam);
    12961461
    12971462    return PAGER_RecalcSize(hwnd);
     
    13341499        case PGM_RECALCSIZE:
    13351500            return PAGER_RecalcSize(hwnd);
    1336    
     1501
    13371502        case PGM_SETBKCOLOR:
    13381503            return PAGER_SetBkColor (hwnd, wParam, lParam);
     
    13821547            if (infoPtr->bForward && infoPtr->hwndChild)
    13831548                PostMessageA(infoPtr->hwndChild, WM_MOUSEMOVE, wParam, lParam);
    1384             return TRUE;                       
     1549            return PAGER_MouseMove (hwnd, wParam, lParam);
    13851550
    13861551        case WM_MOUSELEAVE:
    1387             return PAGER_MouseLeave (hwnd, wParam, lParam);     
     1552            return PAGER_MouseLeave (hwnd, wParam, lParam);
     1553
     1554        case WM_NCLBUTTONDOWN:
     1555            return PAGER_NCLButtonDown (hwnd, wParam, lParam);
    13881556
    13891557        case WM_LBUTTONDOWN:
    13901558            return PAGER_LButtonDown (hwnd, wParam, lParam);
    13911559
     1560        case WM_NCLBUTTONUP:
    13921561        case WM_LBUTTONUP:
    13931562            return PAGER_LButtonUp (hwnd, wParam, lParam);
     
    13971566/*
    13981567        case WM_PAINT:
    1399             return PAGER_Paint (hwnd, wParam); 
     1568            return PAGER_Paint (hwnd, wParam);
    14001569*/
    14011570        case WM_TIMER:
    1402             /* if initial timer, kill it and start the repeat timer */
    1403             if (wParam == TIMERID1)
    1404             {
    1405                 KillTimer(hwnd, TIMERID1);
    1406                 SetTimer(hwnd, TIMERID2, REPEAT_DELAY, 0);
    1407             }
    1408 
    1409             KillTimer(hwnd, TIMERID2);
    1410             if (infoPtr->direction > 0)
    1411             {
    1412                 PAGER_Scroll(hwnd, infoPtr->direction);
    1413                 SetTimer(hwnd, TIMERID2, REPEAT_DELAY, 0);         
    1414             }
    1415             break;
     1571            return PAGER_Timer (hwnd, wParam);
    14161572
    14171573        case WM_NOTIFY:
     
    14401596    wndClass.hbrBackground = 0;
    14411597    wndClass.lpszClassName = WC_PAGESCROLLERA;
    1442  
     1598
    14431599    RegisterClassA (&wndClass);
    14441600}
     
    14501606    UnregisterClassA (WC_PAGESCROLLERA, (HINSTANCE)NULL);
    14511607}
    1452 
  • trunk/src/comctl32/progress.c

    r8382 r9370  
    1 /*             
     1/*
    22 * Progress control
    33 *
     
    1818 * License along with this library; if not, write to the Free Software
    1919 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     20 *
     21 * NOTE
     22 *
     23 * This code was audited for completeness against the documented features
     24 * of Comctl32.dll version 6.0 on Sep. 9, 2002, by Dimitrie O. Paun.
     25 *
     26 * Unless otherwise noted, we belive this code to be complete, as per
     27 * the specification mentioned above.
     28 * If you discover missing features, or bugs, please note them below.
     29 *
     30 * TODO
     31 *   --support PBS_MARQUE
     32 *
    2033 */
    2134
     
    4356#define LED_GAP    2
    4457
    45 #define UNKNOWN_PARAM(msg, wParam, lParam) WARN(       \
    46    "Unknown parameter(s) for message " #msg            \
    47    "(%04x): wp=%04x lp=%08lx\n", msg, wParam, lParam);
    48 
    49 /***********************************************************************
    50  * PROGRESS_EraseBackground
    51  */
    52 static void PROGRESS_EraseBackground(PROGRESS_INFO *infoPtr, WPARAM wParam)
    53 {
     58/***********************************************************************
     59 * PROGRESS_Invalidate
     60 *
     61 * Invalide the range between old and new pos.
     62 */
     63static void PROGRESS_Invalidate( PROGRESS_INFO *infoPtr, INT old, INT new )
     64{
     65    LONG style = GetWindowLongW (infoPtr->Self, GWL_STYLE);
    5466    RECT rect;
    55     HBRUSH hbrBk;
    56     HDC hdc = wParam ? (HDC)wParam : GetDC(infoPtr->Self);
    57 
    58     /* get the required background brush */
    59     if(infoPtr->ColorBk == CLR_DEFAULT)
    60         hbrBk = GetSysColorBrush(COLOR_3DFACE);
     67    int oldPos, newPos, ledWidth;
     68
     69    GetClientRect (infoPtr->Self, &rect);
     70    InflateRect(&rect, -1, -1);
     71
     72    if (style & PBS_VERTICAL)
     73    {
     74        oldPos = rect.bottom - MulDiv (old - infoPtr->MinVal, rect.bottom - rect.top,
     75                                       infoPtr->MaxVal - infoPtr->MinVal);
     76        newPos = rect.bottom - MulDiv (new - infoPtr->MinVal, rect.bottom - rect.top,
     77                                       infoPtr->MaxVal - infoPtr->MinVal);
     78        ledWidth = MulDiv (rect.right - rect.left, 2, 3);
     79        rect.top = min( oldPos, newPos );
     80        rect.bottom = max( oldPos, newPos );
     81        if (!(style & PBS_SMOOTH)) rect.top -= ledWidth;
     82        InvalidateRect( infoPtr->Self, &rect, oldPos < newPos );
     83    }
    6184    else
    62         hbrBk = CreateSolidBrush(infoPtr->ColorBk);
    63 
    64     /* get client rectangle */
    65     GetClientRect(infoPtr->Self, &rect);
    66 
    67     /* draw the background */
    68     FillRect(hdc, &rect, hbrBk);
    69 
    70     /* delete background brush */
    71     if(infoPtr->ColorBk != CLR_DEFAULT)
    72         DeleteObject (hbrBk);
    73 
    74     if(!wParam) ReleaseDC(infoPtr->Self, hdc);
    75 }
     85    {
     86        oldPos = rect.left + MulDiv (old - infoPtr->MinVal, rect.right - rect.left,
     87                                     infoPtr->MaxVal - infoPtr->MinVal);
     88        newPos = rect.left + MulDiv (new - infoPtr->MinVal, rect.right - rect.left,
     89                                     infoPtr->MaxVal - infoPtr->MinVal);
     90        ledWidth = MulDiv (rect.bottom - rect.top, 2, 3);
     91        rect.left = min( oldPos, newPos );
     92        rect.right = max( oldPos, newPos );
     93        if (!(style & PBS_SMOOTH)) rect.right += ledWidth;
     94        InvalidateRect( infoPtr->Self, &rect, oldPos > newPos );
     95    }
     96}
     97
    7698
    7799/***********************************************************************
     
    81103static LRESULT PROGRESS_Draw (PROGRESS_INFO *infoPtr, HDC hdc)
    82104{
    83     HBRUSH hbrBar;
     105    HBRUSH hbrBar, hbrBk;
    84106    int rightBar, rightMost, ledWidth;
    85107    RECT rect;
    86108    DWORD dwStyle;
    87109
    88     TRACE("(infoPtr=%p, hdc=%x)\n", infoPtr, hdc);
     110    TRACE("(infoPtr=%p, hdc=%p)\n", infoPtr, hdc);
    89111
    90112    /* get the required bar brush */
     
    94116        hbrBar = CreateSolidBrush (infoPtr->ColorBar);
    95117
     118    if (infoPtr->ColorBk == CLR_DEFAULT)
     119        hbrBk = GetSysColorBrush(COLOR_3DFACE);
     120    else
     121        hbrBk = CreateSolidBrush(infoPtr->ColorBk);
     122
    96123    /* get client rectangle */
    97124    GetClientRect (infoPtr->Self, &rect);
    98 
     125    FrameRect( hdc, &rect, hbrBk );
    99126    InflateRect(&rect, -1, -1);
    100127
     
    104131    /* compute extent of progress bar */
    105132    if (dwStyle & PBS_VERTICAL) {
    106         rightBar  = rect.bottom - 
     133        rightBar  = rect.bottom -
    107134                    MulDiv (infoPtr->CurVal - infoPtr->MinVal,
    108135                            rect.bottom - rect.top,
     
    111138        rightMost = rect.top;
    112139    } else {
    113         rightBar = rect.left + 
     140        rightBar = rect.left +
    114141                   MulDiv (infoPtr->CurVal - infoPtr->MinVal,
    115142                           rect.right - rect.left,
     
    120147
    121148    /* now draw the bar */
    122     if (dwStyle & PBS_SMOOTH) {
    123         if (dwStyle & PBS_VERTICAL)
    124             rect.top = rightBar;
    125         else
    126             rect.right = rightBar;
    127         FillRect(hdc, &rect, hbrBar);
     149    if (dwStyle & PBS_SMOOTH)
     150    {
     151        if (dwStyle & PBS_VERTICAL)
     152        {
     153            INT old_top = rect.top;
     154            rect.top = rightBar;
     155            FillRect(hdc, &rect, hbrBar);
     156            rect.bottom = rect.top;
     157            rect.top = old_top;
     158            FillRect(hdc, &rect, hbrBk);
     159        }
     160        else
     161        {
     162            INT old_right = rect.right;
     163            rect.right = rightBar;
     164            FillRect(hdc, &rect, hbrBar);
     165            rect.left = rect.right;
     166            rect.right = old_right;
     167            FillRect(hdc, &rect, hbrBk);
     168        }
    128169    } else {
    129170        if (dwStyle & PBS_VERTICAL) {
    130             while(rect.bottom > rightBar) { 
     171            while(rect.bottom > rightBar) {
    131172                rect.top = rect.bottom - ledWidth;
    132173                if (rect.top < rightMost)
    133174                    rect.top = rightMost;
    134175                FillRect(hdc, &rect, hbrBar);
    135                 rect.bottom = rect.top - LED_GAP;
     176                rect.bottom = rect.top;
     177                rect.top -= LED_GAP;
     178                if (rect.top <= rightBar) break;
     179                FillRect(hdc, &rect, hbrBk);
     180                rect.bottom = rect.top;
    136181            }
     182            rect.top = rightMost;
     183            FillRect(hdc, &rect, hbrBk);
    137184        } else {
    138             while(rect.left < rightBar) { 
     185            while(rect.left < rightBar) {
    139186                rect.right = rect.left + ledWidth;
    140187                if (rect.right > rightMost)
    141188                    rect.right = rightMost;
    142189                FillRect(hdc, &rect, hbrBar);
    143                 rect.left  = rect.right + LED_GAP;
     190                rect.left = rect.right;
     191                rect.right += LED_GAP;
     192                if (rect.right >= rightBar) break;
     193                FillRect(hdc, &rect, hbrBk);
     194                rect.left = rect.right;
    144195            }
     196            rect.right = rightMost;
     197            FillRect(hdc, &rect, hbrBk);
    145198        }
    146199    }
    147200
    148201    /* delete bar brush */
    149     if (infoPtr->ColorBar != CLR_DEFAULT)
    150         DeleteObject (hbrBar);
     202    if (infoPtr->ColorBar != CLR_DEFAULT) DeleteObject (hbrBar);
     203    if (infoPtr->ColorBk != CLR_DEFAULT) DeleteObject (hbrBk);
    151204
    152205    return 0;
     
    201254    /* if nothing changes, simply return */
    202255    if(infoPtr->MinVal == low && infoPtr->MaxVal == high) return res;
    203    
     256
    204257    infoPtr->MinVal = low;
    205258    infoPtr->MaxVal = high;
     
    211264 *           ProgressWindowProc
    212265 */
    213 static LRESULT WINAPI ProgressWindowProc(HWND hwnd, UINT message, 
     266static LRESULT WINAPI ProgressWindowProc(HWND hwnd, UINT message,
    214267                                  WPARAM wParam, LPARAM lParam)
    215268{
    216269    PROGRESS_INFO *infoPtr;
    217270
    218     TRACE("hwnd=%x msg=%04x wparam=%x lParam=%lx\n", hwnd, message, wParam, lParam);
     271    TRACE("hwnd=%p msg=%04x wparam=%x lParam=%lx\n", hwnd, message, wParam, lParam);
    219272
    220273    infoPtr = (PROGRESS_INFO *)GetWindowLongW(hwnd, 0);
    221274
    222275    if (!infoPtr && message != WM_CREATE)
    223         return DefWindowProcW( hwnd, message, wParam, lParam ); 
     276        return DefWindowProcW( hwnd, message, wParam, lParam );
    224277
    225278    switch(message) {
     
    229282        dwExStyle &= ~(WS_EX_CLIENTEDGE | WS_EX_WINDOWEDGE);
    230283        dwExStyle |= WS_EX_STATICEDGE;
    231         SetWindowLongW (hwnd, GWL_EXSTYLE, dwExStyle | WS_EX_STATICEDGE);
     284        SetWindowLongW (hwnd, GWL_EXSTYLE, dwExStyle);
    232285        /* Force recalculation of a non-client area */
    233286        SetWindowPos(hwnd, 0, 0, 0, 0, 0,
     
    241294        /* initialize the info struct */
    242295        infoPtr->Self = hwnd;
    243         infoPtr->MinVal = 0; 
     296        infoPtr->MinVal = 0;
    244297        infoPtr->MaxVal = 100;
    245         infoPtr->CurVal = 0; 
     298        infoPtr->CurVal = 0;
    246299        infoPtr->Step = 10;
    247300        infoPtr->ColorBar = CLR_DEFAULT;
    248301        infoPtr->ColorBk = CLR_DEFAULT;
    249302        infoPtr->Font = 0;
    250         TRACE("Progress Ctrl creation, hwnd=%04x\n", hwnd);
     303        TRACE("Progress Ctrl creation, hwnd=%p\n", hwnd);
    251304        return 0;
    252305    }
    253    
     306
    254307    case WM_DESTROY:
    255         TRACE("Progress Ctrl destruction, hwnd=%04x\n", hwnd);
     308        TRACE("Progress Ctrl destruction, hwnd=%p\n", hwnd);
    256309        COMCTL32_Free (infoPtr);
    257310        SetWindowLongW(hwnd, 0, 0);
    258311        return 0;
    259312
    260     case WM_ERASEBKGND:
    261         PROGRESS_EraseBackground(infoPtr, wParam);
    262         return TRUE;
    263        
    264313    case WM_GETFONT:
    265314        return (LRESULT)infoPtr->Font;
    266315
    267316    case WM_SETFONT:
    268         return PROGRESS_SetFont (infoPtr, (HFONT)wParam, (BOOL)lParam);
     317        return (LRESULT)PROGRESS_SetFont(infoPtr, (HFONT)wParam, (BOOL)lParam);
    269318
    270319    case WM_PAINT:
    271320        return PROGRESS_Paint (infoPtr, (HDC)wParam);
    272    
     321
    273322    case PBM_DELTAPOS:
    274323    {
    275324        INT oldVal;
    276         if(lParam) UNKNOWN_PARAM(PBM_DELTAPOS, wParam, lParam);
    277325        oldVal = infoPtr->CurVal;
    278326        if(wParam != 0) {
    279             BOOL bErase;
    280327            infoPtr->CurVal += (INT)wParam;
    281328            PROGRESS_CoercePos (infoPtr);
    282329            TRACE("PBM_DELTAPOS: current pos changed from %d to %d\n", oldVal, infoPtr->CurVal);
    283             bErase = (oldVal > infoPtr->CurVal);
    284             InvalidateRect(hwnd, NULL, bErase);
     330            PROGRESS_Invalidate( infoPtr, oldVal, infoPtr->CurVal );
    285331        }
    286332        return oldVal;
     
    290336    {
    291337        INT oldVal;
    292         if (lParam) UNKNOWN_PARAM(PBM_SETPOS, wParam, lParam);
    293338        oldVal = infoPtr->CurVal;
    294339        if(oldVal != wParam) {
    295             BOOL bErase;
    296340            infoPtr->CurVal = (INT)wParam;
    297341            PROGRESS_CoercePos(infoPtr);
    298342            TRACE("PBM_SETPOS: current pos changed from %d to %d\n", oldVal, infoPtr->CurVal);
    299             bErase = (oldVal > infoPtr->CurVal);
    300             InvalidateRect(hwnd, NULL, bErase);
     343            PROGRESS_Invalidate( infoPtr, oldVal, infoPtr->CurVal );
    301344        }
    302345        return oldVal;
    303346    }
    304      
     347
    305348    case PBM_SETRANGE:
    306         if (wParam) UNKNOWN_PARAM(PBM_SETRANGE, wParam, lParam);
    307349        return PROGRESS_SetRange (infoPtr, (int)LOWORD(lParam), (int)HIWORD(lParam));
    308350
     
    310352    {
    311353        INT oldStep;
    312         if (lParam) UNKNOWN_PARAM(PBM_SETSTEP, wParam, lParam);
    313354        oldStep = infoPtr->Step;
    314355        infoPtr->Step = (INT)wParam;
     
    319360    {
    320361        INT oldVal;
    321         if (wParam || lParam) UNKNOWN_PARAM(PBM_STEPIT, wParam, lParam);
    322         oldVal = infoPtr->CurVal;   
     362        oldVal = infoPtr->CurVal;
    323363        infoPtr->CurVal += infoPtr->Step;
    324364        if(infoPtr->CurVal > infoPtr->MaxVal)
     
    326366        if(oldVal != infoPtr->CurVal)
    327367        {
    328             BOOL bErase;
    329368            TRACE("PBM_STEPIT: current pos changed from %d to %d\n", oldVal, infoPtr->CurVal);
    330             bErase = (oldVal > infoPtr->CurVal);
    331             InvalidateRect(hwnd, NULL, bErase);
     369            PROGRESS_Invalidate( infoPtr, oldVal, infoPtr->CurVal );
    332370        }
    333371        return oldVal;
     
    336374    case PBM_SETRANGE32:
    337375        return PROGRESS_SetRange (infoPtr, (int)wParam, (int)lParam);
    338    
     376
    339377    case PBM_GETRANGE:
    340378        if (lParam) {
     
    345383
    346384    case PBM_GETPOS:
    347         if (wParam || lParam) UNKNOWN_PARAM(PBM_STEPIT, wParam, lParam);
    348385        return infoPtr->CurVal;
    349386
    350387    case PBM_SETBARCOLOR:
    351         if (wParam) UNKNOWN_PARAM(PBM_SETBARCOLOR, wParam, lParam);
    352388        infoPtr->ColorBar = (COLORREF)lParam;
    353389        InvalidateRect(hwnd, NULL, TRUE);
     
    355391
    356392    case PBM_SETBKCOLOR:
    357         if (wParam) UNKNOWN_PARAM(PBM_SETBKCOLOR, wParam, lParam);
    358393        infoPtr->ColorBk = (COLORREF)lParam;
    359394        InvalidateRect(hwnd, NULL, TRUE);
    360395        return 0;
    361396
    362     default: 
    363         if (message >= WM_USER)
     397    default:
     398        if ((message >= WM_USER) && (message < WM_APP))
    364399            ERR("unknown msg %04x wp=%04x lp=%08lx\n", message, wParam, lParam );
    365         return DefWindowProcW( hwnd, message, wParam, lParam ); 
    366     } 
     400        return DefWindowProcW( hwnd, message, wParam, lParam );
     401    }
    367402}
    368403
     
    398433    UnregisterClassW (PROGRESS_CLASSW, (HINSTANCE)NULL);
    399434}
    400 
  • trunk/src/comctl32/propsheet.c

    r8515 r9370  
    2525
    2626#include <string.h>
     27
    2728#include "winbase.h"
    2829#include "commctrl.h"
     
    3031#include "winnls.h"
    3132#include "comctl32.h"
     33#include "heap.h"
     34
    3235#include "wine/debug.h"
    33 #include "heap.h"
    34 
     36#include "wine/unicode.h"
    3537
    3638/******************************************************************************
    3739 * Data structures
    3840 */
     41#include "pshpack2.h"
     42
    3943typedef struct
    4044{
     
    4549  DWORD style;
    4650} MyDLGTEMPLATEEX;
     51
     52typedef struct
     53{
     54  DWORD helpid;
     55  DWORD exStyle;
     56  DWORD style;
     57  short x;
     58  short y;
     59  short cy;
     60  DWORD id;
     61} MyDLGITEMTEMPLATEEX;
     62#include "poppack.h"
    4763
    4864typedef struct tagPropPageInfo
     
    89105 */
    90106
    91 const WCHAR PropSheetInfoStr[] = 
     107const WCHAR PropSheetInfoStr[] =
    92108    {'P','r','o','p','e','r','t','y','S','h','e','e','t','I','n','f','o',0 };
    93109
     
    139155                                int skipdir,
    140156                                HPROPSHEETPAGE hpage);
     157static void PROPSHEET_SetCurSelId(HWND hwndDlg, int id);
    141158static LRESULT PROPSHEET_QuerySiblings(HWND hwndDlg,
    142159                                       WPARAM wParam, LPARAM lParam);
     
    210227
    211228/******************************************************************************
     229 *            PROPSHEET_GetPageRect
     230 *
     231 * Retrieve rect from tab control and map into the dialog for SetWindowPos
     232 */
     233static void PROPSHEET_GetPageRect(const PropSheetInfo * psInfo, HWND hwndDlg, RECT *rc)
     234{
     235    HWND hwndTabCtrl = GetDlgItem(hwndDlg, IDC_TABCONTROL);
     236
     237    GetClientRect(hwndTabCtrl, rc);
     238    SendMessageW(hwndTabCtrl, TCM_ADJUSTRECT, FALSE, (LPARAM)rc);
     239    MapWindowPoints(hwndTabCtrl, hwndDlg, (LPPOINT)rc, 2);
     240}
     241
     242/******************************************************************************
    212243 *            PROPSHEET_FindPageByResId
    213244 *
     
    262293
    263294  memcpy(&psInfo->ppshheader,lppsh,dwSize);
    264   TRACE("\n** PROPSHEETHEADER **\ndwSize\t\t%ld\ndwFlags\t\t%08lx\nhwndParent\t%04x\nhInstance\t%08x\npszCaption\t'%s'\nnPages\t\t%d\npfnCallback\t%p\n",
     295  TRACE("\n** PROPSHEETHEADER **\ndwSize\t\t%ld\ndwFlags\t\t%08lx\nhwndParent\t%p\nhInstance\t%p\npszCaption\t'%s'\nnPages\t\t%d\npfnCallback\t%p\n",
    265296        lppsh->dwSize, lppsh->dwFlags, lppsh->hwndParent, lppsh->hInstance,
    266297        debugstr_a(lppsh->pszCaption), lppsh->nPages, lppsh->pfnCallback);
     
    313344
    314345  memcpy(&psInfo->ppshheader,lppsh,dwSize);
    315   TRACE("\n** PROPSHEETHEADER **\ndwSize\t\t%ld\ndwFlags\t\t%08lx\nhwndParent\t%04x\nhInstance\t%08x\npszCaption\t'%s'\nnPages\t\t%d\npfnCallback\t%p\n",
     346  TRACE("\n** PROPSHEETHEADER **\ndwSize\t\t%ld\ndwFlags\t\t%08lx\nhwndParent\t%p\nhInstance\t%p\npszCaption\t'%s'\nnPages\t\t%d\npfnCallback\t%p\n",
    316347      lppsh->dwSize, lppsh->dwFlags, lppsh->hwndParent, lppsh->hInstance, debugstr_w(lppsh->pszCaption), lppsh->nPages, lppsh->pfnCallback);
    317348
     
    443474      p += lstrlenW( (LPCWSTR)p ) + 1;
    444475      break;
    445   } 
     476  }
    446477
    447478  /* class */
     
    492523   * Build the image list for icons
    493524   */
    494   if ((dwFlags & PSP_USEHICON) || (dwFlags & PSP_USEICONID)) 
     525  if ((dwFlags & PSP_USEHICON) || (dwFlags & PSP_USEICONID))
    495526  {
    496527    HICON hIcon;
     
    499530
    500531    if (dwFlags & PSP_USEICONID)
    501       hIcon = LoadImageW(lppsp->hInstance, lppsp->u2.pszIcon, IMAGE_ICON, 
     532      hIcon = LoadImageW(lppsp->hInstance, lppsp->u2.pszIcon, IMAGE_ICON,
    502533                         icon_cx, icon_cy, LR_DEFAULTCOLOR);
    503534    else
     
    569600                                       psInfo->ppshheader.hwndParent,
    570601                                       (DLGPROC) PROPSHEET_DialogProc,
    571                                        (LPARAM)psInfo);
     602                                       (LPARAM)psInfo) ? TRUE : FALSE;
    572603
    573604  COMCTL32_Free(temp);
     
    578609/******************************************************************************
    579610 *            PROPSHEET_SizeMismatch
    580  * 
     611 *
    581612 *     Verify that the tab control and the "largest" property sheet page dlg. template
    582613 *     match in size.
     
    702733      psInfo->height = MulDiv((rc.bottom - rc.top),8,units.top);
    703734  }
    704  
     735
    705736  if ((rc.right - rc.left) < (tabRect.right - tabRect.left))
    706737  {
     
    716747  rc.right -= rc.left;
    717748  rc.bottom -= rc.top;
     749  TRACE("setting tab %08lx, rc (0,0)-(%d,%d)\n",
     750        (DWORD)hwndTabCtrl, rc.right, rc.bottom);
    718751  SetWindowPos(hwndTabCtrl, 0, 0, 0, rc.right, rc.bottom,
    719752               SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
     
    730763   * Resize the property sheet.
    731764   */
     765  TRACE("setting dialog %08lx, rc (0,0)-(%d,%d)\n",
     766        (DWORD)hwndDlg, rc.right, rc.bottom);
    732767  SetWindowPos(hwndDlg, 0, 0, 0, rc.right, rc.bottom,
    733768               SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
     
    779814      psInfo->height = MulDiv((rc.bottom - rc.top), 8, units.top);
    780815  }
    781  
     816
    782817  if ((rc.right - rc.left) < (tabRect.right - tabRect.left))
    783818  {
     
    787822
    788823  TRACE("Biggest page %d %d %d %d\n", rc.left, rc.top, rc.right, rc.bottom);
     824  TRACE("   constants padx=%d, pady=%d, butH=%d, lH=%d\n",
     825        padding.x, padding.y, buttonHeight, lineHeight);
    789826
    790827  /* Make room */
     
    795832   * Resize the property sheet.
    796833   */
     834  TRACE("setting dialog %08lx, rc (0,0)-(%d,%d)\n",
     835        (DWORD)hwndDlg, rc.right, rc.bottom);
    797836  SetWindowPos(hwndDlg, 0, 0, 0, rc.right, rc.bottom,
    798837               SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
     
    829868  /*
    830869   * Get the size of the property sheet.
    831    */ 
     870   */
    832871  GetClientRect(hwndParent, &rcSheet);
    833872
    834   /* 
     873  /*
    835874   * All buttons will be at this y coordinate.
    836875   */
     
    868907    else
    869908      x = rcSheet.right - (padding.x + buttonWidth);
    870  
     909
    871910    SetWindowPos(hwndButton, 0, x, y, 0, 0,
    872911                 SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
     
    885924  {
    886925    x = rcSheet.right - (padding.x + buttonWidth);
    887  
     926
    888927    SetWindowPos(hwndButton, 0, x, y, 0, 0,
    889928                 SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
     
    10641103    }
    10651104  }
    1066  
     1105
    10671106  hwndControl = GetDlgItem(hwndDlg, idButton);
    10681107  GetWindowRect(hwndControl, &rc);
     
    11361175
    11371176  return TRUE;
     1177}
     1178/*
     1179 * Get the size of an in-memory Template
     1180 *
     1181 *( Based on the code of PROPSHEET_CollectPageInfo)
     1182 */
     1183
     1184static UINT GetTemplateSize(DLGTEMPLATE* pTemplate)
     1185
     1186{
     1187  const WORD*  p = (const WORD *)pTemplate;
     1188  BOOL  istemplateex = (((MyDLGTEMPLATEEX*)pTemplate)->signature == 0xFFFF);
     1189  WORD nrofitems;
     1190
     1191  if (istemplateex)
     1192  {
     1193    /* DIALOGEX template */
     1194
     1195    p++;       /* dlgVer    */
     1196    p++;       /* signature */
     1197    p += 2;    /* help ID   */
     1198    p += 2;    /* ext style */
     1199    p += 2;    /* style     */
     1200  }
     1201  else
     1202  {
     1203    /* DIALOG template */
     1204
     1205    p += 2;    /* style     */
     1206    p += 2;    /* ext style */
     1207  }
     1208
     1209  nrofitems =   (WORD)*p; p++;    /* nb items */
     1210  p++;    /*   x      */
     1211  p++;    /*   y      */
     1212  p++;    /*   width  */
     1213  p++;    /*   height */
     1214
     1215  /* menu */
     1216  switch ((WORD)*p)
     1217  {
     1218    case 0x0000:
     1219      p++;
     1220      break;
     1221    case 0xffff:
     1222      p += 2;
     1223      break;
     1224    default:
     1225      TRACE("menu %s\n",debugstr_w((LPCWSTR)p));
     1226      p += lstrlenW( (LPCWSTR)p ) + 1;
     1227      break;
     1228  }
     1229
     1230  /* class */
     1231  switch ((WORD)*p)
     1232  {
     1233    case 0x0000:
     1234      p++;
     1235      break;
     1236    case 0xffff:
     1237      p += 2;
     1238      break;
     1239    default:
     1240      TRACE("class %s\n",debugstr_w((LPCWSTR)p));
     1241      p += lstrlenW( (LPCWSTR)p ) + 1;
     1242      break;
     1243  }
     1244
     1245  /*title */
     1246  TRACE("title %s\n",debugstr_w((LPCWSTR)p));
     1247  p += lstrlenW((LPCWSTR)p) + 1;
     1248
     1249  /* font, if DS_FONT set */
     1250  if ((DS_SETFONT & ((istemplateex)?  ((MyDLGTEMPLATEEX*)pTemplate)->style :
     1251                     pTemplate->style)))
     1252    {
     1253      p+=(istemplateex)?3:1;
     1254      TRACE("font %s\n",debugstr_w((LPCWSTR)p));
     1255      p += lstrlenW( (LPCWSTR)p ) + 1; /* the font name*/
     1256    }
     1257
     1258  TRACE("%d items\n",nrofitems);
     1259  while (nrofitems > 0)
     1260    {
     1261      p = (WORD*)(((DWORD)p + 3) & ~3); /* DWORD align */
     1262     
     1263      p += (istemplateex ? sizeof(MyDLGITEMTEMPLATEEX) : sizeof(DLGITEMTEMPLATE))/sizeof(WORD);
     1264     
     1265      switch ((WORD)*p)
     1266        {
     1267        case 0x0000:
     1268          p++;
     1269          break;
     1270        case 0xffff:
     1271          TRACE("class ordinal 0x%08lx\n",*(DWORD*)p);
     1272          p += 2;
     1273          break;
     1274        default:
     1275          TRACE("class %s\n",debugstr_w((LPCWSTR)p));
     1276          p += lstrlenW( (LPCWSTR)p ) + 1;
     1277          break;
     1278        }
     1279      switch ((WORD)*p)
     1280        {
     1281        case 0x0000:
     1282          p++;
     1283          break;
     1284        case 0xffff:
     1285          TRACE("text ordinal 0x%08lx\n",*(DWORD*)p);
     1286          p += 2;
     1287          break;
     1288        default:
     1289          TRACE("text %s\n",debugstr_w((LPCWSTR)p));
     1290          p += lstrlenW( (LPCWSTR)p ) + 1;
     1291          break;
     1292        }
     1293      p += *p + 1;    /* Skip extra data */
     1294      --nrofitems;
     1295    }
     1296 
     1297  TRACE("%p %p size 0x%08x\n",p, (WORD*)pTemplate,sizeof(WORD)*(p - (WORD*)pTemplate));
     1298  return (p - (WORD*)pTemplate)*sizeof(WORD);
     1299 
    11381300}
    11391301
     
    11651327
    11661328  if (ppshpage->dwFlags & PSP_DLGINDIRECT)
    1167     pTemplate = (DLGTEMPLATE*)ppshpage->u.pResource;
     1329    {
     1330      pTemplate = (DLGTEMPLATE*)ppshpage->u.pResource;
     1331      resSize = GetTemplateSize(pTemplate);
     1332    }
    11681333  else
    11691334  {
     
    11871352     * Make a copy of the dialog template to make it writable
    11881353     */
    1189     temp = COMCTL32_Alloc(resSize);
    1190     if (!temp)
    1191       return FALSE;
    1192 
    1193     memcpy(temp, pTemplate, resSize);
    1194     pTemplate = temp;
    1195   }
     1354  }
     1355  temp = COMCTL32_Alloc(resSize);
     1356  if (!temp)
     1357    return FALSE;
     1358 
     1359  memcpy(temp, pTemplate, resSize);
     1360  pTemplate = temp;
    11961361
    11971362  if (((MyDLGTEMPLATEEX*)pTemplate)->signature == 0xFFFF)
     
    12341399  ppInfo[index].hwndPage = hwndPage;
    12351400
    1236   rc.left = psInfo->x;
    1237   rc.top = psInfo->y;
    1238   rc.right = psInfo->width;
    1239   rc.bottom = psInfo->height;
    1240 
    1241   MapDialogRect(hwndParent, &rc);
    1242 
    1243   pageWidth = rc.right - rc.left;
    1244   pageHeight = rc.bottom - rc.top;
    1245 
    1246   if (psInfo->ppshheader.dwFlags & INTRNL_ANY_WIZARD)
    1247     padding = PROPSHEET_GetPaddingInfoWizard(hwndParent, psInfo);
    1248   else
    1249   {
    1250     /*
    1251      * Ask the Tab control to fit this page in.
    1252      */
    1253 
    1254     HWND hwndTabCtrl = GetDlgItem(hwndParent, IDC_TABCONTROL);
    1255     SendMessageW(hwndTabCtrl, TCM_ADJUSTRECT, FALSE, (LPARAM)&rc);
    1256     padding = PROPSHEET_GetPaddingInfo(hwndParent);
    1257   }
    1258 
    1259   SetWindowPos(hwndPage, HWND_TOP,
    1260                rc.left + padding.x/2,
    1261                rc.top + padding.y/2,
    1262                pageWidth, pageHeight, 0);
     1401  if (psInfo->ppshheader.dwFlags & INTRNL_ANY_WIZARD) {
     1402      /* FIXME: This code may no longer be correct.
     1403       *        It was not for the non-wizard path.  (GLA 6/02)
     1404       */
     1405      rc.left = psInfo->x;
     1406      rc.top = psInfo->y;
     1407      rc.right = psInfo->width;
     1408      rc.bottom = psInfo->height;
     1409
     1410      MapDialogRect(hwndParent, &rc);
     1411
     1412      pageWidth = rc.right - rc.left;
     1413      pageHeight = rc.bottom - rc.top;
     1414
     1415      padding = PROPSHEET_GetPaddingInfoWizard(hwndParent, psInfo);
     1416      TRACE("setting page %08lx, rc (%d,%d)-(%d,%d) w=%d, h=%d, padx=%d, pady=%d\n",
     1417            (DWORD)hwndPage, rc.left, rc.top, rc.right, rc.bottom,
     1418            pageWidth, pageHeight, padding.x, padding.y);
     1419      SetWindowPos(hwndPage, HWND_TOP,
     1420                   rc.left + padding.x/2,
     1421                   rc.top + padding.y/2,
     1422                   pageWidth, pageHeight, 0);
     1423  }
     1424  else {
     1425      /*
     1426       * Ask the Tab control to reduce the client rectangle to that
     1427       * it has available.
     1428       */
     1429      PROPSHEET_GetPageRect(psInfo, hwndParent, &rc);
     1430      pageWidth = rc.right - rc.left;
     1431      pageHeight = rc.bottom - rc.top;
     1432      TRACE("setting page %08lx, rc (%d,%d)-(%d,%d) w=%d, h=%d\n",
     1433            (DWORD)hwndPage, rc.left, rc.top, rc.right, rc.bottom,
     1434            pageWidth, pageHeight);
     1435      SetWindowPos(hwndPage, HWND_TOP,
     1436                   rc.left, rc.top,
     1437                   pageWidth, pageHeight, 0);
     1438  }
    12631439
    12641440  return TRUE;
     
    13261502  psn.hdr.idFrom   = 0;
    13271503  psn.lParam       = 0;
    1328  
     1504
    13291505  hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
    13301506
     
    13651541  psn.hdr.idFrom   = 0;
    13661542  psn.lParam       = 0;
    1367  
     1543
    13681544  hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
    13691545
     
    14041580  psn.hdr.idFrom   = 0;
    14051581  psn.lParam       = 0;
    1406  
     1582
    14071583  hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
    14081584
     
    14411617  psn.hdr.idFrom   = 0;
    14421618  psn.lParam       = 0;
    1443  
     1619
    14441620
    14451621  /*
     
    14581634  psn.hdr.code = PSN_APPLY;
    14591635  psn.lParam   = lParam;
    1460  
     1636
    14611637  for (i = 0; i < psInfo->nPages; i++)
    14621638  {
     
    15051681  psn.hdr.idFrom   = 0;
    15061682  psn.lParam       = 0;
    1507  
     1683
    15081684  if (SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn))
    15091685    return;
     
    15111687  psn.hdr.code = PSN_RESET;
    15121688  psn.lParam   = lParam;
    1513  
     1689
    15141690  for (i = 0; i < psInfo->nPages; i++)
    15151691  {
     
    15481724  psn.hdr.idFrom   = 0;
    15491725  psn.lParam       = 0;
    1550  
     1726
    15511727  SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn);
    15521728}
     
    16501826
    16511827/*************************************************************************
    1652  * BOOL PROPSHEET_CanSetCurSel [Internal] 
     1828 * BOOL PROPSHEET_CanSetCurSel [Internal]
    16531829 *
    16541830 * Test whether the current page can be changed by sending a PSN_KILLACTIVE
     
    17101886  PropSheetInfo* psInfo = (PropSheetInfo*) GetPropW(hwndDlg, PropSheetInfoStr);
    17111887  HWND hwndHelp  = GetDlgItem(hwndDlg, IDHELP);
     1888  HWND hwndTabControl = GetDlgItem(hwndDlg, IDC_TABCONTROL);
    17121889
    17131890  TRACE("index %d, skipdir %d, hpage %p\n", index, skipdir, hpage);
     
    17251902    int result;
    17261903    PSHNOTIFY psn;
     1904
     1905    if (hwndTabControl)
     1906        SendMessageW(hwndTabControl, TCM_SETCURSEL, index, 0);
    17271907
    17281908    psn.hdr.code     = PSN_SETACTIVE;
     
    17721952
    17731953/******************************************************************************
     1954 *            PROPSHEET_SetCurSelId
     1955 *
     1956 * Selects the page, specified by resource id.
     1957 */
     1958static void PROPSHEET_SetCurSelId(HWND hwndDlg, int id)
     1959{
     1960      int idx;
     1961      PropSheetInfo* psInfo =
     1962          (PropSheetInfo*) GetPropW(hwndDlg, PropSheetInfoStr);
     1963
     1964      idx = PROPSHEET_FindPageByResId(psInfo, id);
     1965      if (idx < psInfo->nPages )
     1966      {
     1967          if (PROPSHEET_CanSetCurSel(hwndDlg) != FALSE)
     1968              PROPSHEET_SetCurSel(hwndDlg, idx, 1, 0);
     1969      }
     1970}
     1971
     1972/******************************************************************************
    17741973 *            PROPSHEET_SetTitleA
    17751974 */
     
    17791978  {
    17801979     WCHAR szTitle[256];
    1781      MultiByteToWideChar(CP_ACP, 0, lpszText, -1, 
     1980     MultiByteToWideChar(CP_ACP, 0, lpszText, -1,
    17821981                             szTitle, sizeof szTitle);
    17831982     PROPSHEET_SetTitleW(hwndDlg, dwStyle, szTitle);
     
    17991998  TRACE("'%s' (style %08lx)\n", debugstr_w(lpszText), dwStyle);
    18001999  if (HIWORD(lpszText) == 0) {
    1801     if (!LoadStringW(psInfo->ppshheader.hInstance, 
     2000    if (!LoadStringW(psInfo->ppshheader.hInstance,
    18022001                     LOWORD(lpszText), szTitle, sizeof(szTitle)-sizeof(WCHAR)))
    18032002      return;
     
    19302129  item.pszText = (LPWSTR) psInfo->proppage[psInfo->nPages].pszText;
    19312130  item.cchTextMax = MAX_TABTEXT_LENGTH;
     2131
     2132  if (psInfo->hImageList)
     2133  {
     2134    SendMessageW(hwndTabControl, TCM_SETIMAGELIST, 0, (LPARAM)psInfo->hImageList);
     2135  }
     2136
     2137  if ( psInfo->proppage[psInfo->nPages].hasIcon )
     2138  {
     2139    item.mask |= TCIF_IMAGE;
     2140    item.iImage = psInfo->nPages;
     2141  }
    19322142
    19332143  SendMessageW(hwndTabControl, TCM_INSERTITEMW, psInfo->nPages + 1,
     
    20212231     DestroyPropertySheetPage(psInfo->proppage[index].hpage);
    20222232  }
    2023  
     2233
    20242234  /* Remove the tab */
    20252235  SendMessageW(hwndTabControl, TCM_DELETEITEM, index, 0);
     
    20282238  psInfo->proppage = COMCTL32_Alloc(sizeof(PropPageInfo) * psInfo->nPages);
    20292239
    2030   if (index > 0) 
     2240  if (index > 0)
    20312241    memcpy(&psInfo->proppage[0], &oldPages[0], index * sizeof(PropPageInfo));
    20322242
     
    21562366
    21572367/******************************************************************************
    2158  *            PropertySheet    (COMCTL32.87)
    2159  *            PropertySheetA   (COMCTL32.88)
     2368 *            PropertySheet    (COMCTL32.@)
     2369 *            PropertySheetA   (COMCTL32.@)
    21602370 */
    21612371INT WINAPI PropertySheetA(LPCPROPSHEETHEADERA lppsh)
     
    22012411
    22022412/******************************************************************************
    2203  *            PropertySheetW   (COMCTL32.89)
     2413 *            PropertySheetW   (COMCTL32.@)
    22042414 */
    22052415INT WINAPI PropertySheetW(LPCPROPSHEETHEADERW lppsh)
     
    22452455
    22462456/******************************************************************************
    2247  *            CreatePropertySheetPage    (COMCTL32.18)
    2248  *            CreatePropertySheetPageA   (COMCTL32.19)
     2457 *            CreatePropertySheetPage    (COMCTL32.@)
     2458 *            CreatePropertySheetPageA   (COMCTL32.@)
    22492459 */
    22502460HPROPSHEETPAGE WINAPI CreatePropertySheetPageA(
     
    22572467  if ( !(ppsp->dwFlags & PSP_DLGINDIRECT) && HIWORD( ppsp->u.pszTemplate ) )
    22582468  {
    2259       PROPSHEET_AtoW(&ppsp->u.pszTemplate, lpPropSheetPage->u.pszTemplate); 
     2469      PROPSHEET_AtoW(&ppsp->u.pszTemplate, lpPropSheetPage->u.pszTemplate);
    22602470  }
    22612471  if ( (ppsp->dwFlags & PSP_USEICONID) && HIWORD( ppsp->u2.pszIcon ) )
    22622472  {
    2263       PROPSHEET_AtoW(&ppsp->u2.pszIcon, lpPropSheetPage->u2.pszIcon); 
     2473      PROPSHEET_AtoW(&ppsp->u2.pszIcon, lpPropSheetPage->u2.pszIcon);
    22642474  }
    22652475
    22662476  if ((ppsp->dwFlags & PSP_USETITLE) && HIWORD( ppsp->pszTitle ))
    22672477  {
    2268       PROPSHEET_AtoW(&ppsp->pszTitle, lpPropSheetPage->pszTitle); 
     2478      PROPSHEET_AtoW(&ppsp->pszTitle, lpPropSheetPage->pszTitle);
    22692479  }
    22702480  else if ( !(ppsp->dwFlags & PSP_USETITLE) )
     
    22752485
    22762486/******************************************************************************
    2277  *            CreatePropertySheetPageW   (COMCTL32.20)
     2487 *            CreatePropertySheetPageW   (COMCTL32.@)
    22782488 */
    22792489HPROPSHEETPAGE WINAPI CreatePropertySheetPageW(LPCPROPSHEETPAGEW lpPropSheetPage)
     
    23102520
    23112521/******************************************************************************
    2312  *            DestroyPropertySheetPage   (COMCTL32.24)
     2522 *            DestroyPropertySheetPage   (COMCTL32.@)
    23132523 */
    23142524BOOL WINAPI DestroyPropertySheetPage(HPROPSHEETPAGE hPropPage)
     
    24562666PROPSHEET_DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    24572667{
    2458   TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n",
     2668  TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n",
    24592669        hwnd, uMsg, wParam, lParam);
    24602670
     
    24722682
    24732683      /*
    2474        * psInfo->hwnd is not being used by WINE code - it exists 
    2475        * for compatibility with "real" Windoze. The same about 
     2684       * psInfo->hwnd is not being used by WINE code - it exists
     2685       * for compatibility with "real" Windoze. The same about
    24762686       * SetWindowLong - WINE is only using the PropSheetInfoStr
    24772687       * property.
     
    24992709          hIcon = psInfo->ppshheader.u.hIcon;
    25002710
    2501         SendMessageW(hwnd, WM_SETICON, 0, hIcon);
     2711        SendMessageW(hwnd, WM_SETICON, 0, (LPARAM)hIcon);
    25022712      }
    2503      
     2713
    25042714      if (psInfo->ppshheader.dwFlags & PSH_USEHICON)
    2505         SendMessageW(hwnd, WM_SETICON, 0, psInfo->ppshheader.u.hIcon);
     2715        SendMessageW(hwnd, WM_SETICON, 0, (LPARAM)psInfo->ppshheader.u.hIcon);
    25062716
    25072717      psInfo->strPropertiesFor = strCaption;
     
    25282738      }
    25292739
    2530       if (psInfo->useCallback) 
    2531              (*(psInfo->ppshheader.pfnCallback))(hwnd, 
    2532                                               PSCB_INITIALIZED, (LPARAM)0); 
     2740      if (psInfo->useCallback)
     2741             (*(psInfo->ppshheader.pfnCallback))(hwnd,
     2742                                              PSCB_INITIALIZED, (LPARAM)0);
    25332743
    25342744      idx = psInfo->active_page;
    25352745      ppshpage = (LPCPROPSHEETPAGEW)psInfo->proppage[idx].hpage;
    25362746      psInfo->active_page = -1;
    2537  
     2747
    25382748      PROPSHEET_SetCurSel(hwnd, idx, 1, psInfo->proppage[idx].hpage);
    25392749
     
    25482758         WCHAR szText[256];
    25492759
    2550          if (LoadStringW(psInfo->ppshheader.hInstance, 
     2760         if (LoadStringW(psInfo->ppshheader.hInstance,
    25512761                 (UINT)psInfo->ppshheader.pszCaption, szText, 255))
    25522762            PROPSHEET_SetTitleW(hwnd, psInfo->ppshheader.dwFlags, szText);
     
    26012811        hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
    26022812
    2603       SetWindowLongW(hwnd, DWL_MSGRESULT, hwndPage);
     2813      SetWindowLongW(hwnd, DWL_MSGRESULT, (LONG)hwndPage);
    26042814
    26052815      return TRUE;
     
    26182828      HWND hwndTabCtrl = GetDlgItem(hwnd, IDC_TABCONTROL);
    26192829
    2620       SetWindowLongW(hwnd, DWL_MSGRESULT, hwndTabCtrl);
     2830      SetWindowLongW(hwnd, DWL_MSGRESULT, (LONG)hwndTabCtrl);
    26212831
    26222832      return TRUE;
     
    26502860      if (LoadStringW(COMCTL32_hModule, IDS_CLOSE, buf, sizeof(buf)))
    26512861         SetWindowTextW(hwndOK, buf);
    2652  
     2862
    26532863      return FALSE;
    26542864    }
     
    26652875    case PSM_REBOOTSYSTEM:
    26662876    {
    2667       PropSheetInfo* psInfo = (PropSheetInfo*) GetPropW(hwnd, 
     2877      PropSheetInfo* psInfo = (PropSheetInfo*) GetPropW(hwnd,
    26682878                                                        PropSheetInfoStr);
    26692879
     
    26752885      PROPSHEET_SetTitleA(hwnd, (DWORD) wParam, (LPCSTR) lParam);
    26762886      return TRUE;
    2677    
     2887
    26782888    case PSM_SETTITLEW:
    26792889      PROPSHEET_SetTitleW(hwnd, (DWORD) wParam, (LPCWSTR) lParam);
     
    27312941
    27322942    case PSM_SETFINISHTEXTA:
    2733       PROPSHEET_SetFinishTextA(hwnd, (LPCSTR) lParam);       
     2943      PROPSHEET_SetFinishTextA(hwnd, (LPCSTR) lParam);
    27342944      return TRUE;
    27352945
     
    27392949
    27402950    case PSM_SETCURSELID:
    2741         FIXME("Unimplemented msg PSM_SETCURSELID\n");
    2742         return FALSE;
     2951        PROPSHEET_SetCurSelId(hwnd, (int)lParam);
     2952        return TRUE;
    27432953
    27442954    case PSM_SETFINISHTEXTW:
    2745         PROPSHEET_SetFinishTextW(hwnd, (LPCWSTR) lParam);       
     2955        PROPSHEET_SetFinishTextW(hwnd, (LPCWSTR) lParam);
    27462956        return FALSE;
    27472957
     
    27492959      return FALSE;
    27502960  }
    2751  
     2961
    27522962  return FALSE;
    27532963}
    2754 
  • trunk/src/comctl32/rebar.c

    r8382 r9370  
    4747 *   - vertical placement
    4848 *   - ComboBox and ComboBoxEx placement
    49  *   - center image 
     49 *   - center image
    5050 *   - Layout code.
    5151 *   - Display code.
     
    5656 *  rev 2,3,4
    5757 *   - Implement initial version of row grouping, row separators,
    58  *     text and background colors. Support additional messages. 
     58 *     text and background colors. Support additional messages.
    5959 *     Support RBBS_BREAK. Implement ERASEBKGND and improve painting.
    6060 *  rev 5
    6161 *   - implement support for dragging Gripper left or right in a row. Supports
    62  *     WM_LBUTTONDOWN, WM_LBUTTONUP, and WM_MOUSEMOVE. Also support 
     62 *     WM_LBUTTONDOWN, WM_LBUTTONUP, and WM_MOUSEMOVE. Also support
    6363 *     RBS_BANDBORDERS.
    6464 *  rev 6
     
    6969 * rev 7
    7070 *   - Fix algorithm for _Layout and _AdjustBand.
    71  *   - Fix or implement RBN_ENDDRAG, RB_MOVEBAND, WM_SETREDRAW, 
     71 *   - Fix or implement RBN_ENDDRAG, RB_MOVEBAND, WM_SETREDRAW,
    7272 *     WM_STYLECHANGED, RB_MINIMIZEBAND, RBBS_VARIABLEHEIGHT, RBS_VARHEIGHT,
    7373 *     RBBS_HIDDEN, WM_NOTIFYFORMAT, NM_NCHITTEST, WM_SETREDRAW, RBS_AUTOSIZE,
     
    8888 *     so that repainting is correct.
    8989 *  8. Implement RB_MAXIMIZEBAND for the "ideal=TRUE" case.
    90  *  9. Implement item custom draw notifications partially. Only done for 
     90 *  9. Implement item custom draw notifications partially. Only done for
    9191 *     ITEMPREPAINT and ITEMPOSTPAINT. (Used by IE4 for "Favorites" frame
    9292 *     to draw the word "Favorites").
     
    9797 * 12. Fix CCS_VERT errors in _ForceResize, _NCCalcSize, and _NCPaint.
    9898 * 13. Support some special cases of CCS_TOP (and therefore CCS_LEFT),
    99  *     CCS_BOTTOM (and therefore CCS_RIGHT) and CCS_NOPARENTALIGN. Not 
     99 *     CCS_BOTTOM (and therefore CCS_RIGHT) and CCS_NOPARENTALIGN. Not
    100100 *     at all sure whether this is all cases.
    101101 * 14. Handle returned value for the RBN_CHILDSIZE notify.
     
    122122 *            RBBS_USECHEVRON, CCS_NORESIZE,
    123123 *            CCS_NOMOVEX, CCS_NOMOVEY
    124  *  3. Following are only partially handled: 
     124 *  3. Following are only partially handled:
    125125 *            RBS_AUTOSIZE, RBBS_VARIABLEHEIGHT
    126126 *  5. Native uses (on each draw!!) SM_CYBORDER (or SM_CXBORDER for CCS_VERT)
    127  *     to set the size of the separator width (the value SEP_WIDTH_SIZE 
     127 *     to set the size of the separator width (the value SEP_WIDTH_SIZE
    128128 *     in here). Should be fixed!!
    129129 *  6. The following messages are not implemented:
     
    237237    BOOL     NtfUnicode;  /* TRUE if parent wants notify in W format */
    238238    BOOL     DoRedraw;    /* TRUE to acutally draw bands */
    239     UINT     fStatus;     /* Status flags (see below)  */ 
     239    UINT     fStatus;     /* Status flags (see below)  */
    240240    HCURSOR  hcurArrow;   /* handle to the arrow cursor */
    241241    HCURSOR  hcurHorz;    /* handle to the EW cursor */
     
    317317
    318318/*  The following defines adjust the right or left end of a rectangle */
    319 #define READJ(b,i) {if(infoPtr->dwStyle & CCS_VERT) b->rcBand.bottom+=(i); \
    320                     else b->rcBand.right += (i);}
    321 #define LEADJ(b,i) {if(infoPtr->dwStyle & CCS_VERT) b->rcBand.top+=(i); \
    322                     else b->rcBand.left += (i);}
     319#define READJ(b,i) do { if(infoPtr->dwStyle & CCS_VERT) b->rcBand.bottom+=(i); \
     320                    else b->rcBand.right += (i); } while(0)
     321#define LEADJ(b,i) do { if(infoPtr->dwStyle & CCS_VERT) b->rcBand.top+=(i); \
     322                    else b->rcBand.left += (i); } while(0)
    323323
    324324
     
    400400{
    401401    if( !TRACE_ON(rebar) ) return;
    402     TRACE("band info: ID=%u, size=%u, child=%04x, clrF=0x%06lx, clrB=0x%06lx\n",
    403           pB->wID, pB->cbSize, pB->hwndChild, pB->clrFore, pB->clrBack); 
     402    TRACE("band info: ID=%u, size=%u, child=%p, clrF=0x%06lx, clrB=0x%06lx\n",
     403          pB->wID, pB->cbSize, pB->hwndChild, pB->clrFore, pB->clrBack);
    404404    TRACE("band info: mask=0x%08x (%s)\n", pB->fMask, REBAR_FmtMask(pB->fMask));
    405405    if (pB->fMask & RBBIM_STYLE)
     
    419419    if (pB->fMask & RBBIM_CHILDSIZE)
    420420        TRACE("band info: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
    421               pB->cxMinChild, 
     421              pB->cxMinChild,
    422422              pB->cyMinChild, pB->cyChild, pB->cyMaxChild, pB->cyIntegral);
    423423}
     
    431431    if(! TRACE_ON(rebar) ) return;
    432432
    433     TRACE("hwnd=%04x: color=%08lx/%08lx, bands=%u, rows=%u, cSize=%ld,%ld\n",
     433    TRACE("hwnd=%p: color=%08lx/%08lx, bands=%u, rows=%u, cSize=%ld,%ld\n",
    434434          iP->hwndSelf, iP->clrText, iP->clrBk, iP->uNumBands, iP->uNumRows,
    435435          iP->calcSize.cx, iP->calcSize.cy);
    436     TRACE("hwnd=%04x: flags=%08x, dragStart=%d,%d, dragNow=%d,%d, ihitBand=%d\n",
     436    TRACE("hwnd=%p: flags=%08x, dragStart=%d,%d, dragNow=%d,%d, ihitBand=%d\n",
    437437          iP->hwndSelf, iP->fStatus, iP->dragStart.x, iP->dragStart.y,
    438438          iP->dragNow.x, iP->dragNow.y,
    439439          iP->ihitBand);
    440     TRACE("hwnd=%04x: style=%08lx, I'm Unicode=%s, notify in Unicode=%s, redraw=%s\n",
     440    TRACE("hwnd=%p: style=%08lx, I'm Unicode=%s, notify in Unicode=%s, redraw=%s\n",
    441441          iP->hwndSelf, iP->dwStyle, (iP->bUnicode)?"TRUE":"FALSE",
    442442          (iP->NtfUnicode)?"TRUE":"FALSE", (iP->DoRedraw)?"TRUE":"FALSE");
    443443    for (i = 0; i < iP->uNumBands; i++) {
    444444        pB = &iP->bands[i];
    445         TRACE("band # %u: ID=%u, child=%04x, row=%u, clrF=0x%06lx, clrB=0x%06lx\n",
     445        TRACE("band # %u: ID=%u, child=%p, row=%u, clrF=0x%06lx, clrB=0x%06lx\n",
    446446              i, pB->wID, pB->hwndChild, pB->iRow, pB->clrFore, pB->clrBack);
    447447        TRACE("band # %u: mask=0x%08x (%s)\n", i, pB->fMask, REBAR_FmtMask(pB->fMask));
    448448        if (pB->fMask & RBBIM_STYLE)
    449             TRACE("band # %u: style=0x%08x (%s)\n", 
     449            TRACE("band # %u: style=0x%08x (%s)\n",
    450450                  i, pB->fStyle, REBAR_FmtStyle(pB->fStyle));
    451         TRACE("band # %u: uMinH=%u xHeader=%u", 
     451        TRACE("band # %u: uMinH=%u xHeader=%u",
    452452              i, pB->uMinHeight, pB->cxHeader);
    453453        if (pB->fMask & (RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_LPARAM )) {
     
    507507    nmhdr->code = code;
    508508
    509     TRACE("window %04x, code=%08x, %s\n", parent, code,
     509    TRACE("window %p, code=%08x, %s\n", parent, code,
    510510          (infoPtr->NtfUnicode) ? "via Unicode" : "via ANSI");
    511511
     
    605605        if (oldBkMode != TRANSPARENT)
    606606            SetBkMode (hdc, oldBkMode);
    607         if (lpBand->clrFore != CLR_NONE) 
     607        if (lpBand->clrFore != CLR_NONE)
    608608            SetTextColor (hdc, oldcolor);
    609609        SelectObject (hdc, hOldFont);
     
    636636        lpBand = &infoPtr->bands[i];
    637637
    638         if (HIDDENBAND(lpBand)) continue; 
     638        if (HIDDENBAND(lpBand)) continue;
    639639
    640640        /* now draw the band */
    641         TRACE("[%04x] drawing band %i, flags=%08x\n",
     641        TRACE("[%p] drawing band %i, flags=%08x\n",
    642642              infoPtr->hwndSelf, i, lpBand->fDraw);
    643643        REBAR_DrawBand (hdc, infoPtr, lpBand);
     
    650650REBAR_FixVert (REBAR_INFO *infoPtr, UINT rowstart, UINT rowend,
    651651                   INT mcy)
    652      /* Function:                                                    */ 
     652     /* Function:                                                    */
    653653     /*   Cycle through bands in row and fix height of each band.    */
    654654     /*   Also determine whether each band has changed.              */
     
    719719    /*         or band's ->ccx reached.                       */
    720720    /*  If any band modified, add any space left to last band */
    721     /*  adjusted.                                             */ 
     721    /*  adjusted.                                             */
    722722    /*                                                        */
    723723    /* ****************************************************** */
     
    772772    if ((x >= maxx) || (last_adjusted != -1)) {
    773773        if (x > maxx) {
    774             ERR("Phase 1 failed, x=%d, maxx=%d, start=%u, end=%u\n", 
     774            ERR("Phase 1 failed, x=%d, maxx=%d, start=%u, end=%u\n",
    775775                x, maxx,  rowstart, rowend);
    776776        }
     
    842842    if (x >= maxx) {
    843843        if (x > maxx) {
    844             ERR("Phase 2 failed, x=%d, maxx=%d, start=%u, end=%u\n", 
     844            ERR("Phase 2 failed, x=%d, maxx=%d, start=%u, end=%u\n",
    845845                x, maxx,  rowstart, rowend);
    846846        }
     
    910910              /* if no gripper but either image or text, then leave space */
    911911              xoff = REBAR_ALWAYS_SPACE;
    912           SetRect (&lpBand->rcCapImage, 
     912          SetRect (&lpBand->rcCapImage,
    913913                   lpBand->rcBand.left+xoff, lpBand->rcBand.top,
    914914                   lpBand->rcBand.left+xoff, lpBand->rcBand.bottom);
     
    925925                   lpBand->rcCapImage.right+REBAR_POST_IMAGE, lpBand->rcBand.top+1,
    926926                   lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.bottom-1);
    927           /* update band height 
     927          /* update band height
    928928          if (lpBand->uMinHeight < infoPtr->imageSize.cy + 2) {
    929929              lpBand->uMinHeight = infoPtr->imageSize.cy + 2;
     
    940940      if (lpBand->fStatus & HAS_TEXT) {
    941941          lpBand->fDraw |= DRAW_TEXT;
    942           lpBand->rcCapText.right = max(lpBand->rcCapText.left, 
     942          lpBand->rcCapText.right = max(lpBand->rcCapText.left,
    943943                                        lpBand->rcCapText.right-REBAR_POST_TEXT);
    944944      }
     
    959959
    960960      /* flag if notify required and invalidate rectangle */
    961       if (notify && 
     961      if (notify &&
    962962          ((oldChild.right-oldChild.left != lpBand->rcChild.right-lpBand->rcChild.left) ||
    963963           (oldChild.bottom-oldChild.top != lpBand->rcChild.bottom-lpBand->rcChild.top))) {
     
    971971      if (lpBand->fDraw & NTF_INVALIDATE) {
    972972          TRACE("invalidating (%d,%d)-(%d,%d)\n",
    973                 lpBand->rcBand.left, 
     973                lpBand->rcBand.left,
    974974                lpBand->rcBand.top,
    975                 lpBand->rcBand.right + ((lpBand->fDraw & DRAW_RIGHTSEP) ? SEP_WIDTH_SIZE : 0), 
     975                lpBand->rcBand.right + ((lpBand->fDraw & DRAW_RIGHTSEP) ? SEP_WIDTH_SIZE : 0),
    976976                lpBand->rcBand.bottom + ((lpBand->fDraw & DRAW_BOTTOMSEP) ? SEP_WIDTH_SIZE : 0));
    977977          lpBand->fDraw &= ~NTF_INVALIDATE;
     
    10471047                xoff = REBAR_ALWAYS_SPACE;
    10481048            /* initialize Caption image rectangle  */
    1049             SetRect (&lpBand->rcCapImage, 
     1049            SetRect (&lpBand->rcCapImage,
    10501050                     lpBand->rcBand.left, lpBand->rcBand.top+xoff,
    10511051                     lpBand->rcBand.right, lpBand->rcBand.top+xoff);
     
    10601060
    10611061            /* set initial caption text rectangle */
    1062             SetRect (&lpBand->rcCapText, 
     1062            SetRect (&lpBand->rcCapText,
    10631063                     lpBand->rcBand.left, lpBand->rcCapImage.bottom+REBAR_POST_IMAGE,
    10641064                     lpBand->rcBand.right, lpBand->rcBand.top+lpBand->cxHeader);
     
    10711071        else {
    10721072            /* set initial caption text rectangle */
    1073             SetRect (&lpBand->rcCapText, 
     1073            SetRect (&lpBand->rcCapText,
    10741074                     lpBand->rcBand.left, lpBand->rcCapImage.bottom,
    10751075                     lpBand->rcBand.right, lpBand->rcBand.top+lpBand->cxHeader);
     
    10981098
    10991099        /* flag if notify required and invalidate rectangle */
    1100         if (notify && 
     1100        if (notify &&
    11011101            ((oldChild.right-oldChild.left != lpBand->rcChild.right-lpBand->rcChild.left) ||
    11021102             (oldChild.bottom-oldChild.top != lpBand->rcChild.bottom-lpBand->rcChild.top))) {
     
    11101110        if (lpBand->fDraw & NTF_INVALIDATE) {
    11111111            TRACE("invalidating (%d,%d)-(%d,%d)\n",
    1112                   lpBand->rcBand.left, 
     1112                  lpBand->rcBand.left,
    11131113                  lpBand->rcBand.top,
    1114                   lpBand->rcBand.right + ((lpBand->fDraw & DRAW_BOTTOMSEP) ? SEP_WIDTH_SIZE : 0), 
     1114                  lpBand->rcBand.right + ((lpBand->fDraw & DRAW_BOTTOMSEP) ? SEP_WIDTH_SIZE : 0),
    11151115                  lpBand->rcBand.bottom + ((lpBand->fDraw & DRAW_RIGHTSEP) ? SEP_WIDTH_SIZE : 0));
    11161116            lpBand->fDraw &= ~NTF_INVALIDATE;
     
    12251225    }
    12261226
    1227     TRACE("hwnd %08x, style=%08lx, setting at (%d,%d) for (%d,%d)\n",
     1227    TRACE("hwnd %p, style=%08lx, setting at (%d,%d) for (%d,%d)\n",
    12281228        infoPtr->hwndSelf, infoPtr->dwStyle,
    12291229        x, y, width, height);
     
    12511251        if (HIDDENBAND(lpBand)) continue;
    12521252        if (lpBand->hwndChild) {
    1253             TRACE("hwndChild = %x\n", lpBand->hwndChild);
     1253            TRACE("hwndChild = %p\n", lpBand->hwndChild);
    12541254
    12551255            /* Always geterate the RBN_CHILDSIZE even it child
     
    12591259            rbcz.rcChild = lpBand->rcChild;
    12601260            rbcz.rcBand = lpBand->rcBand;
    1261             if (infoPtr->dwStyle & CCS_VERT) 
     1261            if (infoPtr->dwStyle & CCS_VERT)
    12621262                rbcz.rcBand.top += lpBand->cxHeader;
    12631263            else
     
    12971297
    12981298                /* center combo box inside child area */
    1299                 TRACE("moving child (Combo(Ex)) %04x to (%d,%d) for (%d,%d)\n",
     1299                TRACE("moving child (Combo(Ex)) %p to (%d,%d) for (%d,%d)\n",
    13001300                      lpBand->hwndChild,
    13011301                      lpBand->rcChild.left, yPos,
     
    13121312            }
    13131313            else {
    1314                 TRACE("moving child (Other) %04x to (%d,%d) for (%d,%d)\n",
     1314                TRACE("moving child (Other) %p to (%d,%d) for (%d,%d)\n",
    13151315                      lpBand->hwndChild,
    13161316                      lpBand->rcChild.left, lpBand->rcChild.top,
     
    14011401
    14021402    /* save height of original control */
    1403     if (infoPtr->dwStyle & CCS_VERT) 
     1403    if (infoPtr->dwStyle & CCS_VERT)
    14041404        origheight = infoPtr->calcSize.cx;
    14051405    else
     
    14401440
    14411441        /* separator from previous band */
    1442         cxsep = (cntonrow == 0) ? 0 : SEP_WIDTH; 
     1442        cxsep = (cntonrow == 0) ? 0 : SEP_WIDTH;
    14431443
    14441444        /* Header: includes gripper, text, image */
    1445         cx = lpBand->cxHeader;   
     1445        cx = lpBand->cxHeader;
    14461446        if (lpBand->fStyle & RBBS_FIXEDSIZE) cx = lpBand->lcx;
    14471447
     
    14851485        }
    14861486
    1487         if (mcy < lpBand->lcy + REBARSPACE(lpBand)) 
     1487        if (mcy < lpBand->lcy + REBARSPACE(lpBand))
    14881488            mcy = lpBand->lcy + REBARSPACE(lpBand);
    14891489
     
    15141514            bottomy = (lpRect) ? min(clientcy, y+cxsep+cx) : y+cxsep+cx;
    15151515            lpBand->rcBand.left   = x;
    1516             lpBand->rcBand.right  = x + min(mcy, 
     1516            lpBand->rcBand.right  = x + min(mcy,
    15171517                                            lpBand->lcy+REBARSPACE(lpBand));
    15181518            lpBand->rcBand.top    = min(bottomy, y + cxsep);
     
    15281528            lpBand->rcBand.right  = rightx;
    15291529            lpBand->rcBand.top    = y;
    1530             lpBand->rcBand.bottom = y + min(mcy, 
     1530            lpBand->rcBand.bottom = y + min(mcy,
    15311531                                            lpBand->lcy+REBARSPACE(lpBand));
    15321532            lpBand->uMinHeight = lpBand->lcy;
     
    16161616
    16171617/* FIXME:  problem # 2 */
    1618         if (((infoPtr->dwStyle & CCS_VERT) ? 
     1618        if (((infoPtr->dwStyle & CCS_VERT) ?
    16191619#if PROBLEM2
    16201620             (x < adjcx) : (y < adjcy)
     
    16981698                        }
    16991699                    }
    1700                     if ((infoPtr->dwStyle & CCS_VERT) ? (x >= adjcx) : (y >= adjcy)) 
     1700                    if ((infoPtr->dwStyle & CCS_VERT) ? (x >= adjcx) : (y >= adjcy))
    17011701                        break; /* all done */
    17021702                }
     
    17621762            if(HIDDENBAND(lpBand)) continue;
    17631763            if (lpBand->fMask & RBBS_VARIABLEHEIGHT) continue;
    1764             if (((INT)lpBand->cyMaxChild < 1) || 
     1764            if (((INT)lpBand->cyMaxChild < 1) ||
    17651765                ((INT)lpBand->cyIntegral < 1)) {
    17661766                if (lpBand->cyMaxChild + lpBand->cyIntegral == 0) continue;
     
    17701770            }
    17711771            /* j is now the maximum height/width in the client area */
    1772             j = ((diff / lpBand->cyIntegral) * lpBand->cyIntegral) + 
     1772            j = ((diff / lpBand->cyIntegral) * lpBand->cyIntegral) +
    17731773                ircBw(lpBand);
    1774             if (j > lpBand->cyMaxChild + REBARSPACE(lpBand)) 
     1774            if (j > lpBand->cyMaxChild + REBARSPACE(lpBand))
    17751775                j = lpBand->cyMaxChild + REBARSPACE(lpBand);
    17761776            diff -= (j - ircBw(lpBand));
     
    18281828            mcy = 0;
    18291829
    1830             TRACE("P3 processing row %d, starting band %d, ending band %d\n", 
     1830            TRACE("P3 processing row %d, starting band %d, ending band %d\n",
    18311831                  i, p->istartband, p->iendband);
    18321832
     
    18401840
    18411841            REBAR_AdjustBands (infoPtr, p->istartband, p->iendband,
    1842                                (infoPtr->dwStyle & CCS_VERT) ? 
     1842                               (infoPtr->dwStyle & CCS_VERT) ?
    18431843                               clientcy : clientcx, mcy);
    18441844        }
     
    18501850        }
    18511851        else {
    1852             REBAR_CalcHorzBand (infoPtr, 0, infoPtr->uNumBands, 
     1852            REBAR_CalcHorzBand (infoPtr, 0, infoPtr->uNumBands,
    18531853                                notify);
    18541854        }
     
    18761876        TRACE("horz, notify=%d, y=%d, origheight=%d\n",
    18771877              notify, y, origheight);
    1878         if (notify && (y != origheight)) infoPtr->fStatus |= NTF_HGHTCHG; 
     1878        if (notify && (y != origheight)) infoPtr->fStatus |= NTF_HGHTCHG;
    18791879    }
    18801880
     
    19431943    /* calculate gripper rectangle */
    19441944    if (  (!(lpBand->fStyle & RBBS_NOGRIPPER)) &&
    1945           ( (lpBand->fStyle & RBBS_GRIPPERALWAYS) || 
     1945          ( (lpBand->fStyle & RBBS_GRIPPERALWAYS) ||
    19461946            ( !(lpBand->fStyle & RBBS_FIXEDSIZE) && (nonfixed > 1)))
    19471947       ) {
     
    20612061        }
    20622062        else {
    2063             TRACE("child: 0x%x  prev parent: 0x%x\n",
     2063            TRACE("child: %p  prev parent: %p\n",
    20642064                   lpBand->hwndChild, lpBand->hwndPrevParent);
    20652065            lpBand->hwndChild = 0;
     
    21862186        rect = lpBand->rcBand;
    21872187        TRACE("%s background color=0x%06lx, band (%d,%d)-(%d,%d), clip (%d,%d)-(%d,%d)\n",
    2188               (lpBand->clrBack == CLR_NONE) ? "none" : 
     2188              (lpBand->clrBack == CLR_NONE) ? "none" :
    21892189                ((lpBand->clrBack == CLR_DEFAULT) ? "dft" : ""),
    21902190              GetBkColor(hdc),
     
    23932393            if (i < ihitBand)
    23942394                LHeaderSum += (band->lcx + SEP_WIDTH);
    2395             else 
     2395            else
    23962396                RHeaderSum += (band->lcx + SEP_WIDTH);
    23972397
     
    24262426    REBAR_DumpBand (infoPtr);
    24272427
    2428     if (movement < 0) { 
     2428    if (movement < 0) {
    24292429
    24302430        /* ***  Drag left/up *** */
     
    24412441            if (HIDDENBAND(band)) continue;
    24422442            if (i == ihitBand) {
    2443                 LEADJ(band, movement)
     2443                LEADJ(band, movement);
    24442444            }
    2445             else 
     2445            else
    24462446                movement = REBAR_Shrink (infoPtr, band, movement, i);
    24472447            band->ccx = rcBw(band);
     
    24642464            if (first) {
    24652465                first = FALSE;
    2466                 READJ(band, movement)
     2466                READJ(band, movement);
    24672467            }
    2468             else 
     2468            else
    24692469                movement = REBAR_Shrink (infoPtr, band, movement, i);
    24702470            band->ccx = rcBw(band);
     
    24782478    }
    24792479    else {
    2480         REBAR_CalcHorzBand (infoPtr, imindBand, imaxdBand+1, 
     2480        REBAR_CalcHorzBand (infoPtr, imindBand, imaxdBand+1,
    24812481                            FALSE);
    24822482    }
     
    24862486    REBAR_DumpBand (infoPtr);
    24872487
    2488     SetRect (&newrect, 
     2488    SetRect (&newrect,
    24892489             mindBand->rcBand.left,
    24902490             mindBand->rcBand.top,
     
    26532653              lprbbi->lpText[lprbbi->cch-1] = 0;
    26542654      }
    2655       else 
     2655      else
    26562656        *lprbbi->lpText = 0;
    26572657    }
     
    27352735      if (lpBand->lpText && (lpBand->fMask & RBBIM_TEXT))
    27362736        lstrcpynW (lprbbi->lpText, lpBand->lpText, lprbbi->cch);
    2737       else 
     2737      else
    27382738        *lprbbi->lpText = 0;
    27392739    }
     
    29162916REBAR_GetToolTips (REBAR_INFO *infoPtr)
    29172917{
    2918     return infoPtr->hwndToolTip;
     2918    return (LRESULT)infoPtr->hwndToolTip;
    29192919}
    29202920
     
    29232923REBAR_GetUnicodeFormat (REBAR_INFO *infoPtr)
    29242924{
    2925     TRACE("%s hwnd=0x%x\n",
     2925    TRACE("%s hwnd=%p\n",
    29262926          infoPtr->bUnicode ? "TRUE" : "FALSE", infoPtr->hwndSelf);
    29272927
     
    29412941REBAR_HitTest (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
    29422942{
    2943     LPRBHITTESTINFO lprbht = (LPRBHITTESTINFO)lParam; 
     2943    LPRBHITTESTINFO lprbht = (LPRBHITTESTINFO)lParam;
    29442944
    29452945    if (!lprbht)
     
    32503250        startBand = uBand;
    32513251        endBand = iprevBand;
    3252         SetRect (&newrect, 
     3252        SetRect (&newrect,
    32533253                 lpBand->rcBand.left,
    32543254                 lpBand->rcBand.top,
     
    32763276        startBand = iprevBand;
    32773277        endBand = uBand;
    3278         SetRect (&newrect, 
     3278        SetRect (&newrect,
    32793279                 band->rcBand.left,
    32803280                 band->rcBand.top,
     
    32913291    }
    32923292    else {
    3293         REBAR_CalcHorzBand (infoPtr, startBand, endBand+1, 
     3293        REBAR_CalcHorzBand (infoPtr, startBand, endBand+1,
    32943294                            FALSE);
    32953295    }
     
    35543554    BOOL bTemp = infoPtr->bUnicode;
    35553555
    3556     TRACE("to %s hwnd=0x%04x, was %s\n",
     3556    TRACE("to %s hwnd=%p, was %s\n",
    35573557          ((BOOL)wParam) ? "TRUE" : "FALSE", infoPtr->hwndSelf,
    35583558          (bTemp) ? "TRUE" : "FALSE");
    35593559
    35603560    infoPtr->bUnicode = (BOOL)wParam;
    3561  
     3561
    35623562   return bTemp;
    35633563}
     
    38793879    /* issue WM_NOTIFYFORMAT to get unicode status of parent */
    38803880    i = SendMessageA(REBAR_GetNotifyParent (infoPtr),
    3881                      WM_NOTIFYFORMAT, hwnd, NF_QUERY);
     3881                     WM_NOTIFYFORMAT, (WPARAM)hwnd, NF_QUERY);
    38823882    if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
    38833883        ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
     
    38933893    /* get font handle for Caption Font */
    38943894    ncm.cbSize = sizeof(NONCLIENTMETRICSA);
    3895     SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 
     3895    SystemParametersInfoA (SPI_GETNONCLIENTMETRICS,
    38963896                          ncm.cbSize, &ncm, 0);
    38973897    /* if the font is bold, set to normal */
     
    39533953    clpt = pt;
    39543954    ScreenToClient (infoPtr->hwndSelf, &clpt);
    3955     REBAR_InternalHitTest (infoPtr, &clpt, &scrap, 
     3955    REBAR_InternalHitTest (infoPtr, &clpt, &scrap,
    39563956                           (INT *)&nmmouse.dwItemSpec);
    39573957    nmmouse.dwItemData = 0;
     
    39603960    if ((i = REBAR_Notify((NMHDR *) &nmmouse, infoPtr, NM_NCHITTEST))) {
    39613961        TRACE("notify changed return value from %ld to %d\n",
    3962               ret, i); 
     3962              ret, i);
    39633963        ret = (LRESULT) i;
    39643964    }
     
    40024002    if (lParam == NF_REQUERY) {
    40034003        i = SendMessageA(REBAR_GetNotifyParent (infoPtr),
    4004                          WM_NOTIFYFORMAT, infoPtr->hwndSelf, NF_QUERY);
     4004                         WM_NOTIFYFORMAT, (WPARAM)infoPtr->hwndSelf, NF_QUERY);
    40054005        if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
    40064006            ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
     
    41024102      *
    41034103      * Documentation:
    4104       *  According to testing V4.71 of COMCTL32 returns the 
     4104      *  According to testing V4.71 of COMCTL32 returns the
    41054105      *  *previous* status of the redraw flag (either 0 or -1)
    41064106      *  instead of the MSDN documented value of 0 if handled
     
    41104110    BOOL oldredraw = infoPtr->DoRedraw;
    41114111
    4112     TRACE("set to %s, fStatus=%08x\n", 
     4112    TRACE("set to %s, fStatus=%08x\n",
    41134113          (wParam) ? "TRUE" : "FALSE", infoPtr->fStatus);
    41144114    infoPtr->DoRedraw = (BOOL) wParam;
     
    41534153              rcWin.left, rcWin.top, rcWin.right, rcWin.bottom);
    41544154
    4155         if ((lParam == 0) && (rcWin.right-rcWin.left == 0) && 
     4155        if ((lParam == 0) && (rcWin.right-rcWin.left == 0) &&
    41564156            (rcWin.bottom-rcWin.top == 0)) {
    41574157            /* native control seems to do this */
    41584158            GetClientRect (GetParent(infoPtr->hwndSelf), &rcClient);
    4159             TRACE("sizing rebar, message and client zero, parent client (%d,%d)\n", 
     4159            TRACE("sizing rebar, message and client zero, parent client (%d,%d)\n",
    41604160                  rcClient.right, rcClient.bottom);
    41614161        }
     
    41714171            /* do the actual WM_SIZE request */
    41724172            GetClientRect (infoPtr->hwndSelf, &rcClient);
    4173             TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%d,%d)\n", 
     4173            TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%d,%d)\n",
    41744174                  infoPtr->calcSize.cx, infoPtr->calcSize.cy,
    41754175                  LOWORD(lParam), HIWORD(lParam),
     
    41914191            /* native seems to use the current client rect for the size      */
    41924192            infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
    4193             TRACE("sizing rebar to client (%d,%d) size is zero but AUTOSIZE set\n", 
     4193            TRACE("sizing rebar to client (%d,%d) size is zero but AUTOSIZE set\n",
    41944194                  rcClient.right, rcClient.bottom);
    41954195        }
    41964196        else {
    4197             TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%d,%d)\n", 
     4197            TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%d,%d)\n",
    41984198                  infoPtr->calcSize.cx, infoPtr->calcSize.cy,
    41994199                  LOWORD(lParam), HIWORD(lParam),
     
    42094209        autosize.rcActual = autosize.rcTarget;  /* ??? */
    42104210        REBAR_Notify((NMHDR *) &autosize, infoPtr, RBN_AUTOSIZE);
    4211         TRACE("RBN_AUTOSIZE client=(%d,%d), lp=%08lx\n", 
     4211        TRACE("RBN_AUTOSIZE client=(%d,%d), lp=%08lx\n",
    42124212              autosize.rcTarget.right, autosize.rcTarget.bottom, lParam);
    42134213    }
     
    42474247    infoPtr->origin.x = lpwp->x;
    42484248    infoPtr->origin.y = lpwp->y;
    4249     ret = DefWindowProcA(infoPtr->hwndSelf, WM_WINDOWPOSCHANGED, 
     4249    ret = DefWindowProcA(infoPtr->hwndSelf, WM_WINDOWPOSCHANGED,
    42504250                         wParam, lParam);
    42514251    GetWindowRect(infoPtr->hwndSelf, &rc);
    4252     TRACE("hwnd %08x new pos (%d,%d)-(%d,%d)\n",
     4252    TRACE("hwnd %p new pos (%d,%d)-(%d,%d)\n",
    42534253          infoPtr->hwndSelf, rc.left, rc.top, rc.right, rc.bottom);
    42544254    return ret;
     
    42614261    REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
    42624262
    4263     TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n",
     4263    TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n",
    42644264          hwnd, uMsg, /* SPY_GetMsgName(uMsg), */ wParam, lParam);
    42654265    if (!infoPtr && (uMsg != WM_NCCREATE))
     
    44634463/*      case WM_SYSCOLORCHANGE: supported according to ControlSpy */
    44644464/*      "Applications that have brushes using the existing system colors
    4465          should delete those brushes and recreate them using the new 
     4465         should delete those brushes and recreate them using the new
    44664466         system colors."  per MSDN                                */
    44674467
     
    44734473
    44744474        default:
    4475             if (uMsg >= WM_USER)
     4475            if ((uMsg >= WM_USER) && (uMsg < WM_APP))
    44764476                ERR("unknown msg %04x wp=%08x lp=%08lx\n",
    44774477                     uMsg, wParam, lParam);
     
    44984498#endif
    44994499    wndClass.lpszClassName = REBARCLASSNAMEA;
    4500  
     4500
    45014501    RegisterClassA (&wndClass);
    45024502
     
    45124512    UnregisterClassA (REBARCLASSNAMEA, (HINSTANCE)NULL);
    45134513}
    4514 
  • trunk/src/comctl32/tab.c

    r8382 r9370  
    4646  LPARAM lParam;
    4747  RECT   rect;    /* bounding rectangle of the item relative to the
    48                    * leftmost item (the leftmost item, 0, would have a 
    49                    * "left" member of 0 in this rectangle) 
    50                    * 
     48                   * leftmost item (the leftmost item, 0, would have a
     49                   * "left" member of 0 in this rectangle)
     50                   *
    5151                   * additionally the top member hold the row number
    5252                   * and bottom is unused and should be 0 */
     
    7070  TAB_ITEM*  items;           /* pointer to an array of TAB_ITEM's */
    7171  BOOL       DoRedraw;        /* flag for redrawing when tab contents is changed*/
    72   BOOL       needsScrolling;  /* TRUE if the size of the tabs is greater than 
     72  BOOL       needsScrolling;  /* TRUE if the size of the tabs is greater than
    7373                               * the size of the control */
    7474  BOOL       fSizeSet;        /* was the size of the tabs explicitly set? */
     
    8181 */
    8282#define SELECTED_TAB_OFFSET     2
    83 #define HORIZONTAL_ITEM_PADDING 5
     83#define HORIZONTAL_ITEM_PADDING 6
    8484#define VERTICAL_ITEM_PADDING   3
    8585#define ROUND_CORNER_SIZE       2
     
    8888#define CONTROL_BORDER_SIZEX    2
    8989#define CONTROL_BORDER_SIZEY    2
    90 #define BUTTON_SPACINGX         4 
     90#define BUTTON_SPACINGX         4
    9191#define BUTTON_SPACINGY         4
    9292#define FLAT_BTN_SPACINGX       8
     
    140140}
    141141
     142static void
     143TAB_DumpItemExternalA(TCITEMA *pti, UINT iItem)
     144{
     145    if (TRACE_ON(tab)) {
     146        TRACE("external tab %d, mask=0x%08x, dwState=0x%08x, dwStateMask=0x%08x, cchTextMax=0x%08x\n",
     147              iItem, pti->mask, pti->dwState, pti->dwStateMask, pti->cchTextMax);
     148        TRACE("external tab %d,   iImage=%d, lParam=0x%08lx, pszTextA=%s\n",
     149              iItem, pti->iImage, pti->lParam, debugstr_a(pti->pszText));
     150    }
     151}
     152
     153
     154static void
     155TAB_DumpItemExternalW(TCITEMW *pti, UINT iItem)
     156{
     157    if (TRACE_ON(tab)) {
     158        TRACE("external tab %d, mask=0x%08x, dwState=0x%08lx, dwStateMask=0x%08lx, cchTextMax=0x%08x\n",
     159              iItem, pti->mask, pti->dwState, pti->dwStateMask, pti->cchTextMax);
     160        TRACE("external tab %d,   iImage=%d, lParam=0x%08lx, pszTextW=%s\n",
     161              iItem, pti->iImage, pti->lParam, debugstr_w(pti->pszText));
     162    }
     163}
     164
     165static void
     166TAB_DumpItemInternal(TAB_INFO *infoPtr, UINT iItem)
     167{
     168    if (TRACE_ON(tab)) {
     169        TAB_ITEM *ti;
     170
     171        ti = &infoPtr->items[iItem];
     172        TRACE("tab %d, mask=0x%08x, dwState=0x%08lx, pszText=%s, iImage=%d\n",
     173              iItem, ti->mask, ti->dwState, debugstr_w(ti->pszText),
     174              ti->iImage);
     175        TRACE("tab %d, lParam=0x%08lx, rect.left=%d, rect.top(row)=%d\n",
     176              iItem, ti->lParam, ti->rect.left, ti->rect.top);
     177    }
     178}
     179
    142180static LRESULT
    143181TAB_GetCurSel (HWND hwnd)
    144182{
    145183    TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    146  
     184
    147185    return infoPtr->iSelected;
    148186}
     
    152190{
    153191    TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    154  
     192
    155193    return infoPtr->uFocus;
    156194}
     
    162200
    163201    if (infoPtr == NULL) return 0;
    164     return infoPtr->hwndToolTip;
     202    return (LRESULT)infoPtr->hwndToolTip;
    165203}
    166204
     
    171209  INT iItem = (INT)wParam;
    172210  INT prevItem;
    173  
     211
    174212  prevItem = -1;
    175213  if ((iItem >= 0) && (iItem < infoPtr->uNumItem)) {
     
    187225  TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    188226  INT iItem=(INT) wParam;
    189  
     227
    190228  if ((iItem < 0) || (iItem >= infoPtr->uNumItem)) return 0;
    191229
    192230  if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BUTTONS) {
    193231    FIXME("Should set input focus\n");
    194   } else { 
     232  } else {
    195233    int oldFocus = infoPtr->uFocus;
    196234    if (infoPtr->iSelected != iItem || infoPtr->uFocus == -1 ) {
     
    239277  RECT tmpItemRect,clientRect;
    240278  LONG        lStyle  = GetWindowLongA(hwnd, GWL_STYLE);
    241  
     279
    242280  /* Perform a sanity check and a trivial visibility check. */
    243281  if ( (infoPtr->uNumItem <= 0) ||
     
    252290  if (itemRect == NULL)
    253291    itemRect = &tmpItemRect;
    254  
     292
    255293  /* Retrieve the unmodified item rect. */
    256294  *itemRect = infoPtr->items[itemIndex].rect;
     
    287325  else if(!(lStyle & TCS_VERTICAL) && !(lStyle & TCS_BOTTOM)) /* not TCS_BOTTOM and not TCS_VERTICAL */
    288326  {
    289     itemRect->bottom = clientRect.top + 
     327    itemRect->bottom = clientRect.top +
    290328                      infoPtr->tabHeight +
    291329                      itemRect->top * (infoPtr->tabHeight - 2) +
    292330                      ((lStyle & TCS_BUTTONS) ? itemRect->top * BUTTON_SPACINGY : 0);
    293     itemRect->top = clientRect.top + 
     331    itemRect->top = clientRect.top +
    294332                   SELECTED_TAB_OFFSET +
    295333                   itemRect->top * (infoPtr->tabHeight - 2) +
     
    298336
    299337  /*
    300    * "scroll" it to make sure the item at the very left of the 
     338   * "scroll" it to make sure the item at the very left of the
    301339   * tab control is the leftmost visible tab.
    302340   */
     
    318356  {
    319357    OffsetRect(itemRect,
    320              -infoPtr->items[infoPtr->leftmostVisible].rect.left, 
     358             -infoPtr->items[infoPtr->leftmostVisible].rect.left,
    321359             0);
    322360
     
    329367             0);
    330368  }
     369  TRACE("item %d tab h=%d, rect=(%d,%d)-(%d,%d)\n",
     370        itemIndex, infoPtr->tabHeight,
     371        itemRect->left, itemRect->top, itemRect->right, itemRect->bottom);
    331372
    332373  /* Now, calculate the position of the item as if it were selected. */
     
    343384    /* If it also a bit higher. */
    344385    if ((lStyle & TCS_BOTTOM) && !(lStyle & TCS_VERTICAL))
    345     {     
     386    {
    346387      selectedRect->top -= 2; /* the border is thicker on the bottom */
    347388      selectedRect->bottom += SELECTED_TAB_OFFSET;
     
    369410static BOOL TAB_GetItemRect(HWND hwnd, WPARAM wParam, LPARAM lParam)
    370411{
    371   return TAB_InternalGetItemRect(hwnd, TAB_GetInfoPtr(hwnd), (INT)wParam, 
     412  return TAB_InternalGetItemRect(hwnd, TAB_GetInfoPtr(hwnd), (INT)wParam,
    372413                                 (LPRECT)lParam, (LPRECT)NULL);
    373414}
     
    379420 */
    380421static LRESULT TAB_KeyUp(
    381   HWND   hwnd, 
     422  HWND   hwnd,
    382423  WPARAM keyCode)
    383424{
     
    394435      break;
    395436  }
    396  
     437
    397438  /*
    398439   * If we changed to a valid item, change the selection
     
    423464 */
    424465static LRESULT TAB_FocusChanging(
    425   HWND   hwnd, 
    426   UINT   uMsg, 
    427   WPARAM wParam, 
     466  HWND   hwnd,
     467  UINT   uMsg,
     468  WPARAM wParam,
    428469  LPARAM lParam)
    429470{
     
    440481                                      NULL,
    441482                                      &selectedRect);
    442  
     483
    443484  /*
    444485   * If the rectangle is not completely invisible, invalidate that
     
    447488  if (isVisible)
    448489  {
     490      TRACE("invalidate (%d,%d)-(%d,%d)\n",
     491            selectedRect.left,selectedRect.top,
     492            selectedRect.right,selectedRect.bottom);
    449493    InvalidateRect(hwnd, &selectedRect, TRUE);
    450494  }
     
    456500}
    457501
    458 static HWND TAB_InternalHitTest (
     502static INT TAB_InternalHitTest (
    459503  HWND      hwnd,
    460   TAB_INFO* infoPtr, 
    461   POINT     pt, 
     504  TAB_INFO* infoPtr,
     505  POINT     pt,
    462506  UINT*     flags)
    463507
    464508{
    465509  RECT rect;
    466   int iCount;
    467  
     510  INT iCount;
     511
    468512  for (iCount = 0; iCount < infoPtr->uNumItem; iCount++)
    469513  {
     
    486530  TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    487531  LPTCHITTESTINFO lptest = (LPTCHITTESTINFO) lParam;
    488  
     532
    489533  return TAB_InternalHitTest (hwnd, infoPtr, lptest->pt, &lptest->flags);
    490534}
     
    537581    TAB_RelayEvent (infoPtr->hwndToolTip, hwnd,
    538582                    WM_LBUTTONDOWN, wParam, lParam);
    539  
     583
    540584  pt.x = (INT)LOWORD(lParam);
    541585  pt.y = (INT)HIWORD(lParam);
    542  
     586
    543587  newItem = TAB_InternalHitTest (hwnd, infoPtr, pt, &dummy);
    544  
     588
    545589  TRACE("On Tab, item %d\n", newItem);
    546590
     
    626670    ** overlaps.  Note also that the case where the cursor stayed within our
    627671    ** window but has moved off the hot-tracked tab will be handled by the
    628     ** WM_MOUSEMOVE event. 
     672    ** WM_MOUSEMOVE event.
    629673    */
    630674    if (!GetCursorPos(&pt) || WindowFromPoint(pt) != hwnd)
     
    771815 */
    772816static LRESULT TAB_AdjustRect(
    773   HWND   hwnd, 
    774   WPARAM fLarger, 
     817  HWND   hwnd,
     818  WPARAM fLarger,
    775819  LPRECT prc)
    776820{
     
    852896 */
    853897static LRESULT TAB_OnHScroll(
    854   HWND    hwnd, 
     898  HWND    hwnd,
    855899  int     nScrollCode,
    856900  int     nPos,
     
    878922 * TAB_SetupScrolling
    879923 *
    880  * This method will check the current scrolling state and make sure the 
     924 * This method will check the current scrolling state and make sure the
    881925 * scrolling control is displayed (or not).
    882926 */
     
    943987                                          controlPos.bottom - controlPos.top,
    944988                                          hwnd,
    945                                           (HMENU)NULL, 
    946                                           (HINSTANCE)NULL, 
    947                                           NULL);       
     989                                          (HMENU)NULL,
     990                                          (HINSTANCE)NULL,
     991                                          NULL);
    948992    }
    949993    else
    950994    {
    951       SetWindowPos(infoPtr->hwndUpDown, 
     995      SetWindowPos(infoPtr->hwndUpDown,
    952996                   (HWND)NULL,
    953997                   controlPos.left, controlPos.top,
    954998                   controlPos.right - controlPos.left,
    955999                   controlPos.bottom - controlPos.top,
    956                    SWP_SHOWWINDOW | SWP_NOZORDER);                 
     1000                   SWP_SHOWWINDOW | SWP_NOZORDER);
    9571001    }
    9581002
     
    10171061   * a font.
    10181062   */
    1019   hdc = GetDC(hwnd); 
    1020    
     1063  hdc = GetDC(hwnd);
     1064
    10211065  hFont = infoPtr->hFont ? infoPtr->hFont : GetStockObject (SYSTEM_FONT);
    10221066  hOldFont = SelectObject (hdc, hFont);
     
    10291073
    10301074  /* if TCS_VERTICAL then swap the height and width so this code places the
    1031      tabs along the top of the rectangle and we can just rotate them after 
     1075     tabs along the top of the rectangle and we can just rotate them after
    10321076     rather than duplicate all of the below code */
    10331077  if(lStyle & TCS_VERTICAL)
     
    10611105
    10621106    /*
    1063      * Make sure there is enough space for the letters + icon + growing the 
    1064      * selected item + extra space for the selected item.   
     1107     * Make sure there is enough space for the letters + icon + growing the
     1108     * selected item + extra space for the selected item.
    10651109     */
    1066     infoPtr->tabHeight = item_height + 2 * VERTICAL_ITEM_PADDING +
    1067         SELECTED_TAB_OFFSET;
    1068 
    1069   }
     1110    infoPtr->tabHeight = item_height + SELECTED_TAB_OFFSET +
     1111                         ((lStyle & TCS_BUTTONS) ? 2 : 1) *
     1112                          VERTICAL_ITEM_PADDING;
     1113
     1114    TRACE("tabH=%d, tmH=%ld, iconh=%d\n",
     1115          infoPtr->tabHeight, fontMetrics.tmHeight, icon_height);
     1116  }
     1117
     1118  TRACE("client right=%d\n", clientRect.right);
    10701119
    10711120  for (curItem = 0; curItem < infoPtr->uNumItem; curItem++)
     
    11021151
    11031152      infoPtr->items[curItem].rect.right = infoPtr->items[curItem].rect.left +
    1104                                            size.cx + icon_width + 
     1153                                           size.cx + icon_width +
    11051154                                           num * HORIZONTAL_ITEM_PADDING;
     1155      TRACE("for <%s>, l,r=%d,%d, num=%d\n",
     1156          debugstr_w(infoPtr->items[curItem].pszText),
     1157          infoPtr->items[curItem].rect.left,
     1158          infoPtr->items[curItem].rect.right,
     1159          num);
    11061160    }
    11071161
     
    11231177        infoPtr->items[curItem].rect.left = 0;
    11241178        curItemRowCount++;
     1179        TRACE("wrapping <%s>, l,r=%d,%d\n",
     1180            debugstr_w(infoPtr->items[curItem].pszText),
     1181            infoPtr->items[curItem].rect.left,
     1182            infoPtr->items[curItem].rect.right);
    11251183    }
    11261184
     
    11291187
    11301188    TRACE("TextSize: %li\n", size.cx);
    1131     TRACE("Rect: T %i, L %i, B %i, R %i\n", 
     1189    TRACE("Rect: T %i, L %i, B %i, R %i\n",
    11321190          infoPtr->items[curItem].rect.top,
    11331191          infoPtr->items[curItem].rect.left,
    11341192          infoPtr->items[curItem].rect.bottom,
    1135           infoPtr->items[curItem].rect.right); 
     1193          infoPtr->items[curItem].rect.right);
    11361194
    11371195    /*
     
    11591217    /* Don't need scrolling, then update infoPtr->leftmostVisible */
    11601218    if(!infoPtr->needsScrolling)
    1161       infoPtr->leftmostVisible = 0; 
     1219      infoPtr->leftmostVisible = 0;
    11621220
    11631221    TAB_SetupScrolling(hwnd, infoPtr, &clientRect);
     
    11861244           iItm++,iCount++)
    11871245      {
     1246          /* normalize the current rect */
     1247
     1248          /* shift the item to the left side of the clientRect */
     1249          infoPtr->items[iItm].rect.right -=
     1250            infoPtr->items[iItm].rect.left;
     1251          infoPtr->items[iItm].rect.left = 0;
     1252
     1253          TRACE("r=%d, cl=%d, cl.r=%d, iCount=%d, iRow=%d, uNumRows=%d, remTab=%d, tabPerRow=%d\n",
     1254              infoPtr->items[iItm].rect.right,
     1255              curItemLeftPos, clientRect.right,
     1256              iCount, iRow, infoPtr->uNumRows, remTab, tabPerRow);
     1257
    11881258          /* if we have reached the maximum number of tabs on this row */
    11891259          /* move to the next row, reset our current item left position and */
    11901260          /* the count of items on this row */
    1191           if (iCount >= ((iRow<remTab)?tabPerRow + 1:tabPerRow))
    1192           {
    1193               iRow++;
    1194               curItemLeftPos = 0;
    1195               iCount = 0;
    1196           }
    1197 
    1198           /* normalize the current rect */
    1199 
    1200           /* shift the item to the left side of the clientRect */
    1201           infoPtr->items[iItm].rect.right -=
    1202             infoPtr->items[iItm].rect.left;
    1203           infoPtr->items[iItm].rect.left = 0;
     1261
     1262          /* ************  FIXME FIXME FIXME  *************** */
     1263          /*                                                  */
     1264          /* FIXME:                                           */
     1265          /* if vertical,                                     */
     1266          /*   if item n and n+1 are in the same row,         */
     1267          /*      then the display has n+1 lower (toward the  */
     1268          /*      bottom) than n. We do it just the           */
     1269          /*      opposite!!!                                 */
     1270          /*                                                  */
     1271          /* ************  FIXME FIXME FIXME  *************** */
     1272
     1273          if (lStyle & TCS_VERTICAL) {
     1274              /* Vert: Add the remaining tabs in the *last* remainder rows */
     1275              if (iCount >= ((iRow>=(INT)infoPtr->uNumRows - remTab)?tabPerRow + 1:tabPerRow)) {
     1276                  iRow++;
     1277                  curItemLeftPos = 0;
     1278                  iCount = 0;
     1279              }
     1280          } else {
     1281              /* Horz: Add the remaining tabs in the *first* remainder rows */
     1282              if (iCount >= ((iRow<remTab)?tabPerRow + 1:tabPerRow)) {
     1283                  iRow++;
     1284                  curItemLeftPos = 0;
     1285                  iCount = 0;
     1286              }
     1287          }
    12041288
    12051289          /* shift the item to the right to place it as the next item in this row */
     
    12151299          else
    12161300            curItemLeftPos = infoPtr->items[iItm].rect.right;
     1301
     1302          TRACE("arranging <%s>, l,r=%d,%d, row=%d\n",
     1303              debugstr_w(infoPtr->items[iItm].pszText),
     1304              infoPtr->items[iItm].rect.left,
     1305              infoPtr->items[iItm].rect.right,
     1306              infoPtr->items[iItm].rect.top);
    12171307      }
    1218          
     1308
    12191309      /*
    12201310       * Justify the rows
     
    12231313         while(iIndexStart < infoPtr->uNumItem)
    12241314        {
    1225         /* 
     1315        /*
    12261316         * find the indexs of the row
    12271317         */
    12281318        /* find the first item on the next row */
    12291319        for (iIndexEnd=iIndexStart;
    1230              (iIndexEnd < infoPtr->uNumItem) && 
     1320             (iIndexEnd < infoPtr->uNumItem) &&
    12311321               (infoPtr->items[iIndexEnd].rect.top ==
    12321322                infoPtr->items[iIndexStart].rect.top) ;
     
    12341324        /* intentionally blank */;
    12351325
    1236         /* 
     1326        /*
    12371327         * we need to justify these tabs so they fill the whole given
    12381328         * client area
     
    12521342           widthDiff = widthDiff / iCount;
    12531343           /* add widthDiff/iCount, or extra space/items on row, to each item on this row */
    1254            for (iIndex=iIndexStart,iCount=0; iIndex < iIndexEnd; 
     1344           for (iIndex=iIndexStart,iCount=0; iIndex < iIndexEnd;
    12551345                iIndex++,iCount++)
    12561346           {
    12571347              infoPtr->items[iIndex].rect.left += iCount * widthDiff;
    12581348              infoPtr->items[iIndex].rect.right += (iCount + 1) * widthDiff;
     1349
     1350              TRACE("adjusting 1 <%s>, l,r=%d,%d\n",
     1351                  debugstr_w(infoPtr->items[iIndex].pszText),
     1352                  infoPtr->items[iIndex].rect.left,
     1353                  infoPtr->items[iIndex].rect.right);
     1354
    12591355           }
    12601356           infoPtr->items[iIndex - 1].rect.right += remainder;
     
    12641360          infoPtr->items[iIndexStart].rect.left = clientRect.left;
    12651361          infoPtr->items[iIndexStart].rect.right = clientRect.right - 4;
     1362
     1363          TRACE("adjusting 2 <%s>, l,r=%d,%d\n",
     1364              debugstr_w(infoPtr->items[iIndexStart].pszText),
     1365              infoPtr->items[iIndexStart].rect.left,
     1366              infoPtr->items[iIndexStart].rect.right);
     1367
    12661368        }
    12671369
     
    13031405 * This method is used to draw the interior (text and icon) of a single tab
    13041406 * into the tab control.
    1305  */         
     1407 */
    13061408static void
    13071409TAB_DrawItemInterior
     
    13181420  RECT localRect;
    13191421
    1320   HPEN   htextPen   = GetSysColorPen (COLOR_BTNTEXT);
     1422  HPEN   htextPen;
    13211423  HPEN   holdPen;
    13221424  INT    oldBkMode;
     
    13691471   * Text pen
    13701472   */
     1473  htextPen = CreatePen( PS_SOLID, 1, GetSysColor(COLOR_BTNTEXT) );
    13711474  holdPen = SelectObject(hdc, htextPen);
    13721475
    13731476  oldBkMode = SetBkMode(hdc, TRANSPARENT);
    1374   SetTextColor(hdc, GetSysColor((iItem == infoPtr->iHotTracked) ? COLOR_HIGHLIGHT : COLOR_BTNTEXT));
     1477  SetTextColor(hdc, (iItem == infoPtr->iHotTracked) ?
     1478                     comctl32_color.clrHighlight : comctl32_color.clrBtnText);
    13751479
    13761480  /*
     
    13961500    id = GetWindowLongA( hwnd, GWL_ID );
    13971501
    1398     /* 
     1502    /*
    13991503     * put together the DRAWITEMSTRUCT
    14001504     */
    1401     dis.CtlType    = ODT_TAB;   
    1402     dis.CtlID      = id;               
    1403     dis.itemID     = iItem;             
    1404     dis.itemAction = ODA_DRAWENTIRE;   
     1505    dis.CtlType    = ODT_TAB;
     1506    dis.CtlID      = id;
     1507    dis.itemID     = iItem;
     1508    dis.itemAction = ODA_DRAWENTIRE;
    14051509    if ( iItem == infoPtr->iSelected )
    1406       dis.itemState = ODS_SELECTED;     
    1407     else                               
    1408       dis.itemState = 0;               
     1510      dis.itemState = ODS_SELECTED;
     1511    else
     1512      dis.itemState = 0;
    14091513    dis.hwndItem = hwnd;                /* */
    1410     dis.hDC      = hdc;         
     1514    dis.hDC      = hdc;
    14111515    dis.rcItem   = *drawRect;           /* */
    14121516    dis.itemData = infoPtr->items[iItem].lParam;
     
    14411545    rcTemp = *drawRect;
    14421546
     1547    rcText.left = rcText.top = rcText.right = rcText.bottom = 0;
     1548
    14431549    /*
    14441550     * Setup for text output
    14451551     */
    14461552    oldBkMode = SetBkMode(hdc, TRANSPARENT);
    1447     SetTextColor(hdc, GetSysColor((iItem == infoPtr->iHotTracked) ? COLOR_HIGHLIGHT : COLOR_BTNTEXT));
     1553    SetTextColor(hdc, (iItem == infoPtr->iHotTracked) ?
     1554                 comctl32_color.clrHighlight : comctl32_color.clrBtnText);
    14481555
    14491556    /* get the rectangle that the text fits in */
     
    14611568
    14621569      if(lStyle & TCS_VERTICAL)
    1463         center_offset = ((drawRect->bottom - drawRect->top) - (cy + VERTICAL_ITEM_PADDING + (rcText.right - rcText.left))) / 2;
     1570        center_offset = ((drawRect->bottom - drawRect->top) - (cy + HORIZONTAL_ITEM_PADDING + (rcText.right - rcText.left))) / 2;
    14641571      else
    14651572        center_offset = ((drawRect->right - drawRect->left) - (cx + HORIZONTAL_ITEM_PADDING + (rcText.right - rcText.left))) / 2;
    14661573
     1574      TRACE("for <%s>, c_o=%d, draw=(%d,%d)-(%d,%d), textlen=%d\n",
     1575          debugstr_w(infoPtr->items[iItem].pszText), center_offset,
     1576          drawRect->left, drawRect->top, drawRect->right, drawRect->bottom,
     1577          (rcText.right-rcText.left));
     1578
    14671579      if((lStyle & TCS_VERTICAL) && (lStyle & TCS_BOTTOM))
    14681580      {
    1469         /* rcImage.left = drawRect->left; */ /* explicit from above rcImage = *drawRect */
    14701581        rcImage.top = drawRect->top + center_offset;
    14711582        rcImage.left = drawRect->right - cx; /* if tab is TCS_VERTICAL and TCS_BOTTOM, the text is drawn from the */
    14721583                                             /* right side of the tab, but the image still uses the left as its x position */
    14731584                                             /* this keeps the image always drawn off of the same side of the tab */
    1474         drawRect->top = rcImage.top + (cx + VERTICAL_ITEM_PADDING);
     1585        drawRect->top = rcImage.top + (cx + HORIZONTAL_ITEM_PADDING);
    14751586      }
    14761587      else if(lStyle & TCS_VERTICAL)
    14771588      {
    1478         /* rcImage.left = drawRect->left; */ /* explicit from above rcImage = *drawRect */
    14791589        rcImage.top = drawRect->bottom - cy - center_offset;
    1480 
    1481         drawRect->bottom = rcImage.top - VERTICAL_ITEM_PADDING;
     1590        rcImage.left--;
     1591        drawRect->bottom = rcImage.top - HORIZONTAL_ITEM_PADDING;
    14821592      }
    14831593      else /* normal style, whether TCS_BOTTOM or not */
    14841594      {
    1485         rcImage.left = drawRect->left + center_offset;
    1486         /* rcImage.top = drawRect->top; */ /* explicit from above rcImage = *drawRect */
    1487 
     1595        rcImage.left = drawRect->left + center_offset + 3;
    14881596        drawRect->left = rcImage.left + cx + HORIZONTAL_ITEM_PADDING;
     1597        rcImage.top -= (lStyle & TCS_BOTTOM) ? 2 : 1;
    14891598      }
    14901599
     1600      TRACE("drawing image=%d, left=%d, top=%d\n",
     1601            infoPtr->items[iItem].iImage, rcImage.left, rcImage.top-1);
    14911602      ImageList_Draw
    14921603        (
     
    14951606        hdc,
    14961607        rcImage.left,
    1497         rcImage.top + 1,
     1608        rcImage.top,
    14981609        ILD_NORMAL
    14991610        );
     
    15441655    if(lStyle & TCS_VERTICAL)
    15451656    {
    1546       if (!GetObjectA((infoPtr->hFont) ? 
     1657      if (!GetObjectA((infoPtr->hFont) ?
    15471658                infoPtr->hFont : GetStockObject(SYSTEM_FONT),
    15481659                sizeof(LOGFONTA),&logfont))
     
    15511662
    15521663        lstrcpyA(logfont.lfFaceName, "Arial");
    1553         logfont.lfHeight = -MulDiv(iPointSize, GetDeviceCaps(hdc, LOGPIXELSY), 
     1664        logfont.lfHeight = -MulDiv(iPointSize, GetDeviceCaps(hdc, LOGPIXELSY),
    15541665                                    72);
    15551666        logfont.lfWeight = FW_NORMAL;
     
    16041715  SetBkMode(hdc, oldBkMode);
    16051716  SelectObject(hdc, holdPen);
     1717  DeleteObject( htextPen );
    16061718}
    16071719
     
    16101722 *
    16111723 * This method is used to draw a single tab into the tab control.
    1612  */         
     1724 */
    16131725static void TAB_DrawItem(
    1614   HWND hwnd, 
    1615   HDC  hdc, 
     1726  HWND hwnd,
     1727  HDC  hdc,
    16161728  INT  iItem)
    16171729{
     
    16211733  RECT      selectedRect;
    16221734  BOOL      isVisible;
    1623   RECT      r;
     1735  RECT      r, fillRect, r1;
     1736  INT       clRight = 0;
     1737  INT       clBottom = 0;
     1738  COLORREF  bkgnd, corner;
    16241739
    16251740  /*
     
    16341749  if (isVisible)
    16351750  {
    1636     HBRUSH hbr       = CreateSolidBrush (GetSysColor(COLOR_BTNFACE));   
    1637     HPEN   hwPen     = GetSysColorPen (COLOR_3DHILIGHT);
    1638     HPEN hbPen  = GetSysColorPen (COLOR_3DDKSHADOW);
    1639     HPEN hShade = GetSysColorPen (COLOR_BTNSHADOW);
    1640 
    1641     HPEN   holdPen;
    1642     BOOL   deleteBrush = TRUE;
     1751    /* If you need to see what the control is doing,
     1752     * then override these variables. They will change what
     1753     * fill colors are used for filling the tabs, and the
     1754     * corners when drawing the edge.
     1755     */
     1756    bkgnd = comctl32_color.clrBtnFace;
     1757    corner = comctl32_color.clrBtnFace;
    16431758
    16441759    if (lStyle & TCS_BUTTONS)
    16451760    {
     1761      HBRUSH hbr       = CreateSolidBrush (bkgnd);
     1762      BOOL   deleteBrush = TRUE;
     1763
    16461764      /* Get item rectangle */
    16471765      r = itemRect;
    16481766
    1649       holdPen = SelectObject (hdc, hwPen);
    1650 
    16511767      /* Separators between flat buttons */
    1652       /* FIXME: test and correct this if necessary for TCS_FLATBUTTONS style */
    1653       if (lStyle & TCS_FLATBUTTONS)
     1768      if (lStyle & TCS_FLATBUTTONS)
    16541769      {
    1655         int x = r.right + FLAT_BTN_SPACINGX - 2;
    1656 
    1657         /* highlight */
    1658         MoveToEx (hdc, x, r.bottom - 1, NULL);
    1659         LineTo   (hdc, x, r.top - 1);
    1660         x--;
    1661 
    1662         /* shadow */
    1663         SelectObject(hdc, hbPen);
    1664         MoveToEx (hdc, x, r.bottom - 1, NULL);
    1665         LineTo   (hdc, x, r.top - 1);
    1666 
    1667         /* shade */
    1668         SelectObject (hdc, hShade );
    1669         MoveToEx (hdc, x - 1, r.bottom - 1, NULL);
    1670         LineTo   (hdc, x - 1, r.top - 1);
     1770        r1 = r;
     1771        r1.right += (FLAT_BTN_SPACINGX -2);
     1772        DrawEdge(hdc, &r1, EDGE_ETCHED, BF_RIGHT);
    16711773      }
    16721774
     
    16761778        if (!((lStyle & TCS_OWNERDRAWFIXED) && infoPtr->fSizeSet))
    16771779        {
    1678               COLORREF bk = GetSysColor(COLOR_3DHILIGHT);
    16791780              DeleteObject(hbr);
    16801781              hbr = GetSysColorBrush(COLOR_SCROLLBAR);
    16811782
    1682               SetTextColor(hdc, GetSysColor(COLOR_3DFACE));
    1683               SetBkColor(hdc, bk);
     1783              SetTextColor(hdc, comctl32_color.clr3dFace);
     1784              SetBkColor(hdc, comctl32_color.clr3dHilight);
    16841785
    16851786              /* if COLOR_WINDOW happens to be the same as COLOR_3DHILIGHT
     
    16871788               * look different from the window background.
    16881789               */
    1689                if (bk == GetSysColor(COLOR_WINDOW))
     1790               if (comctl32_color.clr3dHilight == comctl32_color.clrWindow)
    16901791                  hbr = COMCTL32_hPattern55AABrush;
    16911792
     
    16931794        }
    16941795
    1695         /* Erase the background */
     1796        /* Clear interior */
    16961797        FillRect(hdc, &r, hbr);
    16971798
    1698         /*
    1699          * Draw the tab now.
    1700          * The rectangles calculated exclude the right and bottom
    1701          * borders of the rectangle. To simplify the following code, those
    1702          * borders are shaved-off beforehand.
    1703          */
    1704         r.right--;
    1705         r.bottom--;
    1706 
    1707         /* highlight */
    1708         SelectObject(hdc, hwPen);
    1709         MoveToEx (hdc, r.left, r.bottom, NULL);
    1710         LineTo   (hdc, r.right, r.bottom);
    1711         LineTo   (hdc, r.right, r.top + 1);
    1712        
    1713         /* shadow */
    1714         SelectObject(hdc, hbPen);
    1715         LineTo  (hdc, r.left + 1, r.top + 1);
    1716         LineTo  (hdc, r.left + 1, r.bottom);
    1717 
    1718         /* shade */
    1719         SelectObject (hdc, hShade );
    1720         MoveToEx (hdc, r.right, r.top, NULL);
    1721         LineTo   (hdc, r.left, r.top);
    1722         LineTo   (hdc, r.left, r.bottom);
     1799        DrawEdge(hdc, &r, EDGE_SUNKEN, BF_SOFT|BF_RECT);
     1800      }
     1801      else  /* ! selected */
     1802      {
     1803        if (!(lStyle & TCS_FLATBUTTONS))
     1804        {
     1805          /* Clear interior */
     1806          FillRect(hdc, &r, hbr);
     1807
     1808          DrawEdge(hdc, &r, EDGE_RAISED, BF_SOFT|BF_RECT);
     1809        }
     1810      }
     1811
     1812      /* Cleanup */
     1813      if (deleteBrush) DeleteObject(hbr);
     1814    }
     1815    else /* !TCS_BUTTONS */
     1816    {
     1817      /* We draw a rectangle of different sizes depending on the selection
     1818       * state. */
     1819      if (iItem == infoPtr->iSelected) {
     1820        RECT rect;
     1821        GetClientRect (hwnd, &rect);
     1822        clRight = rect.right;
     1823        clBottom = rect.bottom;
     1824        r = selectedRect;
    17231825      }
    17241826      else
    1725       {
    1726         /* Erase the background */
    1727         FillRect(hdc, &r, hbr);
    1728 
    1729         if (!(lStyle & TCS_FLATBUTTONS))
    1730         {
    1731           /* highlight */
    1732           MoveToEx (hdc, r.left, r.bottom, NULL);
    1733           LineTo   (hdc, r.left, r.top);
    1734           LineTo   (hdc, r.right, r.top);
    1735          
    1736           /* shadow */
    1737           SelectObject(hdc, hbPen);
    1738           LineTo  (hdc, r.right, r.bottom);
    1739           LineTo  (hdc, r.left, r.bottom);
    1740 
    1741           /* shade */
    1742           SelectObject (hdc, hShade );
    1743           MoveToEx (hdc, r.right - 1, r.top, NULL);
    1744           LineTo   (hdc, r.right - 1, r.bottom - 1);
    1745           LineTo   (hdc, r.left + 1, r.bottom - 1);
    1746         }
    1747       }
    1748     }
    1749     else /* !TCS_BUTTONS */
    1750     {
    1751       /* Background color */
    1752       DeleteObject(hbr);
    1753       hbr = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));   
    1754 
    1755       /* We draw a rectangle of different sizes depending on the selection
    1756        * state. */
    1757       if (iItem == infoPtr->iSelected)
    1758         r = selectedRect;
    1759       else
    17601827        r = itemRect;
    17611828
    17621829      /*
    1763        * Erase the background.
    1764        * This is necessary when drawing the selected item since it is larger 
    1765        * than the others, it might overlap with stuff already drawn by the 
     1830       * Erase the background. (Delay it but setup rectangle.)
     1831       * This is necessary when drawing the selected item since it is larger
     1832       * than the others, it might overlap with stuff already drawn by the
    17661833       * other tabs
    1767        */     
    1768       FillRect(hdc, &r, hbr);
    1769 
    1770       /*
    1771        * Draw the tab now.
    1772        * The rectangles calculated exclude the right and bottom
    1773        * borders of the rectangle. To simplify the following code, those
    1774        * borders are shaved-off beforehand.
    17751834       */
    1776       r.right--;
    1777       r.bottom--;
    1778      
    1779       holdPen = SelectObject (hdc, hwPen);
     1835      fillRect = r;
     1836
    17801837      if(lStyle & TCS_VERTICAL)
    17811838      {
     1839        /* These are for adjusting the drawing of a Selected tab      */
     1840        /* The initial values are for the normal case of non-Selected */
     1841        int ZZ = 1;   /* Do not strech if selected */
     1842        if (iItem == infoPtr->iSelected) {
     1843            ZZ = 0;
     1844
     1845            /* if leftmost draw the line longer */
     1846            if(selectedRect.top == 0)
     1847                fillRect.top += 2;
     1848            /* if rightmost draw the line longer */
     1849            if(selectedRect.bottom == clBottom)
     1850                fillRect.bottom -= 2;
     1851        }
     1852
    17821853        if (lStyle & TCS_BOTTOM)
    17831854        {
    1784           /* highlight */
    1785           MoveToEx (hdc, r.left, r.top, NULL);
    1786           LineTo   (hdc, r.right - ROUND_CORNER_SIZE, r.top);
    1787           LineTo   (hdc, r.right, r.top + ROUND_CORNER_SIZE);
    1788 
    1789           /* shadow */
    1790           SelectObject(hdc, hbPen);
    1791           LineTo  (hdc, r.right, r.bottom - ROUND_CORNER_SIZE);
    1792           LineTo  (hdc, r.right - ROUND_CORNER_SIZE, r.bottom);
    1793           LineTo  (hdc, r.left - 1, r.bottom);
    1794 
    1795           /* shade */
    1796           SelectObject (hdc, hShade );
    1797           MoveToEx (hdc, r.right - 1, r.top, NULL);
    1798           LineTo   (hdc, r.right - 1, r.bottom - 1);
    1799           LineTo   (hdc, r.left - 1,    r.bottom - 1);
     1855          /* Adjust both rectangles to match native */
     1856          r.left += (1-ZZ);
     1857
     1858          TRACE("<left> item=%d, fill=(%d,%d)-(%d,%d), edge=(%d,%d)-(%d,%d)\n",
     1859                iItem,
     1860                fillRect.left,fillRect.top,fillRect.right,fillRect.bottom,
     1861                r.left,r.top,r.right,r.bottom);
     1862
     1863          /* Clear interior */
     1864          SetBkColor(hdc, bkgnd);
     1865          ExtTextOutA(hdc, 0, 0, 2, &fillRect, NULL, 0, 0);
     1866
     1867          /* Draw rectangular edge around tab */
     1868          DrawEdge(hdc, &r, EDGE_RAISED, BF_SOFT|BF_RIGHT|BF_TOP|BF_BOTTOM);
     1869
     1870          /* Now erase the top corner and draw diagonal edge */
     1871          SetBkColor(hdc, corner);
     1872          r1.left = r.right - ROUND_CORNER_SIZE - 1;
     1873          r1.top = r.top;
     1874          r1.right = r.right;
     1875          r1.bottom = r1.top + ROUND_CORNER_SIZE;
     1876          ExtTextOutA(hdc, 0, 0, 2, &r1, NULL, 0, 0);
     1877          r1.right--;
     1878          DrawEdge(hdc, &r1, EDGE_RAISED, BF_SOFT|BF_DIAGONAL_ENDTOPLEFT);
     1879
     1880          /* Now erase the bottom corner and draw diagonal edge */
     1881          r1.left = r.right - ROUND_CORNER_SIZE - 1;
     1882          r1.bottom = r.bottom;
     1883          r1.right = r.right;
     1884          r1.top = r1.bottom - ROUND_CORNER_SIZE;
     1885          ExtTextOutA(hdc, 0, 0, 2, &r1, NULL, 0, 0);
     1886          r1.right--;
     1887          DrawEdge(hdc, &r1, EDGE_RAISED, BF_SOFT|BF_DIAGONAL_ENDBOTTOMLEFT);
     1888
     1889          if ((iItem == infoPtr->iSelected) && (selectedRect.top == 0)) {
     1890              r1 = r;
     1891              r1.right = r1.left;
     1892              r1.left--;
     1893              DrawEdge(hdc, &r1, EDGE_RAISED, BF_SOFT|BF_TOP);
     1894          }
     1895
    18001896        }
    18011897        else
    18021898        {
    1803           /* highlight */
    1804           MoveToEx (hdc, r.right, r.top, NULL);
    1805           LineTo   (hdc, r.left + ROUND_CORNER_SIZE, r.top);
    1806           LineTo   (hdc, r.left, r.top + ROUND_CORNER_SIZE);
    1807           LineTo   (hdc, r.left, r.bottom - ROUND_CORNER_SIZE);
    1808 
    1809           /* shadow */
    1810           SelectObject(hdc, hbPen);
    1811           LineTo (hdc, r.left + ROUND_CORNER_SIZE,  r.bottom);
    1812           LineTo (hdc, r.right + 1, r.bottom);
    1813 
    1814           /* shade */
    1815           SelectObject (hdc, hShade );
    1816           MoveToEx (hdc, r.left + ROUND_CORNER_SIZE - 1, r.bottom - 1, NULL);
    1817           LineTo   (hdc, r.right + 1, r.bottom - 1);
     1899          /* Adjust both rectangles to match native */
     1900          fillRect.right += (1-ZZ);
     1901
     1902          TRACE("<left> item=%d, fill=(%d,%d)-(%d,%d), edge=(%d,%d)-(%d,%d)\n",
     1903                iItem,
     1904                fillRect.left,fillRect.top,fillRect.right,fillRect.bottom,
     1905                r.left,r.top,r.right,r.bottom);
     1906
     1907          /* Clear interior */
     1908          SetBkColor(hdc, bkgnd);
     1909          ExtTextOutA(hdc, 0, 0, 2, &fillRect, NULL, 0, 0);
     1910
     1911          /* Draw rectangular edge around tab */
     1912          DrawEdge(hdc, &r, EDGE_RAISED, BF_SOFT|BF_LEFT|BF_TOP|BF_BOTTOM);
     1913
     1914          /* Now erase the top corner and draw diagonal edge */
     1915          SetBkColor(hdc, corner);
     1916          r1.left = r.left;
     1917          r1.top = r.top;
     1918          r1.right = r1.left + ROUND_CORNER_SIZE + 1;
     1919          r1.bottom = r1.top + ROUND_CORNER_SIZE;
     1920          ExtTextOutA(hdc, 0, 0, 2, &r1, NULL, 0, 0);
     1921          r1.left++;
     1922          DrawEdge(hdc, &r1, EDGE_RAISED, BF_SOFT|BF_DIAGONAL_ENDTOPRIGHT);
     1923
     1924          /* Now erase the bottom corner and draw diagonal edge */
     1925          r1.left = r.left;
     1926          r1.bottom = r.bottom;
     1927          r1.right = r1.left + ROUND_CORNER_SIZE + 1;
     1928          r1.top = r1.bottom - ROUND_CORNER_SIZE;
     1929          ExtTextOutA(hdc, 0, 0, 2, &r1, NULL, 0, 0);
     1930          r1.left++;
     1931          DrawEdge(hdc, &r1, EDGE_SUNKEN, BF_DIAGONAL_ENDTOPLEFT);
    18181932        }
    18191933      }
    1820       else
     1934      else  /* ! TCS_VERTICAL */
    18211935      {
     1936        /* These are for adjusting the drawing of a Selected tab      */
     1937        /* The initial values are for the normal case of non-Selected */
     1938        int ZZ = 1;   /* Do not strech if selected */
     1939        if (iItem == infoPtr->iSelected) {
     1940            ZZ = 0;
     1941
     1942            /* if leftmost draw the line longer */
     1943            if(selectedRect.left == 0)
     1944                fillRect.left += 2;
     1945            /* if rightmost draw the line longer */
     1946            if(selectedRect.right == clRight)
     1947                fillRect.right -= 2;
     1948        }
     1949
    18221950        if (lStyle & TCS_BOTTOM)
    18231951        {
    1824           /* highlight */
    1825           MoveToEx (hdc, r.left, r.top, NULL);
    1826           LineTo   (hdc, r.left, r.bottom - ROUND_CORNER_SIZE);
    1827           LineTo   (hdc, r.left + ROUND_CORNER_SIZE, r.bottom);
    1828 
    1829           /* shadow */
    1830           SelectObject(hdc, hbPen);
    1831           LineTo  (hdc, r.right - ROUND_CORNER_SIZE, r.bottom);
    1832           LineTo  (hdc, r.right, r.bottom - ROUND_CORNER_SIZE);
    1833           LineTo  (hdc, r.right, r.top - 1);
    1834 
    1835           /* shade */
    1836           SelectObject (hdc, hShade );
    1837           MoveToEx   (hdc, r.left, r.bottom - 1, NULL);
    1838           LineTo   (hdc, r.right - ROUND_CORNER_SIZE - 1, r.bottom - 1);
    1839           LineTo   (hdc, r.right - 1, r.bottom - ROUND_CORNER_SIZE - 1);
    1840           LineTo  (hdc, r.right - 1, r.top - 1);
     1952
     1953          /* Adjust both rectangles to match native */
     1954          fillRect.top--;
     1955          fillRect.bottom--;
     1956          r.bottom--;
     1957          r.top -= ZZ;
     1958
     1959          TRACE("<bottom> item=%d, fill=(%d,%d)-(%d,%d), edge=(%d,%d)-(%d,%d)\n",
     1960                iItem,
     1961                fillRect.left,fillRect.top,fillRect.right,fillRect.bottom,
     1962                r.left,r.top,r.right,r.bottom);
     1963
     1964          /* Clear interior */
     1965          SetBkColor(hdc, bkgnd);
     1966          ExtTextOutA(hdc, 0, 0, 2, &fillRect, NULL, 0, 0);
     1967
     1968          /* Draw rectangular edge around tab */
     1969          DrawEdge(hdc, &r, EDGE_RAISED, BF_SOFT|BF_LEFT|BF_BOTTOM|BF_RIGHT);
     1970
     1971          /* Now erase the righthand corner and draw diagonal edge */
     1972          SetBkColor(hdc, corner);
     1973          r1.left = r.right - ROUND_CORNER_SIZE;
     1974          r1.bottom = r.bottom;
     1975          r1.right = r.right;
     1976          r1.top = r1.bottom - ROUND_CORNER_SIZE - 1;
     1977          ExtTextOutA(hdc, 0, 0, 2, &r1, NULL, 0, 0);
     1978          r1.bottom--;
     1979          DrawEdge(hdc, &r1, EDGE_RAISED, BF_SOFT|BF_DIAGONAL_ENDBOTTOMLEFT);
     1980
     1981          /* Now erase the lefthand corner and draw diagonal edge */
     1982          r1.left = r.left;
     1983          r1.bottom = r.bottom;
     1984          r1.right = r1.left + ROUND_CORNER_SIZE;
     1985          r1.top = r1.bottom - ROUND_CORNER_SIZE - 1;
     1986          ExtTextOutA(hdc, 0, 0, 2, &r1, NULL, 0, 0);
     1987          r1.bottom--;
     1988          DrawEdge(hdc, &r1, EDGE_RAISED, BF_SOFT|BF_DIAGONAL_ENDTOPLEFT);
     1989
     1990          if ((iItem == infoPtr->iSelected) && (selectedRect.left == 0)) {
     1991              r1 = r;
     1992              r1.bottom = r1.top;
     1993              r1.top--;
     1994              DrawEdge(hdc, &r1, EDGE_RAISED, BF_SOFT|BF_LEFT);
     1995          }
     1996
    18411997        }
    18421998        else
    18431999        {
    1844           /* highlight */
    1845           if(infoPtr->items[iItem].rect.left == 0) /* if leftmost draw the line longer */
    1846             MoveToEx (hdc, r.left, r.bottom, NULL);
    1847           else
    1848             MoveToEx (hdc, r.left, r.bottom - 1, NULL);
    1849 
    1850           LineTo   (hdc, r.left, r.top + ROUND_CORNER_SIZE);
    1851           LineTo   (hdc, r.left + ROUND_CORNER_SIZE, r.top);
    1852           LineTo   (hdc, r.right - ROUND_CORNER_SIZE, r.top);
    1853 
    1854           /* shadow */
    1855           SelectObject(hdc, hbPen);
    1856           LineTo (hdc, r.right,  r.top + ROUND_CORNER_SIZE);
    1857           LineTo (hdc, r.right,  r.bottom + 1);
    1858 
    1859 
    1860           /* shade */
    1861           SelectObject (hdc, hShade );
    1862           MoveToEx (hdc, r.right - 1, r.top + ROUND_CORNER_SIZE, NULL);
    1863           LineTo   (hdc, r.right - 1, r.bottom + 1);
     2000
     2001          /* Adjust both rectangles to match native */
     2002          fillRect.bottom += (1-ZZ);
     2003
     2004          TRACE("<top> item=%d, fill=(%d,%d)-(%d,%d), edge=(%d,%d)-(%d,%d)\n",
     2005                iItem,
     2006                fillRect.left,fillRect.top,fillRect.right,fillRect.bottom,
     2007                r.left,r.top,r.right,r.bottom);
     2008
     2009          /* Clear interior */
     2010          SetBkColor(hdc, bkgnd);
     2011          ExtTextOutA(hdc, 0, 0, 2, &fillRect, NULL, 0, 0);
     2012
     2013          /* Draw rectangular edge around tab */
     2014          DrawEdge(hdc, &r, EDGE_RAISED, BF_SOFT|BF_LEFT|BF_TOP|BF_RIGHT);
     2015
     2016          /* Now erase the righthand corner and draw diagonal edge */
     2017          SetBkColor(hdc, corner);
     2018          r1.left = r.right - ROUND_CORNER_SIZE;
     2019          r1.top = r.top;
     2020          r1.right = r.right;
     2021          r1.bottom = r1.top + ROUND_CORNER_SIZE + 1;
     2022          ExtTextOutA(hdc, 0, 0, 2, &r1, NULL, 0, 0);
     2023          r1.top++;
     2024          DrawEdge(hdc, &r1, EDGE_RAISED, BF_SOFT|BF_DIAGONAL_ENDBOTTOMRIGHT);
     2025
     2026          /* Now erase the lefthand corner and draw diagonal edge */
     2027          r1.left = r.left;
     2028          r1.top = r.top;
     2029          r1.right = r1.left + ROUND_CORNER_SIZE;
     2030          r1.bottom = r1.top + ROUND_CORNER_SIZE + 1;
     2031          ExtTextOutA(hdc, 0, 0, 2, &r1, NULL, 0, 0);
     2032          r1.top++;
     2033          DrawEdge(hdc, &r1, EDGE_RAISED, BF_SOFT|BF_DIAGONAL_ENDTOPRIGHT);
     2034
    18642035        }
    18652036      }
    18662037    }
    1867  
     2038
     2039    TAB_DumpItemInternal(infoPtr, iItem);
     2040
    18682041    /* This modifies r to be the text rectangle. */
    18692042    {
     
    18832056      DrawFocusRect(hdc, &r);
    18842057    }
    1885 
    1886     /* Cleanup */
    1887     SelectObject(hdc, holdPen);
    1888     if (deleteBrush) DeleteObject(hbr);
    18892058  }
    18902059}
     
    18952064 * This method is used to draw the raised border around the tab control
    18962065 * "content" area.
    1897  */         
     2066 */
    18982067static void TAB_DrawBorder (HWND hwnd, HDC hdc)
    18992068{
    19002069  TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    1901   HPEN htmPen;
    1902   HPEN hwPen  = GetSysColorPen (COLOR_3DHILIGHT);
    1903   HPEN hbPen  = GetSysColorPen (COLOR_3DDKSHADOW);
    1904   HPEN hShade = GetSysColorPen (COLOR_BTNSHADOW);
    19052070  RECT rect;
    19062071  DWORD lStyle = GetWindowLongA(hwnd, GWL_STYLE);
     
    19162081    if ((lStyle & TCS_BOTTOM) && !(lStyle & TCS_VERTICAL))
    19172082    {
    1918       rect.bottom -= (infoPtr->tabHeight - 2) * infoPtr->uNumRows + 2;
     2083      rect.bottom -= (infoPtr->tabHeight - 2) * infoPtr->uNumRows + 3;
    19192084    }
    19202085    else if((lStyle & TCS_BOTTOM) && (lStyle & TCS_VERTICAL))
     
    19282093    else /* not TCS_VERTICAL and not TCS_BOTTOM */
    19292094    {
    1930       rect.top += (infoPtr->tabHeight - 2) * infoPtr->uNumRows + 1;
    1931     }
    1932   }
    1933 
    1934   /*
    1935    * Shave-off the right and bottom margins (exluded in the
    1936    * rect)
    1937    */
    1938   rect.right--;
    1939   rect.bottom--;
    1940 
    1941   /* highlight */
    1942   htmPen = SelectObject (hdc, hwPen);
    1943 
    1944   MoveToEx (hdc, rect.left, rect.bottom, NULL);
    1945   LineTo (hdc, rect.left, rect.top);
    1946   LineTo (hdc, rect.right, rect.top);
    1947 
    1948   /* Dark Shadow */
    1949   SelectObject (hdc, hbPen);
    1950   LineTo (hdc, rect.right, rect.bottom );
    1951   LineTo (hdc, rect.left, rect.bottom);
    1952 
    1953   /* shade */
    1954   SelectObject (hdc, hShade );
    1955   MoveToEx (hdc, rect.right - 1, rect.top, NULL);
    1956   LineTo   (hdc, rect.right - 1, rect.bottom - 1);
    1957   LineTo   (hdc, rect.left,    rect.bottom - 1);
    1958 
    1959   SelectObject(hdc, htmPen);
     2095      rect.top += (infoPtr->tabHeight - 2) * infoPtr->uNumRows + 2;
     2096    }
     2097  }
     2098
     2099  TRACE("border=(%d,%d)-(%d,%d)\n",
     2100        rect.left, rect.top, rect.right, rect.bottom);
     2101
     2102  DrawEdge(hdc, &rect, EDGE_RAISED, BF_SOFT|BF_RECT);
    19602103}
    19612104
     
    19642107 *
    19652108 * This method repaints the tab control..
    1966  */             
     2109 */
    19672110static void TAB_Refresh (HWND hwnd, HDC hdc)
    19682111{
     
    19782121  if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BUTTONS)
    19792122  {
    1980     for (i = 0; i < infoPtr->uNumItem; i++) 
     2123    for (i = 0; i < infoPtr->uNumItem; i++)
    19812124      TAB_DrawItem (hwnd, hdc, i);
    19822125  }
     
    19842127  {
    19852128    /* Draw all the non selected item first */
    1986     for (i = 0; i < infoPtr->uNumItem; i++) 
     2129    for (i = 0; i < infoPtr->uNumItem; i++)
    19872130    {
    19882131      if (i != infoPtr->iSelected)
     
    20182161{
    20192162    TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    2020  
     2163
    20212164  infoPtr->DoRedraw=(BOOL) wParam;
    20222165  return 0;
     
    20242167
    20252168static LRESULT TAB_EraseBackground(
    2026   HWND hwnd, 
     2169  HWND hwnd,
    20272170  HDC  givenDC)
    20282171{
     
    20302173  RECT clientRect;
    20312174
    2032   HBRUSH brush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
     2175  HBRUSH brush = CreateSolidBrush(comctl32_color.clrBtnFace);
    20332176
    20342177  hdc = givenDC ? givenDC : GetDC(hwnd);
     
    21842327                   infoPtr->tabHeight -
    21852328                   lastRow * (infoPtr->tabHeight - 2) -
    2186                    ((lStyle & TCS_BUTTONS) ? lastRow * BUTTON_SPACINGY : 0) - 2;
     2329                   ((lStyle & TCS_BUTTONS) ? lastRow * BUTTON_SPACINGY : 0) - 3;
    21872330  }
    21882331  else if((lStyle & TCS_BOTTOM) && (lStyle & TCS_VERTICAL))
     
    21962339    clientRect.right = clientRect.left + infoPtr->tabHeight +
    21972340                       lastRow * (infoPtr->tabHeight - 2) -
    2198                       ((lStyle & TCS_BUTTONS) ? lastRow * BUTTON_SPACINGY : 0) + 1;
     2341                      ((lStyle & TCS_BUTTONS) ? lastRow * BUTTON_SPACINGY : 0) + 2;
    21992342
    22002343  }
     
    22032346    clientRect.bottom = clientRect.top + infoPtr->tabHeight +
    22042347                      lastRow * (infoPtr->tabHeight - 2) +
    2205                       ((lStyle & TCS_BUTTONS) ? lastRow * BUTTON_SPACINGY : 0) + 1;
    2206   }
    2207 
     2348                      ((lStyle & TCS_BUTTONS) ? lastRow * BUTTON_SPACINGY : 0) + 2;
     2349  }
     2350
     2351  TRACE("invalidate (%d,%d)-(%d,%d)\n",
     2352        clientRect.left,clientRect.top,
     2353        clientRect.right,clientRect.bottom);
    22082354  InvalidateRect(hwnd, &clientRect, TRUE);
    22092355}
     
    22142360  HDC hdc;
    22152361  PAINTSTRUCT ps;
    2216    
     2362
    22172363  hdc = wParam== 0 ? BeginPaint (hwnd, &ps) : (HDC)wParam;
     2364
     2365  TRACE("erase %d, rect=(%d,%d)-(%d,%d)\n",
     2366        ps.fErase,
     2367        ps.rcPaint.left,ps.rcPaint.top,ps.rcPaint.right,ps.rcPaint.bottom);
     2368
     2369  if (ps.fErase)
     2370      TAB_EraseBackground (hwnd, hdc);
     2371
    22182372  TAB_Refresh (hwnd, hdc);
    2219    
     2373
    22202374  if(!wParam)
    22212375    EndPaint (hwnd, &ps);
     
    22262380static LRESULT
    22272381TAB_InsertItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    2228 {   
     2382{
    22292383  TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    22302384  TCITEMA *pti;
    22312385  INT iItem;
    22322386  RECT rect;
    2233  
     2387
    22342388  GetClientRect (hwnd, &rect);
    2235   TRACE("Rect: %x T %i, L %i, B %i, R %i\n", hwnd,
    2236         rect.top, rect.left, rect.bottom, rect.right); 
    2237  
     2389  TRACE("Rect: %p T %i, L %i, B %i, R %i\n", hwnd,
     2390        rect.top, rect.left, rect.bottom, rect.right);
     2391
    22382392  pti = (TCITEMA *)lParam;
    22392393  iItem = (INT)wParam;
    2240  
     2394
    22412395  if (iItem < 0) return -1;
    22422396  if (iItem > infoPtr->uNumItem)
    22432397    iItem = infoPtr->uNumItem;
    2244  
     2398
     2399  TAB_DumpItemExternalA(pti, iItem);
     2400
     2401
    22452402  if (infoPtr->uNumItem == 0) {
    22462403    infoPtr->items = COMCTL32_Alloc (sizeof (TAB_ITEM));
     
    22502407  else {
    22512408    TAB_ITEM *oldItems = infoPtr->items;
    2252    
     2409
    22532410    infoPtr->uNumItem++;
    22542411    infoPtr->items = COMCTL32_Alloc (sizeof (TAB_ITEM) * infoPtr->uNumItem);
    2255    
     2412
    22562413    /* pre insert copy */
    22572414    if (iItem > 0) {
     
    22592416              iItem * sizeof(TAB_ITEM));
    22602417    }
    2261    
     2418
    22622419    /* post insert copy */
    22632420    if (iItem < infoPtr->uNumItem - 1) {
    22642421      memcpy (&infoPtr->items[iItem+1], &oldItems[iItem],
    22652422              (infoPtr->uNumItem - iItem - 1) * sizeof(TAB_ITEM));
    2266      
     2423
    22672424    }
    22682425
     
    22722429    COMCTL32_Free (oldItems);
    22732430  }
    2274  
     2431
    22752432  infoPtr->items[iItem].mask = pti->mask;
    22762433  if (pti->mask & TCIF_TEXT)
     
    22792436  if (pti->mask & TCIF_IMAGE)
    22802437    infoPtr->items[iItem].iImage = pti->iImage;
    2281  
     2438
    22822439  if (pti->mask & TCIF_PARAM)
    22832440    infoPtr->items[iItem].lParam = pti->lParam;
    2284  
     2441
    22852442  TAB_SetItemBounds(hwnd);
    2286   TAB_InvalidateTabArea(hwnd, infoPtr);
    2287  
    2288   TRACE("[%04x]: added item %d %s\n",
     2443  if (infoPtr->uNumItem > 1)
     2444    TAB_InvalidateTabArea(hwnd, infoPtr);
     2445  else
     2446    InvalidateRect(hwnd, NULL, TRUE);
     2447
     2448  TRACE("[%p]: added item %d %s\n",
    22892449        hwnd, iItem, debugstr_w(infoPtr->items[iItem].pszText));
    22902450
     
    23022462
    23032463  GetClientRect (hwnd, &rect);
    2304   TRACE("Rect: %x T %i, L %i, B %i, R %i\n", hwnd,
     2464  TRACE("Rect: %p T %i, L %i, B %i, R %i\n", hwnd,
    23052465        rect.top, rect.left, rect.bottom, rect.right);
    23062466
     
    23112471  if (iItem > infoPtr->uNumItem)
    23122472    iItem = infoPtr->uNumItem;
     2473
     2474  TAB_DumpItemExternalW(pti, iItem);
    23132475
    23142476  if (infoPtr->uNumItem == 0) {
     
    23352497
    23362498  }
    2337  
     2499
    23382500    if (iItem <= infoPtr->iSelected)
    23392501      infoPtr->iSelected++;
     
    23482510  if (pti->mask & TCIF_IMAGE)
    23492511    infoPtr->items[iItem].iImage = pti->iImage;
    2350  
     2512
    23512513  if (pti->mask & TCIF_PARAM)
    23522514    infoPtr->items[iItem].lParam = pti->lParam;
    2353  
     2515
    23542516  TAB_SetItemBounds(hwnd);
    2355   TAB_InvalidateTabArea(hwnd, infoPtr);
    2356  
    2357   TRACE("[%04x]: added item %d %s\n",
     2517  if (infoPtr->uNumItem > 1)
     2518    TAB_InvalidateTabArea(hwnd, infoPtr);
     2519  else
     2520    InvalidateRect(hwnd, NULL, TRUE);
     2521
     2522  TRACE("[%p]: added item %d %s\n",
    23582523        hwnd, iItem, debugstr_w(infoPtr->items[iItem].pszText));
    23592524
     
    23622527
    23632528
    2364 static LRESULT 
     2529static LRESULT
    23652530TAB_SetItemSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
    23662531{
     
    23692534  LONG lResult = 0;
    23702535
     2536  TRACE("\n");
    23712537  if ((lStyle & TCS_FIXEDWIDTH) || (lStyle & TCS_OWNERDRAWFIXED))
    23722538  {
     
    23742540    infoPtr->tabWidth = (INT)LOWORD(lParam);
    23752541    infoPtr->tabHeight = (INT)HIWORD(lParam);
     2542    TRACE("was h=%d,w=%d, now h=%d,w=%d\n",
     2543          HIWORD(lResult), LOWORD(lResult),
     2544          infoPtr->tabHeight, infoPtr->tabWidth);
    23762545  }
    23772546  infoPtr->fSizeSet = TRUE;
     
    23802549}
    23812550
    2382 static LRESULT 
     2551static LRESULT
    23832552TAB_SetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    23842553{
    23852554  TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    2386   TCITEMA *tabItem; 
     2555  TCITEMA *tabItem;
    23872556  TAB_ITEM *wineItem;
    23882557  INT    iItem;
     
    23942563  if ((iItem<0) || (iItem>=infoPtr->uNumItem)) return FALSE;
    23952564
     2565  TAB_DumpItemExternalA(tabItem, iItem);
     2566
    23962567  wineItem = &infoPtr->items[iItem];
    23972568
     
    24022573    wineItem->lParam = tabItem->lParam;
    24032574
    2404   if (tabItem->mask & TCIF_RTLREADING) 
     2575  if (tabItem->mask & TCIF_RTLREADING)
    24052576    FIXME("TCIF_RTLREADING\n");
    24062577
    2407   if (tabItem->mask & TCIF_STATE) 
     2578  if (tabItem->mask & TCIF_STATE)
    24082579    wineItem->dwState = tabItem->dwState;
    24092580
     
    24332604  if ((iItem<0) || (iItem>=infoPtr->uNumItem)) return FALSE;
    24342605
     2606  TAB_DumpItemExternalW(tabItem, iItem);
     2607
    24352608  wineItem = &infoPtr->items[iItem];
    24362609
     
    24582631
    24592632
    2460 static LRESULT 
     2633static LRESULT
    24612634TAB_GetItemCount (HWND hwnd, WPARAM wParam, LPARAM lParam)
    24622635{
     
    24672640
    24682641
    2469 static LRESULT 
     2642static LRESULT
    24702643TAB_GetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    24712644{
     
    24832656  wineItem = &infoPtr->items[iItem];
    24842657
    2485   if (tabItem->mask & TCIF_IMAGE) 
     2658  if (tabItem->mask & TCIF_IMAGE)
    24862659    tabItem->iImage = wineItem->iImage;
    24872660
    2488   if (tabItem->mask & TCIF_PARAM) 
     2661  if (tabItem->mask & TCIF_PARAM)
    24892662    tabItem->lParam = wineItem->lParam;
    24902663
    2491   if (tabItem->mask & TCIF_RTLREADING) 
     2664  if (tabItem->mask & TCIF_RTLREADING)
    24922665    FIXME("TCIF_RTLREADING\n");
    24932666
    2494   if (tabItem->mask & TCIF_STATE) 
     2667  if (tabItem->mask & TCIF_STATE)
    24952668    tabItem->dwState = wineItem->dwState;
    24962669
    2497   if (tabItem->mask & TCIF_TEXT) 
     2670  if (tabItem->mask & TCIF_TEXT)
    24982671   Str_GetPtrWtoA (wineItem->pszText, tabItem->pszText, tabItem->cchTextMax);
    24992672
     2673  TAB_DumpItemExternalA(tabItem, iItem);
     2674
    25002675  return TRUE;
    25012676}
    25022677
    25032678
    2504 static LRESULT 
     2679static LRESULT
    25052680TAB_GetItemW (HWND hwnd, WPARAM wParam, LPARAM lParam)
    25062681{
     
    25332708   Str_GetPtrW (wineItem->pszText, tabItem->pszText, tabItem->cchTextMax);
    25342709
     2710  TAB_DumpItemExternalW(tabItem, iItem);
     2711
    25352712  return TRUE;
    25362713}
    25372714
    25382715
    2539 static LRESULT 
     2716static LRESULT
    25402717TAB_DeleteItem (HWND hwnd, WPARAM wParam, LPARAM lParam)
    25412718{
     
    25472724  {
    25482725    TAB_ITEM *oldItems = infoPtr->items;
    2549    
     2726
    25502727    infoPtr->uNumItem--;
    25512728    infoPtr->items = COMCTL32_Alloc(sizeof (TAB_ITEM) * infoPtr->uNumItem);
    2552    
    2553     if (iItem > 0) 
     2729
     2730    if (iItem > 0)
    25542731      memcpy(&infoPtr->items[0], &oldItems[0], iItem * sizeof(TAB_ITEM));
    2555    
    2556     if (iItem < infoPtr->uNumItem) 
     2732
     2733    if (iItem < infoPtr->uNumItem)
    25572734      memcpy(&infoPtr->items[iItem], &oldItems[iItem + 1],
    25582735              (infoPtr->uNumItem - iItem) * sizeof(TAB_ITEM));
    2559    
     2736
    25602737    COMCTL32_Free(oldItems);
    25612738
     
    25632740    if ((iItem == infoPtr->iSelected) && (iItem > 0))
    25642741      infoPtr->iSelected--;
    2565      
     2742
    25662743    if (iItem < infoPtr->iSelected)
    25672744      infoPtr->iSelected--;
     
    25802757}
    25812758
    2582 static LRESULT 
     2759static LRESULT
    25832760TAB_DeleteAllItems (HWND hwnd, WPARAM wParam, LPARAM lParam)
    25842761{
     
    25912768    KillTimer(hwnd, TAB_HOTTRACK_TIMER);
    25922769  infoPtr->iHotTracked = -1;
    2593  
     2770
    25942771  TAB_SetItemBounds(hwnd);
    25952772  TAB_InvalidateTabArea(hwnd,infoPtr);
     
    26122789{
    26132790  TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    2614  
     2791
    26152792  TRACE("%x %lx\n",wParam, lParam);
    2616  
     2793
    26172794  infoPtr->hFont = (HFONT)wParam;
    2618  
     2795
    26192796  TAB_SetItemBounds(hwnd);
    26202797
     
    26832860    cx=LOWORD (lParam);
    26842861    cy=HIWORD (lParam);
    2685     if (GetWindowLongA(hwnd, GWL_STYLE) & CCS_NORESIZE) 
     2862    if (GetWindowLongA(hwnd, GWL_STYLE) & CCS_NORESIZE)
    26862863        uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
    26872864
     
    27022879
    27032880
    2704 static LRESULT 
     2881static LRESULT
    27052882TAB_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
    27062883{
     
    27142891
    27152892  SetWindowLongA(hwnd, 0, (DWORD)infoPtr);
    2716    
     2893
    27172894  infoPtr->uNumItem        = 0;
    27182895  infoPtr->uNumRows        = 0;
     
    27222899  infoPtr->iSelected       = -1;
    27232900  infoPtr->iHotTracked     = -1;
    2724   infoPtr->uFocus          = -1; 
     2901  infoPtr->uFocus          = -1;
    27252902  infoPtr->hwndToolTip     = 0;
    27262903  infoPtr->DoRedraw        = TRUE;
     
    27302907  infoPtr->fSizeSet        = FALSE;
    27312908  infoPtr->bUnicode        = IsWindowUnicode (hwnd);
    2732  
    2733   TRACE("Created tab control, hwnd [%04x]\n", hwnd);
    2734 
    2735   /* The tab control always has the WS_CLIPSIBLINGS style. Even 
    2736      if you don't specify it in CreateWindow. This is necessary in 
     2909
     2910  TRACE("Created tab control, hwnd [%p]\n", hwnd);
     2911
     2912  /* The tab control always has the WS_CLIPSIBLINGS style. Even
     2913     if you don't specify it in CreateWindow. This is necessary in
    27372914     order for paint to work correctly. This follows windows behaviour. */
    27382915  dwStyle = GetWindowLongA(hwnd, GWL_STYLE);
     
    27462923                       CW_USEDEFAULT, CW_USEDEFAULT,
    27472924                       hwnd, 0, 0, 0);
    2748    
     2925
    27492926    /* Send NM_TOOLTIPSCREATED notification */
    27502927    if (infoPtr->hwndToolTip) {
    27512928      NMTOOLTIPSCREATED nmttc;
    2752      
     2929
    27532930      nmttc.hdr.hwndFrom = hwnd;
    27542931      nmttc.hdr.idFrom = GetWindowLongA(hwnd, GWL_ID);
    27552932      nmttc.hdr.code = NM_TOOLTIPSCREATED;
    27562933      nmttc.hwndToolTips = infoPtr->hwndToolTip;
    2757      
     2934
    27582935      SendMessageA (GetParent (hwnd), WM_NOTIFY,
    27592936                    (WPARAM)GetWindowLongA(hwnd, GWL_ID), (LPARAM)&nmttc);
    27602937    }
    2761   } 
    2762    
     2938  }
     2939
    27632940  /*
    27642941   * We need to get text information so we need a DC and we need to select
    27652942   * a font.
    27662943   */
    2767   hdc = GetDC(hwnd); 
     2944  hdc = GetDC(hwnd);
    27682945  hOldFont = SelectObject (hdc, GetStockObject (SYSTEM_FONT));
    27692946
     
    27722949
    27732950  /*
    2774    * Make sure there is enough space for the letters + growing the 
    2775    * selected item + extra space for the selected item.   
     2951   * Make sure there is enough space for the letters + growing the
     2952   * selected item + extra space for the selected item.
    27762953   */
    2777   infoPtr->tabHeight = fontMetrics.tmHeight + 2 * VERTICAL_ITEM_PADDING +
    2778                        SELECTED_TAB_OFFSET;
     2954  infoPtr->tabHeight = fontMetrics.tmHeight + SELECTED_TAB_OFFSET +
     2955                       ((dwStyle & TCS_BUTTONS) ? 2 : 1) *
     2956                        VERTICAL_ITEM_PADDING;
    27792957
    27802958  /* Initialize the width of a tab. */
    27812959  infoPtr->tabWidth = DEFAULT_TAB_WIDTH;
     2960
     2961  TRACE("tabH=%d, tabW=%d\n", infoPtr->tabHeight, infoPtr->tabWidth);
    27822962
    27832963  SelectObject (hdc, hOldFont);
     
    28032983    COMCTL32_Free (infoPtr->items);
    28042984  }
    2805  
    2806   if (infoPtr->hwndToolTip) 
     2985
     2986  if (infoPtr->hwndToolTip)
    28072987    DestroyWindow (infoPtr->hwndToolTip);
    2808  
     2988
    28092989  if (infoPtr->hwndUpDown)
    28102990    DestroyWindow(infoPtr->hwndUpDown);
     
    28223002{
    28233003
    2824     TRACE("hwnd=%x msg=%x wParam=%x lParam=%lx\n", hwnd, uMsg, wParam, lParam);
     3004    TRACE("hwnd=%p msg=%x wParam=%x lParam=%lx\n", hwnd, uMsg, wParam, lParam);
    28253005    if (!TAB_GetInfoPtr(hwnd) && (uMsg != WM_CREATE))
    28263006      return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     
    28303010    case TCM_GETIMAGELIST:
    28313011      return TAB_GetImageList (hwnd, wParam, lParam);
    2832      
     3012
    28333013    case TCM_SETIMAGELIST:
    28343014      return TAB_SetImageList (hwnd, wParam, lParam);
    2835      
     3015
    28363016    case TCM_GETITEMCOUNT:
    28373017      return TAB_GetItemCount (hwnd, wParam, lParam);
    2838      
     3018
    28393019    case TCM_GETITEMA:
    28403020      return TAB_GetItemA (hwnd, wParam, lParam);
    2841      
     3021
    28423022    case TCM_GETITEMW:
    28433023      return TAB_GetItemW (hwnd, wParam, lParam);
    2844      
     3024
    28453025    case TCM_SETITEMA:
    28463026      return TAB_SetItemA (hwnd, wParam, lParam);
    2847      
     3027
    28483028    case TCM_SETITEMW:
    28493029      return TAB_SetItemW (hwnd, wParam, lParam);
    2850      
     3030
    28513031    case TCM_DELETEITEM:
    28523032      return TAB_DeleteItem (hwnd, wParam, lParam);
    2853      
     3033
    28543034    case TCM_DELETEALLITEMS:
    28553035     return TAB_DeleteAllItems (hwnd, wParam, lParam);
    2856      
     3036
    28573037    case TCM_GETITEMRECT:
    28583038     return TAB_GetItemRect (hwnd, wParam, lParam);
    2859      
     3039
    28603040    case TCM_GETCURSEL:
    28613041      return TAB_GetCurSel (hwnd);
    2862      
     3042
    28633043    case TCM_HITTEST:
    28643044      return TAB_HitTest (hwnd, wParam, lParam);
    2865      
     3045
    28663046    case TCM_SETCURSEL:
    28673047      return TAB_SetCurSel (hwnd, wParam);
    2868      
     3048
    28693049    case TCM_INSERTITEMA:
    28703050      return TAB_InsertItemA (hwnd, wParam, lParam);
    2871      
     3051
    28723052    case TCM_INSERTITEMW:
    28733053      return TAB_InsertItemW (hwnd, wParam, lParam);
    2874      
     3054
    28753055    case TCM_SETITEMEXTRA:
    28763056      FIXME("Unimplemented msg TCM_SETITEMEXTRA\n");
    28773057      return 0;
    2878      
     3058
    28793059    case TCM_ADJUSTRECT:
    28803060      return TAB_AdjustRect (hwnd, (BOOL)wParam, (LPRECT)lParam);
    2881      
     3061
    28823062    case TCM_SETITEMSIZE:
    28833063      return TAB_SetItemSize (hwnd, wParam, lParam);
    2884      
     3064
    28853065    case TCM_REMOVEIMAGE:
    28863066      FIXME("Unimplemented msg TCM_REMOVEIMAGE\n");
    28873067      return 0;
    2888      
     3068
    28893069    case TCM_SETPADDING:
    28903070      FIXME("Unimplemented msg TCM_SETPADDING\n");
    28913071      return 0;
    2892      
     3072
    28933073    case TCM_GETROWCOUNT:
    28943074      return TAB_GetRowCount(hwnd);
     
    29033083      FIXME("Unimplemented msg TCM_HIGHLIGHTITEM\n");
    29043084      return 0;
    2905      
     3085
    29063086    case TCM_GETTOOLTIPS:
    29073087      return TAB_GetToolTips (hwnd, wParam, lParam);
    2908      
     3088
    29093089    case TCM_SETTOOLTIPS:
    29103090      return TAB_SetToolTips (hwnd, wParam, lParam);
    2911      
     3091
    29123092    case TCM_GETCURFOCUS:
    29133093      return TAB_GetCurFocus (hwnd);
    2914      
     3094
    29153095    case TCM_SETCURFOCUS:
    29163096      return TAB_SetCurFocus (hwnd, wParam);
    2917      
     3097
    29183098    case TCM_SETMINTABWIDTH:
    29193099      FIXME("Unimplemented msg TCM_SETMINTABWIDTH\n");
    29203100      return 0;
    2921      
     3101
    29223102    case TCM_DESELECTALL:
    29233103      FIXME("Unimplemented msg TCM_DESELECTALL\n");
    29243104      return 0;
    2925      
     3105
    29263106    case TCM_GETEXTENDEDSTYLE:
    29273107      FIXME("Unimplemented msg TCM_GETEXTENDEDSTYLE\n");
     
    29343114    case WM_GETFONT:
    29353115      return TAB_GetFont (hwnd, wParam, lParam);
    2936      
     3116
    29373117    case WM_SETFONT:
    29383118      return TAB_SetFont (hwnd, wParam, lParam);
    2939      
     3119
    29403120    case WM_CREATE:
    29413121      return TAB_Create (hwnd, wParam, lParam);
    2942      
     3122
    29433123    case WM_NCDESTROY:
    29443124      return TAB_Destroy (hwnd, wParam, lParam);
    2945      
     3125
    29463126    case WM_GETDLGCODE:
    29473127      return DLGC_WANTARROWS | DLGC_WANTCHARS;
    2948      
     3128
    29493129    case WM_LBUTTONDOWN:
    29503130      return TAB_LButtonDown (hwnd, wParam, lParam);
    2951      
     3131
    29523132    case WM_LBUTTONUP:
    29533133      return TAB_LButtonUp (hwnd, wParam, lParam);
    2954      
     3134
    29553135    case WM_NOTIFY:
    29563136      return SendMessageA(GetParent(hwnd), WM_NOTIFY, wParam, lParam);
    2957  
     3137
    29583138    case WM_RBUTTONDOWN:
    29593139      return TAB_RButtonDown (hwnd, wParam, lParam);
    2960      
     3140
    29613141    case WM_MOUSEMOVE:
    29623142      return TAB_MouseMove (hwnd, wParam, lParam);
    2963      
     3143
    29643144    case WM_ERASEBKGND:
    29653145      return TAB_EraseBackground (hwnd, (HDC)wParam);
     
    29703150    case WM_SIZE:
    29713151      return TAB_Size (hwnd, wParam, lParam);
    2972      
     3152
    29733153    case WM_SETREDRAW:
    29743154      return TAB_SetRedraw (hwnd, wParam);
     
    29813161      InvalidateRect(hwnd, NULL, TRUE);
    29823162      return 0;
    2983      
     3163
     3164    case WM_SYSCOLORCHANGE:
     3165      COMCTL32_RefreshSysColors();
     3166      return 0;
     3167
    29843168    case WM_KILLFOCUS:
    29853169    case WM_SETFOCUS:
     
    29923176
    29933177    default:
    2994       if (uMsg >= WM_USER)
     3178      if ((uMsg >= WM_USER) && (uMsg < WM_APP))
    29953179        WARN("unknown msg %04x wp=%08x lp=%08lx\n",
    29963180             uMsg, wParam, lParam);
     
    30153199  wndClass.hbrBackground = (HBRUSH)NULL;
    30163200  wndClass.lpszClassName = WC_TABCONTROLA;
    3017  
     3201
    30183202  RegisterClassA (&wndClass);
    30193203}
  • trunk/src/comctl32/toolbar.c

    r8382 r9370  
    8686    INT nRow;
    8787    RECT rect;
    88 } TBUTTON_INFO; 
     88} TBUTTON_INFO;
    8989
    9090typedef struct
     
    171171#define TOP_BORDER         2
    172172#define BOTTOM_BORDER      2
    173 #define DDARROW_WIDTH      11 
     173#define DDARROW_WIDTH      11
    174174
    175175#define TOOLBAR_GetInfoPtr(hwnd) ((TOOLBAR_INFO *)GetWindowLongA(hwnd,0))
     
    197197    else if ((btnPtr->iString >= 0) && (btnPtr->iString < infoPtr->nNumStrings))
    198198        lpText = infoPtr->strings[btnPtr->iString];
    199    
     199
    200200    return lpText;
    201201}
     
    213213                  btn_num, bP->idCommand,
    214214                  (bP->bHot) ? "TRUE":"FALSE", bP->nRow,
    215                   bP->rect.left, bP->rect.top, 
     215                  bP->rect.left, bP->rect.top,
    216216                  bP->rect.right, bP->rect.bottom);
    217217    }
     
    227227
    228228        dwStyle = GetWindowLongA (iP->hwndSelf, GWL_STYLE);
    229         TRACE("toolbar %08x at line %d, exStyle=%08lx, buttons=%d, bitmaps=%d, strings=%d, style=%08lx\n",
     229        TRACE("toolbar %p at line %d, exStyle=%08lx, buttons=%d, bitmaps=%d, strings=%d, style=%08lx\n",
    230230              iP->hwndSelf, line,
    231231              iP->dwExStyle, iP->nNumButtons, iP->nNumBitmaps,
    232232              iP->nNumStrings, dwStyle);
    233         TRACE("toolbar %08x at line %d, himlInt=%p, himlDef=%p, himlHot=%p, himlDis=%p, redrawable=%s\n",
     233        TRACE("toolbar %p at line %d, himlInt=%p, himlDef=%p, himlHot=%p, himlDis=%p, redrawable=%s\n",
    234234              iP->hwndSelf, line,
    235235              iP->himlInt, iP->himlDef, iP->himlHot, iP->himlDis,
     
    253253{
    254254    if (dwStyle & TBSTYLE_ALTDRAG)
    255         FIXME("[%04x] TBSTYLE_ALTDRAG not implemented\n", hwnd);
     255        FIXME("[%p] TBSTYLE_ALTDRAG not implemented\n", hwnd);
    256256    if (dwStyle & TBSTYLE_REGISTERDROP)
    257         FIXME("[%04x] TBSTYLE_REGISTERDROP not implemented\n", hwnd);
     257        FIXME("[%p] TBSTYLE_REGISTERDROP not implemented\n", hwnd);
    258258}
    259259
     
    264264        if(!IsWindow(infoPtr->hwndSelf))
    265265            return 0;   /* we have just been destroyed */
    266        
     266
    267267    nmhdr->idFrom = GetDlgCtrlID (infoPtr->hwndSelf);
    268268    nmhdr->hwndFrom = infoPtr->hwndSelf;
    269269    nmhdr->code = code;
    270270
    271     TRACE("to window %04x, code=%08x, %s\n", infoPtr->hwndNotify, code,
     271    TRACE("to window %p, code=%08x, %s\n", infoPtr->hwndNotify, code,
    272272          (infoPtr->bNtfUnicode) ? "via Unicode" : "via ANSI");
    273273
    274274    if (infoPtr->bNtfUnicode)
    275         return SendMessageW (infoPtr->hwndNotify, WM_NOTIFY, 
     275        return SendMessageW (infoPtr->hwndNotify, WM_NOTIFY,
    276276                             (WPARAM) nmhdr->idFrom, (LPARAM)nmhdr);
    277277    else
    278         return SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, 
     278        return SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
    279279                             (WPARAM) nmhdr->idFrom, (LPARAM)nmhdr);
    280280}
     
    287287* is issued to retrieve the index.
    288288*/
    289 static INT 
     289static INT
    290290TOOLBAR_GetBitmapIndex(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr)
    291291{
     
    306306        }
    307307        ret = nmgd.iImage;
    308         TRACE("TBN_GETDISPINFOA returned bitmap id %d, mask=%08lx, nNumBitmaps=%d\n", 
     308        TRACE("TBN_GETDISPINFOA returned bitmap id %d, mask=%08lx, nNumBitmaps=%d\n",
    309309              ret, nmgd.dwMask, infoPtr->nNumBitmaps);
    310310    }
     
    313313
    314314
    315 static BOOL 
     315static BOOL
    316316TOOLBAR_IsValidBitmapIndex(TOOLBAR_INFO *infoPtr, INT index)
    317317{
     
    329329* This function validates the bitmap index (including I_IMAGECALLBACK
    330330* functionality). It then draws the image via the ImageList_Draw
    331 * function. It returns TRUE if the image was drawn, FALSE otherwise. 
     331* function. It returns TRUE if the image was drawn, FALSE otherwise.
    332332*/
    333333static BOOL
     
    341341    if (!TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
    342342        if (btnPtr->iBitmap == I_IMAGENONE) return FALSE;
    343         ERR("index %d is not valid, max %d\n", 
     343        ERR("index %d is not valid, max %d\n",
    344344            btnPtr->iBitmap, infoPtr->nNumBitmaps);
    345345        return FALSE;
     
    376376    if (!TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
    377377        if (btnPtr->iBitmap == I_IMAGENONE) return FALSE;
    378         ERR("index %d is not valid, max %d\n", 
     378        ERR("index %d is not valid, max %d\n",
    379379            btnPtr->iBitmap, infoPtr->nNumBitmaps);
    380380        return FALSE;
     
    403403    myrect.bottom = lpRect->bottom - 2;
    404404
    405     newcolor = (infoPtr->clrBtnShadow == CLR_DEFAULT) ? 
     405    newcolor = (infoPtr->clrBtnShadow == CLR_DEFAULT) ?
    406406                comctl32_color.clrBtnShadow : infoPtr->clrBtnShadow;
    407407    oldcolor = SetBkColor (hdc, newcolor);
     
    411411    myrect.right = myrect.left + 1;
    412412
    413     newcolor = (infoPtr->clrBtnHighlight == CLR_DEFAULT) ? 
     413    newcolor = (infoPtr->clrBtnHighlight == CLR_DEFAULT) ?
    414414                comctl32_color.clrBtnHighlight : infoPtr->clrBtnHighlight;
    415415    SetBkColor (hdc, newcolor);
     
    447447          myrect.left, myrect.top, myrect.right, myrect.bottom);
    448448
    449     newcolor = (infoPtr->clrBtnShadow == CLR_DEFAULT) ? 
     449    newcolor = (infoPtr->clrBtnShadow == CLR_DEFAULT) ?
    450450                comctl32_color.clrBtnShadow : infoPtr->clrBtnShadow;
    451451    oldcolor = SetBkColor (hdc, newcolor);
     
    455455    myrect.bottom = myrect.top + 1;
    456456
    457     newcolor = (infoPtr->clrBtnHighlight == CLR_DEFAULT) ? 
     457    newcolor = (infoPtr->clrBtnHighlight == CLR_DEFAULT) ?
    458458                comctl32_color.clrBtnHighlight : infoPtr->clrBtnHighlight;
    459459    SetBkColor (hdc, newcolor);
     
    468468{
    469469    INT x, y;
    470     SelectObject ( hdc, GetSysColorPen (colorRef));
     470    HPEN hPen, hOldPen;
     471
     472    if (!(hPen = CreatePen( PS_SOLID, 1, GetSysColor( colorRef )))) return;
     473    hOldPen = SelectObject ( hdc, hPen );
    471474    x = left + 2;
    472475    y = top + 8;
     
    477480    MoveToEx (hdc, x, y, NULL);
    478481    LineTo (hdc, x+1, y++);
     482    SelectObject( hdc, hOldPen );
     483    DeleteObject( hPen );
    479484}
    480485
     
    627632        else
    628633            rc.right = max(rc.left, rc.right - DDARROW_WIDTH - 2);
    629         rcArrow.left = rc.right; 
     634        rcArrow.left = rc.right;
    630635    }
    631636
     
    641646        rcBitmap.top+=(infoPtr->nButtonHeight - infoPtr->nBitmapHeight) / 2;
    642647
    643     TRACE("iBitmap: %d, start=(%d,%d) w=%d, h=%d\n", 
     648    TRACE("iBitmap: %d, start=(%d,%d) w=%d, h=%d\n",
    644649          btnPtr->iBitmap, rcBitmap.left, rcBitmap.top,
    645650          infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
     
    652657        InflateRect (&rcText, -3, -3);
    653658
    654         if (infoPtr->himlDef && 
     659        if (infoPtr->himlDef &&
    655660            TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
    656661                /* The following test looked like this before
     
    660665                 *    ((btnPtr->fsStyle & TBSTYLE_AUTOSIZE) == 0) &&
    661666                 *       (btnPtr->iBitmap != I_IMAGENONE))
    662                  */ 
     667                 */
    663668                if (dwStyle & TBSTYLE_LIST) {
    664669                    /* LIST style w/ ICON offset is by matching native. */
     
    707712    tbcd.hpenLines = 0;
    708713
    709     /* Issue Item Prepaint notify */ 
     714    /* Issue Item Prepaint notify */
    710715    infoPtr->dwItemCustDraw = 0;
    711716    infoPtr->dwItemCDFlag = 0;
     
    721726        infoPtr->dwItemCustDraw = ntfret & 0xffff;
    722727        infoPtr->dwItemCDFlag = ntfret & 0xffff0000;
    723         if (infoPtr->dwItemCustDraw & CDRF_SKIPDEFAULT) 
     728        if (infoPtr->dwItemCustDraw & CDRF_SKIPDEFAULT)
    724729            return;
    725730        /* save the only part of the rect that the user can change */
     
    761766                      BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
    762767        }
    763        
     768
    764769        if (hasDropDownArrow)
    765770        {
     
    769774
    770775        if (!TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDis,
    771                                    hdc, rcBitmap.left, rcBitmap.top, 
     776                                   hdc, rcBitmap.left, rcBitmap.top,
    772777                                   ILD_NORMAL))
    773778            TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top);
     
    800805
    801806        TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef,
    802                                hdc, rcBitmap.left+offset, rcBitmap.top+offset, 
     807                               hdc, rcBitmap.left+offset, rcBitmap.top+offset,
    803808                               ILD_NORMAL);
    804809
     
    821826
    822827        TOOLBAR_DrawPattern (hdc, &rc);
    823        
     828
    824829        TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef,
    825                                hdc, rcBitmap.left+1, rcBitmap.top+1, 
     830                               hdc, rcBitmap.left+1, rcBitmap.top+1,
    826831                               ILD_NORMAL);
    827832
     
    830835    }
    831836
    832     /* indeterminate */ 
     837    /* indeterminate */
    833838    if (btnPtr->fsState & TBSTATE_INDETERMINATE) {
    834839        if (!(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES))
     
    884889        if (btnPtr->bHot) {
    885890            /* if hot, attempt to draw with himlHot, if fails, use himlDef */
    886             if (!TOOLBAR_DrawImageList (infoPtr, btnPtr, 
     891            if (!TOOLBAR_DrawImageList (infoPtr, btnPtr,
    887892                                        infoPtr->himlHot,
    888                                         hdc, rcBitmap.left, 
     893                                        hdc, rcBitmap.left,
    889894                                        rcBitmap.top, ILD_NORMAL))
    890895                TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef,
     
    914919                               hdc, rcBitmap.left, rcBitmap.top,
    915920                               ILD_NORMAL);}
    916    
     921
    917922
    918923    TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle, &rcText, lpText, &tbcd);
     
    9981003*/
    9991004static void
    1000 TOOLBAR_MeasureString(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, 
     1005TOOLBAR_MeasureString(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
    10011006                      HDC hdc, LPSIZE lpSize)
    10021007{
     
    10061011    lpSize->cy = 0;
    10071012
    1008     if (!(btnPtr->fsState & TBSTATE_HIDDEN) ) 
     1013    if (!(btnPtr->fsState & TBSTATE_HIDDEN) )
    10091014    {
    10101015        LPWSTR lpText = TOOLBAR_GetText(infoPtr, btnPtr);
     
    10761081*               TOOLBAR_WrapToolbar
    10771082*
    1078 * This function walks through the buttons and seperators in the 
    1079 * toolbar, and sets the TBSTATE_WRAP flag only on those items where 
    1080 * wrapping should occur based on the width of the toolbar window. 
    1081 * It does *not* calculate button placement itself.  That task 
    1082 * takes place in TOOLBAR_CalcToolbar. If the program wants to manage 
    1083 * the toolbar wrapping on its own, it can use the TBSTYLE_WRAPABLE 
     1083* This function walks through the buttons and seperators in the
     1084* toolbar, and sets the TBSTATE_WRAP flag only on those items where
     1085* wrapping should occur based on the width of the toolbar window.
     1086* It does *not* calculate button placement itself.  That task
     1087* takes place in TOOLBAR_CalcToolbar. If the program wants to manage
     1088* the toolbar wrapping on its own, it can use the TBSTYLE_WRAPABLE
    10841089* flag, and set the TBSTATE_WRAP flags manually on the appropriate items.
    10851090*
    1086 * Note: TBSTYLE_WRAPABLE or TBSTYLE_EX_UNDOC1 can be used also to allow 
    1087 * vertical toolbar lists. 
    1088 */ 
     1091* Note: TBSTYLE_WRAPABLE or TBSTYLE_EX_UNDOC1 can be used also to allow
     1092* vertical toolbar lists.
     1093*/
    10891094
    10901095static void
     
    10971102    BOOL bWrap, bButtonWrap;
    10981103
    1099     /*  When the toolbar window style is not TBSTYLE_WRAPABLE,  */ 
     1104    /*  When the toolbar window style is not TBSTYLE_WRAPABLE,  */
    11001105    /*  no layout is necessary. Applications may use this style */
    11011106    /*  to perform their own layout on the toolbar.             */
    1102     if( !(dwStyle & TBSTYLE_WRAPABLE) && 
     1107    if( !(dwStyle & TBSTYLE_WRAPABLE) &&
    11031108        !(infoPtr->dwExStyle & TBSTYLE_EX_UNDOC1) )  return;
    11041109
     
    11221127        bWrap = FALSE;
    11231128        btnPtr[i].fsState &= ~TBSTATE_WRAP;
    1124        
     1129
    11251130        if (btnPtr[i].fsState & TBSTATE_HIDDEN)
    11261131            continue;
     
    11341139        if ((btnPtr[i].fsStyle & TBSTYLE_SEP) &&
    11351140            !(btnPtr[i].fsStyle & TBSTYLE_DROPDOWN))
    1136             cx = (btnPtr[i].iBitmap > 0) ? 
     1141            cx = (btnPtr[i].iBitmap > 0) ?
    11371142                        btnPtr[i].iBitmap : SEPARATOR_WIDTH;
    11381143        else
    11391144            cx = infoPtr->nButtonWidth;
    11401145
    1141         /* Two or more adjacent separators form a separator group.   */ 
     1146        /* Two or more adjacent separators form a separator group.   */
    11421147        /* The first separator in a group should be wrapped to the   */
    11431148        /* next row if the previous wrapping is on a button.         */
    11441149        if( bButtonWrap &&
    1145                 (btnPtr[i].fsStyle & TBSTYLE_SEP) && 
     1150                (btnPtr[i].fsStyle & TBSTYLE_SEP) &&
    11461151                (i + 1 < infoPtr->nNumButtons ) &&
    1147                 (btnPtr[i + 1].fsStyle & TBSTYLE_SEP) ) 
     1152                (btnPtr[i + 1].fsStyle & TBSTYLE_SEP) )
    11481153        {
    11491154            TRACE("wrap point 1 btn %d style %02x\n", i, btnPtr[i].fsStyle);
     
    11581163        /* Test added to also wrap after a button that starts a row but     */
    11591164        /* is bigger than the area.  - GA  8/01                             */
    1160         if (( x + cx - (infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2 
     1165        if (( x + cx - (infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2
    11611166           > infoPtr->nWidth ) ||
    11621167            ((x == infoPtr->nIndent) && (cx > infoPtr->nWidth)))
     
    11641169            BOOL bFound = FALSE;
    11651170
    1166             /*  If the current button is a separator and not hidden,  */ 
     1171            /*  If the current button is a separator and not hidden,  */
    11671172            /*  go to the next until it reaches a non separator.      */
    11681173            /*  Wrap the last separator if it is before a button.     */
    11691174            while( ( ((btnPtr[i].fsStyle & TBSTYLE_SEP) &&
    1170                       !(btnPtr[i].fsStyle & TBSTYLE_DROPDOWN)) || 
     1175                      !(btnPtr[i].fsStyle & TBSTYLE_DROPDOWN)) ||
    11711176                     (btnPtr[i].fsState & TBSTATE_HIDDEN) ) &&
    11721177                        i < infoPtr->nNumButtons )
     
    11751180                bFound = TRUE;
    11761181            }
    1177    
     1182
    11781183            if( bFound && i < infoPtr->nNumButtons )
    11791184            {
    11801185                i--;
    1181                 TRACE("wrap point 2 btn %d style %02x, x=%d, cx=%d\n", 
     1186                TRACE("wrap point 2 btn %d style %02x, x=%d, cx=%d\n",
    11821187                      i, btnPtr[i].fsStyle, x, cx);
    11831188                btnPtr[i].fsState |= TBSTATE_WRAP;
     
    11891194                break;
    11901195
    1191             /*  If the current button is not a separator, find the last  */ 
     1196            /*  If the current button is not a separator, find the last  */
    11921197            /*  separator and wrap it.                                   */
    11931198            for ( j = i - 1; j >= 0  &&  !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
     
    11961201                        !(btnPtr[j].fsState & TBSTATE_HIDDEN))
    11971202                {
    1198                     bFound = TRUE; 
    1199                     i = j; 
    1200                     TRACE("wrap point 3 btn %d style %02x, x=%d, cx=%d\n", 
     1203                    bFound = TRUE;
     1204                    i = j;
     1205                    TRACE("wrap point 3 btn %d style %02x, x=%d, cx=%d\n",
    12011206                          i, btnPtr[i].fsStyle, x, cx);
    12021207                    x = infoPtr->nIndent;
    12031208                    btnPtr[j].fsState |= TBSTATE_WRAP;
    1204                     bButtonWrap = FALSE; 
     1209                    bButtonWrap = FALSE;
    12051210                    break;
    12061211                }
     
    12111216            if (!bFound)
    12121217            {
    1213                 for ( j = i - 1; 
     1218                for ( j = i - 1;
    12141219                        j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
    12151220                {
    1216                     if (btnPtr[j].fsState & TBSTATE_HIDDEN) 
     1221                    if (btnPtr[j].fsState & TBSTATE_HIDDEN)
    12171222                        continue;
    12181223
    1219                     bFound = TRUE; 
    1220                     i = j; 
    1221                     TRACE("wrap point 4 btn %d style %02x, x=%d, cx=%d\n", 
     1224                    bFound = TRUE;
     1225                    i = j;
     1226                    TRACE("wrap point 4 btn %d style %02x, x=%d, cx=%d\n",
    12221227                          i, btnPtr[i].fsStyle, x, cx);
    12231228                    x = infoPtr->nIndent;
     
    12291234
    12301235            /* If all above failed, wrap the current button. */
    1231             if (!bFound) 
     1236            if (!bFound)
    12321237            {
    12331238                TRACE("wrap point 5 btn %d style %02x, x=%d, cx=%d\n",
     
    12401245                else
    12411246                    bButtonWrap = TRUE;
    1242             }               
     1247            }
    12431248        }
    12441249        else {
    1245             TRACE("wrap point 6 btn %d style %02x, x=%d, cx=%d\n", 
     1250            TRACE("wrap point 6 btn %d style %02x, x=%d, cx=%d\n",
    12461251                  i, btnPtr[i].fsStyle, x, cx);
    12471252            x += cx;
     
    12541259*               TOOLBAR_CalcToolbar
    12551260*
    1256 * This function calculates button and separator placement. It first 
    1257 * calculates the button sizes, gets the toolbar window width and then 
    1258 * calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap 
     1261* This function calculates button and separator placement. It first
     1262* calculates the button sizes, gets the toolbar window width and then
     1263* calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap
    12591264* on. It assigns a new location to each item and sends this location to
    1260 * the tooltip window if appropriate. Finally, it updates the rcBound 
    1261 * rect and calculates the new required toolbar window height. 
    1262 */ 
     1265* the tooltip window if appropriate. Finally, it updates the rcBound
     1266* rect and calculates the new required toolbar window height.
     1267*/
    12631268
    12641269static void
     
    12971302        {
    12981303            if (usesBitmaps)
    1299                 infoPtr->nButtonHeight = sizeString.cy + 
     1304                infoPtr->nButtonHeight = sizeString.cy +
    13001305                    2 + /* this is the space to separate text from bitmap */
    13011306                  infoPtr->nBitmapHeight + 6;
    1302             else 
     1307            else
    13031308                infoPtr->nButtonHeight = sizeString.cy + 6;
    13041309        }
     
    13231328
    13241329   /*
    1325     * We will set the height below, and we set the width on entry 
    1326     * so we do not reset them here.. 
     1330    * We will set the height below, and we set the width on entry
     1331    * so we do not reset them here..
    13271332    */
    13281333#if 0
     
    13851390        else
    13861391        {
    1387             if (btnPtr->fsStyle & TBSTYLE_AUTOSIZE) 
     1392            if (btnPtr->fsStyle & TBSTYLE_AUTOSIZE)
    13881393            {
    13891394              SIZE sz;
     
    14021407              /* toolbars with native control (v4.71).  -  GA 8/01    */
    14031408              cx = sz.cx + 6 + 5 + 5;
    1404               if ((dwStyle & TBSTYLE_LIST) && 
     1409              if ((dwStyle & TBSTYLE_LIST) &&
    14051410                  (TOOLBAR_TestImageExist (infoPtr, btnPtr, infoPtr->himlDef)))
    14061411                  cx += infoPtr->nBitmapWidth;
     
    14101415
    14111416            if (hasDropDownArrows && (btnPtr->fsStyle & TBSTYLE_DROPDOWN))
    1412               cx += DDARROW_WIDTH; 
     1417              cx += DDARROW_WIDTH;
    14131418        }
    14141419        if (btnPtr->fsState & TBSTATE_WRAP )
     
    14251430
    14261431        /* Set the toolTip only for non-hidden, non-separator button */
    1427         if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & TBSTYLE_SEP )) 
     1432        if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & TBSTYLE_SEP ))
    14281433        {
    14291434            TTTOOLINFOA ti;
     
    14501455            if ( !(btnPtr->fsStyle & TBSTYLE_SEP) )
    14511456                y += cy;
    1452             else 
    1453             {   
     1457            else
     1458            {
    14541459                /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
    14551460                /* it is the actual width of the separator. This is used for */
     
    14571462                if ( !(btnPtr->fsStyle & TBSTYLE_DROPDOWN))
    14581463                    y += cy + ( (btnPtr->iBitmap > 0 ) ?
    1459                                 btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 /3; 
     1464                                btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 /3;
    14601465                else
    14611466                    y += cy;
    1462              
     1467
    14631468                /* nSepRows is used to calculate the extra height follwoing  */
    14641469                /* the last row.                                             */
     
    14911496    /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following   */
    14921497    /* the last row.                                                    */
    1493     infoPtr->nHeight = TOP_BORDER + (nRows + 1) * infoPtr->nButtonHeight + 
     1498    infoPtr->nHeight = TOP_BORDER + (nRows + 1) * infoPtr->nButtonHeight +
    14941499                        nSepRows * (SEPARATOR_WIDTH * 2 / 3) +
    1495                         nSepRows * (infoPtr->nBitmapHeight + 1) + 
    1496                         BOTTOM_BORDER; 
     1500                        nSepRows * (infoPtr->nBitmapHeight + 1) +
     1501                        BOTTOM_BORDER;
    14971502#endif
    14981503
     
    15091514    TBUTTON_INFO *btnPtr;
    15101515    INT i;
    1511    
     1516
    15121517    btnPtr = infoPtr->buttons;
    15131518    for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
     
    15891594    nRunIndex = nIndex + 1;
    15901595    while (nRunIndex < infoPtr->nNumButtons) {
    1591         btnPtr = &infoPtr->buttons[nRunIndex]; 
     1596        btnPtr = &infoPtr->buttons[nRunIndex];
    15921597        if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
    15931598            if (btnPtr->fsState & TBSTATE_CHECKED)
     
    16441649                int i = 0;
    16451650                int index;
    1646                
     1651
    16471652                infoPtr = custInfo->tbInfo;
    16481653
     
    16641669                    /* send TBN_QUERYDELETE notification */
    16651670                    nmtb.iItem = i;
    1666                     btnInfo->bRemovable = TOOLBAR_SendNotify ((NMHDR *) &nmtb, 
    1667                                                       infoPtr, 
     1671                    btnInfo->bRemovable = TOOLBAR_SendNotify ((NMHDR *) &nmtb,
     1672                                                      infoPtr,
    16681673                                                      TBN_QUERYDELETE);
    16691674
     
    16931698                        break;
    16941699
    1695                     TRACE("style: %x\n", nmtb.tbButton.fsStyle);               
     1700                    TRACE("style: %x\n", nmtb.tbButton.fsStyle);
    16961701
    16971702                    /* insert button into the apropriate list */
     
    17691774                        /* send TBN_QUERYINSERT notification */
    17701775                        nmtb.iItem = index;
    1771                         TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, 
     1776                        TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
    17721777                                        TBN_QUERYINSERT);
    17731778
     
    19871992                RECT rcButton;
    19881993                RECT rcText;
    1989                 HPEN hOldPen;
     1994                HPEN hPen, hOldPen;
    19901995                HBRUSH hOldBrush;
    19911996                COLORREF oldText = 0;
     
    20062011                else
    20072012                   oldText = SetTextColor (lpdis->hDC, (lpdis->itemState & ODS_FOCUS)?comctl32_color.clrHighlightText:comctl32_color.clrWindowText);
    2008                 hOldPen = SelectObject (lpdis->hDC, GetSysColorPen ((lpdis->itemState & ODS_SELECTED)?COLOR_HIGHLIGHT:COLOR_WINDOW));
     2013                hPen = CreatePen( PS_SOLID, 1,
     2014                     GetSysColor( (lpdis->itemState & ODS_SELECTED)?COLOR_HIGHLIGHT:COLOR_WINDOW));
     2015                hOldPen = SelectObject (lpdis->hDC, hPen );
    20092016                hOldBrush = SelectObject (lpdis->hDC, GetSysColorBrush ((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW));
    20102017
     
    20392046                SetBkColor (lpdis->hDC, oldBk);
    20402047                SetTextColor (lpdis->hDC, oldText);
    2041 
     2048                DeleteObject( hPen );
    20422049                return TRUE;
    20432050            }
     
    20762083    HBITMAP hbmLoad;
    20772084
    2078     TRACE("hwnd=%x wParam=%x lParam=%lx\n", hwnd, wParam, lParam);
     2085    TRACE("hwnd=%p wParam=%x lParam=%lx\n", hwnd, wParam, lParam);
    20792086    if (!lpAddBmp)
    20802087        return -1;
     
    20942101
    20952102        /* Windows resize all the buttons to the size of a newly added standard image */
    2096         if (lpAddBmp->nID & 1) 
     2103        if (lpAddBmp->nID & 1)
    20972104        {
    20982105            /* large icons */
    2099             /* FIXME: on windows the size of the images is 25x24 but the size of the bitmap 
    2100              * in rsrc is only 24x24. Fix the bitmap (how?) and then fix this 
     2106            /* FIXME: on windows the size of the images is 25x24 but the size of the bitmap
     2107             * in rsrc is only 24x24. Fix the bitmap (how?) and then fix this
    21012108             */
    21022109            SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
     
    21042111            SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
    21052112                          MAKELPARAM((WORD)31, (WORD)30));
    2106         }       
    2107         else 
     2113        }
     2114        else
    21082115        {
    21092116            /* small icons */
     
    21132120                          MAKELPARAM((WORD)22, (WORD)22));
    21142121        }
    2115        
     2122
    21162123        TOOLBAR_CalcToolbar (hwnd);
    21172124    }
     
    21212128        if (nButtons <= 0)
    21222129            return -1;
    2123        
     2130
    21242131        TRACE ("adding %d bitmaps!\n", nButtons);
    21252132    }
    2126    
     2133
    21272134    if (!(infoPtr->himlDef)) {
    21282135        /* create new default image list */
     
    21402147    if (lpAddBmp->hInst == (HINSTANCE)0)
    21412148    {
    2142         nIndex = 
     2149        nIndex =
    21432150            ImageList_AddMasked (infoPtr->himlDef, (HBITMAP)lpAddBmp->nID,
    21442151                                 CLR_DEFAULT);
     
    24702477        {
    24712478            PWSTR p = szString + 1;
    2472                
    2473             nIndex = infoPtr->nNumStrings;
    2474             while (*p != L'|') {
    2475 
    2476             if (infoPtr->nNumStrings == 0) {
    2477                 infoPtr->strings =
    2478                     COMCTL32_Alloc (sizeof(LPWSTR));
    2479             }
    2480             else {
    2481                 LPWSTR *oldStrings = infoPtr->strings;
    2482                 infoPtr->strings =
    2483                     COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
    2484                 memcpy (&infoPtr->strings[0], &oldStrings[0],
    2485                         sizeof(LPWSTR) * infoPtr->nNumStrings);
    2486                 COMCTL32_Free (oldStrings);
    2487             }
    2488 
    2489             len = COMCTL32_StrChrW (p, L'|') - p;
    2490             TRACE("len=%d %s\n", len, debugstr_w(p));
    2491             infoPtr->strings[infoPtr->nNumStrings] =
    2492                 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
    2493             lstrcpynW (infoPtr->strings[infoPtr->nNumStrings], p, len+1);
    2494             infoPtr->nNumStrings++;
    2495 
    2496                 p += (len+1);
    2497             }
     2479
     2480            nIndex = infoPtr->nNumStrings;
     2481            while (*p != L'|' && *p != L'\0') {
     2482                PWSTR np;
     2483
     2484                if (infoPtr->nNumStrings == 0) {
     2485                    infoPtr->strings = COMCTL32_Alloc (sizeof(LPWSTR));
     2486                }
     2487                else
     2488                {
     2489                    LPWSTR *oldStrings = infoPtr->strings;
     2490                    infoPtr->strings = COMCTL32_Alloc(sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
     2491                    memcpy(&infoPtr->strings[0], &oldStrings[0],
     2492                           sizeof(LPWSTR) * infoPtr->nNumStrings);
     2493                    COMCTL32_Free(oldStrings);
     2494                }
     2495
     2496                np=COMCTL32_StrChrW (p, L'|');
     2497                if (np!=NULL) {
     2498                    len = np - p;
     2499                    np++;
     2500                } else {
     2501                    len = strlenW(p);
     2502                    np = p + len;
     2503                }
     2504                TRACE("len=%d %s\n", len, debugstr_w(p));
     2505                infoPtr->strings[infoPtr->nNumStrings] =
     2506                    COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
     2507                lstrcpynW (infoPtr->strings[infoPtr->nNumStrings], p, len+1);
     2508                infoPtr->nNumStrings++;
     2509
     2510                p = np;
     2511            }
    24982512        }
    24992513        else
     
    26352649
    26362650    if (infoPtr == NULL) {
    2637         ERR("(0x%x, 0x%x, 0x%lx)\n", hwnd, wParam, lParam);
     2651        ERR("(%p, 0x%x, 0x%lx)\n", hwnd, wParam, lParam);
    26382652        ERR("infoPtr == NULL!\n");
    26392653        return 0;
     
    26922706    else {
    26932707        if (btnPtr->fsStyle & TBSTYLE_GROUP) {
    2694             nOldIndex = 
     2708            nOldIndex =
    26952709                TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, nIndex);
    26962710            if (nOldIndex == nIndex)
     
    27522766        return FALSE;
    27532767
    2754     ret = DialogBoxIndirectParamA (GetWindowLongA (hwnd, GWL_HINSTANCE),
     2768    ret = DialogBoxIndirectParamA ((HINSTANCE)GetWindowLongA(hwnd, GWL_HINSTANCE),
    27552769                                   (LPDLGTEMPLATEA)template,
    27562770                                   hwnd,
     
    27752789        return FALSE;
    27762790
    2777     if ((infoPtr->hwndToolTip) && 
     2791    if ((infoPtr->hwndToolTip) &&
    27782792        !(infoPtr->buttons[nIndex].fsStyle & TBSTYLE_SEP)) {
    27792793        TTTOOLINFOA ti;
     
    29702984        return -1;
    29712985
    2972     nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, 
     2986    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam,
    29732987                                     lpTbInfo->dwMask & 0x80000000);
    29742988    if (nIndex == -1)
     
    29762990
    29772991    btnPtr = &infoPtr->buttons[nIndex];
     2992
     2993    if(!btnPtr)
     2994        return -1;
    29782995
    29792996    if (lpTbInfo->dwMask & TBIF_COMMAND)
     
    31283145    if (btnPtr->fsState & TBSTATE_HIDDEN)
    31293146        return FALSE;
    3130    
     3147
    31313148    lpRect->left   = btnPtr->rect.left;
    31323149    lpRect->right  = btnPtr->rect.right;
     
    31893206    if (lpRect == NULL)
    31903207        return FALSE;
    3191    
     3208
    31923209    lpRect->left   = btnPtr->rect.left;
    31933210    lpRect->right  = btnPtr->rect.right;
     
    32583275    if (infoPtr == NULL)
    32593276        return 0;
    3260     return infoPtr->hwndToolTip;
     3277    return (LRESULT)infoPtr->hwndToolTip;
    32613278}
    32623279
     
    32673284    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    32683285
    3269     TRACE("%s hwnd=0x%x stub!\n",
     3286    TRACE("%s hwnd=%p stub!\n",
    32703287           infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
    32713288
     
    34653482       return FALSE;
    34663483
    3467     /* If the string passed is not an index, assume address of string 
     3484    /* If the string passed is not an index, assume address of string
    34683485       and do our own AddString */
    34693486    if ((HIWORD(lpTbb->iString) != 0) && (lpTbb->iString != -1)) {
     
    36633680    int i = 0, nOldButtons = 0, pos = 0;
    36643681
    3665     TRACE("hInstOld %x nIDOld %x hInstNew %x nIDNew %x nButtons %x\n",
     3682    TRACE("hInstOld %p nIDOld %x hInstNew %p nIDNew %x nButtons %x\n",
    36663683          lpReplace->hInstOld, lpReplace->nIDOld, lpReplace->hInstNew, lpReplace->nIDNew,
    36673684          lpReplace->nButtons);
    36683685
    3669     if (lpReplace->hInstOld == -1)
     3686    if (lpReplace->hInstOld == HINST_COMMCTRL)
    36703687    {
    36713688        FIXME("changing standard bitmaps not implemented\n");
     
    36823699    }
    36833700
    3684     TRACE("To be replaced hInstOld %x nIDOld %x\n", lpReplace->hInstOld, lpReplace->nIDOld);
     3701    TRACE("To be replaced hInstOld %p nIDOld %x\n", lpReplace->hInstOld, lpReplace->nIDOld);
    36853702    for (i = 0; i < infoPtr->nNumBitmapInfos; i++) {
    36863703        TBITMAP_INFO *tbi = &infoPtr->bitmaps[i];
    3687         TRACE("tbimapinfo %d hInstOld %x nIDOld %x\n", i, tbi->hInst, tbi->nID);
     3704        TRACE("tbimapinfo %d hInstOld %p nIDOld %x\n", i, tbi->hInst, tbi->nID);
    36883705        if (tbi->hInst == lpReplace->hInstOld && tbi->nID == lpReplace->nIDOld)
    36893706        {
    3690             TRACE("Found: nButtons %d hInst %x nID %x\n", tbi->nButtons, tbi->hInst, tbi->nID);
     3707            TRACE("Found: nButtons %d hInst %p nID %x\n", tbi->nButtons, tbi->hInst, tbi->nID);
    36913708            nOldButtons = tbi->nButtons;
    36923709            tbi->nButtons = lpReplace->nButtons;
    36933710            tbi->hInst = lpReplace->hInstNew;
    36943711            tbi->nID = lpReplace->nIDNew;
    3695             TRACE("tbimapinfo changed %d hInstOld %x nIDOld %x\n", i, tbi->hInst, tbi->nID);
     3712            TRACE("tbimapinfo changed %d hInstOld %p nIDOld %x\n", i, tbi->hInst, tbi->nID);
    36963713            break;
    36973714        }
     
    37013718    if (nOldButtons == 0)
    37023719    {
    3703         WARN("No hinst/bitmap found! hInst %x nID %x\n", lpReplace->hInstOld, lpReplace->nIDOld);
     3720        WARN("No hinst/bitmap found! hInst %p nID %x\n", lpReplace->hInstOld, lpReplace->nIDOld);
    37043721        return FALSE;
    37053722    }
     
    38333850    if (lptbbi->cbSize < sizeof(TBBUTTONINFOA))
    38343851        return FALSE;
    3835    
     3852
    38363853    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam,
    38373854                                     lptbbi->dwMask & 0x80000000);
     
    38573874            /* iString is index, zero it to make Str_SetPtr succeed */
    38583875            btnPtr->iString=0;
    3859      
     3876
    38603877         Str_SetPtrAtoW ((LPWSTR *)&btnPtr->iString, lptbbi->pszText);
    38613878    }
     
    39193936
    39203937    /* The documentation claims you can only change the button size before
    3921      * any button has been added. But this is wrong. 
    3922      * WINZIP32.EXE (ver 8) calls this on one of its buttons after adding 
     3938     * any button has been added. But this is wrong.
     3939     * WINZIP32.EXE (ver 8) calls this on one of its buttons after adding
    39233940     * it to the toolbar, and it checks that the return value is nonzero - mjm
    39243941     * Further testing shows that we must actually perform the change too.
     
    39273944     * The documentation also does not mention that if 0 is supplied for
    39283945     * either size, the system changes it to the default of 24 wide and
    3929      * 22 high. Demonstarted in ControlSpy Toolbar. GLA 3/02 
     3946     * 22 high. Demonstarted in ControlSpy Toolbar. GLA 3/02
    39303947     */
    39313948    infoPtr->nButtonWidth = (cx) ? cx : 24;
     
    39503967        TRACE("matches current width, min=%d, max=%d, no recalc\n",
    39513968              infoPtr->cxMin, infoPtr->cxMax);
    3952         return TRUE; 
     3969        return TRUE;
    39533970    }
    39543971
     
    39593976    /* if both values are 0 then we are done */
    39603977    if (lParam == 0) {
    3961         TRACE("setting both min and max to 0, norecalc\n"); 
     3978        TRACE("setting both min and max to 0, norecalc\n");
    39623979        return TRUE;
    39633980    }
     
    39663983       recalc the bounding rectangle (does DrawText w/ DT_CALCRECT
    39673984       which doesn't actually draw - GA). */
    3968     TRACE("number of buttons %d, cx=%d, cy=%d, recalcing\n", 
     3985    TRACE("number of buttons %d, cx=%d, cy=%d, recalcing\n",
    39693986        infoPtr->nNumButtons, infoPtr->cxMin, infoPtr->cxMax);
    39703987
     
    40154032    /* FIXME: redraw ? */
    40164033
    4017     return (LRESULT)himlTemp; 
     4034    return (LRESULT)himlTemp;
    40184035}
    40194036
     
    40544071              (infoPtr->dwExStyle & ~TBSTYLE_EX_ALL));
    40554072
    4056     return (LRESULT)dwTemp; 
     4073    return (LRESULT)dwTemp;
    40574074}
    40584075
     
    40744091    /* FIXME: redraw ? */
    40754092
    4076     return (LRESULT)himlTemp; 
     4093    return (LRESULT)himlTemp;
    40774094}
    40784095
     
    41334150    ImageList_GetIconSize(infoPtr->himlDef, &infoPtr->nBitmapWidth,
    41344151                          &infoPtr->nBitmapHeight);
    4135     TRACE("hwnd %08x, new himl=%08x, count=%d, bitmap w=%d, h=%d\n",
     4152    TRACE("hwnd %p, new himl=%08x, count=%d, bitmap w=%d, h=%d\n",
    41364153          hwnd, (INT)infoPtr->himlDef, infoPtr->nNumBitmaps,
    41374154          infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
     
    41404157    InvalidateRect(hwnd, NULL, TRUE);
    41414158
    4142     return (LRESULT)himlTemp; 
     4159    return (LRESULT)himlTemp;
    41434160}
    41444161
     
    42234240    infoPtr->hwndNotify = (HWND)wParam;
    42244241
    4225     return hwndOldNotify;
     4242    return (LRESULT)hwndOldNotify;
    42264243}
    42274244
     
    43424359    BOOL bTemp;
    43434360
    4344     TRACE("%s hwnd=0x%04x stub!\n",
     4361    TRACE("%s hwnd=%p stub!\n",
    43454362           ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd);
    43464363
     
    43574374    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    43584375
    4359     lParam->clrBtnHighlight = (infoPtr->clrBtnHighlight == CLR_DEFAULT) ? 
    4360                                comctl32_color.clrBtnHighlight : 
     4376    lParam->clrBtnHighlight = (infoPtr->clrBtnHighlight == CLR_DEFAULT) ?
     4377                               comctl32_color.clrBtnHighlight :
    43614378                               infoPtr->clrBtnHighlight;
    4362     lParam->clrBtnShadow = (infoPtr->clrBtnShadow == CLR_DEFAULT) ? 
     4379    lParam->clrBtnShadow = (infoPtr->clrBtnShadow == CLR_DEFAULT) ?
    43634380                           comctl32_color.clrBtnShadow : infoPtr->clrBtnShadow;
    43644381    return 1;
     
    44204437                infoPtr->buttons[nOldHotItem].idCommand : 0;
    44214438        if ( !(nmhotitem.dwFlags & HICF_LEAVING) )
    4422             nmhotitem.idNew = (infoPtr->nHotItem >= 0) ? 
     4439            nmhotitem.idNew = (infoPtr->nHotItem >= 0) ?
    44234440                infoPtr->buttons[infoPtr->nHotItem].idCommand : 0;
    44244441        no_hi = TOOLBAR_SendNotify((NMHDR*)&nmhotitem, infoPtr, TBN_HOTITEMCHANGE);
     
    46294646
    46304647        /* FIXME: in general the return flags *can* be or'ed together */
    4631         switch (infoPtr->dwBaseCustDraw) 
     4648        switch (infoPtr->dwBaseCustDraw)
    46324649            {
    46334650            case CDRF_DODEFAULT:
     
    46364653                return TRUE;
    46374654            default:
    4638                 FIXME("[%04x] response %ld not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",
     4655                FIXME("[%p] response %ld not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",
    46394656                      hwnd, ntfret);
    46404657            }
    46414658    }
    46424659
    4643     /* If the toolbar is "transparent" then pass the WM_ERASEBKGND up 
     4660    /* If the toolbar is "transparent" then pass the WM_ERASEBKGND up
    46444661     * to my parent for processing.
    46454662     */
     
    46604677        ret = DefWindowProcA (hwnd, WM_ERASEBKGND, wParam, lParam);
    46614678
    4662     if ((dwStyle & TBSTYLE_CUSTOMERASE) && 
    4663         (infoPtr->dwBaseCustDraw & CDRF_NOTIFYPOSTERASE)) { 
     4679    if ((dwStyle & TBSTYLE_CUSTOMERASE) &&
     4680        (infoPtr->dwBaseCustDraw & CDRF_NOTIFYPOSTERASE)) {
    46644681        ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW));
    46654682        tbcd.nmcd.dwDrawStage = CDDS_POSTERASE;
     
    46674684        ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
    46684685        infoPtr->dwBaseCustDraw = ntfret & 0xffff;
    4669         switch (infoPtr->dwBaseCustDraw) 
     4686        switch (infoPtr->dwBaseCustDraw)
    46704687            {
    46714688            case CDRF_DODEFAULT:
     
    46744691                return TRUE;
    46754692            default:
    4676                 FIXME("[%04x] response %ld not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",
     4693                FIXME("[%p] response %ld not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",
    46774694                      hwnd, ntfret);
    46784695            }
     
    46874704    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    46884705
    4689     return infoPtr->hFont;
     4706    return (LRESULT)infoPtr->hFont;
    46904707}
    46914708
     
    47434760        RECT arrowRect;
    47444761        btnPtr = &infoPtr->buttons[nHit];
    4745         if (!(btnPtr->fsState & TBSTATE_ENABLED))
    4746             return 0;
    4747 
    47484762        infoPtr->nOldHit = nHit;
    47494763
     
    47524766
    47534767        /* for EX_DRAWDDARROWS style,  click must be in the drop-down arrow rect */
    4754         if ((btnPtr->fsStyle & TBSTYLE_DROPDOWN) &&
     4768        if ((btnPtr->fsState & TBSTATE_ENABLED) && (btnPtr->fsStyle & TBSTYLE_DROPDOWN) &&
    47554769             ((TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) && PtInRect(&arrowRect, pt)) ||
    47564770              (!TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle))))
     
    47834797        btnPtr->bHot = FALSE;
    47844798
    4785         InvalidateRect(hwnd, &btnPtr->rect,
    4786                       TOOLBAR_HasText(infoPtr, btnPtr));
     4799        if (btnPtr->fsState & TBSTATE_ENABLED)
     4800            InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, btnPtr));
    47874801        UpdateWindow(hwnd);
    47884802        SetCapture (hwnd);
     
    48404854                    if (nOldIndex == nHit)
    48414855                        bSendMessage = FALSE;
    4842                     if ((nOldIndex != nHit) && 
     4856                    if ((nOldIndex != nHit) &&
    48434857                        (nOldIndex != -1))
    48444858                        infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
     
    48624876         * now we can ReleaseCapture, which triggers CAPTURECHANGED msg,
    48634877         * that resets bCaptured and btn TBSTATE_PRESSED flags,
    4864          * and obliterates nButtonDown and nOldHit (see TOOLBAR_CaptureChanged) 
     4878         * and obliterates nButtonDown and nOldHit (see TOOLBAR_CaptureChanged)
    48654879         */
    48664880        if ((infoPtr->bCaptured) && (infoPtr->nButtonDown >= 0))
    48674881            ReleaseCapture ();
     4882        infoPtr->nButtonDown = -1;
    48684883
    48694884        /* Issue NM_RELEASEDCAPTURE to parent to let him know it is released */
     
    48714886                        NM_RELEASEDCAPTURE);
    48724887
    4873         /* native issues TBN_ENDDRAG here, if _LBUTTONDOWN issued the 
     4888        /* native issues TBN_ENDDRAG here, if _LBUTTONDOWN issued the
    48744889         * TBN_BEGINDRAG
    48754890         */
     
    48864901                        TBN_ENDDRAG);
    48874902
    4888         SendMessageA (infoPtr->hwndNotify, WM_COMMAND,
    4889           MAKEWPARAM(infoPtr->buttons[nHit].idCommand, 0), (LPARAM)hwnd);
    4890 
    4891         /* !!! Undocumented - toolbar at 4.71 level and above sends
    4892          * either NMRCLICK or NM_CLICK with the NMMOUSE structure.
    4893          * Only NM_RCLICK is documented.
    4894          */
    4895         nmmouse.dwItemSpec = btnPtr->idCommand;
    4896         nmmouse.dwItemData = btnPtr->dwData;
    4897         TOOLBAR_SendNotify ((NMHDR *) &nmmouse, infoPtr,
    4898                         NM_CLICK);
     4903        if (btnPtr->fsState & TBSTATE_ENABLED)
     4904        {
     4905            SendMessageA (infoPtr->hwndNotify, WM_COMMAND,
     4906              MAKEWPARAM(infoPtr->buttons[nHit].idCommand, 0), (LPARAM)hwnd);
     4907
     4908            /* !!! Undocumented - toolbar at 4.71 level and above sends
     4909            * either NMRCLICK or NM_CLICK with the NMMOUSE structure.
     4910            * Only NM_RCLICK is documented.
     4911            */
     4912            nmmouse.dwItemSpec = btnPtr->idCommand;
     4913            nmmouse.dwItemData = btnPtr->dwData;
     4914            TOOLBAR_SendNotify ((NMHDR *) &nmmouse, infoPtr, NM_CLICK);
     4915        }
    48994916    return 0;
    49004917}
     
    49134930        btnPtr->fsState &= ~TBSTATE_PRESSED;
    49144931
    4915         infoPtr->nButtonDown = -1;
    49164932        infoPtr->nOldHit = -1;
    49174933
    4918         InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
    4919             btnPtr));
     4934        if (btnPtr->fsState & TBSTATE_ENABLED)
     4935            InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
     4936              btnPtr));
    49204937    }
    49214938    return 0;
     
    49865003    if(!(trackinfo.dwFlags & TME_LEAVE)) {
    49875004        trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */
    4988  
     5005
    49895006        /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
    49905007        /* and can properly deactivate the hot toolbar button */
     
    50055022        /* Remove the effect of an old hot button if the button was enabled and was
    50065023           drawn with the hot button effect */
    5007         if(infoPtr->nOldHit >= 0 && infoPtr->nOldHit == infoPtr->nHotItem && 
     5024        if(infoPtr->nOldHit >= 0 && infoPtr->nOldHit == infoPtr->nHotItem &&
    50085025                (infoPtr->buttons[infoPtr->nOldHit].fsState & TBSTATE_ENABLED))
    50095026        {
     
    50195036            infoPtr->nHotItem = nHit;
    50205037
    5021             /* only enabled buttons show hot effect */           
     5038            /* only enabled buttons show hot effect */
    50225039            if(infoPtr->buttons[nHit].fsState & TBSTATE_ENABLED)
    50235040            {
     
    51105127     *    hdc = GetDC(toolbar)
    51115128     *    GetSystemMetrics(0x48)
    5112      *    fnt2=CreateFontA(0xe, 0, 0, 0, 0x190, 0, 0, 0, 0, 2, 
     5129     *    fnt2=CreateFontA(0xe, 0, 0, 0, 0x190, 0, 0, 0, 0, 2,
    51135130     *                     0, 0, 0, 0, "MARLETT")
    51145131     *    oldfnt = SelectObject(hdc, fnt2)
     
    51995216        if (lppgc->dwFlag == PGF_CALCWIDTH) {
    52005217            lppgc->iWidth = infoPtr->rcBound.right - infoPtr->rcBound.left;
    5201             TRACE("processed PGN_CALCSIZE, returning horz size = %d\n", 
     5218            TRACE("processed PGN_CALCSIZE, returning horz size = %d\n",
    52025219                  lppgc->iWidth);
    52035220        }
    52045221        else {
    52055222            lppgc->iHeight = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
    5206             TRACE("processed PGN_CALCSIZE, returning vert size = %d\n", 
     5223            TRACE("processed PGN_CALCSIZE, returning vert size = %d\n",
    52075224                  lppgc->iHeight);
    52085225        }
     5226        return 0;
     5227    }
     5228
     5229    if (lpnmh->code == PGN_SCROLL) {
     5230        LPNMPGSCROLL lppgs = (LPNMPGSCROLL)lParam;
     5231
     5232        lppgs->iScroll = (lppgs->iDir & (PGF_SCROLLLEFT | PGF_SCROLLRIGHT)) ?
     5233                          infoPtr->nButtonWidth : infoPtr->nButtonHeight;
     5234        TRACE("processed PGN_SCROLL, returning scroll=%d, dir=%d\n",
     5235              lppgs->iScroll, lppgs->iDir);
    52095236        return 0;
    52105237    }
     
    52155242    if ((infoPtr->hwndToolTip) && (lpnmh->hwndFrom == infoPtr->hwndToolTip)) {
    52165243        if (infoPtr->bNtfUnicode)
    5217             return SendMessageW (infoPtr->hwndNotify, WM_NOTIFY, 
     5244            return SendMessageW (infoPtr->hwndNotify, WM_NOTIFY,
    52185245                                 wParam, lParam);
    52195246        else
    5220             return SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, 
     5247            return SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
    52215248                                 wParam, lParam);
    52225249
     
    52595286    if (lParam == NF_REQUERY) {
    52605287        i = SendMessageA(GetParent(infoPtr->hwndSelf),
    5261                          WM_NOTIFYFORMAT, infoPtr->hwndSelf, NF_QUERY);
     5288                         WM_NOTIFYFORMAT, (WPARAM)infoPtr->hwndSelf, NF_QUERY);
    52625289        if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
    52635290            ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
     
    52805307
    52815308    /* fill ps.rcPaint with a default rect */
    5282     memcpy(&(ps.rcPaint), &(infoPtr->rcBound), sizeof(infoPtr->rcBound)); 
     5309    memcpy(&(ps.rcPaint), &(infoPtr->rcBound), sizeof(infoPtr->rcBound));
    52835310
    52845311    hdc = wParam==0 ? BeginPaint(hwnd, &ps) : (HDC)wParam;
     
    53035330      *
    53045331      * Documentation:
    5305       *  According to testing V4.71 of COMCTL32 returns the 
     5332      *  According to testing V4.71 of COMCTL32 returns the
    53065333      *  *previous* status of the redraw flag (either 0 or 1)
    53075334      *  instead of the MSDN documented value of 0 if handled.
     
    53145341    BOOL oldredraw = infoPtr->bDoRedraw;
    53155342
    5316     TRACE("set to %s\n", 
     5343    TRACE("set to %s\n",
    53175344          (wParam) ? "TRUE" : "FALSE");
    53185345    infoPtr->bDoRedraw = (BOOL) wParam;
     
    53685395             * Calc Toolbar will not adjust it, only the height
    53695396             */
    5370             infoPtr->nWidth = parent_rect.right - parent_rect.left; 
     5397            infoPtr->nWidth = parent_rect.right - parent_rect.left;
    53715398            cy = infoPtr->nHeight;
    53725399            cx = infoPtr->nWidth;
     
    54245451        }
    54255452        infoPtr->bTransparent = (lpStyle->styleNew & TBSTYLE_TRANSPARENT);
    5426         infoPtr->bBtnTranspnt = (lpStyle->styleNew & 
     5453        infoPtr->bBtnTranspnt = (lpStyle->styleNew &
    54275454                                 (TBSTYLE_FLAT | TBSTYLE_LIST));
    54285455        TOOLBAR_CheckStyle (hwnd, lpStyle->styleNew);
     
    54505477ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    54515478{
    5452     TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n",
     5479    TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n",
    54535480          hwnd, uMsg, /* SPY_GetMsgName(uMsg), */ wParam, lParam);
    54545481
     
    57585785
    57595786        case WM_MOUSELEAVE:
    5760             return TOOLBAR_MouseLeave (hwnd, wParam, lParam);   
     5787            return TOOLBAR_MouseLeave (hwnd, wParam, lParam);
    57615788
    57625789        case WM_CAPTURECHANGED:
    5763             return TOOLBAR_CaptureChanged(hwnd);       
     5790            return TOOLBAR_CaptureChanged(hwnd);
    57645791
    57655792        case WM_NCACTIVATE:
     
    58165843
    58175844        default:
    5818             if (uMsg >= WM_USER)
     5845            if ((uMsg >= WM_USER) && (uMsg < WM_APP))
    58195846                ERR("unknown msg %04x wp=%08x lp=%08lx\n",
    58205847                     uMsg, wParam, lParam);
     
    58385865    wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
    58395866    wndClass.lpszClassName = TOOLBARCLASSNAMEA;
    5840  
     5867
    58415868    RegisterClassA (&wndClass);
    58425869}
  • trunk/src/comctl32/updown.c

    r8382 r9370  
    1 /*             
     1/*
    22 * Updown control
    33 *
     
    1818 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    1919 *
     20 * NOTE
     21 *
     22 * This code was audited for completeness against the documented features
     23 * of Comctl32.dll version 6.0 on Sep. 9, 2002, by Dimitrie O. Paun.
     24 *
     25 * Unless otherwise noted, we believe this code to be complete, as per
     26 * the specification mentioned above.
     27 * If you discover missing features, or bugs, please note them below.
     28 *
    2029 */
    2130
     
    3039#include "commctrl.h"
    3140#include "winnls.h"
    32 #include "ntddk.h"
     41#include "wine/unicode.h"
    3342#include "wine/debug.h"
    34 #ifdef __WIN32OS2__
    35 #include "comctl32.h"
    36 #endif
    3743
    3844WINE_DEFAULT_DEBUG_CHANNEL(updown);
     
    8793#define BUDDY_SUPERCLASS_WNDPROC "buddySupperClassWndProc"
    8894
    89 #define UNKNOWN_PARAM(msg, wParam, lParam) WARN(\
    90         "Unknown parameter(s) for message " #msg \
    91         "(%04x): wp=%04x lp=%08lx\n", msg, wParam, lParam);
    92 
    9395#define UPDOWN_GetInfoPtr(hwnd) ((UPDOWN_INFO *)GetWindowLongA (hwnd,0))
    9496#define COUNT_OF(a) (sizeof(a)/sizeof(a[0]))
     
    155157 */
    156158static BOOL UPDOWN_HasBuddyBorder(UPDOWN_INFO* infoPtr)
    157 { 
     159{
    158160    DWORD dwStyle = GetWindowLongW (infoPtr->Self, GWL_STYLE);
    159161
     
    185187        else
    186188            rect->right -= DEFAULT_BUDDYBORDER;
    187    
     189
    188190        InflateRect(rect, 0, -DEFAULT_BUDDYBORDER);
    189191    }
     
    194196        else rect->left += DEFAULT_BUDDYSPACER;
    195197    }
    196    
     198
    197199    /*
    198200     * We're calculating the midpoint to figure-out where the
     
    203205        int len = rect->right - rect->left + 1; /* compute the width */
    204206        if (arrow & FLAG_INCR)
    205             rect->left = rect->left + len/2; 
     207            rect->left = rect->left + len/2;
    206208        if (arrow & FLAG_DECR)
    207209            rect->right =  rect->left + len/2 - 1;
     
    271273        if (!GetWindowTextW(infoPtr->Buddy, txt, COUNT_OF(txt))) return FALSE;
    272274
    273         sep = UPDOWN_GetThousandSep(); 
     275        sep = UPDOWN_GetThousandSep();
    274276
    275277        /* now get rid of the separators */
     
    279281
    280282        /* try to convert the number and validate it */
    281         newVal = wcstol(txt, &src, infoPtr->Base);
     283        newVal = strtolW(txt, &src, infoPtr->Base);
    282284        if(*src || !UPDOWN_InBounds (infoPtr, newVal)) return FALSE;
    283285    }
    284  
     286
    285287    TRACE("new value(%d) from buddy (old=%d)\n", newVal, infoPtr->CurVal);
    286288    infoPtr->CurVal = newVal;
     
    310312        return SendMessageW(infoPtr->Buddy, LB_SETCURSEL, infoPtr->CurVal, 0) != LB_ERR;
    311313    }
    312    
     314
    313315    /* Regular window, so set caption to the number */
    314316    if (infoPtr->Base == 16) fmt[1] = 'X';
    315     len = swprintf(txt, fmt, infoPtr->CurVal);
     317    len = wsprintfW(txt, fmt, infoPtr->CurVal);
    316318
    317319
     
    321323        WCHAR sep = UPDOWN_GetThousandSep();
    322324        int start = len % 3;
    323        
     325
    324326        memcpy(tmp, txt, sizeof(txt));
    325327        if (start == 0) start = 3;
     
    332334        *dst = 0;
    333335    }
    334    
     336
    335337    return SetWindowTextW(infoPtr->Buddy, txt);
    336 } 
     338}
    337339
    338340/***********************************************************************
     
    350352    if (UPDOWN_HasBuddyBorder(infoPtr)) {
    351353        GetClientRect(infoPtr->Self, &rect);
    352         DrawEdge(hdc, &rect, EDGE_SUNKEN, 
    353                  BF_BOTTOM | BF_TOP | 
     354        DrawEdge(hdc, &rect, EDGE_SUNKEN,
     355                 BF_BOTTOM | BF_TOP |
    354356                 (dwStyle & UDS_ALIGNLEFT ? BF_LEFT : BF_RIGHT));
    355357    }
    356  
     358
    357359    /* Draw the incr button */
    358360    UPDOWN_GetArrowRect (infoPtr, &rect, FLAG_INCR);
    359361    pressed = (infoPtr->Flags & FLAG_PRESSED) && (infoPtr->Flags & FLAG_INCR);
    360362    hot = (infoPtr->Flags & FLAG_INCR) && (infoPtr->Flags & FLAG_MOUSEIN);
    361     DrawFrameControl(hdc, &rect, DFC_SCROLL, 
     363    DrawFrameControl(hdc, &rect, DFC_SCROLL,
    362364        (dwStyle & UDS_HORZ ? DFCS_SCROLLRIGHT : DFCS_SCROLLUP) |
    363365        ((dwStyle & UDS_HOTTRACK) && hot ? DFCS_HOT : 0) |
     
    369371    pressed = (infoPtr->Flags & FLAG_PRESSED) && (infoPtr->Flags & FLAG_DECR);
    370372    hot = (infoPtr->Flags & FLAG_DECR) && (infoPtr->Flags & FLAG_MOUSEIN);
    371     DrawFrameControl(hdc, &rect, DFC_SCROLL, 
     373    DrawFrameControl(hdc, &rect, DFC_SCROLL,
    372374        (dwStyle & UDS_HORZ ? DFCS_SCROLLLEFT : DFCS_SCROLLDOWN) |
    373375        ((dwStyle & UDS_HOTTRACK) && hot ? DFCS_HOT : 0) |
     
    402404{
    403405    int arrow;
    404    
     406
    405407    if (key == VK_UP) arrow = FLAG_INCR;
    406408    else if (key == VK_DOWN) arrow = FLAG_DECR;
    407409    else return 1;
    408    
     410
    409411    UPDOWN_GetBuddyInt (infoPtr);
    410412    infoPtr->Flags &= ~FLAG_ARROW;
     
    417419
    418420/***********************************************************************
    419  * UPDOWN_Buddy_SubclassProc used to handle messages sent to the buddy 
     421 * UPDOWN_Buddy_SubclassProc used to handle messages sent to the buddy
    420422 *                           control.
    421423 */
    422 static LRESULT CALLBACK 
     424static LRESULT CALLBACK
    423425UPDOWN_Buddy_SubclassProc(HWND  hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    424426{
    425427    WNDPROC superClassWndProc = (WNDPROC)GetPropA(hwnd, BUDDY_SUPERCLASS_WNDPROC);
    426     TRACE("hwnd=%04x, wndProc=%d, uMsg=%04x, wParam=%d, lParam=%d\n",
     428    TRACE("hwnd=%p, wndProc=%d, uMsg=%04x, wParam=%d, lParam=%d\n",
    427429          hwnd, (INT)superClassWndProc, uMsg, wParam, (UINT)lParam);
    428430
    429431    if (uMsg == WM_KEYDOWN) {
    430432        HWND upDownHwnd = GetPropA(hwnd, BUDDY_UPDOWN_HWND);
    431      
     433
    432434        UPDOWN_KeyPressed(UPDOWN_GetInfoPtr(upDownHwnd), (int)wParam);
    433435    }
     
    440442 * Tests if 'bud' is a valid window handle. If not, returns FALSE.
    441443 * Else, sets it as a new Buddy.
    442  * Then, it should subclass the buddy 
     444 * Then, it should subclass the buddy
    443445 * If window has the UDS_ARROWKEYS, it subcalsses the buddy window to
    444446 * process the UP/DOWN arrow keys.
     
    451453    RECT  budRect;  /* new coord for the buddy */
    452454    int   x, width;  /* new x position and width for the up-down */
    453     WNDPROC baseWndProc, currWndProc;
     455    WNDPROC baseWndProc;
    454456    CHAR buddyClass[40];
    455          
     457
    456458    /* Is it a valid bud? */
    457459    if(!IsWindow(bud)) return FALSE;
    458460
    459     TRACE("(hwnd=%04x, bud=%04x)\n", infoPtr->Self, bud);
    460    
     461    TRACE("(hwnd=%p, bud=%p)\n", infoPtr->Self, bud);
     462
    461463    /* there is already a body assigned */
    462464    if (infoPtr->Buddy)  RemovePropA(infoPtr->Buddy, BUDDY_UPDOWN_HWND);
    463465
    464466    /* Store buddy window handle */
    465     infoPtr->Buddy = bud;   
    466 
    467     /* keep upDown ctrl hwnd in a buddy property */           
    468     SetPropA( bud, BUDDY_UPDOWN_HWND, infoPtr->Self); 
     467    infoPtr->Buddy = bud;
     468
     469    /* keep upDown ctrl hwnd in a buddy property */
     470    SetPropA( bud, BUDDY_UPDOWN_HWND, infoPtr->Self);
    469471
    470472    /* Store buddy window class type */
     
    478480
    479481    if(dwStyle & UDS_ARROWKEYS){
    480         /* Note that I don't clear the BUDDY_SUPERCLASS_WNDPROC property 
    481            when we reset the upDown ctrl buddy to another buddy because it is not 
     482        /* Note that I don't clear the BUDDY_SUPERCLASS_WNDPROC property
     483           when we reset the upDown ctrl buddy to another buddy because it is not
    482484           good to break the window proc chain. */
    483         currWndProc = (WNDPROC) GetWindowLongW(bud, GWL_WNDPROC);
    484         if (currWndProc != UPDOWN_Buddy_SubclassProc) {
    485             baseWndProc = (WNDPROC)SetWindowLongW(bud, GWL_WNDPROC, (LPARAM)UPDOWN_Buddy_SubclassProc);
     485        if (!GetPropA(bud, BUDDY_SUPERCLASS_WNDPROC)) {
     486            baseWndProc = (WNDPROC)SetWindowLongW(bud, GWL_WNDPROC, (LPARAM)UPDOWN_Buddy_SubclassProc);
    486487            SetPropA(bud, BUDDY_SUPERCLASS_WNDPROC, (HANDLE)baseWndProc);
    487488        }
     
    505506    /* first adjust the buddy to accomodate the up/down */
    506507    SetWindowPos(infoPtr->Buddy, 0, budRect.left, budRect.top,
    507                  budRect.right  - budRect.left, budRect.bottom - budRect.top, 
     508                 budRect.right  - budRect.left, budRect.bottom - budRect.top,
    508509                 SWP_NOACTIVATE|SWP_NOZORDER);
    509510
     
    515516    /*
    516517     * If the updown has a buddy border, it has to overlap with the buddy
    517      * to look as if it is integrated with the buddy control. 
     518     * to look as if it is integrated with the buddy control.
    518519     * We nudge the control or change it size to overlap.
    519520     */
     
    525526    }
    526527
    527     SetWindowPos(infoPtr->Self, infoPtr->Buddy, x, 
    528                  budRect.top - DEFAULT_ADDTOP, width, 
     528    SetWindowPos(infoPtr->Self, infoPtr->Buddy, x,
     529                 budRect.top - DEFAULT_ADDTOP, width,
    529530                 budRect.bottom - budRect.top + DEFAULT_ADDTOP + DEFAULT_ADDBOT,
    530531                 SWP_NOACTIVATE);
    531532
    532533    return TRUE;
    533 }         
     534}
    534535
    535536/***********************************************************************
    536537 *           UPDOWN_DoAction
    537538 *
    538  * This function increments/decrements the CurVal by the 
     539 * This function increments/decrements the CurVal by the
    539540 * 'delta' amount according to the 'action' flag which can be a
    540541 * combination of FLAG_INCR and FLAG_DECR
     
    559560    ni.hdr.hwndFrom = infoPtr->Self;
    560561    ni.hdr.idFrom   = GetWindowLongW (infoPtr->Self, GWL_ID);
    561     ni.hdr.code = UDN_DELTAPOS; 
     562    ni.hdr.code = UDN_DELTAPOS;
    562563    if (!SendMessageW(GetParent (infoPtr->Self), WM_NOTIFY,
    563564                   (WPARAM)ni.hdr.idFrom, (LPARAM)&ni)) {
     
    570571        }
    571572    }
    572  
     573
    573574    /* Also, notify it. This message is sent in any case. */
    574     SendMessageW( GetParent(infoPtr->Self),
    575                   dwStyle & UDS_HORZ ? WM_HSCROLL : WM_VSCROLL,
    576                   MAKELONG(SB_THUMBPOSITION, infoPtr->CurVal), infoPtr->Self);
     575    SendMessageW( GetParent(infoPtr->Self),
     576                  dwStyle & UDS_HORZ ? WM_HSCROLL : WM_VSCROLL,
     577                  MAKELONG(SB_THUMBPOSITION, infoPtr->CurVal),
     578                  (LPARAM)infoPtr->Self);
    577579}
    578580
     
    597599 * Deletes any timers, releases the mouse and does  redraw if necessary.
    598600 * If the control is not in "capture" mode, it does nothing.
    599  * If the control was not in cancel mode, it returns FALSE. 
     601 * If the control was not in cancel mode, it returns FALSE.
    600602 * If the control was in cancel mode, it returns TRUE.
    601603 */
     
    603605{
    604606    if (!(infoPtr->Flags & FLAG_PRESSED)) return FALSE;
    605    
     607
    606608    KillTimer (infoPtr->Self, TIMER_AUTOREPEAT);
    607609    KillTimer (infoPtr->Self, TIMER_ACCEL);
    608610    KillTimer (infoPtr->Self, TIMER_AUTOPRESS);
    609  
     611
    610612    if (GetCapture() == infoPtr->Self) {
    611613        NMHDR hdr;
     
    616618        ReleaseCapture();
    617619    }
    618    
     620
    619621    infoPtr->Flags &= ~FLAG_PRESSED;
    620622    InvalidateRect (infoPtr->Self, NULL, FALSE);
    621  
     623
    622624    return TRUE;
    623625}
     
    628630 * Handle a mouse event for the updown.
    629631 * 'pt' is the location of the mouse event in client or
    630  * windows coordinates. 
    631  */
    632 static void UPDOWN_HandleMouseEvent (UPDOWN_INFO *infoPtr, UINT msg, POINT pt)
     632 * windows coordinates.
     633 */
     634static void UPDOWN_HandleMouseEvent (UPDOWN_INFO *infoPtr, UINT msg, POINTS pts)
    633635{
    634636    DWORD dwStyle = GetWindowLongW (infoPtr->Self, GWL_STYLE);
     637    POINT pt = { pts.x, pts.y };
    635638    RECT rect;
    636639    int temp, arrow;
     
    650653                /* Update the CurVal if necessary */
    651654                if (dwStyle & UDS_SETBUDDYINT) UPDOWN_GetBuddyInt (infoPtr);
    652        
     655
    653656                /* Set up the correct flags */
    654                 infoPtr->Flags |= FLAG_PRESSED; 
    655      
     657                infoPtr->Flags |= FLAG_PRESSED;
     658
    656659                /* repaint the control */
    657660                InvalidateRect (infoPtr->Self, NULL, FALSE);
     
    682685                if(infoPtr->AccelIndex != -1) infoPtr->AccelIndex = 0;
    683686            }
    684            
     687
    685688            /* If state changed, redraw the control */
    686689            if(temp != infoPtr->Flags)
     
    703706    DWORD dwStyle = GetWindowLongW (hwnd, GWL_STYLE);
    704707    int temp;
    705    
     708
    706709    if (!infoPtr && (message != WM_CREATE))
    707         return DefWindowProcW (hwnd, message, wParam, lParam); 
     710        return DefWindowProcW (hwnd, message, wParam, lParam);
    708711
    709712    switch(message)
     
    719722            infoPtr->AccelVect = 0;
    720723            infoPtr->AccelIndex = -1;
    721             infoPtr->CurVal = 0; 
    722             infoPtr->MinVal = 0; 
     724            infoPtr->CurVal = 0;
     725            infoPtr->MinVal = 0;
    723726            infoPtr->MaxVal = 9999;
    724727            infoPtr->Base  = 10; /* Default to base 10  */
     
    729732            if (dwStyle & UDS_AUTOBUDDY)
    730733                UPDOWN_SetBuddy (infoPtr, GetWindow (hwnd, GW_HWNDPREV));
    731        
    732             TRACE("UpDown Ctrl creation, hwnd=%04x\n", hwnd);
    733             break;
    734    
     734
     735            TRACE("UpDown Ctrl creation, hwnd=%p\n", hwnd);
     736            break;
     737
    735738        case WM_DESTROY:
    736739            if(infoPtr->AccelVect) COMCTL32_Free (infoPtr->AccelVect);
     
    740743            COMCTL32_Free (infoPtr);
    741744            SetWindowLongW (hwnd, 0, 0);
    742             TRACE("UpDown Ctrl destruction, hwnd=%04x\n", hwnd);
    743             break;
    744        
     745            TRACE("UpDown Ctrl destruction, hwnd=%p\n", hwnd);
     746            break;
     747
    745748        case WM_ENABLE:
    746749            if (dwStyle & WS_DISABLED) UPDOWN_CancelMode (infoPtr);
     
    774777                temp = infoPtr->AccelIndex == -1 ? 1 : infoPtr->AccelVect[infoPtr->AccelIndex].nInc;
    775778                UPDOWN_DoAction(infoPtr, temp, infoPtr->Flags & FLAG_ARROW);
    776        
     779
    777780                if(infoPtr->AccelIndex != -1 && infoPtr->AccelIndex < infoPtr->AccelCount-1) {
    778781                    KillTimer(hwnd, TIMER_ACCEL);
     
    780783                    temp = infoPtr->AccelVect[infoPtr->AccelIndex].nSec * 1000 + 1;
    781784                    /* make sure we have at least 1ms intervals */
    782                     SetTimer(hwnd, TIMER_ACCEL, temp, 0);           
     785                    SetTimer(hwnd, TIMER_ACCEL, temp, 0);
    783786                }
    784787            }
     
    790793        case WM_LBUTTONUP:
    791794            if (GetCapture() != infoPtr->Self) break;
    792            
     795
    793796            if ( (infoPtr->Flags & FLAG_MOUSEIN) &&
    794797                 (infoPtr->Flags & FLAG_ARROW) ) {
    795                    
    796                 SendMessageW( GetParent(hwnd), 
     798
     799                SendMessageW( GetParent(hwnd),
    797800                              dwStyle & UDS_HORZ ? WM_HSCROLL : WM_VSCROLL,
    798                               MAKELONG(SB_ENDSCROLL, infoPtr->CurVal), hwnd);
     801                              MAKELONG(SB_ENDSCROLL, infoPtr->CurVal),
     802                              (LPARAM)hwnd);
    799803                if (UPDOWN_IsBuddyEdit(infoPtr))
    800804                    SendMessageW(infoPtr->Buddy, EM_SETSEL, 0, MAKELONG(0, -1));
     
    802806            UPDOWN_CancelMode(infoPtr);
    803807            break;
    804      
     808
    805809        case WM_LBUTTONDOWN:
    806810        case WM_MOUSEMOVE:
    807             if(UPDOWN_IsEnabled(infoPtr)){
    808                 POINT pt;
    809                 pt.x = SLOWORD(lParam);
    810                 pt.y = SHIWORD(lParam);
    811                 UPDOWN_HandleMouseEvent (infoPtr, message, pt );
    812             }
     811            if(UPDOWN_IsEnabled(infoPtr))
     812                UPDOWN_HandleMouseEvent (infoPtr, message, MAKEPOINTS(lParam));
    813813            break;
    814814
    815815        case WM_KEYDOWN:
    816             if((dwStyle & UDS_ARROWKEYS) && UPDOWN_IsEnabled(infoPtr)) {
     816            if((dwStyle & UDS_ARROWKEYS) && UPDOWN_IsEnabled(infoPtr))
    817817                return UPDOWN_KeyPressed(infoPtr, (int)wParam);
    818             }
    819             break;
    820      
     818            break;
     819
    821820        case WM_PAINT:
    822821            return UPDOWN_Paint (infoPtr, (HDC)wParam);
    823    
     822
    824823        case UDM_GETACCEL:
    825824            if (wParam==0 && lParam==0) return infoPtr->AccelCount;
     
    829828                return temp;
    830829            }
    831             UNKNOWN_PARAM(UDM_GETACCEL, wParam, lParam);
    832830            return 0;
    833831
    834832        case UDM_SETACCEL:
    835             TRACE("UpDown Ctrl new accel info, hwnd=%04x\n", hwnd);
     833            TRACE("UpDown Ctrl new accel info, hwnd=%p\n", hwnd);
    836834            if(infoPtr->AccelVect) {
    837835                COMCTL32_Free (infoPtr->AccelVect);
     
    846844
    847845        case UDM_GETBASE:
    848             if (wParam || lParam) UNKNOWN_PARAM(UDM_GETBASE, wParam, lParam);
    849846            return infoPtr->Base;
    850847
    851848        case UDM_SETBASE:
    852             TRACE("UpDown Ctrl new base(%d), hwnd=%04x\n", wParam, hwnd);
    853             if ( !(wParam==10 || wParam==16) || lParam)
    854                 UNKNOWN_PARAM(UDM_SETBASE, wParam, lParam);
     849            TRACE("UpDown Ctrl new base(%d), hwnd=%p\n", wParam, hwnd);
    855850            if (wParam==10 || wParam==16) {
    856851                temp = infoPtr->Base;
     
    861856
    862857        case UDM_GETBUDDY:
    863             if (wParam || lParam) UNKNOWN_PARAM(UDM_GETBUDDY, wParam, lParam);
    864             return infoPtr->Buddy;
     858            return (LRESULT)infoPtr->Buddy;
    865859
    866860        case UDM_SETBUDDY:
    867             if (lParam) UNKNOWN_PARAM(UDM_SETBUDDY, wParam, lParam);
    868             temp = infoPtr->Buddy;
    869             UPDOWN_SetBuddy (infoPtr, wParam);
     861            temp = (int)infoPtr->Buddy;
     862            UPDOWN_SetBuddy (infoPtr, (HWND)wParam);
    870863            return temp;
    871864
    872865        case UDM_GETPOS:
    873             if (wParam || lParam) UNKNOWN_PARAM(UDM_GETPOS, wParam, lParam);
    874866            temp = UPDOWN_GetBuddyInt (infoPtr);
    875867            return MAKELONG(infoPtr->CurVal, temp ? 0 : 1);
    876868
    877869        case UDM_SETPOS:
    878             if (wParam || HIWORD(lParam)) UNKNOWN_PARAM(UDM_GETPOS, wParam, lParam);
    879870            temp = SLOWORD(lParam);
    880             TRACE("UpDown Ctrl new value(%d), hwnd=%04x\n", temp, hwnd);
     871            TRACE("UpDown Ctrl new value(%d), hwnd=%p\n", temp, hwnd);
    881872            if(!UPDOWN_InBounds(infoPtr, temp)) {
    882873                if(temp < infoPtr->MinVal) temp = infoPtr->MinVal;
     
    887878            if(dwStyle & UDS_SETBUDDYINT) UPDOWN_SetBuddyInt (infoPtr);
    888879            return wParam;            /* return prev value */
    889      
     880
    890881        case UDM_GETRANGE:
    891             if (wParam || lParam) UNKNOWN_PARAM(UDM_GETRANGE, wParam, lParam);
    892882            return MAKELONG(infoPtr->MaxVal, infoPtr->MinVal);
    893883
    894884        case UDM_SETRANGE:
    895             if (wParam) UNKNOWN_PARAM(UDM_SETRANGE, wParam, lParam);
    896885                                               /* we must have:     */
    897886            infoPtr->MaxVal = SLOWORD(lParam); /* UD_MINVAL <= Max <= UD_MAXVAL */
    898887            infoPtr->MinVal = SHIWORD(lParam); /* UD_MINVAL <= Min <= UD_MAXVAL */
    899888                                               /* |Max-Min| <= UD_MAXVAL        */
    900             TRACE("UpDown Ctrl new range(%d to %d), hwnd=%04x\n",
     889            TRACE("UpDown Ctrl new range(%d to %d), hwnd=%p\n",
    901890                  infoPtr->MinVal, infoPtr->MaxVal, hwnd);
    902             break;                             
     891            break;
    903892
    904893        case UDM_GETRANGE32:
     
    912901            if (infoPtr->MaxVal <= infoPtr->MinVal)
    913902                infoPtr->MaxVal = infoPtr->MinVal + 1;
    914             TRACE("UpDown Ctrl new range(%d to %d), hwnd=%04x\n",
     903            TRACE("UpDown Ctrl new range(%d to %d), hwnd=%p\n",
    915904                  infoPtr->MinVal, infoPtr->MaxVal, hwnd);
    916905            break;
     
    931920
    932921        case UDM_GETUNICODEFORMAT:
    933             if (wParam || lParam) UNKNOWN_PARAM(UDM_GETUNICODEFORMAT, wParam, lParam);
    934922            /* we lie a bit here, we're always using Unicode internally */
    935923            return infoPtr->UnicodeFormat;
    936924
    937925        case UDM_SETUNICODEFORMAT:
    938             if (lParam) UNKNOWN_PARAM(UDM_SETUNICODEFORMAT, wParam, lParam);
    939926            /* do we really need to honour this flag? */
    940927            temp = infoPtr->UnicodeFormat;
    941928            infoPtr->UnicodeFormat = (BOOL)wParam;
    942929            return temp;
    943            
    944         default: 
    945             if (message >= WM_USER)
     930
     931        default:
     932            if ((message >= WM_USER) && (message < WM_APP))
    946933                ERR("unknown msg %04x wp=%04x lp=%08lx\n", message, wParam, lParam);
    947             return DefWindowProcW (hwnd, message, wParam, lParam); 
    948     } 
     934            return DefWindowProcW (hwnd, message, wParam, lParam);
     935    }
    949936
    950937    return 0;
     
    956943 * Registers the updown window class.
    957944 */
    958 
    959 VOID
    960 UPDOWN_Register(void)
     945void UPDOWN_Register(void)
    961946{
    962947    WNDCLASSW wndClass;
     
    970955    wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
    971956    wndClass.lpszClassName = UPDOWN_CLASSW;
    972  
     957
    973958    RegisterClassW( &wndClass );
    974959}
     
    980965 * Unregisters the updown window class.
    981966 */
    982 
    983 VOID
    984 UPDOWN_Unregister (void)
     967void UPDOWN_Unregister (void)
    985968{
    986969    UnregisterClassW (UPDOWN_CLASSW, (HINSTANCE)NULL);
    987970}
    988 
Note: See TracChangeset for help on using the changeset viewer.