Changeset 7815 for trunk/src


Ignore:
Timestamp:
Feb 6, 2002, 6:23:21 PM (24 years ago)
Author:
sandervl
Message:

Wine updates

Location:
trunk/src/comctl32
Files:
3 added
2 deleted
11 edited

Legend:

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

    r7726 r7815  
    5252 *  mod 4
    5353 *   1. Implemented CBN_SELCHANGE, CBN_KILLFOCUS, and CBN_SELENDOK.
    54  *   2. Fix putting text in CBEN_ENDEDIT notifys for CBN_DROPDOWN case.
     54 *   2. Fix putting text in CBEN_ENDEDIT notifies for CBN_DROPDOWN case.
    5555 *   3. Lock image selected status to focus state of edit control if
    5656 *      edit control exists. Mimics native actions.
     
    8787#include "debugtools.h"
    8888#include "wine/unicode.h"
    89 #ifdef __WIN32OS2__
    90 #include "ccbase.h"
    91 #define inline
    92 #endif
    9389
    9490DEFAULT_DEBUG_CHANNEL(comboex);
     
    116112typedef struct
    117113{
    118 #ifdef __WIN32OS2__
    119     COMCTL32_HEADER header;
    120 #endif
    121114    HIMAGELIST   himl;
    122115    HWND         hwndSelf;         /* my own hwnd */
     
    128121    INT          selected;         /* index of selected item */
    129122    DWORD        flags;            /* WINE internal flags */
    130 #ifdef __WIN32OS2__
    131123    HFONT        hDefaultFont;
    132 #endif
    133124    HFONT        font;
    134 
    135125    INT          nb_items;         /* Number of items */
    136126    BOOL         bUnicode;        /* TRUE if this window is Unicode   */
     
    543533    COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    544534
    545     TRACE("-- 0x%p\n", infoPtr->himl);
     535    TRACE("-- %p\n", infoPtr->himl);
    546536
    547537    return (LRESULT)infoPtr->himl;
     
    10991089
    11001090    /* allocate memory for info structure */
    1101 #ifdef __WIN32OS2__
    1102     infoPtr = (COMBOEX_INFO*)initControl(hwnd,sizeof(COMBOEX_INFO));
    1103 #else
    11041091    infoPtr = (COMBOEX_INFO *)COMCTL32_Alloc (sizeof(COMBOEX_INFO));
    1105 #endif
    11061092    if (infoPtr == NULL) {
    11071093        ERR("could not allocate info memory!\n");
     
    12251211        SystemParametersInfoA (SPI_GETICONTITLELOGFONT, sizeof(mylogfont),
    12261212                               &mylogfont, 0);
    1227 #ifdef __WIN32OS2__
    12281213        infoPtr->font = infoPtr->hDefaultFont = CreateFontIndirectA (&mylogfont);
    1229 #else
    1230         infoPtr->font = CreateFontIndirectA (&mylogfont);
    1231 #endif
    12321214    }
    12331215    SendMessageW (infoPtr->hwndCombo, WM_SETFONT, (WPARAM)infoPtr->font, 0);
     
    14601442          dis->CtlType, dis->CtlID, dis->itemID, dis->hwndItem, dis->itemData);
    14611443
    1462     if ((dis->itemID >= infoPtr->nb_items) || (dis->itemID < 0)) return FALSE;
     1444    if (dis->itemID >= infoPtr->nb_items) return FALSE;
    14631445
    14641446    olditem = infoPtr->items;
     
    17701752    }
    17711753
    1772 #ifdef __WIN32OS2__
    1773     //NEVER delete the font object received by WM_SETFONT!
    17741754    if (infoPtr->hDefaultFont) DeleteObject (infoPtr->hDefaultFont);
    1775 #else
    1776     DeleteObject (infoPtr->font);
    1777 #endif
    17781755
    17791756    /* free comboex info data */
     
    24742451                ERR("unknown msg %04x wp=%08x lp=%08lx\n",
    24752452                     uMsg, wParam, lParam);
    2476 #ifdef __WIN32OS2__
    2477             return defComCtl32ProcA (hwnd, uMsg, wParam, lParam);
    2478 #else
    24792453            return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    2480 #endif
    24812454    }
    24822455    return 0;
  • trunk/src/comctl32/comctl32.c

    r7342 r7815  
    22 * Common controls functions
    33 *
    4  * Copyright 1997 Dimitrie O. Paun
    5  * Copyright 1998,2000 Eric Kohl
    6  *
    74 */
    85
    9 #ifdef __WIN32OS2__
    10 #include <odin.h>
    11 #endif
     6#include <windows.h>
     7#include <misc.h>
    128
    13 #include <string.h>
    14 #include "winbase.h"
    15 #include "heap.h"
    16 #include "commctrl.h"
    17 #include "debugtools.h"
    18 #include "winerror.h"
    19 #include "shlwapi.h"
    20 #include "comctl32.h"
    21 
    22 DEFAULT_DEBUG_CHANNEL(commctrl);
    23 
    24 #ifndef __WIN32OS2__
    25 extern void ANIMATE_Register(void);
    26 extern void ANIMATE_Unregister(void);
    27 extern void COMBOEX_Register(void);
    28 extern void COMBOEX_Unregister(void);
    29 extern void DATETIME_Register(void);
    30 extern void DATETIME_Unregister(void);
    31 extern void FLATSB_Register(void);
    32 extern void FLATSB_Unregister(void);
    33 extern void HEADER_Register(void);
    34 extern void HEADER_Unregister(void);
    35 extern void HOTKEY_Register(void);
    36 extern void HOTKEY_Unregister(void);
    37 extern void IPADDRESS_Register(void);
    38 extern void IPADDRESS_Unregister(void);
    39 extern void LISTVIEW_Register(void);
    40 extern void LISTVIEW_Unregister(void);
    41 extern void MONTHCAL_Register(void);
    42 extern void MONTHCAL_Unregister(void);
    43 extern void NATIVEFONT_Register(void);
    44 extern void NATIVEFONT_Unregister(void);
    45 extern void PAGER_Register(void);
    46 extern void PAGER_Unregister(void);
    47 extern void PROGRESS_Register(void);
    48 extern void PROGRESS_Unregister(void);
    49 extern void REBAR_Register(void);
    50 extern void REBAR_Unregister(void);
    51 extern void STATUS_Register(void);
    52 extern void STATUS_Unregister(void);
    53 extern void TAB_Register(void);
    54 extern void TAB_Unregister(void);
    55 extern void TOOLBAR_Register(void);
    56 extern void TOOLBAR_Unregister(void);
    57 extern void TOOLTIPS_Register(void);
    58 extern void TOOLTIPS_Unregister(void);
    59 extern void TRACKBAR_Register(void);
    60 extern void TRACKBAR_Unregister(void);
    61 extern void TREEVIEW_Register(void);
    62 extern void TREEVIEW_Unregister(void);
    63 extern void UPDOWN_Register(void);
    64 extern void UPDOWN_Unregister(void);
    65 #endif
    66 
    67 HANDLE COMCTL32_hHeap = (HANDLE)NULL;
    68 LPSTR    COMCTL32_aSubclass = (LPSTR)NULL;
    69 HMODULE COMCTL32_hModule = 0;
    70 LANGID  COMCTL32_uiLang = MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL);
    71 HBRUSH  COMCTL32_hPattern55AABrush = (HANDLE)NULL;
    72 
    73 static HBITMAP COMCTL32_hPattern55AABitmap = (HANDLE)NULL;
    74 
    75 static const WORD wPattern55AA[] =
     9DWORD WINAPI COMCTL32_389(DWORD x1, DWORD x2)
    7610{
    77     0x5555, 0xaaaa, 0x5555, 0xaaaa,
    78     0x5555, 0xaaaa, 0x5555, 0xaaaa
    79 };
    80 
    81 
    82 /***********************************************************************
    83  * COMCTL32_LibMain [Internal] Initializes the internal 'COMCTL32.DLL'.
    84  *
    85  * PARAMS
    86  *     hinstDLL    [I] handle to the 'dlls' instance
    87  *     fdwReason   [I]
    88  *     lpvReserved [I] reserverd, must be NULL
    89  *
    90  * RETURNS
    91  *     Success: TRUE
    92  *     Failure: FALSE
    93  */
    94 
    95 BOOL WINAPI
    96 COMCTL32_LibMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
    97 {
    98     TRACE("%x,%lx,%p\n", hinstDLL, fdwReason, lpvReserved);
    99 
    100     switch (fdwReason) {
    101         case DLL_PROCESS_ATTACH:
    102             COMCTL32_hModule = (HMODULE)hinstDLL;
    103 
    104             /* create private heap */
    105             COMCTL32_hHeap = HeapCreate (0, 0x10000, 0);
    106             TRACE("Heap created: 0x%x\n", COMCTL32_hHeap);
    107 
    108             /* add global subclassing atom (used by 'tooltip' and 'updown') */
    109             COMCTL32_aSubclass = (LPSTR)(DWORD)GlobalAddAtomA ("CC32SubclassInfo");
    110             TRACE("Subclassing atom added: %p\n", COMCTL32_aSubclass);
    111 
    112             /* create local pattern brush */
    113             COMCTL32_hPattern55AABitmap = CreateBitmap (8, 8, 1, 1, wPattern55AA);
    114             COMCTL32_hPattern55AABrush = CreatePatternBrush (COMCTL32_hPattern55AABitmap);
    115 
    116             /* register all Win95 common control classes */
    117             ANIMATE_Register ();
    118             FLATSB_Register ();
    119             HEADER_Register ();
    120             HOTKEY_Register ();
    121             LISTVIEW_Register ();
    122             PROGRESS_Register ();
    123             STATUS_Register ();
    124             TAB_Register ();
    125             TOOLBAR_Register ();
    126             TOOLTIPS_Register ();
    127             TRACKBAR_Register ();
    128             TREEVIEW_Register ();
    129             UPDOWN_Register ();
    130             break;
    131 
    132         case DLL_PROCESS_DETACH:
    133             /* unregister all common control classes */
    134             ANIMATE_Unregister ();
    135             COMBOEX_Unregister ();
    136             DATETIME_Unregister ();
    137             FLATSB_Unregister ();
    138             HEADER_Unregister ();
    139             HOTKEY_Unregister ();
    140             IPADDRESS_Unregister ();
    141             LISTVIEW_Unregister ();
    142             MONTHCAL_Unregister ();
    143             NATIVEFONT_Unregister ();
    144             PAGER_Unregister ();
    145             PROGRESS_Unregister ();
    146             REBAR_Unregister ();
    147             STATUS_Unregister ();
    148             TAB_Unregister ();
    149             TOOLBAR_Unregister ();
    150             TOOLTIPS_Unregister ();
    151             TRACKBAR_Unregister ();
    152             TREEVIEW_Unregister ();
    153             UPDOWN_Unregister ();
    154 
    155             /* delete local pattern brush */
    156             DeleteObject (COMCTL32_hPattern55AABrush);
    157             COMCTL32_hPattern55AABrush = (HANDLE)NULL;
    158             DeleteObject (COMCTL32_hPattern55AABitmap);
    159             COMCTL32_hPattern55AABitmap = (HANDLE)NULL;
    160 
    161             /* delete global subclassing atom */
    162             GlobalDeleteAtom (LOWORD(COMCTL32_aSubclass));
    163             TRACE("Subclassing atom deleted: %p\n", COMCTL32_aSubclass);
    164             COMCTL32_aSubclass = (LPSTR)NULL;
    165 
    166             /* destroy private heap */
    167             HeapDestroy (COMCTL32_hHeap);
    168             TRACE("Heap destroyed: 0x%x\n", COMCTL32_hHeap);
    169             COMCTL32_hHeap = (HANDLE)NULL;
    170             break;
    171     }
    172 
    173     return TRUE;
     11   dprintf(("comctl32_389: %x %X not implemented!!", x1, x2));
     12   return 0; //NT 4 comctl32 returns 0
    17413}
    17514
     15DWORD WINAPI COMCTL32_390(DWORD x1, DWORD x2, DWORD x3, DWORD x4)
     16{
     17  dprintf(("comctl32_390: %x %x %x %x not implemented!!", x1, x2, x3, x4));
    17618
    177 /***********************************************************************
    178  * MenuHelp [COMCTL32.2]
    179  *
    180  * PARAMS
    181  *     uMsg       [I] message (WM_MENUSELECT) (see NOTES)
    182  *     wParam     [I] wParam of the message uMsg
    183  *     lParam     [I] lParam of the message uMsg
    184  *     hMainMenu  [I] handle to the application's main menu
    185  *     hInst      [I] handle to the module that contains string resources
    186  *     hwndStatus [I] handle to the status bar window
    187  *     lpwIDs     [I] pointer to an array of integers (see NOTES)
    188  *
    189  * RETURNS
    190  *     No return value
    191  *
    192  * NOTES
    193  *     The official documentation is incomplete!
    194  *     This is the correct documentation:
    195  *
    196  *     uMsg:
    197  *     MenuHelp() does NOT handle WM_COMMAND messages! It only handles
    198  *     WM_MENUSELECT messages.
    199  *
    200  *     lpwIDs:
    201  *     (will be written ...)
    202  */
     19  /* Pseudo Assembler
     20   push [esp+arg_C]
     21   mov  eax, [esp+4+arg_0]
     22   push [esp+4+arg_8]
     23   mov  dword ptr [eax+1A8h], 1
     24   push [esp+8+arg_4]
     25   push dword ptr [eax + 38h]
     26   call ds:SetDIBColorTable
     27   retn 10h
     28  */
    20329
    204 VOID WINAPI
    205 MenuHelp (UINT uMsg, WPARAM wParam, LPARAM lParam, HMENU hMainMenu,
    206           HINSTANCE hInst, HWND hwndStatus, LPUINT lpwIDs)
    207 {
    208     UINT uMenuID = 0;
    209 
    210     if (!IsWindow (hwndStatus))
    211         return;
    212 
    213     switch (uMsg) {
    214         case WM_MENUSELECT:
    215             TRACE("WM_MENUSELECT wParam=0x%X lParam=0x%lX\n",
    216                    wParam, lParam);
    217 
    218             if ((HIWORD(wParam) == 0xFFFF) && (lParam == 0)) {
    219                 /* menu was closed */
    220                 TRACE("menu was closed!\n");
    221                 SendMessageA (hwndStatus, SB_SIMPLE, FALSE, 0);
    222             }
    223             else {
    224                 /* menu item was selected */
    225                 if (HIWORD(wParam) & MF_POPUP)
    226                     uMenuID = (UINT)*(lpwIDs+1);
    227                 else
    228                     uMenuID = (UINT)LOWORD(wParam);
    229                 TRACE("uMenuID = %u\n", uMenuID);
    230 
    231                 if (uMenuID) {
    232                     CHAR szText[256];
    233 
    234                     if (!LoadStringA (hInst, uMenuID, szText, 256))
    235                         szText[0] = '\0';
    236 
    237                     SendMessageA (hwndStatus, SB_SETTEXTA,
    238                                     255 | SBT_NOBORDERS, (LPARAM)szText);
    239                     SendMessageA (hwndStatus, SB_SIMPLE, TRUE, 0);
    240                 }
    241             }
    242             break;
    243 
    244         case WM_COMMAND :
    245             TRACE("WM_COMMAND wParam=0x%X lParam=0x%lX\n",
    246                    wParam, lParam);
    247             /* WM_COMMAND is not invalid since it is documented
    248              * in the windows api reference. So don't output
    249              * any FIXME for WM_COMMAND
    250              */
    251             WARN("We don't care about the WM_COMMAND\n");
    252             break;
    253 
    254         default:
    255             FIXME("Invalid Message 0x%x!\n", uMsg);
    256             break;
    257     }
     30   return 0;
    25831}
    259 
    260 
    261 /***********************************************************************
    262  * ShowHideMenuCtl [COMCTL32.3]
    263  *
    264  * Shows or hides controls and updates the corresponding menu item.
    265  *
    266  * PARAMS
    267  *     hwnd   [I] handle to the client window.
    268  *     uFlags [I] menu command id.
    269  *     lpInfo [I] pointer to an array of integers. (See NOTES.)
    270  *
    271  * RETURNS
    272  *     Success: TRUE
    273  *     Failure: FALSE
    274  *
    275  * NOTES
    276  *     The official documentation is incomplete!
    277  *     This is the correct documentation:
    278  *
    279  *     hwnd
    280  *     Handle to the window that contains the menu and controls.
    281  *
    282  *     uFlags
    283  *     Identifier of the menu item to receive or loose a check mark.
    284  *
    285  *     lpInfo
    286  *     The array of integers contains pairs of values. BOTH values of
    287  *     the first pair must be the handles to the application's main menu.
    288  *     Each subsequent pair consists of a menu id and control id.
    289  */
    290 
    291 BOOL WINAPI
    292 ShowHideMenuCtl (HWND hwnd, UINT uFlags, LPINT lpInfo)
    293 {
    294     LPINT lpMenuId;
    295 
    296     TRACE("%x, %x, %p\n", hwnd, uFlags, lpInfo);
    297 
    298     if (lpInfo == NULL)
    299         return FALSE;
    300 
    301     if (!(lpInfo[0]) || !(lpInfo[1]))
    302         return FALSE;
    303 
    304     /* search for control */
    305     lpMenuId = &lpInfo[2];
    306     while (*lpMenuId != uFlags)
    307         lpMenuId += 2;
    308 
    309     if (GetMenuState (lpInfo[1], uFlags, MF_BYCOMMAND) & MFS_CHECKED) {
    310         /* uncheck menu item */
    311         CheckMenuItem (lpInfo[0], *lpMenuId, MF_BYCOMMAND | MF_UNCHECKED);
    312 
    313         /* hide control */
    314         lpMenuId++;
    315         SetWindowPos (GetDlgItem (hwnd, *lpMenuId), 0, 0, 0, 0, 0,
    316                         SWP_HIDEWINDOW);
    317     }
    318     else {
    319         /* check menu item */
    320         CheckMenuItem (lpInfo[0], *lpMenuId, MF_BYCOMMAND | MF_CHECKED);
    321 
    322         /* show control */
    323         lpMenuId++;
    324         SetWindowPos (GetDlgItem (hwnd, *lpMenuId), 0, 0, 0, 0, 0,
    325                         SWP_SHOWWINDOW);
    326     }
    327 
    328     return TRUE;
    329 }
    330 
    331 
    332 /***********************************************************************
    333  * GetEffectiveClientRect [COMCTL32.4]
    334  *
    335  * PARAMS
    336  *     hwnd   [I] handle to the client window.
    337  *     lpRect [O] pointer to the rectangle of the client window
    338  *     lpInfo [I] pointer to an array of integers (see NOTES)
    339  *
    340  * RETURNS
    341  *     No return value.
    342  *
    343  * NOTES
    344  *     The official documentation is incomplete!
    345  *     This is the correct documentation:
    346  *
    347  *     lpInfo
    348  *     (will be written...)
    349  */
    350 
    351 VOID WINAPI
    352 GetEffectiveClientRect (HWND hwnd, LPRECT lpRect, LPINT lpInfo)
    353 {
    354     RECT rcCtrl;
    355     INT  *lpRun;
    356     HWND hwndCtrl;
    357 
    358     TRACE("(0x%08lx 0x%08lx 0x%08lx)\n",
    359            (DWORD)hwnd, (DWORD)lpRect, (DWORD)lpInfo);
    360 
    361     GetClientRect (hwnd, lpRect);
    362     lpRun = lpInfo;
    363 
    364     do {
    365         lpRun += 2;
    366         if (*lpRun == 0)
    367             return;
    368         lpRun++;
    369         hwndCtrl = GetDlgItem (hwnd, *lpRun);
    370         if (GetWindowLongA (hwndCtrl, GWL_STYLE) & WS_VISIBLE) {
    371             TRACE("control id 0x%x\n", *lpRun);
    372             GetWindowRect (hwndCtrl, &rcCtrl);
    373             MapWindowPoints ((HWND)0, hwnd, (LPPOINT)&rcCtrl, 2);
    374             SubtractRect (lpRect, lpRect, &rcCtrl);
    375         }
    376         lpRun++;
    377     } while (*lpRun);
    378 }
    379 
    380 
    381 /***********************************************************************
    382  * DrawStatusTextA [COMCTL32.5][COMCTL32.27]
    383  *
    384  * Draws text with borders, like in a status bar.
    385  *
    386  * PARAMS
    387  *     hdc   [I] handle to the window's display context
    388  *     lprc  [I] pointer to a rectangle
    389  *     text  [I] pointer to the text
    390  *     style [I] drawing style
    391  *
    392  * RETURNS
    393  *     No return value.
    394  *
    395  * NOTES
    396  *     The style variable can have one of the following values:
    397  *     (will be written ...)
    398  */
    399 
    400 VOID WINAPI
    401 DrawStatusTextA (HDC hdc, LPRECT lprc, LPCSTR text, UINT style)
    402 {
    403     RECT r = *lprc;
    404     UINT border = BDR_SUNKENOUTER;
    405 
    406     if (style & SBT_POPOUT)
    407       border = BDR_RAISEDOUTER;
    408     else if (style & SBT_NOBORDERS)
    409       border = 0;
    410 
    411     DrawEdge (hdc, &r, border, BF_RECT|BF_ADJUST|BF_MIDDLE);
    412 
    413     /* now draw text */
    414     if (text) {
    415       int oldbkmode = SetBkMode (hdc, TRANSPARENT);
    416       r.left += 3;
    417       DrawTextA (hdc, text, lstrlenA(text),
    418                    &r, DT_LEFT|DT_VCENTER|DT_SINGLELINE); 
    419       if (oldbkmode != TRANSPARENT)
    420         SetBkMode(hdc, oldbkmode);
    421     }
    422 }
    423 
    424 
    425 /***********************************************************************
    426  * DrawStatusTextW [COMCTL32.28]
    427  *
    428  * Draws text with borders, like in a status bar.
    429  *
    430  * PARAMS
    431  *     hdc   [I] handle to the window's display context
    432  *     lprc  [I] pointer to a rectangle
    433  *     text  [I] pointer to the text
    434  *     style [I] drawing style
    435  *
    436  * RETURNS
    437  *     No return value.
    438  */
    439 
    440 VOID WINAPI
    441 DrawStatusTextW (HDC hdc, LPRECT lprc, LPCWSTR text, UINT style)
    442 {
    443     LPSTR p = HEAP_strdupWtoA (GetProcessHeap (), 0, text);
    444     DrawStatusTextA (hdc, lprc, p, style);
    445     HeapFree (GetProcessHeap (), 0, p );
    446 }
    447 
    448 
    449 /***********************************************************************
    450  * CreateStatusWindowA [COMCTL32.6][COMCTL32.21]
    451  *
    452  * Creates a status bar
    453  *
    454  * PARAMS
    455  *     style  [I] window style
    456  *     text   [I] pointer to the window text
    457  *     parent [I] handle to the parent window
    458  *     wid    [I] control id of the status bar
    459  *
    460  * RETURNS
    461  *     Success: handle to the status window
    462  *     Failure: 0
    463  */
    464 
    465 HWND WINAPI
    466 CreateStatusWindowA (INT style, LPCSTR text, HWND parent, UINT wid)
    467 {
    468     return CreateWindowA(STATUSCLASSNAMEA, text, style,
    469                            CW_USEDEFAULT, CW_USEDEFAULT,
    470                            CW_USEDEFAULT, CW_USEDEFAULT,
    471                            parent, wid, 0, 0);
    472 }
    473 
    474 
    475 /***********************************************************************
    476  * CreateStatusWindowW [COMCTL32.22] Creates a status bar control
    477  *
    478  * PARAMS
    479  *     style  [I] window style
    480  *     text   [I] pointer to the window text
    481  *     parent [I] handle to the parent window
    482  *     wid    [I] control id of the status bar
    483  *
    484  * RETURNS
    485  *     Success: handle to the status window
    486  *     Failure: 0
    487  */
    488 
    489 HWND WINAPI
    490 CreateStatusWindowW (INT style, LPCWSTR text, HWND parent, UINT wid)
    491 {
    492     return CreateWindowW(STATUSCLASSNAMEW, text, style,
    493                            CW_USEDEFAULT, CW_USEDEFAULT,
    494                            CW_USEDEFAULT, CW_USEDEFAULT,
    495                            parent, wid, 0, 0);
    496 }
    497 
    498 
    499 /***********************************************************************
    500  * CreateUpDownControl [COMCTL32.16] Creates an up-down control
    501  *
    502  * PARAMS
    503  *     style  [I] window styles
    504  *     x      [I] horizontal position of the control
    505  *     y      [I] vertical position of the control
    506  *     cx     [I] with of the control
    507  *     cy     [I] height of the control
    508  *     parent [I] handle to the parent window
    509  *     id     [I] the control's identifier
    510  *     inst   [I] handle to the application's module instance
    511  *     buddy  [I] handle to the buddy window, can be NULL
    512  *     maxVal [I] upper limit of the control
    513  *     minVal [I] lower limit of the control
    514  *     curVal [I] current value of the control
    515  *
    516  * RETURNS
    517  *     Success: handle to the updown control
    518  *     Failure: 0
    519  */
    520 
    521 HWND WINAPI
    522 CreateUpDownControl (DWORD style, INT x, INT y, INT cx, INT cy,
    523                      HWND parent, INT id, HINSTANCE inst,
    524                      HWND buddy, INT maxVal, INT minVal, INT curVal)
    525 {
    526     HWND hUD =
    527         CreateWindowA (UPDOWN_CLASSA, 0, style, x, y, cx, cy,
    528                          parent, id, inst, 0);
    529     if (hUD) {
    530         SendMessageA (hUD, UDM_SETBUDDY, buddy, 0);
    531         SendMessageA (hUD, UDM_SETRANGE, 0, MAKELONG(maxVal, minVal));
    532         SendMessageA (hUD, UDM_SETPOS, 0, MAKELONG(curVal, 0));     
    533     }
    534 
    535     return hUD;
    536 }
    537 
    538 
    539 /***********************************************************************
    540  * InitCommonControls [COMCTL32.17]
    541  *
    542  * Registers the common controls.
    543  *
    544  * PARAMS
    545  *     No parameters.
    546  *
    547  * RETURNS
    548  *     No return values.
    549  *
    550  * NOTES
    551  *     This function is just a dummy.
    552  *     The Win95 controls are registered at the DLL's initialization.
    553  *     To register other controls InitCommonControlsEx() must be used.
    554  */
    555 
    556 VOID WINAPI
    557 InitCommonControls (void)
    558 {
    559 }
    560 
    561 
    562 /***********************************************************************
    563  * InitCommonControlsEx [COMCTL32.81]
    564  *
    565  * Registers the common controls.
    566  *
    567  * PARAMS
    568  *     lpInitCtrls [I] pointer to an INITCOMMONCONTROLS structure.
    569  *
    570  * RETURNS
    571  *     Success: TRUE
    572  *     Failure: FALSE
    573  *
    574  * NOTES
    575  *     Only the additional common controls are registered by this function.
    576  *     The Win95 controls are registered at the DLL's initialization.
    577  */
    578 
    579 BOOL WINAPI
    580 InitCommonControlsEx (LPINITCOMMONCONTROLSEX lpInitCtrls)
    581 {
    582     INT cCount;
    583     DWORD dwMask;
    584 
    585     if (!lpInitCtrls)
    586         return FALSE;
    587     if (lpInitCtrls->dwSize != sizeof(INITCOMMONCONTROLSEX))
    588         return FALSE;
    589 
    590     TRACE("(0x%08lx)\n", lpInitCtrls->dwICC);
    591 
    592     for (cCount = 0; cCount < 32; cCount++) {
    593         dwMask = 1 << cCount;
    594         if (!(lpInitCtrls->dwICC & dwMask))
    595             continue;
    596 
    597         switch (lpInitCtrls->dwICC & dwMask) {
    598             /* dummy initialization */
    599             case ICC_ANIMATE_CLASS:
    600             case ICC_BAR_CLASSES:
    601             case ICC_LISTVIEW_CLASSES:
    602             case ICC_TREEVIEW_CLASSES:
    603             case ICC_TAB_CLASSES:
    604             case ICC_UPDOWN_CLASS:
    605             case ICC_PROGRESS_CLASS:
    606             case ICC_HOTKEY_CLASS:
    607                 break;
    608 
    609             /* advanced classes - not included in Win95 */
    610             case ICC_DATE_CLASSES:
    611                 MONTHCAL_Register ();
    612                 DATETIME_Register ();
    613                 break;
    614 
    615             case ICC_USEREX_CLASSES:
    616                 COMBOEX_Register ();
    617                 break;
    618 
    619             case ICC_COOL_CLASSES:
    620                 REBAR_Register ();
    621                 break;
    622 
    623             case ICC_INTERNET_CLASSES:
    624                 IPADDRESS_Register ();
    625                 break;
    626 
    627             case ICC_PAGESCROLLER_CLASS:
    628                 PAGER_Register ();
    629                 break;
    630 
    631             case ICC_NATIVEFNTCTL_CLASS:
    632                 NATIVEFONT_Register ();
    633                 break;
    634 
    635             default:
    636                 FIXME("Unknown class! dwICC=0x%lX\n", dwMask);
    637                 break;
    638         }
    639     }
    640 
    641     return TRUE;
    642 }
    643 
    644 
    645 /***********************************************************************
    646  * CreateToolbarEx [COMCTL32.32] Creates a tool bar window
    647  *
    648  * PARAMS
    649  *     hwnd
    650  *     style
    651  *     wID
    652  *     nBitmaps
    653  *     hBMInst
    654  *     wBMID
    655  *     lpButtons
    656  *     iNumButtons
    657  *     dxButton
    658  *     dyButton
    659  *     dxBitmap
    660  *     dyBitmap
    661  *     uStructSize
    662  *
    663  * RETURNS
    664  *     Success: handle to the tool bar control
    665  *     Failure: 0
    666  */
    667 
    668 HWND WINAPI
    669 CreateToolbarEx (HWND hwnd, DWORD style, UINT wID, INT nBitmaps,
    670                  HINSTANCE hBMInst, UINT wBMID, LPCTBBUTTON lpButtons,
    671                  INT iNumButtons, INT dxButton, INT dyButton,
    672                  INT dxBitmap, INT dyBitmap, UINT uStructSize)
    673 {
    674     HWND hwndTB;
    675 
    676     /* If not position is specified then put it at the top */
    677     if ((style & CCS_BOTTOM) == 0) {
    678       style|=CCS_TOP;
    679     }
    680 
    681     hwndTB =
    682         CreateWindowExA (0, TOOLBARCLASSNAMEA, "", style|WS_CHILD, 0, 0, 0, 0,
    683                            hwnd, (HMENU)wID, 0, NULL);
    684     if(hwndTB) {
    685         TBADDBITMAP tbab;
    686 
    687         SendMessageA (hwndTB, TB_BUTTONSTRUCTSIZE,
    688                         (WPARAM)uStructSize, 0);
    689 
    690        /* set bitmap and button size */
    691        /*If CreateToolbarEx receives 0, windows sets default values*/
    692        if (dxBitmap <= 0)
    693            dxBitmap = 16;
    694        if (dyBitmap <= 0)
    695            dyBitmap = 15;
    696        SendMessageA (hwndTB, TB_SETBITMAPSIZE, 0,
    697                        MAKELPARAM((WORD)dxBitmap, (WORD)dyBitmap));
    698 
    699        if (dxButton <= 0)
    700            dxButton = 24;
    701        if (dyButton <= 0)
    702            dyButton = 22;
    703        SendMessageA (hwndTB, TB_SETBUTTONSIZE, 0,
    704                        MAKELPARAM((WORD)dxButton, (WORD)dyButton));
    705 
    706 
    707         /* add bitmaps */
    708         if (nBitmaps > 0)
    709         {
    710         tbab.hInst = hBMInst;
    711         tbab.nID   = wBMID;
    712 
    713         SendMessageA (hwndTB, TB_ADDBITMAP,
    714                         (WPARAM)nBitmaps, (LPARAM)&tbab);
    715         }
    716         /* add buttons */
    717         if(iNumButtons > 0)
    718         SendMessageA (hwndTB, TB_ADDBUTTONSA,
    719                         (WPARAM)iNumButtons, (LPARAM)lpButtons);
    720     }
    721 
    722     return hwndTB;
    723 }
    724 
    725 
    726 /***********************************************************************
    727  * CreateMappedBitmap [COMCTL32.8]
    728  *
    729  * PARAMS
    730  *     hInstance  [I]
    731  *     idBitmap   [I]
    732  *     wFlags     [I]
    733  *     lpColorMap [I]
    734  *     iNumMaps   [I]
    735  *
    736  * RETURNS
    737  *     Success: handle to the new bitmap
    738  *     Failure: 0
    739  */
    740 
    741 HBITMAP WINAPI
    742 CreateMappedBitmap (HINSTANCE hInstance, INT idBitmap, UINT wFlags,
    743                     LPCOLORMAP lpColorMap, INT iNumMaps)
    744 {
    745     HGLOBAL hglb;
    746     HRSRC hRsrc;
    747     LPBITMAPINFOHEADER lpBitmap, lpBitmapInfo;
    748     UINT nSize, nColorTableSize;
    749     RGBQUAD *pColorTable;
    750     INT iColor, i, iMaps, nWidth, nHeight;
    751     HDC hdcScreen;
    752     HBITMAP hbm;
    753     LPCOLORMAP sysColorMap;
    754     COLORREF cRef;
    755     COLORMAP internalColorMap[4] =
    756         {{0x000000, 0}, {0x808080, 0}, {0xC0C0C0, 0}, {0xFFFFFF, 0}};
    757 
    758     /* initialize pointer to colortable and default color table */
    759     if (lpColorMap) {
    760         iMaps = iNumMaps;
    761         sysColorMap = lpColorMap;
    762     }
    763     else {
    764         internalColorMap[0].to = GetSysColor (COLOR_BTNTEXT);
    765         internalColorMap[1].to = GetSysColor (COLOR_BTNSHADOW);
    766         internalColorMap[2].to = GetSysColor (COLOR_BTNFACE);
    767         internalColorMap[3].to = GetSysColor (COLOR_BTNHIGHLIGHT);
    768         iMaps = 4;
    769         sysColorMap = (LPCOLORMAP)internalColorMap;
    770     }
    771 
    772     hRsrc = FindResourceA (hInstance, (LPSTR)idBitmap, RT_BITMAPA);
    773     if (hRsrc == 0)
    774         return 0;
    775     hglb = LoadResource (hInstance, hRsrc);
    776     if (hglb == 0)
    777         return 0;
    778     lpBitmap = (LPBITMAPINFOHEADER)LockResource (hglb);
    779     if (lpBitmap == NULL)
    780         return 0;
    781 
    782     nColorTableSize = (1 << lpBitmap->biBitCount);
    783     nSize = lpBitmap->biSize + nColorTableSize * sizeof(RGBQUAD);
    784     lpBitmapInfo = (LPBITMAPINFOHEADER)GlobalAlloc (GMEM_FIXED, nSize);
    785     if (lpBitmapInfo == NULL)
    786         return 0;
    787     RtlMoveMemory (lpBitmapInfo, lpBitmap, nSize);
    788 
    789     pColorTable = (RGBQUAD*)(((LPBYTE)lpBitmapInfo)+(UINT)lpBitmapInfo->biSize);
    790 
    791     for (iColor = 0; iColor < nColorTableSize; iColor++) {
    792         for (i = 0; i < iMaps; i++) {
    793             cRef = RGB(pColorTable[iColor].rgbRed,
    794                        pColorTable[iColor].rgbGreen,
    795                        pColorTable[iColor].rgbBlue);
    796             if ( cRef  == sysColorMap[i].from) {
    797 #if 0
    798                 if (wFlags & CBS_MASKED) {
    799                     if (sysColorMap[i].to != COLOR_BTNTEXT)
    800                         pColorTable[iColor] = RGB(255, 255, 255);
    801                 }
    802                 else
    803 #endif
    804                     pColorTable[iColor].rgbBlue  = GetBValue(sysColorMap[i].to);
    805                     pColorTable[iColor].rgbGreen = GetGValue(sysColorMap[i].to);
    806                     pColorTable[iColor].rgbRed   = GetRValue(sysColorMap[i].to);
    807                 break;
    808             }
    809         }
    810     }
    811     nWidth  = (INT)lpBitmapInfo->biWidth;
    812     nHeight = (INT)lpBitmapInfo->biHeight;
    813     hdcScreen = GetDC ((HWND)0);
    814     hbm = CreateCompatibleBitmap (hdcScreen, nWidth, nHeight);
    815     if (hbm) {
    816         HDC hdcDst = CreateCompatibleDC (hdcScreen);
    817         HBITMAP hbmOld = SelectObject (hdcDst, hbm);
    818         LPBYTE lpBits = (LPBYTE)(lpBitmap + 1);
    819         lpBits += (1 << (lpBitmapInfo->biBitCount)) * sizeof(RGBQUAD);
    820         StretchDIBits (hdcDst, 0, 0, nWidth, nHeight, 0, 0, nWidth, nHeight,
    821                          lpBits, (LPBITMAPINFO)lpBitmapInfo, DIB_RGB_COLORS,
    822                          SRCCOPY);
    823         SelectObject (hdcDst, hbmOld);
    824         DeleteDC (hdcDst);
    825     }
    826     ReleaseDC ((HWND)0, hdcScreen);
    827     GlobalFree ((HGLOBAL)lpBitmapInfo);
    828     FreeResource (hglb);
    829 
    830     return hbm;
    831 }
    832 
    833 
    834 /***********************************************************************
    835  * CreateToolbar [COMCTL32.7] Creates a tool bar control
    836  *
    837  * PARAMS
    838  *     hwnd
    839  *     style
    840  *     wID
    841  *     nBitmaps
    842  *     hBMInst
    843  *     wBMID
    844  *     lpButtons
    845  *     iNumButtons
    846  *
    847  * RETURNS
    848  *     Success: handle to the tool bar control
    849  *     Failure: 0
    850  *
    851  * NOTES
    852  *     Do not use this functions anymore. Use CreateToolbarEx instead.
    853  */
    854 
    855 HWND WINAPI
    856 CreateToolbar (HWND hwnd, DWORD style, UINT wID, INT nBitmaps,
    857                HINSTANCE hBMInst, UINT wBMID,
    858                LPCOLDTBBUTTON lpButtons,INT iNumButtons)
    859 {
    860     return CreateToolbarEx (hwnd, style | CCS_NODIVIDER, wID, nBitmaps,
    861                             hBMInst, wBMID, (LPCTBBUTTON)lpButtons,
    862                             iNumButtons, 0, 0, 0, 0, sizeof (OLDTBBUTTON));
    863 }
    864 
    865 
    866 /***********************************************************************
    867  * DllGetVersion [COMCTL32.25]
    868  *
    869  * Retrieves version information of the 'COMCTL32.DLL'
    870  *
    871  * PARAMS
    872  *     pdvi [O] pointer to version information structure.
    873  *
    874  * RETURNS
    875  *     Success: S_OK
    876  *     Failure: E_INVALIDARG
    877  *
    878  * NOTES
    879  *     Returns version of a comctl32.dll from IE4.01 SP1.
    880  */
    881 
    882 HRESULT WINAPI
    883 COMCTL32_DllGetVersion (DLLVERSIONINFO *pdvi)
    884 {
    885     if (pdvi->cbSize != sizeof(DLLVERSIONINFO)) {
    886         WARN("wrong DLLVERSIONINFO size from app");
    887         return E_INVALIDARG;
    888     }
    889 
    890     pdvi->dwMajorVersion = COMCTL32_VERSION;
    891     pdvi->dwMinorVersion = COMCTL32_VERSION_MINOR;
    892     pdvi->dwBuildNumber = 2919;
    893     pdvi->dwPlatformID = 6304;
    894 
    895     TRACE("%lu.%lu.%lu.%lu\n",
    896            pdvi->dwMajorVersion, pdvi->dwMinorVersion,
    897            pdvi->dwBuildNumber, pdvi->dwPlatformID);
    898 
    899     return S_OK;
    900 }
    901 
    902 /***********************************************************************
    903  *              DllInstall (COMCTL32.@)
    904  */
    905 HRESULT WINAPI COMCTL32_DllInstall(BOOL bInstall, LPCWSTR cmdline)
    906 {
    907   FIXME("(%s, %s): stub\n", bInstall?"TRUE":"FALSE",
    908         debugstr_w(cmdline));
    909 
    910   return S_OK;
    911 }
    912 
    913 
    914 typedef struct __TRACKINGLIST {
    915     TRACKMOUSEEVENT tme;
    916     POINT pos; /* center of hover rectangle */
    917     INT iHoverTime; /* elapsed time the cursor has been inside of the hover rect */
    918 } _TRACKINGLIST;
    919 
    920 static _TRACKINGLIST TrackingList[10];
    921 static int iTrackMax = 0;
    922 static UINT_PTR timer;
    923 
    924 static const INT iTimerInterval = 50; /* msec for timer interval */
    925 
    926 /* FIXME: need to implement WM_NCMOUSELEAVE and WM_NCMOUSEHOVER for */
    927 /* TrackMouseEventProc and _TrackMouseEvent */
    928 static void CALLBACK TrackMouseEventProc(HWND hwndUnused, UINT uMsg, UINT_PTR idEvent,
    929     DWORD dwTime)
    930 {
    931     int i = 0;
    932     POINT pos;
    933     HWND hwnd;
    934     INT hoverwidth = 0, hoverheight = 0;
    935 
    936     GetCursorPos(&pos);
    937     hwnd = WindowFromPoint(pos);
    938 
    939     SystemParametersInfoA(SPI_GETMOUSEHOVERWIDTH, 0, &hoverwidth, 0);
    940     SystemParametersInfoA(SPI_GETMOUSEHOVERHEIGHT, 0, &hoverheight, 0);
    941 
    942     /* loop through tracking events we are processing */
    943     while (i < iTrackMax) {
    944         /* see if this tracking event is looking for TME_LEAVE and that the */
    945         /* mouse has left the window */
    946         if ((TrackingList[i].tme.dwFlags & TME_LEAVE) &&
    947              (TrackingList[i].tme.hwndTrack != hwnd)) {
    948             PostMessageA(TrackingList[i].tme.hwndTrack, WM_MOUSELEAVE, 0, 0);
    949 
    950             /* remove the TME_LEAVE flag */
    951             TrackingList[i].tme.dwFlags ^= TME_LEAVE;
    952         }
    953 
    954         /* see if we are tracking hovering for this hwnd */
    955         if(TrackingList[i].tme.dwFlags & TME_HOVER) {
    956             /* add the timer interval to the hovering time */
    957             TrackingList[i].iHoverTime+=iTimerInterval; 
    958      
    959             /* has the cursor moved outside the rectangle centered around pos? */
    960             if((abs(pos.x - TrackingList[i].pos.x) > (hoverwidth / 2.0))
    961               || (abs(pos.y - TrackingList[i].pos.y) > (hoverheight / 2.0)))
    962             {
    963                 /* record this new position as the current position and reset */
    964                 /* the iHoverTime variable to 0 */
    965                 TrackingList[i].pos = pos;
    966                 TrackingList[i].iHoverTime = 0;
    967             }
    968 
    969             /* has the mouse hovered long enough? */
    970             if(TrackingList[i].iHoverTime <= TrackingList[i].tme.dwHoverTime)
    971              {
    972                 PostMessageA(TrackingList[i].tme.hwndTrack, WM_MOUSEHOVER, 0, 0);
    973 
    974                 /* stop tracking mouse hover */
    975                 TrackingList[i].tme.dwFlags ^= TME_HOVER;
    976             }
    977         }
    978 
    979         /* see if we are still tracking TME_HOVER or TME_LEAVE for this entry */
    980         if((TrackingList[i].tme.dwFlags & TME_HOVER) ||
    981            (TrackingList[i].tme.dwFlags & TME_LEAVE)) {
    982             i++;
    983         } else { /* remove this entry from the tracking list */
    984             TrackingList[i] = TrackingList[--iTrackMax];
    985         }
    986     }
    987        
    988     /* stop the timer if the tracking list is empty */
    989     if(iTrackMax == 0) {
    990         KillTimer(0, timer);
    991         timer = 0;
    992     }
    993 }
    994 
    995 /***********************************************************************
    996  * _TrackMouseEvent [COMCTL32.25]
    997  *
    998  * Requests notification of mouse events
    999  *
    1000  * During mouse tracking WM_MOUSEHOVER or WM_MOUSELEAVE events are posted
    1001  * to the hwnd specified in the ptme structure.  After the event message
    1002  * is posted to the hwnd, the entry in the queue is removed.
    1003  *
    1004  * If the current hwnd isn't ptme->hwndTrack the TME_HOVER flag is completely
    1005  * ignored. The TME_LEAVE flag results in a WM_MOUSELEAVE message being posted
    1006  * immediately and the TME_LEAVE flag being ignored.
    1007  *
    1008  * PARAMS
    1009  *     ptme [I,O] pointer to TRACKMOUSEEVENT information structure.
    1010  *
    1011  * RETURNS
    1012  *     Success: non-zero
    1013  *     Failure: zero
    1014  *
    1015  */
    1016 
    1017 BOOL WINAPI
    1018 _TrackMouseEvent (TRACKMOUSEEVENT *ptme)
    1019 {
    1020     DWORD flags = 0;
    1021     int i = 0;
    1022     BOOL cancel = 0, hover = 0, leave = 0, query = 0;
    1023     HWND hwnd;
    1024     POINT pos;
    1025 
    1026     pos.x = 0;
    1027     pos.y = 0;
    1028 
    1029     TRACE("%lx, %lx, %x, %lx\n", ptme->cbSize, ptme->dwFlags, ptme->hwndTrack, ptme->dwHoverTime);
    1030 
    1031     if (ptme->cbSize != sizeof(TRACKMOUSEEVENT)) {
    1032         WARN("wrong TRACKMOUSEEVENT size from app");
    1033         SetLastError(ERROR_INVALID_PARAMETER); /* FIXME not sure if this is correct */
    1034         return FALSE;
    1035     }
    1036 
    1037     flags = ptme->dwFlags;
    1038    
    1039     /* if HOVER_DEFAULT was specified replace this with the systems current value */
    1040     if(ptme->dwHoverTime == HOVER_DEFAULT)
    1041         SystemParametersInfoA(SPI_GETMOUSEHOVERTIME, 0, &(ptme->dwHoverTime), 0);
    1042 
    1043     GetCursorPos(&pos);
    1044     hwnd = WindowFromPoint(pos);   
    1045 
    1046     if ( flags & TME_CANCEL ) {
    1047         flags &= ~ TME_CANCEL;
    1048         cancel = 1;
    1049     }
    1050    
    1051     if ( flags & TME_HOVER  ) {
    1052         flags &= ~ TME_HOVER;
    1053         hover = 1;
    1054     }
    1055    
    1056     if ( flags & TME_LEAVE ) {
    1057         flags &= ~ TME_LEAVE;
    1058         leave = 1;
    1059     }
    1060 
    1061     /* fill the TRACKMOUSEEVENT struct with the current tracking for the given hwnd */
    1062     if ( flags & TME_QUERY ) {
    1063         flags &= ~ TME_QUERY;
    1064         query = 1;
    1065         i = 0;
    1066 
    1067         /* Find the tracking list entry with the matching hwnd */
    1068         while((i < iTrackMax) && (TrackingList[i].tme.hwndTrack != ptme->hwndTrack)) {
    1069             i++;
    1070         }
    1071 
    1072         /* hwnd found, fill in the ptme struct */
    1073         if(i < iTrackMax)
    1074             *ptme = TrackingList[i].tme;
    1075         else
    1076             ptme->dwFlags = 0;
    1077    
    1078         return TRUE; /* return here, TME_QUERY is retrieving information */
    1079     }
    1080 
    1081     if ( flags )
    1082         FIXME("Unknown flag(s) %08lx\n", flags );
    1083 
    1084     if(cancel) {
    1085         /* find a matching hwnd if one exists */
    1086         i = 0;
    1087 
    1088         while((i < iTrackMax) && (TrackingList[i].tme.hwndTrack != ptme->hwndTrack)) {
    1089           i++;
    1090         }
    1091 
    1092         if(i < iTrackMax) {
    1093             TrackingList[i].tme.dwFlags &= ~(ptme->dwFlags & ~TME_CANCEL);
    1094 
    1095             /* if we aren't tracking on hover or leave remove this entry */
    1096             if(!((TrackingList[i].tme.dwFlags & TME_HOVER) ||
    1097                  (TrackingList[i].tme.dwFlags & TME_LEAVE)))
    1098             {
    1099                 TrackingList[i] = TrackingList[--iTrackMax];
    1100        
    1101                 if(iTrackMax == 0) {
    1102                     KillTimer(0, timer);
    1103                     timer = 0;
    1104                 }
    1105             }
    1106         }
    1107     } else {
    1108         /* see if hwndTrack isn't the current window */
    1109         if(ptme->hwndTrack != hwnd) {
    1110             if(leave) {
    1111                 PostMessageA(ptme->hwndTrack, WM_MOUSELEAVE, 0, 0);
    1112             }
    1113         } else {
    1114             /* See if this hwnd is already being tracked and update the tracking flags */
    1115             for(i = 0; i < iTrackMax; i++) {
    1116                 if(TrackingList[i].tme.hwndTrack == ptme->hwndTrack) {
    1117                     if(hover) {
    1118                         TrackingList[i].tme.dwFlags |= TME_HOVER;
    1119                         TrackingList[i].tme.dwHoverTime = ptme->dwHoverTime;
    1120                     }
    1121  
    1122                     if(leave)
    1123                         TrackingList[i].tme.dwFlags |= TME_LEAVE;
    1124 
    1125                     /* reset iHoverTime as per winapi specs */
    1126                     TrackingList[i].iHoverTime = 0;                 
    1127  
    1128                     return TRUE;
    1129                 }
    1130             }           
    1131 
    1132             /* if the tracking list is full return FALSE */
    1133             if (iTrackMax == sizeof (TrackingList) / sizeof(*TrackingList)) {
    1134                 return FALSE;
    1135             }
    1136 
    1137             /* Adding new mouse event to the tracking list */
    1138             TrackingList[iTrackMax].tme = *ptme;
    1139 
    1140             /* Initialize HoverInfo variables even if not hover tracking */
    1141             TrackingList[iTrackMax].iHoverTime = 0;
    1142             TrackingList[iTrackMax].pos = pos;
    1143 
    1144             iTrackMax++;
    1145 
    1146             if (!timer) {
    1147                 timer = SetTimer(0, 0, iTimerInterval, TrackMouseEventProc);
    1148             }
    1149         }
    1150     }
    1151 
    1152     return TRUE;
    1153 }
    1154 
    1155 
    1156 /*************************************************************************
    1157  * GetMUILanguage [COMCTL32.39]
    1158  *
    1159  * FIXME: What's this supposed to do?  Apparently some i18n thing.
    1160  *
    1161  */
    1162 LANGID WINAPI GetMUILanguage (VOID)
    1163 {
    1164     return COMCTL32_uiLang;
    1165 }
    1166 
    1167 
    1168 /*************************************************************************
    1169  * InitMUILanguage [COMCTL32.85]
    1170  *
    1171  * FIXME: What's this supposed to do?  Apparently some i18n thing.
    1172  *
    1173  */
    1174 
    1175 VOID WINAPI InitMUILanguage (LANGID uiLang)
    1176 {
    1177    COMCTL32_uiLang = uiLang;
    1178 }
    1179 
    1180 
    1181 /***********************************************************************
    1182  * COMCTL32_CreateToolTip [NOT AN API]
    1183  *
    1184  * Creates a tooltip for the control specified in hwnd and does all
    1185  * necessary setup and notifications.
    1186  *
    1187  * PARAMS
    1188  *     hwndOwner [I] Handle to the window that will own the tool tip.
    1189  *
    1190  * RETURNS
    1191  *     Success: Handle of tool tip window.
    1192  *     Failure: NULL
    1193  */
    1194 HWND
    1195 COMCTL32_CreateToolTip(HWND hwndOwner)
    1196 {
    1197     HWND hwndToolTip;
    1198 
    1199     hwndToolTip = CreateWindowExA(0, TOOLTIPS_CLASSA, NULL, 0,
    1200                                   CW_USEDEFAULT, CW_USEDEFAULT,
    1201                                   CW_USEDEFAULT, CW_USEDEFAULT, hwndOwner,
    1202                                   0, 0, 0);
    1203 
    1204     /* Send NM_TOOLTIPSCREATED notification */
    1205     if (hwndToolTip)
    1206     {
    1207         NMTOOLTIPSCREATED nmttc;
    1208         /* true owner can be different if hwndOwner is a child window */
    1209         HWND hwndTrueOwner = GetWindow(hwndToolTip, GW_OWNER);
    1210         nmttc.hdr.hwndFrom = hwndTrueOwner;
    1211         nmttc.hdr.idFrom = GetWindowLongA(hwndTrueOwner, GWL_ID);
    1212         nmttc.hdr.code = NM_TOOLTIPSCREATED;
    1213         nmttc.hwndToolTips = hwndToolTip;
    1214 
    1215        SendMessageA(GetParent(hwndTrueOwner), WM_NOTIFY,
    1216                     (WPARAM)GetWindowLongA(hwndTrueOwner, GWL_ID),
    1217                      (LPARAM)&nmttc);
    1218     }
    1219 
    1220     return hwndToolTip;
    1221 }
  • trunk/src/comctl32/comctl32.def

    r6380 r7815  
    1 ; $Id: comctl32.def,v 1.24 2001-07-21 09:07:16 sandervl Exp $
     1; $Id: comctl32.def,v 1.25 2002-02-06 17:23:18 sandervl Exp $
    22LIBRARY COMCTL32 INITINSTANCE
    33DESCRIPTION 'Odin32 System DLL - ComCtl32 - Common Controls Library'
     
    2121  CreateUpDownControl          = _CreateUpDownControl@48             @16
    2222  InitCommonControls           = _InitCommonControls@0               @17
    23   CreatePropertySheetPageA     = _CreatePropertySheetPageA@4         @18
    24   CreatePropertySheetPageW     = _CreatePropertySheetPageW@4         @19
    25   CreateStatusWindow           = _CreateStatusWindowA@16             @20
    26   CreateStatusWindowW          = _CreateStatusWindowW@16             @21
    27   CreateToolbarEx              = _CreateToolbarEx@52                 @22
    28   DestroyPropertySheetPage     = _DestroyPropertySheetPage@4         @23
    29   DllGetVersion                = _COMCTL32_DllGetVersion@4           @24
    30   DllInstall                   = _COMCTL32_DllInstall@8              @25
    31   DrawStatusText               = _DrawStatusTextA@16                 @26
    32   DrawStatusTextW              = _DrawStatusTextW@16                 @27
    33 
    34   FlatSB_EnableScrollBar       = _FlatSB_EnableScrollBar@12          @28
    35   FlatSB_GetScrollInfo         = _FlatSB_GetScrollInfo@12            @29
    36   FlatSB_GetScrollPos          = _FlatSB_GetScrollPos@8              @30
    37   FlatSB_GetScrollProp         = _FlatSB_GetScrollProp@12            @31
    38   FlatSB_GetScrollRange        = _FlatSB_GetScrollRange@16           @32
    39   FlatSB_SetScrollInfo         = _FlatSB_SetScrollInfo@16            @33
    40   FlatSB_SetScrollPos          = _FlatSB_SetScrollPos@16             @34
    41   FlatSB_SetScrollProp         = _FlatSB_SetScrollProp@16            @35
    42   FlatSB_SetScrollRange        = _FlatSB_SetScrollRange@20           @36
    43   FlatSB_ShowScrollBar         = _FlatSB_ShowScrollBar@12            @37
    44   GetMUILanguage               = _GetMUILanguage@0                   @38
    45 
    46   ImageList_Add                = _ImageList_Add@12                   @39
    47   ImageList_AddIcon            = _ImageList_AddIcon@8                @40
    48   ImageList_AddMasked          = _ImageList_AddMasked@12             @41
    49   ImageList_BeginDrag          = _ImageList_BeginDrag@16             @42
    50   ImageList_Copy               = _ImageList_Copy@20                  @43
    51   ImageList_Create             = _ImageList_Create@20                @44
    52   ImageList_Destroy            = _ImageList_Destroy@4                @45
    53   ImageList_DragEnter          = _ImageList_DragEnter@12             @46
    54   ImageList_DragLeave          = _ImageList_DragLeave@4              @47
    55   ImageList_DragMove           = _ImageList_DragMove@8               @48
    56   ImageList_DragShowNolock     = _ImageList_DragShowNolock@4         @49
    57   ImageList_Draw               = _ImageList_Draw@24                  @50
    58   ImageList_DrawEx             = _ImageList_DrawEx@40                @51
    59   ImageList_DrawIndirect       = _ImageList_DrawIndirect@4           @52
    60   ImageList_Duplicate          = _ImageList_Duplicate@4              @53
    61   ImageList_EndDrag            = _ImageList_EndDrag@0                @54
    62   ImageList_GetBkColor         = _ImageList_GetBkColor@4             @55
    63   ImageList_GetDragImage       = _ImageList_GetDragImage@8           @56
    64   ;;stub ImageList_GetFlags                                          @57
    65   ImageList_GetIcon            = _ImageList_GetIcon@12               @58
    66   ImageList_GetIconSize        = _ImageList_GetIconSize@12           @59
    67   ImageList_GetImageCount      = _ImageList_GetImageCount@4          @60
    68   ImageList_GetImageInfo       = _ImageList_GetImageInfo@12          @61
    69   ImageList_GetImageRect       = _ImageList_GetImageRect@12          @62
    70   ImageList_LoadImage          = _ImageList_LoadImageA@28            @63
    71   ImageList_LoadImageA         = _ImageList_LoadImageA@28            @64
    72   ImageList_LoadImageW         = _ImageList_LoadImageW@28            @65
    73   ImageList_Merge              = _ImageList_Merge@24                 @66
    74   ImageList_Read               = _ImageList_Read@4                   @67
    75   ImageList_Remove             = _ImageList_Remove@8                 @68
    76   ImageList_Replace            = _ImageList_Replace@16               @69
    77   ImageList_ReplaceIcon        = _ImageList_ReplaceIcon@12           @70
     23  CreatePropertySheetPage      = _CreatePropertySheetPageA@4         @18
     24  CreatePropertySheetPageA     = _CreatePropertySheetPageA@4         @19
     25  CreatePropertySheetPageW     = _CreatePropertySheetPageW@4         @20
     26  CreateStatusWindow           = _CreateStatusWindowA@16             @21
     27  CreateStatusWindowW          = _CreateStatusWindowW@16             @22
     28  CreateToolbarEx              = _CreateToolbarEx@52                 @23
     29  DestroyPropertySheetPage     = _DestroyPropertySheetPage@4         @24
     30  DllGetVersion                = _COMCTL32_DllGetVersion@4           @25
     31  DllInstall                   = _COMCTL32_DllInstall@8              @26
     32  DrawStatusText               = _DrawStatusTextA@16                 @27
     33  DrawStatusTextW              = _DrawStatusTextW@16                 @28
     34  FlatSB_EnableScrollBar       = _FlatSB_EnableScrollBar@12          @29
     35  FlatSB_GetScrollInfo         = _FlatSB_GetScrollInfo@12            @30
     36  FlatSB_GetScrollPos          = _FlatSB_GetScrollPos@8              @31
     37  FlatSB_GetScrollProp         = _FlatSB_GetScrollProp@12            @32
     38  FlatSB_GetScrollRange        = _FlatSB_GetScrollRange@16           @33
     39  FlatSB_SetScrollInfo         = _FlatSB_SetScrollInfo@16            @34
     40  FlatSB_SetScrollPos          = _FlatSB_SetScrollPos@16             @35
     41  FlatSB_SetScrollProp         = _FlatSB_SetScrollProp@16            @36
     42  FlatSB_SetScrollRange        = _FlatSB_SetScrollRange@20           @37
     43  FlatSB_ShowScrollBar         = _FlatSB_ShowScrollBar@12            @38
     44  GetMUILanguage               = _GetMUILanguage@0                   @39
     45  ImageList_Add                = _ImageList_Add@12                   @40
     46  ImageList_AddIcon            = _ImageList_AddIcon@8                @41
     47  ImageList_AddMasked          = _ImageList_AddMasked@12             @42
     48  ImageList_BeginDrag          = _ImageList_BeginDrag@16             @43
     49  ImageList_Copy               = _ImageList_Copy@20                  @44
     50  ImageList_Create             = _ImageList_Create@20                @45
     51  ImageList_Destroy            = _ImageList_Destroy@4                @46
     52  ImageList_DragEnter          = _ImageList_DragEnter@12             @47
     53  ImageList_DragLeave          = _ImageList_DragLeave@4              @48
     54  ImageList_DragMove           = _ImageList_DragMove@8               @49
     55  ImageList_DragShowNolock     = _ImageList_DragShowNolock@4         @50
     56  ImageList_Draw               = _ImageList_Draw@24                  @51
     57  ImageList_DrawEx             = _ImageList_DrawEx@40                @52
     58  ImageList_DrawIndirect       = _ImageList_DrawIndirect@4           @53
     59  ImageList_Duplicate          = _ImageList_Duplicate@4              @54
     60  ImageList_EndDrag            = _ImageList_EndDrag@0                @55
     61  ImageList_GetBkColor         = _ImageList_GetBkColor@4             @56
     62  ImageList_GetDragImage       = _ImageList_GetDragImage@8           @57
     63  ImageList_GetFlags           = _ImageList_GetFlags@4               @58
     64  ImageList_GetIcon            = _ImageList_GetIcon@12               @59
     65  ImageList_GetIconSize        = _ImageList_GetIconSize@12           @60
     66  ImageList_GetImageCount      = _ImageList_GetImageCount@4          @61
     67  ImageList_GetImageInfo       = _ImageList_GetImageInfo@12          @62
     68  ImageList_GetImageRect       = _ImageList_GetImageRect@12          @63
     69  ImageList_LoadImage          = _ImageList_LoadImageA@28            @64
     70  ImageList_LoadImageA         = _ImageList_LoadImageA@28            @65
     71  ImageList_LoadImageW         = _ImageList_LoadImageW@28            @66
     72  ImageList_Merge              = _ImageList_Merge@24                 @67
     73  ImageList_Read               = _ImageList_Read@4                   @68
     74  ImageList_Remove             = _ImageList_Remove@8                 @69
     75  ImageList_Replace            = _ImageList_Replace@16               @70
    7876  Alloc                        = _COMCTL32_Alloc@4                   @71
    7977  ReAlloc                      = _COMCTL32_ReAlloc@8                 @72
    8078  Free                         = _COMCTL32_Free@4                    @73
    8179  GetSize                      = _COMCTL32_GetSize@4                 @74
    82   ImageList_SetBkColor         = _ImageList_SetBkColor@8             @75
    83   ImageList_SetDragCursorImage = _ImageList_SetDragCursorImage@16    @76
    84   ImageList_SetFilter          = _ImageList_SetFilter@12             @77
    85   ;;stub ImageList_SetFlags                                          @78
    86   ImageList_SetIconSize        = _ImageList_SetIconSize@12           @79
    87   ImageList_SetImageCount      = _ImageList_SetImageCount@8          @80
    88   ImageList_SetOverlayImage    = _ImageList_SetOverlayImage@12       @81
    89   ImageList_Write              = _ImageList_Write@8                  @82
    90 
    91   InitCommonControlsEx         = _InitCommonControlsEx@4             @83
    92   InitMUILanguage              = _InitMUILanguage@4                  @84
    93   InitializeFlatSB             = _InitializeFlatSB@4                 @85
    94   PropertySheet                = _PropertySheetA@4                   @86
    95   PropertySheetA               = _PropertySheetA@4                   @87
    96   PropertySheetW               = _PropertySheetW@4                   @88
    97   UninitializeFlatSB           = _UninitializeFlatSB@4               @89
    98   _TrackMouseEvent             = __TrackMouseEvent@4                 @90
     80  ImageList_ReplaceIcon        = _ImageList_ReplaceIcon@12           @75
     81  ImageList_SetBkColor         = _ImageList_SetBkColor@8             @76
     82  ImageList_SetDragCursorImage = _ImageList_SetDragCursorImage@16    @77
     83  ImageList_SetFilter          = _ImageList_SetFilter@12             @78
     84  ImageList_SetFlags           = _ImageList_SetFlags@8               @79
     85  ImageList_SetIconSize        = _ImageList_SetIconSize@12           @80
     86  ImageList_SetImageCount      = _ImageList_SetImageCount@8          @81
     87  ImageList_SetOverlayImage    = _ImageList_SetOverlayImage@12       @82
     88  ImageList_Write              = _ImageList_Write@8                  @83
     89  InitCommonControlsEx         = _InitCommonControlsEx@4             @84
     90  InitMUILanguage              = _InitMUILanguage@4                  @85
     91  InitializeFlatSB             = _InitializeFlatSB@4                 @86
     92  PropertySheet                = _PropertySheetA@4                   @87
     93  PropertySheetA               = _PropertySheetA@4                   @88
     94  PropertySheetW               = _PropertySheetW@4                   @89
     95  UninitializeFlatSB           = _UninitializeFlatSB@4               @90
     96  _TrackMouseEvent             = __TrackMouseEvent@4                 @91
    9997
    10098
     
    102100  CreateMRUListA      = _CreateMRUListA@4          @151
    103101; ordinals????
    104   FreeMRUListA        = _FreeMRUListA@4            @152
     102  FreeMRUList         = _FreeMRUList@4             @152
    105103  AddMRUStringA       = _AddMRUStringA@8           @153
    106104  EnumMRUListA        = _EnumMRUListA@16           @154
     
    180178                        _COMCTL32_390@16           @390 NONAME
    181179
    182 ;400 stub CreateMRUListW@4
    183 ;401 stub AddMRUStringW@8
    184 ;402 stub FindMRUStringW@12
    185 ;403 stub EnumMRUListW@16
    186 ;404 stub CreateMRUListLazyW@16
     180  CreateMRUListW      = _CreateMRUListW@4          @400
     181  AddMRUStringW       = _AddMRUStringW@8           @401
     182  FindMRUStringW      = _FindMRUStringW@12         @402
     183  EnumMRUListW        = _EnumMRUListW@16           @403
     184  CreateMRUListLazyW  = _CreateMRUListLazyW@16     @404
    187185
    188186                        _COMCTL32_410@16           @410 NONAME
     
    191189                        _COMCTL32_413@16           @413 NONAME
    192190                        _COMCTL32_415@20           @415 NONAME
     191
     192                        _COMCTL32_419@16           @419 NONAME
     193
  • trunk/src/comctl32/comctl32.h

    r5630 r7815  
    1 /* $Id: comctl32.h,v 1.20 2001-04-29 10:30:56 sandervl Exp $ */
     1/* $Id: comctl32.h,v 1.21 2002-02-06 17:23:18 sandervl Exp $ */
    22/*
    33 * Win32 common controls implementation
     
    2626#define NO_ULONG
    2727#include <misc.h>
     28
     29#ifndef __cplusplus
     30#undef inline
     31#define inline
     32#endif
     33
     34extern HBRUSH  COMCTL32_hPattern55AABrush;
    2835
    2936#ifdef __cplusplus
  • trunk/src/comctl32/comctl32undoc.c

    r7508 r7815  
    2323#include <stdlib.h> /* atoi */
    2424#include <ctype.h>
     25#include <limits.h>
    2526
    2627#include "commctrl.h"
     
    3738DEFAULT_DEBUG_CHANNEL(commctrl);
    3839
     40
    3941extern HANDLE COMCTL32_hHeap; /* handle to the private heap */
    4042
     
    5658typedef HRESULT (* CALLBACK DPALOADPROC)(LPLOADDATA,IStream*,LPARAM);
    5759#else
    58 typedef HRESULT CALLBACK (*DPALOADPROC)(LPLOADDATA,IStream*,LPARAM);
     60typedef HRESULT (CALLBACK *DPALOADPROC)(LPLOADDATA,IStream*,LPARAM);
    5961#endif
    6062
     
    99101    position.s.HighPart = 0;
    100102
     103    /*
     104     * Zero out our streamData
     105     */
     106    memset(&streamData,0,sizeof(STREAMDATA));
     107
    101108    errCode = IStream_Seek (pStream, position, STREAM_SEEK_CUR, &newPosition);
    102109    if (errCode != S_OK)
     
    110117           streamData.dwSize, streamData.dwData2, streamData.dwItems);
    111118
    112     if (lParam < sizeof(STREAMDATA) ||
     119    if ( ulRead < sizeof(STREAMDATA) ||
     120    lParam < sizeof(STREAMDATA) ||
    113121        streamData.dwSize < sizeof(STREAMDATA) ||
    114122        streamData.dwData2 < 1) {
    115123        errCode = E_FAIL;
    116124    }
     125
     126    if (streamData.dwItems > (UINT_MAX / 2 / sizeof(VOID*))) /* 536870911 */
     127        return E_OUTOFMEMORY;
    117128
    118129    /* create the dpa */
     
    261272        else if (nResult < 0)
    262273        {
    263             if (!dwFlags & 8)
     274            if (!(dwFlags & 8))
    264275            {
    265276                PVOID ptr;
     
    274285        else
    275286        {
    276             if (!dwFlags & 4)
     287            if (!(dwFlags & 4))
    277288            {
    278289                PVOID ptr;
     
    414425 */
    415426
    416 #ifdef __WIN32OS2__
    417 #include <wine\undoccomctl32.h>
    418 #else
    419 typedef struct tagCREATEMRULIST
     427typedef struct tagCREATEMRULISTA
    420428{
    421429    DWORD  cbSize;        /* size of struct */
     
    425433    LPCSTR lpszSubKey;    /* reg. subkey */
    426434    PROC   lpfnCompare;   /* item compare proc */
    427 } CREATEMRULIST, *LPCREATEMRULIST;
     435} CREATEMRULISTA, *LPCREATEMRULISTA;
     436
     437typedef struct tagCREATEMRULISTW
     438{
     439    DWORD   cbSize;        /* size of struct */
     440    DWORD   nMaxItems;     /* max no. of items in list */
     441    DWORD   dwFlags;       /* see below */
     442    HKEY    hKey;          /* root reg. key under which list is saved */
     443    LPCWSTR lpszSubKey;    /* reg. subkey */
     444    PROC    lpfnCompare;   /* item compare proc */
     445} CREATEMRULISTW, *LPCREATEMRULISTW;
    428446
    429447/* dwFlags */
     
    452470typedef struct tagWINEMRULIST
    453471{
    454     CREATEMRULIST  extview;     /* original create information       */
     472    CREATEMRULISTW extview;     /* original create information       */
     473    BOOL           isUnicode;   /* is compare fn Unicode */
    455474    DWORD          wineFlags;   /* internal flags                    */
    456475    DWORD          cursize;     /* current size of realMRU           */
     
    463482#define WMRUF_CHANGED  0x0001   /* MRU list has changed              */
    464483
    465 HANDLE WINAPI
    466 CreateMRUListLazyA (LPCREATEMRULIST lpcml, DWORD dwParam2,
    467                     DWORD dwParam3, DWORD dwParam4);
    468 #endif
    469 
    470484/**************************************************************************
    471485 *              MRU_SaveChanged - Localize MRU saving code
     
    476490    INT i, err;
    477491    HKEY newkey;
    478     CHAR realname[2];
     492    WCHAR realname[2];
    479493    LPWINEMRUITEM witem;
     494    WCHAR emptyW[] = {'\0'};
    480495
    481496    /* or should we do the following instead of RegOpenKeyEx:
     
    483498
    484499    /* open the sub key */
    485     if ((err = RegOpenKeyExA( mp->extview.hKey, mp->extview.lpszSubKey,
    486                                0, KEY_WRITE, &newkey))) {
     500    if ((err = RegOpenKeyExW( mp->extview.hKey, mp->extview.lpszSubKey,
     501                              0, KEY_WRITE, &newkey))) {
    487502        /* not present - what to do ??? */
    488503        ERR("Can not open key, error=%d, attempting to create\n",
    489504            err);
    490         if ((err = RegCreateKeyExA( mp->extview.hKey, mp->extview.lpszSubKey,
     505        if ((err = RegCreateKeyExW( mp->extview.hKey, mp->extview.lpszSubKey,
    491506                                    0,
    492                                     "",
     507                                    emptyW,
    493508                                    REG_OPTION_NON_VOLATILE,
    494509                                    KEY_READ | KEY_WRITE,
     
    497512                                    0))) {
    498513            ERR("failed to create key /%s/, err=%d\n",
    499                 mp->extview.lpszSubKey, err);
     514                debugstr_w(mp->extview.lpszSubKey), err);
    500515            return;
    501516        }
     
    504519        mp->wineFlags &= ~WMRUF_CHANGED;
    505520        err = RegSetValueExA(newkey, "MRUList", 0, REG_SZ,
    506                              mp->realMRU, lstrlenA(mp->realMRU) + 1);
     521                             mp->realMRU, strlen(mp->realMRU) + 1);
    507522        if (err) {
    508523            ERR("error saving MRUList, err=%d\n", err);
     
    516531            witem->itemFlag &= ~WMRUIF_CHANGED;
    517532            realname[0] = 'a' + i;
    518             err = RegSetValueExA(newkey, realname, 0,
     533            err = RegSetValueExW(newkey, realname, 0,
    519534                                 (mp->extview.dwFlags & MRUF_BINARY_LIST) ?
    520535                                 REG_BINARY : REG_SZ,
    521536                                 &witem->datastart, witem->size);
    522537            if (err) {
    523                 ERR("error saving /%s/, err=%d\n", realname, err);
     538                ERR("error saving /%s/, err=%d\n", debugstr_w(realname), err);
    524539            }
    525540            TRACE("saving value for name /%s/ size=%ld\n",
    526                   realname, witem->size);
     541                  debugstr_w(realname), witem->size);
    527542        }
    528543    }
     
    531546
    532547/**************************************************************************
    533  *              CreateMRUListA [COMCTL32.151]
    534  *
    535  * PARAMS
    536  *     lpcml [I] ptr to CREATEMRULIST structure.
    537  *
    538  * RETURNS
    539  *     Handle to MRU list.
    540  */
    541 HANDLE WINAPI
    542 CreateMRUListA (LPCREATEMRULIST lpcml)
    543 {
    544      return CreateMRUListLazyA (lpcml, 0, 0, 0);
    545 }
    546 
    547 /**************************************************************************
    548548 *              FreeMRUList [COMCTL32.152]
    549549 *
     
    553553 */
    554554DWORD WINAPI
    555 FreeMRUListA (HANDLE hMRUList)
     555FreeMRUList (HANDLE hMRUList)
    556556{
    557557    LPWINEMRULIST mp = (LPWINEMRULIST)hMRUList;
     
    570570    COMCTL32_Free(mp->realMRU);
    571571    COMCTL32_Free(mp->array);
     572    COMCTL32_Free((LPWSTR)mp->extview.lpszSubKey);
    572573    return COMCTL32_Free(mp);
    573574}
     
    595596    LPWINEMRULIST mp = (LPWINEMRULIST)hList;
    596597    INT i, ret;
     598    LPSTR dataA = NULL;
    597599
    598600    if (!mp->extview.lpfnCompare) {
    599601        ERR("MRU list not properly created. No compare procedure.\n");
    600602        return -1;
     603    }
     604
     605    if(!(mp->extview.dwFlags & MRUF_BINARY_LIST) && !mp->isUnicode) {
     606        DWORD len = WideCharToMultiByte(CP_ACP, 0, lpData, -1,
     607                                        NULL, 0, NULL, NULL);
     608        dataA = COMCTL32_Alloc(len);
     609        WideCharToMultiByte(CP_ACP, 0, lpData, -1, dataA, len, NULL, NULL);
    601610    }
    602611
     
    608617        }
    609618        else {
    610             if (!mp->extview.lpfnCompare(lpData, &mp->array[i]->datastart))
    611                 break;
     619            if(mp->isUnicode) {
     620                if (!mp->extview.lpfnCompare(lpData, &mp->array[i]->datastart))
     621                    break;
     622            } else {
     623                DWORD len = WideCharToMultiByte(CP_ACP, 0,
     624                                                (LPWSTR)&mp->array[i]->datastart, -1,
     625                                                NULL, 0, NULL, NULL);
     626                LPSTR itemA = COMCTL32_Alloc(len);
     627                INT cmp;
     628                WideCharToMultiByte(CP_ACP, 0, (LPWSTR)&mp->array[i]->datastart, -1,
     629                                    itemA, len, NULL, NULL);
     630
     631                cmp = mp->extview.lpfnCompare(dataA, itemA);
     632                COMCTL32_Free(itemA);
     633                if(!cmp)
     634                    break;
     635            }
    612636        }
    613637    }
     638    if(dataA)
     639        COMCTL32_Free(dataA);
    614640    if (i < mp->cursize)
    615641        ret = i;
     
    693719
    694720/**************************************************************************
    695  *              AddMRUStringA [COMCTL32.153]
     721 *              AddMRUStringW [COMCTL32.401]
    696722 *
    697723 * Add item to MRU string list.  If item already exists in list them it is
     
    708734 */
    709735INT WINAPI
     736AddMRUStringW(HANDLE hList, LPCWSTR lpszString)
     737{
     738    FIXME("(%08x, %s) empty stub!\n", hList, debugstr_w(lpszString));
     739
     740    return 0;
     741}
     742
     743/**************************************************************************
     744 *              AddMRUStringA [COMCTL32.153]
     745 */
     746INT WINAPI
    710747AddMRUStringA(HANDLE hList, LPCSTR lpszString)
    711748{
     
    732769    FIXME("(%08x, %d): stub\n", hList, nItemPos);
    733770    return TRUE;
     771}
     772
     773/**************************************************************************
     774 *                  FindMRUStringW [COMCTL32.402]
     775 */
     776INT WINAPI
     777FindMRUStringW (HANDLE hList, LPCWSTR lpszString, LPINT lpRegNum)
     778{
     779  FIXME("stub\n");
     780  return -1;
    734781}
    735782
     
    752799FindMRUStringA (HANDLE hList, LPCSTR lpszString, LPINT lpRegNum)
    753800{
    754     return FindMRUData(hList, (LPVOID)lpszString, lstrlenA(lpszString),
    755                        lpRegNum);
    756 }
    757 
    758 /**************************************************************************
    759  *                  CreateMRUListLazyA [COMCTL32.157]
    760  */
    761 HANDLE WINAPI
    762 CreateMRUListLazyA (LPCREATEMRULIST lpcml, DWORD dwParam2, DWORD dwParam3, DWORD dwParam4)
    763 {
    764     LPWINEMRULIST mp;
     801    DWORD len = MultiByteToWideChar(CP_ACP, 0, lpszString, -1, NULL, 0);
     802    LPWSTR stringW = COMCTL32_Alloc(len * sizeof(WCHAR));
     803    INT ret;
     804
     805    MultiByteToWideChar(CP_ACP, 0, lpszString, -1, stringW, len);
     806    ret = FindMRUData(hList, stringW, len * sizeof(WCHAR), lpRegNum);
     807    COMCTL32_Free(stringW);
     808    return ret;
     809}
     810
     811/*************************************************************************
     812 *                 CreateMRUListLazy_common
     813 */
     814HANDLE CreateMRUListLazy_common(LPWINEMRULIST mp)
     815{
    765816    INT i, err;
    766817    HKEY newkey;
    767818    DWORD datasize, dwdisp;
    768     CHAR realname[2];
     819    WCHAR realname[2];
    769820    LPWINEMRUITEM witem;
    770821    DWORD type;
    771 
    772     if (lpcml == NULL)
    773         return 0;
    774 
    775     if (lpcml->cbSize < sizeof(CREATEMRULIST))
    776         return 0;
    777 
    778     mp = (LPWINEMRULIST) COMCTL32_Alloc(sizeof(WINEMRULIST));
    779     memcpy(mp, lpcml, sizeof(CREATEMRULIST));
    780 
    781     /* get space to save indexes that will turn into names
     822    WCHAR emptyW[] = {'\0'};
     823
     824    /* get space to save indices that will turn into names
    782825     * but in order of most to least recently used
    783826     */
     
    791834
    792835    /* open the sub key */
    793      if ((err = RegCreateKeyExA( mp->extview.hKey, mp->extview.lpszSubKey,
    794                                0,
    795                                 "",
     836    if ((err = RegCreateKeyExW( mp->extview.hKey, mp->extview.lpszSubKey,
     837                                0,
     838                                emptyW,
    796839                                REG_OPTION_NON_VOLATILE,
    797840                                KEY_READ | KEY_WRITE,
     
    801844        /* error - what to do ??? */
    802845        ERR("(%lu %lu %lx %lx \"%s\" %p): Can not open key, error=%d\n",
    803             lpcml->cbSize, lpcml->nMaxItems, lpcml->dwFlags,
    804             (DWORD)lpcml->hKey, lpcml->lpszSubKey, lpcml->lpfnCompare,
    805             err);
     846            mp->extview.cbSize, mp->extview.nMaxItems, mp->extview.dwFlags,
     847            (DWORD)mp->extview.hKey, debugstr_w(mp->extview.lpszSubKey),
     848                                 mp->extview.lpfnCompare, err);
    806849        return 0;
    807850    }
     
    826869        for(i=0; i<mp->cursize; i++) {
    827870            realname[0] = 'a' + i;
    828             if(RegQueryValueExA( newkey, realname, 0, &type, 0, &datasize)) {
     871            if(RegQueryValueExW( newkey, realname, 0, &type, 0, &datasize)) {
    829872                /* not present - what to do ??? */
    830                 ERR("Key %s not found 1\n", realname);
     873                ERR("Key %s not found 1\n", debugstr_w(realname));
    831874            }
    832875            mp->array[i] = witem = (LPWINEMRUITEM)COMCTL32_Alloc(datasize +
    833876                                                                 sizeof(WINEMRUITEM));
    834877            witem->size = datasize;
    835             if(RegQueryValueExA( newkey, realname, 0, &type,
     878            if(RegQueryValueExW( newkey, realname, 0, &type,
    836879                                 &witem->datastart, &datasize)) {
    837880                /* not present - what to do ??? */
    838                 ERR("Key %s not found 2\n", realname);
     881                ERR("Key %s not found 2\n", debugstr_w(realname));
    839882            }
    840883        }
     
    845888
    846889    TRACE("(%lu %lu %lx %lx \"%s\" %p): Current Size = %ld\n",
    847           lpcml->cbSize, lpcml->nMaxItems, lpcml->dwFlags,
    848           (DWORD)lpcml->hKey, lpcml->lpszSubKey, lpcml->lpfnCompare,
    849           mp->cursize);
    850 
     890          mp->extview.cbSize, mp->extview.nMaxItems, mp->extview.dwFlags,
     891          (DWORD)mp->extview.hKey, debugstr_w(mp->extview.lpszSubKey),
     892          mp->extview.lpfnCompare, mp->cursize);
    851893    return (HANDLE)mp;
    852894}
    853895
    854896/**************************************************************************
    855  *                EnumMRUListA [COMCTL32.154]
    856  *
     897 *                  CreateMRUListLazyW [COMCTL32.404]
     898 */
     899HANDLE WINAPI
     900CreateMRUListLazyW (LPCREATEMRULISTW lpcml, DWORD dwParam2, DWORD dwParam3, DWORD dwParam4)
     901{
     902    LPWINEMRULIST mp;
     903
     904    if (lpcml == NULL)
     905        return 0;
     906
     907    if (lpcml->cbSize < sizeof(CREATEMRULISTW))
     908        return 0;
     909
     910    mp = (LPWINEMRULIST) COMCTL32_Alloc(sizeof(WINEMRULIST));
     911    memcpy(&mp->extview, lpcml, sizeof(CREATEMRULISTW));
     912    mp->extview.lpszSubKey = COMCTL32_Alloc((strlenW(lpcml->lpszSubKey) + 1) *
     913                                            sizeof(WCHAR));
     914    strcpyW((LPWSTR)mp->extview.lpszSubKey, lpcml->lpszSubKey);
     915    mp->isUnicode = TRUE;
     916
     917    return CreateMRUListLazy_common(mp);   
     918}
     919
     920/**************************************************************************
     921 *                  CreateMRUListLazyA [COMCTL32.157]
     922 */
     923HANDLE WINAPI
     924CreateMRUListLazyA (LPCREATEMRULISTA lpcml, DWORD dwParam2, DWORD dwParam3, DWORD dwParam4)
     925{
     926    LPWINEMRULIST mp;
     927    DWORD len;
     928
     929    if (lpcml == NULL)
     930        return 0;
     931
     932    if (lpcml->cbSize < sizeof(CREATEMRULISTA))
     933        return 0;
     934
     935    mp = (LPWINEMRULIST) COMCTL32_Alloc(sizeof(WINEMRULIST));
     936    memcpy(&mp->extview, lpcml, sizeof(CREATEMRULISTW));
     937    len = MultiByteToWideChar(CP_ACP, 0, lpcml->lpszSubKey, -1, NULL, 0);
     938    mp->extview.lpszSubKey = COMCTL32_Alloc(len * sizeof(WCHAR));
     939    MultiByteToWideChar(CP_ACP, 0, lpcml->lpszSubKey, -1,
     940                        (LPWSTR)mp->extview.lpszSubKey, len);
     941    mp->isUnicode = FALSE;
     942    return CreateMRUListLazy_common(mp);
     943}
     944
     945/**************************************************************************
     946 *              CreateMRUListW [COMCTL32.400]
     947 *
     948 * PARAMS
     949 *     lpcml [I] ptr to CREATEMRULIST structure.
     950 *
     951 * RETURNS
     952 *     Handle to MRU list.
     953 */
     954HANDLE WINAPI
     955CreateMRUListW (LPCREATEMRULISTW lpcml)
     956{
     957    return CreateMRUListLazyW(lpcml, 0, 0, 0);
     958}
     959
     960/**************************************************************************
     961 *              CreateMRUListA [COMCTL32.151]
     962 */
     963HANDLE WINAPI
     964CreateMRUListA (LPCREATEMRULISTA lpcml)
     965{
     966     return CreateMRUListLazyA (lpcml, 0, 0, 0);
     967}
     968
     969
     970/**************************************************************************
     971 *                EnumMRUListW [COMCTL32.403]
     972 *
    857973 * Enumerate item in a list
    858974 *
     
    870986 *    the list.
    871987 */
    872 INT WINAPI EnumMRUListA(HANDLE hList, INT nItemPos, LPVOID lpBuffer,
     988INT WINAPI EnumMRUListW(HANDLE hList, INT nItemPos, LPVOID lpBuffer,
    873989DWORD nBufferSize)
    874990{
     
    8891005    return datasize;
    8901006}
     1007
     1008/**************************************************************************
     1009 *                EnumMRUListA [COMCTL32.154]
     1010 *
     1011 */
     1012INT WINAPI EnumMRUListA(HANDLE hList, INT nItemPos, LPVOID lpBuffer,
     1013DWORD nBufferSize)
     1014{
     1015    LPWINEMRULIST mp = (LPWINEMRULIST) hList;
     1016    LPWINEMRUITEM witem;
     1017    INT desired, datasize;
     1018    DWORD lenA;
     1019
     1020    if (nItemPos >= mp->cursize) return -1;
     1021    if ((nItemPos < 0) || !lpBuffer) return mp->cursize;
     1022    desired = mp->realMRU[nItemPos];
     1023    desired -= 'a';
     1024    TRACE("nItemPos=%d, desired=%d\n", nItemPos, desired);
     1025    witem = mp->array[desired];
     1026    if(mp->extview.dwFlags & MRUF_BINARY_LIST) {
     1027        datasize = min( witem->size, nBufferSize );
     1028        memcpy( lpBuffer, &witem->datastart, datasize);
     1029    } else {
     1030        lenA = WideCharToMultiByte(CP_ACP, 0, (LPWSTR)&witem->datastart, -1,
     1031                                   NULL, 0, NULL, NULL);
     1032        datasize = min( witem->size, nBufferSize );
     1033        WideCharToMultiByte(CP_ACP, 0, (LPWSTR)&witem->datastart, -1,
     1034                            lpBuffer, datasize, NULL, NULL);
     1035    }
     1036    TRACE("(%08x, %d, %p, %ld): returning len=%d\n",
     1037          hList, nItemPos, lpBuffer, nBufferSize, datasize);
     1038    return datasize;
     1039}
     1040 
    8911041
    8921042/**************************************************************************
     
    13281478DSA_InsertItem (const HDSA hdsa, INT nIndex, LPVOID pSrc)
    13291479{
    1330     INT   nNewItems, nSize, i;
     1480    INT   nNewItems, nSize;
    13311481    LPVOID  lpTemp, lpDest;
    1332     LPDWORD p;
    13331482   
    13341483    TRACE("(%p %d %p)\n", hdsa, nIndex, pSrc);
     
    13371486        return -1;
    13381487
    1339     for (i = 0; i < hdsa->nItemSize; i += 4) {
    1340         p = *(DWORD**)((char *) pSrc + i);
    1341         if (IsBadStringPtrA ((char*)p, 256))
    1342             TRACE("-- %d=%p\n", i, (DWORD*)p);
    1343         else
    1344             TRACE("-- %d=%p [%s]\n", i, p, debugstr_a((char*)p));
    1345     }
    1346    
    13471488    /* when nIndex >= nItemCount then append */
    13481489    if (nIndex >= hdsa->nItemCount)
     
    21622303            if (hwndParent) {
    21632304                hwndParent = GetWindow (lpNotify->hwndFrom, GW_OWNER);
    2164                 if (hwndParent)
    2165                     idFrom = GetDlgCtrlID (lpNotify->hwndFrom);
     2305                /* the following is done even if the return from above
     2306                 * is zero.  GLA 12/2001 */
     2307                idFrom = GetDlgCtrlID (lpNotify->hwndFrom);
    21662308            }
    21672309        }
     
    21822324 *
    21832325 * PARAMS
     2326 *     hwndTo   [I]
    21842327 *     hwndFrom [I]
    2185  *     hwndTo   [I]
    21862328 *     uCode    [I]
    21872329 *     lpHdr    [I]
     
    21932335
    21942336LRESULT WINAPI
    2195 COMCTL32_SendNotify (HWND hwndFrom, HWND hwndTo,
     2337COMCTL32_SendNotify (HWND hwndTo, HWND hwndFrom,
    21962338                     UINT uCode, LPNMHDR lpHdr)
    21972339{
     
    21992341
    22002342    TRACE("(0x%04x 0x%04x %d %p)\n",
    2201            hwndFrom, hwndTo, uCode, lpHdr);
     2343           hwndTo, hwndFrom, uCode, lpHdr);
    22022344
    22032345    notify.hwndFrom = hwndFrom;
     
    26452787}
    26462788
    2647 #ifdef __WIN32OS2__
    2648 DWORD WINAPI COMCTL32_389(DWORD x1, DWORD x2)
    2649 {
    2650    dprintf(("comctl32_389: %x %X not implemented!!", x1, x2));
    2651    return 0; //NT 4 comctl32 returns 0
    2652 }
    2653 
    2654 DWORD WINAPI COMCTL32_390(DWORD x1, DWORD x2, DWORD x3, DWORD x4)
    2655 {
    2656   dprintf(("comctl32_390: %x %x %x %x not implemented!!", x1, x2, x3, x4));
    2657 
    2658   /* Pseudo Assembler
    2659    push [esp+arg_C]
    2660    mov  eax, [esp+4+arg_0]
    2661    push [esp+4+arg_8]
    2662    mov  dword ptr [eax+1A8h], 1
    2663    push [esp+8+arg_4]
    2664    push dword ptr [eax + 38h]
    2665    call ds:SetDIBColorTable
    2666    retn 10h
    2667   */
    2668 
    2669    return 0;
    2670 }
    2671 #endif
     2789/**************************************************************************
     2790 * @ [COMCTL32.419]
     2791 *
     2792 * FIXME: What's this supposed to do?
     2793 */
     2794
     2795BOOL WINAPI COMCTL32_419( DWORD a, DWORD b, DWORD c, DWORD d)
     2796{
     2797
     2798   FIXME("(%lx, %lx, %lx, %lx): stub!\n", a, b, c, d);
     2799
     2800   return TRUE;
     2801}
     2802
  • trunk/src/comctl32/imagelist.c

    r7508 r7815  
    44 *  Copyright 1998 Eric Kohl
    55 *            2000 Jason Mawdsley.
     6 *            2001 Michael Stefaniuc
     7 *            2001 Charles Loep for CodeWeavers
    68 *
    79 *  TODO:
    810 *    - Fix ImageList_DrawIndirect (xBitmap, yBitmap, rgbFg, rgbBk, dwRop).
    911 *    - Fix ImageList_GetIcon.
    10  *    - Fix drag functions.
    11  *    - Fix ImageList_Write.
    1212 *    - Fix ImageList_SetFilter (undocumented).
    1313 *      BTW does anybody know anything about this function???
     
    2424 */
    2525
     26#include <stdlib.h>
    2627#include <string.h>
    2728#include "winerror.h"
     
    3637
    3738
    38 #define _MAX(a,b) (((a)>(b))?(a):(b))
    39 #define _MIN(a,b) (((a)>(b))?(b):(a))
    40 
    4139#define MAX_OVERLAYIMAGE 15
    4240
    43 
    4441/* internal image list data used for Drag & Drop operations */
    45 
    46 static HIMAGELIST himlInternalDrag = NULL;
    47 static INT      nInternalDragHotspotX = 0;
    48 static INT      nInternalDragHotspotY = 0;
    49 
    50 static HWND     hwndInternalDrag = 0;
    51 static INT      xInternalPos = 0;
    52 static INT      yInternalPos = 0;
    53 
    54 static HDC      hdcBackBuffer = 0;
    55 static HBITMAP  hbmBackBuffer = 0;
     42typedef struct
     43{
     44    HWND        hwnd;
     45    HIMAGELIST  himl;
     46    /* position of the drag image relative to the window */
     47    INT         x;
     48    INT         y;
     49    /* offset of the hotspot relative to the origin of the image */
     50    INT         dxHotspot;
     51    INT         dyHotspot;
     52    /* is the drag image visible */
     53    BOOL        bShow;
     54    /* saved background */
     55    HBITMAP     hbmBg;
     56} INTERNALDRAG;
     57
     58static INTERNALDRAG InternalDrag = { 0, 0, 0, 0, 0, 0, FALSE, 0 };
     59
    5660
    5761
     
    7882    INT     nNewWidth, nNewCount;
    7983
    80     if ((himl->cCurImage + nImageCount < himl->cMaxImage)
     84    if ((himl->cCurImage + nImageCount <= himl->cMaxImage)
    8185        && (himl->cy >= cy))
    8286        return;
     
    459463    }
    460464}
    461 
    462 
    463 
    464465
    465466
     
    707708{
    708709    HDC hdcSrc, hdcDst;
    709 
    710     FIXME("partially implemented!\n");
     710    INT cx, cy;
     711
     712    TRACE("(himlTrack=%p iTrack=%d dx=%d dy=%d)\n", himlTrack, iTrack,
     713          dxHotspot, dyHotspot);
    711714
    712715    if (himlTrack == NULL)
    713716        return FALSE;
    714717
    715     if (himlInternalDrag)
     718    if (InternalDrag.himl)
    716719        ImageList_EndDrag ();
    717720
    718     himlInternalDrag =
    719         ImageList_Create (himlTrack->cx, himlTrack->cy,
    720                           himlTrack->flags, 1, 1);
    721     if (himlInternalDrag == NULL) {
     721    cx = himlTrack->cx;
     722    cy = himlTrack->cy;
     723
     724    InternalDrag.himl = ImageList_Create (cx, cy, himlTrack->flags, 1, 1);
     725    if (InternalDrag.himl == NULL) {
    722726        ERR("Error creating drag image list!\n");
    723727        return FALSE;
    724728    }
    725729
    726     nInternalDragHotspotX = dxHotspot;
    727     nInternalDragHotspotY = dyHotspot;
     730    InternalDrag.dxHotspot = dxHotspot;
     731    InternalDrag.dyHotspot = dyHotspot;
    728732
    729733    hdcSrc = CreateCompatibleDC (0);
     
    732736    /* copy image */
    733737    SelectObject (hdcSrc, himlTrack->hbmImage);
    734     SelectObject (hdcDst, himlInternalDrag->hbmImage);
    735     StretchBlt (hdcDst, 0, 0, himlInternalDrag->cx, himlInternalDrag->cy, hdcSrc,
    736                   iTrack * himlTrack->cx, 0, himlTrack->cx, himlTrack->cy, SRCCOPY);
     738    SelectObject (hdcDst, InternalDrag.himl->hbmImage);
     739    BitBlt (hdcDst, 0, 0, cx, cy, hdcSrc, iTrack * cx, 0, SRCCOPY);
    737740
    738741    /* copy mask */
    739742    SelectObject (hdcSrc, himlTrack->hbmMask);
    740     SelectObject (hdcDst, himlInternalDrag->hbmMask);
    741     StretchBlt (hdcDst, 0, 0, himlInternalDrag->cx, himlInternalDrag->cy, hdcSrc,
    742                   iTrack * himlTrack->cx, 0, himlTrack->cx, himlTrack->cy, SRCCOPY);
     743    SelectObject (hdcDst, InternalDrag.himl->hbmMask);
     744    BitBlt (hdcDst, 0, 0, cx, cy, hdcSrc, iTrack * cx, 0, SRCCOPY);
    743745
    744746    DeleteDC (hdcSrc);
    745747    DeleteDC (hdcDst);
    746748
    747     himlInternalDrag->cCurImage = 1;
     749    InternalDrag.himl->cCurImage = 1;
    748750
    749751    return TRUE;
     
    10321034ImageList_DragEnter (HWND hwndLock, INT x, INT y)
    10331035{
    1034     if (himlInternalDrag == NULL)
     1036    TRACE("(hwnd=%#x x=%d y=%d)\n", hwndLock, x, y);
     1037
     1038    if (InternalDrag.himl == NULL)
    10351039        return FALSE;
    10361040
    10371041    if (hwndLock)
    1038         hwndInternalDrag = hwndLock;
     1042        InternalDrag.hwnd = hwndLock;
    10391043    else
    1040         hwndInternalDrag = GetDesktopWindow ();
    1041 
    1042     xInternalPos = x;
    1043     yInternalPos = y;
    1044 
    1045     hdcBackBuffer = CreateCompatibleDC (0);
    1046     hbmBackBuffer = CreateCompatibleBitmap (hdcBackBuffer,
    1047                 himlInternalDrag->cx, himlInternalDrag->cy);
    1048 
    1049     ImageList_DragShowNolock (TRUE);
    1050 
    1051     return FALSE;
     1044        InternalDrag.hwnd = GetDesktopWindow ();
     1045
     1046    InternalDrag.x = x;
     1047    InternalDrag.y = y;
     1048
     1049    /* draw the drag image and save the background */
     1050    if (!ImageList_DragShowNolock(TRUE)) {
     1051        return FALSE;
     1052    }
     1053
     1054    return TRUE;
    10521055}
    10531056
     
    10701073{
    10711074    if (hwndLock)
    1072         hwndInternalDrag = hwndLock;
     1075        InternalDrag.hwnd = hwndLock;
    10731076    else
    1074         hwndInternalDrag = GetDesktopWindow ();
     1077        InternalDrag.hwnd = GetDesktopWindow ();
    10751078
    10761079    ImageList_DragShowNolock (FALSE);
    1077 
    1078     DeleteDC (hdcBackBuffer);
    1079     DeleteObject (hbmBackBuffer);
    10801080
    10811081    return TRUE;
     
    10991099 *     The position of the drag image is relative to the window, not
    11001100 *     the client area.
     1101 *
     1102 * BUGS
     1103 *     The drag image should be drawn semitransparent.
    11011104 */
    11021105
     
    11041107ImageList_DragMove (INT x, INT y)
    11051108{
    1106     ImageList_DragShowNolock (FALSE);
    1107 
    1108     xInternalPos = x;
    1109     yInternalPos = y;
    1110 
    1111     ImageList_DragShowNolock (TRUE);
    1112 
    1113     return FALSE;
     1109    TRACE("(x=%d y=%d)\n", x, y);
     1110
     1111    if (!InternalDrag.himl) {
     1112        return FALSE;
     1113    }
     1114
     1115    /* draw/update the drag image */
     1116    if (InternalDrag.bShow) {
     1117        HDC hdcDrag;
     1118        HDC hdcOffScreen;
     1119        HDC hdcBg;
     1120        HBITMAP hbmOffScreen;
     1121        INT origNewX, origNewY;
     1122        INT origOldX, origOldY;
     1123        INT origRegX, origRegY;
     1124        INT sizeRegX, sizeRegY;
     1125       
     1126
     1127        /* calculate the update region */
     1128        origNewX = x - InternalDrag.dxHotspot;
     1129        origNewY = y - InternalDrag.dyHotspot;
     1130        origOldX = InternalDrag.x - InternalDrag.dxHotspot;
     1131        origOldY = InternalDrag.y - InternalDrag.dyHotspot;
     1132        origRegX = min(origNewX, origOldX);
     1133        origRegY = min(origNewY, origOldY);
     1134        sizeRegX = InternalDrag.himl->cx + abs(x - InternalDrag.x);
     1135        sizeRegY = InternalDrag.himl->cy + abs(y - InternalDrag.y);
     1136
     1137        hdcDrag = GetDCEx(InternalDrag.hwnd, 0,
     1138                          DCX_WINDOW | DCX_CACHE | DCX_LOCKWINDOWUPDATE);
     1139        hdcOffScreen = CreateCompatibleDC(hdcDrag);
     1140        hdcBg = CreateCompatibleDC(hdcDrag);
     1141
     1142        hbmOffScreen = CreateCompatibleBitmap(hdcDrag, sizeRegX, sizeRegY);
     1143        SelectObject(hdcOffScreen, hbmOffScreen);
     1144        SelectObject(hdcBg, InternalDrag.hbmBg);
     1145
     1146        /* get the actual background of the update region */
     1147        BitBlt(hdcOffScreen, 0, 0, sizeRegX, sizeRegY, hdcDrag,
     1148               origRegX, origRegY, SRCCOPY);
     1149        /* erase the old image */
     1150        BitBlt(hdcOffScreen, origOldX - origRegX, origOldY - origRegY,
     1151               InternalDrag.himl->cx, InternalDrag.himl->cy, hdcBg, 0, 0,
     1152               SRCCOPY);
     1153        /* save the background */
     1154        BitBlt(hdcBg, 0, 0, InternalDrag.himl->cx, InternalDrag.himl->cy,
     1155               hdcOffScreen, origNewX - origRegX, origNewY - origRegY, SRCCOPY);
     1156        /* draw the image */
     1157        /* FIXME: image should be drawn semitransparent */
     1158        ImageList_Draw(InternalDrag.himl, 0, hdcOffScreen, origNewX - origRegX,
     1159                       origNewY - origRegY, ILD_NORMAL);
     1160        /* draw the update region to the screen */
     1161        BitBlt(hdcDrag, origRegX, origRegY, sizeRegX, sizeRegY,
     1162               hdcOffScreen, 0, 0, SRCCOPY);
     1163
     1164        DeleteDC(hdcBg);
     1165        DeleteDC(hdcOffScreen);
     1166        DeleteObject(hbmOffScreen);
     1167        ReleaseDC(InternalDrag.hwnd, hdcDrag);
     1168    }
     1169
     1170    /* update the image position */
     1171    InternalDrag.x = x;
     1172    InternalDrag.y = y;
     1173
     1174    return TRUE;
    11141175}
    11151176
     
    11271188 *     Failure: FALSE
    11281189 *
    1129  * FIXME
    1130  *     semi-stub.
     1190 * BUGS
     1191 *     The drag image should be drawn semitransparent.
    11311192 */
    11321193
     
    11351196{
    11361197    HDC hdcDrag;
    1137 
    1138     FIXME("semi-stub!\n");
     1198    HDC hdcBg;
     1199    INT x, y;
     1200
    11391201    TRACE("bShow=0x%X!\n", bShow);
    11401202
    1141     hdcDrag = GetDCEx (hwndInternalDrag, 0,
     1203    /* DragImage is already visible/hidden */
     1204    if ((InternalDrag.bShow && bShow) || (!InternalDrag.bShow && !bShow)) {
     1205        return FALSE;
     1206    }
     1207
     1208    /* position of the origin of the DragImage */
     1209    x = InternalDrag.x - InternalDrag.dxHotspot;
     1210    y = InternalDrag.y - InternalDrag.dyHotspot;
     1211
     1212    hdcDrag = GetDCEx (InternalDrag.hwnd, 0,
    11421213                         DCX_WINDOW | DCX_CACHE | DCX_LOCKWINDOWUPDATE);
    1143 
     1214    if (!hdcDrag) {
     1215        return FALSE;
     1216    }
     1217
     1218    hdcBg = CreateCompatibleDC(hdcDrag);
     1219    if (!InternalDrag.hbmBg) {
     1220        InternalDrag.hbmBg = CreateCompatibleBitmap(hdcDrag,
     1221                    InternalDrag.himl->cx, InternalDrag.himl->cy);
     1222    }
     1223    SelectObject(hdcBg, InternalDrag.hbmBg);
     1224   
    11441225    if (bShow) {
    1145         /* show drag image */
    1146 
    1147         /* save background */
    1148 
    1149         /* draw drag image */
    1150 
    1151     }
    1152     else {
    1153         /* hide drag image */
    1154 
    1155         /* restore background */
    1156 
    1157     }
    1158 
    1159     ReleaseDC (hwndInternalDrag, hdcDrag);
    1160 
    1161     return FALSE;
     1226        /* save the background */
     1227        BitBlt(hdcBg, 0, 0, InternalDrag.himl->cx, InternalDrag.himl->cy,
     1228               hdcDrag, x, y, SRCCOPY);
     1229        /* show the image */
     1230        /* FIXME: this should be drawn semitransparent */
     1231        ImageList_Draw(InternalDrag.himl, 0, hdcDrag, x, y, ILD_NORMAL);
     1232    } else {
     1233        /* hide the image */
     1234        BitBlt(hdcDrag, x, y, InternalDrag.himl->cx, InternalDrag.himl->cy,
     1235               hdcBg, 0, 0, SRCCOPY);
     1236    }
     1237
     1238    InternalDrag.bShow = !InternalDrag.bShow;
     1239
     1240    DeleteDC(hdcBg);
     1241    ReleaseDC (InternalDrag.hwnd, hdcDrag);
     1242    return TRUE;
    11621243}
    11631244
     
    13931474 *     Success: TRUE
    13941475 *     Failure: FALSE
    1395  *
    1396  * BUGS
    1397  *     semi-stub.
    13981476 */
    13991477
     
    14011479ImageList_EndDrag (void)
    14021480{
    1403     FIXME("semi-stub!\n");
    1404 
    1405     if (himlInternalDrag)
    1406     {
    1407 
    1408         ImageList_Destroy (himlInternalDrag);
    1409         himlInternalDrag = NULL;
    1410 
    1411         nInternalDragHotspotX = 0;
    1412         nInternalDragHotspotY = 0;
    1413 
    1414     }
     1481    /* cleanup the InternalDrag struct */
     1482    InternalDrag.hwnd = 0;
     1483    ImageList_Destroy (InternalDrag.himl);
     1484    InternalDrag.himl = 0;
     1485    InternalDrag.x= 0;
     1486    InternalDrag.y= 0;
     1487    InternalDrag.dxHotspot = 0;
     1488    InternalDrag.dyHotspot = 0;
     1489    InternalDrag.bShow = FALSE;
     1490    DeleteObject(InternalDrag.hbmBg);
     1491    InternalDrag.hbmBg = 0;
    14151492
    14161493    return TRUE;
     
    14531530 *     Success: Handle of the drag image list.
    14541531 *     Failure: NULL.
    1455  *
    1456  * BUGS
    1457  *     semi-stub.
    14581532 */
    14591533
     
    14611535ImageList_GetDragImage (POINT *ppt, POINT *pptHotspot)
    14621536{
    1463     FIXME("semi-stub!\n");
    1464 
    1465     if (himlInternalDrag)
    1466         return (himlInternalDrag);
     1537    if (InternalDrag.himl) {
     1538        if (ppt) {
     1539            ppt->x = InternalDrag.x;
     1540            ppt->y = InternalDrag.y;
     1541        }
     1542        if (pptHotspot) {
     1543            pptHotspot->x = InternalDrag.dxHotspot;
     1544            pptHotspot->y = InternalDrag.dyHotspot;
     1545        }
     1546        return (InternalDrag.himl);
     1547    }
    14671548
    14681549    return NULL;
     1550}
     1551
     1552
     1553/*************************************************************************
     1554 * ImageList_GetFlags [COMCTL32.58]
     1555 *
     1556 * BUGS
     1557 *    Stub.
     1558 */
     1559
     1560DWORD WINAPI
     1561ImageList_GetFlags(HIMAGELIST himl)
     1562{
     1563    FIXME("(%p):empty stub\n", himl);
     1564    return 0;
    14691565}
    14701566
     
    18381934    INT      nX1, nX2;
    18391935
     1936    TRACE("(himl1=%p i1=%d himl2=%p i2=%d dx=%d dy=%d)\n", himl1, i1, himl2,
     1937           i2, dx, dy);
     1938
    18401939    if ((himl1 == NULL) || (himl2 == NULL))
    18411940        return NULL;
     
    18531952
    18541953    if (dx > 0) {
    1855         cxDst = _MAX (himl1->cx, dx + himl2->cx);
     1954        cxDst = max (himl1->cx, dx + himl2->cx);
    18561955        xOff1 = 0;
    18571956        xOff2 = dx;
    18581957    }
    18591958    else if (dx < 0) {
    1860         cxDst = _MAX (himl2->cx, himl1->cx - dx);
     1959        cxDst = max (himl2->cx, himl1->cx - dx);
    18611960        xOff1 = -dx;
    18621961        xOff2 = 0;
    18631962    }
    18641963    else {
    1865         cxDst = _MAX (himl1->cx, himl2->cx);
     1964        cxDst = max (himl1->cx, himl2->cx);
    18661965        xOff1 = 0;
    18671966        xOff2 = 0;
     
    18691968
    18701969    if (dy > 0) {
    1871         cyDst = _MAX (himl1->cy, dy + himl2->cy);
     1970        cyDst = max (himl1->cy, dy + himl2->cy);
    18721971        yOff1 = 0;
    18731972        yOff2 = dy;
    18741973    }
    18751974    else if (dy < 0) {
    1876         cyDst = _MAX (himl2->cy, himl1->cy - dy);
     1975        cyDst = max (himl2->cy, himl1->cy - dy);
    18771976        yOff1 = -dy;
    18781977        yOff2 = 0;
    18791978    }
    18801979    else {
    1881         cyDst = _MAX (himl1->cy, himl2->cy);
     1980        cyDst = max (himl1->cy, himl2->cy);
    18821981        yOff1 = 0;
    18831982        yOff2 = 0;
     
    19222021        DeleteDC (hdcSrcImage);
    19232022        DeleteDC (hdcDstImage);
     2023        himlDst->cCurImage = 1;
    19242024    }
    19252025   
     
    23802480
    23812481    if (i == -1) {
    2382         if (himl->cCurImage + 1 >= himl->cMaxImage)
     2482        if (himl->cCurImage + 1 > himl->cMaxImage)
    23832483            IMAGELIST_InternalExpandBitmaps (himl, 1, 0, 0);
    23842484
     
    24742574 *     Failure: FALSE
    24752575 *
    2476  * BUGS
    2477  *     semi-stub.
     2576 * NOTES
     2577 *     When this function is called and the drag image is visible, a
     2578 *     short flickering occurs but this matches the Win9x behavior. It is
     2579 *     possible to fix the flickering using code like in ImageList_DragMove.
    24782580 */
    24792581
     
    24832585{
    24842586    HIMAGELIST himlTemp;
    2485 
    2486     FIXME("semi-stub!\n");
    2487 
    2488     if (himlInternalDrag == NULL)
     2587    INT dx, dy;
     2588    BOOL visible;
     2589
     2590    if (InternalDrag.himl == NULL)
    24892591        return FALSE;
    24902592
    24912593    TRACE(" dxH=%d dyH=%d nX=%d nY=%d\n",
    2492            dxHotspot, dyHotspot, nInternalDragHotspotX, nInternalDragHotspotY);
    2493 
    2494     himlTemp = ImageList_Merge (himlInternalDrag, 0, himlDrag, iDrag,
    2495                                 dxHotspot, dyHotspot);
    2496 
    2497     ImageList_Destroy (himlInternalDrag);
    2498     himlInternalDrag = himlTemp;
    2499 
    2500     nInternalDragHotspotX = dxHotspot;
    2501     nInternalDragHotspotY = dyHotspot;
    2502 
    2503     return FALSE;
     2594           dxHotspot, dyHotspot, InternalDrag.dxHotspot, InternalDrag.dyHotspot);
     2595
     2596    visible = InternalDrag.bShow;
     2597
     2598    /* Calculate the offset between the origin of the old image and the
     2599     * origin of the second image.
     2600     * dxHotspot, dyHotspot is the offset of THE Hotspot (there is only one
     2601     * hotspot) to the origin of the second image.
     2602     * See M$DN for details */
     2603    dx = InternalDrag.dxHotspot - dxHotspot;
     2604    dy = InternalDrag.dyHotspot - dyHotspot;
     2605    himlTemp = ImageList_Merge (InternalDrag.himl, 0, himlDrag, iDrag, dx, dy);
     2606
     2607    if (visible) {
     2608        /* hide the drag image */
     2609        ImageList_DragShowNolock(FALSE);
     2610    }
     2611    if ((InternalDrag.himl->cx != himlTemp->cx) ||
     2612           (InternalDrag.himl->cy != himlTemp->cy)) {
     2613        /* the size of the drag image changed, invalidate the buffer */
     2614        DeleteObject(InternalDrag.hbmBg);
     2615        InternalDrag.hbmBg = 0;
     2616    }
     2617
     2618    ImageList_Destroy (InternalDrag.himl);
     2619    InternalDrag.himl = himlTemp;
     2620
     2621    /* update the InternalDragOffset, if the origin of the
     2622     * DragImage was changed by ImageList_Merge. */
     2623    if (dx > InternalDrag.dxHotspot) {
     2624        InternalDrag.dxHotspot = dx;
     2625    }
     2626    if (dy > InternalDrag.dyHotspot) {
     2627        InternalDrag.dyHotspot = dy;
     2628    }
     2629
     2630    if (visible) {
     2631        /* show the drag image */
     2632        ImageList_DragShowNolock(TRUE);
     2633    }
     2634
     2635    return TRUE;
    25042636}
    25052637
     
    25312663
    25322664    return FALSE;
     2665}
     2666
     2667
     2668/*************************************************************************
     2669 * ImageList_SetFlags [COMCTL32.79]
     2670 *
     2671 * BUGS
     2672 *    Stub.
     2673 */
     2674
     2675DWORD WINAPI
     2676ImageList_SetFlags(HIMAGELIST himl, DWORD flags)
     2677{
     2678    FIXME("(%p %08lx):empty stub\n", himl, flags);
     2679    return 0;
    25332680}
    25342681
     
    26122759
    26132760    nNewCount = iImageCount + himl->cGrow;
    2614     nCopyCount = _MIN(himl->cCurImage, iImageCount);
     2761    nCopyCount = min(himl->cCurImage, iImageCount);
    26152762
    26162763    hdcImageList = CreateCompatibleDC (0);
     
    27072854
    27082855
     2856
     2857/* helper for ImageList_Write - write bitmap to pstm
     2858 * currently everything is written as 24 bit RGB, except masks
     2859 */
     2860static BOOL
     2861_write_bitmap(HBITMAP hBitmap, LPSTREAM pstm, int cx, int cy)
     2862{
     2863    LPBITMAPFILEHEADER bmfh;
     2864    LPBITMAPINFOHEADER bmih;
     2865    LPBYTE data, lpBits, lpBitsOrg;
     2866    BITMAP bm;
     2867    INT bitCount, sizeImage, offBits, totalSize;
     2868    INT nwidth, nheight, nsizeImage, icount;
     2869    HDC xdc;
     2870    BOOL result = FALSE;
     2871
     2872
     2873    xdc = GetDC(0);
     2874    GetObjectA(hBitmap, sizeof(BITMAP), (LPVOID)&bm);
     2875   
     2876    /* XXX is this always correct? */
     2877    icount = bm.bmWidth / cx;
     2878    nwidth = cx << 2;
     2879    nheight = cy * ((icount+3)>>2);
     2880
     2881    bitCount = bm.bmBitsPixel == 1 ? 1 : 24;
     2882    sizeImage = ((((bm.bmWidth * bitCount)+31) & ~31) >> 3) * bm.bmHeight;
     2883    nsizeImage = ((((nwidth * bitCount)+31) & ~31) >> 3) * nheight;
     2884
     2885    totalSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
     2886    if(bitCount != 24)
     2887        totalSize += (1 << bitCount) * sizeof(RGBQUAD);
     2888    offBits = totalSize;
     2889    totalSize += nsizeImage;
     2890
     2891    data = (LPBYTE)LocalAlloc(LMEM_ZEROINIT, totalSize);
     2892    bmfh = (LPBITMAPFILEHEADER)data;
     2893    bmih = (LPBITMAPINFOHEADER)(data + sizeof(BITMAPFILEHEADER));
     2894    lpBits = data + offBits;
     2895
     2896    /* setup BITMAPFILEHEADER */
     2897    bmfh->bfType      = (('M' << 8) | 'B');
     2898    bmfh->bfSize      = 0;
     2899    bmfh->bfReserved1 = 0;
     2900    bmfh->bfReserved2 = 0;
     2901    bmfh->bfOffBits   = offBits;
     2902
     2903    /* setup BITMAPINFOHEADER */
     2904    bmih->biSize          = sizeof(BITMAPINFOHEADER);
     2905    bmih->biWidth         = bm.bmWidth;
     2906    bmih->biHeight        = bm.bmHeight;
     2907    bmih->biPlanes        = 1;
     2908    bmih->biBitCount      = bitCount;
     2909    bmih->biCompression   = BI_RGB;
     2910    bmih->biSizeImage     = nsizeImage;
     2911    bmih->biXPelsPerMeter = 0;
     2912    bmih->biYPelsPerMeter = 0;
     2913    bmih->biClrUsed       = 0;
     2914    bmih->biClrImportant  = 0;
     2915
     2916    lpBitsOrg = (LPBYTE)LocalAlloc(LMEM_ZEROINIT, nsizeImage);
     2917    if(!GetDIBits(xdc, hBitmap, 0, bm.bmHeight, lpBitsOrg,
     2918                  (BITMAPINFO *)bmih, DIB_RGB_COLORS))
     2919        goto failed;
     2920    else {
     2921        int i;
     2922        int obpl = (((bm.bmWidth*bitCount+31) & ~31)>>3);
     2923        int nbpl = (((nwidth*bitCount+31) & ~31)>>3);
     2924               
     2925        for(i = 0; i < nheight; i++) {
     2926            int ooff = ((nheight-1-i)%cy) * obpl + ((i/cy) * nbpl);
     2927            int noff = (nbpl * (nheight-1-i));
     2928            memcpy(lpBits + noff, lpBitsOrg + ooff, nbpl);
     2929        }
     2930    }
     2931   
     2932    bmih->biWidth  = nwidth;
     2933    bmih->biHeight = nheight;
     2934
     2935    if(bitCount == 1) {
     2936        //Hack.
     2937        LPBITMAPINFO inf = (LPBITMAPINFO)bmih;
     2938        inf->bmiColors[0].rgbRed = inf->bmiColors[0].rgbGreen = inf->bmiColors[0].rgbBlue = 0;
     2939        inf->bmiColors[1].rgbRed = inf->bmiColors[1].rgbGreen = inf->bmiColors[1].rgbBlue = 0xff;
     2940    }
     2941
     2942    if(!SUCCEEDED(IStream_Write(pstm, data, totalSize, NULL)))
     2943        goto failed;
     2944
     2945    result = TRUE;
     2946
     2947    failed:
     2948    ReleaseDC(0, xdc);
     2949    LocalFree((HLOCAL)lpBitsOrg);
     2950
     2951    return result;
     2952}
     2953
     2954
    27092955/*************************************************************************
    27102956 * ImageList_Write [COMCTL32.83]
     
    27202966 *     Failure: FALSE
    27212967 *
    2722  * NOTES
    2723  *     This function can not be implemented yet, because
    2724  *     IStream32::Write is not implemented.
    2725  *
    27262968 * BUGS
    2727  *     empty stub.
     2969 *     probably.
    27282970 */
    27292971
     
    27312973ImageList_Write (HIMAGELIST himl, LPSTREAM pstm)
    27322974{
     2975    ILHEAD ilHead;
     2976    int i;
     2977
    27332978    if (!himl)
    27342979        return FALSE;
    27352980
    2736     FIXME("empty stub!\n");
    2737 
    2738     return FALSE;
    2739 }
    2740 
     2981    ilHead.usMagic   = (('L' << 8) | 'I');
     2982    ilHead.usVersion = 0x101;
     2983    ilHead.cCurImage = himl->cCurImage;
     2984    ilHead.cMaxImage = himl->cMaxImage;
     2985    ilHead.cGrow     = himl->cGrow;
     2986    ilHead.cx        = himl->cx;
     2987    ilHead.cy        = himl->cy;
     2988    ilHead.bkcolor   = himl->clrBk;
     2989    ilHead.flags     = himl->flags;
     2990    for(i = 0; i < 4; i++) {
     2991        ilHead.ovls[i] = himl->nOvlIdx[i];
     2992    }
     2993
     2994    if(!SUCCEEDED(IStream_Write(pstm, &ilHead, sizeof(ILHEAD), NULL)))
     2995        return FALSE;
     2996
     2997    /* write the bitmap */
     2998    if(!_write_bitmap(himl->hbmImage, pstm, himl->cx, himl->cy))
     2999        return FALSE;
     3000
     3001    /* write the mask if we have one */
     3002    if(himl->flags & ILC_MASK) {
     3003        if(!_write_bitmap(himl->hbmMask, pstm, himl->cx, himl->cy))
     3004            return FALSE;
     3005    }
     3006
     3007    return TRUE;
     3008}
     3009
  • trunk/src/comctl32/initcomctl32.cpp

    r6644 r7815  
    1 /* $Id: initcomctl32.cpp,v 1.3 2001-09-05 12:04:58 bird Exp $ */
     1/* $Id: initcomctl32.cpp,v 1.4 2002-02-06 17:23:19 sandervl Exp $ */
    22/*
    33 * COMCTL32 DLL entry point
     
    5858
    5959   case DLL_PROCESS_DETACH:
    60    {
    61         BOOL ret = COMCTL32_LibMain(hinstDLL, fdwReason, fImpLoad);
    62     return ret;
    63    }
     60        return COMCTL32_LibMain(hinstDLL, fdwReason, fImpLoad);
    6461   }
    6562   return FALSE;
  • trunk/src/comctl32/makefile

    r6892 r7815  
    1 # $Id: makefile,v 1.36 2001-09-30 08:58:01 bird Exp $
     1# $Id: makefile,v 1.37 2002-02-06 17:23:20 sandervl Exp $
    22
    33#
     
    2222$(OBJDIR)\initterm.obj \
    2323$(OBJDIR)\initcomctl32.obj \
     24$(OBJDIR)\commctrl.obj \
    2425$(OBJDIR)\progress.obj \
    2526$(OBJDIR)\comctl32undoc.obj \
  • trunk/src/comctl32/rebar.c

    r7726 r7815  
    2121
    2222/*
    23  * Rebar control    rev 8a
     23 * Rebar control    rev 8b
    2424 *
    2525 * Copyright 1998, 1999 Eric Kohl
     
    8989 *     time.
    9090 * 16. Fix REBARSPACE. It should depend on CCS_NODIVIDER.
     91 * rev 8b
     92 * 17. Fix determination of whether Gripper is needed in _ValidateBand.
     93 * 18. Fix _AdjustBand processing of RBBS_FIXEDSIZE.
     94 * rev 8c
     95 * 19. Fix problem in _Layout when all lengths are 0.
    9196 *
    9297 *
     
    123128#include "debugtools.h"
    124129
    125 #ifdef __WIN32OS2__
    126 #include <winuser.h>
    127 #include "ccbase.h"
    128 #endif
    129 
    130130DEFAULT_DEBUG_CHANNEL(rebar);
    131131
     
    196196typedef struct
    197197{
    198 #ifdef __WIN32OS2__
    199     COMCTL32_HEADER header;
    200 #endif
    201198    COLORREF   clrBk;       /* background color */
    202199    COLORREF   clrText;     /* text color */
     
    209206    HWND     hwndToolTip; /* handle to the tool tip control */
    210207    HWND     hwndNotify;  /* notification window (parent) */
    211 #ifdef __WIN32OS2__
    212208    HFONT    hDefaultFont;
    213 #endif
    214209    HFONT    hFont;       /* handle to the rebar's font */
    215210    SIZE     imageSize;   /* image size (image list) */
     
    577572        INT oldBkMode = SetBkMode (hdc, TRANSPARENT);
    578573        COLORREF oldcolor = CLR_NONE;
    579         oldcolor = SetTextColor (hdc, (lpBand->clrFore != CLR_NONE) ?
    580                                  lpBand->clrFore : infoPtr->clrBtnText);
     574        COLORREF new;
     575        if (lpBand->clrFore != CLR_NONE) {
     576            new = (lpBand->clrFore == CLR_DEFAULT) ? infoPtr->clrBtnText :
     577                    lpBand->clrFore;
     578            oldcolor = SetTextColor (hdc, new);
     579        }
    581580        DrawTextW (hdc, lpBand->lpText, -1, &lpBand->rcCapText,
    582581                   DT_CENTER | DT_VCENTER | DT_SINGLELINE);
    583582        if (oldBkMode != TRANSPARENT)
    584583            SetBkMode (hdc, oldBkMode);
    585         SetTextColor (hdc, oldcolor);
     584        if (lpBand->clrFore != CLR_NONE)
     585            SetTextColor (hdc, oldcolor);
    586586        SelectObject (hdc, hOldFont);
    587587    }
     
    716716
    717717        /* compute new width */
    718         if (lpBand->hwndChild && extra) {
     718        if ((lpBand->hwndChild && extra) && !(lpBand->fStyle & RBBS_FIXEDSIZE)) {
    719719            /* set to the "current" band size less the header */
    720720            fudge = lpBand->ccx;
     
    13311331    INT initx, inity, x, y, cx, cxsep, mmcy, mcy, clientcx, clientcy;
    13321332    INT adjcx, adjcy, row, rightx, bottomy, origheight;
    1333     UINT i, j, rowstart, origrows;
     1333    UINT i, j, rowstart, origrows, cntonrow;
    13341334    BOOL dobreak;
    13351335
     
    13921392    rowstart = 0;
    13931393    prevBand = NULL;
     1394    cntonrow = 0;
    13941395
    13951396    for (i = 0; i < infoPtr->uNumBands; i++) {
     
    14101411
    14111412        /* separator from previous band */
    1412         cxsep = ( ((infoPtr->dwStyle & CCS_VERT) ? y==inity : x==initx)) ?
    1413             0 : SEP_WIDTH; 
     1413        cxsep = (cntonrow == 0) ? 0 : SEP_WIDTH; 
    14141414
    14151415        /* Header: includes gripper, text, image */
     
    14531453            prevBand = NULL;
    14541454            rowstart = i;
     1455            cntonrow = 0;
    14551456        }
    14561457
     
    15081509              lpBand->rcBand.right, lpBand->rcBand.bottom);
    15091510        prevBand = lpBand;
     1511        cntonrow++;
    15101512
    15111513    } /* for (i = 0; i < infoPtr->uNumBands... */
     
    17301732            lpBand = &infoPtr->bands[iband];
    17311733            if(HIDDENBAND(lpBand)) continue;
    1732             if (!lpBand->fMask & RBBS_VARIABLEHEIGHT) continue;
     1734            if (!(lpBand->fMask & RBBS_VARIABLEHEIGHT)) continue;
    17331735            if (((INT)lpBand->cyMaxChild < 1) ||
    17341736                ((INT)lpBand->cyIntegral < 1)) {
     
    18641866    UINT header=0;
    18651867    UINT textheight=0;
     1868    INT i, nonfixed;
     1869    REBAR_BAND *tBand;
    18661870
    18671871    lpBand->fStatus = 0;
     
    19001904    /* in the band and preceed the child window.          */
    19011905
     1906    /* count number of non-FIXEDSIZE and non-Hidden bands */
     1907    nonfixed = 0;
     1908    for (i=0; i<infoPtr->uNumBands; i++){
     1909        tBand = &infoPtr->bands[i];
     1910        if (!HIDDENBAND(tBand) && !(tBand->fStyle & RBBS_FIXEDSIZE))
     1911            nonfixed++;
     1912    }
     1913
    19021914    /* calculate gripper rectangle */
    19031915    if (  (!(lpBand->fStyle & RBBS_NOGRIPPER)) &&
    19041916          ( (lpBand->fStyle & RBBS_GRIPPERALWAYS) ||
    1905             ( !(lpBand->fStyle & RBBS_FIXEDSIZE) && (infoPtr->uNumBands > 1)))
     1917            ( !(lpBand->fStyle & RBBS_FIXEDSIZE) && (nonfixed > 1)))
    19061918       ) {
    19071919        lpBand->fStatus |= HAS_GRIPPER;
     
    20762088    HDC hdc = (HDC)wParam;
    20772089    RECT rect;
    2078     COLORREF old, new;
     2090    COLORREF old = CLR_NONE, new;
    20792091
    20802092    oldrow = -1;
     
    21222134
    21232135        /* draw the actual background */
    2124         if (lpBand->clrBack != CLR_NONE)
    2125             new = lpBand->clrBack;
    2126         else
    2127             new = infoPtr->clrBtnFace;
     2136        if (lpBand->clrBack != CLR_NONE) {
     2137            new = (lpBand->clrBack == CLR_DEFAULT) ? infoPtr->clrBtnFace :
     2138                    lpBand->clrBack;
     2139#if GLATESTING
     2140            /* testing only - make background green to see it */
     2141            new = RGB(0,128,0);
     2142#endif
     2143            old = SetBkColor (hdc, new);
     2144        }
     2145
    21282146        rect = lpBand->rcBand;
    2129 #if GLATESTING
    2130         /* testing only - make background green to see it */
    2131         new = RGB(0,128,0);
    2132 #endif
    2133         old = SetBkColor (hdc, new);
    21342147        TRACE("%s background color=0x%06lx, band (%d,%d)-(%d,%d), clip (%d,%d)-(%d,%d)\n",
    2135               (lpBand->clrBack == CLR_NONE) ? "std" : "",
    2136               new,
     2148              (lpBand->clrBack == CLR_NONE) ? "none" :
     2149                ((lpBand->clrBack == CLR_DEFAULT) ? "dft" : ""),
     2150              GetBkColor(hdc),
    21372151              lpBand->rcBand.left,lpBand->rcBand.top,
    21382152              lpBand->rcBand.right,lpBand->rcBand.bottom,
     
    21402154              clip->right, clip->bottom);
    21412155        ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, 0);
    2142         SetBkColor (hdc, old);
     2156        if (lpBand->clrBack != CLR_NONE)
     2157            SetBkColor (hdc, old);
    21432158    }
    21442159    return TRUE;
     
    25872602        lprbbi->clrFore = lpBand->clrFore;
    25882603        lprbbi->clrBack = lpBand->clrBack;
    2589         if (lprbbi->clrBack == CLR_NONE)
     2604        if (lprbbi->clrBack == CLR_DEFAULT)
    25902605            lprbbi->clrBack = infoPtr->clrBtnFace;
    25912606    }
     
    26732688        lprbbi->clrFore = lpBand->clrFore;
    26742689        lprbbi->clrBack = lpBand->clrBack;
    2675         if (lprbbi->clrBack == CLR_NONE)
     2690        if (lprbbi->clrBack == CLR_DEFAULT)
    26762691            lprbbi->clrBack = infoPtr->clrBtnFace;
    26772692    }
     
    27712786    COLORREF clr = infoPtr->clrBk;
    27722787
    2773     if (clr == CLR_NONE)
     2788    if (clr == CLR_DEFAULT)
    27742789      clr = infoPtr->clrBtnFace;
    27752790
     
    36363651    DeleteObject (infoPtr->hcurVert);
    36373652    DeleteObject (infoPtr->hcurDrag);
    3638 
    3639 #ifdef __WIN32OS2__
    3640     //NEVER delete the font object received by WM_SETFONT!
    36413653    if(infoPtr->hDefaultFont) DeleteObject (infoPtr->hDefaultFont);
    3642 #else
    3643     DeleteObject (infoPtr->hFont);
    3644 #endif
    36453654    SetWindowLongA (infoPtr->hwndSelf, 0, 0);
    36463655
     
    38093818
    38103819    /* allocate memory for info structure */
    3811 #ifdef __WIN32OS2__
    3812     infoPtr = (REBAR_INFO*)initControl(hwnd,sizeof(REBAR_INFO));
    3813 #else
    38143820    infoPtr = (REBAR_INFO *)COMCTL32_Alloc (sizeof(REBAR_INFO));
    3815 #endif
    38163821    SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
    38173822
     
    38563861    tfont = CreateFontIndirectA (&ncm.lfCaptionFont);
    38573862    if (tfont) {
    3858 #ifdef __WIN32OS2__
    38593863        infoPtr->hFont = infoPtr->hDefaultFont = tfont;
    3860 #else
    3861         infoPtr->hFont = tfont;
    3862 #endif
    38633864    }
    38643865
     
    44134414                ERR("unknown msg %04x wp=%08x lp=%08lx\n",
    44144415                     uMsg, wParam, lParam);
    4415 #ifdef __WIN32OS2__
    4416             return defComCtl32ProcA (hwnd, uMsg, wParam, lParam);
    4417 #else
    44184416            return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    4419 #endif
    44204417    }
    44214418    return 0;
  • trunk/src/comctl32/tab.c

    r6709 r7815  
    2121#include "debugtools.h"
    2222#include <math.h>
    23 #ifdef __WIN32OS2__
    24 #include "ccbase.h"
    25 #define COMCTL32_hPattern55AABrush GetPattern55AABitmap()
    26 #endif
    2723
    2824DEFAULT_DEBUG_CHANNEL(tab);
     
    4541typedef struct
    4642{
    47 #ifdef __WIN32OS2__
    48   COMCTL32_HEADER header;
    49 #endif
    5043  UINT       uNumItem;        /* number of tab items */
    5144  UINT       uNumRows;        /* number of tab rows */
     
    11681161
    11691162      /*
    1170        * Ok Microsoft trys to even out the rows. place the same
     1163       * Ok windows tries to even out the rows. place the same
    11711164       * number of tabs in each row. So lets give that a shot
    1172        *
    11731165       */
    11741166
     
    12261218                infoPtr->items[iIndexStart].rect.top) ;
    12271219            iIndexEnd++)
    1228         /* intentionaly blank */;
     1220        /* intentionally blank */;
    12291221
    12301222        /*
     
    18611853 
    18621854    /* This modifies r to be the text rectangle. */
    1863 {
    1864     HFONT hOldFont = SelectObject(hdc, infoPtr->hFont);
    1865     TAB_DrawItemInterior(hwnd, hdc, iItem, &r);
    1866     SelectObject(hdc,hOldFont);
    1867 }
     1855    {
     1856      HFONT hOldFont = SelectObject(hdc, infoPtr->hFont);
     1857      TAB_DrawItemInterior(hwnd, hdc, iItem, &r);
     1858      SelectObject(hdc,hOldFont);
     1859    }
     1860
    18681861    /* Draw the focus rectangle */
    18691862    if (((lStyle & TCS_FOCUSNEVER) == 0) &&
     
    22792272  TAB_InvalidateTabArea(hwnd, infoPtr);
    22802273 
    2281   TRACE("[%04x]: added item %d '%s'\n",
     2274  TRACE("[%04x]: added item %d %s\n",
    22822275        hwnd, iItem, debugstr_w(infoPtr->items[iItem].pszText));
    22832276
     
    23482341  TAB_InvalidateTabArea(hwnd, infoPtr);
    23492342 
    2350   TRACE("[%04x]: added item %d '%s'\n",
     2343  TRACE("[%04x]: added item %d %s\n",
    23512344        hwnd, iItem, debugstr_w(infoPtr->items[iItem].pszText));
    23522345
     
    27042697  DWORD dwStyle;
    27052698
    2706 #ifdef __WIN32OS2__
    2707   infoPtr = (TAB_INFO*)initControl(hwnd,sizeof(TAB_INFO));
    2708 #else
    27092699  infoPtr = (TAB_INFO *)COMCTL32_Alloc (sizeof(TAB_INFO));
    2710 #endif
    27112700
    27122701  SetWindowLongA(hwnd, 0, (DWORD)infoPtr);
     
    29492938    case WM_LBUTTONUP:
    29502939      return TAB_LButtonUp (hwnd, wParam, lParam);
    2951      
     2940     
     2941    case WM_NOTIFY:
     2942      return SendMessageA(GetParent(hwnd), WM_NOTIFY, wParam, lParam);
     2943 
    29522944    case WM_RBUTTONDOWN:
    29532945      return TAB_RButtonDown (hwnd, wParam, lParam);
     
    29892981        WARN("unknown msg %04x wp=%08x lp=%08lx\n",
    29902982             uMsg, wParam, lParam);
    2991 #ifdef __WIN32OS2__
    2992       return defComCtl32ProcA (hwnd, uMsg, wParam, lParam);
    2993 #else
    2994       return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    2995 #endif
     2983      return DefWindowProcA(hwnd, uMsg, wParam, lParam);
    29962984    }
    29972985
  • trunk/src/comctl32/toolbar.c

    r7616 r7815  
    6060DEFAULT_DEBUG_CHANNEL(toolbar);
    6161
    62 #ifdef __WIN32OS2__
    63 #undef inline
    64 #define inline
    65 #define COMCTL32_hPattern55AABrush GetPattern55AABrush()
    66 #endif
    67 
    6862typedef struct
    6963{
     
    10296    INT      nOldHit;
    10397    INT      nHotItem;        /* index of the "hot" item */
    104 #ifdef __WIN32OS2__
    10598    HFONT    hDefaultFont;
    106 #endif
    10799    HFONT    hFont;           /* text font */
    108100    HIMAGELIST himlInt;         /* image list created internally */
     
    118110    BOOL     bAnchor;         /* anchor highlight enabled */
    119111    BOOL     bNtfUnicode;     /* TRUE if NOTIFYs use {W} */
     112    BOOL     bDoRedraw;       /* Redraw status */
    120113    DWORD      dwExStyle;       /* extended toolbar style */
    121114    DWORD      dwDTFlags;       /* DrawText flags */
     
    156149
    157150
     151static LPWSTR
     152TOOLBAR_GetText(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr)
     153{
     154    LPWSTR lpText = NULL;
     155
     156    /* FIXME: iString == -1 is undocumented */
     157    if ((HIWORD(btnPtr->iString) != 0) && (btnPtr->iString != -1))
     158        lpText = (LPWSTR)btnPtr->iString;
     159    else if ((btnPtr->iString >= 0) && (btnPtr->iString < infoPtr->nNumStrings))
     160        lpText = infoPtr->strings[btnPtr->iString];
     161   
     162    return lpText;
     163}
     164
    158165static void
    159166TOOLBAR_DumpButton(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *bP, INT btn_num, BOOL internal)
    160167{
    161168    if (TRACE_ON(toolbar)){
    162         TRACE("button %d id %d, bitmap=%d, state=%02x, style=%02x, data=%08lx, string=%d\n",
     169        TRACE("button %d id %d, bitmap=%d, state=%02x, style=%02x, data=%08lx, stringid=0x%08x\n",
    163170              btn_num, bP->idCommand,
    164171              bP->iBitmap, bP->fsState, bP->fsStyle, bP->dwData, bP->iString);
     172        TRACE("string %s\n", debugstr_w(TOOLBAR_GetText(infoPtr,bP)));
    165173        if (internal)
    166174            TRACE("button %d id %d, hot=%s, row=%d, rect=(%d,%d)-(%d,%d)\n",
     
    185193              iP->dwExStyle, iP->nNumButtons, iP->nNumBitmaps,
    186194              iP->nNumStrings, dwStyle);
    187         TRACE("toolbar %08x at line %d, himlInt=%p, himlDef=%p, himlHot=%p, himlDis=%p\n",
     195        TRACE("toolbar %08x at line %d, himlInt=%p, himlDef=%p, himlHot=%p, himlDis=%p, redrawable=%s\n",
    188196              iP->hwndSelf, line,
    189               iP->himlInt, iP->himlDef, iP->himlHot, iP->himlDis);
     197              iP->himlInt, iP->himlDef, iP->himlHot, iP->himlDis,
     198              (iP->bDoRedraw) ? "TRUE" : "FALSE");
    190199        for(i=0; i<iP->nNumButtons; i++) {
    191200            TOOLBAR_DumpButton(iP, &iP->buttons[i], i, TRUE);
     
    215224TOOLBAR_SendNotify (NMHDR *nmhdr, TOOLBAR_INFO *infoPtr, UINT code)
    216225{
     226        if(!IsWindow(infoPtr->hwndSelf))
     227            return 0;   /* we have just been destroyed */
     228       
    217229    nmhdr->idFrom = GetDlgCtrlID (infoPtr->hwndSelf);
    218230    nmhdr->hwndFrom = infoPtr->hwndSelf;
     
    228240        return SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
    229241                             (WPARAM) nmhdr->idFrom, (LPARAM)nmhdr);
    230 }
    231 
    232 static LPWSTR
    233 TOOLBAR_GetText(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr)
    234 {
    235     LPWSTR lpText = NULL;
    236 
    237     /* FIXME: iString == -1 is undocumented */
    238     if ((HIWORD(btnPtr->iString) != 0) && (btnPtr->iString != -1))
    239         lpText = (LPWSTR)btnPtr->iString;
    240     else if ((btnPtr->iString >= 0) && (btnPtr->iString < infoPtr->nNumStrings))
    241         lpText = infoPtr->strings[btnPtr->iString];
    242    
    243     return lpText;
    244242}
    245243
     
    447445    lpText = TOOLBAR_GetText(infoPtr, btnPtr);
    448446
    449     TRACE ("lpText: %s\n", debugstr_w(lpText));
     447    TRACE ("Stringtext: %s\n", debugstr_w(lpText));
    450448
    451449    /* draw text */
     
    818816    lpSize->cy = 0;
    819817
    820     if (!(btnPtr->fsState & TBSTATE_HIDDEN) &&
    821          (btnPtr->iString > -1) &&
    822          (btnPtr->iString < infoPtr->nNumStrings))
     818    if (!(btnPtr->fsState & TBSTATE_HIDDEN) )
    823819    {
    824         LPWSTR lpText = infoPtr->strings[btnPtr->iString];
     820        LPWSTR lpText = TOOLBAR_GetText(infoPtr, btnPtr);
    825821
    826822        /* first get size of all the text */
     
    13301326
    13311327static INT
    1332 TOOLBAR_GetButtonIndex (TOOLBAR_INFO *infoPtr, INT idCommand)
     1328TOOLBAR_GetButtonIndex (TOOLBAR_INFO *infoPtr, INT idCommand, BOOL CommandIsIndex)
    13331329{
    13341330    TBUTTON_INFO *btnPtr;
    13351331    INT i;
    13361332
     1333    if (CommandIsIndex) {
     1334        TRACE("command is really index command=%d\n", idCommand);
     1335        return idCommand;
     1336    }
    13371337    btnPtr = infoPtr->buttons;
    13381338    for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
     
    14211421    PCUSTOMBUTTON btnInfo;
    14221422    NMTOOLBARA nmtb;
    1423     TOOLBAR_INFO *infoPtr = custInfo->tbInfo;
     1423    TOOLBAR_INFO *infoPtr = custInfo ? custInfo->tbInfo : NULL;
    14241424
    14251425    switch (uMsg)
     
    14341434                int i = 0;
    14351435                int index;
     1436               
     1437                infoPtr = custInfo->tbInfo;
    14361438
    14371439                /* send TBN_QUERYINSERT notification */
     
    14841486
    14851487                    /* insert button into the apropriate list */
    1486                     index = TOOLBAR_GetButtonIndex (custInfo->tbInfo, nmtb.tbButton.idCommand);
     1488                    index = TOOLBAR_GetButtonIndex (custInfo->tbInfo, nmtb.tbButton.idCommand, FALSE);
    14871489                    if (index == -1)
    14881490                    {
     
    20762078    TOOLBAR_CalcToolbar (hwnd);
    20772079
     2080    TOOLBAR_DumpToolbar (infoPtr, __LINE__);
     2081
    20782082    InvalidateRect(hwnd, NULL, FALSE);
    20792083
     
    21382142    TOOLBAR_CalcToolbar (hwnd);
    21392143
     2144    TOOLBAR_DumpToolbar (infoPtr, __LINE__);
     2145
    21402146    InvalidateRect(hwnd, NULL, FALSE);
    21412147
     
    21522158    if ((wParam) && (HIWORD(lParam) == 0)) {
    21532159        char szString[256];
    2154         INT len, lenW;
     2160        INT len;
    21552161        TRACE("adding string from resource!\n");
    21562162
     
    21732179        }
    21742180
    2175         lenW = MultiByteToWideChar( CP_ACP, 0, szString, -1, NULL, 0 );
    2176         infoPtr->strings[infoPtr->nNumStrings] = COMCTL32_Alloc (sizeof(WCHAR)*lenW);
    2177         MultiByteToWideChar( CP_ACP, 0, szString, -1,
    2178                              infoPtr->strings[infoPtr->nNumStrings], lenW );
     2181        /*COMCTL32_Alloc zeros out the allocated memory*/
     2182        Str_SetPtrAtoW (&infoPtr->strings[infoPtr->nNumStrings], szString );
    21792183        infoPtr->nNumStrings++;
    21802184    }
    21812185    else {
    21822186        LPSTR p = (LPSTR)lParam;
    2183         INT len, lenW;
     2187        INT len;
    21842188
    21852189        if (p == NULL)
     
    22052209            }
    22062210
    2207             lenW = MultiByteToWideChar( CP_ACP, 0, p, -1, NULL, 0 );
    2208             infoPtr->strings[infoPtr->nNumStrings] = COMCTL32_Alloc (sizeof(WCHAR)*lenW);
    2209             MultiByteToWideChar( CP_ACP, 0, p, -1,
    2210                                  infoPtr->strings[infoPtr->nNumStrings], lenW );
     2211            Str_SetPtrAtoW (&infoPtr->strings[infoPtr->nNumStrings], p );
    22112212            infoPtr->nNumStrings++;
    22122213
     
    22602261            infoPtr->strings[infoPtr->nNumStrings] =
    22612262                COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
    2262             lstrcpynW (infoPtr->strings[infoPtr->nNumStrings], p, len);
     2263            lstrcpynW (infoPtr->strings[infoPtr->nNumStrings], p, len+1);
    22632264            infoPtr->nNumStrings++;
    22642265
     
    22822283            }
    22832284
    2284             infoPtr->strings[infoPtr->nNumStrings] =
    2285                 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
    2286             strcpyW (infoPtr->strings[infoPtr->nNumStrings], szString);
     2285            Str_SetPtrW (&infoPtr->strings[infoPtr->nNumStrings], szString);
    22872286            infoPtr->nNumStrings++;
    22882287        }
     
    23132312            }
    23142313
    2315             infoPtr->strings[infoPtr->nNumStrings] =
    2316                 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
    2317             strcpyW (infoPtr->strings[infoPtr->nNumStrings], p);
     2314            Str_SetPtrW (&infoPtr->strings[infoPtr->nNumStrings], p);
    23182315            infoPtr->nNumStrings++;
    23192316
     
    23532350        cx = 0;
    23542351        cy = 0;
     2352        TOOLBAR_CalcToolbar (hwnd);
    23552353    }
    23562354    else {
     
    24252423    INT nIndex;
    24262424
    2427     nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
     2425    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
    24282426    if (nIndex == -1)
    24292427        return FALSE;
     
    24492447    BOOL bChecked = FALSE;
    24502448
    2451     nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
     2449    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
    24522450    if (nIndex == -1)
    24532451        return FALSE;
     
    24952493    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    24962494
    2497     return TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
     2495    return TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
    24982496}
    24992497
     
    26002598    DWORD bState;
    26012599
    2602     nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
     2600    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
    26032601    if (nIndex == -1)
    26042602        return FALSE;
     
    26412639    INT nIndex;
    26422640
    2643     nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
     2641    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
    26442642    if (nIndex == -1)
    26452643        return -1;
     
    27002698        return -1;
    27012699
    2702     nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
     2700    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam,
     2701                                     lpTbInfo->dwMask & 0x80000000);
    27032702    if (nIndex == -1)
    27042703        return -1;
    27052704
    2706     btnPtr = &infoPtr->buttons[nIndex];
     2705    if (!(btnPtr = &infoPtr->buttons[nIndex])) return -1;
    27072706
    27082707    if (lpTbInfo->dwMask & TBIF_COMMAND)
     
    27192718        lpTbInfo->fsStyle = btnPtr->fsStyle;
    27202719     if (lpTbInfo->dwMask & TBIF_TEXT) {
    2721          if ((btnPtr->iString >= 0) && (btnPtr->iString < infoPtr->nNumStrings))
    2722          {     
    2723              if (!WideCharToMultiByte( CP_ACP, 0, (LPWSTR)infoPtr->strings[btnPtr->iString], -1,
    2724                                        lpTbInfo->pszText, lpTbInfo->cchText, NULL, NULL ))
    2725                  lpTbInfo->pszText[lpTbInfo->cchText-1] = 0;
     2720         LPWSTR lpText = TOOLBAR_GetText(infoPtr,btnPtr);
     2721         Str_GetPtrWtoA (lpText, lpTbInfo->pszText,lpTbInfo->cchText);
    27262722         }
    2727          else lpTbInfo->pszText[0]=0;
    2728     }
    27292723    return nIndex;
    27302724}
     
    27462740        return -1;
    27472741
    2748     nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
     2742    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam,
     2743                                     lpTbInfo->dwMask & 0x80000000);
    27492744    if (nIndex == -1)
    27502745        return -1;
     
    27652760        lpTbInfo->fsStyle = btnPtr->fsStyle;
    27662761    if (lpTbInfo->dwMask & TBIF_TEXT) {
    2767         if ((btnPtr->iString >= 0) || (btnPtr->iString < infoPtr->nNumStrings))
    2768             lstrcpynW (lpTbInfo->pszText,
    2769                        (LPWSTR)infoPtr->strings[btnPtr->iString],
    2770                        lpTbInfo->cchText);
     2762        LPWSTR lpText = TOOLBAR_GetText(infoPtr,btnPtr);
     2763        Str_GetPtrW (lpText,lpTbInfo->pszText,lpTbInfo->cchText);
    27712764    }
    27722765
     
    27922785{
    27932786    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    2794     INT nIndex, nStringIndex;
    2795 
    2796     nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
     2787    INT nIndex;
     2788    LPWSTR lpText;
     2789
     2790    if (lParam == 0)
     2791        return -1;
     2792
     2793    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
    27972794    if (nIndex == -1)
    27982795        return -1;
    27992796
    2800     nStringIndex = infoPtr->buttons[nIndex].iString;
    2801 
    2802     TRACE("index=%d stringIndex=%d\n", nIndex, nStringIndex);
    2803 
    2804     if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings))
    2805         return -1;
     2797    lpText = TOOLBAR_GetText(infoPtr,&infoPtr->buttons[nIndex]);
     2798
     2799    return WideCharToMultiByte( CP_ACP, 0, lpText, -1,
     2800                                (LPSTR)lParam, 0x7fffffff, NULL, NULL ) - 1;
     2801}
     2802
     2803
     2804static LRESULT
     2805TOOLBAR_GetButtonTextW (HWND hwnd, WPARAM wParam, LPARAM lParam)
     2806{
     2807    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
     2808    INT nIndex;
     2809    LPWSTR lpText;
    28062810
    28072811    if (lParam == 0)
    28082812        return -1;
    28092813
    2810     return WideCharToMultiByte( CP_ACP, 0, (LPWSTR)infoPtr->strings[nStringIndex], -1,
    2811                                 (LPSTR)lParam, 0x7fffffff, NULL, NULL ) - 1;
    2812 }
    2813 
    2814 
    2815 static LRESULT
    2816 TOOLBAR_GetButtonTextW (HWND hwnd, WPARAM wParam, LPARAM lParam)
    2817 {
    2818     TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    2819     INT nIndex, nStringIndex;
    2820 
    2821     nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
     2814    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
    28222815    if (nIndex == -1)
    28232816        return -1;
    28242817
    2825     nStringIndex = infoPtr->buttons[nIndex].iString;
    2826 
    2827     TRACE("index=%d stringIndex=%d\n", nIndex, nStringIndex);
    2828 
    2829     if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings))
    2830         return -1;
    2831 
    2832     if (lParam == 0)
    2833         return -1;
    2834 
    2835     strcpyW ((LPWSTR)lParam, (LPWSTR)infoPtr->strings[nStringIndex]);
    2836 
    2837     return strlenW ((LPWSTR)infoPtr->strings[nStringIndex]);
     2818    lpText = TOOLBAR_GetText(infoPtr,&infoPtr->buttons[nIndex]);
     2819
     2820    strcpyW ((LPWSTR)lParam, lpText);
     2821
     2822    return strlenW (lpText);
    28382823}
    28392824
     
    29602945    if (infoPtr == NULL)
    29612946        return FALSE;
    2962     nIndex = (INT)wParam;
     2947    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
    29632948    btnPtr = &infoPtr->buttons[nIndex];
    29642949    if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
     
    29952980    INT nIndex;
    29962981
    2997     nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
     2982    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
    29982983    if (nIndex == -1)
    29992984        return -1;
     
    30092994    INT nIndex;
    30102995
    3011     nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
     2996    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
    30122997    if (nIndex == -1)
    30132998        return -1;
     
    30693054    TRACE("\n");
    30703055
    3071     nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
     3056    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
    30723057    if (nIndex == -1)
    30733058        return FALSE;
     
    31013086    INT nIndex;
    31023087
    3103     nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
     3088    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
    31043089    if (nIndex == -1)
    31053090        return FALSE;
     
    31383123        * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
    31393124        */
    3140        int      len;
    3141        LPSTR    ptr;
    3142 
    3143        /* FIXME: iString == -1 is undocumented */
    3144        if(lpTbb->iString && lpTbb->iString!=-1) {
    3145            len = strlen((char*)lpTbb->iString) + 2;
    3146            ptr = COMCTL32_Alloc(len);
    3147            nIndex = infoPtr->nNumButtons;
    3148            strcpy(ptr, (char*)lpTbb->iString);
    3149            ptr[len - 1] = 0; /* ended by two '\0' */
    3150            lpTbb->iString = TOOLBAR_AddStringA(hwnd, 0, (LPARAM)ptr);
    3151            COMCTL32_Free(ptr);
    3152        }
    3153        else {
    3154            ERR("lpTbb->iString is NULL\n");
    3155            return FALSE;
    3156        }
     3125        nIndex = infoPtr->nNumButtons;
    31573126
    31583127    } else if (nIndex < 0)
    31593128       return FALSE;
     3129
     3130    /* If the string passed is not an index, assume address of string
     3131       and do our own AddString */
     3132    if ((HIWORD(lpTbb->iString) != 0) && (lpTbb->iString != -1)) {
     3133        LPSTR ptr;
     3134        INT len;
     3135
     3136        TRACE("string %s passed instead of index, adding string\n",
     3137              debugstr_a((LPSTR)lpTbb->iString));
     3138        len = strlen((LPSTR)lpTbb->iString) + 2;
     3139        ptr = COMCTL32_Alloc(len);
     3140        strcpy(ptr, (LPSTR)lpTbb->iString);
     3141        ptr[len - 1] = 0; /* ended by two '\0' */
     3142        lpTbb->iString = TOOLBAR_AddStringA(hwnd, 0, (LPARAM)ptr);
     3143        COMCTL32_Free(ptr);
     3144    }
    31603145
    31613146    TRACE("inserting button index=%d\n", nIndex);
     
    31803165    infoPtr->buttons[nIndex].fsStyle   = lpTbb->fsStyle;
    31813166    infoPtr->buttons[nIndex].dwData    = lpTbb->dwData;
    3182     infoPtr->buttons[nIndex].iString   = lpTbb->iString;
     3167    /* if passed string and not index, then add string */
     3168    if(HIWORD(lpTbb->iString) && lpTbb->iString!=-1) {
     3169        Str_SetPtrAtoW ((LPWSTR *)&infoPtr->buttons[nIndex].iString, (LPCSTR )lpTbb->iString);
     3170    }
     3171    else
     3172        infoPtr->buttons[nIndex].iString   = lpTbb->iString;
    31833173
    31843174    if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
     
    32063196    TOOLBAR_CalcToolbar (hwnd);
    32073197
    3208     InvalidateRect (hwnd, NULL, FALSE);
     3198    InvalidateRect (hwnd, NULL, TRUE);
    32093199
    32103200    return TRUE;
     
    32223212    if (lpTbb == NULL)
    32233213        return FALSE;
     3214
     3215    TOOLBAR_DumpButton(infoPtr, (TBUTTON_INFO *)lpTbb, nIndex, FALSE);
     3216
    32243217    if (nIndex < 0)
    32253218        return FALSE;
     
    32403233    }
    32413234
     3235
     3236    /* If the string passed is not an index, assume address of string
     3237       and do our own AddString */
     3238    if ((HIWORD(lpTbb->iString) != 0) && (lpTbb->iString != -1)) {
     3239        LPWSTR ptr;
     3240        INT len;
     3241
     3242        TRACE("string %s passed instead of index, adding string\n",
     3243              debugstr_w((LPWSTR)lpTbb->iString));
     3244        len = strlenW((LPWSTR)lpTbb->iString) + 2;
     3245        ptr = COMCTL32_Alloc(len*sizeof(WCHAR));
     3246        strcpyW(ptr, (LPWSTR)lpTbb->iString);
     3247        ptr[len - 1] = 0; /* ended by two '\0' */
     3248        lpTbb->iString = TOOLBAR_AddStringW(hwnd, 0, (LPARAM)ptr);
     3249        COMCTL32_Free(ptr);
     3250    }
     3251
    32423252    /* insert new button */
    32433253    infoPtr->buttons[nIndex].iBitmap   = lpTbb->iBitmap;
     
    32463256    infoPtr->buttons[nIndex].fsStyle   = lpTbb->fsStyle;
    32473257    infoPtr->buttons[nIndex].dwData    = lpTbb->dwData;
    3248     infoPtr->buttons[nIndex].iString   = lpTbb->iString;
     3258    /* if passed string and not index, then add string */
     3259    if(HIWORD(lpTbb->iString) && lpTbb->iString!=-1) {
     3260        Str_SetPtrW ((LPWSTR *)&infoPtr->buttons[nIndex].iString, (LPWSTR)lpTbb->iString);
     3261    }
     3262    else
     3263        infoPtr->buttons[nIndex].iString   = lpTbb->iString;
    32493264
    32503265    if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
     
    32703285    COMCTL32_Free (oldButtons);
    32713286
    3272     InvalidateRect (hwnd, NULL, FALSE);
     3287    InvalidateRect (hwnd, NULL, TRUE);
    32733288
    32743289    return TRUE;
     
    32853300    INT nIndex;
    32863301
    3287     nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
     3302    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
    32883303    if (nIndex == -1)
    32893304        return FALSE;
     
    32993314    INT nIndex;
    33003315
    3301     nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
     3316    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
    33023317    if (nIndex == -1)
    33033318        return FALSE;
     
    33133328    INT nIndex;
    33143329
    3315     nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
     3330    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
    33163331    if (nIndex == -1)
    33173332        return TRUE;
     
    33273342    INT nIndex;
    33283343
    3329     nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
     3344    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
    33303345    if (nIndex == -1)
    33313346        return FALSE;
     
    33413356    INT nIndex;
    33423357
    3343     nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
     3358    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
    33443359    if (nIndex == -1)
    33453360        return FALSE;
     
    33553370    INT nIndex;
    33563371
    3357     nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
     3372    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
    33583373    if (nIndex == -1)
    33593374        return FALSE;
     
    33763391    INT nIndex;
    33773392
    3378     nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
     3393    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
    33793394    if (nIndex == -1)
    33803395        return FALSE;
     
    35083523        return FALSE;
    35093524   
    3510     nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
     3525    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam,
     3526                                     lptbbi->dwMask & 0x80000000);
    35113527    if (nIndex == -1)
    35123528        return FALSE;
     
    35263542        btnPtr->fsStyle = lptbbi->fsStyle;
    35273543
    3528     if (lptbbi->dwMask & TBIF_TEXT) {
    3529         if ((btnPtr->iString >= 0) ||
    3530             (btnPtr->iString < infoPtr->nNumStrings)) {
    3531            TRACE("Ooooooch\n");
    3532 #if 0
    3533             WCHAR **lpString = &infoPtr->strings[btnPtr->iString];
    3534             INT len = lstrlenA (lptbbi->pszText);
    3535             *lpString = COMCTL32_ReAlloc (lpString, sizeof(WCHAR)*(len+1));
    3536 #endif
    3537 
    3538             /* this is the ultimate sollution */
    3539 /*          Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */
    3540         }
    3541     }
    3542 
     3544    if ((lptbbi->dwMask & TBIF_TEXT) && ((INT)lptbbi->pszText != -1)) {
     3545        if ((HIWORD(btnPtr->iString) == 0) || (btnPtr->iString == -1))
     3546            /* iString is index, zero it to make Str_SetPtr succeed */
     3547            btnPtr->iString=0;
     3548     
     3549         Str_SetPtrAtoW ((LPWSTR *)&btnPtr->iString, lptbbi->pszText);
     3550    }
    35433551    return TRUE;
    35443552}
     
    35583566        return FALSE;
    35593567
    3560     nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
     3568    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam,
     3569                                     lptbbi->dwMask & 0x80000000);
    35613570    if (nIndex == -1)
    35623571        return FALSE;
     
    35763585        btnPtr->fsStyle = lptbbi->fsStyle;
    35773586
    3578     if (lptbbi->dwMask & TBIF_TEXT) {
    3579         if ((btnPtr->iString >= 0) ||
    3580             (btnPtr->iString < infoPtr->nNumStrings)) {
    3581 #if 0
    3582             WCHAR **lpString = &infoPtr->strings[btnPtr->iString];
    3583             INT len = lstrlenW (lptbbi->pszText);
    3584             *lpString = COMCTL32_ReAlloc (lpString, sizeof(WCHAR)*(len+1));
    3585 #endif
    3586 
    3587             /* this is the ultimate solution */
    3588 /*          Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */
    3589         }
    3590     }
    3591 
     3587    if ((lptbbi->dwMask & TBIF_TEXT) && ((INT)lptbbi->pszText != -1)) {
     3588        if ((HIWORD(btnPtr->iString) == 0) || (btnPtr->iString == -1))
     3589            /* iString is index, zero it to make Str_SetPtr succeed */
     3590            btnPtr->iString=0;
     3591        Str_SetPtrW ((LPWSTR *)&btnPtr->iString, lptbbi->pszText);
     3592    }
    35923593    return TRUE;
    35933594}
     
    36903691
    36913692
     3693    if (wParam != 0) {
     3694        FIXME("no support for multiple image lists\n");
     3695        return 0;
     3696    }
     3697
    36923698    himlTemp = infoPtr->himlDis;
    36933699    infoPtr->himlDis = (HIMAGELIST)lParam;
     
    37313737    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
    37323738    HIMAGELIST himlTemp;
     3739
     3740    if (wParam != 0) {
     3741        FIXME("no support for multiple image lists\n");
     3742        return 0;
     3743    }
    37333744
    37343745    himlTemp = infoPtr->himlHot;
     
    37843795    HIMAGELIST himlTemp;
    37853796
     3797    if (wParam != 0) {
     3798        FIXME("no support for multiple image lists\n");
     3799        return 0;
     3800    }
     3801
    37863802    himlTemp = infoPtr->himlDef;
    37873803    infoPtr->himlDef = (HIMAGELIST)lParam;
     
    37963812
    37973813    /* FIXME: redraw ? */
     3814    InvalidateRect(hwnd, NULL, TRUE);
    37983815
    37993816    return (LRESULT)himlTemp;
     
    39143931    INT nIndex;
    39153932
    3916     nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
     3933    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
    39173934    if (nIndex == -1)
    39183935        return FALSE;
     
    39473964    INT nIndex;
    39483965
    3949     nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
     3966    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
    39503967    if (nIndex == -1)
    39513968        return FALSE;
     
    40434060    infoPtr->bNtfUnicode = FALSE;
    40444061    infoPtr->hwndSelf = hwnd;
     4062    infoPtr->bDoRedraw = TRUE;
    40454063
    40464064    SystemParametersInfoA (SPI_GETICONTITLELOGFONT, 0, &logFont, 0);
    4047 #ifdef __WIN32OS2__
    40484065    infoPtr->hFont = infoPtr->hDefaultFont = CreateFontIndirectA (&logFont);
    4049 #else
    4050     infoPtr->hFont = CreateFontIndirectA (&logFont);
    4051 #endif
    40524066
    40534067    if (dwStyle & TBSTYLE_TOOLTIPS) {
     
    41064120
    41074121    /* delete default font */
    4108 #ifdef __WIN32OS2__
    4109     //NEVER delete the font object received by WM_SETFONT!
    4110     if (infoPtr->hDefaultFont)
    4111         DeleteObject (infoPtr->hDefaultFont);
    4112 #else
    41134122    if (infoPtr->hFont)
    4114         DeleteObject (infoPtr->hFont);
    4115 #endif
     4123        DeleteObject (infoPtr->hDefaultFont);
    41164124
    41174125    /* free toolbar info data */
     
    41294137    DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
    41304138    NMTBCUSTOMDRAW tbcd;
    4131     INT ret, ntfret;
     4139    INT ret = FALSE, ntfret;
    41324140
    41334141    if (dwStyle & TBSTYLE_CUSTOMERASE) {
     
    41624170        MapWindowPoints(hwnd, parent, &pt, 1);
    41634171        OffsetWindowOrgEx (hdc, pt.x, pt.y, &ptorig);
    4164         SendMessageA (parent, WM_ERASEBKGND, wParam, lParam);
     4172        ret = SendMessageA (parent, WM_ERASEBKGND, wParam, lParam);
    41654173        SetWindowOrgEx (hdc, ptorig.x, ptorig.y, 0);
    4166         return TRUE;
    4167     }
    4168     ret = DefWindowProcA (hwnd, WM_ERASEBKGND, wParam, lParam);
     4174    }
     4175    if (!ret)
     4176        ret = DefWindowProcA (hwnd, WM_ERASEBKGND, wParam, lParam);
    41694177
    41704178    if (dwStyle & TBSTYLE_CUSTOMERASE) {
     
    43974405
    43984406        if (bSendMessage)
    4399             SendMessageA (GetParent(hwnd), WM_COMMAND,
     4407            SendMessageA (infoPtr->hwndNotify, WM_COMMAND,
    44004408                          MAKEWPARAM(btnPtr->idCommand, 0), (LPARAM)hwnd);
    44014409
     
    47594767
    47604768static LRESULT
     4769TOOLBAR_SetRedraw (HWND hwnd, WPARAM wParam, LPARAM lParam)
     4770     /*****************************************************
     4771      *
     4772      * Function;
     4773      *  Handles the WM_SETREDRAW message.
     4774      *
     4775      * Documentation:
     4776      *  According to testing V4.71 of COMCTL32 returns the
     4777      *  *previous* status of the redraw flag (either 0 or 1)
     4778      *  instead of the MSDN documented value of 0 if handled.
     4779      *  (For laughs see the "consistancy" with same function
     4780      *   in rebar.)
     4781      *
     4782      *****************************************************/
     4783{
     4784    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
     4785    BOOL oldredraw = infoPtr->bDoRedraw;
     4786
     4787    TRACE("set to %s\n",
     4788          (wParam) ? "TRUE" : "FALSE");
     4789    infoPtr->bDoRedraw = (BOOL) wParam;
     4790    if (wParam) {
     4791        InvalidateRect (infoPtr->hwndSelf, 0, TRUE);
     4792    }
     4793    return (oldredraw) ? 1 : 0;
     4794}
     4795
     4796
     4797static LRESULT
    47614798TOOLBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
    47624799{
     
    51915228            return TOOLBAR_Paint (hwnd, wParam);
    51925229
     5230        case WM_SETREDRAW:
     5231            return TOOLBAR_SetRedraw (hwnd, wParam, lParam);
     5232
    51935233        case WM_SIZE:
    51945234            return TOOLBAR_Size (hwnd, wParam, lParam);
     
    52065246        case WM_MEASUREITEM:
    52075247        case WM_VKEYTOITEM:
    5208             return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
     5248            {
     5249                TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
     5250                if(infoPtr != NULL)
     5251                    return SendMessageA (infoPtr->hwndNotify, uMsg, wParam, lParam);
     5252                else
     5253                    return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
     5254            }
    52095255
    52105256        default:
Note: See TracChangeset for help on using the changeset viewer.