Changeset 6709 for trunk/src/comctl32


Ignore:
Timestamp:
Sep 15, 2001, 11:26:26 AM (24 years ago)
Author:
sandervl
Message:

restored old version

Location:
trunk/src/comctl32
Files:
10 edited

Legend:

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

    r6705 r6709  
    44 *
    55 * Copyright 1998, 1999 Eric Kohl
    6  *         1999 Eric Pouech
     6 *                 1999 Eric Pouech
    77 *
    88 * NOTES
     
    3333#endif
    3434   /* reference to input stream (file or resource) */
    35    HGLOBAL      hRes;
    36    HMMIO        hMMio;  /* handle to mmio stream */
    37    HWND         hWnd;
     35   HGLOBAL              hRes;
     36   HMMIO                hMMio;  /* handle to mmio stream */
     37   HWND                 hWnd;
    3838   /* information on the loaded AVI file */
    39    MainAVIHeader    mah;
    40    AVIStreamHeader  ash;
    41    LPBITMAPINFOHEADER   inbih;
    42    LPDWORD      lpIndex;
     39   MainAVIHeader        mah;
     40   AVIStreamHeader      ash;
     41   LPBITMAPINFOHEADER   inbih;
     42   LPDWORD              lpIndex;
    4343   /* data for the decompressor */
    44    HIC          hic;
    45    LPBITMAPINFOHEADER   outbih;
    46    LPVOID       indata;
    47    LPVOID       outdata;
     44   HIC                  hic;
     45   LPBITMAPINFOHEADER   outbih;
     46   LPVOID               indata;
     47   LPVOID               outdata;
    4848   /* data for the background mechanism */
    49    CRITICAL_SECTION cs;
    50    HANDLE       hThread;
    51    UINT         uTimer;
     49   CRITICAL_SECTION     cs;
     50   HANDLE               hThread;
     51   UINT                 uTimer;
    5252   /* data for playing the file */
    53    int          nFromFrame;
    54    int          nToFrame;
    55    int          nLoop;
    56    int          currFrame;
     53   int                  nFromFrame;
     54   int                  nToFrame;
     55   int                  nLoop;
     56   int                  currFrame;
    5757   /* tranparency info*/
    58    COLORREF             transparentColor;
    59    HBRUSH               hbrushBG;
    60    HBITMAP              hbmPrevFrame;
     58   COLORREF             transparentColor;   
     59   HBRUSH               hbrushBG;
     60   HBITMAP              hbmPrevFrame;
    6161} ANIMATE_INFO;
    6262
    6363#define ANIMATE_GetInfoPtr(hWnd) ((ANIMATE_INFO *)GetWindowLongA(hWnd, 0))
    64 #define ANIMATE_COLOR_NONE      0xffffffff
     64#define ANIMATE_COLOR_NONE      0xffffffff
    6565
    6666static void ANIMATE_Notify(ANIMATE_INFO* infoPtr, UINT notif)
    6767{
    68     SendMessageA(GetParent(infoPtr->hWnd), WM_COMMAND,
    69          MAKEWPARAM(GetDlgCtrlID(infoPtr->hWnd), notif),
    70         (LPARAM)infoPtr->hWnd);
     68    SendMessageA(GetParent(infoPtr->hWnd), WM_COMMAND, 
     69                 MAKEWPARAM(GetDlgCtrlID(infoPtr->hWnd), notif),
     70                (LPARAM)infoPtr->hWnd);
    7171}
    7272
     
    7777#endif
    7878{
    79     HRSRC   hrsrc;
    80     MMIOINFO    mminfo;
    81     LPVOID  lpAvi;
    82 
     79    HRSRC       hrsrc;
     80    MMIOINFO    mminfo;
     81    LPVOID      lpAvi;
     82   
    8383#ifdef __WIN32OS2__
    8484    if (unicode)
     
    9090#endif
    9191    if (!hrsrc)
    92     return FALSE;
    93 
     92        return FALSE;
     93   
    9494    infoPtr->hRes = LoadResource(hInst, hrsrc);
    9595    if (!infoPtr->hRes)
    96     return FALSE;
    97 
     96        return FALSE;
     97   
    9898    lpAvi = LockResource(infoPtr->hRes);
    9999    if (!lpAvi)
    100     return FALSE;
    101 
     100        return FALSE;
     101   
    102102    memset(&mminfo, 0, sizeof(mminfo));
    103103    mminfo.fccIOProc = FOURCC_MEM;
     
    106106    infoPtr->hMMio = mmioOpenA(NULL, &mminfo, MMIO_READ);
    107107    if (!infoPtr->hMMio) {
    108     GlobalFree((HGLOBAL)lpAvi);
    109     return FALSE;
     108        GlobalFree((HGLOBAL)lpAvi);
     109        return FALSE;
    110110    }
    111111
     
    127127#else
    128128    infoPtr->hMMio = mmioOpenA((LPSTR)lpName, NULL,
    129                    MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE);
     129                               MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE);
    130130#endif
    131131    if (!infoPtr->hMMio)
    132     return FALSE;
    133 
     132        return FALSE;
     133   
    134134    return TRUE;
    135135}
     
    141141
    142142    /* should stop playing */
    143     if (infoPtr->hThread)
     143    if (infoPtr->hThread) 
    144144    {
    145145        if (!TerminateThread(infoPtr->hThread,0))
    146146            WARN("could not destroy animation thread!\n");
    147         infoPtr->hThread = 0;
     147            infoPtr->hThread = 0;
    148148    }
    149149    if (infoPtr->uTimer) {
    150     KillTimer(infoPtr->hWnd, infoPtr->uTimer);
    151     infoPtr->uTimer = 0;
     150        KillTimer(infoPtr->hWnd, infoPtr->uTimer);
     151        infoPtr->uTimer = 0;
    152152    }
    153153
     
    163163{
    164164    if (infoPtr->hMMio) {
    165     ANIMATE_DoStop(infoPtr);
    166     mmioClose(infoPtr->hMMio, 0);
    167     if (infoPtr->hRes) {
    168         FreeResource(infoPtr->hRes);
    169         infoPtr->hRes = 0;
    170     }
    171     if (infoPtr->lpIndex) {
    172         HeapFree(GetProcessHeap(), 0, infoPtr->lpIndex);
    173         infoPtr->lpIndex = NULL;
    174     }
    175     if (infoPtr->hic) {
    176         ICClose(infoPtr->hic);
    177         infoPtr->hic = 0;
    178     }
    179     if (infoPtr->inbih) {
    180         HeapFree(GetProcessHeap(), 0, infoPtr->inbih);
    181         infoPtr->inbih = NULL;
    182     }
    183     if (infoPtr->outbih) {
    184         HeapFree(GetProcessHeap(), 0, infoPtr->outbih);
    185         infoPtr->outbih = NULL;
    186     }
     165        ANIMATE_DoStop(infoPtr);
     166        mmioClose(infoPtr->hMMio, 0);
     167        if (infoPtr->hRes) {
     168            FreeResource(infoPtr->hRes);
     169            infoPtr->hRes = 0;
     170        }
     171        if (infoPtr->lpIndex) {
     172            HeapFree(GetProcessHeap(), 0, infoPtr->lpIndex);
     173            infoPtr->lpIndex = NULL;
     174        }
     175        if (infoPtr->hic) {
     176            ICClose(infoPtr->hic);
     177            infoPtr->hic = 0;
     178        }
     179        if (infoPtr->inbih) {
     180            HeapFree(GetProcessHeap(), 0, infoPtr->inbih);
     181            infoPtr->inbih = NULL;
     182        }
     183        if (infoPtr->outbih) {
     184            HeapFree(GetProcessHeap(), 0, infoPtr->outbih);
     185            infoPtr->outbih = NULL;
     186        }
    187187        if( infoPtr->indata )
    188188        {
    189     HeapFree(GetProcessHeap(), 0, infoPtr->indata);
     189        HeapFree(GetProcessHeap(), 0, infoPtr->indata);
    190190            infoPtr->indata = NULL;
    191191        }
    192         if( infoPtr->outdata )
     192        if( infoPtr->outdata )
    193193        {
    194     HeapFree(GetProcessHeap(), 0, infoPtr->outdata);
     194        HeapFree(GetProcessHeap(), 0, infoPtr->outdata);
    195195            infoPtr->outdata = NULL;
    196196        }
    197         if( infoPtr->hbmPrevFrame )
     197        if( infoPtr->hbmPrevFrame )
    198198        {
    199         DeleteObject(infoPtr->hbmPrevFrame);
     199            DeleteObject(infoPtr->hbmPrevFrame);
    200200            infoPtr->hbmPrevFrame = 0;
    201201        }
    202     infoPtr->indata = infoPtr->outdata = NULL;
    203     infoPtr->hWnd = 0;
    204     infoPtr->hMMio = 0;
    205 
    206     memset(&infoPtr->mah, 0, sizeof(infoPtr->mah));
    207     memset(&infoPtr->ash, 0, sizeof(infoPtr->ash));
    208     infoPtr->nFromFrame = infoPtr->nToFrame = infoPtr->nLoop = infoPtr->currFrame = 0;
    209     }
    210     infoPtr->transparentColor = ANIMATE_COLOR_NONE;
     202        infoPtr->indata = infoPtr->outdata = NULL;
     203        infoPtr->hWnd = 0;
     204        infoPtr->hMMio = 0;
     205       
     206        memset(&infoPtr->mah, 0, sizeof(infoPtr->mah));
     207        memset(&infoPtr->ash, 0, sizeof(infoPtr->ash));
     208        infoPtr->nFromFrame = infoPtr->nToFrame = infoPtr->nLoop = infoPtr->currFrame = 0;
     209    }
     210    infoPtr->transparentColor = ANIMATE_COLOR_NONE;   
    211211}
    212212
    213213static void ANIMATE_TransparentBlt(ANIMATE_INFO* infoPtr, HDC hdcDest, HDC hdcSource)
    214 {
     214{       
    215215    HDC hdcMask;
    216216    HBITMAP hbmMask;
    217     HBITMAP hbmOld;
    218 
     217    HBITMAP hbmOld;           
     218   
    219219    /* create a transparency mask */
    220220    hdcMask = CreateCompatibleDC(hdcDest);
    221     hbmMask = CreateBitmap(infoPtr->inbih->biWidth, infoPtr->inbih->biHeight, 1,1,NULL);
    222     hbmOld = SelectObject(hdcMask, hbmMask);
     221    hbmMask = CreateBitmap(infoPtr->inbih->biWidth, infoPtr->inbih->biHeight, 1,1,NULL);   
     222    hbmOld = SelectObject(hdcMask, hbmMask);             
    223223
    224224    SetBkColor(hdcSource,infoPtr->transparentColor);
    225225    BitBlt(hdcMask,0,0,infoPtr->inbih->biWidth, infoPtr->inbih->biHeight,hdcSource,0,0,SRCCOPY);
    226 
     226           
    227227    /* mask the source bitmap */
    228     SetBkColor(hdcSource, RGB(0,0,0));
    229     SetTextColor(hdcSource, RGB(255,255,255));
     228    SetBkColor(hdcSource, RGB(0,0,0));         
     229    SetTextColor(hdcSource, RGB(255,255,255)); 
    230230    BitBlt(hdcSource, 0, 0, infoPtr->inbih->biWidth, infoPtr->inbih->biHeight, hdcMask, 0, 0, SRCAND);
    231231
    232232    /* mask the destination bitmap */
    233     SetBkColor(hdcDest, RGB(255,255,255));
    234     SetTextColor(hdcDest, RGB(0,0,0));
     233    SetBkColor(hdcDest, RGB(255,255,255));   
     234    SetTextColor(hdcDest, RGB(0,0,0));         
    235235    BitBlt(hdcDest, 0, 0, infoPtr->inbih->biWidth, infoPtr->inbih->biHeight, hdcMask, 0, 0, SRCAND);
    236236
     
    258258
    259259    if (!hDC || !infoPtr->inbih)
    260     return TRUE;
     260        return TRUE;
    261261
    262262    if (infoPtr->hic )
     
    266266
    267267        nWidth = infoPtr->outbih->biWidth;
    268         nHeight = infoPtr->outbih->biHeight;
     268        nHeight = infoPtr->outbih->biHeight; 
    269269    } else
    270     {
     270    { 
    271271        pBitmapData = infoPtr->indata;
    272272        pBitmapInfo = (LPBITMAPINFO)infoPtr->inbih;
    273273
    274274        nWidth = infoPtr->inbih->biWidth;
    275         nHeight = infoPtr->inbih->biHeight;
    276     }
     275        nHeight = infoPtr->inbih->biHeight; 
     276    } 
    277277
    278278    if(!infoPtr->hbmPrevFrame)
     
    281281    }
    282282
    283     SetDIBits(hDC, infoPtr->hbmPrevFrame, 0, nHeight, pBitmapData, (LPBITMAPINFO)pBitmapInfo, DIB_RGB_COLORS);
    284 
     283    SetDIBits(hDC, infoPtr->hbmPrevFrame, 0, nHeight, pBitmapData, (LPBITMAPINFO)pBitmapInfo, DIB_RGB_COLORS); 
     284   
    285285    hdcMem = CreateCompatibleDC(hDC);
    286286    hbmOld = SelectObject(hdcMem, infoPtr->hbmPrevFrame);
    287287
    288     /*
    289      * we need to get the transparent color even without ACS_TRANSPARENT,
     288    /* 
     289     * we need to get the transparent color even without ACS_TRANSPARENT, 
    290290     * because the style can be changed later on and the color should always
    291      * be obtained in the first frame
     291     * be obtained in the first frame 
    292292     */
    293293    if(infoPtr->transparentColor == ANIMATE_COLOR_NONE)
    294294    {
    295295        infoPtr->transparentColor = GetPixel(hdcMem,0,0);
    296     }
    297 
    298     if(GetWindowLongA(infoPtr->hWnd, GWL_STYLE) & ACS_TRANSPARENT)
    299     {
     296    } 
     297
     298    if(GetWindowLongA(infoPtr->hWnd, GWL_STYLE) & ACS_TRANSPARENT) 
     299    { 
    300300        HDC hdcFinal = CreateCompatibleDC(hDC);
    301301        HBITMAP hbmFinal = CreateCompatibleBitmap(hDC,nWidth, nHeight);
    302302        HBITMAP hbmOld2 = SelectObject(hdcFinal, hbmFinal);
    303303        RECT rect;
    304 
     304       
    305305        rect.left = 0;
    306306        rect.top = 0;
    307307        rect.right = nWidth;
    308308        rect.bottom = nHeight;
    309 
     309       
    310310        if(!infoPtr->hbrushBG)
    311311            infoPtr->hbrushBG = GetCurrentObject(hDC, OBJ_BRUSH);
     
    320320        infoPtr->hbmPrevFrame = hbmFinal;
    321321         }
    322 
    323     if (GetWindowLongA(infoPtr->hWnd, GWL_STYLE) & ACS_CENTER)
     322   
     323    if (GetWindowLongA(infoPtr->hWnd, GWL_STYLE) & ACS_CENTER) 
    324324    {
    325        RECT rect;
     325       RECT rect;   
    326326
    327327       GetWindowRect(infoPtr->hWnd, &rect);
    328        nOffsetX = ((rect.right - rect.left) - nWidth)/2;
    329        nOffsetY = ((rect.bottom - rect.top) - nHeight)/2;
    330     }
    331     BitBlt(hDC, nOffsetX, nOffsetY, nWidth, nHeight, hdcMem, 0, 0, SRCCOPY);
     328       nOffsetX = ((rect.right - rect.left) - nWidth)/2; 
     329       nOffsetY = ((rect.bottom - rect.top) - nHeight)/2; 
     330    }
     331    BitBlt(hDC, nOffsetX, nOffsetY, nWidth, nHeight, hdcMem, 0, 0, SRCCOPY);   
    332332
    333333    SelectObject(hdcMem, hbmOld);
     
    338338static LRESULT ANIMATE_DrawFrame(ANIMATE_INFO* infoPtr)
    339339{
    340     HDC     hDC;
     340    HDC         hDC;
    341341
    342342    TRACE("Drawing frame %d (loop %d)\n", infoPtr->currFrame, infoPtr->nLoop);
     
    346346    mmioSeek(infoPtr->hMMio, infoPtr->lpIndex[infoPtr->currFrame], SEEK_SET);
    347347    mmioRead(infoPtr->hMMio, infoPtr->indata, infoPtr->ash.dwSuggestedBufferSize);
    348 
     348   
    349349    if (infoPtr->hic &&
    350     ICDecompress(infoPtr->hic, 0, infoPtr->inbih, infoPtr->indata,
    351              infoPtr->outbih, infoPtr->outdata) != ICERR_OK) {
     350        ICDecompress(infoPtr->hic, 0, infoPtr->inbih, infoPtr->indata,
     351                     infoPtr->outbih, infoPtr->outdata) != ICERR_OK) {
     352        LeaveCriticalSection(&infoPtr->cs);
     353        WARN("Decompression error\n");
     354        return FALSE;
     355    }
     356
     357    if ((hDC = GetDC(infoPtr->hWnd)) != 0) {
     358        ANIMATE_PaintFrame(infoPtr, hDC);
     359        ReleaseDC(infoPtr->hWnd, hDC);
     360    }
     361
     362    if (infoPtr->currFrame++ >= infoPtr->nToFrame) {
     363        infoPtr->currFrame = infoPtr->nFromFrame;
     364        if (infoPtr->nLoop != -1) {
     365            if (--infoPtr->nLoop == 0) {
     366                ANIMATE_DoStop(infoPtr);
     367            }
     368        }
     369    }
    352370    LeaveCriticalSection(&infoPtr->cs);
    353     WARN("Decompression error\n");
    354     return FALSE;
    355     }
    356 
    357     if ((hDC = GetDC(infoPtr->hWnd)) != 0) {
    358     ANIMATE_PaintFrame(infoPtr, hDC);
    359     ReleaseDC(infoPtr->hWnd, hDC);
    360     }
    361 
    362     if (infoPtr->currFrame++ >= infoPtr->nToFrame) {
    363     infoPtr->currFrame = infoPtr->nFromFrame;
    364     if (infoPtr->nLoop != -1) {
    365         if (--infoPtr->nLoop == 0) {
    366         ANIMATE_DoStop(infoPtr);
    367         }
    368     }
    369     }
    370     LeaveCriticalSection(&infoPtr->cs);
    371371
    372372    return TRUE;
     
    375375static DWORD CALLBACK ANIMATE_AnimationThread(LPVOID ptr_)
    376376{
    377     ANIMATE_INFO*   infoPtr = (ANIMATE_INFO*)ptr_;
     377    ANIMATE_INFO*       infoPtr = (ANIMATE_INFO*)ptr_;
    378378    HDC hDC;
    379 
     379   
    380380    if(!infoPtr)
    381381    {
     
    385385
    386386    while(1)
    387     {
    388         if(GetWindowLongA(infoPtr->hWnd, GWL_STYLE) & ACS_TRANSPARENT)
     387    {   
     388        if(GetWindowLongA(infoPtr->hWnd, GWL_STYLE) & ACS_TRANSPARENT) 
    389389        {
    390390            hDC = GetDC(infoPtr->hWnd);
    391         /* sometimes the animation window will be destroyed in between
    392          * by the main program, so a ReleaseDC() error msg is possible */
     391            /* sometimes the animation window will be destroyed in between
     392             * by the main program, so a ReleaseDC() error msg is possible */
    393393            infoPtr->hbrushBG = SendMessageA(GetParent(infoPtr->hWnd),WM_CTLCOLORSTATIC,hDC, infoPtr->hWnd);
    394394            ReleaseDC(infoPtr->hWnd,hDC);
    395395        }
    396 
     396       
    397397        EnterCriticalSection(&infoPtr->cs);
    398398        ANIMATE_DrawFrame(infoPtr);
    399399        LeaveCriticalSection(&infoPtr->cs);
    400 
     400   
    401401        /* time is in microseconds, we should convert it to milliseconds */
    402402        Sleep((infoPtr->mah.dwMicroSecPerFrame+500)/1000);
     
    411411    /* nothing opened */
    412412    if (!infoPtr->hMMio)
    413     return FALSE;
     413        return FALSE;
    414414
    415415    if (infoPtr->hThread || infoPtr->uTimer) {
    416     FIXME("Already playing ? what should I do ??\n");
    417     ANIMATE_DoStop(infoPtr);
     416        FIXME("Already playing ? what should I do ??\n");
     417        ANIMATE_DoStop(infoPtr);
    418418    }
    419419
     
    423423
    424424    if (infoPtr->nToFrame == 0xFFFF)
    425     infoPtr->nToFrame = infoPtr->mah.dwTotalFrames - 1;
    426 
    427     TRACE("(repeat=%d from=%d to=%d);\n",
    428       infoPtr->nLoop, infoPtr->nFromFrame, infoPtr->nToFrame);
     425        infoPtr->nToFrame = infoPtr->mah.dwTotalFrames - 1;
     426
     427    TRACE("(repeat=%d from=%d to=%d);\n", 
     428          infoPtr->nLoop, infoPtr->nFromFrame, infoPtr->nToFrame);
    429429
    430430    if (infoPtr->nFromFrame >= infoPtr->nToFrame ||
    431     infoPtr->nToFrame >= infoPtr->mah.dwTotalFrames)
    432     return FALSE;
     431        infoPtr->nToFrame >= infoPtr->mah.dwTotalFrames)
     432        return FALSE;
    433433
    434434    infoPtr->currFrame = infoPtr->nFromFrame;
    435435
    436436    if (GetWindowLongA(hWnd, GWL_STYLE) & ACS_TIMER) {
    437     TRACE("Using a timer\n");
    438     /* create a timer to display AVI */
    439     infoPtr->uTimer = SetTimer(hWnd, 1, infoPtr->mah.dwMicroSecPerFrame / 1000, NULL);
     437        TRACE("Using a timer\n");
     438        /* create a timer to display AVI */
     439        infoPtr->uTimer = SetTimer(hWnd, 1, infoPtr->mah.dwMicroSecPerFrame / 1000, NULL);
    440440    } else {
    441441        DWORD threadID;
    442442
    443     TRACE("Using an animation thread\n");
     443        TRACE("Using an animation thread\n");
    444444        infoPtr->hThread = CreateThread(0,0,ANIMATE_AnimationThread,(LPVOID)infoPtr,0,0 &threadID);
    445445        if(!infoPtr->hThread)
     
    448448           return FALSE;
    449449    }
    450 
    451     }
    452 
     450       
     451    }
     452       
    453453    ANIMATE_Notify(infoPtr, ACN_START);
    454454
     
    459459static BOOL ANIMATE_GetAviInfo(ANIMATE_INFO *infoPtr)
    460460{
    461     MMCKINFO        ckMainRIFF;
    462     MMCKINFO        mmckHead;
    463     MMCKINFO        mmckList;
    464     MMCKINFO        mmckInfo;
    465     DWORD       numFrame;
    466     DWORD       insize;
     461    MMCKINFO            ckMainRIFF;
     462    MMCKINFO            mmckHead;
     463    MMCKINFO            mmckList;
     464    MMCKINFO            mmckInfo;
     465    DWORD               numFrame;
     466    DWORD               insize;
    467467
    468468    if (mmioDescend(infoPtr->hMMio, &ckMainRIFF, NULL, 0) != 0) {
    469     WARN("Can't find 'RIFF' chunk\n");
    470     return FALSE;
     469        WARN("Can't find 'RIFF' chunk\n");
     470        return FALSE;
    471471    }
    472472
    473473    if ((ckMainRIFF.ckid != FOURCC_RIFF) ||
    474     (ckMainRIFF.fccType != mmioFOURCC('A', 'V', 'I', ' '))) {
    475     WARN("Can't find 'AVI ' chunk\n");
    476     return FALSE;
     474        (ckMainRIFF.fccType != mmioFOURCC('A', 'V', 'I', ' '))) {
     475        WARN("Can't find 'AVI ' chunk\n");
     476        return FALSE;
    477477    }
    478478
    479479    mmckHead.fccType = mmioFOURCC('h', 'd', 'r', 'l');
    480480    if (mmioDescend(infoPtr->hMMio, &mmckHead, &ckMainRIFF, MMIO_FINDLIST) != 0) {
    481     WARN("Can't find 'hdrl' list\n");
    482     return FALSE;
     481        WARN("Can't find 'hdrl' list\n");
     482        return FALSE;
    483483    }
    484484
    485485    mmckInfo.ckid = mmioFOURCC('a', 'v', 'i', 'h');
    486486    if (mmioDescend(infoPtr->hMMio, &mmckInfo, &mmckHead, MMIO_FINDCHUNK) != 0) {
    487     WARN("Can't find 'avih' chunk\n");
    488     return FALSE;
     487        WARN("Can't find 'avih' chunk\n");
     488        return FALSE;
    489489    }
    490490
    491491    mmioRead(infoPtr->hMMio, (LPSTR)&infoPtr->mah, sizeof(infoPtr->mah));
    492492
    493     TRACE("mah.dwMicroSecPerFrame=%ld\n",   infoPtr->mah.dwMicroSecPerFrame);
    494     TRACE("mah.dwMaxBytesPerSec=%ld\n",     infoPtr->mah.dwMaxBytesPerSec);
    495     TRACE("mah.dwPaddingGranularity=%ld\n",     infoPtr->mah.dwPaddingGranularity);
    496     TRACE("mah.dwFlags=%ld\n",          infoPtr->mah.dwFlags);
    497     TRACE("mah.dwTotalFrames=%ld\n",        infoPtr->mah.dwTotalFrames);
    498     TRACE("mah.dwInitialFrames=%ld\n",      infoPtr->mah.dwInitialFrames);
    499     TRACE("mah.dwStreams=%ld\n",        infoPtr->mah.dwStreams);
    500     TRACE("mah.dwSuggestedBufferSize=%ld\n",    infoPtr->mah.dwSuggestedBufferSize);
    501     TRACE("mah.dwWidth=%ld\n",          infoPtr->mah.dwWidth);
    502     TRACE("mah.dwHeight=%ld\n",         infoPtr->mah.dwHeight);
     493    TRACE("mah.dwMicroSecPerFrame=%ld\n",       infoPtr->mah.dwMicroSecPerFrame);
     494    TRACE("mah.dwMaxBytesPerSec=%ld\n",         infoPtr->mah.dwMaxBytesPerSec);
     495    TRACE("mah.dwPaddingGranularity=%ld\n",     infoPtr->mah.dwPaddingGranularity);
     496    TRACE("mah.dwFlags=%ld\n",                  infoPtr->mah.dwFlags);
     497    TRACE("mah.dwTotalFrames=%ld\n",            infoPtr->mah.dwTotalFrames);
     498    TRACE("mah.dwInitialFrames=%ld\n",          infoPtr->mah.dwInitialFrames);
     499    TRACE("mah.dwStreams=%ld\n",                infoPtr->mah.dwStreams);
     500    TRACE("mah.dwSuggestedBufferSize=%ld\n",    infoPtr->mah.dwSuggestedBufferSize);
     501    TRACE("mah.dwWidth=%ld\n",                  infoPtr->mah.dwWidth);
     502    TRACE("mah.dwHeight=%ld\n",                 infoPtr->mah.dwHeight);
    503503
    504504    mmioAscend(infoPtr->hMMio, &mmckInfo, 0);
     
    506506    mmckList.fccType = mmioFOURCC('s', 't', 'r', 'l');
    507507    if (mmioDescend(infoPtr->hMMio, &mmckList, &mmckHead, MMIO_FINDLIST) != 0) {
    508     WARN("Can't find 'strl' list\n");
    509     return FALSE;
     508        WARN("Can't find 'strl' list\n");
     509        return FALSE;
    510510    }
    511511
    512512    mmckInfo.ckid = mmioFOURCC('s', 't', 'r', 'h');
    513513    if (mmioDescend(infoPtr->hMMio, &mmckInfo, &mmckList, MMIO_FINDCHUNK) != 0) {
    514     WARN("Can't find 'strh' chunk\n");
    515     return FALSE;
     514        WARN("Can't find 'strh' chunk\n");
     515        return FALSE;
    516516    }
    517517
    518518    mmioRead(infoPtr->hMMio, (LPSTR)&infoPtr->ash, sizeof(infoPtr->ash));
    519519
    520     TRACE("ash.fccType='%c%c%c%c'\n",       LOBYTE(LOWORD(infoPtr->ash.fccType)),
    521                                             HIBYTE(LOWORD(infoPtr->ash.fccType)),
    522                                             LOBYTE(HIWORD(infoPtr->ash.fccType)),
    523                                             HIBYTE(HIWORD(infoPtr->ash.fccType)));
    524     TRACE("ash.fccHandler='%c%c%c%c'\n",    LOBYTE(LOWORD(infoPtr->ash.fccHandler)),
    525                                             HIBYTE(LOWORD(infoPtr->ash.fccHandler)),
    526                                             LOBYTE(HIWORD(infoPtr->ash.fccHandler)),
    527                                             HIBYTE(HIWORD(infoPtr->ash.fccHandler)));
    528     TRACE("ash.dwFlags=%ld\n",          infoPtr->ash.dwFlags);
    529     TRACE("ash.wPriority=%d\n",         infoPtr->ash.wPriority);
    530     TRACE("ash.wLanguage=%d\n",         infoPtr->ash.wLanguage);
    531     TRACE("ash.dwInitialFrames=%ld\n",      infoPtr->ash.dwInitialFrames);
    532     TRACE("ash.dwScale=%ld\n",          infoPtr->ash.dwScale);
    533     TRACE("ash.dwRate=%ld\n",           infoPtr->ash.dwRate);
    534     TRACE("ash.dwStart=%ld\n",          infoPtr->ash.dwStart);
    535     TRACE("ash.dwLength=%ld\n",         infoPtr->ash.dwLength);
    536     TRACE("ash.dwSuggestedBufferSize=%ld\n",    infoPtr->ash.dwSuggestedBufferSize);
    537     TRACE("ash.dwQuality=%ld\n",        infoPtr->ash.dwQuality);
    538     TRACE("ash.dwSampleSize=%ld\n",         infoPtr->ash.dwSampleSize);
    539     TRACE("ash.rcFrame=(%d,%d,%d,%d)\n",    infoPtr->ash.rcFrame.top, infoPtr->ash.rcFrame.left,
    540       infoPtr->ash.rcFrame.bottom, infoPtr->ash.rcFrame.right);
     520    TRACE("ash.fccType='%c%c%c%c'\n",           LOBYTE(LOWORD(infoPtr->ash.fccType)),
     521                                                HIBYTE(LOWORD(infoPtr->ash.fccType)),
     522                                                LOBYTE(HIWORD(infoPtr->ash.fccType)),
     523                                                HIBYTE(HIWORD(infoPtr->ash.fccType)));
     524    TRACE("ash.fccHandler='%c%c%c%c'\n",        LOBYTE(LOWORD(infoPtr->ash.fccHandler)),
     525                                                HIBYTE(LOWORD(infoPtr->ash.fccHandler)),
     526                                                LOBYTE(HIWORD(infoPtr->ash.fccHandler)),
     527                                                HIBYTE(HIWORD(infoPtr->ash.fccHandler)));
     528    TRACE("ash.dwFlags=%ld\n",                  infoPtr->ash.dwFlags);
     529    TRACE("ash.wPriority=%d\n",                 infoPtr->ash.wPriority);
     530    TRACE("ash.wLanguage=%d\n",                 infoPtr->ash.wLanguage);
     531    TRACE("ash.dwInitialFrames=%ld\n",          infoPtr->ash.dwInitialFrames);
     532    TRACE("ash.dwScale=%ld\n",                  infoPtr->ash.dwScale);
     533    TRACE("ash.dwRate=%ld\n",                   infoPtr->ash.dwRate);
     534    TRACE("ash.dwStart=%ld\n",                  infoPtr->ash.dwStart);
     535    TRACE("ash.dwLength=%ld\n",                 infoPtr->ash.dwLength);
     536    TRACE("ash.dwSuggestedBufferSize=%ld\n",    infoPtr->ash.dwSuggestedBufferSize);
     537    TRACE("ash.dwQuality=%ld\n",                infoPtr->ash.dwQuality);
     538    TRACE("ash.dwSampleSize=%ld\n",             infoPtr->ash.dwSampleSize);
     539    TRACE("ash.rcFrame=(%d,%d,%d,%d)\n",        infoPtr->ash.rcFrame.top, infoPtr->ash.rcFrame.left,
     540          infoPtr->ash.rcFrame.bottom, infoPtr->ash.rcFrame.right);
    541541
    542542    mmioAscend(infoPtr->hMMio, &mmckInfo, 0);
     
    544544    mmckInfo.ckid = mmioFOURCC('s', 't', 'r', 'f');
    545545    if (mmioDescend(infoPtr->hMMio, &mmckInfo, &mmckList, MMIO_FINDCHUNK) != 0) {
    546     WARN("Can't find 'strh' chunk\n");
    547     return FALSE;
     546        WARN("Can't find 'strh' chunk\n");
     547        return FALSE;
    548548    }
    549549
    550550    infoPtr->inbih = HeapAlloc(GetProcessHeap(), 0, mmckInfo.cksize);
    551551    if (!infoPtr->inbih) {
    552     WARN("Can't alloc input BIH\n");
    553     return FALSE;
     552        WARN("Can't alloc input BIH\n");
     553        return FALSE;
    554554    }
    555555
    556556    mmioRead(infoPtr->hMMio, (LPSTR)infoPtr->inbih, mmckInfo.cksize);
    557557
    558     TRACE("bih.biSize=%ld\n",       infoPtr->inbih->biSize);
    559     TRACE("bih.biWidth=%ld\n",      infoPtr->inbih->biWidth);
    560     TRACE("bih.biHeight=%ld\n",     infoPtr->inbih->biHeight);
    561     TRACE("bih.biPlanes=%d\n",      infoPtr->inbih->biPlanes);
    562     TRACE("bih.biBitCount=%d\n",    infoPtr->inbih->biBitCount);
    563     TRACE("bih.biCompression=%ld\n",    infoPtr->inbih->biCompression);
    564     TRACE("bih.biSizeImage=%ld\n",  infoPtr->inbih->biSizeImage);
    565     TRACE("bih.biXPelsPerMeter=%ld\n",  infoPtr->inbih->biXPelsPerMeter);
    566     TRACE("bih.biYPelsPerMeter=%ld\n",  infoPtr->inbih->biYPelsPerMeter);
    567     TRACE("bih.biClrUsed=%ld\n",    infoPtr->inbih->biClrUsed);
    568     TRACE("bih.biClrImportant=%ld\n",   infoPtr->inbih->biClrImportant);
     558    TRACE("bih.biSize=%ld\n",           infoPtr->inbih->biSize);
     559    TRACE("bih.biWidth=%ld\n",          infoPtr->inbih->biWidth);
     560    TRACE("bih.biHeight=%ld\n",         infoPtr->inbih->biHeight);
     561    TRACE("bih.biPlanes=%d\n",          infoPtr->inbih->biPlanes);
     562    TRACE("bih.biBitCount=%d\n",        infoPtr->inbih->biBitCount);
     563    TRACE("bih.biCompression=%ld\n",    infoPtr->inbih->biCompression);
     564    TRACE("bih.biSizeImage=%ld\n",      infoPtr->inbih->biSizeImage);
     565    TRACE("bih.biXPelsPerMeter=%ld\n",  infoPtr->inbih->biXPelsPerMeter);
     566    TRACE("bih.biYPelsPerMeter=%ld\n",  infoPtr->inbih->biYPelsPerMeter);
     567    TRACE("bih.biClrUsed=%ld\n",        infoPtr->inbih->biClrUsed);
     568    TRACE("bih.biClrImportant=%ld\n",   infoPtr->inbih->biClrImportant);
    569569
    570570    mmioAscend(infoPtr->hMMio, &mmckInfo, 0);
    571571
    572572    mmioAscend(infoPtr->hMMio, &mmckList, 0);
    573 
     573   
    574574#if 0
    575575    /* an AVI has 0 or 1 video stream, and to be animated should not contain
    576      * an audio stream, so only one strl is allowed
     576     * an audio stream, so only one strl is allowed 
    577577     */
    578578    mmckList.fccType = mmioFOURCC('s', 't', 'r', 'l');
    579579    if (mmioDescend(infoPtr->hMMio, &mmckList, &mmckHead, MMIO_FINDLIST) == 0) {
    580     WARN("There should be a single 'strl' list\n");
    581     return FALSE;
     580        WARN("There should be a single 'strl' list\n");
     581        return FALSE;
    582582    }
    583583#endif
     
    589589    mmckList.fccType = mmioFOURCC('m', 'o', 'v', 'i');
    590590    if (mmioDescend(infoPtr->hMMio, &mmckList, &ckMainRIFF, MMIO_FINDLIST) != 0) {
    591     WARN("Can't find 'movi' list\n");
    592     return FALSE;
     591        WARN("Can't find 'movi' list\n");
     592        return FALSE;
    593593    }
    594594
    595595    /* FIXME: should handle the 'rec ' LIST when present */
    596596
    597     infoPtr->lpIndex = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
    598                 infoPtr->mah.dwTotalFrames * sizeof(DWORD));
     597    infoPtr->lpIndex = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 
     598                                infoPtr->mah.dwTotalFrames * sizeof(DWORD));
    599599    if (!infoPtr->lpIndex) {
    600     WARN("Can't alloc index array\n");
    601     return FALSE;
     600        WARN("Can't alloc index array\n");
     601        return FALSE;
    602602    }
    603603
    604604    numFrame = insize = 0;
    605     while (mmioDescend(infoPtr->hMMio, &mmckInfo, &mmckList, 0) == 0 &&
    606        numFrame < infoPtr->mah.dwTotalFrames) {
    607     infoPtr->lpIndex[numFrame] = mmckInfo.dwDataOffset;
    608     if (insize < mmckInfo.cksize)
    609         insize = mmckInfo.cksize;
    610     numFrame++;
    611     mmioAscend(infoPtr->hMMio, &mmckInfo, 0);
     605    while (mmioDescend(infoPtr->hMMio, &mmckInfo, &mmckList, 0) == 0 && 
     606           numFrame < infoPtr->mah.dwTotalFrames) {
     607        infoPtr->lpIndex[numFrame] = mmckInfo.dwDataOffset;
     608        if (insize < mmckInfo.cksize)
     609            insize = mmckInfo.cksize;
     610        numFrame++;
     611        mmioAscend(infoPtr->hMMio, &mmckInfo, 0);
    612612    }
    613613    if (numFrame != infoPtr->mah.dwTotalFrames) {
    614     WARN("Found %ld frames (/%ld)\n", numFrame, infoPtr->mah.dwTotalFrames);
    615     return FALSE;
     614        WARN("Found %ld frames (/%ld)\n", numFrame, infoPtr->mah.dwTotalFrames);
     615        return FALSE;
    616616    }
    617617    if (insize > infoPtr->ash.dwSuggestedBufferSize) {
    618     WARN("insize=%ld suggestedSize=%ld\n", insize, infoPtr->ash.dwSuggestedBufferSize);
    619     infoPtr->ash.dwSuggestedBufferSize = insize;
     618        WARN("insize=%ld suggestedSize=%ld\n", insize, infoPtr->ash.dwSuggestedBufferSize);
     619        infoPtr->ash.dwSuggestedBufferSize = insize;
    620620    }
    621621
    622622    infoPtr->indata = HeapAlloc(GetProcessHeap(), 0, infoPtr->ash.dwSuggestedBufferSize);
    623623    if (!infoPtr->indata) {
    624     WARN("Can't alloc input buffer\n");
    625     return FALSE;
     624        WARN("Can't alloc input buffer\n");
     625        return FALSE;
    626626    }
    627627
     
    632632static BOOL    ANIMATE_GetAviCodec(ANIMATE_INFO *infoPtr)
    633633{
    634     DWORD   outSize;
     634    DWORD       outSize;
    635635
    636636    /* check uncompressed AVI */
     
    638638       (infoPtr->ash.fccHandler == mmioFOURCC('R', 'L', 'E', ' ')))
    639639    {
    640         infoPtr->hic = 0;
    641     return TRUE;
     640        infoPtr->hic = 0;             
     641        return TRUE;
    642642    }
    643643
     
    645645    infoPtr->hic = ICOpen(ICTYPE_VIDEO, infoPtr->ash.fccHandler, ICMODE_DECOMPRESS);
    646646    if (!infoPtr->hic) {
    647     WARN("Can't load codec for the file\n");
    648     return FALSE;
    649     }
    650 
    651     outSize = ICSendMessage(infoPtr->hic, ICM_DECOMPRESS_GET_FORMAT,
    652                 (DWORD)infoPtr->inbih, 0L);
     647        WARN("Can't load codec for the file\n");
     648        return FALSE;
     649    }
     650   
     651    outSize = ICSendMessage(infoPtr->hic, ICM_DECOMPRESS_GET_FORMAT, 
     652                            (DWORD)infoPtr->inbih, 0L);
    653653
    654654    infoPtr->outbih = HeapAlloc(GetProcessHeap(), 0, outSize);
    655655    if (!infoPtr->outbih) {
    656     WARN("Can't alloc output BIH\n");
    657     return FALSE;
    658     }
    659 
    660     if (ICSendMessage(infoPtr->hic, ICM_DECOMPRESS_GET_FORMAT,
    661               (DWORD)infoPtr->inbih, (DWORD)infoPtr->outbih) != ICERR_OK) {
    662     WARN("Can't get output BIH\n");
    663     return FALSE;
     656        WARN("Can't alloc output BIH\n");
     657        return FALSE;
     658    }
     659
     660    if (ICSendMessage(infoPtr->hic, ICM_DECOMPRESS_GET_FORMAT, 
     661                      (DWORD)infoPtr->inbih, (DWORD)infoPtr->outbih) != ICERR_OK) {
     662        WARN("Can't get output BIH\n");
     663        return FALSE;
    664664    }
    665665
    666666    infoPtr->outdata = HeapAlloc(GetProcessHeap(), 0, infoPtr->outbih->biSizeImage);
    667667    if (!infoPtr->outdata) {
    668     WARN("Can't alloc output buffer\n");
    669     return FALSE;
    670     }
    671 
    672     if (ICSendMessage(infoPtr->hic, ICM_DECOMPRESS_BEGIN,
    673               (DWORD)infoPtr->inbih, (DWORD)infoPtr->outbih) != ICERR_OK) {
    674     WARN("Can't begin decompression\n");
    675     return FALSE;
     668        WARN("Can't alloc output buffer\n");
     669        return FALSE;
     670    }
     671
     672    if (ICSendMessage(infoPtr->hic, ICM_DECOMPRESS_BEGIN, 
     673                      (DWORD)infoPtr->inbih, (DWORD)infoPtr->outbih) != ICERR_OK) {
     674        WARN("Can't begin decompression\n");
     675        return FALSE;
    676676    }
    677677
     
    691691
    692692    if (!lParam) {
    693     TRACE("Closing avi!\n");
    694     return TRUE;
    695     }
    696 
     693        TRACE("Closing avi!\n");
     694        return TRUE;
     695    }
     696   
    697697    if (!hInstance)
    698698       hInstance = GetWindowLongA(hWnd, GWL_HINSTANCE);
     
    719719#else
    720720    if (HIWORD(lParam)) {
    721     TRACE("(\"%s\");\n", (LPSTR)lParam);
    722 
    723     if (!ANIMATE_LoadResA(infoPtr, hInstance, (LPSTR)lParam)) {
    724         TRACE("No AVI resource found!\n");
    725         if (!ANIMATE_LoadFileA(infoPtr, (LPSTR)lParam)) {
    726         WARN("No AVI file found!\n");
    727         return FALSE;
    728         }
    729     }
     721        TRACE("(\"%s\");\n", (LPSTR)lParam);
     722
     723        if (!ANIMATE_LoadResA(infoPtr, hInstance, (LPSTR)lParam)) {
     724            TRACE("No AVI resource found!\n");
     725            if (!ANIMATE_LoadFileA(infoPtr, (LPSTR)lParam)) {
     726                WARN("No AVI file found!\n");
     727                return FALSE;
     728            }
     729        }
    730730    } else {
    731     TRACE("(%u);\n", (WORD)LOWORD(lParam));
    732 
    733     if (!ANIMATE_LoadResA(infoPtr, hInstance,
    734                   MAKEINTRESOURCEA((INT)lParam))) {
    735         WARN("No AVI resource found!\n");
    736         return FALSE;
    737     }
     731        TRACE("(%u);\n", (WORD)LOWORD(lParam));
     732
     733        if (!ANIMATE_LoadResA(infoPtr, hInstance,
     734                              MAKEINTRESOURCEA((INT)lParam))) {
     735            WARN("No AVI resource found!\n");
     736            return FALSE;
     737        }
    738738    }
    739739#endif
    740740    if (!ANIMATE_GetAviInfo(infoPtr)) {
    741     WARN("Can't get AVI information\n");
    742     ANIMATE_Free(infoPtr);
    743     return FALSE;
     741        WARN("Can't get AVI information\n");
     742        ANIMATE_Free(infoPtr);
     743        return FALSE;
    744744    }
    745745
    746746    if (!ANIMATE_GetAviCodec(infoPtr)) {
    747     WARN("Can't get AVI Codec\n");
    748     ANIMATE_Free(infoPtr);
    749     return FALSE;
     747        WARN("Can't get AVI Codec\n");
     748        ANIMATE_Free(infoPtr);
     749        return FALSE;
    750750    }
    751751
    752752    if (!GetWindowLongA(hWnd, GWL_STYLE) & ACS_CENTER) {
    753     SetWindowPos(hWnd, 0, 0, 0, infoPtr->mah.dwWidth, infoPtr->mah.dwHeight,
    754              SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER);
     753        SetWindowPos(hWnd, 0, 0, 0, infoPtr->mah.dwWidth, infoPtr->mah.dwHeight,
     754                     SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER);
    755755    }
    756756
    757757    if (GetWindowLongA(hWnd, GWL_STYLE) & ACS_AUTOPLAY) {
    758     return ANIMATE_Play(hWnd, -1, (LPARAM)MAKELONG(0, infoPtr->mah.dwTotalFrames-1));
     758        return ANIMATE_Play(hWnd, -1, (LPARAM)MAKELONG(0, infoPtr->mah.dwTotalFrames-1));
    759759    }
    760760
     
    771771    /* nothing opened */
    772772    if (!infoPtr->hMMio)
    773     return FALSE;
     773        return FALSE;
    774774
    775775    ANIMATE_DoStop(infoPtr);
     
    780780static LRESULT ANIMATE_Create(HWND hWnd, WPARAM wParam, LPARAM lParam)
    781781{
    782     ANIMATE_INFO*   infoPtr;
     782    ANIMATE_INFO*       infoPtr;
    783783
    784784    /* allocate memory for info structure */
     
    789789#endif
    790790    if (!infoPtr) {
    791     ERR("could not allocate info memory!\n");
    792     return 0;
     791        ERR("could not allocate info memory!\n");
     792        return 0;
    793793    }
    794794
     
    802802
    803803    InitializeCriticalSection(&infoPtr->cs);
    804 
     804   
    805805    return 0;
    806806}
     
    826826{
    827827    RECT rect;
    828     HBRUSH hBrush = 0;
    829 
    830     if(GetWindowLongA(hWnd, GWL_STYLE) & ACS_TRANSPARENT)
     828    HBRUSH hBrush = 0;       
     829
     830    if(GetWindowLongA(hWnd, GWL_STYLE) & ACS_TRANSPARENT) 
    831831    {
    832         hBrush = SendMessageA(GetParent(hWnd),WM_CTLCOLORSTATIC,(HDC)wParam, hWnd);
     832        hBrush = SendMessageA(GetParent(hWnd),WM_CTLCOLORSTATIC,(HDC)wParam, hWnd);   
    833833    }
    834834
     
    842842{
    843843    if (GetWindowLongA(hWnd, GWL_STYLE) & ACS_CENTER) {
    844     InvalidateRect(hWnd, NULL, TRUE);
     844        InvalidateRect(hWnd, NULL, TRUE);
    845845    }
    846846    return TRUE;
     
    851851    TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n", hWnd, uMsg, wParam, lParam);
    852852    if (!ANIMATE_GetInfoPtr(hWnd) && (uMsg != WM_NCCREATE))
    853     return DefWindowProcA(hWnd, uMsg, wParam, lParam);
     853        return DefWindowProcA(hWnd, uMsg, wParam, lParam);
    854854    switch (uMsg)
    855855    {
     
    862862#else
    863863    case ACM_OPENA:
    864     return ANIMATE_OpenA(hWnd, wParam, lParam);
    865 
    866     /*  case ACM_OPEN32W: FIXME!! */
    867     /*      return ANIMATE_Open32W(hWnd, wParam, lParam); */
    868 #endif
    869 
     864        return ANIMATE_OpenA(hWnd, wParam, lParam);
     865       
     866        /*      case ACM_OPEN32W: FIXME!! */
     867        /*          return ANIMATE_Open32W(hWnd, wParam, lParam); */
     868#endif
     869       
    870870    case ACM_PLAY:
    871     return ANIMATE_Play(hWnd, wParam, lParam);
    872 
     871        return ANIMATE_Play(hWnd, wParam, lParam);
     872       
    873873    case ACM_STOP:
    874     return ANIMATE_Stop(hWnd, wParam, lParam);
    875 
     874        return ANIMATE_Stop(hWnd, wParam, lParam);
     875       
    876876    case WM_NCCREATE:
    877     ANIMATE_Create(hWnd, wParam, lParam);
    878     return DefWindowProcA(hWnd, uMsg, wParam, lParam);
    879 
     877        ANIMATE_Create(hWnd, wParam, lParam);
     878        return DefWindowProcA(hWnd, uMsg, wParam, lParam);
     879       
    880880    case WM_NCHITTEST:
    881     return HTTRANSPARENT;
     881        return HTTRANSPARENT;
    882882
    883883    case WM_DESTROY:
    884     ANIMATE_Destroy(hWnd, wParam, lParam);
    885     return DefWindowProcA(hWnd, uMsg, wParam, lParam);
    886 
     884        ANIMATE_Destroy(hWnd, wParam, lParam);
     885        return DefWindowProcA(hWnd, uMsg, wParam, lParam);
     886       
    887887    case WM_ERASEBKGND:
    888     ANIMATE_EraseBackground(hWnd, wParam, lParam);
    889     break;
    890 
    891     /*  case WM_STYLECHANGED: FIXME shall we do something ?? */
     888        ANIMATE_EraseBackground(hWnd, wParam, lParam);
     889        break;
     890
     891    /*  case WM_STYLECHANGED: FIXME shall we do something ?? */
    892892
    893893    case WM_TIMER:
    894         if (GetWindowLongA(hWnd, GWL_STYLE) & ACS_TRANSPARENT)
     894        if (GetWindowLongA(hWnd, GWL_STYLE) & ACS_TRANSPARENT)
    895895        {
    896896            ANIMATE_INFO* infoPtr = ANIMATE_GetInfoPtr(hWnd);
    897897            infoPtr->hbrushBG = SendMessageA(GetParent(hWnd),WM_CTLCOLORSTATIC,(HDC)wParam, hWnd);
    898898        }
    899     return ANIMATE_DrawFrame(ANIMATE_GetInfoPtr(hWnd));
    900 
     899        return ANIMATE_DrawFrame(ANIMATE_GetInfoPtr(hWnd));
     900       
    901901    case WM_CLOSE:
    902     ANIMATE_Free(ANIMATE_GetInfoPtr(hWnd));
    903     return TRUE;
     902        ANIMATE_Free(ANIMATE_GetInfoPtr(hWnd));
     903        return TRUE;
    904904
    905905    case WM_PAINT:
    906906        {
    907907            ANIMATE_INFO* infoPtr = ANIMATE_GetInfoPtr(hWnd);
    908 
     908               
    909909            /* the animation isn't playing, don't paint */
    910         if(!infoPtr->uTimer && !infoPtr->hThread)
    911         /* default paint handling */
    912             return DefWindowProcA(hWnd, uMsg, wParam, lParam);
    913 
     910            if(!infoPtr->uTimer && !infoPtr->hThread)
     911                /* default paint handling */
     912                return DefWindowProcA(hWnd, uMsg, wParam, lParam);
     913           
    914914            if (GetWindowLongA(hWnd, GWL_STYLE) & ACS_TRANSPARENT)
    915915                infoPtr->hbrushBG = SendMessageA(GetParent(hWnd), WM_CTLCOLORSTATIC,
    916                                          (HDC)wParam, hWnd);
    917 
     916                                                 (HDC)wParam, hWnd);
     917   
    918918            if (wParam)
    919919            {
     
    924924            else
    925925            {
    926             PAINTSTRUCT ps;
    927             HDC hDC = BeginPaint(hWnd, &ps);
     926                PAINTSTRUCT ps;
     927                HDC hDC = BeginPaint(hWnd, &ps);
    928928
    929929                EnterCriticalSection(&infoPtr->cs);
    930930                ANIMATE_PaintFrame(infoPtr, hDC);
    931931                LeaveCriticalSection(&infoPtr->cs);
    932 
    933             EndPaint(hWnd, &ps);
     932   
     933                EndPaint(hWnd, &ps);
     934            }
    934935        }
    935         }
    936     break;
     936        break;
    937937
    938938    case WM_SIZE:
    939     ANIMATE_Size(hWnd, wParam, lParam);
    940     return DefWindowProcA(hWnd, uMsg, wParam, lParam);
     939        ANIMATE_Size(hWnd, wParam, lParam);
     940        return DefWindowProcA(hWnd, uMsg, wParam, lParam);
    941941
    942942    default:
    943     if (uMsg >= WM_USER)
    944         ERR("unknown msg %04x wp=%08x lp=%08lx\n", uMsg, wParam, lParam);
    945 
     943        if (uMsg >= WM_USER)
     944            ERR("unknown msg %04x wp=%08x lp=%08lx\n", uMsg, wParam, lParam);
     945       
    946946#ifdef __WIN32OS2__
    947947        return defComCtl32ProcA (hWnd, uMsg, wParam, lParam);
    948948#else
    949     return DefWindowProcA(hWnd, uMsg, wParam, lParam);
     949        return DefWindowProcA(hWnd, uMsg, wParam, lParam);
    950950#endif
    951951    }
     
    966966    wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
    967967    wndClass.lpszClassName = ANIMATE_CLASSA;
    968 
     968 
    969969    RegisterClassA(&wndClass);
    970970}
  • trunk/src/comctl32/comboex.c

    r6705 r6709  
    44 *     result in a FIXME:
    55 *           CBES_EX_NOEDITIMAGEINDENT
    6  *       CBES_EX_PATHWORDBREAKPROC
    7  *       CBES_EX_NOSIZELIMIT
    8  *       CBES_EX_CASESENSITIVE
     6 *           CBES_EX_PATHWORDBREAKPROC
     7 *           CBES_EX_NOSIZELIMIT
     8 *           CBES_EX_CASESENSITIVE
    99 *  2. None of the following callback items are implemented. Therefor
    1010 *     no CBEN_GETDISPINFO notifies are issued. Use in either CBEM_INSERTITEM
     
    3737 *      generate message sequence similar to native DLL.
    3838 *   2. Handle case where CBEM_SETITEM is called to display data in EDIT
    39  *      Control.
     39 *      Control. 
    4040 *   3. Add override for WNDPROC for the EDIT control (reqed for VK_RETURN).
    4141 *   4. Dump input data for things using COMBOBOXEXITEM{A|W}.
     
    5555 *   3. Lock image selected status to focus state of edit control if
    5656 *      edit control exists. Mimics native actions.
    57  *   4. Implemented WM_SETFOCUS in EditWndProc to track status of
     57 *   4. Implemented WM_SETFOCUS in EditWndProc to track status of 
    5858 *      focus for 3 above.
    5959 *   5. The LBN_SELCHANGE is just for documentation purposes.
     
    7070 *
    7171 *  mod 6
    72  *   1. Add support for WM_NOTIFYFORMAT (both incoming and outgoing) and do
     72 *   1. Add support for WM_NOTIFYFORMAT (both incoming and outgoing) and do 
    7373 *      WM_NOTIFY correctly based on results.
    7474 *   2. Fix memory leaks of text strings in COMBOEX_WM_DELETEITEM.
    7575 *   3. Add routines to handle special cases of NMCBEENDEDIT and NMCOMBOXEX
    76  *      so translation to ANSI is done correctly.
     76 *      so translation to ANSI is done correctly. 
    7777 *   4. Fix some issues with COMBOEX_DrawItem.
    7878 *
     
    150150/*
    151151 * Special flag set in DRAWITEMSTRUCT itemState field. It is set by
    152  * the ComboEx version of the Combo Window Proc so that when the
    153  * WM_DRAWITEM message is then passed to ComboEx, we know that this
     152 * the ComboEx version of the Combo Window Proc so that when the 
     153 * WM_DRAWITEM message is then passed to ComboEx, we know that this 
    154154 * particular WM_DRAWITEM message is for listbox only items. Any messasges
    155155 * without this flag is then for the Edit control field.
    156156 *
    157  * We really cannot use the ODS_COMBOBOXEDIT flag because MSDN states that
     157 * We really cannot use the ODS_COMBOBOXEDIT flag because MSDN states that 
    158158 * only version 4.0 applications will have ODS_COMBOBOXEDIT set.
    159159 */
     
    189189    if (TRACE_ON(comboex)){
    190190      TRACE("item %p - mask=%08x, pszText=%p, cchTM=%d, iImage=%d\n",
    191         item, item->mask, item->pszText, item->cchTextMax,
    192         item->iImage);
     191            item, item->mask, item->pszText, item->cchTextMax,
     192            item->iImage);
    193193      TRACE("item %p - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n",
    194         item, item->iSelectedImage, item->iOverlay, item->iIndent, item->lParam);
     194            item, item->iSelectedImage, item->iOverlay, item->iIndent, item->lParam);
    195195      if ((item->mask & CBEIF_TEXT) && item->pszText)
    196       TRACE("item %p - pszText=%s\n",
    197         item, debugstr_w((const WCHAR *)item->pszText));
     196          TRACE("item %p - pszText=%s\n",
     197                item, debugstr_w((const WCHAR *)item->pszText));
    198198    }
    199199}
     
    205205    if (TRACE_ON(comboex)){
    206206      TRACE("input - mask=%08x, iItem=%d, pszText=%p, cchTM=%d, iImage=%d\n",
    207         input->mask, input->iItem, input->pszText, input->cchTextMax,
    208         input->iImage);
     207            input->mask, input->iItem, input->pszText, input->cchTextMax,
     208            input->iImage);
    209209      if ((input->mask & CBEIF_TEXT) && input->pszText) {
    210       if (true_for_w)
    211           TRACE("input - pszText=<%s>\n",
    212             debugstr_w((const WCHAR *)input->pszText));
    213       else
    214           TRACE("input - pszText=<%s>\n",
    215             debugstr_a((const char *)input->pszText));
     210          if (true_for_w)
     211              TRACE("input - pszText=<%s>\n",
     212                    debugstr_w((const WCHAR *)input->pszText));
     213          else
     214              TRACE("input - pszText=<%s>\n",
     215                    debugstr_a((const char *)input->pszText));
    216216      }
    217217      TRACE("input - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n",
    218         input->iSelectedImage, input->iOverlay, input->iIndent, input->lParam);
     218            input->iSelectedImage, input->iOverlay, input->iIndent, input->lParam);
    219219    }
    220220}
     
    226226    COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    227227
    228     if (infoPtr->hwndCombo)
    229     return SendMessageA (infoPtr->hwndCombo, uMsg, wParam, lParam);
     228    if (infoPtr->hwndCombo)   
     229        return SendMessageA (infoPtr->hwndCombo, uMsg, wParam, lParam);
    230230
    231231    return 0;
     
    241241    hdr->code = code;
    242242    if (infoPtr->NtfUnicode)
    243     return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
    244                  (LPARAM)hdr);
     243        return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
     244                             (LPARAM)hdr);
    245245    else
    246     return SendMessageA (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
    247                  (LPARAM)hdr);
     246        return SendMessageA (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
     247                             (LPARAM)hdr);
    248248}
    249249
     
    259259    hdr->hdr.code = code;
    260260    if (infoPtr->NtfUnicode)
    261     return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
    262                  (LPARAM)hdr);
     261        return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
     262                             (LPARAM)hdr);
    263263    else {
    264     LPWSTR str, ostr = NULL;
    265     INT ret, len = 0;
    266 
    267     if (hdr->ceItem.mask & CBEIF_TEXT) {
    268         ostr = hdr->ceItem.pszText;
    269         str = ostr;
    270         if (!str) str = (LPWSTR)L"";
    271         len = WideCharToMultiByte (CP_ACP, 0, str, -1, 0, 0, NULL, NULL);
    272         if (len > 0) {
    273         hdr->ceItem.pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(CHAR));
    274         WideCharToMultiByte (CP_ACP, 0, str, -1, (LPSTR)hdr->ceItem.pszText,
    275                      len, NULL, NULL);
    276         }
    277     }
    278 
    279     ret = SendMessageA (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
    280                 (LPARAM)hdr);
    281     if (hdr->ceItem.mask & CBEIF_TEXT) {
    282         if (len > 0)
    283         COMCTL32_Free (hdr->ceItem.pszText);
    284         hdr->ceItem.pszText = ostr;
    285     }
    286     return ret;
     264        LPWSTR str, ostr = NULL;
     265        INT ret, len = 0;
     266
     267        if (hdr->ceItem.mask & CBEIF_TEXT) {
     268            ostr = hdr->ceItem.pszText;
     269            str = ostr;
     270            if (!str) str = (LPWSTR)L"";
     271            len = WideCharToMultiByte (CP_ACP, 0, str, -1, 0, 0, NULL, NULL);
     272            if (len > 0) {
     273                hdr->ceItem.pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(CHAR));
     274                WideCharToMultiByte (CP_ACP, 0, str, -1, (LPSTR)hdr->ceItem.pszText,
     275                                     len, NULL, NULL);
     276            }
     277        }
     278
     279        ret = SendMessageA (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
     280                            (LPARAM)hdr);
     281        if (hdr->ceItem.mask & CBEIF_TEXT) {
     282            if (len > 0)
     283                COMCTL32_Free (hdr->ceItem.pszText);
     284            hdr->ceItem.pszText = ostr;
     285        }
     286        return ret;
    287287    }
    288288}
     
    299299    hdr->hdr.code = (infoPtr->NtfUnicode) ? CBEN_ENDEDITW : CBEN_ENDEDITA;
    300300    if (infoPtr->NtfUnicode)
    301     return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
    302                  (LPARAM)hdr);
     301        return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
     302                             (LPARAM)hdr);
    303303    else {
    304     NMCBEENDEDITA ansi;
    305 
    306     memcpy (&ansi.hdr, &hdr->hdr, sizeof(NMHDR));
    307     ansi.fChanged = hdr->fChanged;
    308     ansi.iNewSelection = hdr->iNewSelection;
    309     WideCharToMultiByte (CP_ACP, 0, itemText, -1,
    310                  (LPSTR)&ansi.szText, CBEMAXSTRLEN, NULL, NULL);
    311     ansi.iWhy = hdr->iWhy;
    312     return SendMessageA (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
    313                  (LPARAM)&ansi);
     304        NMCBEENDEDITA ansi;
     305
     306        memcpy (&ansi.hdr, &hdr->hdr, sizeof(NMHDR));
     307        ansi.fChanged = hdr->fChanged;
     308        ansi.iNewSelection = hdr->iNewSelection;
     309        WideCharToMultiByte (CP_ACP, 0, itemText, -1,
     310                             (LPSTR)&ansi.szText, CBEMAXSTRLEN, NULL, NULL);
     311        ansi.iWhy = hdr->iWhy;
     312        return SendMessageA (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
     313                             (LPARAM)&ansi);
    314314    }
    315315}
     
    340340    }
    341341    if (cit->mask & CBEIF_IMAGE)
    342     cit->iImage         = item->iImage;
     342        cit->iImage         = item->iImage;
    343343    if (cit->mask & CBEIF_SELECTEDIMAGE)
    344     cit->iSelectedImage = item->iSelectedImage;
     344        cit->iSelectedImage = item->iSelectedImage;
    345345    if (cit->mask & CBEIF_OVERLAY)
    346     cit->iOverlay       = item->iOverlay;
     346        cit->iOverlay       = item->iOverlay;
    347347    if (cit->mask & CBEIF_INDENT)
    348     cit->iIndent        = item->iIndent;
     348        cit->iIndent        = item->iIndent;
    349349    if (cit->mask & CBEIF_LPARAM)
    350     cit->lParam         = item->lParam;
     350        cit->lParam         = item->lParam;
    351351
    352352}
     
    364364    iinfo.rcImage.left = iinfo.rcImage.right = 0;
    365365    if (infoPtr->himl) {
    366     ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo);
    367     xoff = iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP;
     366        ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo);
     367        xoff = iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP;
    368368    }
    369369    GetClientRect (infoPtr->hwndCombo, &rect);
     
    380380
    381381    TRACE("Combo client (%d,%d)-(%d,%d), setting Edit to (%d,%d)-(%d,%d)\n",
    382       rect.left, rect.top, rect.right, rect.bottom,
    383       x, y, x + w, y + h);
     382          rect.left, rect.top, rect.right, rect.bottom,
     383          x, y, x + w, y + h);
    384384    SetWindowPos(infoPtr->hwndEdit, HWND_TOP,
    385         x, y,
    386         w, h,
    387         SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER);
     385                x, y,
     386                w, h,
     387                SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER);
    388388}
    389389
     
    399399    cy = mysize.cy + CBE_EXTRA;
    400400    if (infoPtr->himl) {
    401     ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo);
    402     cy = max (iinfo.rcImage.bottom - iinfo.rcImage.top, cy);
    403     TRACE("upgraded height due to image:  height=%d\n", cy);
     401        ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo);
     402        cy = max (iinfo.rcImage.bottom - iinfo.rcImage.top, cy);
     403        TRACE("upgraded height due to image:  height=%d\n", cy);
    404404    }
    405405    SendMessageW (hwnd, CB_SETITEMHEIGHT, (WPARAM) -1, (LPARAM) cy);
    406406    if (infoPtr->hwndCombo)
    407407        SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT,
    408               (WPARAM) 0, (LPARAM) cy);
     408                      (WPARAM) 0, (LPARAM) cy);
    409409}
    410410
     
    419419    /*      EM_SETSEL32 (0,-1)      */
    420420    if (item->mask & CBEIF_TEXT) {
    421     SendMessageW (infoPtr->hwndEdit, WM_SETTEXT, 0, (LPARAM)item->pszText);
    422     SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, 0);
    423     SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, -1);
    424     }
    425 }
    426 
    427 
     421        SendMessageW (infoPtr->hwndEdit, WM_SETTEXT, 0, (LPARAM)item->pszText);
     422        SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, 0);
     423        SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, -1);
     424    }
     425}
     426
     427 
    428428static CBE_ITEMDATA *
    429429COMBOEX_FindItem(COMBOEX_INFO *infoPtr, INT index)
     
    433433
    434434    if ((index > infoPtr->nb_items) || (index < -1))
    435     return 0;
     435        return 0;
    436436    if (index == -1)
    437     return infoPtr->edit;
     437        return infoPtr->edit;
    438438    item = infoPtr->items;
    439439    i = infoPtr->nb_items - 1;
     
    441441    /* find the item in the list */
    442442    while (item && (i > index)) {
    443     item = (CBE_ITEMDATA *)item->next;
    444     i--;
     443        item = (CBE_ITEMDATA *)item->next;
     444        i--;
    445445    }
    446446    if (!item || (i != index)) {
    447     FIXME("COMBOBOXEX item structures broken. Please report!\n");
    448     return 0;
     447        FIXME("COMBOBOXEX item structures broken. Please report!\n");
     448        return 0;
    449449    }
    450450    return item;
     
    456456{
    457457    if (item->pszText == LPSTR_TEXTCALLBACKW)
    458     FIXME("Callback not implemented yet for pszText\n");
     458        FIXME("Callback not implemented yet for pszText\n");
    459459    if (item->iImage == I_IMAGECALLBACK)
    460     FIXME("Callback not implemented yet for iImage\n");
     460        FIXME("Callback not implemented yet for iImage\n");
    461461    if (item->iSelectedImage == I_IMAGECALLBACK)
    462     FIXME("Callback not implemented yet for iSelectedImage\n");
     462        FIXME("Callback not implemented yet for iSelectedImage\n");
    463463    if (item->iOverlay == I_IMAGECALLBACK)
    464     FIXME("Callback not implemented yet for iOverlay\n");
     464        FIXME("Callback not implemented yet for iOverlay\n");
    465465    if (item->iIndent == I_INDENTCALLBACK)
    466     FIXME("Callback not implemented yet for iIndent\n");
     466        FIXME("Callback not implemented yet for iIndent\n");
    467467}
    468468
     
    482482    /* if item number requested does not exist then return failure */
    483483    if ((index > infoPtr->nb_items) || (index < 0)) {
    484     ERR("attempt to delete item that does not exist\n");
    485     return CB_ERR;
     484        ERR("attempt to delete item that does not exist\n");
     485        return CB_ERR;
    486486    }
    487487
    488488    if (!(item = COMBOEX_FindItem(infoPtr, index))) {
    489     ERR("attempt to delete item that was not found!\n");
    490     return CB_ERR;
     489        ERR("attempt to delete item that was not found!\n");
     490        return CB_ERR;
    491491    }
    492492
     
    515515
    516516    if ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN)
    517     return 0;
     517        return 0;
    518518
    519519    TRACE("-- 0x%x\n", infoPtr->hwndEdit);
     
    560560    /* if item number requested does not exist then return failure */
    561561    if ((index > infoPtr->nb_items) || (index < -1)) {
    562     ERR("attempt to get item that does not exist\n");
    563     return 0;
     562        ERR("attempt to get item that does not exist\n");
     563        return 0;
    564564    }
    565565
    566566    /* if the item is the edit control and there is no edit control, skip */
    567     if ((index == -1) &&
     567    if ((index == -1) && 
    568568        ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN))
    569         return 0;
     569            return 0;
    570570
    571571    if (!(item = COMBOEX_FindItem(infoPtr, index))) {
    572     ERR("attempt to get item that was not found!\n");
    573     return 0;
     572        ERR("attempt to get item that was not found!\n");
     573        return 0;
    574574    }
    575575
     
    594594
    595595    len = WideCharToMultiByte (CP_ACP, 0, tmpcit.pszText, -1, 0, 0, NULL, NULL);
    596     if (len > 0)
    597     WideCharToMultiByte (CP_ACP, 0, tmpcit.pszText, -1,
    598                  cit->pszText, cit->cchTextMax, NULL, NULL);
     596    if (len > 0) 
     597        WideCharToMultiByte (CP_ACP, 0, tmpcit.pszText, -1,
     598                             cit->pszText, cit->cchTextMax, NULL, NULL);
    599599
    600600    cit->iImage = tmpcit.iImage;
     
    613613    COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    614614
    615     TRACE("%s hwnd=0x%x\n",
    616        infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
     615    TRACE("%s hwnd=0x%x\n", 
     616           infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
    617617
    618618    return infoPtr->bUnicode;
     
    626626
    627627    if ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN)
    628     return FALSE;
    629     if ((infoPtr->flags & (WCBE_ACTEDIT | WCBE_EDITCHG)) ==
    630     (WCBE_ACTEDIT | WCBE_EDITCHG))
    631     return TRUE;
     628        return FALSE;
     629    if ((infoPtr->flags & (WCBE_ACTEDIT | WCBE_EDITCHG)) == 
     630        (WCBE_ACTEDIT | WCBE_EDITCHG))
     631        return TRUE;
    632632    return FALSE;
    633633}
     
    661661        /* fast path for iItem = -1 */
    662662        item->next = infoPtr->items;
    663     infoPtr->items = item;
     663        infoPtr->items = item;
    664664    }
    665665    else {
    666666        INT i = infoPtr->nb_items-1;
    667     CBE_ITEMDATA *moving = infoPtr->items;
    668 
    669     while ((i > index) && moving) {
    670         moving = (CBE_ITEMDATA *)moving->next;
    671         i--;
    672     }
    673     if (!moving) {
    674         FIXME("COMBOBOXEX item structures broken. Please report!\n");
    675         COMCTL32_Free(item);
    676         return -1;
    677     }
    678     item->next = moving->next;
    679     moving->next = item;
     667        CBE_ITEMDATA *moving = infoPtr->items;
     668
     669        while ((i > index) && moving) {
     670            moving = (CBE_ITEMDATA *)moving->next;
     671            i--;
     672        }
     673        if (!moving) {
     674            FIXME("COMBOBOXEX item structures broken. Please report!\n");
     675            COMCTL32_Free(item);
     676            return -1;
     677        }
     678        item->next = moving->next;
     679        moving->next = item;
    680680    }
    681681
     
    684684    if (item->mask & CBEIF_TEXT) {
    685685        LPWSTR str;
    686     INT len;
     686        INT len;
    687687
    688688        str = cit->pszText;
    689689        if (!str) str = (LPWSTR) L"";
    690     len = strlenW (str);
    691     if (len > 0) {
    692         item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
    693         strcpyW (item->pszText, str);
    694     }
    695     else
    696         item->pszText = NULL;
     690        len = strlenW (str);
     691        if (len > 0) {
     692            item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     693            strcpyW (item->pszText, str);
     694        }
     695        else
     696            item->pszText = NULL;
    697697        item->cchTextMax   = cit->cchTextMax;
    698698    }
     
    713713    COMBOEX_DumpItem (item);
    714714
    715     SendMessageW (infoPtr->hwndCombo, CB_INSERTSTRING,
    716           (WPARAM)cit->iItem, (LPARAM)item);
     715    SendMessageW (infoPtr->hwndCombo, CB_INSERTSTRING, 
     716                  (WPARAM)cit->iItem, (LPARAM)item);
    717717
    718718    COMBOEX_CopyItem (infoPtr, item, &nmcit.ceItem);
     
    727727COMBOEX_InsertItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    728728{
    729     COMBOBOXEXITEMA *cit = (COMBOBOXEXITEMA *) lParam;
    730     COMBOBOXEXITEMW citW;
    731     LRESULT     ret;
     729    COMBOBOXEXITEMA     *cit = (COMBOBOXEXITEMA *) lParam;
     730    COMBOBOXEXITEMW     citW;
     731    LRESULT             ret;
    732732
    733733    memcpy(&citW,cit,sizeof(COMBOBOXEXITEMA));
    734734    if (cit->mask & CBEIF_TEXT) {
    735735        LPSTR str;
    736     INT len;
     736        INT len;
    737737
    738738        str = cit->pszText;
    739739        if (!str) str="";
    740     len = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
    741     if (len > 0) {
    742         citW.pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
    743         MultiByteToWideChar (CP_ACP, 0, str, -1, citW.pszText, len);
    744     }
     740        len = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
     741        if (len > 0) {
     742            citW.pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     743            MultiByteToWideChar (CP_ACP, 0, str, -1, citW.pszText, len);
     744        }
    745745    }
    746746    ret = COMBOEX_InsertItemW(hwnd,wParam,(LPARAM)&citW);;
    747747
    748748    if (cit->mask & CBEIF_TEXT)
    749     COMCTL32_Free(citW.pszText);
     749        COMCTL32_Free(citW.pszText);
    750750    return ret;
    751751}
     
    763763
    764764    if (lParam & (CBES_EX_NOEDITIMAGEINDENT |
    765           CBES_EX_PATHWORDBREAKPROC |
    766           CBES_EX_NOSIZELIMIT |
    767           CBES_EX_CASESENSITIVE))
    768     FIXME("Extended style not implemented %08lx\n", lParam);
     765                  CBES_EX_PATHWORDBREAKPROC |
     766                  CBES_EX_NOSIZELIMIT |
     767                  CBES_EX_CASESENSITIVE))
     768        FIXME("Extended style not implemented %08lx\n", lParam);
    769769
    770770    if ((DWORD)wParam) {
    771     infoPtr->dwExtStyle = (infoPtr->dwExtStyle & ~(DWORD)wParam) | (DWORD)lParam;
     771        infoPtr->dwExtStyle = (infoPtr->dwExtStyle & ~(DWORD)wParam) | (DWORD)lParam;
    772772    }
    773773    else
    774     infoPtr->dwExtStyle = (DWORD)lParam;
     774        infoPtr->dwExtStyle = (DWORD)lParam;
    775775
    776776    /*
     
    778778     */
    779779    if ((infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE) ^
    780     (dwTemp & CBES_EX_NOEDITIMAGE)) {
    781     /* if state of EX_NOEDITIMAGE changes, invalidate all */
    782     TRACE("EX_NOEDITIMAGE state changed to %ld\n",
    783         infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE);
    784     InvalidateRect (hwnd, NULL, TRUE);
    785     COMBOEX_AdjustEditPos (infoPtr);
    786     if (infoPtr->hwndEdit)
    787         InvalidateRect (infoPtr->hwndEdit, NULL, TRUE);
     780        (dwTemp & CBES_EX_NOEDITIMAGE)) {
     781        /* if state of EX_NOEDITIMAGE changes, invalidate all */
     782        TRACE("EX_NOEDITIMAGE state changed to %ld\n",
     783            infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE);
     784        InvalidateRect (hwnd, NULL, TRUE);
     785        COMBOEX_AdjustEditPos (infoPtr);
     786        if (infoPtr->hwndEdit)
     787            InvalidateRect (infoPtr->hwndEdit, NULL, TRUE);
    788788    }
    789789
     
    826826    /* if item number requested does not exist then return failure */
    827827    if ((index > infoPtr->nb_items) || (index < -1)) {
    828     ERR("attempt to set item that does not exist yet!\n");
    829     return 0;
     828        ERR("attempt to set item that does not exist yet!\n");
     829        return 0;
    830830    }
    831831
    832832    /* if the item is the edit control and there is no edit control, skip */
    833     if ((index == -1) &&
     833    if ((index == -1) && 
    834834        ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN))
    835         return 0;
     835            return 0;
    836836
    837837    if (!(item = COMBOEX_FindItem(infoPtr, index))) {
    838     ERR("attempt to set item that was not found!\n");
    839     return 0;
    840     }
    841 
    842     /* add/change stuff to the internal item structure */
     838        ERR("attempt to set item that was not found!\n");
     839        return 0;
     840    }
     841
     842    /* add/change stuff to the internal item structure */ 
    843843    item->mask |= cit->mask;
    844844    if (cit->mask & CBEIF_TEXT) {
    845845        LPWSTR str;
    846     INT len;
    847     WCHAR emptystr[1] = {0};
     846        INT len;
     847        WCHAR emptystr[1] = {0};
    848848
    849849        str = cit->pszText;
    850850        if (!str) str=emptystr;
    851     len = strlenW(str);
    852     if (len > 0) {
    853         item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
    854         strcpyW(item->pszText,str);
    855     }
     851        len = strlenW(str);
     852        if (len > 0) {
     853            item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     854            strcpyW(item->pszText,str);
     855        }
    856856        item->cchTextMax   = cit->cchTextMax;
    857857    }
     
    873873    /* if original request was to update edit control, do some fast foot work */
    874874    if (cit->iItem == -1) {
    875     COMBOEX_SetEditText (infoPtr, item);
    876     RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE | RDW_INVALIDATE);
     875        COMBOEX_SetEditText (infoPtr, item);
     876        RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE | RDW_INVALIDATE);
    877877    }
    878878    return TRUE;
     
    882882COMBOEX_SetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    883883{
    884     COMBOBOXEXITEMA *cit = (COMBOBOXEXITEMA *) lParam;
    885     COMBOBOXEXITEMW citW;
    886     LRESULT     ret;
     884    COMBOBOXEXITEMA     *cit = (COMBOBOXEXITEMA *) lParam;
     885    COMBOBOXEXITEMW     citW;
     886    LRESULT             ret;
    887887
    888888    memcpy(&citW,cit,sizeof(COMBOBOXEXITEMA));
    889889    if (cit->mask & CBEIF_TEXT) {
    890890        LPSTR str;
    891     INT len;
     891        INT len;
    892892
    893893        str = cit->pszText;
    894894        if (!str) str="";
    895     len = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
    896     if (len > 0) {
    897         citW.pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
    898         MultiByteToWideChar (CP_ACP, 0, str, -1, citW.pszText, len);
    899     }
     895        len = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
     896        if (len > 0) {
     897            citW.pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     898            MultiByteToWideChar (CP_ACP, 0, str, -1, citW.pszText, len);
     899        }
    900900    }
    901901    ret = COMBOEX_SetItemW(hwnd,wParam,(LPARAM)&citW);;
    902902
    903903    if (cit->mask & CBEIF_TEXT)
    904     COMCTL32_Free(citW.pszText);
     904        COMCTL32_Free(citW.pszText);
    905905    return ret;
    906906}
     
    913913    BOOL bTemp = infoPtr->bUnicode;
    914914
    915     TRACE("to %s hwnd=0x%04x, was %s\n",
    916       ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd,
    917       (bTemp) ? "TRUE" : "FALSE");
     915    TRACE("to %s hwnd=0x%04x, was %s\n", 
     916          ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd,
     917          (bTemp) ? "TRUE" : "FALSE");
    918918
    919919    infoPtr->bUnicode = (BOOL)wParam;
     
    937937    i = MultiByteToWideChar (CP_ACP, 0, (LPSTR)lParam, -1, NULL, 0);
    938938    if (i > 0) {
    939     desired = (LPWSTR)COMCTL32_Alloc ((i + 1)*sizeof(WCHAR));
    940     MultiByteToWideChar (CP_ACP, 0, (LPSTR)lParam, -1, desired, i);
     939        desired = (LPWSTR)COMCTL32_Alloc ((i + 1)*sizeof(WCHAR));
     940        MultiByteToWideChar (CP_ACP, 0, (LPSTR)lParam, -1, desired, i);
    941941    }
    942942
     
    945945    /* now search from after starting loc and wrapping back to start */
    946946    for(i=start+1; i<count; i++) {
    947     item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
    948               CB_GETITEMDATA, (WPARAM)i, 0);
    949     TRACE("desired=%s, item=%s\n",
    950           debugstr_w(desired), debugstr_w(item->pszText));
    951     if (lstrcmpiW(item->pszText, desired) == 0) {
    952         COMCTL32_Free (desired);
    953         return i;
    954     }
     947        item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
     948                          CB_GETITEMDATA, (WPARAM)i, 0);
     949        TRACE("desired=%s, item=%s\n",
     950              debugstr_w(desired), debugstr_w(item->pszText));
     951        if (lstrcmpiW(item->pszText, desired) == 0) {
     952            COMCTL32_Free (desired);
     953            return i;
     954        }
    955955    }
    956956    for(i=0; i<=start; i++) {
    957     item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
    958               CB_GETITEMDATA, (WPARAM)i, 0);
    959     TRACE("desired=%s, item=%s\n",
    960           debugstr_w(desired), debugstr_w(item->pszText));
    961     if (lstrcmpiW(item->pszText, desired) == 0) {
    962         COMCTL32_Free (desired);
    963         return i;
    964     }
     957        item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
     958                          CB_GETITEMDATA, (WPARAM)i, 0);
     959        TRACE("desired=%s, item=%s\n",
     960              debugstr_w(desired), debugstr_w(item->pszText));
     961        if (lstrcmpiW(item->pszText, desired) == 0) {
     962            COMCTL32_Free (desired);
     963            return i;
     964        }
    965965    }
    966966    COMCTL32_Free(desired);
     
    977977    LRESULT lret = 0;
    978978
    979     item1 = (CBE_ITEMDATA *)COMBOEX_Forward (hwnd, CB_GETITEMDATA,
    980                          wParam, lParam);
     979    item1 = (CBE_ITEMDATA *)COMBOEX_Forward (hwnd, CB_GETITEMDATA, 
     980                                             wParam, lParam);
    981981    if ((item1 != NULL) && ((LRESULT)item1 != CB_ERR)) {
    982     item2 = COMBOEX_FindItem (infoPtr, index);
    983     if (item2 != item1) {
    984         ERR("data structures damaged!\n");
    985         return CB_ERR;
    986     }
    987     if (item1->mask & CBEIF_LPARAM)
    988         lret = (LRESULT) item1->lParam;
    989     TRACE("returning 0x%08lx\n", lret);
    990     return lret;
     982        item2 = COMBOEX_FindItem (infoPtr, index);
     983        if (item2 != item1) {
     984            ERR("data structures damaged!\n");
     985            return CB_ERR;
     986        }
     987        if (item1->mask & CBEIF_LPARAM)
     988            lret = (LRESULT) item1->lParam;
     989        TRACE("returning 0x%08lx\n", lret);
     990        return lret;
    991991    }
    992992    lret = (LRESULT)item1;
     
    10051005
    10061006    if (!(item = COMBOEX_FindItem(infoPtr, index))) {
    1007     /* FIXME: need to clear selection */
    1008     return CB_ERR;
     1007        /* FIXME: need to clear selection */
     1008        return CB_ERR;
    10091009    }
    10101010
    10111011    TRACE("selecting item %d text=%s\n", index, (item->pszText) ?
    1012       debugstr_w(item->pszText) : "<null>");
     1012          debugstr_w(item->pszText) : "<null>");
    10131013    infoPtr->selected = index;
    10141014
     
    10261026    CBE_ITEMDATA *item1, *item2;
    10271027
    1028     item1 = (CBE_ITEMDATA *)COMBOEX_Forward (hwnd, CB_GETITEMDATA,
    1029                          wParam, lParam);
     1028    item1 = (CBE_ITEMDATA *)COMBOEX_Forward (hwnd, CB_GETITEMDATA, 
     1029                                             wParam, lParam);
    10301030    if ((item1 != NULL) && ((LRESULT)item1 != CB_ERR)) {
    1031     item2 = COMBOEX_FindItem (infoPtr, index);
    1032     if (item2 != item1) {
    1033         ERR("data structures damaged!\n");
    1034         return CB_ERR;
    1035     }
    1036     item1->mask |= CBEIF_LPARAM;
    1037     item1->lParam = lParam;
    1038     TRACE("setting lparam to 0x%08lx\n", lParam);
    1039     return 0;
     1031        item2 = COMBOEX_FindItem (infoPtr, index);
     1032        if (item2 != item1) {
     1033            ERR("data structures damaged!\n");
     1034            return CB_ERR;
     1035        }
     1036        item1->mask |= CBEIF_LPARAM;
     1037        item1->lParam = lParam;
     1038        TRACE("setting lparam to 0x%08lx\n", lParam);
     1039        return 0;
    10401040    }
    10411041    TRACE("non-valid result from combo 0x%08lx\n", (DWORD)item1);
     
    10541054    /* First, lets forward the message to the normal combo control
    10551055       just like Windows.     */
    1056     if (infoPtr->hwndCombo)
     1056    if (infoPtr->hwndCombo)   
    10571057       SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT, wParam, lParam);
    10581058
     
    10601060    GetWindowRect (hwnd, &cbx_wrect);
    10611061    GetClientRect (hwnd, &cbx_crect);
    1062     /* the height of comboex as height of the combo + comboex border */
     1062    /* the height of comboex as height of the combo + comboex border */ 
    10631063    height = cb_wrect.bottom-cb_wrect.top
    10641064             + cbx_wrect.bottom-cbx_wrect.top
    10651065             - (cbx_crect.bottom-cbx_crect.top);
    10661066    TRACE("EX window=(%d,%d)-(%d,%d), client=(%d,%d)-(%d,%d)\n",
    1067       cbx_wrect.left, cbx_wrect.top, cbx_wrect.right, cbx_wrect.bottom,
    1068       cbx_crect.left, cbx_crect.top, cbx_crect.right, cbx_crect.bottom);
     1067          cbx_wrect.left, cbx_wrect.top, cbx_wrect.right, cbx_wrect.bottom,
     1068          cbx_crect.left, cbx_crect.top, cbx_crect.right, cbx_crect.bottom);
    10691069    TRACE("CB window=(%d,%d)-(%d,%d), EX setting=(0,0)-(%d,%d)\n",
    1070       cb_wrect.left, cb_wrect.top, cb_wrect.right, cb_wrect.bottom,
    1071       cbx_wrect.right-cbx_wrect.left, height);
     1070          cb_wrect.left, cb_wrect.top, cb_wrect.right, cb_wrect.bottom,
     1071          cbx_wrect.right-cbx_wrect.left, height);
    10721072    SetWindowPos (hwnd, HWND_TOP, 0, 0,
    1073           cbx_wrect.right-cbx_wrect.left,
    1074           height,
    1075           SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE);
     1073                  cbx_wrect.right-cbx_wrect.left,
     1074                  height,
     1075                  SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE);
    10761076
    10771077    return ret;
     
    11011101#endif
    11021102    if (infoPtr == NULL) {
    1103     ERR("could not allocate info memory!\n");
    1104     return 0;
     1103        ERR("could not allocate info memory!\n");
     1104        return 0;
    11051105    }
    11061106
     
    11151115
    11161116    i = SendMessageA(GetParent (hwnd),
    1117              WM_NOTIFYFORMAT, hwnd, NF_QUERY);
     1117                     WM_NOTIFYFORMAT, hwnd, NF_QUERY);
    11181118    if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
    1119     ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
    1120         i);
    1121     i = NFR_ANSI;
     1119        ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
     1120            i);
     1121        i = NFR_ANSI;
    11221122    }
    11231123    infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
     
    11271127    /* create combo box */
    11281128    dwComboStyle = GetWindowLongA (hwnd, GWL_STYLE) &
    1129             (CBS_SIMPLE|CBS_DROPDOWN|CBS_DROPDOWNLIST|WS_CHILD);
     1129                        (CBS_SIMPLE|CBS_DROPDOWN|CBS_DROPDOWNLIST|WS_CHILD);
    11301130
    11311131    GetWindowRect(hwnd, &wnrc1);
    11321132    GetClientRect(hwnd, &clrc1);
    11331133    TRACE("EX window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d)\n",
    1134       wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
    1135       clrc1.left, clrc1.top, clrc1.right, clrc1.bottom);
     1134          wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
     1135          clrc1.left, clrc1.top, clrc1.right, clrc1.bottom);
    11361136    TRACE("combo style=%08lx, adding style=%08lx\n", dwComboStyle,
    11371137          WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VSCROLL |
    11381138          CBS_NOINTEGRALHEIGHT | CBS_DROPDOWNLIST |
    1139       WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED);
     1139          WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED);
    11401140
    11411141    /* Native version of ComboEx creates the ComboBox with DROPDOWNLIST */
     
    11471147
    11481148    infoPtr->hwndCombo = CreateWindowA ("ComboBox", "",
    1149             /* following line added to match native */
     1149                        /* following line added to match native */
    11501150                         WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VSCROLL |
    1151                          CBS_NOINTEGRALHEIGHT | CBS_DROPDOWNLIST |
    1152             /* was base and is necessary */
    1153             WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED | dwComboStyle,
    1154             cs->y, cs->x, cs->cx, cs->cy, hwnd,
    1155             (HMENU) GetWindowLongA (hwnd, GWL_ID),
    1156             GetWindowLongA (hwnd, GWL_HINSTANCE), NULL);
    1157 
    1158     /*
     1151                         CBS_NOINTEGRALHEIGHT | CBS_DROPDOWNLIST | 
     1152                        /* was base and is necessary */
     1153                        WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED | dwComboStyle,
     1154                        cs->y, cs->x, cs->cx, cs->cy, hwnd,
     1155                        (HMENU) GetWindowLongA (hwnd, GWL_ID),
     1156                        GetWindowLongA (hwnd, GWL_HINSTANCE), NULL);
     1157
     1158    /* 
    11591159     * native does the following at this point according to trace:
    11601160     *  GetWindowThreadProcessId(hwndCombo,0)
     
    11651165
    11661166    /*
    1167      * Setup a property to hold the pointer to the COMBOBOXEX
     1167     * Setup a property to hold the pointer to the COMBOBOXEX 
    11681168     * data structure.
    11691169     */
    11701170    test = GetPropA(infoPtr->hwndCombo, (LPCSTR)(LONG)ComboExInfo);
    11711171    if (!test || ((COMBOEX_INFO *)test != infoPtr)) {
    1172     SetPropA(infoPtr->hwndCombo, "CC32SubclassInfo", (LONG)infoPtr);
    1173     }
    1174     infoPtr->prevComboWndProc = (WNDPROC)SetWindowLongA(infoPtr->hwndCombo,
    1175                             GWL_WNDPROC, (LONG)COMBOEX_ComboWndProc);
     1172        SetPropA(infoPtr->hwndCombo, "CC32SubclassInfo", (LONG)infoPtr);
     1173    }
     1174    infoPtr->prevComboWndProc = (WNDPROC)SetWindowLongA(infoPtr->hwndCombo, 
     1175                                GWL_WNDPROC, (LONG)COMBOEX_ComboWndProc);
    11761176    infoPtr->font = SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
    11771177
     
    11821182     */
    11831183    if ((cs->style & CBS_DROPDOWNLIST) == CBS_DROPDOWN) {
    1184     infoPtr->hwndEdit = CreateWindowExA (0, "EDIT", "",
    1185             WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | ES_AUTOHSCROLL,
    1186             0, 0, 0, 0,  /* will set later */
    1187             infoPtr->hwndCombo,
    1188             (HMENU) GetWindowLongA (hwnd, GWL_ID),
    1189             GetWindowLongA (hwnd, GWL_HINSTANCE),
    1190             NULL);
    1191 
    1192     /* native does the following at this point according to trace:
    1193     *  GetWindowThreadProcessId(hwndEdit,0)
    1194     *  GetCurrentThreadId()
    1195     *  GetWindowThreadProcessId(hwndEdit, &???)
    1196     *  GetCurrentProcessId()
    1197     */
    1198 
    1199     /*
    1200      * Setup a property to hold the pointer to the COMBOBOXEX
    1201     * data structure.
    1202     */
    1203     test = GetPropA(infoPtr->hwndEdit, (LPCSTR)(LONG)ComboExInfo);
    1204     if (!test || ((COMBOEX_INFO *)test != infoPtr)) {
    1205         SetPropA(infoPtr->hwndEdit, "CC32SubclassInfo", (LONG)infoPtr);
    1206     }
    1207     infoPtr->prevEditWndProc = (WNDPROC)SetWindowLongA(infoPtr->hwndEdit,
    1208                 GWL_WNDPROC, (LONG)COMBOEX_EditWndProc);
    1209     infoPtr->font = SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
     1184        infoPtr->hwndEdit = CreateWindowExA (0, "EDIT", "",
     1185                    WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | ES_AUTOHSCROLL,
     1186                    0, 0, 0, 0,  /* will set later */
     1187                    infoPtr->hwndCombo,
     1188                    (HMENU) GetWindowLongA (hwnd, GWL_ID),
     1189                    GetWindowLongA (hwnd, GWL_HINSTANCE),
     1190                    NULL);
     1191
     1192        /* native does the following at this point according to trace:
     1193        *  GetWindowThreadProcessId(hwndEdit,0)
     1194        *  GetCurrentThreadId()
     1195        *  GetWindowThreadProcessId(hwndEdit, &???)
     1196        *  GetCurrentProcessId()
     1197        */
     1198
     1199        /*
     1200         * Setup a property to hold the pointer to the COMBOBOXEX
     1201        * data structure.
     1202        */
     1203        test = GetPropA(infoPtr->hwndEdit, (LPCSTR)(LONG)ComboExInfo);
     1204        if (!test || ((COMBOEX_INFO *)test != infoPtr)) {
     1205            SetPropA(infoPtr->hwndEdit, "CC32SubclassInfo", (LONG)infoPtr);
     1206        }
     1207        infoPtr->prevEditWndProc = (WNDPROC)SetWindowLongA(infoPtr->hwndEdit,
     1208                                GWL_WNDPROC, (LONG)COMBOEX_EditWndProc);
     1209        infoPtr->font = SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
    12101210    }
    12111211    else {
    1212     infoPtr->hwndEdit = 0;
    1213     infoPtr->font = 0;
     1212        infoPtr->hwndEdit = 0;
     1213        infoPtr->font = 0;
    12141214    }
    12151215
     
    12191219     */
    12201220    if (!infoPtr->font) {
    1221     SystemParametersInfoA (SPI_GETICONTITLELOGFONT, sizeof(mylogfont),
    1222                    &mylogfont, 0);
    1223     infoPtr->font = CreateFontIndirectA (&mylogfont);
     1221        SystemParametersInfoA (SPI_GETICONTITLELOGFONT, sizeof(mylogfont),
     1222                               &mylogfont, 0);
     1223        infoPtr->font = CreateFontIndirectA (&mylogfont);
    12241224    }
    12251225    SendMessageW (infoPtr->hwndCombo, WM_SETFONT, (WPARAM)infoPtr->font, 0);
    12261226    if (infoPtr->hwndEdit) {
    1227     SendMessageW (infoPtr->hwndEdit, WM_SETFONT, (WPARAM)infoPtr->font, 0);
    1228     SendMessageW (infoPtr->hwndEdit, EM_SETMARGINS, (WPARAM)EC_USEFONTINFO, 0);
     1227        SendMessageW (infoPtr->hwndEdit, WM_SETFONT, (WPARAM)infoPtr->font, 0);
     1228        SendMessageW (infoPtr->hwndEdit, EM_SETMARGINS, (WPARAM)EC_USEFONTINFO, 0);
    12291229    }
    12301230
     
    12371237    GetWindowRect(infoPtr->hwndCombo, &cmbwrc);
    12381238    TRACE("EX window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d) CB wnd=(%d,%d)-(%d,%d)\n",
    1239       wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
    1240       clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
    1241       cmbwrc.left, cmbwrc.top, cmbwrc.right, cmbwrc.bottom);
    1242     SetWindowPos(infoPtr->hwndCombo, HWND_TOP,
    1243         0, 0, wnrc1.right-wnrc1.left, wnrc1.bottom-wnrc1.top,
    1244         SWP_NOACTIVATE | SWP_NOREDRAW);
     1239          wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
     1240          clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
     1241          cmbwrc.left, cmbwrc.top, cmbwrc.right, cmbwrc.bottom);
     1242    SetWindowPos(infoPtr->hwndCombo, HWND_TOP, 
     1243                0, 0, wnrc1.right-wnrc1.left, wnrc1.bottom-wnrc1.top,
     1244                SWP_NOACTIVATE | SWP_NOREDRAW);
    12451245
    12461246    GetWindowRect(infoPtr->hwndCombo, &cmbwrc);
    12471247    TRACE("CB window=(%d,%d)-(%d,%d)\n",
    1248       cmbwrc.left, cmbwrc.top, cmbwrc.right, cmbwrc.bottom);
    1249     SetWindowPos(hwnd, HWND_TOP,
    1250         0, 0, cmbwrc.right-cmbwrc.left, cmbwrc.bottom-cmbwrc.top,
    1251         SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE);
     1248          cmbwrc.left, cmbwrc.top, cmbwrc.right, cmbwrc.bottom);
     1249    SetWindowPos(hwnd, HWND_TOP, 
     1250                0, 0, cmbwrc.right-cmbwrc.left, cmbwrc.bottom-cmbwrc.top,
     1251                SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE);
    12521252
    12531253    COMBOEX_AdjustEditPos (infoPtr);
    12541254
    12551255    /*
    1256      * Create an item structure to represent the data in the
     1256     * Create an item structure to represent the data in the 
    12571257     * EDIT control.
    12581258     */
     
    12841284    {
    12851285    case CBN_DROPDOWN:
    1286     SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
    1287                  (LPARAM)hwnd);
    1288     /*
    1289      * from native trace of first dropdown after typing in URL in IE4
    1290     *  CB_GETCURSEL(Combo)
    1291     *  GetWindowText(Edit)
    1292     *  CB_GETCURSEL(Combo)
    1293     *  CB_GETCOUNT(Combo)
    1294     *  CB_GETITEMDATA(Combo, n)
    1295     *  WM_NOTIFY(parent, CBEN_ENDEDITA|W)
    1296     *  CB_GETCURSEL(Combo)
    1297     *  CB_SETCURSEL(COMBOEX, n)
    1298     *  SetFocus(Combo)
    1299      * the rest is supposition
    1300     */
    1301     cursel = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
    1302     if (cursel == -1) {
    1303         /* find match from edit against those in Combobox */
    1304         GetWindowTextW (infoPtr->hwndEdit, wintext, 520);
    1305         n = SendMessageW (infoPtr->hwndCombo, CB_GETCOUNT, 0, 0);
    1306         for (cursel = 0; cursel < n; cursel++){
    1307         item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
    1308                              CB_GETITEMDATA,
    1309                              cursel, 0);
    1310         if ((INT)item == CB_ERR) break;
    1311         if (lstrcmpiW(item->pszText, wintext) == 0) break;
    1312         }
    1313         if ((cursel == n) || ((INT)item == CB_ERR)) {
    1314         TRACE("failed to find match??? item=%p cursel=%d\n",
    1315               item, cursel);
    1316         if (infoPtr->hwndEdit)
    1317             SetFocus(infoPtr->hwndEdit);
    1318         return 0;
    1319         }
    1320     }
    1321     else {
    1322         item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
    1323                          CB_GETITEMDATA,
    1324                         cursel, 0);
    1325         if ((INT)item == CB_ERR) {
    1326         TRACE("failed to find match??? item=%p cursel=%d\n",
    1327               item, cursel);
    1328         if (infoPtr->hwndEdit)
    1329             SetFocus(infoPtr->hwndEdit);
    1330         return 0;
    1331         }
    1332     }
    1333 
    1334     /* Save flags for testing and reset them */
    1335     oldflags = infoPtr->flags;
    1336     infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
    1337 
    1338     if (oldflags & WCBE_ACTEDIT) {
    1339         cbeend.fChanged = (oldflags & WCBE_EDITCHG);
    1340         cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
    1341                         CB_GETCURSEL, 0, 0);
    1342         cbeend.iWhy = CBENF_DROPDOWN;
    1343 
    1344         if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, item->pszText)) {
    1345         /* abort the change */
    1346         TRACE("Notify requested abort of change\n");
    1347         return 0;
    1348         }
    1349     }
    1350 
    1351     /* if selection has changed the set the new current selection */
    1352     cursel = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
    1353     if ((oldflags & WCBE_EDITCHG) || (cursel != infoPtr->selected)) {
    1354         infoPtr->selected = cursel;
    1355         SendMessageW (hwnd, CB_SETCURSEL, cursel, 0);
    1356         SetFocus(infoPtr->hwndCombo);
    1357     }
    1358     return 0;
     1286        SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
     1287                             (LPARAM)hwnd);
     1288        /*
     1289         * from native trace of first dropdown after typing in URL in IE4
     1290        *  CB_GETCURSEL(Combo)
     1291        *  GetWindowText(Edit)
     1292        *  CB_GETCURSEL(Combo)
     1293        *  CB_GETCOUNT(Combo)
     1294        *  CB_GETITEMDATA(Combo, n)
     1295        *  WM_NOTIFY(parent, CBEN_ENDEDITA|W)
     1296        *  CB_GETCURSEL(Combo)
     1297        *  CB_SETCURSEL(COMBOEX, n)
     1298        *  SetFocus(Combo)
     1299         * the rest is supposition 
     1300        */
     1301        cursel = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
     1302        if (cursel == -1) {
     1303            /* find match from edit against those in Combobox */
     1304            GetWindowTextW (infoPtr->hwndEdit, wintext, 520);
     1305            n = SendMessageW (infoPtr->hwndCombo, CB_GETCOUNT, 0, 0);
     1306            for (cursel = 0; cursel < n; cursel++){
     1307                item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
     1308                                                     CB_GETITEMDATA,
     1309                                                     cursel, 0);
     1310                if ((INT)item == CB_ERR) break;
     1311                if (lstrcmpiW(item->pszText, wintext) == 0) break;
     1312            }
     1313            if ((cursel == n) || ((INT)item == CB_ERR)) {
     1314                TRACE("failed to find match??? item=%p cursel=%d\n",
     1315                      item, cursel);
     1316                if (infoPtr->hwndEdit)
     1317                    SetFocus(infoPtr->hwndEdit);
     1318                return 0;
     1319            }
     1320        }
     1321        else {
     1322            item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
     1323                                                 CB_GETITEMDATA,
     1324                                                cursel, 0);
     1325            if ((INT)item == CB_ERR) {
     1326                TRACE("failed to find match??? item=%p cursel=%d\n",
     1327                      item, cursel);
     1328                if (infoPtr->hwndEdit)
     1329                    SetFocus(infoPtr->hwndEdit);
     1330                return 0;
     1331            }
     1332        }
     1333
     1334        /* Save flags for testing and reset them */
     1335        oldflags = infoPtr->flags;
     1336        infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
     1337
     1338        if (oldflags & WCBE_ACTEDIT) {
     1339            cbeend.fChanged = (oldflags & WCBE_EDITCHG);
     1340            cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
     1341                                                CB_GETCURSEL, 0, 0);
     1342            cbeend.iWhy = CBENF_DROPDOWN;
     1343
     1344            if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, item->pszText)) {
     1345                /* abort the change */
     1346                TRACE("Notify requested abort of change\n");
     1347                return 0;
     1348            }
     1349        }
     1350
     1351        /* if selection has changed the set the new current selection */
     1352        cursel = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
     1353        if ((oldflags & WCBE_EDITCHG) || (cursel != infoPtr->selected)) {
     1354            infoPtr->selected = cursel;
     1355            SendMessageW (hwnd, CB_SETCURSEL, cursel, 0);
     1356            SetFocus(infoPtr->hwndCombo);
     1357        }
     1358        return 0;
    13591359
    13601360    case CBN_SELCHANGE:
    1361     /*
    1362     * CB_GETCURSEL(Combo)
    1363     * CB_GETITEMDATA(Combo)   < simulated by COMBOEX_FindItem
    1364     * lstrlenA
    1365     * WM_SETTEXT(Edit)
    1366     * WM_GETTEXTLENGTH(Edit)
    1367     * WM_GETTEXT(Edit)
    1368     * EM_SETSEL(Edit, 0,0)
    1369     * WM_GETTEXTLENGTH(Edit)
    1370     * WM_GETTEXT(Edit)
    1371     * EM_SETSEL(Edit, 0,len)
    1372     * return WM_COMMAND to parent
    1373     */
    1374     oldItem = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
    1375     if (!(item = COMBOEX_FindItem(infoPtr, oldItem))) {
    1376         ERR("item %d not found. Problem!\n", oldItem);
    1377         break;
    1378     }
    1379     infoPtr->selected = oldItem;
    1380     COMBOEX_SetEditText (infoPtr, item);
    1381     return SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
    1382                  (LPARAM)hwnd);
     1361        /*
     1362        * CB_GETCURSEL(Combo)
     1363        * CB_GETITEMDATA(Combo)   < simulated by COMBOEX_FindItem
     1364        * lstrlenA
     1365        * WM_SETTEXT(Edit)
     1366        * WM_GETTEXTLENGTH(Edit)
     1367        * WM_GETTEXT(Edit)
     1368        * EM_SETSEL(Edit, 0,0)
     1369        * WM_GETTEXTLENGTH(Edit)
     1370        * WM_GETTEXT(Edit)
     1371        * EM_SETSEL(Edit, 0,len)
     1372        * return WM_COMMAND to parent
     1373        */
     1374        oldItem = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
     1375        if (!(item = COMBOEX_FindItem(infoPtr, oldItem))) {
     1376            ERR("item %d not found. Problem!\n", oldItem);
     1377            break;
     1378        }
     1379        infoPtr->selected = oldItem;
     1380        COMBOEX_SetEditText (infoPtr, item);
     1381        return SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
     1382                             (LPARAM)hwnd);
    13831383
    13841384    case CBN_SELENDOK:
    1385     /*
    1386     * We have to change the handle since we are the control
    1387     * issuing the message. IE4 depends on this.
    1388     */
    1389     return SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
    1390                  (LPARAM)hwnd);
     1385        /*
     1386        * We have to change the handle since we are the control
     1387        * issuing the message. IE4 depends on this.
     1388        */
     1389        return SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
     1390                             (LPARAM)hwnd);
    13911391
    13921392    case CBN_KILLFOCUS:
    1393     /*
    1394     * from native trace:
    1395     *
    1396     *  pass to parent
    1397     *  WM_GETTEXT(Edit, 104)
    1398     *  CB_GETCURSEL(Combo) rets -1
    1399     *  WM_NOTIFY(CBEN_ENDEDITA) with CBENF_KILLFOCUS
    1400     *  CB_GETCURSEL(Combo)
    1401     *  InvalidateRect(Combo, 0, 0)
    1402     *  return 0
    1403     */
    1404     SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
    1405                  (LPARAM)hwnd);
    1406     if (infoPtr->flags & WCBE_ACTEDIT) {
    1407         GetWindowTextW (infoPtr->hwndEdit, wintext, 260);
    1408         cbeend.fChanged = (infoPtr->flags & WCBE_EDITCHG);
    1409         cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
    1410                         CB_GETCURSEL, 0, 0);
    1411         cbeend.iWhy = CBENF_KILLFOCUS;
    1412 
    1413         infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
    1414         if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, wintext)) {
    1415         /* abort the change */
    1416         TRACE("Notify requested abort of change\n");
    1417         return 0;
    1418         }
    1419     }
    1420     /* possible CB_GETCURSEL */
    1421     InvalidateRect (infoPtr->hwndCombo, 0, 0);
    1422     return 0;
     1393        /*
     1394        * from native trace:
     1395        *
     1396        *  pass to parent
     1397        *  WM_GETTEXT(Edit, 104)
     1398        *  CB_GETCURSEL(Combo) rets -1
     1399        *  WM_NOTIFY(CBEN_ENDEDITA) with CBENF_KILLFOCUS
     1400        *  CB_GETCURSEL(Combo)
     1401        *  InvalidateRect(Combo, 0, 0)
     1402        *  return 0
     1403        */
     1404        SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
     1405                             (LPARAM)hwnd);
     1406        if (infoPtr->flags & WCBE_ACTEDIT) {
     1407            GetWindowTextW (infoPtr->hwndEdit, wintext, 260);
     1408            cbeend.fChanged = (infoPtr->flags & WCBE_EDITCHG);
     1409            cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
     1410                                                CB_GETCURSEL, 0, 0);
     1411            cbeend.iWhy = CBENF_KILLFOCUS;
     1412
     1413            infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
     1414            if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, wintext)) {
     1415                /* abort the change */
     1416                TRACE("Notify requested abort of change\n");
     1417                return 0;
     1418            }
     1419        }
     1420        /* possible CB_GETCURSEL */
     1421        InvalidateRect (infoPtr->hwndCombo, 0, 0);
     1422        return 0;
    14231423
    14241424    case CBN_CLOSEUP:
    14251425    default:
    1426     /*
    1427     * We have to change the handle since we are the control
    1428     * issuing the message. IE4 depends on this.
    1429     * We also need to set the focus back to the Edit control
    1430     * after passing the command to the parent of the ComboEx.
    1431     */
    1432     lret = SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
    1433                  (LPARAM)hwnd);
    1434     if (infoPtr->hwndEdit)
    1435         SetFocus(infoPtr->hwndEdit);
    1436     return lret;
     1426        /*
     1427        * We have to change the handle since we are the control
     1428        * issuing the message. IE4 depends on this.
     1429        * We also need to set the focus back to the Edit control
     1430        * after passing the command to the parent of the ComboEx.
     1431        */
     1432        lret = SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
     1433                             (LPARAM)hwnd);
     1434        if (infoPtr->hwndEdit)
     1435            SetFocus(infoPtr->hwndEdit);
     1436        return lret;
    14371437    }
    14381438    return 0;
     
    14501450
    14511451    TRACE("CtlType=%08x, CtlID=%08x, itemID=%08x, hwnd=%x, data=%08lx\n",
    1452       dis->CtlType, dis->CtlID, dis->itemID, dis->hwndItem, dis->itemData);
     1452          dis->CtlType, dis->CtlID, dis->itemID, dis->hwndItem, dis->itemData);
    14531453
    14541454    if ((dis->itemID >= infoPtr->nb_items) || (dis->itemID < 0)) return FALSE;
     
    14581458
    14591459    if (i == dis->itemID) {
    1460     infoPtr->items = infoPtr->items->next;
     1460        infoPtr->items = infoPtr->items->next;
    14611461    }
    14621462    else {
    1463     item = olditem;
    1464     i--;
    1465 
    1466     /* find the prior item in the list */
    1467     while (item->next && (i > dis->itemID)) {
    1468         item = (CBE_ITEMDATA *)item->next;
    1469         i--;
    1470     }
    1471     if (!item->next || (i != dis->itemID)) {
    1472         FIXME("COMBOBOXEX item structures broken. Please report!\n");
    1473         return FALSE;
    1474     }
    1475     olditem = item->next;
    1476     item->next = (CBE_ITEMDATA *)((CBE_ITEMDATA *)item->next)->next;
     1463        item = olditem;
     1464        i--;
     1465
     1466        /* find the prior item in the list */
     1467        while (item->next && (i > dis->itemID)) {
     1468            item = (CBE_ITEMDATA *)item->next;
     1469            i--;
     1470        }
     1471        if (!item->next || (i != dis->itemID)) {
     1472            FIXME("COMBOBOXEX item structures broken. Please report!\n");
     1473            return FALSE;
     1474        }
     1475        olditem = item->next;
     1476        item->next = (CBE_ITEMDATA *)((CBE_ITEMDATA *)item->next)->next;
    14771477    }
    14781478    infoPtr->nb_items--;
     
    14821482
    14831483    if (olditem->pszText)
    1484     COMCTL32_Free(olditem->pszText);
     1484        COMCTL32_Free(olditem->pszText);
    14851485    COMCTL32_Free(olditem);
    14861486
     
    15101510    /* dump the DRAWITEMSTRUCT if tracing "comboex" but not "message" */
    15111511    if (!TRACE_ON(message)) {
    1512     TRACE("DRAWITEMSTRUCT: CtlType=0x%08x CtlID=0x%08x\n",
    1513           dis->CtlType, dis->CtlID);
    1514     TRACE("itemID=0x%08x itemAction=0x%08x itemState=0x%08x\n",
    1515           dis->itemID, dis->itemAction, dis->itemState);
    1516     TRACE("hWnd=0x%04x hDC=0x%04x (%d,%d)-(%d,%d) itemData=0x%08lx\n",
    1517           dis->hwndItem, dis->hDC, dis->rcItem.left,
    1518           dis->rcItem.top, dis->rcItem.right, dis->rcItem.bottom,
    1519           dis->itemData);
     1512        TRACE("DRAWITEMSTRUCT: CtlType=0x%08x CtlID=0x%08x\n",
     1513              dis->CtlType, dis->CtlID);
     1514        TRACE("itemID=0x%08x itemAction=0x%08x itemState=0x%08x\n",
     1515              dis->itemID, dis->itemAction, dis->itemState);
     1516        TRACE("hWnd=0x%04x hDC=0x%04x (%d,%d)-(%d,%d) itemData=0x%08lx\n",
     1517              dis->hwndItem, dis->hDC, dis->rcItem.left,
     1518              dis->rcItem.top, dis->rcItem.right, dis->rcItem.bottom,
     1519              dis->itemData);
    15201520    }
    15211521
     
    15321532    /*      though the list box or combo box has the focus.             */
    15331533    if (dis->itemID == 0xffffffff) {
    1534     if ( ( (dis->itemAction & ODA_FOCUS) && (dis->itemState & ODS_SELECTED)) ||
    1535          ( (dis->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)) && (dis->itemState & ODS_FOCUS) ) ) {
    1536 
    1537         TRACE("drawing item -1 special focus, rect=(%d,%d)-(%d,%d)\n",
    1538           dis->rcItem.left, dis->rcItem.top,
    1539           dis->rcItem.right, dis->rcItem.bottom);
    1540     }
    1541     else if ((dis->CtlType == ODT_COMBOBOX) &&
    1542         (dis->itemAction == ODA_DRAWENTIRE)) {
    1543         /* draw of edit control data */
    1544 
    1545         /* testing */
    1546         {
    1547         RECT exrc, cbrc, edrc;
    1548         GetWindowRect (hwnd, &exrc);
    1549         GetWindowRect (infoPtr->hwndCombo, &cbrc);
    1550         edrc.left=edrc.top=edrc.right=edrc.bottom=-1;
    1551         if (infoPtr->hwndEdit)
    1552             GetWindowRect (infoPtr->hwndEdit, &edrc);
    1553         TRACE("window rects ex=(%d,%d)-(%d,%d), cb=(%d,%d)-(%d,%d), ed=(%d,%d)-(%d,%d)\n",
    1554               exrc.left, exrc.top, exrc.right, exrc.bottom,
    1555               cbrc.left, cbrc.top, cbrc.right, cbrc.bottom,
    1556               edrc.left, edrc.top, edrc.right, edrc.bottom);
    1557         }
    1558     }
    1559     else {
    1560         ERR("NOT drawing item  -1 special focus, rect=(%d,%d)-(%d,%d), action=%08x, state=%08x\n",
    1561         dis->rcItem.left, dis->rcItem.top,
    1562         dis->rcItem.right, dis->rcItem.bottom,
    1563         dis->itemAction, dis->itemState);
    1564         return 0;
    1565     }
     1534        if ( ( (dis->itemAction & ODA_FOCUS) && (dis->itemState & ODS_SELECTED)) ||
     1535             ( (dis->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)) && (dis->itemState & ODS_FOCUS) ) ) {
     1536
     1537            TRACE("drawing item -1 special focus, rect=(%d,%d)-(%d,%d)\n",
     1538                  dis->rcItem.left, dis->rcItem.top,
     1539                  dis->rcItem.right, dis->rcItem.bottom);
     1540        }
     1541        else if ((dis->CtlType == ODT_COMBOBOX) &&
     1542                (dis->itemAction == ODA_DRAWENTIRE)) {
     1543            /* draw of edit control data */
     1544
     1545            /* testing */
     1546            {
     1547                RECT exrc, cbrc, edrc;
     1548                GetWindowRect (hwnd, &exrc);
     1549                GetWindowRect (infoPtr->hwndCombo, &cbrc);
     1550                edrc.left=edrc.top=edrc.right=edrc.bottom=-1;
     1551                if (infoPtr->hwndEdit)
     1552                    GetWindowRect (infoPtr->hwndEdit, &edrc);
     1553                TRACE("window rects ex=(%d,%d)-(%d,%d), cb=(%d,%d)-(%d,%d), ed=(%d,%d)-(%d,%d)\n",
     1554                      exrc.left, exrc.top, exrc.right, exrc.bottom,
     1555                      cbrc.left, cbrc.top, cbrc.right, cbrc.bottom,
     1556                      edrc.left, edrc.top, edrc.right, edrc.bottom);
     1557            }
     1558        }
     1559        else {
     1560            ERR("NOT drawing item  -1 special focus, rect=(%d,%d)-(%d,%d), action=%08x, state=%08x\n",
     1561                dis->rcItem.left, dis->rcItem.top,
     1562                dis->rcItem.right, dis->rcItem.bottom,
     1563                dis->itemAction, dis->itemState);
     1564            return 0;
     1565        }
    15661566    }
    15671567
    15681568    /* If draw item is -1 (edit control) setup the item pointer */
    15691569    if (dis->itemID == 0xffffffff) {
    1570     CHAR str[260];
    1571     INT wlen, alen;
    1572 
    1573     item = infoPtr->edit;
    1574 
    1575     if (infoPtr->hwndEdit) {
    1576 
    1577         /* free previous text of edit item */
    1578         if (item->pszText) {
    1579         COMCTL32_Free(item->pszText);
    1580         item->pszText = 0;
    1581         item->mask &= ~CBEIF_TEXT;
    1582         }
    1583         alen = SendMessageA (infoPtr->hwndEdit, WM_GETTEXT, 260, (LPARAM)&str);
    1584         TRACE("edit control hwndEdit=%0x, text len=%d str=<%s>\n",
    1585           infoPtr->hwndEdit, alen, str);
    1586         if (alen > 0) {
    1587         item->mask |= CBEIF_TEXT;
    1588         wlen = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
    1589         if (wlen > 0) {
    1590             item->pszText = (LPWSTR)COMCTL32_Alloc ((wlen + 1)*sizeof(WCHAR));
    1591             MultiByteToWideChar (CP_ACP, 0, str, -1, item->pszText, wlen);
    1592         }
    1593         }
    1594     }
     1570        CHAR str[260];
     1571        INT wlen, alen;
     1572
     1573        item = infoPtr->edit;
     1574
     1575        if (infoPtr->hwndEdit) {
     1576
     1577            /* free previous text of edit item */
     1578            if (item->pszText) {
     1579                COMCTL32_Free(item->pszText);
     1580                item->pszText = 0;
     1581                item->mask &= ~CBEIF_TEXT;
     1582            }
     1583            alen = SendMessageA (infoPtr->hwndEdit, WM_GETTEXT, 260, (LPARAM)&str);
     1584            TRACE("edit control hwndEdit=%0x, text len=%d str=<%s>\n",
     1585                  infoPtr->hwndEdit, alen, str);
     1586            if (alen > 0) {
     1587                item->mask |= CBEIF_TEXT;
     1588                wlen = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
     1589                if (wlen > 0) {
     1590                    item->pszText = (LPWSTR)COMCTL32_Alloc ((wlen + 1)*sizeof(WCHAR));
     1591                    MultiByteToWideChar (CP_ACP, 0, str, -1, item->pszText, wlen);
     1592                }
     1593            }
     1594        }
    15951595    }
    15961596
    15971597    /* if the item pointer is not set, then get the data and locate it */
    15981598    if (!item) {
    1599     item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
    1600                  CB_GETITEMDATA, (WPARAM)dis->itemID, 0);
    1601     if (item == (CBE_ITEMDATA *)CB_ERR)
    1602         {
    1603         FIXME("invalid item for id %d \n",dis->itemID);
    1604         return 0;
    1605         }
     1599        item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
     1600                             CB_GETITEMDATA, (WPARAM)dis->itemID, 0);
     1601        if (item == (CBE_ITEMDATA *)CB_ERR)
     1602            {
     1603                FIXME("invalid item for id %d \n",dis->itemID);
     1604                return 0;
     1605            }
    16061606    }
    16071607
     
    16121612        xbase += (item->iIndent * CBE_INDENT);
    16131613    if (item->mask & CBEIF_IMAGE) {
    1614     ImageList_GetImageInfo(infoPtr->himl, item->iImage, &iinfo);
    1615     xioff = (iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP);
     1614        ImageList_GetImageInfo(infoPtr->himl, item->iImage, &iinfo);
     1615        xioff = (iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP);
    16161616    }
    16171617
     
    16191619    case ODA_FOCUS:
    16201620        if (dis->itemState & ODS_SELECTED /*1*/) {
    1621         if ((item->mask & CBEIF_TEXT) && item->pszText) {
    1622         RECT rect2;
    1623 
    1624             len = strlenW (item->pszText);
    1625         GetTextExtentPointW (dis->hDC, item->pszText, len, &txtsize);
    1626         rect.left = xbase + xioff - 1;
    1627         rect.right = rect.left + txtsize.cx + 2;
    1628         rect.top = dis->rcItem.top;
    1629         rect.bottom = dis->rcItem.bottom;
    1630         GetClipBox (dis->hDC, &rect2);
    1631         TRACE("drawing item %d focus, rect=(%d,%d)-(%d,%d)\n",
    1632               dis->itemID, rect.left, rect.top,
    1633               rect.right, rect.bottom);
    1634         TRACE("                      clip=(%d,%d)-(%d,%d)\n",
    1635               rect2.left, rect2.top,
    1636               rect2.right, rect2.bottom);
    1637 
    1638         DrawFocusRect(dis->hDC, &rect);
    1639         }
    1640         else {
    1641         FIXME("ODA_FOCUS and ODS_SELECTED but no text\n");
    1642         }
    1643     }
    1644     else {
    1645         FIXME("ODA_FOCUS but not ODS_SELECTED\n");
    1646     }
     1621            if ((item->mask & CBEIF_TEXT) && item->pszText) {
     1622                RECT rect2;
     1623
     1624                len = strlenW (item->pszText);
     1625                GetTextExtentPointW (dis->hDC, item->pszText, len, &txtsize);
     1626                rect.left = xbase + xioff - 1;
     1627                rect.right = rect.left + txtsize.cx + 2;
     1628                rect.top = dis->rcItem.top;
     1629                rect.bottom = dis->rcItem.bottom;
     1630                GetClipBox (dis->hDC, &rect2);
     1631                TRACE("drawing item %d focus, rect=(%d,%d)-(%d,%d)\n",
     1632                      dis->itemID, rect.left, rect.top,
     1633                      rect.right, rect.bottom);
     1634                TRACE("                      clip=(%d,%d)-(%d,%d)\n",
     1635                      rect2.left, rect2.top,
     1636                      rect2.right, rect2.bottom);
     1637
     1638                DrawFocusRect(dis->hDC, &rect);
     1639            }
     1640            else {
     1641                FIXME("ODA_FOCUS and ODS_SELECTED but no text\n");
     1642            }
     1643        }
     1644        else {
     1645            FIXME("ODA_FOCUS but not ODS_SELECTED\n");
     1646        }
    16471647        break;
    16481648    case ODA_SELECT:
    16491649    case ODA_DRAWENTIRE:
    16501650        drawimage = -1;
    1651     drawstate = ILD_NORMAL;
    1652     if (!(infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE)) {
    1653         if (item->mask & CBEIF_IMAGE)
    1654         drawimage = item->iImage;
    1655         if (dis->itemState & ODS_COMBOEXLBOX) {
    1656         /* drawing listbox entry */
    1657         if (dis->itemState & ODS_SELECTED) {
    1658             if (item->mask & CBEIF_SELECTEDIMAGE)
    1659             drawimage = item->iSelectedImage;
    1660             drawstate = ILD_SELECTED;
    1661         }
    1662         }
    1663         else {
    1664         /* drawing combo/edit entry */
    1665         if (infoPtr->hwndEdit) {
    1666             /* if we have an edit control, the slave the
    1667                      * selection state to the Edit focus state
    1668              */
    1669             if (infoPtr->flags & WCBE_EDITFOCUSED) {
    1670             if (item->mask & CBEIF_SELECTEDIMAGE)
    1671                 drawimage = item->iSelectedImage;
    1672             drawstate = ILD_SELECTED;
    1673             }
    1674         }
    1675         else {
    1676             /* if we don't have an edit control, use
    1677              * the requested state.
    1678              */
    1679             if (dis->itemState & ODS_SELECTED) {
    1680             if (item->mask & CBEIF_SELECTEDIMAGE)
    1681                 drawimage = item->iSelectedImage;
    1682             drawstate = ILD_SELECTED;
    1683             }
    1684         }
    1685         }
    1686     }
    1687     if (drawimage != -1) {
    1688         TRACE("drawing image state=%d\n", dis->itemState & ODS_SELECTED);
    1689         ImageList_Draw (infoPtr->himl, drawimage, dis->hDC,
    1690                 xbase, dis->rcItem.top, drawstate);
    1691     }
    1692 
    1693     /* setup pointer to text to be drawn */
    1694     if ((item->mask & CBEIF_TEXT) && item->pszText)
    1695         str = item->pszText;
    1696     else
    1697         str = (LPWSTR) L"";
    1698 
    1699     /* now draw the text */
    1700     len = lstrlenW (str);
    1701     GetTextExtentPointW (dis->hDC, str, len, &txtsize);
    1702     nbkc = GetSysColor ((dis->itemState & ODS_SELECTED) ?
    1703                 COLOR_HIGHLIGHT : COLOR_WINDOW);
    1704     SetBkColor (dis->hDC, nbkc);
    1705     ntxc = GetSysColor ((dis->itemState & ODS_SELECTED) ?
    1706                 COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT);
    1707     SetTextColor (dis->hDC, ntxc);
    1708     x = xbase + xioff;
    1709     y = dis->rcItem.top +
    1710         (dis->rcItem.bottom - dis->rcItem.top - txtsize.cy) / 2;
    1711     rect.left = x;
    1712     rect.right = x + txtsize.cx;
    1713     rect.top = dis->rcItem.top + 1;
    1714     rect.bottom = dis->rcItem.bottom - 1;
    1715     TRACE("drawing item %d text, rect=(%d,%d)-(%d,%d)\n",
    1716           dis->itemID, rect.left, rect.top, rect.right, rect.bottom);
    1717     ExtTextOutW (dis->hDC, x, y, ETO_OPAQUE | ETO_CLIPPED,
    1718              &rect, str, len, 0);
    1719     if (dis->itemState & ODS_FOCUS) {
    1720         rect.top -= 1;
    1721         rect.bottom += 1;
    1722         rect.left -= 1;
    1723         rect.right += 1;
    1724         TRACE("drawing item %d focus after text, rect=(%d,%d)-(%d,%d)\n",
    1725           dis->itemID, rect.left, rect.top, rect.right, rect.bottom);
    1726         DrawFocusRect (dis->hDC, &rect);
    1727     }
    1728     break;
     1651        drawstate = ILD_NORMAL;
     1652        if (!(infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE)) {
     1653            if (item->mask & CBEIF_IMAGE)
     1654                drawimage = item->iImage;
     1655            if (dis->itemState & ODS_COMBOEXLBOX) {
     1656                /* drawing listbox entry */
     1657                if (dis->itemState & ODS_SELECTED) {
     1658                    if (item->mask & CBEIF_SELECTEDIMAGE)
     1659                        drawimage = item->iSelectedImage;
     1660                    drawstate = ILD_SELECTED;
     1661                }
     1662            }
     1663            else {
     1664                /* drawing combo/edit entry */
     1665                if (infoPtr->hwndEdit) {
     1666                    /* if we have an edit control, the slave the
     1667                     * selection state to the Edit focus state 
     1668                     */
     1669                    if (infoPtr->flags & WCBE_EDITFOCUSED) {
     1670                        if (item->mask & CBEIF_SELECTEDIMAGE)
     1671                            drawimage = item->iSelectedImage;
     1672                        drawstate = ILD_SELECTED;
     1673                    }
     1674                }
     1675                else {
     1676                    /* if we don't have an edit control, use
     1677                     * the requested state.
     1678                     */
     1679                    if (dis->itemState & ODS_SELECTED) {
     1680                        if (item->mask & CBEIF_SELECTEDIMAGE)
     1681                            drawimage = item->iSelectedImage;
     1682                        drawstate = ILD_SELECTED;
     1683                    }
     1684                }
     1685            }
     1686        }
     1687        if (drawimage != -1) {
     1688            TRACE("drawing image state=%d\n", dis->itemState & ODS_SELECTED);
     1689            ImageList_Draw (infoPtr->himl, drawimage, dis->hDC,
     1690                            xbase, dis->rcItem.top, drawstate);
     1691        }
     1692
     1693        /* setup pointer to text to be drawn */
     1694        if ((item->mask & CBEIF_TEXT) && item->pszText)
     1695            str = item->pszText;
     1696        else
     1697            str = (LPWSTR) L"";
     1698
     1699        /* now draw the text */
     1700        len = lstrlenW (str);
     1701        GetTextExtentPointW (dis->hDC, str, len, &txtsize);
     1702        nbkc = GetSysColor ((dis->itemState & ODS_SELECTED) ?
     1703                            COLOR_HIGHLIGHT : COLOR_WINDOW);
     1704        SetBkColor (dis->hDC, nbkc);
     1705        ntxc = GetSysColor ((dis->itemState & ODS_SELECTED) ?
     1706                            COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT);
     1707        SetTextColor (dis->hDC, ntxc);
     1708        x = xbase + xioff;
     1709        y = dis->rcItem.top +
     1710            (dis->rcItem.bottom - dis->rcItem.top - txtsize.cy) / 2;
     1711        rect.left = x;
     1712        rect.right = x + txtsize.cx;
     1713        rect.top = dis->rcItem.top + 1;
     1714        rect.bottom = dis->rcItem.bottom - 1;
     1715        TRACE("drawing item %d text, rect=(%d,%d)-(%d,%d)\n",
     1716              dis->itemID, rect.left, rect.top, rect.right, rect.bottom);
     1717        ExtTextOutW (dis->hDC, x, y, ETO_OPAQUE | ETO_CLIPPED,
     1718                     &rect, str, len, 0);
     1719        if (dis->itemState & ODS_FOCUS) {
     1720            rect.top -= 1;
     1721            rect.bottom += 1;
     1722            rect.left -= 1;
     1723            rect.right += 1;
     1724            TRACE("drawing item %d focus after text, rect=(%d,%d)-(%d,%d)\n",
     1725                  dis->itemID, rect.left, rect.top, rect.right, rect.bottom);
     1726            DrawFocusRect (dis->hDC, &rect);
     1727        }
     1728        break;
    17291729    default:
    1730         FIXME("unknown action hwnd=%08x, wparam=%08x, lparam=%08lx, action=%d\n",
    1731           hwnd, wParam, lParam, dis->itemAction);
     1730        FIXME("unknown action hwnd=%08x, wparam=%08x, lparam=%08lx, action=%d\n", 
     1731              hwnd, wParam, lParam, dis->itemAction);
    17321732    }
    17331733
     
    17421742
    17431743    if (infoPtr->hwndCombo)
    1744     DestroyWindow (infoPtr->hwndCombo);
     1744        DestroyWindow (infoPtr->hwndCombo);
    17451745
    17461746    if (infoPtr->edit) {
    1747     COMCTL32_Free (infoPtr->edit);
    1748     infoPtr->edit = 0;
     1747        COMCTL32_Free (infoPtr->edit);
     1748        infoPtr->edit = 0;
    17491749    }
    17501750
     
    17521752        CBE_ITEMDATA *this, *next;
    17531753
    1754     this = infoPtr->items;
    1755     while (this) {
    1756         next = (CBE_ITEMDATA *)this->next;
    1757         if ((this->mask & CBEIF_TEXT) && this->pszText)
    1758             COMCTL32_Free (this->pszText);
    1759         COMCTL32_Free (this);
    1760         this = next;
    1761     }
     1754        this = infoPtr->items;
     1755        while (this) {
     1756            next = (CBE_ITEMDATA *)this->next;
     1757            if ((this->mask & CBEIF_TEXT) && this->pszText)
     1758                COMCTL32_Free (this->pszText);
     1759            COMCTL32_Free (this);
     1760            this = next;
     1761        }
    17621762    }
    17631763
     
    17851785
    17861786    TRACE("adjusted height hwnd=%08x, height=%d\n",
    1787       hwnd, mis->itemHeight);
     1787          hwnd, mis->itemHeight);
    17881788
    17891789    return 0;
     
    18001800    newstyle = oldstyle & ~(WS_VSCROLL | WS_HSCROLL);
    18011801    if (newstyle != oldstyle) {
    1802     TRACE("req style %08lx, reseting style %08lx\n",
    1803           oldstyle, newstyle);
    1804     SetWindowLongA (hwnd, GWL_STYLE, newstyle);
     1802        TRACE("req style %08lx, reseting style %08lx\n",
     1803              oldstyle, newstyle);
     1804        SetWindowLongA (hwnd, GWL_STYLE, newstyle);
    18051805    }
    18061806    return 1;
     
    18151815
    18161816    if (lParam == NF_REQUERY) {
    1817     i = SendMessageA(GetParent (hwnd),
    1818             WM_NOTIFYFORMAT, infoPtr->hwndSelf, NF_QUERY);
    1819     if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
    1820         ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
    1821         i);
    1822         i = NFR_ANSI;
    1823     }
    1824     infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
    1825     return (LRESULT)i;
     1817        i = SendMessageA(GetParent (hwnd),
     1818                        WM_NOTIFYFORMAT, infoPtr->hwndSelf, NF_QUERY);
     1819        if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
     1820            ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
     1821                i);
     1822            i = NFR_ANSI;
     1823        }
     1824        infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
     1825        return (LRESULT)i;
    18261826    }
    18271827    return (LRESULT)((infoPtr->bUnicode) ? NFR_UNICODE : NFR_ANSI);
     
    18371837    GetWindowRect (hwnd, &rect);
    18381838    TRACE("my rect (%d,%d)-(%d,%d)\n",
    1839       rect.left, rect.top, rect.right, rect.bottom);
     1839          rect.left, rect.top, rect.right, rect.bottom);
    18401840
    18411841    MoveWindow (infoPtr->hwndCombo, 0, 0, rect.right -rect.left,
    1842           rect.bottom - rect.top, TRUE);
     1842                  rect.bottom - rect.top, TRUE);
    18431843
    18441844    COMBOEX_AdjustEditPos (infoPtr);
     
    18621862    /* width is winpos value + border width of comboex */
    18631863    width = wp->cx
    1864         + (cbx_wrect.right-cbx_wrect.left)
    1865             - (cbx_crect.right-cbx_crect.left);
     1864            + (cbx_wrect.right-cbx_wrect.left)
     1865            - (cbx_crect.right-cbx_crect.left); 
    18661866
    18671867    TRACE("winpos=(%d,%d %dx%d) flags=0x%08x\n",
    1868       wp->x, wp->y, wp->cx, wp->cy, wp->flags);
     1868          wp->x, wp->y, wp->cx, wp->cy, wp->flags);
    18691869    TRACE("EX window=(%d,%d)-(%d,%d), client=(%d,%d)-(%d,%d)\n",
    1870       cbx_wrect.left, cbx_wrect.top, cbx_wrect.right, cbx_wrect.bottom,
    1871       cbx_crect.left, cbx_crect.top, cbx_crect.right, cbx_crect.bottom);
     1870          cbx_wrect.left, cbx_wrect.top, cbx_wrect.right, cbx_wrect.bottom,
     1871          cbx_crect.left, cbx_crect.top, cbx_crect.right, cbx_crect.bottom);
    18721872    TRACE("CB window=(%d,%d)-(%d,%d), EX setting=(0,0)-(%d,%d)\n",
    1873       cb_wrect.left, cb_wrect.top, cb_wrect.right, cb_wrect.bottom,
    1874       width, cb_wrect.bottom-cb_wrect.top);
     1873          cb_wrect.left, cb_wrect.top, cb_wrect.right, cb_wrect.bottom,
     1874          width, cb_wrect.bottom-cb_wrect.top);
    18751875
    18761876    if (width) SetWindowPos (infoPtr->hwndCombo, HWND_TOP, 0, 0,
    1877                  width,
    1878                  cb_wrect.bottom-cb_wrect.top,
    1879                  SWP_NOACTIVATE);
     1877                             width,
     1878                             cb_wrect.bottom-cb_wrect.top,
     1879                             SWP_NOACTIVATE);
    18801880
    18811881    GetWindowRect (infoPtr->hwndCombo, &cb_wrect);
     
    18831883    /* height is combo window height plus border width of comboex */
    18841884    height =   (cb_wrect.bottom-cb_wrect.top)
    1885          + (cbx_wrect.bottom-cbx_wrect.top)
     1885             + (cbx_wrect.bottom-cbx_wrect.top)
    18861886             - (cbx_crect.bottom-cbx_crect.top);
    18871887    if (wp->cy < height) wp->cy = height;
    18881888    if (infoPtr->hwndEdit) {
    1889     COMBOEX_AdjustEditPos (infoPtr);
    1890     InvalidateRect (infoPtr->hwndCombo, 0, TRUE);
     1889        COMBOEX_AdjustEditPos (infoPtr);
     1890        InvalidateRect (infoPtr->hwndCombo, 0, TRUE);
    18911891    }
    18921892
     
    19061906    LRESULT lret;
    19071907
    1908     TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx, info_ptr=%p\n",
    1909       hwnd, uMsg, wParam, lParam, infoPtr);
     1908    TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx, info_ptr=%p\n", 
     1909          hwnd, uMsg, wParam, lParam, infoPtr);
    19101910
    19111911    if (!infoPtr) return 0;
     
    19151915
    19161916    case WM_CHAR:
    1917         /* handle (ignore) the return character */
    1918         if (wParam == VK_RETURN) return 0;
    1919         /* all other characters pass into the real Edit */
    1920         return CallWindowProcA (infoPtr->prevEditWndProc,
    1921                    hwnd, uMsg, wParam, lParam);
     1917            /* handle (ignore) the return character */
     1918            if (wParam == VK_RETURN) return 0;
     1919            /* all other characters pass into the real Edit */
     1920            return CallWindowProcA (infoPtr->prevEditWndProc,
     1921                                   hwnd, uMsg, wParam, lParam);
    19221922
    19231923    case WM_ERASEBKGND:
    1924         /*
    1925          * The following was determined by traces of the native
    1926          */
     1924            /*
     1925             * The following was determined by traces of the native
     1926             */
    19271927            hDC = (HDC) wParam;
    1928         nbkc = GetSysColor (COLOR_WINDOW);
    1929         obkc = SetBkColor (hDC, nbkc);
     1928            nbkc = GetSysColor (COLOR_WINDOW);
     1929            obkc = SetBkColor (hDC, nbkc);
    19301930            GetClientRect (hwnd, &rect);
    1931         TRACE("erasing (%d,%d)-(%d,%d)\n",
    1932           rect.left, rect.top, rect.right, rect.bottom);
    1933         ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0);
     1931            TRACE("erasing (%d,%d)-(%d,%d)\n",
     1932                  rect.left, rect.top, rect.right, rect.bottom);
     1933            ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0);
    19341934            SetBkColor (hDC, obkc);
    1935         return CallWindowProcA (infoPtr->prevEditWndProc,
    1936                    hwnd, uMsg, wParam, lParam);
     1935            return CallWindowProcA (infoPtr->prevEditWndProc,
     1936                                   hwnd, uMsg, wParam, lParam);
    19371937
    19381938    case WM_KEYDOWN: {
    1939         INT oldItem, selected;
    1940         CBE_ITEMDATA *item;
    1941 
    1942         switch ((INT)wParam)
    1943         {
    1944         case VK_ESCAPE:
    1945         /* native version seems to do following for COMBOEX */
    1946         /*
    1947          *   GetWindowTextA(Edit,&?, 0x104)             x
    1948          *   CB_GETCURSEL to Combo rets -1              x
    1949          *   WM_NOTIFY to COMBOEX parent (rebar)        x
    1950          *     (CBEN_ENDEDIT{A|W}
    1951          *      fChanged = FALSE                        x
    1952          *      inewSelection = -1                      x
    1953          *      txt="www.hoho"                          x
    1954          *      iWhy = 3                                x
    1955          *   CB_GETCURSEL to Combo rets -1              x
    1956          *   InvalidateRect(Combo, 0)                   x
    1957          *   WM_SETTEXT to Edit                         x
    1958          *   EM_SETSEL to Edit (0,0)                    x
    1959          *   EM_SETSEL to Edit (0,-1)                   x
    1960          *   RedrawWindow(Combo, 0, 0, 5)               x
    1961          */
    1962         TRACE("special code for VK_ESCAPE\n");
    1963 
    1964         GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
    1965 
    1966         infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
    1967         cbeend.fChanged = FALSE;
    1968         cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
    1969                              CB_GETCURSEL, 0, 0);
    1970         cbeend.iWhy = CBENF_ESCAPE;
    1971 
    1972         if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) {
    1973             /* abort the change */
    1974             TRACE("Notify requested abort of change\n");
    1975             return 0;
    1976         }
    1977         oldItem = SendMessageW (infoPtr->hwndCombo,CB_GETCURSEL, 0, 0);
    1978         InvalidateRect (infoPtr->hwndCombo, 0, 0);
    1979         if (!(item = COMBOEX_FindItem(infoPtr, oldItem))) {
    1980             ERR("item %d not found. Problem!\n", oldItem);
    1981             break;
    1982         }
    1983         infoPtr->selected = oldItem;
    1984         COMBOEX_SetEditText (infoPtr, item);
    1985         RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE |
    1986                   RDW_INVALIDATE);
    1987         break;
    1988 
    1989         case VK_RETURN:
    1990         /* native version seems to do following for COMBOEX */
    1991         /*
    1992          *   GetWindowTextA(Edit,&?, 0x104)             x
    1993          *   CB_GETCURSEL to Combo  rets -1             x
    1994          *   CB_GETCOUNT to Combo  rets 0
    1995          *   if >0 loop
    1996          *       CB_GETITEMDATA to match
    1997          * *** above 3 lines simulated by FindItem      x
    1998          *   WM_NOTIFY to COMBOEX parent (rebar)        x
    1999          *     (CBEN_ENDEDIT{A|W}                       x
    2000          *        fChanged = TRUE (-1)                  x
    2001          *        iNewSelection = -1 or selected        x
    2002          *        txt=                                  x
    2003          *        iWhy = 2 (CBENF_RETURN)               x
    2004          *   CB_GETCURSEL to Combo  rets -1             x
    2005          *   if -1 send CB_SETCURSEL to Combo -1        x
    2006          *   InvalidateRect(Combo, 0, 0)                x
    2007          *   SetFocus(Edit)                             x
    2008          *   CallWindowProc(406615a8, Edit, 0x100, 0xd, 0x1c0001)
    2009          */
    2010 
    2011         TRACE("special code for VK_RETURN\n");
    2012 
    2013         GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
    2014 
    2015         infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
    2016         selected = SendMessageW (infoPtr->hwndCombo,
    2017                      CB_GETCURSEL, 0, 0);
    2018 
    2019         if (selected != -1) {
    2020             item = COMBOEX_FindItem (infoPtr, selected);
    2021             TRACE("handling VK_RETURN, selected = %d, selected_text=%s\n",
    2022               selected, debugstr_w(item->pszText));
    2023             TRACE("handling VK_RETURN, edittext=%s\n",
    2024               debugstr_w(edit_text));
    2025             if (lstrcmpiW (item->pszText, edit_text)) {
    2026             /* strings not equal -- indicate edit has changed */
    2027             selected = -1;
     1939            INT oldItem, selected;
     1940            CBE_ITEMDATA *item;
     1941
     1942            switch ((INT)wParam)
     1943            {
     1944            case VK_ESCAPE:
     1945                /* native version seems to do following for COMBOEX */
     1946                /*
     1947                 *   GetWindowTextA(Edit,&?, 0x104)             x
     1948                 *   CB_GETCURSEL to Combo rets -1              x
     1949                 *   WM_NOTIFY to COMBOEX parent (rebar)        x
     1950                 *     (CBEN_ENDEDIT{A|W}
     1951                 *      fChanged = FALSE                        x
     1952                 *      inewSelection = -1                      x
     1953                 *      txt="www.hoho"                          x
     1954                 *      iWhy = 3                                x
     1955                 *   CB_GETCURSEL to Combo rets -1              x
     1956                 *   InvalidateRect(Combo, 0)                   x
     1957                 *   WM_SETTEXT to Edit                         x
     1958                 *   EM_SETSEL to Edit (0,0)                    x
     1959                 *   EM_SETSEL to Edit (0,-1)                   x
     1960                 *   RedrawWindow(Combo, 0, 0, 5)               x
     1961                 */
     1962                TRACE("special code for VK_ESCAPE\n");
     1963
     1964                GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
     1965
     1966                infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
     1967                cbeend.fChanged = FALSE;
     1968                cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
     1969                                                     CB_GETCURSEL, 0, 0);
     1970                cbeend.iWhy = CBENF_ESCAPE;
     1971
     1972                if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) {
     1973                    /* abort the change */
     1974                    TRACE("Notify requested abort of change\n");
     1975                    return 0;
     1976                }
     1977                oldItem = SendMessageW (infoPtr->hwndCombo,CB_GETCURSEL, 0, 0);
     1978                InvalidateRect (infoPtr->hwndCombo, 0, 0);
     1979                if (!(item = COMBOEX_FindItem(infoPtr, oldItem))) {
     1980                    ERR("item %d not found. Problem!\n", oldItem);
     1981                    break;
     1982                }
     1983                infoPtr->selected = oldItem;             
     1984                COMBOEX_SetEditText (infoPtr, item);
     1985                RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE |
     1986                              RDW_INVALIDATE);
     1987                break;
     1988
     1989            case VK_RETURN:
     1990                /* native version seems to do following for COMBOEX */
     1991                /*
     1992                 *   GetWindowTextA(Edit,&?, 0x104)             x
     1993                 *   CB_GETCURSEL to Combo  rets -1             x
     1994                 *   CB_GETCOUNT to Combo  rets 0
     1995                 *   if >0 loop
     1996                 *       CB_GETITEMDATA to match
     1997                 * *** above 3 lines simulated by FindItem      x 
     1998                 *   WM_NOTIFY to COMBOEX parent (rebar)        x
     1999                 *     (CBEN_ENDEDIT{A|W}                       x
     2000                 *        fChanged = TRUE (-1)                  x
     2001                 *        iNewSelection = -1 or selected        x
     2002                 *        txt=                                  x
     2003                 *        iWhy = 2 (CBENF_RETURN)               x
     2004                 *   CB_GETCURSEL to Combo  rets -1             x
     2005                 *   if -1 send CB_SETCURSEL to Combo -1        x
     2006                 *   InvalidateRect(Combo, 0, 0)                x
     2007                 *   SetFocus(Edit)                             x
     2008                 *   CallWindowProc(406615a8, Edit, 0x100, 0xd, 0x1c0001)
     2009                 */
     2010
     2011                TRACE("special code for VK_RETURN\n");
     2012
     2013                GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
     2014
     2015                infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
     2016                selected = SendMessageW (infoPtr->hwndCombo,
     2017                                         CB_GETCURSEL, 0, 0);
     2018
     2019                if (selected != -1) {
     2020                    item = COMBOEX_FindItem (infoPtr, selected);
     2021                    TRACE("handling VK_RETURN, selected = %d, selected_text=%s\n",
     2022                          selected, debugstr_w(item->pszText));
     2023                    TRACE("handling VK_RETURN, edittext=%s\n",
     2024                          debugstr_w(edit_text));
     2025                    if (lstrcmpiW (item->pszText, edit_text)) {
     2026                        /* strings not equal -- indicate edit has changed */
     2027                        selected = -1;
     2028                    }
     2029                }
     2030
     2031                cbeend.iNewSelection = selected;
     2032                cbeend.fChanged = TRUE;
     2033                cbeend.iWhy = CBENF_RETURN;
     2034                if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) {
     2035                    /* abort the change, restore previous */
     2036                    TRACE("Notify requested abort of change\n");
     2037                    COMBOEX_SetEditText (infoPtr, infoPtr->edit);
     2038                    RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE |
     2039                                  RDW_INVALIDATE);
     2040                    return 0;
     2041                }
     2042                oldItem = SendMessageW (infoPtr->hwndCombo,CB_GETCURSEL, 0, 0);
     2043                if (oldItem != -1) {
     2044                    /* if something is selected, then deselect it */
     2045                    SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL,
     2046                                  (WPARAM)-1, 0);
     2047                }
     2048                InvalidateRect (infoPtr->hwndCombo, 0, 0);
     2049                SetFocus(infoPtr->hwndEdit);
     2050                break;
     2051
     2052            default:
     2053                return CallWindowProcA (infoPtr->prevEditWndProc,
     2054                                       hwnd, uMsg, wParam, lParam);
     2055            }
     2056            return 0;
    20282057            }
    2029         }
    2030 
    2031         cbeend.iNewSelection = selected;
    2032         cbeend.fChanged = TRUE;
    2033         cbeend.iWhy = CBENF_RETURN;
    2034         if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) {
    2035             /* abort the change, restore previous */
    2036             TRACE("Notify requested abort of change\n");
    2037             COMBOEX_SetEditText (infoPtr, infoPtr->edit);
    2038             RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE |
    2039                   RDW_INVALIDATE);
    2040             return 0;
    2041         }
    2042         oldItem = SendMessageW (infoPtr->hwndCombo,CB_GETCURSEL, 0, 0);
    2043         if (oldItem != -1) {
    2044             /* if something is selected, then deselect it */
    2045             SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL,
    2046                   (WPARAM)-1, 0);
    2047         }
    2048         InvalidateRect (infoPtr->hwndCombo, 0, 0);
    2049         SetFocus(infoPtr->hwndEdit);
    2050         break;
    2051 
    2052         default:
    2053         return CallWindowProcA (infoPtr->prevEditWndProc,
    2054                        hwnd, uMsg, wParam, lParam);
    2055         }
    2056         return 0;
    2057             }
    20582058
    20592059    case WM_SETFOCUS:
    2060         /* remember the focus to set state of icon */
    2061         lret = CallWindowProcA (infoPtr->prevEditWndProc,
    2062                    hwnd, uMsg, wParam, lParam);
    2063         infoPtr->flags |= WCBE_EDITFOCUSED;
    2064         return lret;
     2060            /* remember the focus to set state of icon */
     2061            lret = CallWindowProcA (infoPtr->prevEditWndProc,
     2062                                   hwnd, uMsg, wParam, lParam);
     2063            infoPtr->flags |= WCBE_EDITFOCUSED;
     2064            return lret;
    20652065
    20662066    case WM_KILLFOCUS:
    2067         /*
    2068          * do NOTIFY CBEN_ENDEDIT with CBENF_KILLFOCUS
    2069          */
    2070         infoPtr->flags &= ~WCBE_EDITFOCUSED;
    2071         if (infoPtr->flags & WCBE_ACTEDIT) {
    2072         infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
    2073 
    2074         GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
    2075         cbeend.fChanged = FALSE;
    2076         cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
    2077                              CB_GETCURSEL, 0, 0);
    2078         cbeend.iWhy = CBENF_KILLFOCUS;
    2079 
    2080         COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text);
    2081         }
    2082         /* fall through */
     2067            /*
     2068             * do NOTIFY CBEN_ENDEDIT with CBENF_KILLFOCUS
     2069             */
     2070            infoPtr->flags &= ~WCBE_EDITFOCUSED;
     2071            if (infoPtr->flags & WCBE_ACTEDIT) {
     2072                infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
     2073
     2074                GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
     2075                cbeend.fChanged = FALSE;
     2076                cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
     2077                                                     CB_GETCURSEL, 0, 0);
     2078                cbeend.iWhy = CBENF_KILLFOCUS;
     2079
     2080                COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text);
     2081            }
     2082            /* fall through */
    20832083
    20842084    default:
    2085         return CallWindowProcA (infoPtr->prevEditWndProc,
    2086                    hwnd, uMsg, wParam, lParam);
     2085            return CallWindowProcA (infoPtr->prevEditWndProc,
     2086                                   hwnd, uMsg, wParam, lParam);
    20872087    }
    20882088    return 0;
     
    21022102    WCHAR edit_text[260];
    21032103
    2104     TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx, info_ptr=%p\n",
    2105       hwnd, uMsg, wParam, lParam, infoPtr);
     2104    TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx, info_ptr=%p\n", 
     2105          hwnd, uMsg, wParam, lParam, infoPtr);
    21062106
    21072107    if (!infoPtr) return 0;
     
    21112111
    21122112    case CB_FINDSTRINGEXACT:
    2113         return COMBOEX_FindStringExact (infoPtr, wParam, lParam);
     2113            return COMBOEX_FindStringExact (infoPtr, wParam, lParam);
    21142114
    21152115    case WM_DRAWITEM:
    2116         /*
    2117          * The only way this message should come is from the
    2118          * child Listbox issuing the message. Flag this so
    2119          * that ComboEx knows this is listbox.
    2120          */
    2121         ((DRAWITEMSTRUCT *)lParam)->itemState |= ODS_COMBOEXLBOX;
    2122         return CallWindowProcA (infoPtr->prevComboWndProc,
    2123                    hwnd, uMsg, wParam, lParam);
     2116            /*
     2117             * The only way this message should come is from the
     2118             * child Listbox issuing the message. Flag this so
     2119             * that ComboEx knows this is listbox.
     2120             */
     2121            ((DRAWITEMSTRUCT *)lParam)->itemState |= ODS_COMBOEXLBOX;
     2122            return CallWindowProcA (infoPtr->prevComboWndProc,
     2123                                   hwnd, uMsg, wParam, lParam);
    21242124
    21252125    case WM_ERASEBKGND:
    2126         /*
    2127          * The following was determined by traces of the native
    2128          */
     2126            /*
     2127             * The following was determined by traces of the native
     2128             */
    21292129            hDC = (HDC) wParam;
    2130         nbkc = GetSysColor (COLOR_WINDOW);
    2131         obkc = SetBkColor (hDC, nbkc);
     2130            nbkc = GetSysColor (COLOR_WINDOW);
     2131            obkc = SetBkColor (hDC, nbkc);
    21322132            GetClientRect (hwnd, &rect);
    2133         TRACE("erasing (%d,%d)-(%d,%d)\n",
    2134           rect.left, rect.top, rect.right, rect.bottom);
    2135         ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0);
     2133            TRACE("erasing (%d,%d)-(%d,%d)\n",
     2134                  rect.left, rect.top, rect.right, rect.bottom);
     2135            ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0);
    21362136            SetBkColor (hDC, obkc);
    2137         return CallWindowProcA (infoPtr->prevComboWndProc,
    2138                    hwnd, uMsg, wParam, lParam);
     2137            return CallWindowProcA (infoPtr->prevComboWndProc,
     2138                                   hwnd, uMsg, wParam, lParam);
    21392139
    21402140    case WM_SETCURSOR:
    2141         /*
    2142          *  WM_NOTIFY to comboex parent (rebar)
    2143          *   with NM_SETCURSOR with extra words of 0,0,0,0,0x02010001
    2144          *  CallWindowProc (previous)
    2145          */
    2146         nmmse.dwItemSpec = 0;
    2147         nmmse.dwItemData = 0;
    2148         nmmse.pt.x = 0;
    2149         nmmse.pt.y = 0;
    2150         nmmse.dwHitInfo = lParam;
    2151         COMBOEX_Notify (infoPtr, NM_SETCURSOR, (NMHDR *)&nmmse);
    2152         return CallWindowProcA (infoPtr->prevComboWndProc,
    2153                    hwnd, uMsg, wParam, lParam);
     2141            /*
     2142             *  WM_NOTIFY to comboex parent (rebar)
     2143             *   with NM_SETCURSOR with extra words of 0,0,0,0,0x02010001
     2144             *  CallWindowProc (previous)
     2145             */
     2146            nmmse.dwItemSpec = 0;
     2147            nmmse.dwItemData = 0;
     2148            nmmse.pt.x = 0;
     2149            nmmse.pt.y = 0;
     2150            nmmse.dwHitInfo = lParam;
     2151            COMBOEX_Notify (infoPtr, NM_SETCURSOR, (NMHDR *)&nmmse);
     2152            return CallWindowProcA (infoPtr->prevComboWndProc,
     2153                                   hwnd, uMsg, wParam, lParam);
    21542154
    21552155    case WM_COMMAND:
    2156         switch (HIWORD(wParam)) {
    2157 
    2158         case EN_UPDATE:
    2159         /* traces show that COMBOEX does not issue CBN_EDITUPDATE
    2160         * on the EN_UPDATE
    2161         */
    2162         return 0;
    2163 
    2164         case EN_KILLFOCUS:
    2165         /*
    2166         * Native does:
    2167         *
    2168         *  GetFocus() retns AA
    2169         *  GetWindowTextA(Edit)
    2170         *  CB_GETCURSEL(Combo) (got -1)
    2171         *  WM_NOTIFY(CBEN_ENDEDITA) with CBENF_KILLFOCUS
    2172         *  CB_GETCURSEL(Combo) (got -1)
    2173         *  InvalidateRect(Combo, 0, 0)
    2174         *  WM_KILLFOCUS(Combo, AA)
    2175         *  return 0;
    2176         */
    2177         focusedhwnd = GetFocus();
    2178         if (infoPtr->flags & WCBE_ACTEDIT) {
    2179             GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
    2180             cbeend.fChanged = (infoPtr->flags & WCBE_EDITCHG);
    2181             cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
    2182                             CB_GETCURSEL, 0, 0);
    2183             cbeend.iWhy = CBENF_KILLFOCUS;
    2184 
    2185             infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
    2186             if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) {
    2187             /* abort the change */
    2188             TRACE("Notify requested abort of change\n");
    2189             return 0;
    2190             }
    2191         }
    2192         /* possible CB_GETCURSEL */
    2193         InvalidateRect (infoPtr->hwndCombo, 0, 0);
    2194         if (focusedhwnd)
    2195             SendMessageW (infoPtr->hwndCombo, WM_KILLFOCUS,
    2196                   (WPARAM)focusedhwnd, 0);
    2197         return 0;
    2198 
    2199         case EN_SETFOCUS: {
    2200         /*
    2201         * For EN_SETFOCUS this issues the same calls and messages
    2202         *  as the native seems to do.
    2203         *
    2204         * for some cases however native does the following:
    2205         *   (noticed after SetFocus during LBUTTONDOWN on
    2206         *    on dropdown arrow)
    2207         *  WM_GETTEXTLENGTH (Edit);
    2208         *  WM_GETTEXT (Edit, len+1, str);
    2209         *  EM_SETSEL (Edit, 0, 0);
    2210         *  WM_GETTEXTLENGTH (Edit);
    2211         *  WM_GETTEXT (Edit, len+1, str);
    2212         *  EM_SETSEL (Edit, 0, len);
    2213         *  WM_NOTIFY (parent, CBEN_BEGINEDIT)
    2214         */
    2215         NMHDR hdr;
    2216 
    2217         SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, 0);
    2218         SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, -1);
    2219         COMBOEX_Notify (infoPtr, CBEN_BEGINEDIT, &hdr);
    2220         infoPtr->flags |= WCBE_ACTEDIT;
    2221         infoPtr->flags &= ~WCBE_EDITCHG; /* no change yet */
    2222         return 0;
    2223             }
    2224 
    2225         case EN_CHANGE: {
    2226         /*
    2227         * For EN_CHANGE this issues the same calls and messages
    2228         *  as the native seems to do.
    2229         */
    2230         WCHAR edit_text[260];
    2231         WCHAR *lastwrk;
    2232         INT selected, cnt;
    2233         CBE_ITEMDATA *item;
    2234 
    2235         selected = SendMessageW (infoPtr->hwndCombo,
    2236                     CB_GETCURSEL, 0, 0);
    2237 
    2238         /* lstrlenA( lastworkingURL ) */
    2239 
    2240         GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
    2241         if (selected == -1) {
    2242             lastwrk = infoPtr->edit->pszText;
    2243             cnt = lstrlenW (lastwrk);
    2244             if (cnt >= 259) cnt = 259;
    2245         }
    2246         else {
    2247             item = COMBOEX_FindItem (infoPtr, selected);
    2248             cnt = lstrlenW (item->pszText);
    2249             lastwrk = item->pszText;
    2250             if (cnt >= 259) cnt = 259;
    2251         }
    2252 
    2253         TRACE("handling EN_CHANGE, selected = %d, selected_text=%s\n",
    2254             selected, debugstr_w(lastwrk));
    2255         TRACE("handling EN_CHANGE, edittext=%s\n",
    2256               debugstr_w(edit_text));
    2257 
    2258         /* lstrcmpiW is between lastworkingURL and GetWindowText */
    2259 
    2260         if (lstrcmpiW (lastwrk, edit_text)) {
    2261             /* strings not equal -- indicate edit has changed */
    2262             infoPtr->flags |= WCBE_EDITCHG;
    2263         }
    2264         SendMessageW ( GetParent(infoPtr->hwndSelf), WM_COMMAND,
    2265                    MAKEWPARAM(GetDlgCtrlID (infoPtr->hwndSelf),
    2266                       CBN_EDITCHANGE),
    2267                    infoPtr->hwndSelf);
    2268         return 0;
    2269             }
    2270 
    2271         case LBN_SELCHANGE:
    2272         /*
    2273         * Therefore from traces there is no additional code here
    2274         */
    2275 
    2276         /*
    2277         * Using native COMCTL32 gets the following:
    2278         *  1 == SHDOCVW.DLL  issues call/message
    2279         *  2 == COMCTL32.DLL  issues call/message
    2280         *  3 == WINE  issues call/message
    2281         *
    2282         *
    2283         * for LBN_SELCHANGE:
    2284         *    1  CB_GETCURSEL(ComboEx)
    2285         *    1  CB_GETDROPPEDSTATE(ComboEx)
    2286         *    1  CallWindowProc( *2* for WM_COMMAND(LBN_SELCHANGE)
    2287         *    2  CallWindowProc( *3* for WM_COMMAND(LBN_SELCHANGE)
    2288         **   call CBRollUp( xxx, TRUE for LBN_SELCHANGE, TRUE)
    2289         *    3  WM_COMMAND(ComboEx, CBN_SELENDOK)
    2290         *      WM_USER+49(ComboLB, 1,0)  <=============!!!!!!!!!!!
    2291         *    3  ShowWindow(ComboLB, SW_HIDE)
    2292         *    3  RedrawWindow(Combo,  RDW_UPDATENOW)
    2293         *    3  WM_COMMAND(ComboEX, CBN_CLOSEUP)
    2294         **   end of CBRollUp
    2295         *    3  WM_COMMAND(ComboEx, CBN_SELCHANGE)  (echo to parent)
    2296         *    ?  LB_GETCURSEL              <==|
    2297         *    ?  LB_GETTEXTLEN                |
    2298         *    ?  LB_GETTEXT                   | Needs to be added to
    2299         *    ?  WM_CTLCOLOREDIT(ComboEx)     | Combo processing
    2300         *    ?  LB_GETITEMDATA               |
    2301         *    ?  WM_DRAWITEM(ComboEx)      <==|
    2302         */
    2303         default:
    2304         break;
    2305         }/* fall through */
     2156            switch (HIWORD(wParam)) {
     2157
     2158            case EN_UPDATE:
     2159                /* traces show that COMBOEX does not issue CBN_EDITUPDATE
     2160                * on the EN_UPDATE
     2161                */
     2162                return 0;
     2163
     2164            case EN_KILLFOCUS:
     2165                /*
     2166                * Native does:
     2167                *
     2168                *  GetFocus() retns AA
     2169                *  GetWindowTextA(Edit)
     2170                *  CB_GETCURSEL(Combo) (got -1)
     2171                *  WM_NOTIFY(CBEN_ENDEDITA) with CBENF_KILLFOCUS
     2172                *  CB_GETCURSEL(Combo) (got -1)
     2173                *  InvalidateRect(Combo, 0, 0)
     2174                *  WM_KILLFOCUS(Combo, AA)
     2175                *  return 0;
     2176                */
     2177                focusedhwnd = GetFocus();
     2178                if (infoPtr->flags & WCBE_ACTEDIT) {
     2179                    GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
     2180                    cbeend.fChanged = (infoPtr->flags & WCBE_EDITCHG);
     2181                    cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
     2182                                                        CB_GETCURSEL, 0, 0);
     2183                    cbeend.iWhy = CBENF_KILLFOCUS;
     2184
     2185                    infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
     2186                    if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) {
     2187                        /* abort the change */
     2188                        TRACE("Notify requested abort of change\n");
     2189                        return 0;
     2190                    }
     2191                }
     2192                /* possible CB_GETCURSEL */
     2193                InvalidateRect (infoPtr->hwndCombo, 0, 0);
     2194                if (focusedhwnd)
     2195                    SendMessageW (infoPtr->hwndCombo, WM_KILLFOCUS,
     2196                                  (WPARAM)focusedhwnd, 0);
     2197                return 0;
     2198
     2199            case EN_SETFOCUS: {
     2200                /*
     2201                * For EN_SETFOCUS this issues the same calls and messages
     2202                *  as the native seems to do.
     2203                *
     2204                * for some cases however native does the following:
     2205                *   (noticed after SetFocus during LBUTTONDOWN on
     2206                *    on dropdown arrow)
     2207                *  WM_GETTEXTLENGTH (Edit);
     2208                *  WM_GETTEXT (Edit, len+1, str);
     2209                *  EM_SETSEL (Edit, 0, 0);
     2210                *  WM_GETTEXTLENGTH (Edit);
     2211                *  WM_GETTEXT (Edit, len+1, str);
     2212                *  EM_SETSEL (Edit, 0, len);
     2213                *  WM_NOTIFY (parent, CBEN_BEGINEDIT)
     2214                */
     2215                NMHDR hdr;
     2216
     2217                SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, 0);
     2218                SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, -1);
     2219                COMBOEX_Notify (infoPtr, CBEN_BEGINEDIT, &hdr);
     2220                infoPtr->flags |= WCBE_ACTEDIT;
     2221                infoPtr->flags &= ~WCBE_EDITCHG; /* no change yet */
     2222                return 0;
     2223                }
     2224
     2225            case EN_CHANGE: {
     2226                /*
     2227                * For EN_CHANGE this issues the same calls and messages
     2228                *  as the native seems to do.
     2229                */
     2230                WCHAR edit_text[260];
     2231                WCHAR *lastwrk;
     2232                INT selected, cnt;
     2233                CBE_ITEMDATA *item;
     2234
     2235                selected = SendMessageW (infoPtr->hwndCombo,
     2236                                        CB_GETCURSEL, 0, 0);
     2237
     2238                /* lstrlenA( lastworkingURL ) */
     2239
     2240                GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
     2241                if (selected == -1) {
     2242                    lastwrk = infoPtr->edit->pszText;
     2243                    cnt = lstrlenW (lastwrk);
     2244                    if (cnt >= 259) cnt = 259;
     2245                }
     2246                else {
     2247                    item = COMBOEX_FindItem (infoPtr, selected);
     2248                    cnt = lstrlenW (item->pszText);
     2249                    lastwrk = item->pszText;
     2250                    if (cnt >= 259) cnt = 259;
     2251                }
     2252
     2253                TRACE("handling EN_CHANGE, selected = %d, selected_text=%s\n",
     2254                    selected, debugstr_w(lastwrk));
     2255                TRACE("handling EN_CHANGE, edittext=%s\n",
     2256                      debugstr_w(edit_text));
     2257
     2258                /* lstrcmpiW is between lastworkingURL and GetWindowText */
     2259
     2260                if (lstrcmpiW (lastwrk, edit_text)) {
     2261                    /* strings not equal -- indicate edit has changed */
     2262                    infoPtr->flags |= WCBE_EDITCHG;
     2263                }
     2264                SendMessageW ( GetParent(infoPtr->hwndSelf), WM_COMMAND,
     2265                               MAKEWPARAM(GetDlgCtrlID (infoPtr->hwndSelf),
     2266                                          CBN_EDITCHANGE),
     2267                               infoPtr->hwndSelf);
     2268                return 0;
     2269                }
     2270
     2271            case LBN_SELCHANGE:
     2272                /*
     2273                * Therefore from traces there is no additional code here
     2274                */
     2275
     2276                /*
     2277                * Using native COMCTL32 gets the following:
     2278                *  1 == SHDOCVW.DLL  issues call/message
     2279                *  2 == COMCTL32.DLL  issues call/message
     2280                *  3 == WINE  issues call/message
     2281                *
     2282                *
     2283                * for LBN_SELCHANGE:
     2284                *    1  CB_GETCURSEL(ComboEx)
     2285                *    1  CB_GETDROPPEDSTATE(ComboEx)
     2286                *    1  CallWindowProc( *2* for WM_COMMAND(LBN_SELCHANGE)
     2287                *    2  CallWindowProc( *3* for WM_COMMAND(LBN_SELCHANGE)
     2288                **   call CBRollUp( xxx, TRUE for LBN_SELCHANGE, TRUE)
     2289                *    3  WM_COMMAND(ComboEx, CBN_SELENDOK)
     2290                *      WM_USER+49(ComboLB, 1,0)  <=============!!!!!!!!!!!
     2291                *    3  ShowWindow(ComboLB, SW_HIDE)
     2292                *    3  RedrawWindow(Combo,  RDW_UPDATENOW)
     2293                *    3  WM_COMMAND(ComboEX, CBN_CLOSEUP)
     2294                **   end of CBRollUp
     2295                *    3  WM_COMMAND(ComboEx, CBN_SELCHANGE)  (echo to parent)
     2296                *    ?  LB_GETCURSEL              <==|
     2297                *    ?  LB_GETTEXTLEN                |
     2298                *    ?  LB_GETTEXT                   | Needs to be added to
     2299                *    ?  WM_CTLCOLOREDIT(ComboEx)     | Combo processing
     2300                *    ?  LB_GETITEMDATA               |
     2301                *    ?  WM_DRAWITEM(ComboEx)      <==|
     2302                */
     2303            default:
     2304                break;
     2305            }/* fall through */
    23062306    default:
    2307         return CallWindowProcA (infoPtr->prevComboWndProc,
    2308                    hwnd, uMsg, wParam, lParam);
     2307            return CallWindowProcA (infoPtr->prevComboWndProc,
     2308                                   hwnd, uMsg, wParam, lParam);
    23092309    }
    23102310    return 0;
     
    23202320
    23212321    if (!COMBOEX_GetInfoPtr (hwnd)) {
    2322     if (uMsg == WM_CREATE)
    2323         return COMBOEX_Create (hwnd, wParam, lParam);
    2324     if (uMsg == WM_NCCREATE)
    2325         COMBOEX_NCCreate (hwnd, wParam, lParam);
     2322        if (uMsg == WM_CREATE)
     2323            return COMBOEX_Create (hwnd, wParam, lParam);
     2324        if (uMsg == WM_NCCREATE)
     2325            COMBOEX_NCCreate (hwnd, wParam, lParam);
    23262326        return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    23272327    }
     
    23302330    {
    23312331        case CBEM_DELETEITEM:  /* maps to CB_DELETESTRING */
    2332         return COMBOEX_DeleteItem (hwnd, wParam, lParam);
    2333 
    2334     case CBEM_GETCOMBOCONTROL:
    2335         return COMBOEX_GetComboControl (hwnd, wParam, lParam);
    2336 
    2337     case CBEM_GETEDITCONTROL:
    2338         return COMBOEX_GetEditControl (hwnd, wParam, lParam);
    2339 
    2340     case CBEM_GETEXTENDEDSTYLE:
    2341         return COMBOEX_GetExtendedStyle (hwnd, wParam, lParam);
    2342 
    2343     case CBEM_GETIMAGELIST:
    2344         return COMBOEX_GetImageList (hwnd, wParam, lParam);
    2345 
    2346     case CBEM_GETITEMA:
    2347         return COMBOEX_GetItemA (hwnd, wParam, lParam);
    2348 
    2349     case CBEM_GETITEMW:
    2350         return COMBOEX_GetItemW (hwnd, wParam, lParam);
    2351 
    2352     case CBEM_GETUNICODEFORMAT:
    2353         return COMBOEX_GetUnicodeFormat (hwnd, wParam, lParam);
    2354 
    2355     case CBEM_HASEDITCHANGED:
    2356         return COMBOEX_HasEditChanged (hwnd, wParam, lParam);
    2357 
    2358     case CBEM_INSERTITEMA:
    2359         return COMBOEX_InsertItemA (hwnd, wParam, lParam);
    2360 
    2361     case CBEM_INSERTITEMW:
    2362         return COMBOEX_InsertItemW (hwnd, wParam, lParam);
    2363 
    2364     case CBEM_SETEXSTYLE:   /* FIXME: obsoleted, should be the same as: */
    2365     case CBEM_SETEXTENDEDSTYLE:
    2366         return COMBOEX_SetExtendedStyle (hwnd, wParam, lParam);
    2367 
    2368     case CBEM_SETIMAGELIST:
    2369         return COMBOEX_SetImageList (hwnd, wParam, lParam);
    2370 
    2371     case CBEM_SETITEMA:
    2372         return COMBOEX_SetItemA (hwnd, wParam, lParam);
    2373 
    2374     case CBEM_SETITEMW:
    2375         return COMBOEX_SetItemW (hwnd, wParam, lParam);
    2376 
    2377     case CBEM_SETUNICODEFORMAT:
    2378         return COMBOEX_SetUnicodeFormat (hwnd, wParam, lParam);
     2332            return COMBOEX_DeleteItem (hwnd, wParam, lParam);
     2333
     2334        case CBEM_GETCOMBOCONTROL:
     2335            return COMBOEX_GetComboControl (hwnd, wParam, lParam);
     2336
     2337        case CBEM_GETEDITCONTROL:
     2338            return COMBOEX_GetEditControl (hwnd, wParam, lParam);
     2339
     2340        case CBEM_GETEXTENDEDSTYLE:
     2341            return COMBOEX_GetExtendedStyle (hwnd, wParam, lParam);
     2342
     2343        case CBEM_GETIMAGELIST:
     2344            return COMBOEX_GetImageList (hwnd, wParam, lParam);
     2345
     2346        case CBEM_GETITEMA:
     2347            return COMBOEX_GetItemA (hwnd, wParam, lParam);
     2348
     2349        case CBEM_GETITEMW:
     2350            return COMBOEX_GetItemW (hwnd, wParam, lParam);
     2351
     2352        case CBEM_GETUNICODEFORMAT:
     2353            return COMBOEX_GetUnicodeFormat (hwnd, wParam, lParam);
     2354
     2355        case CBEM_HASEDITCHANGED:
     2356            return COMBOEX_HasEditChanged (hwnd, wParam, lParam);
     2357
     2358        case CBEM_INSERTITEMA:
     2359            return COMBOEX_InsertItemA (hwnd, wParam, lParam);
     2360
     2361        case CBEM_INSERTITEMW:
     2362            return COMBOEX_InsertItemW (hwnd, wParam, lParam);
     2363
     2364        case CBEM_SETEXSTYLE:   /* FIXME: obsoleted, should be the same as: */
     2365        case CBEM_SETEXTENDEDSTYLE:
     2366            return COMBOEX_SetExtendedStyle (hwnd, wParam, lParam);
     2367
     2368        case CBEM_SETIMAGELIST:
     2369            return COMBOEX_SetImageList (hwnd, wParam, lParam);
     2370
     2371        case CBEM_SETITEMA:
     2372            return COMBOEX_SetItemA (hwnd, wParam, lParam);
     2373
     2374        case CBEM_SETITEMW:
     2375            return COMBOEX_SetItemW (hwnd, wParam, lParam);
     2376
     2377        case CBEM_SETUNICODEFORMAT:
     2378            return COMBOEX_SetUnicodeFormat (hwnd, wParam, lParam);
    23792379
    23802380
    23812381/*   Combo messages we are not sure if we need to process or just forward */
    2382     case CB_GETDROPPEDCONTROLRECT:
    2383     case CB_GETITEMHEIGHT:
    2384     case CB_GETLBTEXT:
    2385     case CB_GETLBTEXTLEN:
    2386     case CB_GETEXTENDEDUI:
    2387     case CB_LIMITTEXT:
    2388     case CB_RESETCONTENT:
    2389     case CB_SELECTSTRING:
    2390     case WM_SETTEXT:
    2391     case WM_GETTEXT:
    2392         FIXME("(0x%x 0x%x 0x%lx): possibly missing function\n",
    2393           uMsg, wParam, lParam);
    2394         return COMBOEX_Forward (hwnd, uMsg, wParam, lParam);
     2382        case CB_GETDROPPEDCONTROLRECT:
     2383        case CB_GETITEMHEIGHT:
     2384        case CB_GETLBTEXT:
     2385        case CB_GETLBTEXTLEN:
     2386        case CB_GETEXTENDEDUI:
     2387        case CB_LIMITTEXT:
     2388        case CB_RESETCONTENT:
     2389        case CB_SELECTSTRING:
     2390        case WM_SETTEXT:
     2391        case WM_GETTEXT:
     2392            FIXME("(0x%x 0x%x 0x%lx): possibly missing function\n",
     2393                  uMsg, wParam, lParam);
     2394            return COMBOEX_Forward (hwnd, uMsg, wParam, lParam);
    23952395
    23962396/*   Combo messages OK to just forward to the regular COMBO */
    2397     case CB_GETCOUNT:
    2398     case CB_GETCURSEL:
    2399     case CB_GETDROPPEDSTATE:
     2397        case CB_GETCOUNT:       
     2398        case CB_GETCURSEL:
     2399        case CB_GETDROPPEDSTATE:
    24002400        case CB_SETDROPPEDWIDTH:
    24012401        case CB_SETEXTENDEDUI:
    24022402        case CB_SHOWDROPDOWN:
    2403         return COMBOEX_Forward (hwnd, uMsg, wParam, lParam);
     2403            return COMBOEX_Forward (hwnd, uMsg, wParam, lParam);
    24042404
    24052405/*   Combo messages we need to process specially */
    24062406        case CB_FINDSTRINGEXACT:
    2407         return COMBOEX_FindStringExact (COMBOEX_GetInfoPtr (hwnd),
    2408                         wParam, lParam);
    2409 
    2410     case CB_GETITEMDATA:
    2411         return COMBOEX_GetItemData (hwnd, wParam, lParam);
    2412 
    2413     case CB_SETCURSEL:
    2414         return COMBOEX_SetCursel (hwnd, wParam, lParam);
    2415 
    2416     case CB_SETITEMDATA:
    2417         return COMBOEX_SetItemData (hwnd, wParam, lParam);
    2418 
    2419     case CB_SETITEMHEIGHT:
    2420         return COMBOEX_SetItemHeight (hwnd, wParam, lParam);
     2407            return COMBOEX_FindStringExact (COMBOEX_GetInfoPtr (hwnd),
     2408                                            wParam, lParam);
     2409
     2410        case CB_GETITEMDATA:
     2411            return COMBOEX_GetItemData (hwnd, wParam, lParam);
     2412
     2413        case CB_SETCURSEL:
     2414            return COMBOEX_SetCursel (hwnd, wParam, lParam);
     2415
     2416        case CB_SETITEMDATA:
     2417            return COMBOEX_SetItemData (hwnd, wParam, lParam);
     2418
     2419        case CB_SETITEMHEIGHT:
     2420            return COMBOEX_SetItemHeight (hwnd, wParam, lParam);
    24212421
    24222422
    24232423
    24242424/*   Window messages passed to parent */
    2425     case WM_COMMAND:
    2426         return COMBOEX_Command (hwnd, wParam, lParam);
    2427 
    2428     case WM_NOTIFY:
    2429         if (infoPtr->NtfUnicode)
    2430         return SendMessageW (GetParent (hwnd),
    2431                      uMsg, wParam, lParam);
    2432         else
    2433         return SendMessageA (GetParent (hwnd),
    2434                      uMsg, wParam, lParam);
     2425        case WM_COMMAND:
     2426            return COMBOEX_Command (hwnd, wParam, lParam);
     2427
     2428        case WM_NOTIFY:
     2429            if (infoPtr->NtfUnicode)
     2430                return SendMessageW (GetParent (hwnd),
     2431                                     uMsg, wParam, lParam);
     2432            else
     2433                return SendMessageA (GetParent (hwnd),
     2434                                     uMsg, wParam, lParam);
    24352435
    24362436
    24372437/*   Window messages we need to process */
    24382438        case WM_DELETEITEM:
    2439         return COMBOEX_WM_DeleteItem (hwnd, wParam, lParam);
     2439            return COMBOEX_WM_DeleteItem (hwnd, wParam, lParam);
    24402440
    24412441        case WM_DRAWITEM:
    24422442            return COMBOEX_DrawItem (hwnd, wParam, lParam);
    24432443
    2444     case WM_DESTROY:
    2445         return COMBOEX_Destroy (hwnd, wParam, lParam);
     2444        case WM_DESTROY:
     2445            return COMBOEX_Destroy (hwnd, wParam, lParam);
    24462446
    24472447        case WM_MEASUREITEM:
     
    24492449
    24502450        case WM_NOTIFYFORMAT:
    2451         return COMBOEX_NotifyFormat (hwnd, wParam, lParam);
    2452 
    2453     case WM_SIZE:
    2454         return COMBOEX_Size (hwnd, wParam, lParam);
     2451            return COMBOEX_NotifyFormat (hwnd, wParam, lParam);
     2452
     2453        case WM_SIZE:
     2454            return COMBOEX_Size (hwnd, wParam, lParam);
    24552455
    24562456        case WM_WINDOWPOSCHANGING:
    2457         return COMBOEX_WindowPosChanging (hwnd, wParam, lParam);
    2458 
    2459     default:
    2460         if (uMsg >= WM_USER)
    2461         ERR("unknown msg %04x wp=%08x lp=%08lx\n",
    2462              uMsg, wParam, lParam);
     2457            return COMBOEX_WindowPosChanging (hwnd, wParam, lParam);
     2458
     2459        default:
     2460            if (uMsg >= WM_USER)
     2461                ERR("unknown msg %04x wp=%08x lp=%08lx\n",
     2462                     uMsg, wParam, lParam);
    24632463#ifdef __WIN32OS2__
    24642464            return defComCtl32ProcA (hwnd, uMsg, wParam, lParam);
    24652465#else
    2466         return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     2466            return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    24672467#endif
    24682468    }
     
    24842484    wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
    24852485    wndClass.lpszClassName = WC_COMBOBOXEXA;
    2486 
     2486 
    24872487    RegisterClassA (&wndClass);
    24882488
  • trunk/src/comctl32/comctl32.c

    r6705 r6709  
    1 /*
     1/*             
    22 * Common controls functions
    33 *
     
    9999
    100100    switch (fdwReason) {
    101     case DLL_PROCESS_ATTACH:
     101        case DLL_PROCESS_ATTACH:
    102102            COMCTL32_hModule = (HMODULE)hinstDLL;
    103103
     
    130130            break;
    131131
    132     case DLL_PROCESS_DETACH:
     132        case DLL_PROCESS_DETACH:
    133133            /* unregister all common control classes */
    134134            ANIMATE_Unregister ();
     
    204204VOID WINAPI
    205205MenuHelp (UINT uMsg, WPARAM wParam, LPARAM lParam, HMENU hMainMenu,
    206       HINSTANCE hInst, HWND hwndStatus, LPUINT lpwIDs)
     206          HINSTANCE hInst, HWND hwndStatus, LPUINT lpwIDs)
    207207{
    208208    UINT uMenuID = 0;
    209209
    210210    if (!IsWindow (hwndStatus))
    211     return;
     211        return;
    212212
    213213    switch (uMsg) {
    214     case WM_MENUSELECT:
    215         TRACE("WM_MENUSELECT wParam=0x%X lParam=0x%lX\n",
    216            wParam, lParam);
     214        case WM_MENUSELECT:
     215            TRACE("WM_MENUSELECT wParam=0x%X lParam=0x%lX\n",
     216                   wParam, lParam);
    217217
    218218            if ((HIWORD(wParam) == 0xFFFF) && (lParam == 0)) {
    219219                /* menu was closed */
    220         TRACE("menu was closed!\n");
     220                TRACE("menu was closed!\n");
    221221                SendMessageA (hwndStatus, SB_SIMPLE, FALSE, 0);
    222222            }
    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;
     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;
    243243
    244244        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
     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
    249249             * any FIXME for WM_COMMAND
    250250             */
    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     }
    258 }
    259 
    260 
    261 /***********************************************************************
    262  * ShowHideMenuCtl [COMCTL32.3]
     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    }
     258}
     259
     260
     261/***********************************************************************
     262 * ShowHideMenuCtl [COMCTL32.3] 
    263263 *
    264264 * Shows or hides controls and updates the corresponding menu item.
     
    297297
    298298    if (lpInfo == NULL)
    299     return FALSE;
     299        return FALSE;
    300300
    301301    if (!(lpInfo[0]) || !(lpInfo[1]))
    302     return FALSE;
     302        return FALSE;
    303303
    304304    /* search for control */
    305305    lpMenuId = &lpInfo[2];
    306306    while (*lpMenuId != uFlags)
    307     lpMenuId += 2;
     307        lpMenuId += 2;
    308308
    309309    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);
     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);
    317317    }
    318318    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);
     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);
    326326    }
    327327
     
    357357
    358358    TRACE("(0x%08lx 0x%08lx 0x%08lx)\n",
    359        (DWORD)hwnd, (DWORD)lpRect, (DWORD)lpInfo);
     359           (DWORD)hwnd, (DWORD)lpRect, (DWORD)lpInfo);
    360360
    361361    GetClientRect (hwnd, lpRect);
     
    363363
    364364    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++;
     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++;
    377377    } while (*lpRun);
    378378}
     
    416416      r.left += 3;
    417417      DrawTextA (hdc, text, lstrlenA(text),
    418            &r, DT_LEFT|DT_VCENTER|DT_SINGLELINE);
     418                   &r, DT_LEFT|DT_VCENTER|DT_SINGLELINE); 
    419419      if (oldbkmode != TRANSPARENT)
    420     SetBkMode(hdc, oldbkmode);
     420        SetBkMode(hdc, oldbkmode);
    421421    }
    422422}
     
    466466CreateStatusWindowA (INT style, LPCSTR text, HWND parent, UINT wid)
    467467{
    468     return CreateWindowA(STATUSCLASSNAMEA, text, style,
    469                CW_USEDEFAULT, CW_USEDEFAULT,
    470                CW_USEDEFAULT, CW_USEDEFAULT,
    471                parent, wid, 0, 0);
     468    return CreateWindowA(STATUSCLASSNAMEA, text, style, 
     469                           CW_USEDEFAULT, CW_USEDEFAULT,
     470                           CW_USEDEFAULT, CW_USEDEFAULT,
     471                           parent, wid, 0, 0);
    472472}
    473473
     
    491491{
    492492    return CreateWindowW(STATUSCLASSNAMEW, text, style,
    493                CW_USEDEFAULT, CW_USEDEFAULT,
    494                CW_USEDEFAULT, CW_USEDEFAULT,
    495                parent, wid, 0, 0);
     493                           CW_USEDEFAULT, CW_USEDEFAULT,
     494                           CW_USEDEFAULT, CW_USEDEFAULT,
     495                           parent, wid, 0, 0);
    496496}
    497497
     
    521521HWND WINAPI
    522522CreateUpDownControl (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)
     523                     HWND parent, INT id, HINSTANCE inst,
     524                     HWND buddy, INT maxVal, INT minVal, INT curVal)
    525525{
    526526    HWND hUD =
    527     CreateWindowA (UPDOWN_CLASSA, 0, style, x, y, cx, cy,
    528             parent, id, inst, 0);
     527        CreateWindowA (UPDOWN_CLASSA, 0, style, x, y, cx, cy,
     528                        parent, id, inst, 0);
    529529    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));
     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));     
    533533    }
    534534
     
    584584
    585585    if (!lpInitCtrls)
    586     return FALSE;
     586        return FALSE;
    587587    if (lpInitCtrls->dwSize != sizeof(INITCOMMONCONTROLSEX))
    588     return FALSE;
     588        return FALSE;
    589589
    590590    TRACE("(0x%08lx)\n", lpInitCtrls->dwICC);
    591591
    592592    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     }
     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        }
    639639    }
    640640
     
    681681    hwndTB =
    682682        CreateWindowExA (0, TOOLBARCLASSNAMEA, "", style|WS_CHILD, 0, 0, 0, 0,
    683                hwnd, (HMENU)wID, 0, NULL);
     683                           hwnd, (HMENU)wID, 0, NULL);
    684684    if(hwndTB) {
    685     TBADDBITMAP tbab;
     685        TBADDBITMAP tbab;
    686686
    687687        SendMessageA (hwndTB, TB_BUTTONSTRUCTSIZE,
    688             (WPARAM)uStructSize, 0);
     688                        (WPARAM)uStructSize, 0);
    689689
    690690       /* set bitmap and button size */
     
    705705
    706706
    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);
     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);
    720720    }
    721721
     
    741741HBITMAP WINAPI
    742742CreateMappedBitmap (HINSTANCE hInstance, INT idBitmap, UINT wFlags,
    743             LPCOLORMAP lpColorMap, INT iNumMaps)
     743                    LPCOLORMAP lpColorMap, INT iNumMaps)
    744744{
    745745    HGLOBAL hglb;
     
    754754    COLORREF cRef;
    755755    COLORMAP internalColorMap[4] =
    756     {{0x000000, 0}, {0x808080, 0}, {0xC0C0C0, 0}, {0xFFFFFF, 0}};
     756        {{0x000000, 0}, {0x808080, 0}, {0xC0C0C0, 0}, {0xFFFFFF, 0}};
    757757
    758758    /* initialize pointer to colortable and default color table */
    759759    if (lpColorMap) {
    760     iMaps = iNumMaps;
    761     sysColorMap = lpColorMap;
     760        iMaps = iNumMaps;
     761        sysColorMap = lpColorMap;
    762762    }
    763763    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;
     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;
    770770    }
    771771
    772772    hRsrc = FindResourceA (hInstance, (LPSTR)idBitmap, RT_BITMAPA);
    773773    if (hRsrc == 0)
    774     return 0;
     774        return 0;
    775775    hglb = LoadResource (hInstance, hRsrc);
    776776    if (hglb == 0)
    777     return 0;
     777        return 0;
    778778    lpBitmap = (LPBITMAPINFOHEADER)LockResource (hglb);
    779779    if (lpBitmap == NULL)
    780     return 0;
     780        return 0;
    781781
    782782    nColorTableSize = (1 << lpBitmap->biBitCount);
     
    784784    lpBitmapInfo = (LPBITMAPINFOHEADER)GlobalAlloc (GMEM_FIXED, nSize);
    785785    if (lpBitmapInfo == NULL)
    786     return 0;
     786        return 0;
    787787    RtlMoveMemory (lpBitmapInfo, lpBitmap, nSize);
    788788
     
    790790
    791791    for (iColor = 0; iColor < nColorTableSize; iColor++) {
    792     for (i = 0; i < iMaps; i++) {
     792        for (i = 0; i < iMaps; i++) {
    793793            cRef = RGB(pColorTable[iColor].rgbRed,
    794794                       pColorTable[iColor].rgbGreen,
    795795                       pColorTable[iColor].rgbBlue);
    796         if ( cRef  == sysColorMap[i].from) {
     796            if ( cRef  == sysColorMap[i].from) {
    797797#if 0
    798         if (wFlags & CBS_MASKED) {
    799             if (sysColorMap[i].to != COLOR_BTNTEXT)
    800             pColorTable[iColor] = RGB(255, 255, 255);
    801         }
    802         else
     798                if (wFlags & CBS_MASKED) {
     799                    if (sysColorMap[i].to != COLOR_BTNTEXT)
     800                        pColorTable[iColor] = RGB(255, 255, 255);
     801                }
     802                else
    803803#endif
    804804                    pColorTable[iColor].rgbBlue  = GetBValue(sysColorMap[i].to);
    805805                    pColorTable[iColor].rgbGreen = GetGValue(sysColorMap[i].to);
    806806                    pColorTable[iColor].rgbRed   = GetRValue(sysColorMap[i].to);
    807         break;
    808         }
    809     }
     807                break;
     808            }
     809        }
    810810    }
    811811    nWidth  = (INT)lpBitmapInfo->biWidth;
     
    814814    hbm = CreateCompatibleBitmap (hdcScreen, nWidth, nHeight);
    815815    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);
     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);
    825825    }
    826826    ReleaseDC ((HWND)0, hdcScreen);
     
    855855HWND WINAPI
    856856CreateToolbar (HWND hwnd, DWORD style, UINT wID, INT nBitmaps,
    857            HINSTANCE hBMInst, UINT wBMID,
    858            LPCOLDTBBUTTON lpButtons,INT iNumButtons)
     857               HINSTANCE hBMInst, UINT wBMID,
     858               LPCOLDTBBUTTON lpButtons,INT iNumButtons)
    859859{
    860860    return CreateToolbarEx (hwnd, style | CCS_NODIVIDER, wID, nBitmaps,
    861                 hBMInst, wBMID, (LPCTBBUTTON)lpButtons,
    862                 iNumButtons, 0, 0, 0, 0, sizeof (OLDTBBUTTON));
     861                            hBMInst, wBMID, (LPCTBBUTTON)lpButtons,
     862                            iNumButtons, 0, 0, 0, 0, sizeof (OLDTBBUTTON));
    863863}
    864864
     
    885885    if (pdvi->cbSize != sizeof(DLLVERSIONINFO)) {
    886886        WARN("wrong DLLVERSIONINFO size from app");
    887     return E_INVALIDARG;
     887        return E_INVALIDARG;
    888888    }
    889889
     
    894894
    895895    TRACE("%lu.%lu.%lu.%lu\n",
    896        pdvi->dwMajorVersion, pdvi->dwMinorVersion,
    897        pdvi->dwBuildNumber, pdvi->dwPlatformID);
     896           pdvi->dwMajorVersion, pdvi->dwMinorVersion,
     897           pdvi->dwBuildNumber, pdvi->dwPlatformID);
    898898
    899899    return S_OK;
     
    901901
    902902/***********************************************************************
    903  *      DllInstall (COMCTL32.@)
     903 *              DllInstall (COMCTL32.@)
    904904 */
    905905HRESULT WINAPI COMCTL32_DllInstall(BOOL bInstall, LPCWSTR cmdline)
    906906{
    907   FIXME("(%s, %s): stub\n", bInstall?"TRUE":"FALSE",
    908     debugstr_w(cmdline));
     907  FIXME("(%s, %s): stub\n", bInstall?"TRUE":"FALSE", 
     908        debugstr_w(cmdline));
    909909
    910910  return S_OK;
     
    916916    POINT pos; /* center of hover rectangle */
    917917    INT iHoverTime; /* elapsed time the cursor has been inside of the hover rect */
    918 } _TRACKINGLIST;
     918} _TRACKINGLIST; 
    919919
    920920static _TRACKINGLIST TrackingList[10];
     
    955955        if(TrackingList[i].tme.dwFlags & TME_HOVER) {
    956956            /* add the timer interval to the hovering time */
    957             TrackingList[i].iHoverTime+=iTimerInterval;
    958 
     957            TrackingList[i].iHoverTime+=iTimerInterval; 
     958     
    959959            /* has the cursor moved outside the rectangle centered around pos? */
    960960            if((abs(pos.x - TrackingList[i].pos.x) > (hoverwidth / 2.0))
     
    985985        }
    986986    }
    987 
     987       
    988988    /* stop the timer if the tracking list is empty */
    989989    if(iTrackMax == 0) {
     
    10361036
    10371037    flags = ptme->dwFlags;
    1038 
     1038   
    10391039    /* if HOVER_DEFAULT was specified replace this with the systems current value */
    10401040    if(ptme->dwHoverTime == HOVER_DEFAULT)
     
    10421042
    10431043    GetCursorPos(&pos);
    1044     hwnd = WindowFromPoint(pos);
     1044    hwnd = WindowFromPoint(pos);   
    10451045
    10461046    if ( flags & TME_CANCEL ) {
     
    10481048        cancel = 1;
    10491049    }
    1050 
     1050   
    10511051    if ( flags & TME_HOVER  ) {
    10521052        flags &= ~ TME_HOVER;
    10531053        hover = 1;
    10541054    }
    1055 
     1055   
    10561056    if ( flags & TME_LEAVE ) {
    10571057        flags &= ~ TME_LEAVE;
     
    10751075        else
    10761076            ptme->dwFlags = 0;
    1077 
     1077   
    10781078        return TRUE; /* return here, TME_QUERY is retrieving information */
    10791079    }
     
    10981098            {
    10991099                TrackingList[i] = TrackingList[--iTrackMax];
    1100 
     1100       
    11011101                if(iTrackMax == 0) {
    11021102                    KillTimer(0, timer);
     
    11191119                        TrackingList[i].tme.dwHoverTime = ptme->dwHoverTime;
    11201120                    }
    1121 
     1121 
    11221122                    if(leave)
    11231123                        TrackingList[i].tme.dwFlags |= TME_LEAVE;
    11241124
    11251125                    /* reset iHoverTime as per winapi specs */
    1126                     TrackingList[i].iHoverTime = 0;
    1127 
     1126                    TrackingList[i].iHoverTime = 0;                 
     1127 
    11281128                    return TRUE;
    11291129                }
    1130             }
     1130            }           
    11311131
    11321132            /* if the tracking list is full return FALSE */
     
    11981198
    11991199    hwndToolTip = CreateWindowExA(0, TOOLTIPS_CLASSA, NULL, 0,
    1200                   CW_USEDEFAULT, CW_USEDEFAULT,
    1201                   CW_USEDEFAULT, CW_USEDEFAULT, hwndOwner,
    1202                   0, 0, 0);
     1200                                  CW_USEDEFAULT, CW_USEDEFAULT,
     1201                                  CW_USEDEFAULT, CW_USEDEFAULT, hwndOwner,
     1202                                  0, 0, 0);
    12031203
    12041204    /* Send NM_TOOLTIPSCREATED notification */
    12051205    if (hwndToolTip)
    12061206    {
    1207     NMTOOLTIPSCREATED nmttc;
     1207        NMTOOLTIPSCREATED nmttc;
    12081208        /* true owner can be different if hwndOwner is a child window */
    12091209        HWND hwndTrueOwner = GetWindow(hwndToolTip, GW_OWNER);
    12101210        nmttc.hdr.hwndFrom = hwndTrueOwner;
    12111211        nmttc.hdr.idFrom = GetWindowLongA(hwndTrueOwner, GWL_ID);
    1212     nmttc.hdr.code = NM_TOOLTIPSCREATED;
    1213     nmttc.hwndToolTips = hwndToolTip;
     1212        nmttc.hdr.code = NM_TOOLTIPSCREATED;
     1213        nmttc.hwndToolTips = hwndToolTip;
    12141214
    12151215       SendMessageA(GetParent(hwndTrueOwner), WM_NOTIFY,
    12161216                    (WPARAM)GetWindowLongA(hwndTrueOwner, GWL_ID),
    1217              (LPARAM)&nmttc);
     1217                     (LPARAM)&nmttc);
    12181218    }
    12191219
  • trunk/src/comctl32/comctl32undoc.c

    r6705 r6709  
    9898
    9999    FIXME ("phDpa=%p loadProc=%p pStream=%p lParam=%lx\n",
    100        phDpa, loadProc, pStream, lParam);
     100           phDpa, loadProc, pStream, lParam);
    101101
    102102    if (!phDpa || !loadProc || !pStream)
    103     return E_INVALIDARG;
     103        return E_INVALIDARG;
    104104
    105105    *phDpa = (HDPA)NULL;
     
    110110    errCode = IStream_Seek (pStream, position, STREAM_SEEK_CUR, &newPosition);
    111111    if (errCode != S_OK)
    112     return errCode;
     112        return errCode;
    113113
    114114    errCode = IStream_Read (pStream, &streamData, sizeof(STREAMDATA), &ulRead);
    115115    if (errCode != S_OK)
    116     return errCode;
     116        return errCode;
    117117
    118118    FIXME ("dwSize=%lu dwData2=%lu dwItems=%lu\n",
    119        streamData.dwSize, streamData.dwData2, streamData.dwItems);
     119           streamData.dwSize, streamData.dwData2, streamData.dwItems);
    120120
    121121    if (lParam < sizeof(STREAMDATA) ||
    122     streamData.dwSize < sizeof(STREAMDATA) ||
    123     streamData.dwData2 < 1) {
    124     errCode = E_FAIL;
     122        streamData.dwSize < sizeof(STREAMDATA) ||
     123        streamData.dwData2 < 1) {
     124        errCode = E_FAIL;
    125125    }
    126126
     
    128128    hDpa = DPA_Create (streamData.dwItems);
    129129    if (!hDpa)
    130     return E_OUTOFMEMORY;
     130        return E_OUTOFMEMORY;
    131131
    132132    if (!DPA_Grow (hDpa, streamData.dwItems))
    133     return E_OUTOFMEMORY;
     133        return E_OUTOFMEMORY;
    134134
    135135    /* load data from the stream into the dpa */
     
    137137    for (loadData.nCount = 0; loadData.nCount < streamData.dwItems; loadData.nCount++) {
    138138        errCode = (loadProc)(&loadData, pStream, lParam);
    139     if (errCode != S_OK) {
    140         errCode = S_FALSE;
    141         break;
    142     }
    143 
    144     *ptr = loadData.ptr;
    145     ptr++;
     139        if (errCode != S_OK) {
     140            errCode = S_FALSE;
     141            break;
     142        }
     143
     144        *ptr = loadData.ptr;
     145        ptr++;
    146146    }
    147147
     
    177177
    178178    FIXME ("hDpa=%p loadProc=%p pStream=%p lParam=%lx\n",
    179        hDpa, loadProc, pStream, lParam);
     179           hDpa, loadProc, pStream, lParam);
    180180
    181181    return E_FAIL;
     
    200200BOOL WINAPI
    201201DPA_Merge (const HDPA hdpa1, const HDPA hdpa2, DWORD dwFlags,
    202        PFNDPACOMPARE pfnCompare, PFNDPAMERGE pfnMerge, LPARAM lParam)
     202           PFNDPACOMPARE pfnCompare, PFNDPAMERGE pfnMerge, LPARAM lParam)
    203203{
    204204    INT nCount;
     
    208208
    209209    TRACE("%p %p %08lx %p %p %08lx)\n",
    210        hdpa1, hdpa2, dwFlags, pfnCompare, pfnMerge, lParam);
     210           hdpa1, hdpa2, dwFlags, pfnCompare, pfnMerge, lParam);
    211211
    212212    if (IsBadWritePtr (hdpa1, sizeof(DPA)))
    213     return FALSE;
     213        return FALSE;
    214214
    215215    if (IsBadWritePtr (hdpa2, sizeof(DPA)))
    216     return FALSE;
     216        return FALSE;
    217217
    218218    if (IsBadCodePtr ((FARPROC)pfnCompare))
    219     return FALSE;
     219        return FALSE;
    220220
    221221    if (IsBadCodePtr ((FARPROC)pfnMerge))
    222     return FALSE;
     222        return FALSE;
    223223
    224224    if (dwFlags & DPAM_SORT) {
    225     TRACE("sorting dpa's!\n");
    226     if (hdpa1->nItemCount > 0)
    227     DPA_Sort (hdpa1, pfnCompare, lParam);
    228     TRACE ("dpa 1 sorted!\n");
    229     if (hdpa2->nItemCount > 0)
    230     DPA_Sort (hdpa2, pfnCompare, lParam);
    231     TRACE ("dpa 2 sorted!\n");
     225        TRACE("sorting dpa's!\n");
     226        if (hdpa1->nItemCount > 0)
     227        DPA_Sort (hdpa1, pfnCompare, lParam);
     228        TRACE ("dpa 1 sorted!\n");
     229        if (hdpa2->nItemCount > 0)
     230        DPA_Sort (hdpa2, pfnCompare, lParam);
     231        TRACE ("dpa 2 sorted!\n");
    232232    }
    233233
    234234    if (hdpa2->nItemCount < 1)
    235     return TRUE;
     235        return TRUE;
    236236
    237237    TRACE("hdpa1->nItemCount=%d hdpa2->nItemCount=%d\n",
    238        hdpa1->nItemCount, hdpa2->nItemCount);
     238           hdpa1->nItemCount, hdpa2->nItemCount);
    239239
    240240
     
    250250    {
    251251        if (nIndex < 0) break;
    252     nResult = (pfnCompare)(*pWork1, *pWork2, lParam);
    253     TRACE("compare result=%d, dpa1.cnt=%d, dpa2.cnt=%d\n",
    254           nResult, nIndex, nCount);
    255 
    256     if (nResult == 0)
    257     {
    258         PVOID ptr;
    259 
    260         ptr = (pfnMerge)(1, *pWork1, *pWork2, lParam);
    261         if (!ptr)
    262         return FALSE;
    263 
    264         nCount--;
    265         pWork2--;
    266         *pWork1 = ptr;
    267         nIndex--;
    268         pWork1--;
    269     }
    270     else if (nResult < 0)
    271     {
    272         if (!dwFlags & 8)
    273         {
    274         PVOID ptr;
    275 
    276         ptr = DPA_DeletePtr (hdpa1, hdpa1->nItemCount - 1);
    277 
    278         (pfnMerge)(2, ptr, NULL, lParam);
    279         }
    280         nIndex--;
    281         pWork1--;
    282     }
    283     else
    284     {
    285         if (!dwFlags & 4)
    286         {
    287         PVOID ptr;
    288 
    289         ptr = (pfnMerge)(3, *pWork2, NULL, lParam);
    290         if (!ptr)
    291             return FALSE;
    292         DPA_InsertPtr (hdpa1, nIndex, ptr);
    293         }
    294         nCount--;
    295         pWork2--;
    296     }
     252        nResult = (pfnCompare)(*pWork1, *pWork2, lParam);
     253        TRACE("compare result=%d, dpa1.cnt=%d, dpa2.cnt=%d\n",
     254              nResult, nIndex, nCount);
     255
     256        if (nResult == 0)
     257        {
     258            PVOID ptr;
     259
     260            ptr = (pfnMerge)(1, *pWork1, *pWork2, lParam);
     261            if (!ptr)
     262                return FALSE;
     263
     264            nCount--;
     265            pWork2--;
     266            *pWork1 = ptr;
     267            nIndex--;
     268            pWork1--;
     269        }
     270        else if (nResult < 0)
     271        {
     272            if (!dwFlags & 8)
     273            {
     274                PVOID ptr;
     275
     276                ptr = DPA_DeletePtr (hdpa1, hdpa1->nItemCount - 1);
     277
     278                (pfnMerge)(2, ptr, NULL, lParam);
     279            }
     280            nIndex--;
     281            pWork1--;
     282        }
     283        else
     284        {
     285            if (!dwFlags & 4)
     286            {
     287                PVOID ptr;
     288
     289                ptr = (pfnMerge)(3, *pWork2, NULL, lParam);
     290                if (!ptr)
     291                    return FALSE;
     292                DPA_InsertPtr (hdpa1, nIndex, ptr);
     293            }
     294            nCount--;
     295            pWork2--;
     296        }
    297297
    298298    }
     
    358358
    359359    if (lpSrc)
    360     lpDest = HeapReAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, lpSrc, dwSize);
     360        lpDest = HeapReAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, lpSrc, dwSize);
    361361    else
    362     lpDest = HeapAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, dwSize);
     362        lpDest = HeapAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, dwSize);
    363363
    364364    TRACE("-- ret=%p\n", lpDest);
     
    458458HANDLE WINAPI
    459459CreateMRUListLazyA (LPCREATEMRULIST lpcml, DWORD dwParam2,
    460             DWORD dwParam3, DWORD dwParam4);
     460                    DWORD dwParam3, DWORD dwParam4);
    461461
    462462
     
    490490#if 0
    491491    if (!(hmru->dwParam1 & 1001)) {
    492     RegSetValueExA (hmru->hKeyMRU, "MRUList", 0, REG_SZ,
    493               hmru->lpszMRUString,
    494               strlen (hmru->lpszMRUString));
     492        RegSetValueExA (hmru->hKeyMRU, "MRUList", 0, REG_SZ,
     493                          hmru->lpszMRUString,
     494                          strlen (hmru->lpszMRUString));
    495495    }
    496496
     
    506506/**************************************************************************
    507507 *              AddMRUData [COMCTL32.167]
    508  *
     508 * 
    509509 * Add item to MRU binary list.  If item already exists in list then it is
    510510 * simply moved up to the top of the list and not added again.  If list is
     
    530530/**************************************************************************
    531531 *              AddMRUStringA [COMCTL32.153]
    532  *
     532 * 
    533533 * Add item to MRU string list.  If item already exists in list them it is
    534534 * simply moved up to the top of the list and not added again.  If list is
     
    572572/**************************************************************************
    573573 *                  FindMRUData [COMCTL32.169]
    574  *
     574 * 
    575575 * Searches binary list for item that matches lpData of length cbData.
    576576 * Returns position in list order 0 -> MRU and if lpRegNum != NULL then value
     
    590590{
    591591    FIXME("(%08x, %p, %ld, %p) empty stub!\n",
    592        hList, lpData, cbData, lpRegNum);
     592           hList, lpData, cbData, lpRegNum);
    593593
    594594    return 0;
     
    597597/**************************************************************************
    598598 *                  FindMRUStringA [COMCTL32.155]
    599  *
     599 * 
    600600 * Searches string list for item that matches lpszString.
    601601 * Returns position in list order 0 -> MRU and if lpRegNum != NULL then value
     
    614614{
    615615    FIXME("(%08x, %s, %p) empty stub!\n", hList, debugstr_a(lpszString),
    616       lpRegNum);
     616          lpRegNum);
    617617
    618618    return 0;
     
    640640
    641641    if (lpcml == NULL)
    642     return 0;
     642        return 0;
    643643
    644644    if (lpcml->cbSize < sizeof(CREATEMRULIST))
    645     return 0;
     645        return 0;
    646646
    647647    FIXME("(%lu %lu %lx %lx \"%s\" %p)\n",
    648       lpcml->cbSize, lpcml->nMaxItems, lpcml->dwFlags,
    649       (DWORD)lpcml->hKey, lpcml->lpszSubKey, lpcml->lpfnCompare);
     648          lpcml->cbSize, lpcml->nMaxItems, lpcml->dwFlags,
     649          (DWORD)lpcml->hKey, lpcml->lpszSubKey, lpcml->lpfnCompare);
    650650
    651651    /* dummy pointer creation */
     
    659659/**************************************************************************
    660660 *                EnumMRUListA [COMCTL32.154]
    661  *
     661 * 
    662662 * Enumerate item in a list
    663663 *
     
    673673 *    of list returns -1.
    674674 *    If lpBuffer == NULL or nItemPos is -ve return value is no. of items in
    675  *    the list.
     675 *    the list. 
    676676 */
    677677INT WINAPI EnumMRUListA(HANDLE hList, INT nItemPos, LPVOID lpBuffer,
     
    679679{
    680680    FIXME("(%08x, %d, %p, %ld): stub\n", hList, nItemPos, lpBuffer,
    681       nBufferSize);
     681          nBufferSize);
    682682    return 0;
    683683}
     
    702702
    703703    if (!lpDest && lpSrc)
    704     return strlen (lpSrc);
     704        return strlen (lpSrc);
    705705
    706706    if (nMaxLen == 0)
    707     return 0;
     707        return 0;
    708708
    709709    if (lpSrc == NULL) {
    710     lpDest[0] = '\0';
    711     return 0;
     710        lpDest[0] = '\0';
     711        return 0;
    712712    }
    713713
    714714    len = strlen (lpSrc);
    715715    if (len >= nMaxLen)
    716     len = nMaxLen - 1;
     716        len = nMaxLen - 1;
    717717
    718718    RtlMoveMemory (lpDest, lpSrc, len);
     
    737737{
    738738    TRACE("(%p %p)\n", lppDest, lpSrc);
    739 
     739 
    740740    if (lpSrc) {
    741     LPSTR ptr = COMCTL32_ReAlloc (*lppDest, strlen (lpSrc) + 1);
    742     if (!ptr)
    743         return FALSE;
    744     strcpy (ptr, lpSrc);
    745     *lppDest = ptr;
     741        LPSTR ptr = COMCTL32_ReAlloc (*lppDest, strlen (lpSrc) + 1);
     742        if (!ptr)
     743            return FALSE;
     744        strcpy (ptr, lpSrc);
     745        *lppDest = ptr;
    746746    }
    747747    else {
    748     if (*lppDest) {
    749         COMCTL32_Free (*lppDest);
    750         *lppDest = NULL;
    751     }
     748        if (*lppDest) {
     749            COMCTL32_Free (*lppDest);
     750            *lppDest = NULL;
     751        }
    752752    }
    753753
     
    775775
    776776    if (!lpDest && lpSrc)
    777     return strlenW (lpSrc);
     777        return strlenW (lpSrc);
    778778
    779779    if (nMaxLen == 0)
    780     return 0;
     780        return 0;
    781781
    782782    if (lpSrc == NULL) {
    783     lpDest[0] = L'\0';
    784     return 0;
     783        lpDest[0] = L'\0';
     784        return 0;
    785785    }
    786786
    787787    len = strlenW (lpSrc);
    788788    if (len >= nMaxLen)
    789     len = nMaxLen - 1;
     789        len = nMaxLen - 1;
    790790
    791791    RtlMoveMemory (lpDest, lpSrc, len*sizeof(WCHAR));
     
    810810{
    811811    TRACE("(%p %p)\n", lppDest, lpSrc);
    812 
     812 
    813813    if (lpSrc) {
    814     INT len = strlenW (lpSrc) + 1;
    815     LPWSTR ptr = COMCTL32_ReAlloc (*lppDest, len * sizeof(WCHAR));
    816     if (!ptr)
    817         return FALSE;
    818     strcpyW (ptr, lpSrc);
    819     *lppDest = ptr;
     814        INT len = strlenW (lpSrc) + 1;
     815        LPWSTR ptr = COMCTL32_ReAlloc (*lppDest, len * sizeof(WCHAR));
     816        if (!ptr)
     817            return FALSE;
     818        strcpyW (ptr, lpSrc);
     819        *lppDest = ptr;
    820820    }
    821821    else {
    822     if (*lppDest) {
    823         COMCTL32_Free (*lppDest);
    824         *lppDest = NULL;
    825     }
     822        if (*lppDest) {
     823            COMCTL32_Free (*lppDest);
     824            *lppDest = NULL;
     825        }
    826826    }
    827827
     
    852852
    853853    if (!lpDest && lpSrc)
    854     return WideCharToMultiByte(CP_ACP, 0, lpSrc, -1, 0, 0, NULL, NULL);
     854        return WideCharToMultiByte(CP_ACP, 0, lpSrc, -1, 0, 0, NULL, NULL);
    855855
    856856    if (nMaxLen == 0)
    857     return 0;
     857        return 0;
    858858
    859859    if (lpSrc == NULL) {
    860     lpDest[0] = '\0';
    861     return 0;
     860        lpDest[0] = '\0';
     861        return 0;
    862862    }
    863863
    864864    len = WideCharToMultiByte(CP_ACP, 0, lpSrc, -1, 0, 0, NULL, NULL);
    865865    if (len >= nMaxLen)
    866     len = nMaxLen - 1;
     866        len = nMaxLen - 1;
    867867
    868868    WideCharToMultiByte(CP_ACP, 0, lpSrc, -1, lpDest, len, NULL, NULL);
     
    897897
    898898    if (lpSrc) {
    899     INT len = MultiByteToWideChar(CP_ACP,0,lpSrc,-1,NULL,0);
    900     LPWSTR ptr = COMCTL32_ReAlloc (*lppDest, len*sizeof(WCHAR));
    901 
    902     if (!ptr)
    903         return FALSE;
    904     MultiByteToWideChar(CP_ACP,0,lpSrc,-1,ptr,len);
    905     *lppDest = ptr;
     899        INT len = MultiByteToWideChar(CP_ACP,0,lpSrc,-1,NULL,0);
     900        LPWSTR ptr = COMCTL32_ReAlloc (*lppDest, len*sizeof(WCHAR));
     901
     902        if (!ptr)
     903            return FALSE;
     904        MultiByteToWideChar(CP_ACP,0,lpSrc,-1,ptr,len);
     905        *lppDest = ptr;
    906906    }
    907907    else {
    908     if (*lppDest) {
    909         COMCTL32_Free (*lppDest);
    910         *lppDest = NULL;
    911     }
     908        if (*lppDest) {
     909            COMCTL32_Free (*lppDest);
     910            *lppDest = NULL;
     911        }
    912912    }
    913913
     
    944944    if (hdsa)
    945945    {
    946     hdsa->nItemCount = 0;
     946        hdsa->nItemCount = 0;
    947947        hdsa->pData = NULL;
    948     hdsa->nMaxCount = 0;
    949     hdsa->nItemSize = nSize;
    950     hdsa->nGrow = max(1, nGrow);
     948        hdsa->nMaxCount = 0;
     949        hdsa->nItemSize = nSize;
     950        hdsa->nGrow = max(1, nGrow);
    951951    }
    952952
     
    972972
    973973    if (!hdsa)
    974     return FALSE;
     974        return FALSE;
    975975
    976976    if (hdsa->pData && (!COMCTL32_Free (hdsa->pData)))
    977     return FALSE;
     977        return FALSE;
    978978
    979979    return COMCTL32_Free (hdsa);
     
    982982
    983983/**************************************************************************
    984  * DSA_GetItem [COMCTL32.322]
     984 * DSA_GetItem [COMCTL32.322] 
    985985 *
    986986 * PARAMS
     
    10001000
    10011001    TRACE("(%p %d %p)\n", hdsa, nIndex, pDest);
    1002 
     1002   
    10031003    if (!hdsa)
    1004     return FALSE;
     1004        return FALSE;
    10051005    if ((nIndex < 0) || (nIndex >= hdsa->nItemCount))
    1006     return FALSE;
     1006        return FALSE;
    10071007
    10081008    pSrc = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
     
    10141014
    10151015/**************************************************************************
    1016  * DSA_GetItemPtr [COMCTL32.323]
     1016 * DSA_GetItemPtr [COMCTL32.323] 
    10171017 *
    10181018 * Retrieves a pointer to the specified item.
     
    10351035
    10361036    if (!hdsa)
    1037     return NULL;
     1037        return NULL;
    10381038    if ((nIndex < 0) || (nIndex >= hdsa->nItemCount))
    1039     return NULL;
     1039        return NULL;
    10401040
    10411041    pSrc = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
    1042 
     1042   
    10431043    TRACE("-- ret=%p\n", pSrc);
    10441044
     
    10481048
    10491049/**************************************************************************
    1050  * DSA_SetItem [COMCTL32.325]
     1050 * DSA_SetItem [COMCTL32.325] 
    10511051 *
    10521052 * Sets the contents of an item in the array.
     
    10671067    INT  nSize, nNewItems;
    10681068    LPVOID pDest, lpTemp;
    1069 
     1069   
    10701070    TRACE("(%p %d %p)\n", hdsa, nIndex, pSrc);
    10711071
    10721072    if ((!hdsa) || nIndex < 0)
    1073     return FALSE;
    1074 
     1073        return FALSE;
     1074     
    10751075    if (hdsa->nItemCount <= nIndex) {
    1076     /* within the old array */
    1077     if (hdsa->nMaxCount > nIndex) {
    1078         /* within the allocated space, set a new boundary */
    1079         hdsa->nItemCount = nIndex + 1;
    1080     }
    1081     else {
    1082         /* resize the block of memory */
    1083         nNewItems =
    1084         hdsa->nGrow * ((INT)(((nIndex + 1) - 1) / hdsa->nGrow) + 1);
    1085         nSize = hdsa->nItemSize * nNewItems;
    1086 
    1087         lpTemp = (LPVOID)COMCTL32_ReAlloc (hdsa->pData, nSize);
    1088         if (!lpTemp)
    1089         return FALSE;
    1090 
    1091         hdsa->nMaxCount = nNewItems;
    1092         hdsa->nItemCount = nIndex + 1;
    1093         hdsa->pData = lpTemp;
    1094     }
     1076        /* within the old array */
     1077        if (hdsa->nMaxCount > nIndex) {
     1078            /* within the allocated space, set a new boundary */
     1079            hdsa->nItemCount = nIndex + 1;
     1080        }
     1081        else {
     1082            /* resize the block of memory */
     1083            nNewItems =
     1084                hdsa->nGrow * ((INT)(((nIndex + 1) - 1) / hdsa->nGrow) + 1);
     1085            nSize = hdsa->nItemSize * nNewItems;
     1086
     1087            lpTemp = (LPVOID)COMCTL32_ReAlloc (hdsa->pData, nSize);
     1088            if (!lpTemp)
     1089                return FALSE;
     1090
     1091            hdsa->nMaxCount = nNewItems;
     1092            hdsa->nItemCount = nIndex + 1;
     1093            hdsa->pData = lpTemp;
     1094        }   
    10951095    }
    10961096
     
    10981098    pDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
    10991099    TRACE("-- move dest=%p src=%p size=%d\n",
    1100        pDest, pSrc, hdsa->nItemSize);
     1100           pDest, pSrc, hdsa->nItemSize);
    11011101    memmove (pDest, pSrc, hdsa->nItemSize);
    11021102
     
    11061106
    11071107/**************************************************************************
    1108  * DSA_InsertItem [COMCTL32.324]
     1108 * DSA_InsertItem [COMCTL32.324] 
    11091109 *
    11101110 * PARAMS
     
    11241124    LPVOID  lpTemp, lpDest;
    11251125    LPDWORD p;
    1126 
     1126   
    11271127    TRACE("(%p %d %p)\n", hdsa, nIndex, pSrc);
    11281128
    11291129    if ((!hdsa) || nIndex < 0)
    1130     return -1;
     1130        return -1;
    11311131
    11321132    for (i = 0; i < hdsa->nItemSize; i += 4) {
    1133     p = *(DWORD**)((char *) pSrc + i);
    1134     if (IsBadStringPtrA ((char*)p, 256))
    1135         TRACE("-- %d=%p\n", i, (DWORD*)p);
    1136     else
    1137         TRACE("-- %d=%p [%s]\n", i, p, debugstr_a((char*)p));
    1138     }
    1139 
     1133        p = *(DWORD**)((char *) pSrc + i);
     1134        if (IsBadStringPtrA ((char*)p, 256))
     1135            TRACE("-- %d=%p\n", i, (DWORD*)p);
     1136        else
     1137            TRACE("-- %d=%p [%s]\n", i, p, debugstr_a((char*)p));
     1138    }
     1139   
    11401140    /* when nIndex >= nItemCount then append */
    11411141    if (nIndex >= hdsa->nItemCount)
    1142     nIndex = hdsa->nItemCount;
     1142        nIndex = hdsa->nItemCount;
    11431143
    11441144    /* do we need to resize ? */
    11451145    if (hdsa->nItemCount >= hdsa->nMaxCount) {
    1146     nNewItems = hdsa->nMaxCount + hdsa->nGrow;
    1147     nSize = hdsa->nItemSize * nNewItems;
    1148 
    1149     lpTemp = (LPVOID)COMCTL32_ReAlloc (hdsa->pData, nSize);
    1150     if (!lpTemp)
    1151         return -1;
    1152 
    1153     hdsa->nMaxCount = nNewItems;
    1154     hdsa->pData = lpTemp;
     1146        nNewItems = hdsa->nMaxCount + hdsa->nGrow;
     1147        nSize = hdsa->nItemSize * nNewItems;
     1148
     1149        lpTemp = (LPVOID)COMCTL32_ReAlloc (hdsa->pData, nSize);
     1150        if (!lpTemp)
     1151            return -1;
     1152
     1153        hdsa->nMaxCount = nNewItems;
     1154        hdsa->pData = lpTemp;         
    11551155    }
    11561156
    11571157    /* do we need to move elements ? */
    11581158    if (nIndex < hdsa->nItemCount) {
    1159     lpTemp = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
    1160     lpDest = (char *) lpTemp + hdsa->nItemSize;
    1161     nSize = (hdsa->nItemCount - nIndex) * hdsa->nItemSize;
    1162     TRACE("-- move dest=%p src=%p size=%d\n",
    1163            lpDest, lpTemp, nSize);
    1164     memmove (lpDest, lpTemp, nSize);
     1159        lpTemp = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
     1160        lpDest = (char *) lpTemp + hdsa->nItemSize;
     1161        nSize = (hdsa->nItemCount - nIndex) * hdsa->nItemSize;
     1162        TRACE("-- move dest=%p src=%p size=%d\n",
     1163               lpDest, lpTemp, nSize);
     1164        memmove (lpDest, lpTemp, nSize);
    11651165    }
    11661166
     
    11691169    lpDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
    11701170    TRACE("-- move dest=%p src=%p size=%d\n",
    1171        lpDest, pSrc, hdsa->nItemSize);
     1171           lpDest, pSrc, hdsa->nItemSize);
    11721172    memmove (lpDest, pSrc, hdsa->nItemSize);
    11731173
     
    11771177
    11781178/**************************************************************************
    1179  * DSA_DeleteItem [COMCTL32.326]
     1179 * DSA_DeleteItem [COMCTL32.326] 
    11801180 *
    11811181 * PARAMS
     
    11931193    LPVOID lpDest,lpSrc;
    11941194    INT  nSize;
    1195 
     1195   
    11961196    TRACE("(%p %d)\n", hdsa, nIndex);
    11971197
    11981198    if (!hdsa)
    1199     return -1;
     1199        return -1;
    12001200    if (nIndex < 0 || nIndex >= hdsa->nItemCount)
    1201     return -1;
     1201        return -1;
    12021202
    12031203    /* do we need to move ? */
    12041204    if (nIndex < hdsa->nItemCount - 1) {
    1205     lpDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
    1206     lpSrc = (char *) lpDest + hdsa->nItemSize;
    1207     nSize = hdsa->nItemSize * (hdsa->nItemCount - nIndex - 1);
    1208     TRACE("-- move dest=%p src=%p size=%d\n",
    1209            lpDest, lpSrc, nSize);
    1210     memmove (lpDest, lpSrc, nSize);
    1211     }
    1212 
     1205        lpDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
     1206        lpSrc = (char *) lpDest + hdsa->nItemSize;
     1207        nSize = hdsa->nItemSize * (hdsa->nItemCount - nIndex - 1);
     1208        TRACE("-- move dest=%p src=%p size=%d\n",
     1209               lpDest, lpSrc, nSize);
     1210        memmove (lpDest, lpSrc, nSize);
     1211    }
     1212   
    12131213    hdsa->nItemCount--;
    1214 
     1214   
    12151215    /* free memory ? */
    12161216    if ((hdsa->nMaxCount - hdsa->nItemCount) >= hdsa->nGrow) {
    1217     nSize = hdsa->nItemSize * hdsa->nItemCount;
    1218 
    1219     lpDest = (LPVOID)COMCTL32_ReAlloc (hdsa->pData, nSize);
    1220     if (!lpDest)
    1221         return -1;
    1222 
    1223     hdsa->nMaxCount = hdsa->nItemCount;
    1224     hdsa->pData = lpDest;
     1217        nSize = hdsa->nItemSize * hdsa->nItemCount;
     1218
     1219        lpDest = (LPVOID)COMCTL32_ReAlloc (hdsa->pData, nSize);
     1220        if (!lpDest)
     1221            return -1;
     1222
     1223        hdsa->nMaxCount = hdsa->nItemCount;
     1224        hdsa->pData = lpDest;
    12251225    }
    12261226
     
    12471247    TRACE("(%p)\n", hdsa);
    12481248
    1249     if (!hdsa)
    1250     return FALSE;
     1249    if (!hdsa) 
     1250        return FALSE;
    12511251    if (hdsa->pData && (!COMCTL32_Free (hdsa->pData)))
    1252     return FALSE;
     1252        return FALSE;
    12531253
    12541254    hdsa->nItemCount = 0;
     
    12851285    hdpa = (HDPA)COMCTL32_Alloc (sizeof(DPA));
    12861286    if (hdpa) {
    1287     hdpa->nGrow = max(8, nGrow);
    1288     hdpa->hHeap = COMCTL32_hHeap;
    1289     hdpa->nMaxCount = hdpa->nGrow * 2;
    1290     hdpa->ptrs =
    1291         (LPVOID*)COMCTL32_Alloc (hdpa->nMaxCount * sizeof(LPVOID));
     1287        hdpa->nGrow = max(8, nGrow);
     1288        hdpa->hHeap = COMCTL32_hHeap;
     1289        hdpa->nMaxCount = hdpa->nGrow * 2;
     1290        hdpa->ptrs =
     1291            (LPVOID*)COMCTL32_Alloc (hdpa->nMaxCount * sizeof(LPVOID));
    12921292    }
    12931293
     
    13151315
    13161316    if (!hdpa)
    1317     return FALSE;
     1317        return FALSE;
    13181318
    13191319    if (hdpa->ptrs && (!HeapFree (hdpa->hHeap, 0, hdpa->ptrs)))
    1320     return FALSE;
     1320        return FALSE;
    13211321
    13221322    return HeapFree (hdpa->hHeap, 0, hdpa);
     
    13441344
    13451345    if (!hdpa)
    1346     return FALSE;
     1346        return FALSE;
    13471347
    13481348    hdpa->nGrow = max(8, nGrow);
     
    13791379
    13801380    if (!hdpa)
    1381     return NULL;
     1381        return NULL;
    13821382
    13831383    TRACE("(%p %p)\n", hdpa, hdpaNew);
    13841384
    13851385    if (!hdpaNew) {
    1386     /* create a new DPA */
    1387     hdpaTemp = (HDPA)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
    1388                     sizeof(DPA));
    1389     hdpaTemp->hHeap = hdpa->hHeap;
    1390     hdpaTemp->nGrow = hdpa->nGrow;
     1386        /* create a new DPA */
     1387        hdpaTemp = (HDPA)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
     1388                                    sizeof(DPA));
     1389        hdpaTemp->hHeap = hdpa->hHeap;
     1390        hdpaTemp->nGrow = hdpa->nGrow;
    13911391    }
    13921392    else
    1393     hdpaTemp = hdpaNew;
     1393        hdpaTemp = hdpaNew;
    13941394
    13951395    if (hdpaTemp->ptrs) {
    1396     /* remove old pointer array */
    1397     HeapFree (hdpaTemp->hHeap, 0, hdpaTemp->ptrs);
    1398     hdpaTemp->ptrs = NULL;
    1399     hdpaTemp->nItemCount = 0;
    1400     hdpaTemp->nMaxCount = 0;
     1396        /* remove old pointer array */
     1397        HeapFree (hdpaTemp->hHeap, 0, hdpaTemp->ptrs);
     1398        hdpaTemp->ptrs = NULL;
     1399        hdpaTemp->nItemCount = 0;
     1400        hdpaTemp->nMaxCount = 0;
    14011401    }
    14021402
    14031403    /* create a new pointer array */
    14041404    nNewItems = hdpaTemp->nGrow *
    1405         ((INT)((hdpa->nItemCount - 1) / hdpaTemp->nGrow) + 1);
     1405                ((INT)((hdpa->nItemCount - 1) / hdpaTemp->nGrow) + 1);
    14061406    nSize = nNewItems * sizeof(LPVOID);
    14071407    hdpaTemp->ptrs =
    1408     (LPVOID*)HeapAlloc (hdpaTemp->hHeap, HEAP_ZERO_MEMORY, nSize);
     1408        (LPVOID*)HeapAlloc (hdpaTemp->hHeap, HEAP_ZERO_MEMORY, nSize);
    14091409    hdpaTemp->nMaxCount = nNewItems;
    14101410
     
    14121412    hdpaTemp->nItemCount = hdpa->nItemCount;
    14131413    memmove (hdpaTemp->ptrs, hdpa->ptrs,
    1414          hdpaTemp->nItemCount * sizeof(LPVOID));
     1414             hdpaTemp->nItemCount * sizeof(LPVOID));
    14151415
    14161416    return hdpaTemp;
     
    14381438
    14391439    if (!hdpa)
    1440     return NULL;
     1440        return NULL;
    14411441    if (!hdpa->ptrs) {
    1442     WARN("no pointer array.\n");
    1443     return NULL;
     1442        WARN("no pointer array.\n");
     1443        return NULL;
    14441444    }
    14451445    if ((i < 0) || (i >= hdpa->nItemCount)) {
    1446     WARN("not enough pointers in array (%d vs %d).\n",i,hdpa->nItemCount);
    1447     return NULL;
     1446        WARN("not enough pointers in array (%d vs %d).\n",i,hdpa->nItemCount);
     1447        return NULL;
    14481448    }
    14491449
     
    14741474
    14751475    if (!hdpa->ptrs)
    1476     return -1;
     1476        return -1;
    14771477
    14781478    for (i = 0; i < hdpa->nItemCount; i++) {
    1479     if (hdpa->ptrs[i] == p)
    1480         return i;
     1479        if (hdpa->ptrs[i] == p)
     1480            return i;
    14811481    }
    14821482
     
    15091509
    15101510    if ((!hdpa) || (i < 0))
    1511     return -1;
     1511        return -1;
    15121512
    15131513    if (!hdpa->ptrs) {
    1514     hdpa->ptrs =
    1515         (LPVOID*)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
    1516                 2 * hdpa->nGrow * sizeof(LPVOID));
    1517     if (!hdpa->ptrs)
    1518         return -1;
    1519     hdpa->nMaxCount = hdpa->nGrow * 2;
     1514        hdpa->ptrs =
     1515            (LPVOID*)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
     1516                                2 * hdpa->nGrow * sizeof(LPVOID));
     1517        if (!hdpa->ptrs)
     1518            return -1;
     1519        hdpa->nMaxCount = hdpa->nGrow * 2;
    15201520        nIndex = 0;
    15211521    }
    15221522    else {
    1523     if (hdpa->nItemCount >= hdpa->nMaxCount) {
    1524         TRACE("-- resizing\n");
    1525         nNewItems = hdpa->nMaxCount + hdpa->nGrow;
    1526         nSize = nNewItems * sizeof(LPVOID);
    1527 
    1528         lpTemp = (LPVOID*)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
    1529                        hdpa->ptrs, nSize);
    1530         if (!lpTemp)
    1531         return -1;
    1532         hdpa->nMaxCount = nNewItems;
    1533         hdpa->ptrs = lpTemp;
    1534     }
    1535 
    1536     if (i >= hdpa->nItemCount) {
    1537         nIndex = hdpa->nItemCount;
    1538         TRACE("-- appending at %d\n", nIndex);
    1539     }
    1540     else {
    1541         TRACE("-- inserting at %d\n", i);
    1542         lpTemp = hdpa->ptrs + i;
    1543         lpDest = lpTemp + 1;
    1544         nSize  = (hdpa->nItemCount - i) * sizeof(LPVOID);
    1545         TRACE("-- move dest=%p src=%p size=%x\n",
    1546            lpDest, lpTemp, nSize);
    1547         memmove (lpDest, lpTemp, nSize);
    1548         nIndex = i;
    1549     }
     1523        if (hdpa->nItemCount >= hdpa->nMaxCount) {
     1524            TRACE("-- resizing\n");
     1525            nNewItems = hdpa->nMaxCount + hdpa->nGrow;
     1526            nSize = nNewItems * sizeof(LPVOID);
     1527
     1528            lpTemp = (LPVOID*)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
     1529                                           hdpa->ptrs, nSize);
     1530            if (!lpTemp)
     1531                return -1;
     1532            hdpa->nMaxCount = nNewItems;
     1533            hdpa->ptrs = lpTemp;
     1534        }
     1535
     1536        if (i >= hdpa->nItemCount) {
     1537            nIndex = hdpa->nItemCount;
     1538            TRACE("-- appending at %d\n", nIndex);
     1539        }
     1540        else {
     1541            TRACE("-- inserting at %d\n", i);
     1542            lpTemp = hdpa->ptrs + i;
     1543            lpDest = lpTemp + 1;
     1544            nSize  = (hdpa->nItemCount - i) * sizeof(LPVOID);
     1545            TRACE("-- move dest=%p src=%p size=%x\n",
     1546                   lpDest, lpTemp, nSize);
     1547            memmove (lpDest, lpTemp, nSize);
     1548            nIndex = i;
     1549        }
    15501550    }
    15511551
     
    15771577{
    15781578    LPVOID *lpTemp;
    1579 
     1579   
    15801580    TRACE("(%p %d %p)\n", hdpa, i, p);
    15811581
    15821582    if ((!hdpa) || i < 0)
    1583     return FALSE;
    1584 
     1583        return FALSE;
     1584     
    15851585    if (hdpa->nItemCount <= i) {
    1586     /* within the old array */
    1587     if (hdpa->nMaxCount > i) {
    1588         /* within the allocated space, set a new boundary */
    1589         hdpa->nItemCount = i+1;
    1590     }
    1591     else {
    1592         /* resize the block of memory */
    1593         INT nNewItems =
    1594         hdpa->nGrow * ((INT)(((i+1) - 1) / hdpa->nGrow) + 1);
    1595         INT nSize = nNewItems * sizeof(LPVOID);
    1596 
    1597         lpTemp = (LPVOID*)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
    1598                        hdpa->ptrs, nSize);
    1599         if (!lpTemp)
    1600         return FALSE;
    1601 
    1602         hdpa->nItemCount = nNewItems;
    1603         hdpa->ptrs = lpTemp;
    1604     }
     1586        /* within the old array */
     1587        if (hdpa->nMaxCount > i) {
     1588            /* within the allocated space, set a new boundary */
     1589            hdpa->nItemCount = i+1;
     1590        }
     1591        else {
     1592            /* resize the block of memory */
     1593            INT nNewItems =
     1594                hdpa->nGrow * ((INT)(((i+1) - 1) / hdpa->nGrow) + 1);
     1595            INT nSize = nNewItems * sizeof(LPVOID);
     1596
     1597            lpTemp = (LPVOID*)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
     1598                                           hdpa->ptrs, nSize);
     1599            if (!lpTemp)
     1600                return FALSE;
     1601
     1602            hdpa->nItemCount = nNewItems;
     1603            hdpa->ptrs = lpTemp;       
     1604        }   
    16051605    }
    16061606
     
    16311631    LPVOID *lpDest, *lpSrc, lpTemp = NULL;
    16321632    INT  nSize;
    1633 
     1633   
    16341634    TRACE("(%p %d)\n", hdpa, i);
    16351635
    16361636    if ((!hdpa) || i < 0 || i >= hdpa->nItemCount)
    1637     return NULL;
     1637        return NULL;
    16381638
    16391639    lpTemp = hdpa->ptrs[i];
     
    16411641    /* do we need to move ?*/
    16421642    if (i < hdpa->nItemCount - 1) {
    1643     lpDest = hdpa->ptrs + i;
    1644     lpSrc = lpDest + 1;
    1645     nSize = (hdpa->nItemCount - i - 1) * sizeof(LPVOID);
    1646     TRACE("-- move dest=%p src=%p size=%x\n",
    1647            lpDest, lpSrc, nSize);
    1648     memmove (lpDest, lpSrc, nSize);
    1649     }
    1650 
     1643        lpDest = hdpa->ptrs + i;
     1644        lpSrc = lpDest + 1;
     1645        nSize = (hdpa->nItemCount - i - 1) * sizeof(LPVOID);
     1646        TRACE("-- move dest=%p src=%p size=%x\n",
     1647               lpDest, lpSrc, nSize);
     1648        memmove (lpDest, lpSrc, nSize);
     1649    }
     1650   
    16511651    hdpa->nItemCount --;
    1652 
     1652   
    16531653    /* free memory ?*/
    16541654    if ((hdpa->nMaxCount - hdpa->nItemCount) >= hdpa->nGrow) {
    1655     INT nNewItems = max(hdpa->nGrow * 2, hdpa->nItemCount);
    1656     nSize = nNewItems * sizeof(LPVOID);
    1657     lpDest = (LPVOID)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
    1658                       hdpa->ptrs, nSize);
    1659     if (!lpDest)
    1660         return NULL;
    1661 
    1662     hdpa->nMaxCount = nNewItems;
    1663     hdpa->ptrs = (LPVOID*)lpDest;
     1655        INT nNewItems = max(hdpa->nGrow * 2, hdpa->nItemCount);
     1656        nSize = nNewItems * sizeof(LPVOID);
     1657        lpDest = (LPVOID)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
     1658                                      hdpa->ptrs, nSize);
     1659        if (!lpDest)
     1660            return NULL;
     1661
     1662        hdpa->nMaxCount = nNewItems;
     1663        hdpa->ptrs = (LPVOID*)lpDest;         
    16641664    }
    16651665
     
    16861686    TRACE("(%p)\n", hdpa);
    16871687
    1688     if (!hdpa)
    1689     return FALSE;
     1688    if (!hdpa) 
     1689        return FALSE;
    16901690
    16911691    if (hdpa->ptrs && (!HeapFree (hdpa->hHeap, 0, hdpa->ptrs)))
    1692     return FALSE;
     1692        return FALSE;
    16931693
    16941694    hdpa->nItemCount = 0;
    16951695    hdpa->nMaxCount = hdpa->nGrow * 2;
    16961696    hdpa->ptrs = (LPVOID*)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
    1697                      hdpa->nMaxCount * sizeof(LPVOID));
     1697                                     hdpa->nMaxCount * sizeof(LPVOID));
    16981698
    16991699    return TRUE;
     
    17191719static VOID
    17201720DPA_QuickSort (LPVOID *lpPtrs, INT l, INT r,
    1721            PFNDPACOMPARE pfnCompare, LPARAM lParam)
     1721               PFNDPACOMPARE pfnCompare, LPARAM lParam)
    17221722{
    17231723    INT m;
     
    17251725
    17261726    TRACE("l=%i r=%i\n", l, r);
    1727 
     1727 
    17281728    if (l==r)    /* one element is always sorted */
    17291729        return;
    17301730    if (r<l)     /* oops, got it in the wrong order */
    1731     {
     1731        {
    17321732        DPA_QuickSort(lpPtrs, r, l, pfnCompare, lParam);
    17331733        return;
    1734     }
     1734        }
    17351735    m = (l+r)/2; /* divide by two */
    17361736    DPA_QuickSort(lpPtrs, l, m, pfnCompare, lParam);
     
    17381738
    17391739    /* join the two sides */
    1740     while( (l<=m) && (m<r) )
     1740    while( (l<=m) && (m<r) ) 
    17411741    {
    17421742        if(pfnCompare(lpPtrs[l],lpPtrs[m+1],lParam)>0)
     
    17721772{
    17731773    if (!hdpa || !pfnCompare)
    1774     return FALSE;
     1774        return FALSE;
    17751775
    17761776    TRACE("(%p %p 0x%lx)\n", hdpa, pfnCompare, lParam);
    17771777
    17781778    if ((hdpa->nItemCount > 1) && (hdpa->ptrs))
    1779     DPA_QuickSort (hdpa->ptrs, 0, hdpa->nItemCount - 1,
    1780                pfnCompare, lParam);
     1779        DPA_QuickSort (hdpa->ptrs, 0, hdpa->nItemCount - 1,
     1780                       pfnCompare, lParam);
    17811781
    17821782    return TRUE;
     
    18091809INT WINAPI
    18101810DPA_Search (const HDPA hdpa, LPVOID pFind, INT nStart,
    1811         PFNDPACOMPARE pfnCompare, LPARAM lParam, UINT uOptions)
     1811            PFNDPACOMPARE pfnCompare, LPARAM lParam, UINT uOptions)
    18121812{
    18131813    if (!hdpa || !pfnCompare || !pFind)
    1814     return -1;
     1814        return -1;
    18151815
    18161816    TRACE("(%p %p %d %p 0x%08lx 0x%08x)\n",
    1817        hdpa, pFind, nStart, pfnCompare, lParam, uOptions);
     1817           hdpa, pFind, nStart, pfnCompare, lParam, uOptions);
    18181818
    18191819    if (uOptions & DPAS_SORTED) {
    1820     /* array is sorted --> use binary search */
    1821     INT l, r, x, n;
    1822     LPVOID *lpPtr;
    1823 
    1824     TRACE("binary search\n");
    1825 
    1826     l = (nStart == -1) ? 0 : nStart;
    1827     r = hdpa->nItemCount - 1;
    1828     lpPtr = hdpa->ptrs;
    1829     while (r >= l) {
    1830         x = (l + r) / 2;
    1831         n = (pfnCompare)(pFind, lpPtr[x], lParam);
    1832         if (n < 0)
    1833         r = x - 1;
    1834         else
    1835         l = x + 1;
    1836         if (n == 0) {
    1837         TRACE("-- ret=%d\n", n);
    1838         return n;
    1839         }
    1840     }
    1841 
    1842     if (uOptions & DPAS_INSERTBEFORE) {
    1843         TRACE("-- ret=%d\n", r);
    1844         return r;
    1845     }
    1846 
    1847     if (uOptions & DPAS_INSERTAFTER) {
    1848         TRACE("-- ret=%d\n", l);
    1849         return l;
    1850     }
     1820        /* array is sorted --> use binary search */
     1821        INT l, r, x, n;
     1822        LPVOID *lpPtr;
     1823
     1824        TRACE("binary search\n");
     1825
     1826        l = (nStart == -1) ? 0 : nStart;
     1827        r = hdpa->nItemCount - 1;
     1828        lpPtr = hdpa->ptrs;
     1829        while (r >= l) {
     1830            x = (l + r) / 2;
     1831            n = (pfnCompare)(pFind, lpPtr[x], lParam);
     1832            if (n < 0)
     1833                r = x - 1;
     1834            else
     1835                l = x + 1;
     1836            if (n == 0) {
     1837                TRACE("-- ret=%d\n", n);
     1838                return n;
     1839            }
     1840        }
     1841
     1842        if (uOptions & DPAS_INSERTBEFORE) {
     1843            TRACE("-- ret=%d\n", r);
     1844            return r;
     1845        }
     1846
     1847        if (uOptions & DPAS_INSERTAFTER) {
     1848            TRACE("-- ret=%d\n", l);
     1849            return l;
     1850        }
    18511851    }
    18521852    else {
    1853     /* array is not sorted --> use linear search */
    1854     LPVOID *lpPtr;
    1855     INT  nIndex;
    1856 
    1857     TRACE("linear search\n");
    1858 
    1859     nIndex = (nStart == -1)? 0 : nStart;
    1860     lpPtr = hdpa->ptrs;
    1861     for (; nIndex < hdpa->nItemCount; nIndex++) {
    1862         if ((pfnCompare)(pFind, lpPtr[nIndex], lParam) == 0) {
    1863         TRACE("-- ret=%d\n", nIndex);
    1864         return nIndex;
    1865         }
    1866     }
     1853        /* array is not sorted --> use linear search */
     1854        LPVOID *lpPtr;
     1855        INT  nIndex;
     1856
     1857        TRACE("linear search\n");
     1858       
     1859        nIndex = (nStart == -1)? 0 : nStart;
     1860        lpPtr = hdpa->ptrs;
     1861        for (; nIndex < hdpa->nItemCount; nIndex++) {
     1862            if ((pfnCompare)(pFind, lpPtr[nIndex], lParam) == 0) {
     1863                TRACE("-- ret=%d\n", nIndex);
     1864                return nIndex;
     1865            }
     1866        }
    18671867    }
    18681868
     
    18941894
    18951895    if (hHeap)
    1896     hdpa = (HDPA)HeapAlloc (hHeap, HEAP_ZERO_MEMORY, sizeof(DPA));
     1896        hdpa = (HDPA)HeapAlloc (hHeap, HEAP_ZERO_MEMORY, sizeof(DPA));
    18971897    else
    1898     hdpa = (HDPA)COMCTL32_Alloc (sizeof(DPA));
     1898        hdpa = (HDPA)COMCTL32_Alloc (sizeof(DPA));
    18991899
    19001900    if (hdpa) {
    1901     hdpa->nGrow = min(8, nGrow);
    1902     hdpa->hHeap = hHeap ? hHeap : COMCTL32_hHeap;
    1903     hdpa->nMaxCount = hdpa->nGrow * 2;
    1904     hdpa->ptrs =
    1905         (LPVOID*)HeapAlloc (hHeap, HEAP_ZERO_MEMORY,
    1906                 hdpa->nMaxCount * sizeof(LPVOID));
     1901        hdpa->nGrow = min(8, nGrow);
     1902        hdpa->hHeap = hHeap ? hHeap : COMCTL32_hHeap;
     1903        hdpa->nMaxCount = hdpa->nGrow * 2;
     1904        hdpa->ptrs =
     1905            (LPVOID*)HeapAlloc (hHeap, HEAP_ZERO_MEMORY,
     1906                                hdpa->nMaxCount * sizeof(LPVOID));
    19071907    }
    19081908
     
    19401940
    19411941    TRACE("(0x%04x 0x%04x %d %p 0x%08lx)\n",
    1942        lpNotify->hwndFrom, lpNotify->hwndTo, uCode, lpHdr,
    1943        lpNotify->dwParam5);
     1942           lpNotify->hwndFrom, lpNotify->hwndTo, uCode, lpHdr,
     1943           lpNotify->dwParam5);
    19441944
    19451945    if (!lpNotify->hwndTo)
    1946     return 0;
     1946        return 0;
    19471947
    19481948    if (lpNotify->hwndFrom == -1) {
    1949     lpNmh = lpHdr;
    1950     idFrom = lpHdr->idFrom;
     1949        lpNmh = lpHdr;
     1950        idFrom = lpHdr->idFrom;
    19511951    }
    19521952    else {
    1953     if (lpNotify->hwndFrom) {
    1954         HWND hwndParent = GetParent (lpNotify->hwndFrom);
    1955         if (hwndParent) {
    1956         hwndParent = GetWindow (lpNotify->hwndFrom, GW_OWNER);
    1957         if (hwndParent)
    1958             idFrom = GetDlgCtrlID (lpNotify->hwndFrom);
    1959         }
    1960     }
    1961 
    1962     lpNmh = (lpHdr) ? lpHdr : &nmhdr;
    1963 
    1964     lpNmh->hwndFrom = lpNotify->hwndFrom;
    1965     lpNmh->idFrom = idFrom;
    1966     lpNmh->code = uCode;
     1953        if (lpNotify->hwndFrom) {
     1954            HWND hwndParent = GetParent (lpNotify->hwndFrom);
     1955            if (hwndParent) {
     1956                hwndParent = GetWindow (lpNotify->hwndFrom, GW_OWNER);
     1957                if (hwndParent)
     1958                    idFrom = GetDlgCtrlID (lpNotify->hwndFrom);
     1959            }
     1960        }
     1961
     1962        lpNmh = (lpHdr) ? lpHdr : &nmhdr;
     1963
     1964        lpNmh->hwndFrom = lpNotify->hwndFrom;
     1965        lpNmh->idFrom = idFrom;
     1966        lpNmh->code = uCode;
    19671967    }
    19681968
     
    19871987LRESULT WINAPI
    19881988COMCTL32_SendNotify (HWND hwndFrom, HWND hwndTo,
    1989              UINT uCode, LPNMHDR lpHdr)
     1989                     UINT uCode, LPNMHDR lpHdr)
    19901990{
    19911991    NOTIFYDATA notify;
    19921992
    19931993    TRACE("(0x%04x 0x%04x %d %p)\n",
    1994        hwndFrom, hwndTo, uCode, lpHdr);
     1994           hwndFrom, hwndTo, uCode, lpHdr);
    19951995
    19961996    notify.hwndFrom = hwndFrom;
     
    20202020LRESULT WINAPI
    20212021COMCTL32_SendNotifyEx (HWND hwndTo, HWND hwndFrom, UINT uCode,
    2022                LPNMHDR lpHdr, DWORD dwParam5)
     2022                       LPNMHDR lpHdr, DWORD dwParam5)
    20232023{
    20242024    NOTIFYDATA notify;
     
    20262026
    20272027    TRACE("(0x%04x 0x%04x %d %p 0x%08lx)\n",
    2028        hwndFrom, hwndTo, uCode, lpHdr, dwParam5);
     2028           hwndFrom, hwndTo, uCode, lpHdr, dwParam5);
    20292029
    20302030    hwndNotify = hwndTo;
    20312031    if (!hwndTo) {
    2032     if (IsWindow (hwndFrom)) {
    2033         hwndNotify = GetParent (hwndFrom);
    2034         if (!hwndNotify)
    2035         return 0;
    2036     }
     2032        if (IsWindow (hwndFrom)) {
     2033            hwndNotify = GetParent (hwndFrom);
     2034            if (!hwndNotify)
     2035                return 0;
     2036        }
    20372037    }
    20382038
     
    20692069
    20702070    if (*lpStr2 == 0)
    2071     return ((LPSTR)lpStr1);
     2071        return ((LPSTR)lpStr1);
    20722072    len1 = 0;
    20732073    while (lpStr1[len1] != 0) ++len1;
     
    20752075    while (lpStr2[len2] != 0) ++len2;
    20762076    if (len2 == 0)
    2077     return ((LPSTR)(lpStr1 + len1));
     2077        return ((LPSTR)(lpStr1 + len1));
    20782078    first = tolower (*lpStr2);
    20792079    while (len1 >= len2) {
    2080     if (tolower(*lpStr1) == first) {
    2081         for (i = 1; i < len2; ++i)
    2082         if (tolower (lpStr1[i]) != tolower(lpStr2[i]))
    2083             break;
    2084         if (i >= len2)
    2085         return ((LPSTR)lpStr1);
     2080        if (tolower(*lpStr1) == first) {
     2081            for (i = 1; i < len2; ++i)
     2082                if (tolower (lpStr1[i]) != tolower(lpStr2[i]))
     2083                    break;
     2084            if (i >= len2)
     2085                return ((LPSTR)lpStr1);
    20862086        }
    2087     ++lpStr1; --len1;
     2087        ++lpStr1; --len1;
    20882088    }
    20892089    return (NULL);
     
    21162116 *
    21172117 * Enumerates all items in a dynamic pointer array.
     2118 *
     2119 * PARAMS
     2120 *     hdpa     [I] handle to the dynamic pointer array
     2121 *     enumProc [I]
     2122 *     lParam   [I]
     2123 *
     2124 * RETURNS
     2125 *     none
     2126 */
     2127
     2128VOID WINAPI
     2129DPA_EnumCallback (const HDPA hdpa, DPAENUMPROC enumProc, LPARAM lParam)
     2130{
     2131    INT i;
     2132
     2133    TRACE("(%p %p %08lx)\n", hdpa, enumProc, lParam);
     2134
     2135    if (!hdpa)
     2136        return;
     2137    if (hdpa->nItemCount <= 0)
     2138        return;
     2139
     2140    for (i = 0; i < hdpa->nItemCount; i++) {
     2141        if ((enumProc)(hdpa->ptrs[i], lParam) == 0)
     2142            return;
     2143    }
     2144
     2145    return;
     2146}
     2147
     2148
     2149/**************************************************************************
     2150 * DPA_DestroyCallback [COMCTL32.386]
     2151 *
     2152 * Enumerates all items in a dynamic pointer array and destroys it.
    21182153 *
    21192154 * PARAMS
     
    21232158 *
    21242159 * RETURNS
    2125  *     none
    2126  */
    2127 
    2128 VOID WINAPI
    2129 DPA_EnumCallback (const HDPA hdpa, DPAENUMPROC enumProc, LPARAM lParam)
    2130 {
    2131     INT i;
    2132 
    2133     TRACE("(%p %p %08lx)\n", hdpa, enumProc, lParam);
    2134 
    2135     if (!hdpa)
    2136     return;
    2137     if (hdpa->nItemCount <= 0)
    2138     return;
    2139 
    2140     for (i = 0; i < hdpa->nItemCount; i++) {
    2141     if ((enumProc)(hdpa->ptrs[i], lParam) == 0)
    2142         return;
    2143     }
    2144 
    2145     return;
    2146 }
    2147 
    2148 
    2149 /**************************************************************************
    2150  * DPA_DestroyCallback [COMCTL32.386]
    2151  *
    2152  * Enumerates all items in a dynamic pointer array and destroys it.
    2153  *
    2154  * PARAMS
    2155  *     hdpa     [I] handle to the dynamic pointer array
    2156  *     enumProc [I]
    2157  *     lParam   [I]
    2158  *
    2159  * RETURNS
    21602160 *     Success: TRUE
    21612161 *     Failure: FALSE
     
    21952195
    21962196    if (!hdsa)
    2197     return;
     2197        return;
    21982198    if (hdsa->nItemCount <= 0)
    2199     return;
     2199        return;
    22002200
    22012201    for (i = 0; i < hdsa->nItemCount; i++) {
    2202     LPVOID lpItem = DSA_GetItemPtr (hdsa, i);
    2203     if ((enumProc)(lpItem, lParam) == 0)
    2204         return;
     2202        LPVOID lpItem = DSA_GetItemPtr (hdsa, i);
     2203        if ((enumProc)(lpItem, lParam) == 0)
     2204            return;
    22052205    }
    22062206
     
    23012301        if (dbcs && lpStart[1] != HIBYTE(wMatch)) continue;
    23022302        lpGotIt = lpStart;
    2303     }
     2303    }   
    23042304    return (LPSTR)lpGotIt;
    23052305}
     
    23552355    if( strchrW(lpSet, *(WORD*)lpLoop))
    23562356      return (INT)(lpLoop-lpStr);
    2357 
     2357 
    23582358  return (INT)(lpLoop-lpStr);
    23592359}
     
    23992399
    24002400    if (IsWindow (hwnd) == FALSE)
    2401     return FALSE;
     2401        return FALSE;
    24022402
    24032403    if (b == 0)
    2404     return FALSE;
     2404        return FALSE;
    24052405
    24062406
  • trunk/src/comctl32/datetime.c

    r6705 r6709  
    3434        COMCTL32_HEADER header;
    3535#endif
    36     HWND hMonthCal;
    37     HWND hUpdown;
    38     SYSTEMTIME date;
    39     BOOL dateValid;
    40     HWND hwndCheckbut;
    41     RECT rcClient; /* rect around the edge of the window */
    42     RECT rcDraw; /* rect inside of the border */
    43     RECT checkbox;  /* checkbox allowing the control to be enabled/disabled */
    44     RECT calbutton; /* button that toggles the dropdown of the monthcal control */
    45     BOOL bCalDepressed; /* TRUE = cal button is depressed */
    46     int  select;
    47     HFONT hFont;
    48     int nrFieldsAllocated;
    49     int nrFields;
    50     int haveFocus;
    51     int *fieldspec;
    52     RECT *fieldRect;
    53     int  *buflen;
    54     char textbuf[256];
     36        HWND hMonthCal;
     37        HWND hUpdown;
     38        SYSTEMTIME date;
     39        BOOL dateValid;
     40        HWND hwndCheckbut;
     41        RECT rcClient; /* rect around the edge of the window */
     42        RECT rcDraw; /* rect inside of the border */
     43        RECT checkbox;  /* checkbox allowing the control to be enabled/disabled */
     44        RECT calbutton; /* button that toggles the dropdown of the monthcal control */
     45        BOOL bCalDepressed; /* TRUE = cal button is depressed */
     46        int  select;
     47        HFONT hFont;
     48        int nrFieldsAllocated;
     49        int nrFields;
     50        int haveFocus;
     51        int *fieldspec;
     52        RECT *fieldRect;
     53        int  *buflen;           
     54        char textbuf[256];
    5555        POINT monthcal_pos;
    5656} DATETIME_INFO, *LPDATETIME_INFO;
     
    6161/* this list of defines is closely related to `allowedformatchars' defined
    6262 * in datetime.c; the high nibble indicates the `base type' of the format
    63  * specifier.
     63 * specifier. 
    6464 * Do not change without first reading DATETIME_UseFormat.
    65  *
     65 * 
    6666 */
    6767
    68 #define DT_END_FORMAT      0
    69 #define ONEDIGITDAY     0x01
    70 #define TWODIGITDAY     0x02
    71 #define THREECHARDAY    0x03
     68#define DT_END_FORMAT      0 
     69#define ONEDIGITDAY     0x01
     70#define TWODIGITDAY     0x02
     71#define THREECHARDAY    0x03
    7272#define FULLDAY         0x04
    7373#define ONEDIGIT12HOUR  0x11
     
    9494#define FORMATCALLBACK  0x81      /* -> maximum of 0x80 callbacks possible */
    9595#define FORMATCALLMASK  0x80
    96 #define DT_STRING   0x0100
     96#define DT_STRING       0x0100
    9797
    9898#define DTHT_DATEFIELD  0xff      /* for hit-testing */
    9999
    100100#define DTHT_NONE     0
    101 #define DTHT_CHECKBOX 0x200 /* these should end at '00' , to make */
     101#define DTHT_CHECKBOX 0x200     /* these should end at '00' , to make */
    102102#define DTHT_MCPOPUP  0x300     /* & DTHT_DATEFIELD 0 when DATETIME_KeyDown */
    103103#define DTHT_GOTFOCUS 0x400     /* tests for date-fields */
     
    126126  if (!lParam) return GDT_NONE;
    127127
    128   if ((dwStyle & DTS_SHOWNONE) &&
     128  if ((dwStyle & DTS_SHOWNONE) && 
    129129       (SendMessageA (infoPtr->hwndCheckbut, BM_GETCHECK, 0, 0)))
    130130        return GDT_NONE;
     
    145145  if (!lParam) return 0;
    146146
    147   if (lParam==GDT_VALID)
    148     MONTHCAL_CopyTime (lprgSysTimeArray, &infoPtr->date);
     147  if (lParam==GDT_VALID) 
     148        MONTHCAL_CopyTime (lprgSysTimeArray, &infoPtr->date);
    149149  if (lParam==GDT_NONE) {
    150     infoPtr->dateValid=FALSE;
     150        infoPtr->dateValid=FALSE;
    151151    SendMessageA (infoPtr->hwndCheckbut, BM_SETCHECK, 0, 0);
    152     }
     152        }
    153153  return 1;
    154154}
     
    228228
    229229
    230 /*
    231    Split up a formattxt in actions.
     230/* 
     231   Split up a formattxt in actions. 
    232232   See ms documentation for the meaning of the letter codes/'specifiers'.
    233233
    234    Notes:
     234   Notes: 
    235235   *'dddddd' is handled as 'dddd' plus 'dd'.
    236    *unrecognized formats are strings (here given the type DT_STRING;
     236   *unrecognized formats are strings (here given the type DT_STRING; 
    237237   start of the string is encoded in lower bits of DT_STRING.
    238238   Therefore, 'string' ends finally up as '<show seconds>tring'.
     
    241241
    242242
    243 static void
     243static void 
    244244DATETIME_UseFormat (DATETIME_INFO *infoPtr, const char *formattxt)
    245245{
     
    256256
    257257 for (i=0; i<strlen (formattxt); i++)  {
    258     TRACE ("\n%d %c:",i, formattxt[i]);
    259     for (j=0; j<len; j++) {
    260         if (allowedformatchars[j]==formattxt[i]) {
    261             TRACE ("%c[%d,%x]",allowedformatchars[j], *nrFields,
    262                             infoPtr->fieldspec[*nrFields]);
    263             if ((*nrFields==0) && (infoPtr->fieldspec[*nrFields]==0)) {
    264                 infoPtr->fieldspec[*nrFields]=(j<<4) +1;
    265                 break;
    266             }
    267             if (infoPtr->fieldspec[*nrFields]>>4!=j) {
    268                 (*nrFields)++;
    269                 infoPtr->fieldspec[*nrFields]=(j<<4) +1;
    270                 break;
    271             }
    272             if ((infoPtr->fieldspec[*nrFields] & 0x0f)==maxrepetition[j]) {
    273                 (*nrFields)++;
    274                 infoPtr->fieldspec[*nrFields]=(j<<4) +1;
    275                 break;
    276             }
    277             infoPtr->fieldspec[*nrFields]++;
    278             break;
    279         }   /* if allowedformatchar */
    280     } /* for j */
    281 
    282 
    283             /* char is not a specifier: handle char like a string */
    284     if (j==len) {
    285         if ((*nrFields==0) && (infoPtr->fieldspec[*nrFields]==0)) {
    286             infoPtr->fieldspec[*nrFields]=DT_STRING+k;
    287             infoPtr->buflen[*nrFields]=0;
    288         } else
    289         if ((infoPtr->fieldspec[*nrFields] & DT_STRING)!=DT_STRING)  {
    290             (*nrFields)++;
    291             infoPtr->fieldspec[*nrFields]=DT_STRING+k;
    292             infoPtr->buflen[*nrFields]=0;
    293         }
    294         infoPtr->textbuf[k]=formattxt[i];
    295         k++;
    296         infoPtr->buflen[*nrFields]++;
    297     }   /* if j=len */
    298 
    299     if (*nrFields==infoPtr->nrFieldsAllocated) {
    300         FIXME ("out of memory; should reallocate. crash ahead.\n");
    301     }
     258        TRACE ("\n%d %c:",i, formattxt[i]);
     259        for (j=0; j<len; j++) {
     260                if (allowedformatchars[j]==formattxt[i]) {   
     261                        TRACE ("%c[%d,%x]",allowedformatchars[j], *nrFields,
     262                                                        infoPtr->fieldspec[*nrFields]);
     263                        if ((*nrFields==0) && (infoPtr->fieldspec[*nrFields]==0)) {
     264                                infoPtr->fieldspec[*nrFields]=(j<<4) +1;
     265                                break;
     266                        }
     267                        if (infoPtr->fieldspec[*nrFields]>>4!=j) {   
     268                                (*nrFields)++; 
     269                                infoPtr->fieldspec[*nrFields]=(j<<4) +1;
     270                                break;
     271                        }
     272                        if ((infoPtr->fieldspec[*nrFields] & 0x0f)==maxrepetition[j]) {
     273                                (*nrFields)++; 
     274                                infoPtr->fieldspec[*nrFields]=(j<<4) +1;
     275                                break;
     276                        }
     277                        infoPtr->fieldspec[*nrFields]++;
     278                        break;
     279                }   /* if allowedformatchar */
     280        } /* for j */
     281
     282
     283                        /* char is not a specifier: handle char like a string */
     284        if (j==len) {
     285                if ((*nrFields==0) && (infoPtr->fieldspec[*nrFields]==0)) {
     286                        infoPtr->fieldspec[*nrFields]=DT_STRING+k;
     287                        infoPtr->buflen[*nrFields]=0;
     288        } else 
     289                if ((infoPtr->fieldspec[*nrFields] & DT_STRING)!=DT_STRING)  {
     290                        (*nrFields)++;
     291                        infoPtr->fieldspec[*nrFields]=DT_STRING+k;
     292                        infoPtr->buflen[*nrFields]=0;
     293                }
     294                infoPtr->textbuf[k]=formattxt[i];
     295                k++;
     296                infoPtr->buflen[*nrFields]++;
     297        }   /* if j=len */
     298
     299        if (*nrFields==infoPtr->nrFieldsAllocated) {
     300                FIXME ("out of memory; should reallocate. crash ahead.\n");
     301        }
    302302
    303303  } /* for i */
     
    309309
    310310
    311 static LRESULT
     311static LRESULT 
    312312DATETIME_SetFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
    313313{
     
    318318 TRACE("%04x %08lx\n",wParam,lParam);
    319319 if (!lParam) {
    320     DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
    321 
    322     if (dwStyle & DTS_LONGDATEFORMAT)
    323         format_item=LOCALE_SLONGDATE;
    324     else if (dwStyle & DTS_TIMEFORMAT)
    325         format_item=LOCALE_STIMEFORMAT;
     320        DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
     321
     322        if (dwStyle & DTS_LONGDATEFORMAT)
     323                format_item=LOCALE_SLONGDATE;
     324        else if (dwStyle & DTS_TIMEFORMAT)
     325                format_item=LOCALE_STIMEFORMAT;
    326326        else /* DTS_SHORTDATEFORMAT */
    327         format_item=LOCALE_SSHORTDATE;
    328     GetLocaleInfoA( GetSystemDefaultLCID(), format_item,format_buf,sizeof(format_buf));
    329     DATETIME_UseFormat (infoPtr, format_buf);
    330  }
     327                format_item=LOCALE_SSHORTDATE;
     328        GetLocaleInfoA( GetSystemDefaultLCID(), format_item,format_buf,sizeof(format_buf));
     329        DATETIME_UseFormat (infoPtr, format_buf);
     330 }     
    331331 else
    332     DATETIME_UseFormat (infoPtr, (char *) lParam);
     332        DATETIME_UseFormat (infoPtr, (char *) lParam);
    333333
    334334 return infoPtr->nrFields;
     
    336336
    337337
    338 static LRESULT
     338static LRESULT 
    339339DATETIME_SetFormatW (HWND hwnd, WPARAM wParam, LPARAM lParam)
    340340
     
    342342 TRACE("%04x %08lx\n",wParam,lParam);
    343343 if (lParam) {
    344     LPSTR buf;
    345     int retval;
     344        LPSTR buf;
     345        int retval;
    346346        int len = WideCharToMultiByte( CP_ACP, 0, (LPWSTR)lParam, -1, NULL, 0, NULL, NULL );
    347347
    348     buf = (LPSTR) COMCTL32_Alloc (len);
     348        buf = (LPSTR) COMCTL32_Alloc (len);
    349349        WideCharToMultiByte( CP_ACP, 0, (LPWSTR)lParam, -1, buf, len, NULL, NULL );
    350     retval=DATETIME_SetFormat (hwnd, 0, (LPARAM) buf);
    351     COMCTL32_Free (buf);
    352     return retval;
    353  }
     350        retval=DATETIME_SetFormat (hwnd, 0, (LPARAM) buf);
     351        COMCTL32_Free (buf);
     352        return retval;
     353 } 
    354354 else
    355     return DATETIME_SetFormat (hwnd, 0, 0);
    356 
    357 }
    358 
    359 
    360 static void
     355        return DATETIME_SetFormat (hwnd, 0, 0);
     356
     357}
     358
     359
     360static void 
    361361DATETIME_ReturnTxt (DATETIME_INFO *infoPtr, int count, char *result)
    362362{
     
    368368 TRACE ("%d,%d\n", infoPtr->nrFields, count);
    369369 if ((count>infoPtr->nrFields) || (count<0)) {
    370     WARN ("buffer overrun, have %d want %d\n", infoPtr->nrFields, count);
    371     return;
     370        WARN ("buffer overrun, have %d want %d\n", infoPtr->nrFields, count);
     371        return;
    372372 }
    373373
    374374 if (!infoPtr->fieldspec) return;
    375 
     375 
    376376 spec=infoPtr->fieldspec[count];
    377377 if (spec & DT_STRING) {
    378     int txtlen=infoPtr->buflen[count];
    379 
    380     strncpy (result, infoPtr->textbuf + (spec &~ DT_STRING), txtlen);
    381     result[txtlen]=0;
    382     TRACE ("arg%d=%x->[%s]\n",count,infoPtr->fieldspec[count],result);
    383     return;
     378        int txtlen=infoPtr->buflen[count];
     379
     380        strncpy (result, infoPtr->textbuf + (spec &~ DT_STRING), txtlen);
     381        result[txtlen]=0;
     382        TRACE ("arg%d=%x->[%s]\n",count,infoPtr->fieldspec[count],result);
     383        return;
    384384 }
    385385
    386 
     386               
    387387 switch (spec) {
    388     case DT_END_FORMAT:
    389         *result=0;
    390         break;
    391     case ONEDIGITDAY:
    392         sprintf (result,"%d",date.wDay);
    393         break;
    394     case TWODIGITDAY:
    395         sprintf (result,"%.2d",date.wDay);
    396         break;
    397     case THREECHARDAY:
    398             GetLocaleInfoA( LOCALE_USER_DEFAULT, LOCALE_SABBREVDAYNAME1+(date.wDayOfWeek+6)%7,
    399                 result,4);
    400         /*sprintf (result,"%.3s",days[date.wDayOfWeek]);*/
    401         break;
    402     case FULLDAY:
    403             GetLocaleInfoA( LOCALE_USER_DEFAULT,LOCALE_SDAYNAME1+ (date.wDayOfWeek+6)%7,
    404                 buffer,sizeof(buffer));
    405         strcpy  (result,buffer);
    406         break;
    407     case ONEDIGIT12HOUR:
    408         if (date.wHour>12)
    409             sprintf (result,"%d",date.wHour-12);
    410         else
    411             sprintf (result,"%d",date.wHour);
    412         break;
    413     case TWODIGIT12HOUR:
    414         if (date.wHour>12)
    415             sprintf (result,"%.2d",date.wHour-12);
    416         else
    417             sprintf (result,"%.2d",date.wHour);
    418         break;
    419     case ONEDIGIT24HOUR:
    420         sprintf (result,"%d",date.wHour);
    421         break;
    422     case TWODIGIT24HOUR:
    423         sprintf (result,"%.2d",date.wHour);
    424         break;
    425     case ONEDIGITSECOND:
    426         sprintf (result,"%d",date.wSecond);
    427         break;
    428     case TWODIGITSECOND:
    429         sprintf (result,"%.2d",date.wSecond);
    430         break;
    431     case ONEDIGITMINUTE:
    432         sprintf (result,"%d",date.wMinute);
    433         break;
    434     case TWODIGITMINUTE:
    435         sprintf (result,"%.2d",date.wMinute);
    436         break;
    437     case ONEDIGITMONTH:
    438         sprintf (result,"%d",date.wMonth);
    439         break;
    440     case TWODIGITMONTH:
    441         sprintf (result,"%.2d",date.wMonth);
    442         break;
    443     case THREECHARMONTH:
    444         GetLocaleInfoA( GetSystemDefaultLCID(),LOCALE_SMONTHNAME1+date.wMonth -1,
    445           buffer,sizeof(buffer));
    446         sprintf (result,"%.3s",buffer);
    447         break;
    448     case FULLMONTH:
    449         GetLocaleInfoA( GetSystemDefaultLCID(),LOCALE_SMONTHNAME1+date.wMonth -1,
     388        case DT_END_FORMAT:
     389                *result=0;
     390                break;
     391        case ONEDIGITDAY:
     392                sprintf (result,"%d",date.wDay);
     393                break;
     394        case TWODIGITDAY:
     395                sprintf (result,"%.2d",date.wDay);
     396                break;
     397        case THREECHARDAY:
     398                GetLocaleInfoA( LOCALE_USER_DEFAULT, LOCALE_SABBREVDAYNAME1+(date.wDayOfWeek+6)%7,
     399                                result,4);
     400                /*sprintf (result,"%.3s",days[date.wDayOfWeek]);*/
     401                break;
     402        case FULLDAY:
     403                GetLocaleInfoA( LOCALE_USER_DEFAULT,LOCALE_SDAYNAME1+ (date.wDayOfWeek+6)%7,
     404                                buffer,sizeof(buffer));
     405                strcpy  (result,buffer);
     406                break;
     407        case ONEDIGIT12HOUR:
     408                if (date.wHour>12)
     409                        sprintf (result,"%d",date.wHour-12);
     410                else
     411                        sprintf (result,"%d",date.wHour);
     412                break;
     413        case TWODIGIT12HOUR:
     414                if (date.wHour>12)
     415                        sprintf (result,"%.2d",date.wHour-12);
     416                else
     417                        sprintf (result,"%.2d",date.wHour);
     418                break;
     419        case ONEDIGIT24HOUR:
     420                sprintf (result,"%d",date.wHour);
     421                break;
     422        case TWODIGIT24HOUR:
     423                sprintf (result,"%.2d",date.wHour);
     424                break;
     425        case ONEDIGITSECOND:
     426                sprintf (result,"%d",date.wSecond);
     427                break;
     428        case TWODIGITSECOND:
     429                sprintf (result,"%.2d",date.wSecond);
     430                break;
     431        case ONEDIGITMINUTE:
     432                sprintf (result,"%d",date.wMinute);
     433                break;
     434        case TWODIGITMINUTE:
     435                sprintf (result,"%.2d",date.wMinute);
     436                break;
     437        case ONEDIGITMONTH:
     438                sprintf (result,"%d",date.wMonth);
     439                break;
     440        case TWODIGITMONTH:
     441                sprintf (result,"%.2d",date.wMonth);
     442                break;
     443        case THREECHARMONTH:
     444                GetLocaleInfoA( GetSystemDefaultLCID(),LOCALE_SMONTHNAME1+date.wMonth -1,
     445                  buffer,sizeof(buffer));
     446                sprintf (result,"%.3s",buffer);
     447                break;
     448        case FULLMONTH:   
     449                GetLocaleInfoA( GetSystemDefaultLCID(),LOCALE_SMONTHNAME1+date.wMonth -1,
    450450#ifdef __WIN32OS2__
    451                 buffer,sizeof(buffer));
    452         strcpy  (result,buffer);
     451                                buffer,sizeof(buffer));
     452                strcpy  (result,buffer);
    453453#else
    454           result,sizeof(result));
     454                  result,sizeof(result));
    455455#endif
    456         break;
    457     case ONELETTERAMPM:
    458         if (date.wHour<12)
    459             strcpy (result,"A");
    460         else
    461             strcpy (result,"P");
    462         break;
    463     case TWOLETTERAMPM:
    464         if (date.wHour<12)
    465             strcpy (result,"AM");
    466         else
    467             strcpy (result,"PM");
    468         break;
    469     case FORMATCALLBACK:
    470         FIXME ("Not implemented\n");
    471         strcpy (result,"xxx");
    472         break;
    473     case ONEDIGITYEAR:
    474         sprintf (result,"%d",date.wYear-10* (int) floor(date.wYear/10));
    475         break;
    476     case TWODIGITYEAR:
    477         sprintf (result,"%.2d",date.wYear-100* (int) floor(date.wYear/100));
    478         break;
    479     case FULLYEAR:
    480         sprintf (result,"%d",date.wYear);
    481         break;
     456                break;
     457        case ONELETTERAMPM:   
     458                if (date.wHour<12)
     459                        strcpy (result,"A");
     460                else
     461                        strcpy (result,"P");
     462                break;
     463        case TWOLETTERAMPM:   
     464                if (date.wHour<12)
     465                        strcpy (result,"AM");
     466                else
     467                        strcpy (result,"PM");
     468                break;
     469        case FORMATCALLBACK:   
     470                FIXME ("Not implemented\n");
     471                strcpy (result,"xxx");
     472                break;
     473        case ONEDIGITYEAR:
     474                sprintf (result,"%d",date.wYear-10* (int) floor(date.wYear/10));
     475                break;
     476        case TWODIGITYEAR:
     477                sprintf (result,"%.2d",date.wYear-100* (int) floor(date.wYear/100));
     478                break;
     479        case FULLYEAR:   
     480                sprintf (result,"%d",date.wYear);
     481                break;
    482482    }
    483 
    484     TRACE ("arg%d=%x->[%s]\n",count,infoPtr->fieldspec[count],result);
    485 }
    486 
    487 
    488 static void
     483       
     484        TRACE ("arg%d=%x->[%s]\n",count,infoPtr->fieldspec[count],result);
     485}
     486
     487
     488static void 
    489489DATETIME_IncreaseField (DATETIME_INFO *infoPtr, int number)
    490490{
     
    497497 spec=infoPtr->fieldspec[number];
    498498 if ((spec & DTHT_DATEFIELD)==0) return;
    499 
     499               
    500500 switch (spec) {
    501     case ONEDIGITDAY:
    502     case TWODIGITDAY:
    503     case THREECHARDAY:
    504     case FULLDAY:
    505         date->wDay++;
    506         if (date->wDay>MONTHCAL_MonthLength(date->wMonth,date->wYear))
    507           date->wDay=1;
    508         break;
    509     case ONEDIGIT12HOUR:
    510     case TWODIGIT12HOUR:
    511     case ONEDIGIT24HOUR:
    512     case TWODIGIT24HOUR:
    513         date->wHour++;
    514         if (date->wHour>23) date->wHour=0;
    515         break;
    516     case ONEDIGITSECOND:
    517     case TWODIGITSECOND:
    518         date->wSecond++;
    519         if (date->wSecond>59) date->wSecond=0;
    520         break;
    521     case ONEDIGITMINUTE:
    522     case TWODIGITMINUTE:
    523         date->wMinute++;
    524         if (date->wMinute>59) date->wMinute=0;
    525         break;
    526     case ONEDIGITMONTH:
    527     case TWODIGITMONTH:
    528     case THREECHARMONTH:
    529     case FULLMONTH:
    530         date->wMonth++;
    531         if (date->wMonth>12) date->wMonth=1;
    532         if (date->wDay>MONTHCAL_MonthLength(date->wMonth,date->wYear))
    533             date->wDay=MONTHCAL_MonthLength(date->wMonth,date->wYear);
    534         break;
    535     case ONELETTERAMPM:
    536     case TWOLETTERAMPM:
    537         date->wHour+=12;
    538         if (date->wHour>23) date->wHour-=24;
    539         break;
    540     case FORMATCALLBACK:
    541         FIXME ("Not implemented\n");
    542         break;
    543     case ONEDIGITYEAR:
    544     case TWODIGITYEAR:
    545     case FULLYEAR:
    546         date->wYear++;
    547         break;
    548     }
    549 
    550 }
    551 
    552 
    553 static void
     501        case ONEDIGITDAY:
     502        case TWODIGITDAY:
     503        case THREECHARDAY:
     504        case FULLDAY:
     505                date->wDay++;
     506                if (date->wDay>MONTHCAL_MonthLength(date->wMonth,date->wYear))
     507                  date->wDay=1;
     508                break;
     509        case ONEDIGIT12HOUR:
     510        case TWODIGIT12HOUR:
     511        case ONEDIGIT24HOUR:
     512        case TWODIGIT24HOUR:
     513                date->wHour++;
     514                if (date->wHour>23) date->wHour=0;
     515                break;
     516        case ONEDIGITSECOND:
     517        case TWODIGITSECOND:
     518                date->wSecond++;
     519                if (date->wSecond>59) date->wSecond=0;
     520                break;
     521        case ONEDIGITMINUTE:
     522        case TWODIGITMINUTE:
     523                date->wMinute++;
     524                if (date->wMinute>59) date->wMinute=0;
     525                break;
     526        case ONEDIGITMONTH:
     527        case TWODIGITMONTH:
     528        case THREECHARMONTH:
     529        case FULLMONTH:   
     530                date->wMonth++;
     531                if (date->wMonth>12) date->wMonth=1;
     532                if (date->wDay>MONTHCAL_MonthLength(date->wMonth,date->wYear))
     533                        date->wDay=MONTHCAL_MonthLength(date->wMonth,date->wYear);
     534                break;
     535        case ONELETTERAMPM:   
     536        case TWOLETTERAMPM:   
     537                date->wHour+=12;
     538                if (date->wHour>23) date->wHour-=24;
     539                break;
     540        case FORMATCALLBACK:   
     541                FIXME ("Not implemented\n");
     542                break;
     543        case ONEDIGITYEAR:
     544        case TWODIGITYEAR:
     545        case FULLYEAR:   
     546                date->wYear++;
     547                break;
     548        }
     549
     550}
     551
     552
     553static void 
    554554DATETIME_DecreaseField (DATETIME_INFO *infoPtr, int number)
    555555{
     
    562562 spec = infoPtr->fieldspec[number];
    563563 if ((spec & DTHT_DATEFIELD)==0) return;
    564 
     564               
    565565 TRACE ("%x\n",spec);
    566566
    567567 switch (spec) {
    568     case ONEDIGITDAY:
    569     case TWODIGITDAY:
    570     case THREECHARDAY:
    571     case FULLDAY:
    572         date->wDay--;
    573         if (date->wDay<1)
    574           date->wDay=MONTHCAL_MonthLength(date->wMonth,date->wYear);
    575         break;
    576     case ONEDIGIT12HOUR:
    577     case TWODIGIT12HOUR:
    578     case ONEDIGIT24HOUR:
    579     case TWODIGIT24HOUR:
    580         if (date->wHour)
    581             date->wHour--;
    582         else
    583             date->wHour=23;
    584         break;
    585     case ONEDIGITSECOND:
    586     case TWODIGITSECOND:
    587         if (date->wHour)
    588             date->wSecond--;
    589         else
    590             date->wHour=59;
    591         break;
    592     case ONEDIGITMINUTE:
    593     case TWODIGITMINUTE:
    594         if (date->wMinute)
    595             date->wMinute--;
    596         else
    597             date->wMinute=59;
    598         break;
    599     case ONEDIGITMONTH:
    600     case TWODIGITMONTH:
    601     case THREECHARMONTH:
    602     case FULLMONTH:
    603         if (date->wMonth>1)
    604             date->wMonth--;
    605         else
    606             date->wMonth=12;
    607         if (date->wDay>MONTHCAL_MonthLength(date->wMonth,date->wYear))
    608             date->wDay=MONTHCAL_MonthLength(date->wMonth,date->wYear);
    609         break;
    610     case ONELETTERAMPM:
    611     case TWOLETTERAMPM:
    612         if (date->wHour<12)
    613             date->wHour+=12;
    614         else
    615             date->wHour-=12;
    616         break;
    617     case FORMATCALLBACK:
    618         FIXME ("Not implemented\n");
    619         break;
    620     case ONEDIGITYEAR:
    621     case TWODIGITYEAR:
    622     case FULLYEAR:
    623         date->wYear--;
    624         break;
    625     }
    626 
    627 }
    628 
    629 
    630 static void
     568        case ONEDIGITDAY:
     569        case TWODIGITDAY:
     570        case THREECHARDAY:
     571        case FULLDAY:
     572                date->wDay--;
     573                if (date->wDay<1)
     574                  date->wDay=MONTHCAL_MonthLength(date->wMonth,date->wYear);
     575                break;
     576        case ONEDIGIT12HOUR:
     577        case TWODIGIT12HOUR:
     578        case ONEDIGIT24HOUR:
     579        case TWODIGIT24HOUR:
     580                if (date->wHour)
     581                        date->wHour--;
     582                else
     583                        date->wHour=23;
     584                break;
     585        case ONEDIGITSECOND:
     586        case TWODIGITSECOND:
     587                if (date->wHour)
     588                        date->wSecond--;
     589                else
     590                        date->wHour=59;
     591                break;
     592        case ONEDIGITMINUTE:
     593        case TWODIGITMINUTE:
     594                if (date->wMinute)
     595                        date->wMinute--;
     596                else
     597                        date->wMinute=59;
     598                break;
     599        case ONEDIGITMONTH:
     600        case TWODIGITMONTH:
     601        case THREECHARMONTH:
     602        case FULLMONTH:   
     603                if (date->wMonth>1)
     604                        date->wMonth--;
     605                else
     606                        date->wMonth=12;
     607                if (date->wDay>MONTHCAL_MonthLength(date->wMonth,date->wYear))
     608                        date->wDay=MONTHCAL_MonthLength(date->wMonth,date->wYear);
     609                break;
     610        case ONELETTERAMPM:   
     611        case TWOLETTERAMPM:   
     612                if (date->wHour<12)
     613                        date->wHour+=12;
     614                else
     615                        date->wHour-=12;
     616                break;
     617        case FORMATCALLBACK:   
     618                FIXME ("Not implemented\n");
     619                break;
     620        case ONEDIGITYEAR:
     621        case TWODIGITYEAR:
     622        case FULLYEAR:   
     623                date->wYear--;
     624                break;
     625        }
     626
     627}
     628
     629
     630static void 
    631631DATETIME_ResetFieldDown (DATETIME_INFO *infoPtr, int number)
    632632{
     
    639639 spec = infoPtr->fieldspec[number];
    640640 if ((spec & DTHT_DATEFIELD)==0) return;
    641 
     641               
    642642
    643643 switch (spec) {
    644     case ONEDIGITDAY:
    645     case TWODIGITDAY:
    646     case THREECHARDAY:
    647     case FULLDAY:
    648         date->wDay = 1;
    649         break;
    650     case ONEDIGIT12HOUR:
    651     case TWODIGIT12HOUR:
    652     case ONEDIGIT24HOUR:
    653     case TWODIGIT24HOUR:
    654     case ONELETTERAMPM:
    655     case TWOLETTERAMPM:
    656         date->wHour = 0;
    657         break;
    658     case ONEDIGITSECOND:
    659     case TWODIGITSECOND:
    660         date->wSecond = 0;
    661         break;
    662     case ONEDIGITMINUTE:
    663     case TWODIGITMINUTE:
    664         date->wMinute = 0;
    665         break;
    666     case ONEDIGITMONTH:
    667     case TWODIGITMONTH:
    668     case THREECHARMONTH:
    669     case FULLMONTH:
    670         date->wMonth = 1;
    671     case FORMATCALLBACK:
    672         FIXME ("Not implemented\n");
    673         break;
    674     case ONEDIGITYEAR:
    675     case TWODIGITYEAR:
     644        case ONEDIGITDAY:
     645        case TWODIGITDAY:
     646        case THREECHARDAY:
     647        case FULLDAY:
     648                date->wDay = 1;
     649                break;
     650        case ONEDIGIT12HOUR:
     651        case TWODIGIT12HOUR:
     652        case ONEDIGIT24HOUR:
     653        case TWODIGIT24HOUR:
     654        case ONELETTERAMPM:   
     655        case TWOLETTERAMPM:   
     656                date->wHour = 0;
     657                break;
     658        case ONEDIGITSECOND:
     659        case TWODIGITSECOND:
     660                date->wSecond = 0;
     661                break;
     662        case ONEDIGITMINUTE:
     663        case TWODIGITMINUTE:
     664                date->wMinute = 0;
     665                break;
     666        case ONEDIGITMONTH:
     667        case TWODIGITMONTH:
     668        case THREECHARMONTH:
     669        case FULLMONTH:   
     670                date->wMonth = 1;
     671        case FORMATCALLBACK:   
     672                FIXME ("Not implemented\n");
     673                break;
     674        case ONEDIGITYEAR:
     675        case TWODIGITYEAR:
    676676        /* FYI: On 9/14/1752 the calender changed and England and the American */
    677677        /* colonies changed to the Gregorian calender.  This change involved */
    678678        /* having September 14th following September 2nd.  So no date algorithms */
    679679        /* work before that date. */
    680     case FULLYEAR:
    681         date->wSecond = 0;
    682         date->wMinute = 0;
    683         date->wHour = 0;
    684         date->wDay = 14;        /* overactive ms-programmers..*/
    685         date->wMonth = 9;
    686         date->wYear = 1752;
    687         break;
    688     }
    689 
    690 }
    691 
    692 
    693 static void
     680        case FULLYEAR:   
     681                date->wSecond = 0;
     682                date->wMinute = 0;
     683                date->wHour = 0;
     684                date->wDay = 14;                /* overactive ms-programmers..*/
     685                date->wMonth = 9;
     686                date->wYear = 1752;
     687                break;
     688        }
     689
     690}
     691
     692
     693static void 
    694694DATETIME_ResetFieldUp (DATETIME_INFO *infoPtr, int number)
    695695{
     
    702702 spec=infoPtr->fieldspec[number];
    703703 if ((spec & DTHT_DATEFIELD)==0) return;
    704 
     704               
    705705 switch (spec) {
    706     case ONEDIGITDAY:
    707     case TWODIGITDAY:
    708     case THREECHARDAY:
    709     case FULLDAY:
    710         date->wDay=MONTHCAL_MonthLength(date->wMonth,date->wYear);
    711         break;
    712     case ONEDIGIT12HOUR:
    713     case TWODIGIT12HOUR:
    714     case ONEDIGIT24HOUR:
    715     case TWODIGIT24HOUR:
    716     case ONELETTERAMPM:
    717     case TWOLETTERAMPM:
    718         date->wHour=23;
    719         break;
    720     case ONEDIGITSECOND:
    721     case TWODIGITSECOND:
    722         date->wSecond=59;
    723         break;
    724     case ONEDIGITMINUTE:
    725     case TWODIGITMINUTE:
    726         date->wMinute=59;
    727         break;
    728     case ONEDIGITMONTH:
    729     case TWODIGITMONTH:
    730     case THREECHARMONTH:
    731     case FULLMONTH:
    732         date->wMonth=12;
    733     case FORMATCALLBACK:
    734         FIXME ("Not implemented\n");
    735         break;
    736     case ONEDIGITYEAR:
    737     case TWODIGITYEAR:
    738     case FULLYEAR:
    739         date->wYear=9999;    /* Y10K problem? naaah. */
    740         break;
    741     }
     706        case ONEDIGITDAY:
     707        case TWODIGITDAY:
     708        case THREECHARDAY:
     709        case FULLDAY:
     710                date->wDay=MONTHCAL_MonthLength(date->wMonth,date->wYear);
     711                break;
     712        case ONEDIGIT12HOUR:
     713        case TWODIGIT12HOUR:
     714        case ONEDIGIT24HOUR:
     715        case TWODIGIT24HOUR:
     716        case ONELETTERAMPM:   
     717        case TWOLETTERAMPM:   
     718                date->wHour=23;
     719                break;
     720        case ONEDIGITSECOND:
     721        case TWODIGITSECOND:
     722                date->wSecond=59;
     723                break;
     724        case ONEDIGITMINUTE:
     725        case TWODIGITMINUTE:
     726                date->wMinute=59;
     727                break;
     728        case ONEDIGITMONTH:
     729        case TWODIGITMONTH:
     730        case THREECHARMONTH:
     731        case FULLMONTH:   
     732                date->wMonth=12;
     733        case FORMATCALLBACK:   
     734                FIXME ("Not implemented\n");
     735                break;
     736        case ONEDIGITYEAR:
     737        case TWODIGITYEAR:
     738        case FULLYEAR:   
     739                date->wYear=9999;    /* Y10K problem? naaah. */
     740                break;
     741        }
    742742
    743743}
     
    758758  SIZE size;
    759759  COLORREF oldBk, oldTextColor;
    760 
     760 
    761761  /* draw control edge */
    762762  TRACE("\n");
     
    764764  FillRect(hdc, rcClient, hbr);
    765765  DrawEdge(hdc, rcClient, EDGE_SUNKEN, BF_RECT);
    766   DeleteObject(hbr);
    767 
     766  DeleteObject(hbr);   
     767       
    768768  if (infoPtr->dateValid) {
    769769    char txt[80];
     
    798798              DT_RIGHT | DT_VCENTER | DT_SINGLELINE );
    799799        SetBkColor (hdc, oldBk);
    800         SetTextColor (hdc, oldTextColor);
     800                SetTextColor (hdc, oldTextColor);
    801801      }
    802802      else
     
    832832    if (PtInRect (&infoPtr->fieldRect[i], pt)) {
    833833      retval = i;
    834       TRACE("Hit in date text in field %d\n", i);
     834      TRACE("Hit in date text in field %d\n", i);           
    835835      break;
    836836    }
     
    845845DATETIME_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
    846846{
    847   DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
     847  DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 
    848848  DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
    849849  int old, new;
     
    874874      infoPtr->monthcal_pos.x = infoPtr->rcClient.right - ((infoPtr->calbutton.right -
    875875                                infoPtr->calbutton.left) + 145);
    876     else
     876    else 
    877877      infoPtr->monthcal_pos.x = 8;
    878878
     
    888888
    889889    TRACE ("dt:%x mc:%x mc parent:%x, desktop:%x, mcpp:%x\n",
    890               hwnd,infoPtr->hMonthCal,
     890              hwnd,infoPtr->hMonthCal, 
    891891              GetParent (infoPtr->hMonthCal),
    892892              GetDesktopWindow (),
     
    904904DATETIME_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
    905905{
    906   DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
     906  DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 
    907907
    908908  TRACE("\n");
    909 
     909 
    910910  if(infoPtr->bCalDepressed == TRUE) {
    911911    infoPtr->bCalDepressed = FALSE;
     
    934934DATETIME_ParentNotify (HWND hwnd, WPARAM wParam, LPARAM lParam)
    935935{
    936  DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
     936 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);   
    937937 LPNMHDR lpnmh = (LPNMHDR) lParam;
    938938
     
    954954
    955955{
    956  DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
     956 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);   
    957957 LPNMHDR lpnmh = (LPNMHDR) lParam;
    958958
     
    964964
    965965
    966 static LRESULT
     966static LRESULT 
    967967DATETIME_KeyDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
    968968{
     
    978978
    979979 if (infoPtr->select & FORMATCALLMASK) {
    980     FIXME ("Callbacks not implemented yet\n");
     980        FIXME ("Callbacks not implemented yet\n");
    981981 }
    982982
    983983 switch (wParam) {
    984     case VK_ADD:
    985         case VK_UP:
    986         DATETIME_IncreaseField (infoPtr,FieldNum);
    987         DATETIME_SendDateTimeChangeNotify (hwnd);
    988         break;
    989     case VK_SUBTRACT:
    990     case VK_DOWN:
    991         DATETIME_DecreaseField (infoPtr,FieldNum);
    992         DATETIME_SendDateTimeChangeNotify (hwnd);
    993         break;
    994     case VK_HOME:
    995         DATETIME_ResetFieldDown (infoPtr,FieldNum);
    996         DATETIME_SendDateTimeChangeNotify (hwnd);
    997         break;
    998     case VK_END:
    999         DATETIME_ResetFieldUp(infoPtr,FieldNum);
    1000         DATETIME_SendDateTimeChangeNotify (hwnd);
    1001         break;
    1002     case VK_LEFT:
    1003         do {
    1004             if (infoPtr->select==0) {
    1005                 infoPtr->select = infoPtr->nrFields - 1;
    1006                 wrap++;
    1007             } else
    1008             infoPtr->select--;
    1009         }
    1010         while ((infoPtr->fieldspec[infoPtr->select] & DT_STRING) && (wrap<2));
    1011         break;
    1012     case VK_RIGHT:
    1013         do {
    1014             infoPtr->select++;
    1015             if (infoPtr->select==infoPtr->nrFields) {
    1016                 infoPtr->select = 0;
    1017                 wrap++;
    1018             }
    1019             }
    1020         while ((infoPtr->fieldspec[infoPtr->select] & DT_STRING) && (wrap<2));
    1021         break;
     984        case VK_ADD:
     985        case VK_UP:
     986                DATETIME_IncreaseField (infoPtr,FieldNum);
     987                DATETIME_SendDateTimeChangeNotify (hwnd);
     988                break;
     989        case VK_SUBTRACT:
     990        case VK_DOWN:
     991                DATETIME_DecreaseField (infoPtr,FieldNum);
     992                DATETIME_SendDateTimeChangeNotify (hwnd);
     993                break;
     994        case VK_HOME:
     995                DATETIME_ResetFieldDown (infoPtr,FieldNum);
     996                DATETIME_SendDateTimeChangeNotify (hwnd);
     997                break;
     998        case VK_END:
     999                DATETIME_ResetFieldUp(infoPtr,FieldNum);
     1000                DATETIME_SendDateTimeChangeNotify (hwnd);
     1001                break;
     1002        case VK_LEFT:
     1003                do {
     1004                        if (infoPtr->select==0) {
     1005                                infoPtr->select = infoPtr->nrFields - 1;
     1006                                wrap++;
     1007                        } else
     1008                        infoPtr->select--;
     1009                }
     1010                while ((infoPtr->fieldspec[infoPtr->select] & DT_STRING) && (wrap<2));
     1011                break;
     1012        case VK_RIGHT: 
     1013                do {
     1014                        infoPtr->select++;
     1015                        if (infoPtr->select==infoPtr->nrFields) {
     1016                                infoPtr->select = 0;
     1017                                wrap++;
     1018                        }
     1019                        }
     1020                while ((infoPtr->fieldspec[infoPtr->select] & DT_STRING) && (wrap<2));
     1021                break;
     1022        }
     1023
     1024  InvalidateRect(hwnd, NULL, FALSE);
     1025
     1026  return 0;
     1027}
     1028
     1029
     1030static LRESULT
     1031DATETIME_KillFocus (HWND hwnd, WPARAM wParam, LPARAM lParam)
     1032{
     1033    DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);       
     1034
     1035    TRACE ("\n");
     1036
     1037    if (infoPtr->haveFocus) {
     1038        DATETIME_SendSimpleNotify (hwnd, NM_KILLFOCUS);
     1039        infoPtr->haveFocus = 0;
    10221040    }
    10231041
    1024   InvalidateRect(hwnd, NULL, FALSE);
    1025 
    1026   return 0;
    1027 }
    1028 
    1029 
    1030 static LRESULT
    1031 DATETIME_KillFocus (HWND hwnd, WPARAM wParam, LPARAM lParam)
    1032 {
    1033     DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
     1042    InvalidateRect (hwnd, NULL, TRUE);
     1043
     1044    return 0;
     1045}
     1046
     1047
     1048static LRESULT
     1049DATETIME_SetFocus (HWND hwnd, WPARAM wParam, LPARAM lParam)
     1050{
     1051    DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);       
    10341052
    10351053    TRACE ("\n");
    10361054
    1037     if (infoPtr->haveFocus) {
    1038     DATETIME_SendSimpleNotify (hwnd, NM_KILLFOCUS);
    1039     infoPtr->haveFocus = 0;
    1040     }
    1041 
    1042     InvalidateRect (hwnd, NULL, TRUE);
    1043 
    1044     return 0;
    1045 }
    1046 
    1047 
    1048 static LRESULT
    1049 DATETIME_SetFocus (HWND hwnd, WPARAM wParam, LPARAM lParam)
    1050 {
    1051     DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
    1052 
    1053     TRACE ("\n");
    1054 
    10551055    if (infoPtr->haveFocus==0) {
    1056     DATETIME_SendSimpleNotify (hwnd, NM_SETFOCUS);
    1057     infoPtr->haveFocus = DTHT_GOTFOCUS;
     1056        DATETIME_SendSimpleNotify (hwnd, NM_SETFOCUS); 
     1057        infoPtr->haveFocus = DTHT_GOTFOCUS;
    10581058    }
    10591059
     
    10681068
    10691069{
    1070  DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
     1070 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);   
    10711071 NMDATETIMECHANGE dtdtc;
    10721072
     
    11361136    infoPtr->monthcal_pos.x = infoPtr->rcClient.right - ((infoPtr->calbutton.right -
    11371137                                infoPtr->calbutton.left) + 145);
    1138   else
     1138  else 
    11391139    infoPtr->monthcal_pos.x = 8;
    11401140
     
    11721172
    11731173  if (dwStyle & DTS_SHOWNONE) {
    1174     infoPtr->hwndCheckbut=CreateWindowExA (0,"button", 0,
    1175          WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
     1174    infoPtr->hwndCheckbut=CreateWindowExA (0,"button", 0, 
     1175         WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, 
    11761176         2,2,13,13,
    1177          hwnd,
     1177         hwnd, 
    11781178         0, GetWindowLongA  (hwnd, GWL_HINSTANCE), 0);
    11791179         SendMessageA (infoPtr->hwndCheckbut, BM_SETCHECK, 1, 0);
     
    11961196
    11971197  /* create the monthcal control */
    1198     infoPtr->hMonthCal = CreateWindowExA (0,"SysMonthCal32", 0,
    1199     WS_BORDER | WS_POPUP | WS_CLIPSIBLINGS,
    1200     0, 0, 0, 0,
    1201     GetParent(hwnd),
    1202     0, 0, 0);
     1198    infoPtr->hMonthCal = CreateWindowExA (0,"SysMonthCal32", 0, 
     1199        WS_BORDER | WS_POPUP | WS_CLIPSIBLINGS,
     1200        0, 0, 0, 0,
     1201        GetParent(hwnd),
     1202        0, 0, 0);
    12031203
    12041204  /* initialize info structure */
     
    12141214{
    12151215    DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
    1216 
     1216       
    12171217    TRACE("\n");
    12181218    COMCTL32_Free (infoPtr);
     
    12271227
    12281228    if (!DATETIME_GetInfoPtr(hwnd) && (uMsg != WM_CREATE))
    1229     return DefWindowProcA( hwnd, uMsg, wParam, lParam );
    1230 
     1229        return DefWindowProcA( hwnd, uMsg, wParam, lParam );
     1230   
    12311231    switch (uMsg)
    12321232    {
     
    12361236
    12371237    case DTM_SETSYSTEMTIME:
    1238     return DATETIME_SetSystemTime (hwnd, wParam, lParam);
     1238        return DATETIME_SetSystemTime (hwnd, wParam, lParam);
    12391239
    12401240    case DTM_GETRANGE:
     
    12661266
    12671267    case WM_PARENTNOTIFY:
    1268     return DATETIME_ParentNotify (hwnd, wParam, lParam);
     1268        return DATETIME_ParentNotify (hwnd, wParam, lParam);
    12691269
    12701270    case WM_NOTIFY:
    1271     return DATETIME_Notify (hwnd, wParam, lParam);
     1271        return DATETIME_Notify (hwnd, wParam, lParam);
    12721272
    12731273    case WM_GETDLGCODE:
     
    12961296
    12971297    case WM_CREATE:
    1298     return DATETIME_Create (hwnd, wParam, lParam);
     1298        return DATETIME_Create (hwnd, wParam, lParam);
    12991299
    13001300    case WM_DESTROY:
    1301     return DATETIME_Destroy (hwnd, wParam, lParam);
     1301        return DATETIME_Destroy (hwnd, wParam, lParam);
    13021302
    13031303    default:
    1304     if (uMsg >= WM_USER)
    1305         ERR("unknown msg %04x wp=%08x lp=%08lx\n",
    1306              uMsg, wParam, lParam);
     1304        if (uMsg >= WM_USER)
     1305                ERR("unknown msg %04x wp=%08x lp=%08lx\n",
     1306                     uMsg, wParam, lParam);
    13071307#ifdef __WIN32OS2__
    13081308        return defComCtl32ProcA (hwnd, uMsg, wParam, lParam);
    13091309#else
    1310     return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     1310        return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    13111311#endif
    13121312    }
     
    13291329    wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
    13301330    wndClass.lpszClassName = DATETIMEPICK_CLASSA;
    1331 
     1331 
    13321332    RegisterClassA (&wndClass);
    13331333}
  • trunk/src/comctl32/flatsb.c

    r6705 r6709  
    3939
    4040/***********************************************************************
    41  *      InitializeFlatSB
    42  *
    43  *  returns nonzero if successful, zero otherwise
     41 *              InitializeFlatSB
     42 *
     43 *      returns nonzero if successful, zero otherwise
    4444 *
    4545 */
     
    5252
    5353/***********************************************************************
    54  *      UninitializeFlatSB
    55  *
    56  *  returns:
    57  *  E_FAIL      if one of the scroll bars is currently in use
    58  *  S_FALSE     if InitializeFlatSB was never called on this hwnd
    59  *  S_OK        otherwise
     54 *              UninitializeFlatSB
     55 *
     56 *      returns:
     57 *      E_FAIL          if one of the scroll bars is currently in use
     58 *      S_FALSE         if InitializeFlatSB was never called on this hwnd
     59 *      S_OK            otherwise
    6060 *
    6161 */
     
    6868
    6969/***********************************************************************
    70  *      FlatSB_GetScrollProp
    71  *
    72  *  Returns nonzero if successful, or zero otherwise. If index is WSB_PROP_HSTYLE,
    73  *  the return is nonzero if InitializeFlatSB has been called for this window, or
    74  *  zero otherwise.
    75  *
    76  */
    77 BOOL WINAPI
     70 *              FlatSB_GetScrollProp
     71 *
     72 *      Returns nonzero if successful, or zero otherwise. If index is WSB_PROP_HSTYLE,
     73 *      the return is nonzero if InitializeFlatSB has been called for this window, or
     74 *      zero otherwise.
     75 *
     76 */
     77BOOL WINAPI 
    7878FlatSB_GetScrollProp(HWND hwnd, INT propIndex, LPINT prop)
    7979{
     
    8484
    8585/***********************************************************************
    86  *      FlatSB_SetScrollProp
    87  */
    88 BOOL WINAPI
     86 *              FlatSB_SetScrollProp
     87 */
     88BOOL WINAPI 
    8989FlatSB_SetScrollProp(HWND hwnd, UINT index, INT newValue, BOOL flag)
    9090{
     
    9595
    9696/***********************************************************************
    97  *  From the Microsoft docs:
    98  *  "If flat scroll bars haven't been initialized for the
    99  *  window, the flat scroll bar APIs will defer to the corresponding
    100  *  standard APIs.  This allows the developer to turn flat scroll
    101  *  bars on and off without having to write conditional code."
    102  *
    103  *  So, if we just call the standard functions until we implement
    104  *  the flat scroll bar functions, flat scroll bars will show up and
    105  *  behave properly, as though they had simply not been setup to
    106  *  have flat properties.
    107  *
    108  *  Susan <sfarley@codeweavers.com>
    109  *
    110  */
    111 
    112 /***********************************************************************
    113  *      FlatSB_EnableScrollBar
    114  */
    115 BOOL WINAPI
     97 *      From the Microsoft docs:
     98 *      "If flat scroll bars haven't been initialized for the
     99 *      window, the flat scroll bar APIs will defer to the corresponding
     100 *      standard APIs.  This allows the developer to turn flat scroll
     101 *      bars on and off without having to write conditional code."
     102 *
     103 *      So, if we just call the standard functions until we implement
     104 *      the flat scroll bar functions, flat scroll bars will show up and
     105 *      behave properly, as though they had simply not been setup to
     106 *      have flat properties.
     107 *
     108 *      Susan <sfarley@codeweavers.com>
     109 *
     110 */
     111
     112/***********************************************************************
     113 *              FlatSB_EnableScrollBar
     114 */
     115BOOL WINAPI 
    116116FlatSB_EnableScrollBar(HWND hwnd, int nBar, UINT flags)
    117117{
     
    120120
    121121/***********************************************************************
    122  *      FlatSB_ShowScrollBar
    123  */
    124 BOOL WINAPI
     122 *              FlatSB_ShowScrollBar
     123 */
     124BOOL WINAPI 
    125125FlatSB_ShowScrollBar(HWND hwnd, int nBar, BOOL fShow)
    126126{
     
    129129
    130130/***********************************************************************
    131  *      FlatSB_GetScrollRange
    132  */
    133 BOOL WINAPI
     131 *              FlatSB_GetScrollRange
     132 */
     133BOOL WINAPI 
    134134FlatSB_GetScrollRange(HWND hwnd, int nBar, LPINT min, LPINT max)
    135135{
     
    138138
    139139/***********************************************************************
    140  *      FlatSB_GetScrollInfo
    141  */
    142 BOOL WINAPI
     140 *              FlatSB_GetScrollInfo
     141 */
     142BOOL WINAPI 
    143143FlatSB_GetScrollInfo(HWND hwnd, int nBar, LPSCROLLINFO info)
    144144{
     
    147147
    148148/***********************************************************************
    149  *      FlatSB_GetScrollPos
    150  */
    151 INT WINAPI
     149 *              FlatSB_GetScrollPos
     150 */
     151INT WINAPI 
    152152FlatSB_GetScrollPos(HWND hwnd, int nBar)
    153153{
     
    156156
    157157/***********************************************************************
    158  *      FlatSB_SetScrollPos
    159  */
    160 INT WINAPI
     158 *              FlatSB_SetScrollPos
     159 */
     160INT WINAPI 
    161161FlatSB_SetScrollPos(HWND hwnd, int nBar, INT pos, BOOL bRedraw)
    162162{
     
    165165
    166166/***********************************************************************
    167  *      FlatSB_SetScrollInfo
    168  */
    169 INT WINAPI
     167 *              FlatSB_SetScrollInfo
     168 */
     169INT WINAPI 
    170170FlatSB_SetScrollInfo(HWND hwnd, int nBar, LPSCROLLINFO info, BOOL bRedraw)
    171171{
     
    174174
    175175/***********************************************************************
    176  *      FlatSB_SetScrollRange
    177  */
    178 INT WINAPI
     176 *              FlatSB_SetScrollRange
     177 */
     178INT WINAPI 
    179179FlatSB_SetScrollRange(HWND hwnd, int nBar, INT min, INT max, BOOL bRedraw)
    180180{
     
    212212    switch (uMsg)
    213213    {
    214     case WM_CREATE:
    215         return FlatSB_Create (hwnd, wParam, lParam);
    216 
    217     case WM_DESTROY:
    218         return FlatSB_Destroy (hwnd, wParam, lParam);
    219 
    220     default:
    221         if (uMsg >= WM_USER)
    222         ERR("unknown msg %04x wp=%08x lp=%08lx\n",
     214        case WM_CREATE:
     215            return FlatSB_Create (hwnd, wParam, lParam);
     216
     217        case WM_DESTROY:
     218            return FlatSB_Destroy (hwnd, wParam, lParam);
     219
     220        default:
     221            if (uMsg >= WM_USER)
     222                ERR("unknown msg %04x wp=%08x lp=%08lx\n",
    223223                    uMsg, wParam, lParam);
    224224#ifdef __WIN32OS2__
    225225            return defComCtl32ProcA (hwnd, uMsg, wParam, lParam);
    226226#else
    227         return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     227            return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    228228#endif
    229229    }
     
    245245    wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
    246246    wndClass.lpszClassName = FLATSB_CLASSA;
    247 
     247 
    248248    RegisterClassA (&wndClass);
    249249}
  • trunk/src/comctl32/imagelist.c

    r6705 r6709  
    2020 *    - ImageList_Draw, ImageList_DrawEx and ImageList_GetIcon use
    2121 *      ImageList_DrawIndirect. Since ImageList_DrawIndirect is still
    22  *      partially implemented, the functions mentioned above will be
     22 *      partially implemented, the functions mentioned above will be 
    2323 *      limited in functionality too.
    2424 */
     
    6969
    7070/*************************************************************************
    71  * IMAGELIST_InternalExpandBitmaps [Internal]
     71 * IMAGELIST_InternalExpandBitmaps [Internal] 
    7272 *
    7373 * Expands the bitmaps of an image list by the given number of images.
     
    9292    if ((himl->cCurImage + nImageCount < himl->cMaxImage)
    9393        && (himl->cy >= cy))
    94     return;
     94        return;
    9595
    9696    if (cy == 0) cy = himl->cy;
     
    116116
    117117    if (himl->hbmMask) {
    118         hbmNewBitmap =
     118        hbmNewBitmap = 
    119119            CreateBitmap (nNewWidth, cy, 1, 1, NULL);
    120120
     
    138138
    139139/*************************************************************************
    140  * IMAGELIST_InternalDraw [Internal]
     140 * IMAGELIST_InternalDraw [Internal] 
    141141 *
    142142 * Draws the image in the ImageList (without the mask)
     
    151151 *
    152152 * NOTES
    153  *     This function is used by ImageList_DrawIndirect, when it is
     153 *     This function is used by ImageList_DrawIndirect, when it is 
    154154 *     required to draw only the Image (without the mask) to the screen.
    155155 *
     
    164164    hImageDC = CreateCompatibleDC(0);
    165165    hOldBitmap = SelectObject(hImageDC, pimldp->himl->hbmImage);
    166     BitBlt(pimldp->hdcDst,
     166    BitBlt(pimldp->hdcDst, 
    167167        pimldp->x, pimldp->y, cx, cy,
    168         hImageDC,
    169         pimldp->himl->cx * pimldp->i, 0,
     168        hImageDC, 
     169        pimldp->himl->cx * pimldp->i, 0, 
    170170        SRCCOPY);
    171171
     
    176176
    177177/*************************************************************************
    178  * IMAGELIST_InternalDrawMask [Internal]
     178 * IMAGELIST_InternalDrawMask [Internal] 
    179179 *
    180180 * Draws the image in the ImageList with the mask
     
    189189 *
    190190 * NOTES
    191  *     This function is used by ImageList_DrawIndirect, when it is
     191 *     This function is used by ImageList_DrawIndirect, when it is 
    192192 *     required to draw the Image with the mask to the screen.
    193193 *
     
    205205    UINT fStyle = pimldp->fStyle & (~ILD_OVERLAYMASK);
    206206
    207     /*
    208      * We need a dc and bitmap to draw on that is
     207    /* 
     208     * We need a dc and bitmap to draw on that is 
    209209     * not on the screen.
    210210     */
     
    221221    hOffScreenDC = CreateCompatibleDC( pimldp->hdcDst );
    222222
    223     if ( hOffScreenDC )
     223    if ( hOffScreenDC ) 
    224224    {
    225225        hOffScreenBmp = CreateCompatibleBitmap( pimldp->hdcDst, cx, cy );
    226226
    227         if ( hOffScreenBmp )
     227        if ( hOffScreenBmp ) 
    228228            SelectObject( hOffScreenDC, hOffScreenBmp  );
    229229        else
     
    235235    hOldBitmapImage = SelectObject(hImageDC, himlLocal->hbmImage);
    236236    hOldBitmapMask = SelectObject(hMaskDC, himlLocal->hbmMask);
    237 
    238     /*
    239      * Get a copy of the image for the masking operations.
     237   
     238    /* 
     239     * Get a copy of the image for the masking operations. 
    240240     * We will use the copy, and this dc for all the various
    241241     * blitting, and then do one final blit to the screen dc.
    242242     * This should clean up most of the flickering.
    243243     */
    244     BitBlt( hOffScreenDC, 0, 0, cx, cy, pimldp->hdcDst, pimldp->x,
     244    BitBlt( hOffScreenDC, 0, 0, cx, cy, pimldp->hdcDst, pimldp->x, 
    245245            pimldp->y, SRCCOPY);
    246246
    247     /*
     247    /* 
    248248     * Draw the Background for the appropriate Styles
    249249     */
    250     if( bUseCustomBackground && (fStyle == ILD_NORMAL || fStyle & ILD_IMAGE
     250    if( bUseCustomBackground && (fStyle == ILD_NORMAL || fStyle & ILD_IMAGE 
    251251         || bBlendFlag) )
    252252    {
    253 
     253       
    254254        hBrush = CreateSolidBrush (himlLocal->clrBk);
    255255        hOldBrush = SelectObject (pimldp->hdcDst, hBrush);
    256 
     256       
    257257        PatBlt( hOffScreenDC, pimldp->x, pimldp->y, cx, cy, PATCOPY );
    258258
     
    260260    }
    261261
    262     /*
     262    /* 
    263263     * Draw Image Transparently over the current background
    264264     */
    265     if(fStyle == ILD_NORMAL || (fStyle & ILD_TRANSPARENT) ||
    266        ((fStyle & ILD_IMAGE) && bUseCustomBackground) || bBlendFlag)
    267     {   /*
     265    if(fStyle == ILD_NORMAL || (fStyle & ILD_TRANSPARENT) || 
     266       ((fStyle & ILD_IMAGE) && bUseCustomBackground) || bBlendFlag) 
     267    {   /* 
    268268         * To obtain a transparent look, background color should be set
    269          * to white and foreground color to black when blting the
    270          * monochrome mask.
     269         * to white and foreground color to black when blting the 
     270         * monochrome mask. 
    271271         */
    272 
    273         oldBkColor = SetBkColor( hOffScreenDC, RGB( 0xff, 0xff, 0xff ) );
     272       
     273        oldBkColor = SetBkColor( hOffScreenDC, RGB( 0xff, 0xff, 0xff ) ); 
    274274        oldFgColor = SetTextColor( hOffScreenDC, RGB( 0, 0, 0 ) );
    275275
     
    279279        BitBlt( hOffScreenDC, 0, 0, cx, cy, hImageDC,himlLocal->cx * pimldp->i,
    280280                0, SRCPAINT );
    281 
    282     }
    283 
     281   
     282    }
     283   
    284284    /*
    285285     * Draw the image when no Background is specified
     
    287287    else if((fStyle & ILD_IMAGE) && !bUseCustomBackground)
    288288    {
    289         BitBlt( hOffScreenDC, 0, 0, cx, cy, hImageDC,
     289        BitBlt( hOffScreenDC, 0, 0, cx, cy, hImageDC, 
    290290                himlLocal->cx * pimldp->i, 0, SRCCOPY);
    291291    }
    292     /*
     292    /* 
    293293     * Draw the mask with or without a background
    294294     */
     
    298298                0, bUseCustomBackground ? SRCCOPY : SRCAND);
    299299    }
    300 
     300   
    301301    /*
    302302     * Blit the bitmap to the screen now.
     
    305305            hOffScreenDC, 0, 0, SRCCOPY);
    306306
    307 
     307   
    308308    SelectObject(hImageDC, hOldBitmapImage);
    309309    SelectObject(hMaskDC, hOldBitmapMask);
    310 
     310   
    311311cleanup:
    312 
     312   
    313313    DeleteDC(hImageDC);
    314314    DeleteDC(hMaskDC);
    315 
     315   
    316316    DeleteDC( hOffScreenDC );
    317317    DeleteObject( hOffScreenBmp );
    318 
     318   
    319319    return;
    320320}
    321321
    322322/*************************************************************************
    323  * IMAGELIST_InternalDrawBlend [Internal]
    324  *
    325  * Draws the Blend over the current image
     323 * IMAGELIST_InternalDrawBlend [Internal] 
     324 *
     325 * Draws the Blend over the current image 
    326326 *
    327327 * PARAMS
     
    334334 *
    335335 * NOTES
    336  *     This functions is used by ImageList_DrawIndirect, when it is
    337  *     required to add the blend to the current image.
    338  *
     336 *     This functions is used by ImageList_DrawIndirect, when it is 
     337 *     required to add the blend to the current image. 
     338 *     
    339339 */
    340340static VOID
     
    375375
    376376        BitBlt(hBlendMaskDC,
    377             0,0, cx, cy,
     377            0,0, cx, cy, 
    378378            hMaskDC,
    379379            himlLocal->cx * pimldp->i,0,
     
    381381
    382382        BitBlt(hBlendMaskDC,
    383             0,0, cx, cy,
     383            0,0, cx, cy, 
    384384            hBlendMaskDC,
    385             0,0,
     385            0,0, 
    386386            NOTSRCCOPY);
    387387
     
    397397    hOldBrush = (HBRUSH) SelectObject (pimldp->hdcDst, hBlendColorBrush);
    398398
    399     BitBlt (pimldp->hdcDst,
    400         pimldp->x, pimldp->y, cx, cy,
    401         hBlendMaskDC,
    402         0, 0,
     399    BitBlt (pimldp->hdcDst, 
     400        pimldp->x, pimldp->y, cx, cy, 
     401        hBlendMaskDC, 
     402        0, 0, 
    403403        0xB8074A); /* PSDPxax */
    404404
     
    413413
    414414/*************************************************************************
    415  * IMAGELIST_InternalDrawOverlay [Internal]
    416  *
    417  * Draws the overlay image
     415 * IMAGELIST_InternalDrawOverlay [Internal] 
     416 *
     417 * Draws the overlay image 
    418418 *
    419419 * PARAMS
     
    426426 *
    427427 * NOTES
    428  *     This functions is used by ImageList_DrawIndirect, when it is
     428 *     This functions is used by ImageList_DrawIndirect, when it is 
    429429 *     required to draw the overlay
    430430 *
    431  *
    432  */
    433 static VOID
     431 *     
     432 */
     433static VOID 
    434434IMAGELIST_InternalDrawOverlay(IMAGELISTDRAWPARAMS *pimldp, INT cx, INT cy)
    435435{
     
    447447            if (pimldp->himl->hbmMask)
    448448            {
    449                 hOldBitmap = (HBITMAP) SelectObject (hImageDC,
     449                hOldBitmap = (HBITMAP) SelectObject (hImageDC, 
    450450                    pimldp->himl->hbmMask);
    451451
    452                 BitBlt (pimldp->hdcDst,
     452                BitBlt (pimldp->hdcDst, 
    453453                    pimldp->x, pimldp->y, cx, cy,
    454454                    hImageDC, pimldp->himl->cx * nOvlIdx, 0,
     
    457457                SelectObject(hImageDC, hOldBitmap);
    458458            }
    459             hOldBitmap = (HBITMAP) SelectObject (hImageDC,
     459            hOldBitmap = (HBITMAP) SelectObject (hImageDC, 
    460460                pimldp->himl->hbmImage);
    461461
    462             BitBlt (pimldp->hdcDst,
    463                 pimldp->x, pimldp->y, cx, cy,
     462            BitBlt (pimldp->hdcDst, 
     463                pimldp->x, pimldp->y, cx, cy, 
    464464                hImageDC,
    465465                pimldp->himl->cx * nOvlIdx, 0,
     
    492492
    493493INT WINAPI
    494 ImageList_Add (HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask)
     494ImageList_Add (HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask)
    495495{
    496496    HDC     hdcImage, hdcBitmap;
     
    531531        hOldBitmapTemp = (HBITMAP) SelectObject(hdcTemp, hbmMask);
    532532
    533         BitBlt (hdcMask,
     533        BitBlt (hdcMask, 
    534534            nStartX, 0, bmp.bmWidth, bmp.bmHeight,
    535             hdcTemp,
    536             0, 0,
     535            hdcTemp, 
     536            0, 0, 
    537537            SRCCOPY);
    538538
     
    542542        /* Remove the background from the image
    543543        */
    544         BitBlt (hdcImage,
     544        BitBlt (hdcImage, 
    545545            nStartX, 0, bmp.bmWidth, bmp.bmHeight,
    546             hdcMask,
    547             nStartX, 0,
     546            hdcMask, 
     547            nStartX, 0, 
    548548            0x220326); /* NOTSRCAND */
    549549
     
    586586
    587587/*************************************************************************
    588  * ImageList_AddMasked [COMCTL32.42]
     588 * ImageList_AddMasked [COMCTL32.42] 
    589589 *
    590590 * Adds an image or images to an image list and creates a mask from the
     
    651651        GetPixel (hdcBitmap, 0, 0);
    652652    SetBkColor (hdcBitmap, bkColor);
    653     BitBlt (hdcMask,
     653    BitBlt (hdcMask, 
    654654        nMaskXOffset, 0, bmp.bmWidth, bmp.bmHeight,
    655         hdcBitmap, 0, 0,
     655        hdcBitmap, 0, 0, 
    656656        SRCCOPY);
    657657
     
    668668        This is here in case some apps rely on this bug
    669669    */
    670     BitBlt(hdcBitmap,
     670    BitBlt(hdcBitmap, 
    671671        0, 0, bmp.bmWidth, bmp.bmHeight,
    672         hdcMask,
    673         nMaskXOffset, 0,
     672        hdcMask, 
     673        nMaskXOffset, 0, 
    674674        0x220326); /* NOTSRCAND */
    675675    /* Copy result to the imagelist
    676676    */
    677     BitBlt (hdcImage,
     677    BitBlt (hdcImage, 
    678678        nIndex * himl->cx, 0, bmp.bmWidth, bmp.bmHeight,
    679         hdcBitmap,
    680         0, 0,
     679        hdcBitmap, 
     680        0, 0, 
    681681        SRCCOPY);
    682682    /* Clean up
     
    698698
    699699/*************************************************************************
    700  * ImageList_BeginDrag [COMCTL32.43]
     700 * ImageList_BeginDrag [COMCTL32.43] 
    701701 *
    702702 * Creates a temporary image list that contains one image. It will be used
     
    716716BOOL WINAPI
    717717ImageList_BeginDrag (HIMAGELIST himlTrack, INT iTrack,
    718                  INT dxHotspot, INT dyHotspot)
     718                     INT dxHotspot, INT dyHotspot)
    719719{
    720720    HDC hdcSrc, hdcDst;
     
    723723
    724724    if (himlTrack == NULL)
    725     return FALSE;
     725        return FALSE;
    726726
    727727    if (himlInternalDrag)
     
    729729
    730730    himlInternalDrag =
    731     ImageList_Create (himlTrack->cx, himlTrack->cy,
    732               himlTrack->flags, 1, 1);
     731        ImageList_Create (himlTrack->cx, himlTrack->cy,
     732                          himlTrack->flags, 1, 1);
    733733    if (himlInternalDrag == NULL) {
    734734        ERR("Error creating drag image list!\n");
     
    764764
    765765/*************************************************************************
    766  * ImageList_Copy [COMCTL32.44]
    767  *
    768  *  Copies an image of the source image list to an image of the
     766 * ImageList_Copy [COMCTL32.44] 
     767 *
     768 *  Copies an image of the source image list to an image of the 
    769769 *  destination image list. Images can be copied or swapped.
    770770 *
     
    787787
    788788BOOL WINAPI
    789 ImageList_Copy (HIMAGELIST himlDst, INT iDst,   HIMAGELIST himlSrc,
    790         INT iSrc, INT uFlags)
    791 {
    792     HDC hdcSrc, hdcDst;
     789ImageList_Copy (HIMAGELIST himlDst, INT iDst,   HIMAGELIST himlSrc,
     790                INT iSrc, INT uFlags)
     791{
     792    HDC hdcSrc, hdcDst;   
    793793
    794794    TRACE("iDst=%d  iSrc=%d\n", iDst, iSrc);
    795795
    796796    if ((himlSrc == NULL) || (himlDst == NULL))
    797     return FALSE;
     797        return FALSE;
    798798    if ((iDst < 0) || (iDst >= himlDst->cCurImage))
    799     return FALSE;
     799        return FALSE;
    800800    if ((iSrc < 0) || (iSrc >= himlSrc->cCurImage))
    801     return FALSE;
     801        return FALSE;
    802802
    803803    hdcSrc = CreateCompatibleDC (0);
     
    815815                                       himlSrc->uBitsPixel, NULL);
    816816        hbmTempMask = CreateBitmap (himlSrc->cx, himlSrc->cy, 1,
    817                       1, NULL);
     817                                      1, NULL);
    818818
    819819        /* copy (and stretch) destination to temporary bitmaps.(save) */
     
    908908HIMAGELIST WINAPI
    909909ImageList_Create (INT cx, INT cy, UINT flags,
    910           INT cInitial, INT cGrow)
     910                  INT cInitial, INT cGrow)
    911911{
    912912    HIMAGELIST himl;
     
    914914    INT      nCount;
    915915    HBITMAP  hbmTemp;
    916     static WORD aBitBlend25[] =
     916    static WORD aBitBlend25[] = 
    917917        {0xAA, 0x00, 0x55, 0x00, 0xAA, 0x00, 0x55, 0x00};
    918918
     
    948948    if (himl->cMaxImage > 0) {
    949949        himl->hbmImage =
    950       CreateBitmap (himl->cx * himl->cMaxImage, himl->cy,
     950          CreateBitmap (himl->cx * himl->cMaxImage, himl->cy,
    951951                        1, himl->uBitsPixel, NULL);
    952     if (himl->hbmImage == 0) {
    953         ERR("Error creating image bitmap!\n");
    954         return NULL;
    955     }
     952        if (himl->hbmImage == 0) {
     953            ERR("Error creating image bitmap!\n");
     954            return NULL;
     955        }
    956956    }
    957957    else
    958958        himl->hbmImage = 0;
    959 
     959   
    960960    if ( (himl->cMaxImage > 0) && (himl->flags & ILC_MASK)) {
    961961        himl->hbmMask = CreateBitmap (himl->cx * himl->cMaxImage, himl->cy,
    962                     1, 1, NULL);
     962                                        1, 1, NULL);
    963963        if (himl->hbmMask == 0) {
    964964            ERR("Error creating mask bitmap!\n");
     
    986986
    987987/*************************************************************************
    988  * ImageList_Destroy [COMCTL32.46]
     988 * ImageList_Destroy [COMCTL32.46] 
    989989 *
    990990 * Destroys an image list.
     
    10001000BOOL WINAPI
    10011001ImageList_Destroy (HIMAGELIST himl)
    1002 {
     1002{ 
    10031003    if (!himl)
    1004     return FALSE;
     1004        return FALSE;
    10051005
    10061006    /* delete image bitmaps */
     
    10151015    if (himl->hbrBlend50)
    10161016        DeleteObject (himl->hbrBlend50);
    1017 
     1017       
    10181018    COMCTL32_Free (himl);
    10191019
     
    10231023
    10241024/*************************************************************************
    1025  * ImageList_DragEnter [COMCTL32.47]
     1025 * ImageList_DragEnter [COMCTL32.47] 
    10261026 *
    10271027 * Locks window update and displays the drag image at the given position.
     
    10451045{
    10461046    if (himlInternalDrag == NULL)
    1047     return FALSE;
     1047        return FALSE;
    10481048
    10491049    if (hwndLock)
    1050     hwndInternalDrag = hwndLock;
     1050        hwndInternalDrag = hwndLock;
    10511051    else
    1052     hwndInternalDrag = GetDesktopWindow ();
     1052        hwndInternalDrag = GetDesktopWindow ();
    10531053
    10541054    xInternalPos = x;
     
    10571057    hdcBackBuffer = CreateCompatibleDC (0);
    10581058    hbmBackBuffer = CreateCompatibleBitmap (hdcBackBuffer,
    1059         himlInternalDrag->cx, himlInternalDrag->cy);
     1059                himlInternalDrag->cx, himlInternalDrag->cy);
    10601060
    10611061    ImageList_DragShowNolock (TRUE);
     
    10661066
    10671067/*************************************************************************
    1068  * ImageList_DragLeave [COMCTL32.48]
     1068 * ImageList_DragLeave [COMCTL32.48] 
    10691069 *
    10701070 * Unlocks window update and hides the drag image.
     
    10821082{
    10831083    if (hwndLock)
    1084     hwndInternalDrag = hwndLock;
     1084        hwndInternalDrag = hwndLock;
    10851085    else
    1086     hwndInternalDrag = GetDesktopWindow ();
     1086        hwndInternalDrag = GetDesktopWindow ();
    10871087
    10881088    ImageList_DragShowNolock (FALSE);
     
    10961096
    10971097/*************************************************************************
    1098  * ImageList_DragMove [COMCTL32.49]
     1098 * ImageList_DragMove [COMCTL32.49] 
    10991099 *
    11001100 * Moves the drag image.
     
    11281128
    11291129/*************************************************************************
    1130  * ImageList_DragShowNolock [COMCTL32.50]
     1130 * ImageList_DragShowNolock [COMCTL32.50] 
    11311131 *
    11321132 * Shows or hides the drag image.
     
    11521152
    11531153    hdcDrag = GetDCEx (hwndInternalDrag, 0,
    1154             DCX_WINDOW | DCX_CACHE | DCX_LOCKWINDOWUPDATE);
     1154                        DCX_WINDOW | DCX_CACHE | DCX_LOCKWINDOWUPDATE);
    11551155
    11561156    if (bShow) {
    1157     /* show drag image */
    1158 
    1159     /* save background */
    1160 
    1161     /* draw drag image */
     1157        /* show drag image */
     1158
     1159        /* save background */
     1160
     1161        /* draw drag image */
    11621162
    11631163    }
    11641164    else {
    1165     /* hide drag image */
    1166 
    1167     /* restore background */
     1165        /* hide drag image */
     1166
     1167        /* restore background */
    11681168
    11691169    }
     
    11991199BOOL WINAPI
    12001200ImageList_Draw (HIMAGELIST himl, INT i, HDC hdc,
    1201         INT x, INT y, UINT fStyle)
     1201                INT x, INT y, UINT fStyle)
    12021202{
    12031203    IMAGELISTDRAWPARAMS imldp;
     
    12521252BOOL WINAPI
    12531253ImageList_DrawEx (HIMAGELIST himl, INT i, HDC hdc, INT x, INT y,
    1254           INT dx, INT dy, COLORREF rgbBk, COLORREF rgbFg,
    1255           UINT fStyle)
     1254                  INT dx, INT dy, COLORREF rgbBk, COLORREF rgbFg,
     1255                  UINT fStyle)
    12561256{
    12571257    IMAGELISTDRAWPARAMS imldp;
     
    12771277
    12781278/*************************************************************************
    1279  * ImageList_DrawIndirect [COMCTL32.53]
     1279 * ImageList_DrawIndirect [COMCTL32.53] 
    12801280 *
    12811281 * Draws an image using ...
     
    12921292ImageList_DrawIndirect (IMAGELISTDRAWPARAMS *pimldp)
    12931293{
    1294     INT      cx, cy;
    1295     /*
     1294    INT      cx, cy;   
     1295    /* 
    12961296        Do some Error Checking
    12971297    */
     
    13031303        return FALSE;
    13041304    if ((pimldp->i < 0) || (pimldp->i >= pimldp->himl->cCurImage)) {
    1305     ERR("%d not within range (max %d)\n",pimldp->i,pimldp->himl->cCurImage-1);
     1305        ERR("%d not within range (max %d)\n",pimldp->i,pimldp->himl->cCurImage-1);
    13061306        return FALSE;
    13071307    }
     
    13221322        IMAGELIST_InternalDraw(pimldp, cx, cy);
    13231323    }
    1324     /*
     1324    /* 
    13251325        Apply the blend if needed to the Image
    13261326    */
     
    13871387        DeleteDC (hdcSrc);
    13881388
    1389     himlDst->cCurImage = himlSrc->cCurImage;
    1390     himlDst->cMaxImage = himlSrc->cMaxImage;
     1389        himlDst->cCurImage = himlSrc->cCurImage;
     1390        himlDst->cMaxImage = himlSrc->cMaxImage;
    13911391    }
    13921392    return himlDst;
     
    14471447{
    14481448    if (himl == NULL)
    1449     return CLR_NONE;
     1449        return CLR_NONE;
    14501450
    14511451    return himl->clrBk;
     
    14831483
    14841484/*************************************************************************
    1485  * ImageList_GetIcon [COMCTL32.59]
     1485 * ImageList_GetIcon [COMCTL32.59] 
    14861486 *
    14871487 * Creates an icon from a masked image of an image list.
     
    15061506
    15071507    if ((himl == NULL) || (i < 0) || (i >= himl->cCurImage)) {
    1508     FIXME("(%p,%d,%x), params out of range!\n",himl,i,fStyle);
    1509     return 0;
     1508        FIXME("(%p,%d,%x), params out of range!\n",himl,i,fStyle);
     1509        return 0;
    15101510   }
    15111511
     
    15191519    hOldDstBitmap = (HBITMAP)SelectObject (hdcDst, ii.hbmMask);
    15201520    if (himl->hbmMask) {
    1521     SelectObject (hdcSrc, himl->hbmMask);
    1522     BitBlt (hdcDst, 0, 0, himl->cx, himl->cy,
    1523           hdcSrc, i * himl->cx, 0, SRCCOPY);
     1521        SelectObject (hdcSrc, himl->hbmMask);
     1522        BitBlt (hdcDst, 0, 0, himl->cx, himl->cy,
     1523                  hdcSrc, i * himl->cx, 0, SRCCOPY);
    15241524    }
    15251525    else
    1526     PatBlt (hdcDst, 0, 0, himl->cx, himl->cy, BLACKNESS);
     1526        PatBlt (hdcDst, 0, 0, himl->cx, himl->cy, BLACKNESS);
    15271527
    15281528    /* draw image*/
     
    15311531    SelectObject (hdcDst, ii.hbmColor);
    15321532    BitBlt (hdcDst, 0, 0, himl->cx, himl->cy,
    1533           hdcSrc, i * himl->cx, 0, SRCCOPY);
     1533              hdcSrc, i * himl->cx, 0, SRCCOPY);
    15341534
    15351535    /*
    15361536     * CreateIconIndirect requires us to deselect the bitmaps from
    1537      * the DCs before calling
     1537     * the DCs before calling 
    15381538     */
    15391539    SelectObject(hdcSrc, hOldSrcBitmap);
    15401540    SelectObject(hdcDst, hOldDstBitmap);
    15411541
    1542     hIcon = CreateIconIndirect (&ii);
     1542    hIcon = CreateIconIndirect (&ii);   
    15431543
    15441544    DeleteDC (hdcSrc);
     
    15731573{
    15741574    if (himl == NULL)
    1575     return FALSE;
     1575        return FALSE;
    15761576    if ((himl->cx <= 0) || (himl->cy <= 0))
    1577     return FALSE;
     1577        return FALSE;
    15781578
    15791579    if (cx)
    1580     *cx = himl->cx;
     1580        *cx = himl->cx;
    15811581    if (cy)
    1582     *cy = himl->cy;
     1582        *cy = himl->cy;
    15831583
    15841584    return TRUE;
     
    16031603{
    16041604    if (himl == NULL)
    1605     return 0;
     1605        return 0;
    16061606
    16071607    return himl->cCurImage;
     
    16281628{
    16291629    if ((himl == NULL) || (pImageInfo == NULL))
    1630     return FALSE;
     1630        return FALSE;
    16311631    if ((i < 0) || (i >= himl->cCurImage))
    1632     return FALSE;
     1632        return FALSE;
    16331633
    16341634    pImageInfo->hbmImage = himl->hbmImage;
    16351635    pImageInfo->hbmMask  = himl->hbmMask;
    1636 
     1636   
    16371637    pImageInfo->rcImage.top    = 0;
    16381638    pImageInfo->rcImage.bottom = himl->cy;
    16391639    pImageInfo->rcImage.left   = i * himl->cx;
    16401640    pImageInfo->rcImage.right  = (i+1) * himl->cx;
    1641 
     1641   
    16421642    return TRUE;
    16431643}
     
    16451645
    16461646/*************************************************************************
    1647  * ImageList_GetImageRect [COMCTL32.63]
     1647 * ImageList_GetImageRect [COMCTL32.63] 
    16481648 *
    16491649 * Retrieves the rectangle of the specified image in an image list.
     
    16661666{
    16671667    if ((himl == NULL) || (lpRect == NULL))
    1668     return FALSE;
     1668        return FALSE;
    16691669    if ((i < 0) || (i >= himl->cCurImage))
    1670     return FALSE;
     1670        return FALSE;
    16711671
    16721672    lpRect->left   = i * himl->cx;
     
    17041704HIMAGELIST WINAPI
    17051705ImageList_LoadImageA (HINSTANCE hi, LPCSTR lpbmp, INT cx, INT cGrow,
    1706             COLORREF clrMask, UINT uType, UINT uFlags)
     1706                        COLORREF clrMask, UINT uType, UINT uFlags)
    17071707{
    17081708    HIMAGELIST himl = NULL;
     
    17441744        GetIconInfo (handle, &ii);
    17451745        GetObjectA (ii.hbmColor, sizeof(BITMAP), (LPVOID)&bmp);
    1746         himl = ImageList_Create (bmp.bmWidth, bmp.bmHeight,
     1746        himl = ImageList_Create (bmp.bmWidth, bmp.bmHeight, 
    17471747                                 ILC_MASK | ILC_COLOR, 1, cGrow);
    17481748        ImageList_Add (himl, ii.hbmColor, ii.hbmMask);
     
    17521752
    17531753    DeleteObject (handle);
    1754 
     1754   
    17551755    return himl;
    17561756}
     
    17811781HIMAGELIST WINAPI
    17821782ImageList_LoadImageW (HINSTANCE hi, LPCWSTR lpbmp, INT cx, INT cGrow,
    1783             COLORREF clrMask, UINT uType,   UINT uFlags)
     1783                        COLORREF clrMask, UINT uType,   UINT uFlags)
    17841784{
    17851785    HIMAGELIST himl = NULL;
     
    18081808        GetIconInfo (handle, &ii);
    18091809        GetObjectA (ii.hbmMask, sizeof(BITMAP), (LPVOID)&bmp);
    1810         himl = ImageList_Create (bmp.bmWidth, bmp.bmHeight,
     1810        himl = ImageList_Create (bmp.bmWidth, bmp.bmHeight, 
    18111811                                 ILC_MASK | ILC_COLOR, 1, cGrow);
    18121812        ImageList_Add (himl, ii.hbmColor, ii.hbmMask);
     
    18161816
    18171817    DeleteObject (handle);
    1818 
     1818   
    18191819    return himl;
    18201820}
     
    18221822
    18231823/*************************************************************************
    1824  * ImageList_Merge [COMCTL32.67]
     1824 * ImageList_Merge [COMCTL32.67] 
    18251825 *
    18261826 * Creates a new image list that contains a merged image from the specified
     
    18421842HIMAGELIST WINAPI
    18431843ImageList_Merge (HIMAGELIST himl1, INT i1, HIMAGELIST himl2, INT i2,
    1844         INT dx, INT dy)
     1844                INT dx, INT dy)
    18451845{
    18461846    HIMAGELIST himlDst = NULL;
     
    18511851
    18521852    if ((himl1 == NULL) || (himl2 == NULL))
    1853     return NULL;
     1853        return NULL;
    18541854
    18551855    /* check indices */
     
    19031903        nX1 = i1 * himl1->cx;
    19041904        nX2 = i2 * himl2->cx;
    1905 
     1905       
    19061906        /* copy image */
    19071907        SelectObject (hdcSrcImage, himl1->hbmImage);
    19081908        SelectObject (hdcDstImage, himlDst->hbmImage);
    1909         BitBlt (hdcDstImage, 0, 0, cxDst, cyDst,
     1909        BitBlt (hdcDstImage, 0, 0, cxDst, cyDst, 
    19101910                  hdcSrcImage, 0, 0, BLACKNESS);
    1911         BitBlt (hdcDstImage, xOff1, yOff1, himl1->cx, himl1->cy,
     1911        BitBlt (hdcDstImage, xOff1, yOff1, himl1->cx, himl1->cy, 
    19121912                  hdcSrcImage, nX1, 0, SRCCOPY);
    19131913
    19141914        SelectObject (hdcSrcImage, himl2->hbmMask);
    1915         BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy,
     1915        BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 
    19161916                  hdcSrcImage, nX2, 0, SRCAND);
    19171917
    19181918        SelectObject (hdcSrcImage, himl2->hbmImage);
    1919         BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy,
     1919        BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 
    19201920                  hdcSrcImage, nX2, 0, SRCPAINT);
    19211921
     
    19231923        SelectObject (hdcSrcImage, himl1->hbmMask);
    19241924        SelectObject (hdcDstImage, himlDst->hbmMask);
    1925         BitBlt (hdcDstImage, 0, 0, cxDst, cyDst,
     1925        BitBlt (hdcDstImage, 0, 0, cxDst, cyDst, 
    19261926                  hdcSrcImage, 0, 0, WHITENESS);
    1927         BitBlt (hdcDstImage, xOff1, yOff1, himl1->cx, himl1->cy,
     1927        BitBlt (hdcDstImage, xOff1, yOff1, himl1->cx, himl1->cy, 
    19281928                  hdcSrcImage, nX1, 0, SRCCOPY);
    19291929
    19301930        SelectObject (hdcSrcImage, himl2->hbmMask);
    1931         BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy,
     1931        BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 
    19321932                  hdcSrcImage, nX2, 0, SRCAND);
    19331933
     
    19351935        DeleteDC (hdcDstImage);
    19361936    }
    1937 
     1937   
    19381938    return himlDst;
    19391939}
     
    19451945    int bitspixel = GetDeviceCaps(hdc,BITSPIXEL)*GetDeviceCaps(hdc,PLANES);
    19461946    if (bitspixel>8)
    1947     return TRUE;
     1947        return TRUE;
    19481948    if (bitspixel<=4)
    1949     return FALSE;
     1949        return FALSE;
    19501950    return GetDeviceCaps(hdc,CAPS1) & C1_DIBENGINE;
    19511951}
     
    19541954/* helper for ImageList_Read, see comments below */
    19551955static HBITMAP _read_bitmap(LPSTREAM pstm,int ilcFlag,int cx,int cy) {
    1956     HDC         xdc = 0;
    1957     BITMAPFILEHEADER    bmfh;
    1958     BITMAPINFOHEADER    bmih;
    1959     int         bitsperpixel,palspace,longsperline,width,height;
    1960     LPBITMAPINFOHEADER  bmihc = NULL;
    1961     int         result = 0;
    1962     HBITMAP     hbitmap = 0;
    1963     LPBYTE      bits = NULL,nbits = NULL;
    1964     int         nbytesperline,bytesperline;
    1965 
    1966     if (!SUCCEEDED(IStream_Read ( pstm, &bmfh, sizeof(bmfh), NULL)) ||
    1967         (bmfh.bfType != (('M'<<8)|'B'))                 ||
    1968         !SUCCEEDED(IStream_Read ( pstm, &bmih, sizeof(bmih), NULL)) ||
    1969         (bmih.biSize != sizeof(bmih))
     1956    HDC                 xdc = 0;
     1957    BITMAPFILEHEADER    bmfh;
     1958    BITMAPINFOHEADER    bmih;
     1959    int                 bitsperpixel,palspace,longsperline,width,height;
     1960    LPBITMAPINFOHEADER  bmihc = NULL;
     1961    int                 result = 0;
     1962    HBITMAP             hbitmap = 0;
     1963    LPBYTE              bits = NULL,nbits = NULL;
     1964    int                 nbytesperline,bytesperline;
     1965
     1966    if (!SUCCEEDED(IStream_Read ( pstm, &bmfh, sizeof(bmfh), NULL))     ||
     1967        (bmfh.bfType != (('M'<<8)|'B'))                                 ||
     1968        !SUCCEEDED(IStream_Read ( pstm, &bmih, sizeof(bmih), NULL))     ||
     1969        (bmih.biSize != sizeof(bmih))
    19701970    )
    1971     return 0;
     1971        return 0;
    19721972
    19731973    bitsperpixel = bmih.biPlanes * bmih.biBitCount;
    19741974    if (bitsperpixel<=8)
    1975         palspace = (1<<bitsperpixel)*sizeof(RGBQUAD);
     1975        palspace = (1<<bitsperpixel)*sizeof(RGBQUAD);
    19761976    else
    1977         palspace = 0;
     1977        palspace = 0;
    19781978    width = bmih.biWidth;
    19791979    height = bmih.biHeight;
    19801980    bmihc = (LPBITMAPINFOHEADER)LocalAlloc(LMEM_ZEROINIT,sizeof(bmih)+palspace);
    19811981    memcpy(bmihc,&bmih,sizeof(bmih));
    1982     longsperline    = ((width*bitsperpixel+31)&~0x1f)>>5;
    1983     bmihc->biSizeImage  = (longsperline*height)<<2;
     1982    longsperline        = ((width*bitsperpixel+31)&~0x1f)>>5;
     1983    bmihc->biSizeImage  = (longsperline*height)<<2;
    19841984
    19851985    /* read the palette right after the end of the bitmapinfoheader */
    19861986    if (palspace)
    1987     if (!SUCCEEDED(IStream_Read ( pstm, bmihc+1, palspace, NULL)))
    1988         goto ret1;
     1987        if (!SUCCEEDED(IStream_Read ( pstm, bmihc+1, palspace, NULL)))
     1988            goto ret1;
    19891989
    19901990    xdc = GetDC(0);
    19911991#if 0 /* Magic for NxM -> 1x(N*M) not implemented for DIB Sections */
    19921992    if ((bitsperpixel>1) &&
    1993     ((ilcFlag!=ILC_COLORDDB) && (!ilcFlag || may_use_dibsection(xdc)))
     1993        ((ilcFlag!=ILC_COLORDDB) && (!ilcFlag || may_use_dibsection(xdc)))
    19941994     ) {
    1995     hbitmap = CreateDIBSection(xdc,(BITMAPINFO*)bmihc,0,(LPVOID*)&bits,0,0);
    1996     if (!hbitmap)
    1997         goto ret1;
    1998     if (!SUCCEEDED(IStream_Read( pstm, bits, bmihc->biSizeImage, NULL)))
    1999         goto ret1;
    2000     result = 1;
     1995        hbitmap = CreateDIBSection(xdc,(BITMAPINFO*)bmihc,0,(LPVOID*)&bits,0,0);
     1996        if (!hbitmap)
     1997            goto ret1;
     1998        if (!SUCCEEDED(IStream_Read( pstm, bits, bmihc->biSizeImage, NULL)))
     1999            goto ret1;
     2000        result = 1;
    20012001    } else
    20022002#endif
    20032003    {
    2004     int i,nwidth,nheight;
    2005 
    2006     nwidth  = width*(height/cy);
    2007     nheight = cy;
    2008 
    2009     if (bitsperpixel==1)
    2010         hbitmap = CreateBitmap(nwidth,nheight,1,1,NULL);
    2011     else
    2012         hbitmap = CreateCompatibleBitmap(xdc,nwidth,nheight);
    2013 
    2014     /* Might be a bit excessive memory use here */
    2015     bits = (LPBYTE)LocalAlloc(LMEM_ZEROINIT,bmihc->biSizeImage);
    2016     nbits = (LPBYTE)LocalAlloc(LMEM_ZEROINIT,bmihc->biSizeImage);
    2017     if (!SUCCEEDED(IStream_Read ( pstm, bits, bmihc->biSizeImage, NULL)))
    2018         goto ret1;
    2019 
    2020     /* Copy the NxM bitmap into a 1x(N*M) bitmap we need, linewise */
    2021     /* Do not forget that windows bitmaps are bottom->top */
    2022     bytesperline    = longsperline*4;
    2023     nbytesperline   = (height/cy)*bytesperline;
    2024     for (i=0;i<height;i++) {
    2025         memcpy(
    2026         nbits+((height-1-i)%cy)*nbytesperline+(i/cy)*bytesperline,
    2027         bits+bytesperline*(height-1-i),
    2028         bytesperline
    2029         );
    2030     }
    2031     bmihc->biWidth  = nwidth;
    2032     bmihc->biHeight = nheight;
    2033     if (!SetDIBits(xdc,hbitmap,0,nheight,nbits,(BITMAPINFO*)bmihc,0))
    2034         goto ret1;
    2035     LocalFree((HLOCAL)nbits);
    2036     LocalFree((HLOCAL)bits);
    2037     result = 1;
     2004        int i,nwidth,nheight;
     2005
     2006        nwidth  = width*(height/cy);
     2007        nheight = cy;
     2008
     2009        if (bitsperpixel==1)
     2010            hbitmap = CreateBitmap(nwidth,nheight,1,1,NULL);
     2011        else
     2012            hbitmap = CreateCompatibleBitmap(xdc,nwidth,nheight);
     2013
     2014        /* Might be a bit excessive memory use here */
     2015        bits = (LPBYTE)LocalAlloc(LMEM_ZEROINIT,bmihc->biSizeImage);
     2016        nbits = (LPBYTE)LocalAlloc(LMEM_ZEROINIT,bmihc->biSizeImage);
     2017        if (!SUCCEEDED(IStream_Read ( pstm, bits, bmihc->biSizeImage, NULL)))
     2018                goto ret1;
     2019
     2020        /* Copy the NxM bitmap into a 1x(N*M) bitmap we need, linewise */
     2021        /* Do not forget that windows bitmaps are bottom->top */
     2022        bytesperline    = longsperline*4;
     2023        nbytesperline   = (height/cy)*bytesperline;
     2024        for (i=0;i<height;i++) {
     2025            memcpy(
     2026                nbits+((height-1-i)%cy)*nbytesperline+(i/cy)*bytesperline,
     2027                bits+bytesperline*(height-1-i),
     2028                bytesperline
     2029            );
     2030        }
     2031        bmihc->biWidth  = nwidth;
     2032        bmihc->biHeight = nheight;
     2033        if (!SetDIBits(xdc,hbitmap,0,nheight,nbits,(BITMAPINFO*)bmihc,0))
     2034                goto ret1;
     2035        LocalFree((HLOCAL)nbits);
     2036        LocalFree((HLOCAL)bits);
     2037        result = 1;
    20382038    }
    20392039ret1:
    2040     if (xdc)    ReleaseDC(0,xdc);
    2041     if (bmihc)  LocalFree((HLOCAL)bmihc);
     2040    if (xdc)    ReleaseDC(0,xdc);
     2041    if (bmihc)  LocalFree((HLOCAL)bmihc);
    20422042    if (!result) {
    2043     if (hbitmap) {
    2044         DeleteObject(hbitmap);
    2045         hbitmap = 0;
    2046     }
     2043        if (hbitmap) {
     2044            DeleteObject(hbitmap);
     2045            hbitmap = 0;
     2046        }
    20472047    }
    20482048    return hbitmap;
     
    20622062 *
    20632063 * The format is like this:
    2064  *  ILHEAD          ilheadstruct;
     2064 *      ILHEAD                  ilheadstruct;
    20652065 *
    20662066 * for the color image part:
    2067  *  BITMAPFILEHEADER    bmfh;
    2068  *  BITMAPINFOHEADER    bmih;
     2067 *      BITMAPFILEHEADER        bmfh;
     2068 *      BITMAPINFOHEADER        bmih;
    20692069 * only if it has a palette:
    2070  *  RGBQUAD     rgbs[nr_of_paletted_colors];
    2071  *
    2072  *  BYTE            colorbits[imagesize];
     2070 *      RGBQUAD         rgbs[nr_of_paletted_colors];
     2071 *
     2072 *      BYTE                    colorbits[imagesize];
    20732073 *
    20742074 * the following only if the ILC_MASK bit is set in ILHEAD.ilFlags:
    2075  *  BITMAPFILEHEADER    bmfh_mask;
    2076  *  BITMAPINFOHEADER    bmih_mask;
     2075 *      BITMAPFILEHEADER        bmfh_mask;
     2076 *      BITMAPINFOHEADER        bmih_mask;
    20772077 * only if it has a palette (it usually does not):
    2078  *  RGBQUAD     rgbs[nr_of_paletted_colors];
    2079  *
    2080  *  BYTE            maskbits[imagesize];
     2078 *      RGBQUAD         rgbs[nr_of_paletted_colors];
     2079 *
     2080 *      BYTE                    maskbits[imagesize];
    20812081 *
    20822082 * CAVEAT: Those images are within a NxM bitmap, not the 1xN we expect.
     
    20852085HIMAGELIST WINAPI ImageList_Read (LPSTREAM pstm)
    20862086{
    2087     ILHEAD  ilHead;
    2088     HIMAGELIST  himl;
    2089     HBITMAP hbmColor=0,hbmMask=0;
    2090     int     i;
     2087    ILHEAD      ilHead;
     2088    HIMAGELIST  himl;
     2089    HBITMAP     hbmColor=0,hbmMask=0;
     2090    int         i;
    20912091
    20922092    if (!SUCCEEDED(IStream_Read (pstm, &ilHead, sizeof(ILHEAD), NULL)))
    2093         return NULL;
     2093        return NULL;
    20942094    if (ilHead.usMagic != (('L' << 8) | 'I'))
    2095     return NULL;
     2095        return NULL;
    20962096    if (ilHead.usVersion != 0x101) /* probably version? */
    2097     return NULL;
     2097        return NULL;
    20982098
    20992099#if 0
    2100     FIXME(" ilHead.cCurImage = %d\n",ilHead.cCurImage);
    2101     FIXME(" ilHead.cMaxImage = %d\n",ilHead.cMaxImage);
    2102     FIXME(" ilHead.cGrow = %d\n",ilHead.cGrow);
    2103     FIXME(" ilHead.cx = %d\n",ilHead.cx);
    2104     FIXME(" ilHead.cy = %d\n",ilHead.cy);
    2105     FIXME(" ilHead.flags = %x\n",ilHead.flags);
    2106     FIXME(" ilHead.ovls[0] = %d\n",ilHead.ovls[0]);
    2107     FIXME(" ilHead.ovls[1] = %d\n",ilHead.ovls[1]);
    2108     FIXME(" ilHead.ovls[2] = %d\n",ilHead.ovls[2]);
    2109     FIXME(" ilHead.ovls[3] = %d\n",ilHead.ovls[3]);
     2100    FIXME("     ilHead.cCurImage = %d\n",ilHead.cCurImage);
     2101    FIXME("     ilHead.cMaxImage = %d\n",ilHead.cMaxImage);
     2102    FIXME("     ilHead.cGrow = %d\n",ilHead.cGrow);
     2103    FIXME("     ilHead.cx = %d\n",ilHead.cx);
     2104    FIXME("     ilHead.cy = %d\n",ilHead.cy);
     2105    FIXME("     ilHead.flags = %x\n",ilHead.flags);
     2106    FIXME("     ilHead.ovls[0] = %d\n",ilHead.ovls[0]);
     2107    FIXME("     ilHead.ovls[1] = %d\n",ilHead.ovls[1]);
     2108    FIXME("     ilHead.ovls[2] = %d\n",ilHead.ovls[2]);
     2109    FIXME("     ilHead.ovls[3] = %d\n",ilHead.ovls[3]);
    21102110#endif
    21112111
    21122112    hbmColor = _read_bitmap(pstm,ilHead.flags & ~ILC_MASK,ilHead.cx,ilHead.cy);
    21132113    if (!hbmColor)
    2114     return NULL;
     2114        return NULL;
    21152115    if (ilHead.flags & ILC_MASK) {
    2116     hbmMask = _read_bitmap(pstm,0,ilHead.cx,ilHead.cy);
    2117     if (!hbmMask) {
    2118         DeleteObject(hbmColor);
    2119         return NULL;
    2120     }
     2116        hbmMask = _read_bitmap(pstm,0,ilHead.cx,ilHead.cy);
     2117        if (!hbmMask) {
     2118            DeleteObject(hbmColor);
     2119            return NULL;
     2120        }
    21212121    }
    21222122
    21232123    himl = ImageList_Create (
    2124             ilHead.cx,
    2125             ilHead.cy,
    2126             ilHead.flags,
    2127             1,      /* initial */
    2128             ilHead.cGrow
     2124                    ilHead.cx,
     2125                    ilHead.cy,
     2126                    ilHead.flags,
     2127                    1,          /* initial */
     2128                    ilHead.cGrow
    21292129    );
    21302130    if (!himl) {
    2131     DeleteObject(hbmColor);
    2132     DeleteObject(hbmMask);
    2133     return NULL;
     2131        DeleteObject(hbmColor);
     2132        DeleteObject(hbmMask);
     2133        return NULL;
    21342134    }
    21352135    himl->hbmImage = hbmColor;
     
    21402140    ImageList_SetBkColor(himl,ilHead.bkcolor);
    21412141    for (i=0;i<4;i++)
    2142         ImageList_SetOverlayImage(himl,ilHead.ovls[i],i+1);
     2142        ImageList_SetOverlayImage(himl,ilHead.ovls[i],i+1);
    21432143    return himl;
    21442144}
     
    21682168        return FALSE;
    21692169    }
    2170 
     2170   
    21712171    if ((i < -1) || (i >= himl->cCurImage)) {
    21722172        ERR("index out of range! %d\n", i);
     
    22112211        TRACE(" - Max. number of images: %d / %d (Old/New)\n",
    22122212                 himl->cMaxImage, himl->cCurImage + himl->cGrow - 1);
    2213 
     2213       
    22142214        hbmNewImage =
    22152215            CreateBitmap (cxNew, himl->cy, 1, himl->uBitsPixel, NULL);
     
    22262226        if (i > 0) {
    22272227            TRACE("Pre image copy: Copy %d images\n", i);
    2228 
     2228       
    22292229            SelectObject (hdcSrc, himl->hbmImage);
    22302230            SelectObject (hdcDst, hbmNewImage);
     
    22772277
    22782278/*************************************************************************
    2279  * ImageList_Replace [COMCTL32.70]
     2279 * ImageList_Replace [COMCTL32.70] 
    22802280 *
    22812281 * Replaces an image in an image list with a new image.
     
    22942294BOOL WINAPI
    22952295ImageList_Replace (HIMAGELIST himl, INT i, HBITMAP hbmImage,
    2296            HBITMAP hbmMask)
     2296                   HBITMAP hbmMask)
    22972297{
    22982298    HDC hdcImageList, hdcImage;
     
    23032303        return FALSE;
    23042304    }
    2305 
     2305   
    23062306    if ((i >= himl->cMaxImage) || (i < 0)) {
    23072307        ERR("Invalid image index!\n");
     
    23332333        */
    23342334        SelectObject (hdcImageList, himl->hbmImage);
    2335         StretchBlt (hdcImageList,
     2335        StretchBlt (hdcImageList, 
    23362336            i*himl->cx, 0, himl->cx, himl->cy,
    2337             hdcImage,
    2338             0, 0, bmp.bmWidth, bmp.bmHeight,
     2337            hdcImage, 
     2338            0, 0, bmp.bmWidth, bmp.bmHeight, 
    23392339            0x220326); /* NOTSRCAND */
    23402340    }
     
    23752375
    23762376    if (himl == NULL)
    2377     return -1;
     2377        return -1;
    23782378    if ((i >= himl->cMaxImage) || (i < -1))
    2379     return -1;
     2379        return -1;
    23802380
    23812381    hBestFitIcon = CopyImage(
    2382         hIcon, IMAGE_ICON,
    2383         himl->cx, himl->cy,
     2382        hIcon, IMAGE_ICON, 
     2383        himl->cx, himl->cy, 
    23842384        LR_COPYFROMRESOURCE);
    23852385
    23862386    GetIconInfo (hBestFitIcon, &ii);
    23872387    if (ii.hbmMask == 0)
    2388     ERR("no mask!\n");
     2388        ERR("no mask!\n");
    23892389    if (ii.hbmColor == 0)
    2390     ERR("no color!\n");
     2390        ERR("no color!\n");
    23912391    GetObjectA (ii.hbmMask, sizeof(BITMAP), (LPVOID)&bmp);
    23922392
     
    24042404    TRACE("hdcImageList=0x%x!\n", hdcImageList);
    24052405    if (hdcImageList == 0)
    2406     ERR("invalid hdcImageList!\n");
     2406        ERR("invalid hdcImageList!\n");
    24072407
    24082408    hdcImage = CreateCompatibleDC (0);
    24092409    TRACE("hdcImage=0x%x!\n", hdcImage);
    24102410    if (hdcImage == 0)
    2411     ERR("invalid hdcImage!\n");
     2411        ERR("invalid hdcImage!\n");
    24122412
    24132413    hbmOldDst = SelectObject (hdcImageList, himl->hbmImage);
     
    24292429
    24302430    if(hBestFitIcon)
    2431     DestroyIcon(hBestFitIcon);
     2431        DestroyIcon(hBestFitIcon);
    24322432    if (hdcImageList)
    2433     DeleteDC (hdcImageList);
     2433        DeleteDC (hdcImageList);
    24342434    if (hdcImage)
    2435     DeleteDC (hdcImage);
     2435        DeleteDC (hdcImage);
    24362436    if (ii.hbmColor)
    2437     DeleteObject (ii.hbmColor);
     2437        DeleteObject (ii.hbmColor);
    24382438    if (ii.hbmMask)
    2439     DeleteObject (ii.hbmMask);
     2439        DeleteObject (ii.hbmMask);
    24402440
    24412441    return nIndex;
     
    24442444
    24452445/*************************************************************************
    2446  * ImageList_SetBkColor [COMCTL32.76]
     2446 * ImageList_SetBkColor [COMCTL32.76] 
    24472447 *
    24482448 * Sets the background color of an image list.
     
    24632463
    24642464    if (himl == NULL)
    2465     return CLR_NONE;
     2465        return CLR_NONE;
    24662466
    24672467    clrOldBk = himl->clrBk;
     
    24922492BOOL WINAPI
    24932493ImageList_SetDragCursorImage (HIMAGELIST himlDrag, INT iDrag,
    2494                   INT dxHotspot, INT dyHotspot)
     2494                              INT dxHotspot, INT dyHotspot)
    24952495{
    24962496    HIMAGELIST himlTemp;
     
    24992499
    25002500    if (himlInternalDrag == NULL)
    2501     return FALSE;
     2501        return FALSE;
    25022502
    25032503    TRACE(" dxH=%d dyH=%d nX=%d nY=%d\n",
    2504        dxHotspot, dyHotspot, nInternalDragHotspotX, nInternalDragHotspotY);
     2504           dxHotspot, dyHotspot, nInternalDragHotspotX, nInternalDragHotspotY);
    25052505
    25062506    himlTemp = ImageList_Merge (himlInternalDrag, 0, himlDrag, iDrag,
    2507                 dxHotspot, dyHotspot);
     2507                                dxHotspot, dyHotspot);
    25082508
    25092509    ImageList_Destroy (himlInternalDrag);
     
    25182518
    25192519/*************************************************************************
    2520  * ImageList_SetFilter [COMCTL32.78]
     2520 * ImageList_SetFilter [COMCTL32.78] 
    25212521 *
    25222522 * Sets a filter (or does something completely different)!!???
     
    25402540{
    25412541    FIXME("(%p 0x%x 0x%lx):empty stub!\n",
    2542        himl, i, dwFilter);
     2542           himl, i, dwFilter);
    25432543
    25442544    return FALSE;
     
    25672567
    25682568    if (!himl)
    2569     return FALSE;
     2569        return FALSE;
    25702570
    25712571    /* remove all images */
     
    26172617
    26182618    if (!himl)
    2619     return FALSE;
     2619        return FALSE;
    26202620    if (himl->cCurImage >= iImageCount)
    2621     return FALSE;
     2621        return FALSE;
    26222622    if (himl->cMaxImage > iImageCount)
    2623     return TRUE;
     2623        return TRUE;
    26242624
    26252625    nNewCount = iImageCount + himl->cGrow;
     
    26362636        SelectObject (hdcBitmap, hbmNewBitmap);
    26372637
    2638     /* copy images */
     2638        /* copy images */
    26392639        BitBlt (hdcBitmap, 0, 0, nCopyCount * himl->cx, himl->cy,
    26402640                  hdcImageList, 0, 0, SRCCOPY);
    26412641#if 0
    2642     /* delete 'empty' image space */
    2643     SetBkColor (hdcBitmap, RGB(255, 255, 255));
    2644     SetTextColor (hdcBitmap, RGB(0, 0, 0));
    2645     PatBlt (hdcBitmap,  nCopyCount * himl->cx, 0,
    2646           (nNewCount - nCopyCount) * himl->cx, himl->cy, BLACKNESS);
     2642        /* delete 'empty' image space */
     2643        SetBkColor (hdcBitmap, RGB(255, 255, 255));
     2644        SetTextColor (hdcBitmap, RGB(0, 0, 0));
     2645        PatBlt (hdcBitmap,  nCopyCount * himl->cx, 0,
     2646                  (nNewCount - nCopyCount) * himl->cx, himl->cy, BLACKNESS);
    26472647#endif
    2648     DeleteObject (himl->hbmImage);
    2649     himl->hbmImage = hbmNewBitmap;
     2648        DeleteObject (himl->hbmImage);
     2649        himl->hbmImage = hbmNewBitmap;
    26502650    }
    26512651    else
    2652     ERR("Could not create new image bitmap !\n");
     2652        ERR("Could not create new image bitmap !\n");
    26532653
    26542654    if (himl->hbmMask)
     
    26612661            SelectObject (hdcBitmap, hbmNewBitmap);
    26622662
    2663         /* copy images */
     2663            /* copy images */
    26642664            BitBlt (hdcBitmap, 0, 0, nCopyCount * himl->cx, himl->cy,
    26652665                      hdcImageList, 0, 0, SRCCOPY);
    26662666#if 0
    2667         /* delete 'empty' image space */
    2668         SetBkColor (hdcBitmap, RGB(255, 255, 255));
    2669         SetTextColor (hdcBitmap, RGB(0, 0, 0));
    2670             PatBlt (hdcBitmap,  nCopyCount * himl->cx, 0,
    2671               (nNewCount - nCopyCount) * himl->cx, himl->cy, BLACKNESS);
     2667            /* delete 'empty' image space */
     2668            SetBkColor (hdcBitmap, RGB(255, 255, 255));
     2669            SetTextColor (hdcBitmap, RGB(0, 0, 0));
     2670            PatBlt (hdcBitmap,  nCopyCount * himl->cx, 0, 
     2671                      (nNewCount - nCopyCount) * himl->cx, himl->cy, BLACKNESS);
    26722672#endif
    26732673            DeleteObject (himl->hbmMask);
     
    27092709{
    27102710    if (!himl)
    2711     return FALSE;
     2711        return FALSE;
    27122712    if ((iOverlay < 1) || (iOverlay > MAX_OVERLAYIMAGE))
    2713     return FALSE;
     2713        return FALSE;
    27142714    if ((iImage!=-1) && ((iImage < 0) || (iImage > himl->cCurImage)))
    2715     return FALSE;
     2715        return FALSE;
    27162716    himl->nOvlIdx[iOverlay - 1] = iImage;
    27172717    return TRUE;
     
    27442744{
    27452745    if (!himl)
     2746        return FALSE;
     2747
     2748    FIXME("empty stub!\n");
     2749
    27462750    return FALSE;
    2747 
    2748     FIXME("empty stub!\n");
    2749 
    2750     return FALSE;
    2751 }
    2752 
     2751}
     2752
  • trunk/src/comctl32/monthcal.c

    r6705 r6709  
    11/* Month calendar control
    2  *
     2
    33 *
    44 * Copyright 1998, 1999 Eric Kohl (ekohl@abo.rhein-zeitung.de)
    55 * Copyright 1999 Alex Priem (alexp@sci.kun.nl)
    66 * Copyright 1999 Chris Morgan <cmorgan@wpi.edu> and
    7  *        James Abbatiello <abbeyj@wpi.edu>
     7 *                James Abbatiello <abbeyj@wpi.edu>
    88 * Copyright 2000 Uwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
    99 *
     
    1313 *
    1414 *  FIXME: handle resources better (doesn't work now); also take care
    15  *         of internationalization.
     15           of internationalization.
    1616 *  FIXME: keyboard handling.
    1717 */
     
    4343DEFAULT_DEBUG_CHANNEL(monthcal);
    4444
    45 #define MC_SEL_LBUTUP       1   /* Left button released */
    46 #define MC_SEL_LBUTDOWN     2   /* Left button pressed in calendar */
     45#define MC_SEL_LBUTUP       1   /* Left button released */
     46#define MC_SEL_LBUTDOWN     2   /* Left button pressed in calendar */
    4747#define MC_PREVPRESSED      4   /* Prev month button pressed */
    4848#define MC_NEXTPRESSED      8   /* Next month button pressed */
    49 #define MC_NEXTMONTHDELAY   350 /* when continuously pressing `next */
    50                                         /* month', wait 500 ms before going */
    51                                         /* to the next month */
    52 #define MC_NEXTMONTHTIMER   1           /* Timer ID's */
    53 #define MC_PREVMONTHTIMER   2
     49#define MC_NEXTMONTHDELAY   350 /* when continuously pressing `next */
     50                                                                                /* month', wait 500 ms before going */
     51                                                                                /* to the next month */
     52#define MC_NEXTMONTHTIMER   1                   /* Timer ID's */
     53#define MC_PREVMONTHTIMER   2                   
    5454
    5555typedef struct
     
    5858    COMCTL32_HEADER header;
    5959#endif
    60     COLORREF    bk;
    61     COLORREF    txt;
    62     COLORREF    titlebk;
    63     COLORREF    titletxt;
    64     COLORREF    monthbk;
    65     COLORREF    trailingtxt;
    66     HFONT   hFont;
    67     HFONT   hBoldFont;
    68     int     textHeight;
    69     int     textWidth;
    70     int     height_increment;
    71     int     width_increment;
    72     int     left_offset;
    73     int     top_offset;
    74     int     firstDayplace; /* place of the first day of the current month */
    75     int     delta;  /* scroll rate; # of months that the */
     60    COLORREF    bk;
     61    COLORREF    txt;
     62    COLORREF    titlebk;
     63    COLORREF    titletxt;
     64    COLORREF    monthbk;
     65    COLORREF    trailingtxt;
     66    HFONT       hFont;
     67    HFONT       hBoldFont;
     68    int         textHeight;
     69    int         textWidth;
     70    int         height_increment;
     71    int         width_increment;
     72    int         left_offset;
     73    int         top_offset;
     74    int         firstDayplace; /* place of the first day of the current month */
     75    int         delta;  /* scroll rate; # of months that the */
    7676                        /* control moves when user clicks a scroll button */
    77     int     visible;    /* # of months visible */
    78     int     firstDay;   /* Start month calendar with firstDay's day */
    79     int     monthRange;
     77    int         visible;        /* # of months visible */
     78    int         firstDay;       /* Start month calendar with firstDay's day */
     79    int         monthRange;
    8080    MONTHDAYSTATE *monthdayState;
    81     SYSTEMTIME  todaysDate;
    82     DWORD   currentMonth;
    83     DWORD   currentYear;
    84     int     status;     /* See MC_SEL flags */
    85     int     curSelDay;  /* current selected day */
    86     int     firstSelDay;    /* first selected day */
    87     int     maxSelCount;
    88     SYSTEMTIME  minSel;
    89     SYSTEMTIME  maxSel;
    90     DWORD   rangeValid;
    91     SYSTEMTIME  minDate;
    92     SYSTEMTIME  maxDate;
    93 
    94     RECT rcClient;  /* rect for whole client area */
    95     RECT rcDraw;    /* rect for drawable portion of client area */
    96     RECT title;     /* rect for the header above the calendar */
    97     RECT titlebtnnext;  /* the `next month' button in the header */
    98     RECT titlebtnprev;  /* the `prev month' button in the header */
    99     RECT titlemonth;    /* the `month name' txt in the header */
    100     RECT titleyear; /* the `year number' txt in the header */
    101     RECT wdays;     /* week days at top */
    102     RECT days;      /* calendar area */
    103     RECT weeknums;  /* week numbers at left side */
    104     RECT todayrect; /* `today: xx/xx/xx' text rect */
     81    SYSTEMTIME  todaysDate;
     82    DWORD       currentMonth;
     83    DWORD       currentYear;
     84    int         status;         /* See MC_SEL flags */
     85    int         curSelDay;      /* current selected day */
     86    int         firstSelDay;    /* first selected day */
     87    int         maxSelCount;
     88    SYSTEMTIME  minSel;
     89    SYSTEMTIME  maxSel;
     90    DWORD       rangeValid;
     91    SYSTEMTIME  minDate;
     92    SYSTEMTIME  maxDate;
     93               
     94    RECT rcClient;      /* rect for whole client area */
     95    RECT rcDraw;        /* rect for drawable portion of client area */
     96    RECT title;         /* rect for the header above the calendar */
     97    RECT titlebtnnext;  /* the `next month' button in the header */
     98    RECT titlebtnprev;  /* the `prev month' button in the header */     
     99    RECT titlemonth;    /* the `month name' txt in the header */
     100    RECT titleyear;     /* the `year number' txt in the header */
     101    RECT wdays;         /* week days at top */
     102    RECT days;          /* calendar area */
     103    RECT weeknums;      /* week numbers at left side */
     104    RECT todayrect;     /* `today: xx/xx/xx' text rect */
    105105    HWND hWndYearEdit;  /* Window Handle of edit box to handle years */
    106106    HWND hWndYearUpDown;/* Window Handle of updown box to handle years */
     
    141141
    142142/* make sure that time is valid */
    143 static int MONTHCAL_ValidateTime(SYSTEMTIME time)
     143static int MONTHCAL_ValidateTime(SYSTEMTIME time) 
    144144{
    145145  if(time.wMonth > 12) return FALSE;
    146146  if(time.wDayOfWeek > 6) return FALSE;
    147147  if(time.wDay > MONTHCAL_MonthLength(time.wMonth, time.wYear))
    148       return FALSE;
     148          return FALSE;
    149149  if(time.wHour > 23) return FALSE;
    150150  if(time.wMinute > 59) return FALSE;
     
    156156
    157157
    158 void MONTHCAL_CopyTime(const SYSTEMTIME *from, SYSTEMTIME *to)
     158void MONTHCAL_CopyTime(const SYSTEMTIME *from, SYSTEMTIME *to) 
    159159{
    160160  to->wYear = from->wYear;
     
    169169
    170170
    171 /* Note:Depending on DST, this may be offset by a day.
     171/* Note:Depending on DST, this may be offset by a day. 
    172172   Need to find out if we're on a DST place & adjust the clock accordingly.
    173173   Above function assumes we have a valid data.
     
    182182  year-=(month < 3);
    183183
    184   return((year + year/4 - year/100 + year/400 +
     184  return((year + year/4 - year/100 + year/400 + 
    185185         DayOfWeekTable[month-1] + day - 1 ) % 7);
    186186}
     
    189189   and day in the calendar. day== 0 mean the last day of tha last month
    190190*/
    191 static int MONTHCAL_CalcDayFromPos(MONTHCAL_INFO *infoPtr, int x, int y,
    192                    int *daypos,int *weekpos)
     191static int MONTHCAL_CalcDayFromPos(MONTHCAL_INFO *infoPtr, int x, int y, 
     192                                   int *daypos,int *weekpos)
    193193{
    194194  int retval, firstDay;
     
    202202  *daypos = (x - infoPtr->days.left ) / infoPtr->width_increment;
    203203  *weekpos = (y - infoPtr->days.top ) / infoPtr->height_increment;
    204 
     204   
    205205  firstDay = (MONTHCAL_CalculateDayOfWeek(1, infoPtr->currentMonth, infoPtr->currentYear)+6 - infoPtr->firstDay)%7;
    206206  retval = *daypos + (7 * *weekpos) - firstDay;
     
    211211/* sets x and y to be the position of the day */
    212212/* x == day, y == week where(0,0) == firstDay, 1st week */
    213 static void MONTHCAL_CalcDayXY(MONTHCAL_INFO *infoPtr, int day, int month,
     213static void MONTHCAL_CalcDayXY(MONTHCAL_INFO *infoPtr, int day, int month, 
    214214                                 int *x, int *y)
    215215{
     
    227227    if(prevMonth==0)
    228228       prevMonth = 12;
    229 
     229   
    230230    *x = (MONTHCAL_MonthLength(prevMonth, infoPtr->currentYear) - firstDay) % 7;
    231231    *y = 0;
     
    240240
    241241/* x: column(day), y: row(week) */
    242 static void MONTHCAL_CalcDayRect(MONTHCAL_INFO *infoPtr, RECT *r, int x, int y)
     242static void MONTHCAL_CalcDayRect(MONTHCAL_INFO *infoPtr, RECT *r, int x, int y) 
    243243{
    244244  r->left = infoPtr->days.left + x * infoPtr->width_increment;
     
    252252/* day is the day value of the month(1 == 1st), month is the month */
    253253/* value(january == 1, december == 12) */
    254 static inline void MONTHCAL_CalcPosFromDay(MONTHCAL_INFO *infoPtr,
     254static inline void MONTHCAL_CalcPosFromDay(MONTHCAL_INFO *infoPtr, 
    255255                                            int day, int month, RECT *r)
    256256{
     
    278278  x = day_rect.left;
    279279  y = day_rect.top;
    280 
     280       
    281281  points[0].x = x;
    282282  points[0].y = y - 1;
     
    287287  points[3].x = x + infoPtr->width_increment;
    288288  points[3].y = y + 0.5 * infoPtr->height_increment;
    289 
     289       
    290290  points[4].x = x + infoPtr->width_increment;
    291291  points[4].y = y + 0.9 * infoPtr->height_increment;
     
    294294  points[6].x = x + 0.5 * infoPtr->width_increment;
    295295  points[6].y = y + 0.9 * infoPtr->height_increment; /* bring the bottom up just
    296                 a hair to fit inside the day rectangle */
    297 
     296                                a hair to fit inside the day rectangle */
     297       
    298298  points[7].x = x + 0.2 * infoPtr->width_increment;
    299299  points[7].y = y + 0.8 * infoPtr->height_increment;
     
    309309  points[12].x = x + 0.4 * infoPtr->width_increment;
    310310  points[12].y = y + 0.2 * infoPtr->height_increment;
    311 
     311 
    312312  PolyBezier(hdc, points, 13);
    313313  DeleteObject(hRedPen);
     
    329329  sprintf(buf, "%d", day);
    330330
    331 /* No need to check styles: when selection is not valid, it is set to zero.
     331/* No need to check styles: when selection is not valid, it is set to zero. 
    332332 * 1<day<31, so evertyhing's OK.
    333333 */
     
    349349
    350350    /* FIXME: this may need to be changed now b/c of the other
    351     drawing changes 11/3/99 CMM */
     351        drawing changes 11/3/99 CMM */
    352352    r2.left   = r.left - 0.25 * infoPtr->textWidth;
    353353    r2.top    = r.top;
     
    390390
    391391/* CHECKME: For `todays date', do we need to check the locale?*/
    392 static void MONTHCAL_Refresh(HWND hwnd, HDC hdc, PAINTSTRUCT* ps)
     392static void MONTHCAL_Refresh(HWND hwnd, HDC hdc, PAINTSTRUCT* ps) 
    393393{
    394394  MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd);
     
    425425  hbr = CreateSolidBrush (infoPtr->bk);
    426426  FillRect(hdc, rcClient, hbr);
    427   DeleteObject(hbr);
     427  DeleteObject(hbr);       
    428428
    429429  /* draw header */
     
    434434    DeleteObject(hbr);
    435435  }
    436 
     436       
    437437  /* if the previous button is pressed draw it depressed */
    438438  if(IntersectRect(&rcTemp, &(ps->rcPaint), prev))
    439   {
     439  { 
    440440    if((infoPtr->status & MC_PREVPRESSED))
    441441        DrawFrameControl(hdc, prev, DFC_SCROLL,
    442        DFCS_SCROLLLEFT | DFCS_PUSHED |
     442           DFCS_SCROLLLEFT | DFCS_PUSHED |
    443443          (dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0));
    444444    else /* if the previous button is pressed draw it depressed */
    445445      DrawFrameControl(hdc, prev, DFC_SCROLL,
    446        DFCS_SCROLLLEFT |(dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0));
    447   }
    448 
    449   /* if next button is depressed draw it depressed */
     446           DFCS_SCROLLLEFT |(dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0));
     447  }
     448
     449  /* if next button is depressed draw it depressed */   
    450450  if(IntersectRect(&rcTemp, &(ps->rcPaint), next))
    451451  {
    452452    if((infoPtr->status & MC_NEXTPRESSED))
    453453      DrawFrameControl(hdc, next, DFC_SCROLL,
    454            DFCS_SCROLLRIGHT | DFCS_PUSHED |
     454           DFCS_SCROLLRIGHT | DFCS_PUSHED |
    455455           (dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0));
    456456    else /* if the next button is pressed draw it depressed */
     
    466466  titlemonth->left   = title->left;
    467467  titlemonth->right  = title->right;
    468 
     468 
    469469  GetLocaleInfoA( LOCALE_USER_DEFAULT,LOCALE_SMONTHNAME1+infoPtr->currentMonth -1,
    470           buf1,sizeof(buf1));
     470                  buf1,sizeof(buf1));
    471471  sprintf(buf, "%s %ld", buf1, infoPtr->currentYear);
    472 
     472 
    473473  if(IntersectRect(&rcTemp, &(ps->rcPaint), titlemonth))
    474474  {
    475     DrawTextA(hdc, buf, strlen(buf), titlemonth,
     475    DrawTextA(hdc, buf, strlen(buf), titlemonth, 
    476476                        DT_CENTER | DT_VCENTER | DT_SINGLELINE);
    477477  }
     
    481481/* titlemonth left/right contained rect for whole titletxt('June  1999')
    482482  * MCM_HitTestInfo wants month & year rects, so prepare these now.
    483   *(no, we can't draw them separately; the whole text is centered)
     483  *(no, we can't draw them separately; the whole text is centered) 
    484484  */
    485485  GetTextExtentPoint32A(hdc, buf, strlen(buf), &size);
     
    489489  titlemonth->right = titlemonth->left + size.cx;
    490490  titleyear->left = titlemonth->right;
    491 
     491 
    492492  /* draw month area */
    493493  rcTemp.top=infoPtr->wdays.top;
     
    501501    DeleteObject(hbr);
    502502  }
    503 
     503       
    504504/* draw line under day abbreviatons */
    505505
    506506  MoveToEx(hdc, infoPtr->days.left + 3, title->bottom + textHeight + 1, NULL);
    507 
     507     
    508508  LineTo(hdc, rcDraw->right - 3, title->bottom + textHeight + 1);
    509 
     509 
    510510  prevMonth = infoPtr->currentMonth - 1;
    511511  if(prevMonth == 0) /* if currentMonth is january(1) prevMonth is */
     
    529529  for(j=0; j<7; j++) {
    530530    GetLocaleInfoA( LOCALE_USER_DEFAULT,LOCALE_SABBREVDAYNAME1 + (i +j)%7,
    531             buf,sizeof(buf));
     531                    buf,sizeof(buf));
    532532    DrawTextA(hdc, buf, strlen(buf), days,
    533533                         DT_CENTER | DT_VCENTER | DT_SINGLELINE );
     
    537537
    538538/* draw day numbers; first, the previous month */
    539 
     539 
    540540  firstDay = MONTHCAL_CalculateDayOfWeek(1, infoPtr->currentMonth, infoPtr->currentYear);
    541 
    542   day = MONTHCAL_MonthLength(prevMonth, infoPtr->currentYear)  +
     541 
     542  day = MONTHCAL_MonthLength(prevMonth, infoPtr->currentYear)  + 
    543543    (infoPtr->firstDay + 7  - firstDay)%7 + 1;
    544544  if (day > MONTHCAL_MonthLength(prevMonth, infoPtr->currentYear))
     
    553553    if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay))
    554554    {
    555       MONTHCAL_DrawDay(hdc, infoPtr, day, prevMonth, i, 0,
     555      MONTHCAL_DrawDay(hdc, infoPtr, day, prevMonth, i, 0, 
    556556          infoPtr->monthdayState[m] & mask);
    557557    }
     
    577577    {
    578578
    579       MONTHCAL_DrawDay(hdc, infoPtr, day, infoPtr->currentMonth, i, 0,
    580     infoPtr->monthdayState[m] & mask);
     579      MONTHCAL_DrawDay(hdc, infoPtr, day, infoPtr->currentMonth, i, 0, 
     580        infoPtr->monthdayState[m] & mask);
    581581
    582582      if((infoPtr->currentMonth==infoPtr->todaysDate.wMonth) &&
    583583          (day==infoPtr->todaysDate.wDay) &&
    584       (infoPtr->currentYear == infoPtr->todaysDate.wYear)) {
     584          (infoPtr->currentYear == infoPtr->todaysDate.wYear)) {
    585585        if(!(dwStyle & MCS_NOTODAYCIRCLE))
    586       MONTHCAL_CircleDay(hdc, infoPtr, day, infoPtr->currentMonth);
     586          MONTHCAL_CircleDay(hdc, infoPtr, day, infoPtr->currentMonth);
    587587      }
    588588    }
     
    595595  j = 1; /* move to the 2nd week of the current month */
    596596  i = 0; /* move back to sunday */
    597   while(day <= MONTHCAL_MonthLength(infoPtr->currentMonth, infoPtr->currentYear)) {
     597  while(day <= MONTHCAL_MonthLength(infoPtr->currentMonth, infoPtr->currentYear)) {     
    598598    MONTHCAL_CalcDayRect(infoPtr, &rcDay, i, j);
    599599    if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay))
     
    604604      if((infoPtr->currentMonth==infoPtr->todaysDate.wMonth) &&
    605605          (day==infoPtr->todaysDate.wDay) &&
    606           (infoPtr->currentYear == infoPtr->todaysDate.wYear))
    607         if(!(dwStyle & MCS_NOTODAYCIRCLE))
    608       MONTHCAL_CircleDay(hdc, infoPtr, day, infoPtr->currentMonth);
     606          (infoPtr->currentYear == infoPtr->todaysDate.wYear)) 
     607        if(!(dwStyle & MCS_NOTODAYCIRCLE)) 
     608          MONTHCAL_CircleDay(hdc, infoPtr, day, infoPtr->currentMonth);
    609609    }
    610610    mask<<=1;
     
    627627    MONTHCAL_CalcDayRect(infoPtr, &rcDay, i, j);
    628628    if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay))
    629     {
     629    {   
    630630      MONTHCAL_DrawDay(hdc, infoPtr, day, infoPtr->currentMonth + 1, i, j,
    631         infoPtr->monthdayState[m] & mask);
     631                infoPtr->monthdayState[m] & mask);
    632632    }
    633633
    634634    mask<<=1;
    635635    day++;
    636     i++;
     636    i++;       
    637637    if(i==7) { /* past saturday, go to next week's sunday */
    638638      i = 0;
     
    650650    if(!(dwStyle & MCS_NOTODAYCIRCLE))  {
    651651      /*day is the number of days from nextmonth we put on the calendar */
    652       MONTHCAL_CircleDay(hdc, infoPtr,
    653              day+MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear),
    654             infoPtr->currentMonth);
     652      MONTHCAL_CircleDay(hdc, infoPtr, 
     653                         day+MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear),
     654                        infoPtr->currentMonth);
    655655      offset+=textWidth;
    656656    }
    657657    if (!LoadStringA(COMCTL32_hModule,IDM_TODAY,buf1,sizeof(buf1)))
    658658      {
    659     WARN("Can't load resource\n");
    660     strcpy(buf1,"Today:");
     659        WARN("Can't load resource\n");
     660        strcpy(buf1,"Today:");
    661661      }
    662662    MONTHCAL_CalcDayRect(infoPtr, &rtoday, 1, 6);
     
    674674  }
    675675
    676 /*eventually draw week numbers*/
     676/*eventually draw week numbers*/   
    677677  if(dwStyle & MCS_WEEKNUMBERS)  {
    678678    /* display weeknumbers*/
     
    682682       LOCALE_IFIRSTWEEKOFYEAR == 0 (e.g US?):
    683683       The week containing Jan 1 is the first week of year
    684        LOCALE_IFIRSTWEEKOFYEAR == 2 (e.g. Germany):
     684       LOCALE_IFIRSTWEEKOFYEAR == 2 (e.g. Germany): 
    685685       First week of year must contain 4 days of the new year
    686686       LOCALE_IFIRSTWEEKOFYEAR == 1  (what contries?)
     
    688688    */
    689689    GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_IFIRSTWEEKOFYEAR,
    690              buf, sizeof(buf));
     690                     buf, sizeof(buf));
    691691    sscanf(buf, "%d", &weeknum);
    692692    switch (weeknum)
    693693      {
    694694      case 1: mindays = 6;
    695     break;
     695        break;
    696696      case 2: mindays = 3;
    697     break;
     697        break;
    698698      case 0:
    699699      default:
    700     mindays = 0;
     700        mindays = 0;
    701701      }
    702702    if (infoPtr->currentMonth < 2)
    703703      {
    704     /* calculate all those exceptions for january */
    705     weeknum1=MONTHCAL_CalculateDayOfWeek(1,1,infoPtr->currentYear);
    706     if ((infoPtr->firstDay +7 - weeknum1)%7 > mindays)
    707         weeknum =1;
    708     else
    709       {
    710         weeknum = 0;
    711         for(i=0; i<11; i++)
    712           weeknum+=MONTHCAL_MonthLength(i+1, infoPtr->currentYear-1);
    713         weeknum +=startofprescal+ 7;
    714         weeknum /=7;
    715         weeknum1=MONTHCAL_CalculateDayOfWeek(1,1,infoPtr->currentYear-1);
    716         if ((infoPtr->firstDay + 7 - weeknum1)%7 > mindays)
    717           weeknum++;
    718       }
     704        /* calculate all those exceptions for january */
     705        weeknum1=MONTHCAL_CalculateDayOfWeek(1,1,infoPtr->currentYear);
     706        if ((infoPtr->firstDay +7 - weeknum1)%7 > mindays)
     707            weeknum =1;
     708        else
     709          {
     710            weeknum = 0;
     711            for(i=0; i<11; i++)
     712              weeknum+=MONTHCAL_MonthLength(i+1, infoPtr->currentYear-1);
     713            weeknum +=startofprescal+ 7;
     714            weeknum /=7;
     715            weeknum1=MONTHCAL_CalculateDayOfWeek(1,1,infoPtr->currentYear-1);
     716            if ((infoPtr->firstDay + 7 - weeknum1)%7 > mindays)
     717              weeknum++;
     718          }
    719719      }
    720720    else
    721721      {
    722     weeknum = 0;
    723     for(i=0; i<prevMonth-1; i++)
    724       weeknum+=MONTHCAL_MonthLength(i+1, infoPtr->currentYear);
    725     weeknum +=startofprescal+ 7;
    726     weeknum /=7;
    727     weeknum1=MONTHCAL_CalculateDayOfWeek(1,1,infoPtr->currentYear);
    728     if ((infoPtr->firstDay + 7 - weeknum1)%7 > mindays)
    729       weeknum++;
     722        weeknum = 0;
     723        for(i=0; i<prevMonth-1; i++)
     724          weeknum+=MONTHCAL_MonthLength(i+1, infoPtr->currentYear);
     725        weeknum +=startofprescal+ 7;
     726        weeknum /=7;
     727        weeknum1=MONTHCAL_CalculateDayOfWeek(1,1,infoPtr->currentYear);
     728        if ((infoPtr->firstDay + 7 - weeknum1)%7 > mindays)
     729          weeknum++;
    730730      }
    731731    days->left = infoPtr->weeknums.left;
     
    735735    for(i=0; i<6; i++) {
    736736      if((i==0)&&(weeknum>50))
    737     {
    738       sprintf(buf, "%d", weeknum);
    739       weeknum=0;
    740     }
     737        {
     738          sprintf(buf, "%d", weeknum);
     739          weeknum=0;
     740        }
    741741      else if((i==5)&&(weeknum>47))
    742     {
    743       sprintf(buf, "%d", 1);
    744     }
     742        {
     743          sprintf(buf, "%d", 1);
     744        }
    745745      else
    746     sprintf(buf, "%d", weeknum + i);
     746        sprintf(buf, "%d", weeknum + i);
    747747      DrawTextA(hdc, buf, -1, days, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
    748748      days->top+=infoPtr->height_increment;
    749749      days->bottom+=infoPtr->height_increment;
    750750    }
    751 
     751                       
    752752    MoveToEx(hdc, infoPtr->weeknums.right, infoPtr->weeknums.top + 3 , NULL);
    753753    LineTo(hdc,   infoPtr->weeknums.right, infoPtr->weeknums.bottom );
    754 
     754               
    755755  }
    756756  /* currentFont was font at entering Refresh */
    757757
    758758  SetBkColor(hdc, oldBkColor);
    759   SelectObject(hdc, currentFont);
     759  SelectObject(hdc, currentFont);     
    760760  SetTextColor(hdc, oldTextColor);
    761761}
    762762
    763763
    764 static LRESULT
     764static LRESULT 
    765765MONTHCAL_GetMinReqRect(HWND hwnd, WPARAM wParam, LPARAM lParam)
    766766{
     
    768768  LPRECT lpRect = (LPRECT) lParam;
    769769  TRACE("%x %lx\n", wParam, lParam);
    770 
     770       
    771771  /* validate parameters */
    772772
     
    781781
    782782
    783 static LRESULT
     783static LRESULT 
    784784MONTHCAL_GetColor(HWND hwnd, WPARAM wParam, LPARAM lParam)
    785785{
     
    807807
    808808
    809 static LRESULT
     809static LRESULT 
    810810MONTHCAL_SetColor(HWND hwnd, WPARAM wParam, LPARAM lParam)
    811811{
     
    847847
    848848
    849 static LRESULT
     849static LRESULT 
    850850MONTHCAL_GetMonthDelta(HWND hwnd, WPARAM wParam, LPARAM lParam)
    851851{
     
    853853
    854854  TRACE("%x %lx\n", wParam, lParam);
    855 
     855 
    856856  if(infoPtr->delta)
    857857    return infoPtr->delta;
     
    861861
    862862
    863 static LRESULT
     863static LRESULT 
    864864MONTHCAL_SetMonthDelta(HWND hwnd, WPARAM wParam, LPARAM lParam)
    865865{
     
    868868
    869869  TRACE("%x %lx\n", wParam, lParam);
    870 
     870       
    871871  infoPtr->delta = (int)wParam;
    872872  return prev;
     
    874874
    875875
    876 static LRESULT
     876static LRESULT 
    877877MONTHCAL_GetFirstDayOfWeek(HWND hwnd, WPARAM wParam, LPARAM lParam)
    878878{
    879879  MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
    880 
     880       
    881881  return infoPtr->firstDay;
    882882}
     
    887887/* FIXME: this needs to be implemented properly in MONTHCAL_Refresh() */
    888888/* FIXME: we need more error checking here */
    889 static LRESULT
     889static LRESULT 
    890890MONTHCAL_SetFirstDayOfWeek(HWND hwnd, WPARAM wParam, LPARAM lParam)
    891891{
     
    903903    {
    904904      GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_IFIRSTDAYOFWEEK,
    905              buf, sizeof(buf));
     905                     buf, sizeof(buf));
    906906      TRACE("%s %d\n", buf, strlen(buf));
    907907      if(sscanf(buf, "%d", &day) == 1)
    908     infoPtr->firstDay = day;
     908        infoPtr->firstDay = day;
    909909      else
    910     infoPtr->firstDay = 0;
     910        infoPtr->firstDay = 0;
    911911    }
    912912  return prev;
     
    916916/* FIXME: fill this in */
    917917static LRESULT
    918 MONTHCAL_GetMonthRange(HWND hwnd, WPARAM wParam, LPARAM lParam)
     918MONTHCAL_GetMonthRange(HWND hwnd, WPARAM wParam, LPARAM lParam) 
    919919{
    920920  MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
     
    937937
    938938/* FIXME: are validated times taken from current date/time or simply
    939  * copied?
     939 * copied? 
    940940 * FIXME:    check whether MCM_GETMONTHRANGE shows correct result after
    941941 *            adjusting range with MCM_SETRANGE
     
    950950
    951951  TRACE("%x %lx\n", wParam, lParam);
    952 
     952 
    953953  if(wParam & GDTR_MAX) {
    954954    if(MONTHCAL_ValidateTime(lprgSysTimeArray[1])){
     
    973973  infoPtr->monthRange = infoPtr->maxDate.wMonth - infoPtr->minDate.wMonth;
    974974
    975   if(infoPtr->monthRange!=prev) {
    976     COMCTL32_ReAlloc(infoPtr->monthdayState,
    977         infoPtr->monthRange * sizeof(MONTHDAYSTATE));
     975  if(infoPtr->monthRange!=prev) { 
     976        COMCTL32_ReAlloc(infoPtr->monthdayState,
     977                infoPtr->monthRange * sizeof(MONTHDAYSTATE));
    978978  }
    979979
     
    983983
    984984/* CHECKME: At the moment, we copy ranges anyway,regardless of
    985  * infoPtr->rangeValid; a invalid range is simply filled with zeros in
     985 * infoPtr->rangeValid; a invalid range is simply filled with zeros in 
    986986 * SetRange.  Is this the right behavior?
    987987*/
     
    10151015  if(iMonths!=infoPtr->monthRange) return 0;
    10161016
    1017   for(i=0; i<iMonths; i++)
     1017  for(i=0; i<iMonths; i++) 
    10181018    infoPtr->monthdayState[i] = dayStates[i];
    10191019  return 1;
    10201020}
    10211021
    1022 static LRESULT
     1022static LRESULT 
    10231023MONTHCAL_GetCurSel(HWND hwnd, WPARAM wParam, LPARAM lParam)
    10241024{
     
    10361036/* FIXME: if the specified date is not visible, make it visible */
    10371037/* FIXME: redraw? */
    1038 static LRESULT
     1038static LRESULT 
    10391039MONTHCAL_SetCurSel(HWND hwnd, WPARAM wParam, LPARAM lParam)
    10401040{
     
    10571057
    10581058
    1059 static LRESULT
     1059static LRESULT 
    10601060MONTHCAL_GetMaxSelCount(HWND hwnd, WPARAM wParam, LPARAM lParam)
    10611061{
     
    10671067
    10681068
    1069 static LRESULT
     1069static LRESULT 
    10701070MONTHCAL_SetMaxSelCount(HWND hwnd, WPARAM wParam, LPARAM lParam)
    10711071{
     
    10811081
    10821082
    1083 static LRESULT
     1083static LRESULT 
    10841084MONTHCAL_GetSelRange(HWND hwnd, WPARAM wParam, LPARAM lParam)
    10851085{
     
    11001100    return TRUE;
    11011101  }
    1102 
     1102 
    11031103  return FALSE;
    11041104}
    11051105
    11061106
    1107 static LRESULT
     1107static LRESULT 
    11081108MONTHCAL_SetSelRange(HWND hwnd, WPARAM wParam, LPARAM lParam)
    11091109{
     
    11241124    return TRUE;
    11251125  }
    1126 
     1126 
    11271127  return FALSE;
    11281128}
    11291129
    11301130
    1131 static LRESULT
     1131static LRESULT 
    11321132MONTHCAL_GetToday(HWND hwnd, WPARAM wParam, LPARAM lParam)
    11331133{
     
    11451145
    11461146
    1147 static LRESULT
     1147static LRESULT 
    11481148MONTHCAL_SetToday(HWND hwnd, WPARAM wParam, LPARAM lParam)
    11491149{
     
    11701170  DWORD retval;
    11711171  int day,wday,wnum;
    1172 
    1173 
     1172 
     1173 
    11741174  x = lpht->pt.x;
    11751175  y = lpht->pt.y;
    11761176  retval = MCHT_NOWHERE;
    1177 
    1178 
    1179   /* Comment in for debugging...
    1180   TRACE("%d %d wd[%d %d %d %d] d[%d %d %d %d] t[%d %d %d %d] wn[%d %d %d %d]\n", x, y,
    1181     infoPtr->wdays.left, infoPtr->wdays.right,
    1182     infoPtr->wdays.top, infoPtr->wdays.bottom,
    1183     infoPtr->days.left, infoPtr->days.right,
    1184     infoPtr->days.top, infoPtr->days.bottom,
    1185     infoPtr->todayrect.left, infoPtr->todayrect.right,
    1186     infoPtr->todayrect.top, infoPtr->todayrect.bottom,
    1187     infoPtr->weeknums.left, infoPtr->weeknums.right,
    1188     infoPtr->weeknums.top, infoPtr->weeknums.bottom);
     1177 
     1178
     1179  /* Comment in for debugging... 
     1180  TRACE("%d %d wd[%d %d %d %d] d[%d %d %d %d] t[%d %d %d %d] wn[%d %d %d %d]\n", x, y, 
     1181        infoPtr->wdays.left, infoPtr->wdays.right,
     1182        infoPtr->wdays.top, infoPtr->wdays.bottom,
     1183        infoPtr->days.left, infoPtr->days.right,
     1184        infoPtr->days.top, infoPtr->days.bottom,
     1185        infoPtr->todayrect.left, infoPtr->todayrect.right,
     1186        infoPtr->todayrect.top, infoPtr->todayrect.bottom,
     1187        infoPtr->weeknums.left, infoPtr->weeknums.right,
     1188        infoPtr->weeknums.top, infoPtr->weeknums.bottom);
    11891189  */
    11901190
    11911191  /* are we in the header? */
    1192 
     1192 
    11931193  if(PtInRect(&infoPtr->title, lpht->pt)) {
    11941194    if(PtInRect(&infoPtr->titlebtnprev, lpht->pt)) {
     
    12081208      goto done;
    12091209    }
    1210 
     1210   
    12111211    retval = MCHT_TITLE;
    12121212    goto done;
    12131213  }
    1214 
     1214 
    12151215  day = MONTHCAL_CalcDayFromPos(infoPtr,x,y,&wday,&wnum);
    12161216  if(PtInRect(&infoPtr->wdays, lpht->pt)) {
     
    12181218    lpht->st.wYear  = infoPtr->currentYear;
    12191219    lpht->st.wMonth = (day < 1)? infoPtr->currentMonth -1 : infoPtr->currentMonth;
    1220     lpht->st.wDay   = (day < 1)?
     1220    lpht->st.wDay   = (day < 1)? 
    12211221      MONTHCAL_MonthLength(infoPtr->currentMonth-1,infoPtr->currentYear) -day : day;
    12221222    goto done;
    12231223  }
    1224   if(PtInRect(&infoPtr->weeknums, lpht->pt)) {
    1225     retval = MCHT_CALENDARWEEKNUM;
     1224  if(PtInRect(&infoPtr->weeknums, lpht->pt)) { 
     1225    retval = MCHT_CALENDARWEEKNUM; 
    12261226    lpht->st.wYear  = infoPtr->currentYear;
    1227     lpht->st.wMonth = (day < 1) ? infoPtr->currentMonth -1 :
    1228       (day > MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear)) ?
     1227    lpht->st.wMonth = (day < 1) ? infoPtr->currentMonth -1 : 
     1228      (day > MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear)) ? 
    12291229      infoPtr->currentMonth +1 :infoPtr->currentMonth;
    1230     lpht->st.wDay   = (day < 1 ) ?
    1231       MONTHCAL_MonthLength(infoPtr->currentMonth-1,infoPtr->currentYear) -day :
    1232       (day > MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear)) ?
     1230    lpht->st.wDay   = (day < 1 ) ? 
     1231      MONTHCAL_MonthLength(infoPtr->currentMonth-1,infoPtr->currentYear) -day : 
     1232      (day > MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear)) ? 
    12331233      day - MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear) : day;
    1234     goto done;
    1235   }
    1236   if(PtInRect(&infoPtr->days, lpht->pt))
     1234    goto done;                             
     1235  }
     1236  if(PtInRect(&infoPtr->days, lpht->pt)) 
    12371237    {
    12381238      lpht->st.wYear  = infoPtr->currentYear;
    1239       if ( day < 1)
    1240     {
    1241       retval = MCHT_CALENDARDATEPREV;
    1242       lpht->st.wMonth = infoPtr->currentMonth - 1;
    1243       if (lpht->st.wMonth <1)
    1244         {
    1245           lpht->st.wMonth = 12;
    1246           lpht->st.wYear--;
    1247         }
    1248       lpht->st.wDay   = MONTHCAL_MonthLength(lpht->st.wMonth,lpht->st.wYear) -day;
    1249     }
     1239      if ( day < 1) 
     1240        {
     1241          retval = MCHT_CALENDARDATEPREV;
     1242          lpht->st.wMonth = infoPtr->currentMonth - 1;
     1243          if (lpht->st.wMonth <1)
     1244            {
     1245              lpht->st.wMonth = 12;
     1246              lpht->st.wYear--;
     1247            }
     1248          lpht->st.wDay   = MONTHCAL_MonthLength(lpht->st.wMonth,lpht->st.wYear) -day;
     1249        }
    12501250      else if (day > MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear))
    1251     {
    1252       retval = MCHT_CALENDARDATENEXT;
    1253       lpht->st.wMonth = infoPtr->currentMonth + 1;
    1254       if (lpht->st.wMonth <12)
    1255         {
    1256           lpht->st.wMonth = 1;
    1257           lpht->st.wYear++;
    1258         }
    1259       lpht->st.wDay   = day - MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear) ;
    1260     }
     1251        {
     1252          retval = MCHT_CALENDARDATENEXT;
     1253          lpht->st.wMonth = infoPtr->currentMonth + 1;
     1254          if (lpht->st.wMonth <12)
     1255            {
     1256              lpht->st.wMonth = 1;
     1257              lpht->st.wYear++;
     1258            }
     1259          lpht->st.wDay   = day - MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear) ;
     1260        }
    12611261      else {
    1262     retval = MCHT_CALENDARDATE;
    1263     lpht->st.wMonth = infoPtr->currentMonth;
    1264     lpht->st.wDay   = day;
     1262        retval = MCHT_CALENDARDATE;
     1263        lpht->st.wMonth = infoPtr->currentMonth;
     1264        lpht->st.wDay   = day;
    12651265      }
    12661266      goto done;
    12671267    }
    12681268  if(PtInRect(&infoPtr->todayrect, lpht->pt)) {
    1269     retval = MCHT_TODAYLINK;
     1269    retval = MCHT_TODAYLINK; 
    12701270    goto done;
    12711271  }
    1272 
    1273 
     1272 
     1273 
    12741274  /* Hit nothing special? What's left must be background :-) */
    1275 
    1276   retval = MCHT_CALENDARBK;
    1277  done:
     1275 
     1276  retval = MCHT_CALENDARBK;       
     1277 done: 
    12781278  lpht->uHit = retval;
    12791279  return retval;
     
    13001300    nmds.nmhdr.idFrom   = GetWindowLongA(hwnd, GWL_ID);
    13011301    nmds.nmhdr.code     = MCN_GETDAYSTATE;
    1302     nmds.cDayState  = infoPtr->monthRange;
    1303     nmds.prgDayState    = COMCTL32_Alloc(infoPtr->monthRange * sizeof(MONTHDAYSTATE));
     1302    nmds.cDayState      = infoPtr->monthRange;
     1303    nmds.prgDayState    = COMCTL32_Alloc(infoPtr->monthRange * sizeof(MONTHDAYSTATE));
    13041304
    13051305    SendMessageA(GetParent(hwnd), WM_NOTIFY,
     
    13301330    nmds.nmhdr.idFrom   = GetWindowLongA(hwnd, GWL_ID);
    13311331    nmds.nmhdr.code     = MCN_GETDAYSTATE;
    1332     nmds.cDayState  = infoPtr->monthRange;
    1333     nmds.prgDayState    = COMCTL32_Alloc
     1332    nmds.cDayState      = infoPtr->monthRange;
     1333    nmds.prgDayState    = COMCTL32_Alloc
    13341334                        (infoPtr->monthRange * sizeof(MONTHDAYSTATE));
    13351335
     
    13481348  POINT menupoint;
    13491349  char buf[32];
    1350 
     1350 
    13511351  hMenu = CreatePopupMenu();
    13521352  if (!LoadStringA(COMCTL32_hModule,IDM_GOTODAY,buf,sizeof(buf)))
     
    13601360  ClientToScreen(hwnd, &menupoint);
    13611361  if( TrackPopupMenu(hMenu,TPM_RIGHTBUTTON| TPM_NONOTIFY|TPM_RETURNCMD,
    1362              menupoint.x,menupoint.y,0,hwnd,NULL))
     1362                     menupoint.x,menupoint.y,0,hwnd,NULL))
    13631363    {
    13641364      infoPtr->currentMonth=infoPtr->todaysDate.wMonth;
    13651365      infoPtr->currentYear=infoPtr->todaysDate.wYear;
    13661366      InvalidateRect(hwnd, NULL, FALSE);
    1367     }
     1367    }   
    13681368  return 0;
    13691369}
     
    13811381  POINT menupoint;
    13821382  TRACE("%x %lx\n", wParam, lParam);
    1383 
     1383       
    13841384  if (infoPtr->hWndYearUpDown)
    13851385    {
    13861386      infoPtr->currentYear=SendMessageA( infoPtr->hWndYearUpDown, UDM_SETPOS,   (WPARAM) 0,(LPARAM)0);
    13871387      if(!DestroyWindow(infoPtr->hWndYearUpDown))
    1388     {
    1389       FIXME("Can't destroy Updown Control\n");
    1390     }
     1388        {
     1389          FIXME("Can't destroy Updown Control\n");
     1390        }
    13911391      else
    1392     infoPtr->hWndYearUpDown=0;
     1392        infoPtr->hWndYearUpDown=0;
    13931393      if(!DestroyWindow(infoPtr->hWndYearEdit))
    1394     {
    1395       FIXME("Can't destroy Updown Control\n");
    1396     }
     1394        {
     1395          FIXME("Can't destroy Updown Control\n");
     1396        }
    13971397      else
    1398     infoPtr->hWndYearEdit=0;
     1398        infoPtr->hWndYearEdit=0;
    13991399      InvalidateRect(hwnd, NULL, FALSE);
    14001400    }
    1401 
     1401 
    14021402  ht.pt.x = (INT)LOWORD(lParam);
    14031403  ht.pt.y = (INT)HIWORD(lParam);
     
    14141414    return TRUE;
    14151415  }
    1416   if(hit == MCHT_TITLEBTNPREV){
     1416  if(hit == MCHT_TITLEBTNPREV){ 
    14171417    MONTHCAL_GoToPrevMonth(hwnd, infoPtr);
    14181418    infoPtr->status = MC_PREVPRESSED;
     
    14241424  if(hit == MCHT_TITLEMONTH) {
    14251425    hMenu = CreatePopupMenu();
    1426 
     1426   
    14271427    for (i=0; i<12;i++)
    14281428      {
    1429     GetLocaleInfoA( LOCALE_USER_DEFAULT,LOCALE_SMONTHNAME1+i,
    1430           buf,sizeof(buf));
    1431     AppendMenuA(hMenu, MF_STRING|MF_ENABLED,i+1, buf);
     1429        GetLocaleInfoA( LOCALE_USER_DEFAULT,LOCALE_SMONTHNAME1+i,
     1430                  buf,sizeof(buf));
     1431        AppendMenuA(hMenu, MF_STRING|MF_ENABLED,i+1, buf);
    14321432      }
    14331433    menupoint.x=infoPtr->titlemonth.right;
     
    14351435    ClientToScreen(hwnd, &menupoint);
    14361436    i= TrackPopupMenu(hMenu,TPM_LEFTALIGN | TPM_NONOTIFY | TPM_RIGHTBUTTON | TPM_RETURNCMD,
    1437               menupoint.x,menupoint.y,0,hwnd,NULL);
     1437                      menupoint.x,menupoint.y,0,hwnd,NULL);
    14381438    if ((i>0) && (i<13))
    14391439      {
    1440     infoPtr->currentMonth=i;
    1441     InvalidateRect(hwnd, NULL, FALSE);
     1440        infoPtr->currentMonth=i;
     1441        InvalidateRect(hwnd, NULL, FALSE);
    14421442      }
    14431443  }
    14441444  if(hit == MCHT_TITLEYEAR) {
    14451445    infoPtr->hWndYearEdit=CreateWindowExA(0,
    1446             "EDIT",
    1447                0,
    1448             WS_VISIBLE | WS_CHILD |UDS_SETBUDDYINT,
    1449             infoPtr->titleyear.left+3,infoPtr->titlebtnnext.top,
    1450             infoPtr->titleyear.right-infoPtr->titleyear.left,
    1451             infoPtr->textHeight,
    1452             hwnd,
    1453              (HMENU)NULL,
    1454              (HINSTANCE)NULL,
    1455             NULL);
     1446                        "EDIT",
     1447                           0,
     1448                        WS_VISIBLE | WS_CHILD |UDS_SETBUDDYINT,
     1449                        infoPtr->titleyear.left+3,infoPtr->titlebtnnext.top,
     1450                        infoPtr->titleyear.right-infoPtr->titleyear.left,
     1451                        infoPtr->textHeight,
     1452                        hwnd,
     1453                         (HMENU)NULL,
     1454                         (HINSTANCE)NULL,
     1455                        NULL);
    14561456    infoPtr->hWndYearUpDown=CreateWindowExA(0,
    1457             UPDOWN_CLASSA,
    1458                0,
    1459             WS_VISIBLE | WS_CHILD |UDS_SETBUDDYINT|UDS_NOTHOUSANDS|UDS_ARROWKEYS,
    1460             infoPtr->titleyear.right+6,infoPtr->titlebtnnext.top,
    1461             20,
    1462             infoPtr->textHeight,
    1463             hwnd,
    1464              (HMENU)NULL,
    1465              (HINSTANCE)NULL,
    1466             NULL);
     1457                        UPDOWN_CLASSA,
     1458                           0,
     1459                        WS_VISIBLE | WS_CHILD |UDS_SETBUDDYINT|UDS_NOTHOUSANDS|UDS_ARROWKEYS,
     1460                        infoPtr->titleyear.right+6,infoPtr->titlebtnnext.top,
     1461                        20,
     1462                        infoPtr->textHeight,
     1463                        hwnd,
     1464                         (HMENU)NULL,
     1465                         (HINSTANCE)NULL,
     1466                        NULL);
    14671467    SendMessageA( infoPtr->hWndYearUpDown, UDM_SETRANGE, (WPARAM) 0, MAKELONG (9999, 1753));
    14681468    SendMessageA( infoPtr->hWndYearUpDown, UDM_SETBUDDY, (WPARAM) infoPtr->hWndYearEdit, (LPARAM)0 );
    14691469    SendMessageA( infoPtr->hWndYearUpDown, UDM_SETPOS,   (WPARAM) 0,(LPARAM)infoPtr->currentYear );
    14701470    return TRUE;
    1471 
     1471         
    14721472  }
    14731473  if(hit == MCHT_TODAYLINK) {
     
    14871487    MONTHCAL_CopyTime(&nmsc.stSelStart, &infoPtr->minSel);
    14881488    MONTHCAL_CopyTime(&nmsc.stSelEnd, &infoPtr->maxSel);
    1489 
     1489       
    14901490    SendMessageA(GetParent(hwnd), WM_NOTIFY,
    14911491           (WPARAM)nmsc.nmhdr.idFrom,(LPARAM)&nmsc);
     
    14931493    MONTHCAL_CopyTime(&ht.st, &selArray[0]);
    14941494    MONTHCAL_CopyTime(&ht.st, &selArray[1]);
    1495     MONTHCAL_SetSelRange(hwnd,0,(LPARAM) &selArray);
     1495    MONTHCAL_SetSelRange(hwnd,0,(LPARAM) &selArray); 
    14961496
    14971497    /* redraw both old and new days if the selected day changed */
     
    15461546    return TRUE;
    15471547  }
    1548   if(hit == MCHT_CALENDARDATEPREV){
     1548  if(hit == MCHT_CALENDARDATEPREV){ 
    15491549    MONTHCAL_GoToPrevMonth(hwnd, infoPtr);
    15501550    InvalidateRect(hwnd, NULL, FALSE);
     
    15641564  MONTHCAL_CopyTime(&nmsc.stSelStart, &infoPtr->minSel);
    15651565  MONTHCAL_CopyTime(&nmsc.stSelEnd, &infoPtr->maxSel);
    1566 
     1566       
    15671567  SendMessageA(GetParent(hwnd), WM_NOTIFY,
    15681568           (WPARAM)nmsc.nmhdr.idFrom, (LPARAM)&nmsc);
    1569 
     1569 
    15701570  /* redraw if necessary */
    15711571  if(redraw)
    15721572    InvalidateRect(hwnd, NULL, FALSE);
    1573 
     1573       
    15741574  return 0;
    15751575}
     
    15861586
    15871587  switch(wParam) {
    1588   case MC_NEXTMONTHTIMER:
     1588  case MC_NEXTMONTHTIMER: 
    15891589    redraw = TRUE;
    15901590    MONTHCAL_GoToNextMonth(hwnd, infoPtr);
     
    16181618  ht.pt.x = LOWORD(lParam);
    16191619  ht.pt.y = HIWORD(lParam);
    1620 
     1620       
    16211621  hit = MONTHCAL_HitTest(hwnd, (LPARAM)&ht);
    1622 
     1622 
    16231623  /* not on the calendar date numbers? bail out */
    16241624  TRACE("hit:%x\n",hit);
     
    16381638    if(infoPtr->firstSelDay==selArray[0].wDay) i=1;
    16391639    TRACE("oldRange:%d %d %d %d\n", infoPtr->firstSelDay, selArray[0].wDay, selArray[1].wDay, i);
    1640     if(infoPtr->firstSelDay==selArray[1].wDay) {
     1640    if(infoPtr->firstSelDay==selArray[1].wDay) { 
    16411641      /* 1st time we get here: selArray[0]=selArray[1])  */
    16421642      /* if we're still at the first selected date, return */
     
    16441644      if(selday<infoPtr->firstSelDay) i = 0;
    16451645    }
    1646 
     1646                       
    16471647    if(abs(infoPtr->firstSelDay - selday) >= infoPtr->maxSelCount) {
    16481648      if(selday>infoPtr->firstSelDay)
     
    16511651        selday = infoPtr->firstSelDay - infoPtr->maxSelCount;
    16521652    }
    1653 
     1653               
    16541654    if(selArray[i].wDay!=selday) {
    16551655      TRACE("newRange:%d %d %d %d\n", infoPtr->firstSelDay, selArray[0].wDay, selArray[1].wDay, i);
    1656 
     1656                       
    16571657      selArray[i].wDay = selday;
    16581658
     
    17121712{
    17131713  TRACE("\n");
    1714 
     1714 
    17151715  InvalidateRect(hwnd, NULL, FALSE);
    17161716
     
    17691769
    17701770  /* recalculate the height and width increments and offsets */
    1771   /* FIXME: We use up all available width. This will inhibit having multiple
    1772      calendars in a row, like win doesn
     1771  /* FIXME: We use up all available width. This will inhibit having multiple 
     1772     calendars in a row, like win doesn 
    17731773  */
    17741774  if(dwStyle & MCS_WEEKNUMBERS)
     
    17761776  else
    17771777    xdiv=7.0;
    1778   infoPtr->width_increment = (infoPtr->rcDraw.right - infoPtr->rcDraw.left) / xdiv;
    1779   infoPtr->height_increment = (infoPtr->rcDraw.bottom - infoPtr->rcDraw.top) / 10.0;
     1778  infoPtr->width_increment = (infoPtr->rcDraw.right - infoPtr->rcDraw.left) / xdiv; 
     1779  infoPtr->height_increment = (infoPtr->rcDraw.bottom - infoPtr->rcDraw.top) / 10.0; 
    17801780  infoPtr->left_offset = (infoPtr->rcDraw.right - infoPtr->rcDraw.left) - (infoPtr->width_increment * xdiv);
    17811781  infoPtr->top_offset = (infoPtr->rcDraw.bottom - infoPtr->rcDraw.top) - (infoPtr->height_increment * 10.0);
     
    17901790    rcDraw->bottom = rcDraw->top + 9 * infoPtr->textHeight + 5;
    17911791    }*/
    1792 
     1792   
    17931793  /* calculate title area */
    17941794  title->top    = rcClient->top;
     
    18051805  next->right  = title->right - 6;
    18061806  next->left   = next->right - (title->bottom - title->top);
    1807 
     1807 
    18081808  /* titlemonth->left and right change based upon the current month */
    18091809  /* and are recalculated in refresh as the current month may change */
     
    18111811  titlemonth->top    = titleyear->top    = title->top    + (infoPtr->height_increment)/2;
    18121812  titlemonth->bottom = titleyear->bottom = title->bottom - (infoPtr->height_increment)/2;
    1813 
     1813 
    18141814  /* setup the dimensions of the rectangle we draw the names of the */
    18151815  /* days of the week in */
    18161816  weeknumrect->left =infoPtr->left_offset;
    1817   if(dwStyle & MCS_WEEKNUMBERS)
     1817  if(dwStyle & MCS_WEEKNUMBERS) 
    18181818    weeknumrect->right=prev->right;
    18191819  else
     
    18231823  wdays->top    = title->bottom ;
    18241824  wdays->bottom = wdays->top + infoPtr->height_increment;
    1825 
     1825 
    18261826  days->top    = weeknumrect->top = wdays->bottom ;
    18271827  days->bottom = weeknumrect->bottom = days->top     + 6 * infoPtr->height_increment;
    1828 
     1828 
    18291829  todayrect->left   = rcClient->left;
    18301830  todayrect->right  = rcClient->right;
     
    18321832  todayrect->bottom = days->bottom + infoPtr->height_increment;
    18331833
    1834   /* uncomment for excessive debugging
     1834  /* uncomment for excessive debugging 
    18351835  TRACE("dx=%d dy=%d rcC[%d %d %d %d] t[%d %d %d %d] wd[%d %d %d %d] w[%d %d %d %d] t[%d %d %d %d]\n",
    1836     infoPtr->width_increment,infoPtr->height_increment,
    1837     rcClient->left, rcClient->right, rcClient->top, rcClient->bottom,
    1838         title->left,    title->right,    title->top,    title->bottom,
    1839         wdays->left,    wdays->right,    wdays->top,    wdays->bottom,
    1840          days->left,     days->right,     days->top,     days->bottom,
    1841     todayrect->left,todayrect->right,todayrect->top,todayrect->bottom);
     1836        infoPtr->width_increment,infoPtr->height_increment,
     1837        rcClient->left, rcClient->right, rcClient->top, rcClient->bottom,
     1838            title->left,    title->right,    title->top,    title->bottom,
     1839            wdays->left,    wdays->right,    wdays->top,    wdays->bottom,
     1840             days->left,     days->right,     days->top,     days->bottom,
     1841        todayrect->left,todayrect->right,todayrect->top,todayrect->bottom);
    18421842  */
    1843 
     1843 
    18441844  /* restore the originally selected font */
    1845   SelectObject(hdc, currentFont);
     1845  SelectObject(hdc, currentFont);     
    18461846
    18471847  ReleaseDC(hwnd, hdc);
     
    18651865{
    18661866  MONTHCAL_INFO *infoPtr;
    1867   LOGFONTA  logFont;
     1867  LOGFONTA      logFont;
    18681868
    18691869  /* allocate memory for info structure */
     
    19001900  infoPtr->maxSelCount  = 7;
    19011901  infoPtr->monthRange = 3;
    1902   infoPtr->monthdayState = COMCTL32_Alloc
     1902  infoPtr->monthdayState = COMCTL32_Alloc 
    19031903                         (infoPtr->monthRange * sizeof(MONTHDAYSTATE));
    19041904  infoPtr->titlebk     = GetSysColor(COLOR_ACTIVECAPTION);
     
    19071907  infoPtr->trailingtxt = GetSysColor(COLOR_GRAYTEXT);
    19081908  infoPtr->bk          = GetSysColor(COLOR_WINDOW);
    1909   infoPtr->txt         = GetSysColor(COLOR_WINDOWTEXT);
     1909  infoPtr->txt         = GetSysColor(COLOR_WINDOWTEXT);
    19101910
    19111911  /* call MONTHCAL_UpdateSize to set all of the dimensions */
     
    20622062  wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
    20632063  wndClass.lpszClassName = MONTHCAL_CLASSA;
    2064 
     2064 
    20652065  RegisterClassA(&wndClass);
    20662066}
  • trunk/src/comctl32/status.c

    r6705 r6709  
    2626typedef struct
    2727{
    28     INT x;
    29     INT style;
    30     RECT    bound;
    31     LPWSTR  text;
     28    INT x;
     29    INT style;
     30    RECT        bound;
     31    LPWSTR      text;
    3232    HICON     hIcon;
    3333} STATUSWINDOWPART;
     
    4848    COLORREF            clrBk;     /* background color */
    4949    BOOL              bUnicode;  /* unicode flag */
    50     STATUSWINDOWPART    part0;     /* simple window */
     50    STATUSWINDOWPART    part0;     /* simple window */
    5151    STATUSWINDOWPART   *parts;
    5252} STATUSWINDOWINFO;
     
    9393    SelectObject (hdc, GetSysColorPen (COLOR_3DSHADOW));
    9494    for (i = 1; i < 11; i += 4) {
    95     MoveToEx (hdc, pt.x - i, pt.y, NULL);
    96     LineTo (hdc, pt.x, pt.y - i);
    97 
    98     MoveToEx (hdc, pt.x - i-1, pt.y, NULL);
    99     LineTo (hdc, pt.x, pt.y - i-1);
     95        MoveToEx (hdc, pt.x - i, pt.y, NULL);
     96        LineTo (hdc, pt.x, pt.y - i);
     97
     98        MoveToEx (hdc, pt.x - i-1, pt.y, NULL);
     99        LineTo (hdc, pt.x, pt.y - i-1);
    100100    }
    101101
    102102    SelectObject (hdc, GetSysColorPen (COLOR_3DHIGHLIGHT));
    103103    for (i = 3; i < 13; i += 4) {
    104     MoveToEx (hdc, pt.x - i, pt.y, NULL);
    105     LineTo (hdc, pt.x, pt.y - i);
     104        MoveToEx (hdc, pt.x - i, pt.y, NULL);
     105        LineTo (hdc, pt.x, pt.y - i);
    106106    }
    107107
     
    110110
    111111
    112 static void
     112static void 
    113113STATUSBAR_DrawPart (HDC hdc, STATUSWINDOWPART *part)
    114114{
     
    126126    /* draw the icon */
    127127    if (part->hIcon) {
    128     INT cy = r.bottom - r.top;
    129 
    130     r.left += 2;
    131     DrawIconEx (hdc, r.left, r.top, part->hIcon, cy, cy, 0, 0, DI_NORMAL);
    132     r.left += cy;
     128        INT cy = r.bottom - r.top;
     129
     130        r.left += 2;
     131        DrawIconEx (hdc, r.left, r.top, part->hIcon, cy, cy, 0, 0, DI_NORMAL);
     132        r.left += cy;
    133133    }
    134134
     
    139139      UINT align = DT_LEFT;
    140140      if (*p == L'\t') {
    141     p++;
    142     align = DT_CENTER;
    143 
    144     if (*p == L'\t') {
    145       p++;
    146       align = DT_RIGHT;
    147     }
     141        p++;
     142        align = DT_CENTER;
     143
     144        if (*p == L'\t') {
     145          p++;
     146          align = DT_RIGHT;
     147        }
    148148      }
    149149      r.left += 3;
     
    151151      DrawTextW (hdc, p, -1, &r, align|DT_VCENTER|DT_SINGLELINE);
    152152      if (oldbkmode != TRANSPARENT)
    153     SetBkMode(hdc, oldbkmode);
     153        SetBkMode(hdc, oldbkmode);
    154154    }
    155155}
     
    169169
    170170    if (infoPtr->clrBk != CLR_DEFAULT)
    171     hbrBk = CreateSolidBrush (infoPtr->clrBk);
     171        hbrBk = CreateSolidBrush (infoPtr->clrBk);
    172172    else
    173     hbrBk = GetSysColorBrush (COLOR_3DFACE);
     173        hbrBk = GetSysColorBrush (COLOR_3DFACE);
    174174    FillRect(hdc, &part->bound, hbrBk);
    175175
     
    177177
    178178    if (part->style & SBT_OWNERDRAW) {
    179     DRAWITEMSTRUCT dis;
    180 
    181     dis.CtlID = GetWindowLongA (hwnd, GWL_ID);
    182     dis.itemID = itemID;
    183     dis.hwndItem = hwnd;
    184     dis.hDC = hdc;
    185     dis.rcItem = part->bound;
    186     dis.itemData = (INT)part->text;
    187     SendMessageA (GetParent (hwnd), WM_DRAWITEM,
    188         (WPARAM)dis.CtlID, (LPARAM)&dis);
     179        DRAWITEMSTRUCT dis;
     180
     181        dis.CtlID = GetWindowLongA (hwnd, GWL_ID);
     182        dis.itemID = itemID;
     183        dis.hwndItem = hwnd;
     184        dis.hDC = hdc;
     185        dis.rcItem = part->bound;
     186        dis.itemData = (INT)part->text;
     187        SendMessageA (GetParent (hwnd), WM_DRAWITEM,
     188                (WPARAM)dis.CtlID, (LPARAM)&dis);
    189189    } else
    190     STATUSBAR_DrawPart (hdc, part);
     190        STATUSBAR_DrawPart (hdc, part);
    191191
    192192    SelectObject (hdc, hOldFont);
    193193
    194194    if (infoPtr->clrBk != CLR_DEFAULT)
    195     DeleteObject (hbrBk);
     195        DeleteObject (hbrBk);
    196196
    197197    if (GetWindowLongA (hwnd, GWL_STYLE) & SBARS_SIZEGRIP) {
    198     RECT rect;
    199 
    200     GetClientRect (hwnd, &rect);
    201     STATUSBAR_DrawSizeGrip (hdc, &rect);
     198        RECT rect;
     199
     200        GetClientRect (hwnd, &rect);
     201        STATUSBAR_DrawSizeGrip (hdc, &rect);
    202202    }
    203203}
     
    221221
    222222    if (infoPtr->clrBk != CLR_DEFAULT)
    223     hbrBk = CreateSolidBrush (infoPtr->clrBk);
     223        hbrBk = CreateSolidBrush (infoPtr->clrBk);
    224224    else
    225     hbrBk = GetSysColorBrush (COLOR_3DFACE);
     225        hbrBk = GetSysColorBrush (COLOR_3DFACE);
    226226    FillRect(hdc, &rect, hbrBk);
    227227
     
    229229
    230230    if (infoPtr->simple) {
    231     STATUSBAR_RefreshPart (infoPtr, hwnd, &infoPtr->part0, hdc, 0);
     231        STATUSBAR_RefreshPart (infoPtr, hwnd, &infoPtr->part0, hdc, 0);
    232232    } else {
    233     for (i = 0; i < infoPtr->numParts; i++) {
    234         if (infoPtr->parts[i].style & SBT_OWNERDRAW) {
    235         DRAWITEMSTRUCT dis;
    236 
    237         dis.CtlID = GetWindowLongA (hwnd, GWL_ID);
    238         dis.itemID = i;
    239         dis.hwndItem = hwnd;
    240         dis.hDC = hdc;
    241         dis.rcItem = infoPtr->parts[i].bound;
    242         dis.itemData = (INT)infoPtr->parts[i].text;
    243         SendMessageA (GetParent (hwnd), WM_DRAWITEM,
    244             (WPARAM)dis.CtlID, (LPARAM)&dis);
    245         } else
    246         STATUSBAR_RefreshPart (infoPtr, hwnd, &infoPtr->parts[i], hdc, i);
    247     }
     233        for (i = 0; i < infoPtr->numParts; i++) {
     234            if (infoPtr->parts[i].style & SBT_OWNERDRAW) {
     235                DRAWITEMSTRUCT dis;
     236
     237                dis.CtlID = GetWindowLongA (hwnd, GWL_ID);
     238                dis.itemID = i;
     239                dis.hwndItem = hwnd;
     240                dis.hDC = hdc;
     241                dis.rcItem = infoPtr->parts[i].bound;
     242                dis.itemData = (INT)infoPtr->parts[i].text;
     243                SendMessageA (GetParent (hwnd), WM_DRAWITEM,
     244                        (WPARAM)dis.CtlID, (LPARAM)&dis);
     245            } else
     246                STATUSBAR_RefreshPart (infoPtr, hwnd, &infoPtr->parts[i], hdc, i);
     247        }
    248248    }
    249249
     
    251251
    252252    if (infoPtr->clrBk != CLR_DEFAULT)
    253     DeleteObject (hbrBk);
     253        DeleteObject (hbrBk);
    254254
    255255    if (GetWindowLongA(hwnd, GWL_STYLE) & SBARS_SIZEGRIP)
    256     STATUSBAR_DrawSizeGrip (hdc, &rect);
     256        STATUSBAR_DrawSizeGrip (hdc, &rect);
    257257
    258258    return TRUE;
     
    265265    STATUSWINDOWPART *part;
    266266    RECT rect, *r;
    267     int i;
     267    int i;
    268268
    269269    /* get our window size */
     
    278278    /* set bounds for non-simple rectangles */
    279279    for (i = 0; i < infoPtr->numParts; i++) {
    280     part = &infoPtr->parts[i];
    281     r = &infoPtr->parts[i].bound;
    282     r->top = rect.top;
    283     r->bottom = rect.bottom;
    284     if (i == 0)
    285         r->left = 0;
    286     else
    287         r->left = infoPtr->parts[i-1].bound.right + HORZ_GAP;
    288     if (part->x == -1)
    289         r->right = rect.right;
    290     else
    291         r->right = part->x;
    292 
    293     if (infoPtr->hwndToolTip) {
    294         TTTOOLINFOA ti;
    295 
    296         ti.cbSize = sizeof(TTTOOLINFOA);
    297         ti.hwnd = hwnd;
    298         ti.uId = i;
    299         ti.rect = *r;
    300         SendMessageA (infoPtr->hwndToolTip, TTM_NEWTOOLRECTA,
    301                 0, (LPARAM)&ti);
    302     }
     280        part = &infoPtr->parts[i];
     281        r = &infoPtr->parts[i].bound;
     282        r->top = rect.top;
     283        r->bottom = rect.bottom;
     284        if (i == 0)
     285            r->left = 0;
     286        else
     287            r->left = infoPtr->parts[i-1].bound.right + HORZ_GAP;
     288        if (part->x == -1)
     289            r->right = rect.right;
     290        else
     291            r->right = part->x;
     292
     293        if (infoPtr->hwndToolTip) {
     294            TTTOOLINFOA ti;
     295
     296            ti.cbSize = sizeof(TTTOOLINFOA);
     297            ti.hwnd = hwnd;
     298            ti.uId = i;
     299            ti.rect = *r;
     300            SendMessageA (infoPtr->hwndToolTip, TTM_NEWTOOLRECTA,
     301                            0, (LPARAM)&ti);
     302        }
    303303    }
    304304}
     
    307307static VOID
    308308STATUSBAR_RelayEvent (HWND hwndTip, HWND hwndMsg, UINT uMsg,
    309               WPARAM wParam, LPARAM lParam)
     309                      WPARAM wParam, LPARAM lParam)
    310310{
    311311    MSG msg;
     
    345345    TRACE("%d\n", nPart);
    346346    if ((nPart < -1) || (nPart >= infoPtr->numParts))
    347     return 0;
     347        return 0;
    348348
    349349    if (nPart == -1)
     
    365365    parts = (LPINT) lParam;
    366366    if (parts) {
    367     for (i = 0; i < num_parts; i++) {
    368         parts[i] = infoPtr->parts[i].x;
    369     }
     367        for (i = 0; i < num_parts; i++) {
     368            parts[i] = infoPtr->parts[i].x;
     369        }
    370370    }
    371371    return (infoPtr->numParts);
     
    376376STATUSBAR_GetRect (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
    377377{
    378     int nPart;
     378    int nPart;
    379379    LPRECT  rect;
    380380
     
    383383    rect = (LPRECT) lParam;
    384384    if (infoPtr->simple)
    385     *rect = infoPtr->part0.bound;
     385        *rect = infoPtr->part0.bound;
    386386    else
    387     *rect = infoPtr->parts[nPart].bound;
     387        *rect = infoPtr->parts[nPart].bound;
    388388    return TRUE;
    389389}
     
    400400    TRACE("part %d\n", nPart);
    401401    if (infoPtr->simple)
    402     part = &infoPtr->part0;
     402        part = &infoPtr->part0;
    403403    else
    404404#ifdef __WIN32OS2__
    405405    {
    406406        if (nPart >= infoPtr->numParts)
    407         return FALSE;
    408     part = &infoPtr->parts[nPart];
     407            return FALSE;
     408        part = &infoPtr->parts[nPart];
    409409    }
    410410#else
    411     part = &infoPtr->parts[nPart];
     411        part = &infoPtr->parts[nPart];
    412412#endif
    413413
    414414    if (part->style & SBT_OWNERDRAW)
    415     result = (LRESULT)part->text;
     415        result = (LRESULT)part->text;
    416416    else {
    417417        DWORD len = part->text ? WideCharToMultiByte( CP_ACP, 0, part->text, -1,
     
    435435    TRACE("part %d\n", nPart);
    436436    if (infoPtr->simple)
    437     part = &infoPtr->part0;
     437        part = &infoPtr->part0;
    438438    else
    439439#ifdef __WIN32OS2__
    440440    {
    441441        if (nPart >= infoPtr->numParts)
    442         return FALSE;
    443     part = &infoPtr->parts[nPart];
     442            return FALSE;
     443        part = &infoPtr->parts[nPart];
    444444    }
    445445#else
    446     part = &infoPtr->parts[nPart];
     446        part = &infoPtr->parts[nPart];
    447447#endif
    448448
    449449    if (part->style & SBT_OWNERDRAW)
    450     result = (LRESULT)part->text;
     450        result = (LRESULT)part->text;
    451451    else {
    452     result = part->text ? strlenW (part->text) : 0;
    453     result |= (part->style << 16);
    454     if (part->text && lParam)
    455         strcpyW ((LPWSTR)lParam, part->text);
     452        result = part->text ? strlenW (part->text) : 0;
     453        result |= (part->style << 16);
     454        if (part->text && lParam)
     455            strcpyW ((LPWSTR)lParam, part->text);
    456456    }
    457457    return result;
     
    471471
    472472    if (infoPtr->simple)
    473     part = &infoPtr->part0;
     473        part = &infoPtr->part0;
    474474    else
    475475#ifdef __WIN32OS2__
    476476    {
    477477        if (nPart >= infoPtr->numParts)
    478         return FALSE;
    479     part = &infoPtr->parts[nPart];
     478            return FALSE;
     479        part = &infoPtr->parts[nPart];
    480480    }
    481481#else
    482     part = &infoPtr->parts[nPart];
     482        part = &infoPtr->parts[nPart];
    483483#endif
    484484
    485485    if (part->text)
    486     result = strlenW(part->text);
     486        result = strlenW(part->text);
    487487    else
    488     result = 0;
     488        result = 0;
    489489
    490490    result |= (part->style << 16);
     
    526526        buf[0]=0;
    527527
    528     if (infoPtr->hwndToolTip) {
    529         TTTOOLINFOW ti;
    530         ti.cbSize = sizeof(TTTOOLINFOW);
    531         ti.hwnd = hwnd;
    532         ti.uId = LOWORD(wParam);
     528        if (infoPtr->hwndToolTip) {
     529            TTTOOLINFOW ti;
     530            ti.cbSize = sizeof(TTTOOLINFOW);
     531            ti.hwnd = hwnd;
     532            ti.uId = LOWORD(wParam);
    533533            ti.lpszText = buf;
    534         SendMessageW(infoPtr->hwndToolTip, TTM_GETTEXTW, 0, (LPARAM)&ti);
    535     }
    536     lstrcpynW(tip, buf, HIWORD(wParam));
     534            SendMessageW(infoPtr->hwndToolTip, TTM_GETTEXTW, 0, (LPARAM)&ti);
     535        }
     536        lstrcpynW(tip, buf, HIWORD(wParam));
    537537    }
    538538
     
    575575
    576576    if ((nPart < -1) || (nPart >= infoPtr->numParts))
    577     return FALSE;
     577        return FALSE;
    578578
    579579    TRACE("setting part %d, icon %lx\n",nPart,lParam);
    580580
    581581    if (nPart == -1) {
    582     if (infoPtr->part0.hIcon == (HICON)lParam) /* same as - no redraw */
    583         return TRUE;
    584     infoPtr->part0.hIcon = (HICON)lParam;
    585     if (infoPtr->simple)
     582        if (infoPtr->part0.hIcon == (HICON)lParam) /* same as - no redraw */
     583            return TRUE;
     584        infoPtr->part0.hIcon = (HICON)lParam;
     585        if (infoPtr->simple)
    586586            InvalidateRect(hwnd, &infoPtr->part0.bound, FALSE);
    587587    } else {
    588     if (infoPtr->parts[nPart].hIcon == (HICON)lParam) /* same as - no redraw */
    589         return TRUE;
    590 
    591     infoPtr->parts[nPart].hIcon = (HICON)lParam;
    592     if (!(infoPtr->simple))
     588        if (infoPtr->parts[nPart].hIcon == (HICON)lParam) /* same as - no redraw */
     589            return TRUE;
     590
     591        infoPtr->parts[nPart].hIcon = (HICON)lParam;
     592        if (!(infoPtr->simple))
    593593            InvalidateRect(hwnd, &infoPtr->parts[nPart].bound, FALSE);
    594594    }
     
    603603    TRACE("\n");
    604604    if (IsWindowVisible (hwnd)) {
    605     HWND parent = GetParent (hwnd);
    606     INT  width, x, y;
    607     RECT parent_rect;
    608 
    609     GetClientRect (parent, &parent_rect);
    610     infoPtr->height = (INT)wParam + VERT_BORDER;
    611     width = parent_rect.right - parent_rect.left;
    612     x = parent_rect.left;
    613     y = parent_rect.bottom - infoPtr->height;
    614     MoveWindow (hwnd, parent_rect.left,
    615               parent_rect.bottom - infoPtr->height,
    616               width, infoPtr->height, TRUE);
    617     STATUSBAR_SetPartBounds (infoPtr, hwnd);
     605        HWND parent = GetParent (hwnd);
     606        INT  width, x, y;
     607        RECT parent_rect;
     608
     609        GetClientRect (parent, &parent_rect);
     610        infoPtr->height = (INT)wParam + VERT_BORDER;
     611        width = parent_rect.right - parent_rect.left;
     612        x = parent_rect.left;
     613        y = parent_rect.bottom - infoPtr->height;
     614        MoveWindow (hwnd, parent_rect.left,
     615                      parent_rect.bottom - infoPtr->height,
     616                      width, infoPtr->height, TRUE);
     617        STATUSBAR_SetPartBounds (infoPtr, hwnd);
    618618    }
    619619
     
    627627    STATUSWINDOWPART *tmp;
    628628    LPINT parts;
    629     int i;
    630     int oldNumParts;
     629    int i;
     630    int oldNumParts;
    631631
    632632    TRACE("(%d,%p)\n",wParam,(LPVOID)lParam);
     
    634634    /* FIXME: should return FALSE sometimes (maybe when wParam == 0 ?) */
    635635    if (infoPtr->simple)
    636     infoPtr->simple = FALSE;
     636        infoPtr->simple = FALSE;
    637637
    638638    oldNumParts = infoPtr->numParts;
     
    640640    parts = (LPINT) lParam;
    641641    if (oldNumParts > infoPtr->numParts) {
    642     for (i = infoPtr->numParts ; i < oldNumParts; i++) {
    643         if (infoPtr->parts[i].text && !(infoPtr->parts[i].style & SBT_OWNERDRAW))
    644         COMCTL32_Free (infoPtr->parts[i].text);
    645     }
     642        for (i = infoPtr->numParts ; i < oldNumParts; i++) {
     643            if (infoPtr->parts[i].text && !(infoPtr->parts[i].style & SBT_OWNERDRAW))
     644                COMCTL32_Free (infoPtr->parts[i].text);
     645        }
    646646    }
    647647    if (oldNumParts < infoPtr->numParts) {
    648     tmp = COMCTL32_Alloc (sizeof(STATUSWINDOWPART) * infoPtr->numParts);
    649     for (i = 0; i < oldNumParts; i++) {
    650         tmp[i] = infoPtr->parts[i];
    651     }
    652     if (infoPtr->parts)
    653         COMCTL32_Free (infoPtr->parts);
    654     infoPtr->parts = tmp;
     648        tmp = COMCTL32_Alloc (sizeof(STATUSWINDOWPART) * infoPtr->numParts);
     649        for (i = 0; i < oldNumParts; i++) {
     650            tmp[i] = infoPtr->parts[i];
     651        }
     652        if (infoPtr->parts)
     653            COMCTL32_Free (infoPtr->parts);
     654        infoPtr->parts = tmp;
    655655    }
    656656    if (oldNumParts == infoPtr->numParts) {
    657     for (i=0;i<oldNumParts;i++)
    658         if (infoPtr->parts[i].x != parts[i])
    659         break;
    660     if (i==oldNumParts) /* Unchanged? no need to redraw! */
    661         return TRUE;
    662     }
    663 
     657        for (i=0;i<oldNumParts;i++)
     658            if (infoPtr->parts[i].x != parts[i])
     659                break;
     660        if (i==oldNumParts) /* Unchanged? no need to redraw! */
     661            return TRUE;
     662    }
     663   
    664664    for (i = 0; i < infoPtr->numParts; i++)
    665     infoPtr->parts[i].x = parts[i];
     665        infoPtr->parts[i].x = parts[i];
    666666
    667667    if (infoPtr->hwndToolTip) {
    668     INT nTipCount =
    669         SendMessageA (infoPtr->hwndToolTip, TTM_GETTOOLCOUNT, 0, 0);
    670 
    671     if (nTipCount < infoPtr->numParts) {
    672         /* add tools */
    673         TTTOOLINFOA ti;
    674         INT i;
    675 
    676         ZeroMemory (&ti, sizeof(TTTOOLINFOA));
    677         ti.cbSize = sizeof(TTTOOLINFOA);
    678         ti.hwnd = hwnd;
    679         for (i = nTipCount; i < infoPtr->numParts; i++) {
    680         TRACE("add tool %d\n", i);
    681         ti.uId = i;
    682         SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
    683                 0, (LPARAM)&ti);
    684         }
    685     }
    686     else if (nTipCount > infoPtr->numParts) {
    687         /* delete tools */
    688         INT i;
    689 
    690         for (i = nTipCount - 1; i >= infoPtr->numParts; i--) {
    691         FIXME("delete tool %d\n", i);
    692         }
    693     }
     668        INT nTipCount =
     669            SendMessageA (infoPtr->hwndToolTip, TTM_GETTOOLCOUNT, 0, 0);
     670
     671        if (nTipCount < infoPtr->numParts) {
     672            /* add tools */
     673            TTTOOLINFOA ti;
     674            INT i;
     675
     676            ZeroMemory (&ti, sizeof(TTTOOLINFOA));
     677            ti.cbSize = sizeof(TTTOOLINFOA);
     678            ti.hwnd = hwnd;
     679            for (i = nTipCount; i < infoPtr->numParts; i++) {
     680                TRACE("add tool %d\n", i);
     681                ti.uId = i;
     682                SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
     683                                0, (LPARAM)&ti);
     684            }
     685        }
     686        else if (nTipCount > infoPtr->numParts) {
     687            /* delete tools */
     688            INT i;
     689
     690            for (i = nTipCount - 1; i >= infoPtr->numParts; i--) {
     691                FIXME("delete tool %d\n", i);
     692            }
     693        }
    694694    }
    695695    STATUSBAR_SetPartBounds (infoPtr, hwnd);
     
    703703{
    704704    STATUSWINDOWPART *part=NULL;
    705     int nPart;
    706     int style;
     705    int nPart;
     706    int style;
    707707    LPSTR text;
    708     BOOL    changed = FALSE;
     708    BOOL        changed = FALSE;
    709709
    710710    text = (LPSTR) lParam;
     
    715715
    716716    if (nPart==255)
    717     part = &infoPtr->part0;
     717        part = &infoPtr->part0;
    718718    else if (!infoPtr->simple && infoPtr->parts!=NULL)
    719719#ifdef __WIN32OS2__
    720720    {
    721721        if (nPart >= infoPtr->numParts)
    722         return FALSE;
    723     part = &infoPtr->parts[nPart];
     722            return FALSE;
     723        part = &infoPtr->parts[nPart];
    724724    }
    725725#else
    726     part = &infoPtr->parts[nPart];
     726        part = &infoPtr->parts[nPart];
    727727#endif
    728728    if (!part) return FALSE;
    729729
    730730    if (part->style != style)
    731     changed = TRUE;
     731        changed = TRUE;
    732732
    733733    part->style = style;
    734734    if (style & SBT_OWNERDRAW) {
    735     if (part->text == (LPWSTR)text)
    736         return TRUE;
    737     part->text = (LPWSTR)text;
     735        if (part->text == (LPWSTR)text)
     736            return TRUE;
     737        part->text = (LPWSTR)text;
    738738    } else {
    739     LPWSTR ntext;
    740 
    741     /* check if text is unchanged -> no need to redraw */
    742     if (text) {
     739        LPWSTR ntext;
     740
     741        /* check if text is unchanged -> no need to redraw */
     742        if (text) {
    743743            DWORD len = MultiByteToWideChar( CP_ACP, 0, text, -1, NULL, 0 );
    744         LPWSTR tmptext = COMCTL32_Alloc(len*sizeof(WCHAR));
     744            LPWSTR tmptext = COMCTL32_Alloc(len*sizeof(WCHAR));
    745745            MultiByteToWideChar( CP_ACP, 0, text, -1, tmptext, len );
    746746
    747         if (!changed && part->text && !lstrcmpW(tmptext,part->text)) {
    748         COMCTL32_Free(tmptext);
    749         return TRUE;
    750         }
    751         ntext = tmptext;
    752     } else {
    753         if (!changed && !part->text)
    754         return TRUE;
    755         ntext = 0;
    756     }
    757 
    758     if (part->text)
    759         COMCTL32_Free (part->text);
    760     part->text = ntext;
     747            if (!changed && part->text && !lstrcmpW(tmptext,part->text)) {
     748                COMCTL32_Free(tmptext);
     749                return TRUE;
     750            }
     751            ntext = tmptext;
     752        } else {
     753            if (!changed && !part->text)
     754                return TRUE;
     755            ntext = 0;
     756        }
     757
     758        if (part->text)
     759            COMCTL32_Free (part->text);
     760        part->text = ntext;
    761761    }
    762762    InvalidateRect(hwnd, &part->bound, FALSE);
     
    780780    TRACE("part %d -> '%s' with style %04x\n", nPart, debugstr_w(text), style);
    781781    if ((infoPtr->simple) || (infoPtr->parts==NULL) || (nPart==255))
    782     part = &infoPtr->part0;
     782        part = &infoPtr->part0;
    783783    else
    784784#ifdef __WIN32OS2__
    785785    {
    786786        if (nPart >= infoPtr->numParts)
    787         return FALSE;
    788     part = &infoPtr->parts[nPart];
     787            return FALSE;
     788        part = &infoPtr->parts[nPart];
    789789    }
    790790#else
    791     part = &infoPtr->parts[nPart];
     791        part = &infoPtr->parts[nPart];
    792792#endif
    793793    if (!part) return FALSE;
     
    801801    if (style & SBT_OWNERDRAW)
    802802    {
    803     part->text = text;
     803        part->text = text;
    804804        bRedraw = TRUE;
    805805    } else if(!text)
     
    813813    } else if(!part->text || strcmpW(part->text, text)) /* see if the new string differs from the existing string */
    814814    {
    815     if(part->text) COMCTL32_Free(part->text);
     815        if(part->text) COMCTL32_Free(part->text);
    816816
    817817        len = strlenW(text);
    818818        part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
    819     strcpyW(part->text, text);
     819        strcpyW(part->text, text);
    820820        bRedraw = TRUE;
    821821    }
     
    833833    TRACE("part %d: \"%s\"\n", (INT)wParam, (LPSTR)lParam);
    834834    if (infoPtr->hwndToolTip) {
    835     TTTOOLINFOA ti;
    836     ti.cbSize = sizeof(TTTOOLINFOA);
    837     ti.hwnd = hwnd;
    838     ti.uId = (INT)wParam;
    839     ti.hinst = 0;
    840     ti.lpszText = (LPSTR)lParam;
    841     SendMessageA (infoPtr->hwndToolTip, TTM_UPDATETIPTEXTA,
    842             0, (LPARAM)&ti);
     835        TTTOOLINFOA ti;
     836        ti.cbSize = sizeof(TTTOOLINFOA);
     837        ti.hwnd = hwnd;
     838        ti.uId = (INT)wParam;
     839        ti.hinst = 0;
     840        ti.lpszText = (LPSTR)lParam;
     841        SendMessageA (infoPtr->hwndToolTip, TTM_UPDATETIPTEXTA,
     842                        0, (LPARAM)&ti);
    843843    }
    844844
     
    852852    TRACE("part %d: \"%s\"\n", (INT)wParam, (LPSTR)lParam);
    853853    if (infoPtr->hwndToolTip) {
    854     TTTOOLINFOW ti;
    855     ti.cbSize = sizeof(TTTOOLINFOW);
    856     ti.hwnd = hwnd;
    857     ti.uId = (INT)wParam;
    858     ti.hinst = 0;
    859     ti.lpszText = (LPWSTR)lParam;
    860     SendMessageW (infoPtr->hwndToolTip, TTM_UPDATETIPTEXTW,
    861             0, (LPARAM)&ti);
     854        TTTOOLINFOW ti;
     855        ti.cbSize = sizeof(TTTOOLINFOW);
     856        ti.hwnd = hwnd;
     857        ti.uId = (INT)wParam;
     858        ti.hinst = 0;
     859        ti.lpszText = (LPWSTR)lParam;
     860        SendMessageW (infoPtr->hwndToolTip, TTM_UPDATETIPTEXTW,
     861                        0, (LPARAM)&ti);
    862862    }
    863863
     
    885885    TRACE("(is simple: %d)\n", wParam);
    886886    if (infoPtr->simple == wParam) /* no need to change */
    887     return TRUE;
     887        return TRUE;
    888888
    889889    infoPtr->simple = (BOOL)wParam;
     
    905905    NONCLIENTMETRICSA nclm;
    906906    DWORD dwStyle;
    907     RECT    rect;
    908     int         width, len;
    909     HDC hdc;
     907    RECT        rect;
     908    int         width, len;
     909    HDC hdc;
    910910    STATUSWINDOWINFO *infoPtr;
    911911
     
    951951
    952952    if (IsWindowUnicode (hwnd)) {
    953     infoPtr->bUnicode = TRUE;
    954     if (lpCreate->lpszName &&
    955         (len = strlenW ((LPCWSTR)lpCreate->lpszName))) {
    956         infoPtr->parts[0].text = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
    957         strcpyW (infoPtr->parts[0].text, (LPCWSTR)lpCreate->lpszName);
    958     }
     953        infoPtr->bUnicode = TRUE;
     954        if (lpCreate->lpszName &&
     955            (len = strlenW ((LPCWSTR)lpCreate->lpszName))) {
     956            infoPtr->parts[0].text = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     957            strcpyW (infoPtr->parts[0].text, (LPCWSTR)lpCreate->lpszName);
     958        }
    959959    }
    960960    else {
    961     if (lpCreate->lpszName &&
    962         (len = strlen((LPCSTR)lpCreate->lpszName))) {
     961        if (lpCreate->lpszName &&
     962            (len = strlen((LPCSTR)lpCreate->lpszName))) {
    963963            DWORD lenW = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)lpCreate->lpszName, -1, NULL, 0 );
    964         infoPtr->parts[0].text = COMCTL32_Alloc (lenW*sizeof(WCHAR));
     964            infoPtr->parts[0].text = COMCTL32_Alloc (lenW*sizeof(WCHAR));
    965965            MultiByteToWideChar( CP_ACP, 0, (LPCSTR)lpCreate->lpszName, -1,
    966966                                 infoPtr->parts[0].text, lenW );
    967     }
     967        }
    968968    }
    969969
     
    977977#endif
    978978    if ((hdc = GetDC (0))) {
    979     TEXTMETRICA tm;
    980     HFONT hOldFont;
    981 
    982     hOldFont = SelectObject (hdc,infoPtr->hDefaultFont);
    983     GetTextMetricsA(hdc, &tm);
    984     infoPtr->textHeight = tm.tmHeight;
    985     SelectObject (hdc, hOldFont);
    986     ReleaseDC(0, hdc);
     979        TEXTMETRICA tm;
     980        HFONT hOldFont;
     981
     982        hOldFont = SelectObject (hdc,infoPtr->hDefaultFont);
     983        GetTextMetricsA(hdc, &tm);
     984        infoPtr->textHeight = tm.tmHeight;
     985        SelectObject (hdc, hOldFont);
     986        ReleaseDC(0, hdc);
    987987    }
    988988
    989989    if (dwStyle & SBT_TOOLTIPS) {
    990     infoPtr->hwndToolTip =
    991         CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
    992                    CW_USEDEFAULT, CW_USEDEFAULT,
    993                    CW_USEDEFAULT, CW_USEDEFAULT,
    994                  hwnd, 0,
    995                  GetWindowLongA (hwnd, GWL_HINSTANCE), NULL);
    996 
    997     if (infoPtr->hwndToolTip) {
    998         NMTOOLTIPSCREATED nmttc;
    999 
    1000         nmttc.hdr.hwndFrom = hwnd;
    1001         nmttc.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
    1002         nmttc.hdr.code = NM_TOOLTIPSCREATED;
    1003         nmttc.hwndToolTips = infoPtr->hwndToolTip;
    1004 
    1005         SendMessageA (lpCreate->hwndParent, WM_NOTIFY,
    1006                 (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc);
    1007     }
     990        infoPtr->hwndToolTip =
     991            CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
     992                               CW_USEDEFAULT, CW_USEDEFAULT,
     993                               CW_USEDEFAULT, CW_USEDEFAULT,
     994                             hwnd, 0,
     995                             GetWindowLongA (hwnd, GWL_HINSTANCE), NULL);
     996
     997        if (infoPtr->hwndToolTip) {
     998            NMTOOLTIPSCREATED nmttc;
     999
     1000            nmttc.hdr.hwndFrom = hwnd;
     1001            nmttc.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
     1002            nmttc.hdr.code = NM_TOOLTIPSCREATED;
     1003            nmttc.hwndToolTips = infoPtr->hwndToolTip;
     1004
     1005            SendMessageA (lpCreate->hwndParent, WM_NOTIFY,
     1006                            (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc);
     1007        }
    10081008    }
    10091009
     
    10141014        infoPtr->height = infoPtr->textHeight + 4 + VERT_BORDER;
    10151015        SetWindowPos(hwnd, 0, lpCreate->x, lpCreate->y - 1,
    1016             width, infoPtr->height, SWP_NOZORDER);
     1016                        width, infoPtr->height, SWP_NOZORDER);
    10171017        STATUSBAR_SetPartBounds (infoPtr, hwnd);
    10181018    }
     
    10251025STATUSBAR_WMDestroy (STATUSWINDOWINFO *infoPtr, HWND hwnd)
    10261026{
    1027     int i;
     1027    int i;
    10281028
    10291029    TRACE("\n");
    10301030    for (i = 0; i < infoPtr->numParts; i++) {
    1031     if (infoPtr->parts[i].text && !(infoPtr->parts[i].style & SBT_OWNERDRAW))
    1032         COMCTL32_Free (infoPtr->parts[i].text);
     1031        if (infoPtr->parts[i].text && !(infoPtr->parts[i].style & SBT_OWNERDRAW))
     1032            COMCTL32_Free (infoPtr->parts[i].text);
    10331033    }
    10341034    if (infoPtr->part0.text && !(infoPtr->part0.style & SBT_OWNERDRAW))
    1035     COMCTL32_Free (infoPtr->part0.text);
     1035        COMCTL32_Free (infoPtr->part0.text);
    10361036    COMCTL32_Free (infoPtr->parts);
    10371037
    10381038    /* delete default font */
    10391039    if (infoPtr->hDefaultFont)
    1040     DeleteObject (infoPtr->hDefaultFont);
     1040        DeleteObject (infoPtr->hDefaultFont);
    10411041
    10421042    /* delete tool tip control */
    10431043    if (infoPtr->hwndToolTip)
    1044     DestroyWindow (infoPtr->hwndToolTip);
     1044        DestroyWindow (infoPtr->hwndToolTip);
    10451045
    10461046    COMCTL32_Free (infoPtr);
     
    10741074
    10751075    if (wParam > len) {
    1076     if (infoPtr->bUnicode)
    1077         strcpyW ((LPWSTR)lParam, infoPtr->parts[0].text);
    1078     else
     1076        if (infoPtr->bUnicode)
     1077            strcpyW ((LPWSTR)lParam, infoPtr->parts[0].text);
     1078        else
    10791079            WideCharToMultiByte( CP_ACP, 0, infoPtr->parts[0].text, -1,
    10801080                                 (LPSTR)lParam, len+1, NULL, NULL );
    1081     return len;
     1081        return len;
    10821082    }
    10831083
     
    10901090{
    10911091    if (infoPtr->hwndToolTip)
    1092     STATUSBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
    1093                   WM_MOUSEMOVE, wParam, lParam);
     1092        STATUSBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
     1093                              WM_MOUSEMOVE, wParam, lParam);
    10941094    return 0;
    10951095}
     
    11001100{
    11011101    if (GetWindowLongA (hwnd, GWL_STYLE) & SBARS_SIZEGRIP) {
    1102     RECT  rect;
    1103     POINT pt;
    1104 
    1105     GetClientRect (hwnd, &rect);
    1106 
    1107     pt.x = (INT)LOWORD(lParam);
    1108     pt.y = (INT)HIWORD(lParam);
    1109     ScreenToClient (hwnd, &pt);
    1110 
    1111     rect.left = rect.right - 13;
    1112     rect.top += 2;
    1113 
    1114     if (PtInRect (&rect, pt))
    1115         return HTBOTTOMRIGHT;
     1102        RECT  rect;
     1103        POINT pt;
     1104
     1105        GetClientRect (hwnd, &rect);
     1106
     1107        pt.x = (INT)LOWORD(lParam);
     1108        pt.y = (INT)HIWORD(lParam);
     1109        ScreenToClient (hwnd, &pt);
     1110
     1111        rect.left = rect.right - 13;
     1112        rect.top += 2;
     1113
     1114        if (PtInRect (&rect, pt))
     1115            return HTBOTTOMRIGHT;
    11161116    }
    11171117
     
    11491149    STATUSBAR_Refresh (infoPtr, hwnd, hdc);
    11501150    if (!wParam)
    1151     EndPaint (hwnd, &ps);
     1151        EndPaint (hwnd, &ps);
    11521152
    11531153    return 0;
     
    11941194    TRACE("\n");
    11951195    if (infoPtr->numParts == 0)
    1196     return FALSE;
     1196        return FALSE;
    11971197
    11981198    part = &infoPtr->parts[0];
     
    12021202    part->text = 0;
    12031203    if (infoPtr->bUnicode) {
    1204     if (lParam && (len = strlenW((LPCWSTR)lParam))) {
    1205         part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
    1206         strcpyW (part->text, (LPCWSTR)lParam);
    1207     }
     1204        if (lParam && (len = strlenW((LPCWSTR)lParam))) {
     1205            part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
     1206            strcpyW (part->text, (LPCWSTR)lParam);
     1207        }
    12081208    }
    12091209    else {
    1210     if (lParam && (len = lstrlenA((LPCSTR)lParam))) {
     1210        if (lParam && (len = lstrlenA((LPCSTR)lParam))) {
    12111211            DWORD lenW = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)lParam, -1, NULL, 0 );
    12121212            part->text = COMCTL32_Alloc (lenW*sizeof(WCHAR));
    12131213            MultiByteToWideChar( CP_ACP, 0, (LPCSTR)lParam, -1, part->text, lenW );
    1214     }
     1214        }
    12151215    }
    12161216
     
    12401240    {
    12411241        if (flags == SIZE_RESTORED) {
    1242         /* width and height don't apply */
    1243         GetClientRect (infoPtr->hwndParent, &parent_rect);
    1244         width = parent_rect.right - parent_rect.left;
    1245         x = parent_rect.left;
    1246         y = parent_rect.bottom - infoPtr->height;
    1247         MoveWindow (hwnd, parent_rect.left,
    1248               parent_rect.bottom - infoPtr->height,
    1249               width, infoPtr->height, TRUE);
    1250         STATUSBAR_SetPartBounds (infoPtr, hwnd);
     1242            /* width and height don't apply */
     1243            GetClientRect (infoPtr->hwndParent, &parent_rect);
     1244            width = parent_rect.right - parent_rect.left;
     1245            x = parent_rect.left;
     1246            y = parent_rect.bottom - infoPtr->height;
     1247            MoveWindow (hwnd, parent_rect.left,
     1248                      parent_rect.bottom - infoPtr->height,
     1249                      width, infoPtr->height, TRUE);
     1250            STATUSBAR_SetPartBounds (infoPtr, hwnd);
    12511251        }
    1252     return 0; /* FIXME: ok to return here ? */
     1252        return 0; /* FIXME: ok to return here ? */
    12531253    }
    12541254
     
    12831283
    12841284    switch (msg) {
    1285     case SB_GETBORDERS:
    1286         return STATUSBAR_GetBorders (lParam);
    1287 
    1288     case SB_GETICON:
    1289         return STATUSBAR_GetIcon (infoPtr, hwnd, wParam);
    1290 
    1291     case SB_GETPARTS:
    1292         return STATUSBAR_GetParts (infoPtr, hwnd, wParam, lParam);
    1293 
    1294     case SB_GETRECT:
    1295         return STATUSBAR_GetRect (infoPtr, hwnd, wParam, lParam);
    1296 
    1297     case SB_GETTEXTA:
    1298         return STATUSBAR_GetTextA (infoPtr, hwnd, wParam, lParam);
    1299 
    1300     case SB_GETTEXTW:
    1301         return STATUSBAR_GetTextW (infoPtr, hwnd, wParam, lParam);
    1302 
    1303     case SB_GETTEXTLENGTHA:
    1304     case SB_GETTEXTLENGTHW:
    1305         return STATUSBAR_GetTextLength (infoPtr, hwnd, wParam);
    1306 
    1307     case SB_GETTIPTEXTA:
    1308         return STATUSBAR_GetTipTextA (infoPtr, hwnd, wParam, lParam);
    1309 
    1310     case SB_GETTIPTEXTW:
    1311         return STATUSBAR_GetTipTextW (infoPtr, hwnd, wParam, lParam);
    1312 
    1313     case SB_GETUNICODEFORMAT:
    1314         return STATUSBAR_GetUnicodeFormat (infoPtr, hwnd);
    1315 
    1316     case SB_ISSIMPLE:
    1317         return STATUSBAR_IsSimple (infoPtr, hwnd);
    1318 
    1319     case SB_SETBKCOLOR:
    1320         return STATUSBAR_SetBkColor (infoPtr, hwnd, wParam, lParam);
    1321 
    1322     case SB_SETICON:
    1323         return STATUSBAR_SetIcon (infoPtr, hwnd, wParam, lParam);
    1324 
    1325     case SB_SETMINHEIGHT:
    1326         return STATUSBAR_SetMinHeight (infoPtr, hwnd, wParam, lParam);
    1327 
    1328     case SB_SETPARTS:
    1329         return STATUSBAR_SetParts (infoPtr, hwnd, wParam, lParam);
    1330 
    1331     case SB_SETTEXTA:
    1332         return STATUSBAR_SetTextA (infoPtr, hwnd, wParam, lParam);
    1333 
    1334     case SB_SETTEXTW:
    1335         return STATUSBAR_SetTextW (infoPtr, hwnd, wParam, lParam);
    1336 
    1337     case SB_SETTIPTEXTA:
    1338         return STATUSBAR_SetTipTextA (infoPtr, hwnd, wParam, lParam);
    1339 
    1340     case SB_SETTIPTEXTW:
    1341         return STATUSBAR_SetTipTextW (infoPtr, hwnd, wParam, lParam);
    1342 
    1343     case SB_SETUNICODEFORMAT:
    1344         return STATUSBAR_SetUnicodeFormat (infoPtr, hwnd, wParam);
    1345 
    1346     case SB_SIMPLE:
    1347         return STATUSBAR_Simple (infoPtr, hwnd, wParam, lParam);
    1348 
    1349 
    1350     case WM_CREATE:
    1351         return STATUSBAR_WMCreate (hwnd, wParam, lParam);
    1352 
    1353     case WM_DESTROY:
    1354         return STATUSBAR_WMDestroy (infoPtr, hwnd);
    1355 
    1356     case WM_GETFONT:
     1285        case SB_GETBORDERS:
     1286            return STATUSBAR_GetBorders (lParam);
     1287
     1288        case SB_GETICON:
     1289            return STATUSBAR_GetIcon (infoPtr, hwnd, wParam);
     1290
     1291        case SB_GETPARTS:
     1292            return STATUSBAR_GetParts (infoPtr, hwnd, wParam, lParam);
     1293
     1294        case SB_GETRECT:
     1295            return STATUSBAR_GetRect (infoPtr, hwnd, wParam, lParam);
     1296
     1297        case SB_GETTEXTA:
     1298            return STATUSBAR_GetTextA (infoPtr, hwnd, wParam, lParam);
     1299
     1300        case SB_GETTEXTW:
     1301            return STATUSBAR_GetTextW (infoPtr, hwnd, wParam, lParam);
     1302
     1303        case SB_GETTEXTLENGTHA:
     1304        case SB_GETTEXTLENGTHW:
     1305            return STATUSBAR_GetTextLength (infoPtr, hwnd, wParam);
     1306
     1307        case SB_GETTIPTEXTA:
     1308            return STATUSBAR_GetTipTextA (infoPtr, hwnd, wParam, lParam);
     1309
     1310        case SB_GETTIPTEXTW:
     1311            return STATUSBAR_GetTipTextW (infoPtr, hwnd, wParam, lParam);
     1312
     1313        case SB_GETUNICODEFORMAT:
     1314            return STATUSBAR_GetUnicodeFormat (infoPtr, hwnd);
     1315
     1316        case SB_ISSIMPLE:
     1317            return STATUSBAR_IsSimple (infoPtr, hwnd);
     1318
     1319        case SB_SETBKCOLOR:
     1320            return STATUSBAR_SetBkColor (infoPtr, hwnd, wParam, lParam);
     1321
     1322        case SB_SETICON:
     1323            return STATUSBAR_SetIcon (infoPtr, hwnd, wParam, lParam);
     1324
     1325        case SB_SETMINHEIGHT:
     1326            return STATUSBAR_SetMinHeight (infoPtr, hwnd, wParam, lParam);
     1327
     1328        case SB_SETPARTS:       
     1329            return STATUSBAR_SetParts (infoPtr, hwnd, wParam, lParam);
     1330
     1331        case SB_SETTEXTA:
     1332            return STATUSBAR_SetTextA (infoPtr, hwnd, wParam, lParam);
     1333
     1334        case SB_SETTEXTW:
     1335            return STATUSBAR_SetTextW (infoPtr, hwnd, wParam, lParam);
     1336
     1337        case SB_SETTIPTEXTA:
     1338            return STATUSBAR_SetTipTextA (infoPtr, hwnd, wParam, lParam);
     1339
     1340        case SB_SETTIPTEXTW:
     1341            return STATUSBAR_SetTipTextW (infoPtr, hwnd, wParam, lParam);
     1342
     1343        case SB_SETUNICODEFORMAT:
     1344            return STATUSBAR_SetUnicodeFormat (infoPtr, hwnd, wParam);
     1345
     1346        case SB_SIMPLE:
     1347            return STATUSBAR_Simple (infoPtr, hwnd, wParam, lParam);
     1348
     1349
     1350        case WM_CREATE:
     1351            return STATUSBAR_WMCreate (hwnd, wParam, lParam);
     1352
     1353        case WM_DESTROY:
     1354            return STATUSBAR_WMDestroy (infoPtr, hwnd);
     1355
     1356        case WM_GETFONT:
    13571357            return STATUSBAR_WMGetFont (infoPtr, hwnd);
    13581358
    1359     case WM_GETTEXT:
     1359        case WM_GETTEXT:
    13601360            return STATUSBAR_WMGetText (infoPtr, hwnd, wParam, lParam);
    13611361
    1362     case WM_GETTEXTLENGTH:
    1363         return STATUSBAR_GetTextLength (infoPtr, hwnd, 0);
    1364 
    1365     case WM_LBUTTONDBLCLK:
     1362        case WM_GETTEXTLENGTH:
     1363            return STATUSBAR_GetTextLength (infoPtr, hwnd, 0);
     1364
     1365        case WM_LBUTTONDBLCLK:
    13661366            return STATUSBAR_SendNotify (hwnd, NM_DBLCLK);
    13671367
    1368     case WM_LBUTTONUP:
    1369         return STATUSBAR_SendNotify (hwnd, NM_CLICK);
    1370 
    1371     case WM_MOUSEMOVE:
     1368        case WM_LBUTTONUP:
     1369            return STATUSBAR_SendNotify (hwnd, NM_CLICK);
     1370
     1371        case WM_MOUSEMOVE:
    13721372            return STATUSBAR_WMMouseMove (infoPtr, hwnd, wParam, lParam);
    13731373
    1374     case WM_NCHITTEST:
     1374        case WM_NCHITTEST:
    13751375            return STATUSBAR_WMNCHitTest (hwnd, wParam, lParam);
    13761376
    1377     case WM_NCLBUTTONDOWN:
    1378         return STATUSBAR_WMNCLButtonDown (hwnd, wParam, lParam);
    1379 
    1380     case WM_NCLBUTTONUP:
    1381         return STATUSBAR_WMNCLButtonUp (hwnd, wParam, lParam);
    1382 
    1383     case WM_PAINT:
    1384         return STATUSBAR_WMPaint (infoPtr, hwnd, wParam);
    1385 
    1386     case WM_RBUTTONDBLCLK:
    1387         return STATUSBAR_SendNotify (hwnd, NM_RDBLCLK);
    1388 
    1389     case WM_RBUTTONUP:
    1390         return STATUSBAR_SendNotify (hwnd, NM_RCLICK);
    1391 
    1392     case WM_SETFONT:
    1393         return STATUSBAR_WMSetFont (infoPtr, hwnd, wParam, lParam);
    1394 
    1395     case WM_SETTEXT:
    1396         return STATUSBAR_WMSetText (infoPtr, hwnd, wParam, lParam);
    1397 
    1398     case WM_SIZE:
    1399         return STATUSBAR_WMSize (infoPtr, hwnd, wParam, lParam);
    1400 
    1401     default:
    1402         if (msg >= WM_USER)
    1403         ERR("unknown msg %04x wp=%04x lp=%08lx\n",
    1404              msg, wParam, lParam);
     1377        case WM_NCLBUTTONDOWN:
     1378            return STATUSBAR_WMNCLButtonDown (hwnd, wParam, lParam);
     1379
     1380        case WM_NCLBUTTONUP:
     1381            return STATUSBAR_WMNCLButtonUp (hwnd, wParam, lParam);
     1382
     1383        case WM_PAINT:
     1384            return STATUSBAR_WMPaint (infoPtr, hwnd, wParam);
     1385
     1386        case WM_RBUTTONDBLCLK:
     1387            return STATUSBAR_SendNotify (hwnd, NM_RDBLCLK);
     1388
     1389        case WM_RBUTTONUP:
     1390            return STATUSBAR_SendNotify (hwnd, NM_RCLICK);
     1391
     1392        case WM_SETFONT:
     1393            return STATUSBAR_WMSetFont (infoPtr, hwnd, wParam, lParam);
     1394
     1395        case WM_SETTEXT:
     1396            return STATUSBAR_WMSetText (infoPtr, hwnd, wParam, lParam);
     1397
     1398        case WM_SIZE:
     1399            return STATUSBAR_WMSize (infoPtr, hwnd, wParam, lParam);
     1400
     1401        default:
     1402            if (msg >= WM_USER)
     1403                ERR("unknown msg %04x wp=%04x lp=%08lx\n",
     1404                     msg, wParam, lParam);
    14051405#ifdef __WIN32OS2__
    14061406            return defComCtl32ProcA (hwnd, msg, wParam, lParam);
    14071407#else
    1408         return DefWindowProcA (hwnd, msg, wParam, lParam);
     1408            return DefWindowProcA (hwnd, msg, wParam, lParam);
    14091409#endif
    14101410    }
     
    14321432    wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
    14331433    wndClass.lpszClassName = STATUSCLASSNAMEA;
    1434 
     1434 
    14351435    RegisterClassA (&wndClass);
    14361436}
  • trunk/src/comctl32/tab.c

    r6705 r6709  
    3636  LPARAM lParam;
    3737  RECT   rect;    /* bounding rectangle of the item relative to the
    38            * leftmost item (the leftmost item, 0, would have a
    39            * "left" member of 0 in this rectangle)
    40                    *
     38                   * leftmost item (the leftmost item, 0, would have a
     39                   * "left" member of 0 in this rectangle)
     40                   * 
    4141                   * additionally the top member hold the row number
    4242                   * and bottom is unused and should be 0 */
     
    4949#endif
    5050  UINT       uNumItem;        /* number of tab items */
    51   UINT       uNumRows;        /* number of tab rows */
     51  UINT       uNumRows;        /* number of tab rows */
    5252  INT        tabHeight;       /* height of the tab row */
    5353  INT        tabWidth;        /* width of tabs */
     
    5757  HWND       hwndToolTip;     /* handle to tab's tooltip */
    5858  INT        leftmostVisible; /* Used for scrolling, this member contains
    59                    * the index of the first visible item */
     59                               * the index of the first visible item */
    6060  INT        iSelected;       /* the currently selected item */
    6161  INT        iHotTracked;     /* the highlighted item under the mouse */
     
    6363  TAB_ITEM*  items;           /* pointer to an array of TAB_ITEM's */
    6464  BOOL       DoRedraw;        /* flag for redrawing when tab contents is changed*/
    65   BOOL       needsScrolling;  /* TRUE if the size of the tabs is greater than
    66                    * the size of the control */
    67   BOOL       fSizeSet;        /* was the size of the tabs explicitly set? */
     65  BOOL       needsScrolling;  /* TRUE if the size of the tabs is greater than 
     66                               * the size of the control */
     67  BOOL       fSizeSet;        /* was the size of the tabs explicitly set? */
    6868  BOOL       bUnicode;        /* Unicode control? */
    6969  HWND       hwndUpDown;      /* Updown control used for scrolling */
     
    8181#define CONTROL_BORDER_SIZEX    2
    8282#define CONTROL_BORDER_SIZEY    2
    83 #define BUTTON_SPACINGX         4
     83#define BUTTON_SPACINGX         4 
    8484#define BUTTON_SPACINGY         4
    8585#define FLAT_BTN_SPACINGX       8
     
    137137{
    138138    TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    139 
     139 
    140140    return infoPtr->iSelected;
    141141}
     
    145145{
    146146    TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    147 
     147 
    148148    return infoPtr->uFocus;
    149149}
     
    164164  INT iItem = (INT)wParam;
    165165  INT prevItem;
    166 
     166 
    167167  prevItem = -1;
    168168  if ((iItem >= 0) && (iItem < infoPtr->uNumItem)) {
     
    180180  TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    181181  INT iItem=(INT) wParam;
    182 
     182 
    183183  if ((iItem < 0) || (iItem >= infoPtr->uNumItem)) return 0;
    184184
    185185  if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BUTTONS) {
    186186    FIXME("Should set input focus\n");
    187   } else {
     187  } else { 
    188188    int oldFocus = infoPtr->uFocus;
    189189    if (infoPtr->iSelected != iItem || infoPtr->uFocus == -1 ) {
     
    232232  RECT tmpItemRect,clientRect;
    233233  LONG        lStyle  = GetWindowLongA(hwnd, GWL_STYLE);
    234 
     234 
    235235  /* Perform a sanity check and a trivial visibility check. */
    236236  if ( (infoPtr->uNumItem <= 0) ||
     
    245245  if (itemRect == NULL)
    246246    itemRect = &tmpItemRect;
    247 
     247 
    248248  /* Retrieve the unmodified item rect. */
    249249  *itemRect = infoPtr->items[itemIndex].rect;
     
    280280  else if(!(lStyle & TCS_VERTICAL) && !(lStyle & TCS_BOTTOM)) /* not TCS_BOTTOM and not TCS_VERTICAL */
    281281  {
    282     itemRect->bottom = clientRect.top +
     282    itemRect->bottom = clientRect.top + 
    283283                      infoPtr->tabHeight +
    284284                      itemRect->top * (infoPtr->tabHeight - 2) +
    285285                      ((lStyle & TCS_BUTTONS) ? itemRect->top * BUTTON_SPACINGY : 0);
    286     itemRect->top = clientRect.top +
     286    itemRect->top = clientRect.top + 
    287287                   SELECTED_TAB_OFFSET +
    288288                   itemRect->top * (infoPtr->tabHeight - 2) +
     
    291291
    292292  /*
    293    * "scroll" it to make sure the item at the very left of the
     293   * "scroll" it to make sure the item at the very left of the 
    294294   * tab control is the leftmost visible tab.
    295295   */
     
    297297  {
    298298    OffsetRect(itemRect,
    299          0,
    300          -(clientRect.bottom - infoPtr->items[infoPtr->leftmostVisible].rect.bottom));
     299             0,
     300             -(clientRect.bottom - infoPtr->items[infoPtr->leftmostVisible].rect.bottom));
    301301
    302302    /*
     
    305305     */
    306306    OffsetRect(itemRect,
    307          0,
    308          -SELECTED_TAB_OFFSET);
     307             0,
     308             -SELECTED_TAB_OFFSET);
    309309
    310310  } else
    311311  {
    312312    OffsetRect(itemRect,
    313          -infoPtr->items[infoPtr->leftmostVisible].rect.left,
    314          0);
     313             -infoPtr->items[infoPtr->leftmostVisible].rect.left,
     314             0);
    315315
    316316    /*
     
    319319     */
    320320    OffsetRect(itemRect,
    321          SELECTED_TAB_OFFSET,
    322          0);
     321             SELECTED_TAB_OFFSET,
     322             0);
    323323  }
    324324
     
    336336    /* If it also a bit higher. */
    337337    if ((lStyle & TCS_BOTTOM) && !(lStyle & TCS_VERTICAL))
    338     {
     338    {     
    339339      selectedRect->top -= 2; /* the border is thicker on the bottom */
    340340      selectedRect->bottom += SELECTED_TAB_OFFSET;
     
    362362static BOOL TAB_GetItemRect(HWND hwnd, WPARAM wParam, LPARAM lParam)
    363363{
    364   return TAB_InternalGetItemRect(hwnd, TAB_GetInfoPtr(hwnd), (INT)wParam,
     364  return TAB_InternalGetItemRect(hwnd, TAB_GetInfoPtr(hwnd), (INT)wParam, 
    365365                                 (LPRECT)lParam, (LPRECT)NULL);
    366366}
     
    372372 */
    373373static LRESULT TAB_KeyUp(
    374   HWND   hwnd,
     374  HWND   hwnd, 
    375375  WPARAM keyCode)
    376376{
     
    387387      break;
    388388  }
    389 
     389 
    390390  /*
    391391   * If we changed to a valid item, change the selection
     
    416416 */
    417417static LRESULT TAB_FocusChanging(
    418   HWND   hwnd,
    419   UINT   uMsg,
    420   WPARAM wParam,
     418  HWND   hwnd, 
     419  UINT   uMsg, 
     420  WPARAM wParam, 
    421421  LPARAM lParam)
    422422{
     
    429429   */
    430430  isVisible = TAB_InternalGetItemRect(hwnd,
    431                       infoPtr,
    432                       infoPtr->uFocus,
    433                       NULL,
    434                       &selectedRect);
    435 
     431                                      infoPtr,
     432                                      infoPtr->uFocus,
     433                                      NULL,
     434                                      &selectedRect);
     435 
    436436  /*
    437437   * If the rectangle is not completely invisible, invalidate that
     
    451451static HWND TAB_InternalHitTest (
    452452  HWND      hwnd,
    453   TAB_INFO* infoPtr,
    454   POINT     pt,
     453  TAB_INFO* infoPtr, 
     454  POINT     pt, 
    455455  UINT*     flags)
    456456
    457457{
    458458  RECT rect;
    459   int iCount;
    460 
     459  int iCount; 
     460 
    461461  for (iCount = 0; iCount < infoPtr->uNumItem; iCount++)
    462462  {
     
    479479  TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    480480  LPTCHITTESTINFO lptest = (LPTCHITTESTINFO) lParam;
    481 
     481 
    482482  return TAB_InternalHitTest (hwnd, infoPtr, lptest->pt, &lptest->flags);
    483483}
     
    521521  if (infoPtr->hwndToolTip)
    522522    TAB_RelayEvent (infoPtr->hwndToolTip, hwnd,
    523             WM_LBUTTONDOWN, wParam, lParam);
     523                    WM_LBUTTONDOWN, wParam, lParam);
    524524
    525525  if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_FOCUSONBUTTONDOWN ) {
     
    529529  if (infoPtr->hwndToolTip)
    530530    TAB_RelayEvent (infoPtr->hwndToolTip, hwnd,
    531             WM_LBUTTONDOWN, wParam, lParam);
    532 
     531                    WM_LBUTTONDOWN, wParam, lParam);
     532 
    533533  pt.x = (INT)LOWORD(lParam);
    534534  pt.y = (INT)HIWORD(lParam);
    535 
     535 
    536536  newItem = TAB_InternalHitTest (hwnd, infoPtr, pt, &dummy);
    537 
     537 
    538538  TRACE("On Tab, item %d\n", newItem);
    539539
     
    619619    ** overlaps.  Note also that the case where the cursor stayed within our
    620620    ** window but has moved off the hot-tracked tab will be handled by the
    621     ** WM_MOUSEMOVE event.
     621    ** WM_MOUSEMOVE event. 
    622622    */
    623623    if (!GetCursorPos(&pt) || WindowFromPoint(pt) != hwnd)
     
    721721    if (item >= 0)
    722722    {
    723     /* Mark new hot-tracked to be redrawn to look highlighted */
     723        /* Mark new hot-tracked to be redrawn to look highlighted */
    724724      if (out_redrawEnter != NULL)
    725725        *out_redrawEnter = item;
     
    743743  if (infoPtr->hwndToolTip)
    744744    TAB_RelayEvent (infoPtr->hwndToolTip, hwnd,
    745             WM_LBUTTONDOWN, wParam, lParam);
     745                    WM_LBUTTONDOWN, wParam, lParam);
    746746
    747747  /* Determine which tab to highlight.  Redraw tabs which change highlight
     
    764764 */
    765765static LRESULT TAB_AdjustRect(
    766   HWND   hwnd,
    767   WPARAM fLarger,
     766  HWND   hwnd, 
     767  WPARAM fLarger, 
    768768  LPRECT prc)
    769769{
     
    845845 */
    846846static LRESULT TAB_OnHScroll(
    847   HWND    hwnd,
     847  HWND    hwnd, 
    848848  int     nScrollCode,
    849849  int     nPos,
     
    871871 * TAB_SetupScrolling
    872872 *
    873  * This method will check the current scrolling state and make sure the
     873 * This method will check the current scrolling state and make sure the 
    874874 * scrolling control is displayed (or not).
    875875 */
     
    930930    {
    931931      infoPtr->hwndUpDown = CreateWindowA("msctls_updown32",
    932                       "",
    933                       WS_VISIBLE | WS_CHILD | UDS_HORZ,
    934                       controlPos.left, controlPos.top,
    935                       controlPos.right - controlPos.left,
    936                       controlPos.bottom - controlPos.top,
    937                       hwnd,
    938                       (HMENU)NULL,
    939                       (HINSTANCE)NULL,
    940                       NULL);
     932                                          "",
     933                                          WS_VISIBLE | WS_CHILD | UDS_HORZ,
     934                                          controlPos.left, controlPos.top,
     935                                          controlPos.right - controlPos.left,
     936                                          controlPos.bottom - controlPos.top,
     937                                          hwnd,
     938                                          (HMENU)NULL,
     939                                          (HINSTANCE)NULL,
     940                                          NULL);       
    941941    }
    942942    else
    943943    {
    944       SetWindowPos(infoPtr->hwndUpDown,
    945            (HWND)NULL,
    946            controlPos.left, controlPos.top,
    947            controlPos.right - controlPos.left,
    948            controlPos.bottom - controlPos.top,
    949            SWP_SHOWWINDOW | SWP_NOZORDER);
     944      SetWindowPos(infoPtr->hwndUpDown, 
     945                   (HWND)NULL,
     946                   controlPos.left, controlPos.top,
     947                   controlPos.right - controlPos.left,
     948                   controlPos.bottom - controlPos.top,
     949                   SWP_SHOWWINDOW | SWP_NOZORDER);                 
    950950    }
    951951
     
    10101010   * a font.
    10111011   */
    1012   hdc = GetDC(hwnd);
    1013 
     1012  hdc = GetDC(hwnd); 
     1013   
    10141014  hFont = infoPtr->hFont ? infoPtr->hFont : GetStockObject (SYSTEM_FONT);
    10151015  hOldFont = SelectObject (hdc, hFont);
     
    10221022
    10231023  /* if TCS_VERTICAL then swap the height and width so this code places the
    1024      tabs along the top of the rectangle and we can just rotate them after
     1024     tabs along the top of the rectangle and we can just rotate them after 
    10251025     rather than duplicate all of the below code */
    10261026  if(lStyle & TCS_VERTICAL)
     
    10541054
    10551055    /*
    1056      * Make sure there is enough space for the letters + icon + growing the
    1057      * selected item + extra space for the selected item.
     1056     * Make sure there is enough space for the letters + icon + growing the 
     1057     * selected item + extra space for the selected item.   
    10581058     */
    10591059    infoPtr->tabHeight = item_height + 2 * VERTICAL_ITEM_PADDING +
     
    10851085       * for button style tabs */
    10861086      if (lStyle & TCS_BUTTONS)
    1087           size.cx = max(size.cx, 2 * (infoPtr->tabHeight - 2));
     1087              size.cx = max(size.cx, 2 * (infoPtr->tabHeight - 2));
    10881088
    10891089      /* Add the icon width */
     
    10951095
    10961096      infoPtr->items[curItem].rect.right = infoPtr->items[curItem].rect.left +
    1097                                            size.cx + icon_width +
     1097                                           size.cx + icon_width + 
    10981098                                           num * HORIZONTAL_ITEM_PADDING;
    10991099    }
     
    11141114                                      infoPtr->items[curItem].rect.left;
    11151115
    1116     infoPtr->items[curItem].rect.left = 0;
     1116        infoPtr->items[curItem].rect.left = 0;
    11171117        curItemRowCount++;
    11181118    }
     
    11221122
    11231123    TRACE("TextSize: %li\n", size.cx);
    1124     TRACE("Rect: T %i, L %i, B %i, R %i\n",
    1125       infoPtr->items[curItem].rect.top,
    1126       infoPtr->items[curItem].rect.left,
    1127       infoPtr->items[curItem].rect.bottom,
    1128       infoPtr->items[curItem].rect.right);
     1124    TRACE("Rect: T %i, L %i, B %i, R %i\n", 
     1125          infoPtr->items[curItem].rect.top,
     1126          infoPtr->items[curItem].rect.left,
     1127          infoPtr->items[curItem].rect.bottom,
     1128          infoPtr->items[curItem].rect.right); 
    11291129
    11301130    /*
     
    11521152    /* Don't need scrolling, then update infoPtr->leftmostVisible */
    11531153    if(!infoPtr->needsScrolling)
    1154       infoPtr->leftmostVisible = 0;
     1154      infoPtr->leftmostVisible = 0; 
    11551155
    11561156    TAB_SetupScrolling(hwnd, infoPtr, &clientRect);
     
    11931193
    11941194          /* shift the item to the left side of the clientRect */
    1195           infoPtr->items[iItm].rect.right -=
     1195          infoPtr->items[iItm].rect.right -= 
    11961196            infoPtr->items[iItm].rect.left;
    11971197          infoPtr->items[iItm].rect.left = 0;
     
    12021202          infoPtr->items[iItm].rect.top = iRow;
    12031203          if (lStyle & TCS_BUTTONS)
    1204       {
     1204          {
    12051205            curItemLeftPos = infoPtr->items[iItm].rect.right + 1;
    12061206            if (lStyle & TCS_FLATBUTTONS)
    1207           curItemLeftPos += FLAT_BTN_SPACINGX;
    1208       }
     1207              curItemLeftPos += FLAT_BTN_SPACINGX;
     1208          }
    12091209          else
    12101210            curItemLeftPos = infoPtr->items[iItm].rect.right;
    12111211      }
    1212 
     1212         
    12131213      /*
    12141214       * Justify the rows
     
    12171217         while(iIndexStart < infoPtr->uNumItem)
    12181218        {
    1219         /*
     1219        /* 
    12201220         * find the indexs of the row
    12211221         */
    12221222        /* find the first item on the next row */
    12231223        for (iIndexEnd=iIndexStart;
    1224              (iIndexEnd < infoPtr->uNumItem) &&
    1225            (infoPtr->items[iIndexEnd].rect.top ==
     1224             (iIndexEnd < infoPtr->uNumItem) && 
     1225               (infoPtr->items[iIndexEnd].rect.top ==
    12261226                infoPtr->items[iIndexStart].rect.top) ;
    12271227            iIndexEnd++)
    12281228        /* intentionaly blank */;
    12291229
    1230         /*
     1230        /* 
    12311231         * we need to justify these tabs so they fill the whole given
    12321232         * client area
     
    12461246           widthDiff = widthDiff / iCount;
    12471247           /* add widthDiff/iCount, or extra space/items on row, to each item on this row */
    1248            for (iIndex=iIndexStart,iCount=0; iIndex < iIndexEnd;
     1248           for (iIndex=iIndexStart,iCount=0; iIndex < iIndexEnd; 
    12491249                iIndex++,iCount++)
    12501250           {
     
    12971297 * This method is used to draw the interior (text and icon) of a single tab
    12981298 * into the tab control.
    1299  */
     1299 */         
    13001300static void
    13011301TAB_DrawItemInterior
     
    13901390    id = GetWindowLongA( hwnd, GWL_ID );
    13911391
    1392     /*
     1392    /* 
    13931393     * put together the DRAWITEMSTRUCT
    13941394     */
    1395     dis.CtlType    = ODT_TAB;
    1396     dis.CtlID      = id;
    1397     dis.itemID     = iItem;
    1398     dis.itemAction = ODA_DRAWENTIRE;
     1395    dis.CtlType    = ODT_TAB;   
     1396    dis.CtlID      = id;               
     1397    dis.itemID     = iItem;             
     1398    dis.itemAction = ODA_DRAWENTIRE;   
    13991399    if ( iItem == infoPtr->iSelected )
    1400       dis.itemState = ODS_SELECTED;
    1401     else
    1402       dis.itemState = 0;
    1403     dis.hwndItem = hwnd;        /* */
    1404     dis.hDC      = hdc;
    1405     dis.rcItem   = *drawRect;       /* */
     1400      dis.itemState = ODS_SELECTED;     
     1401    else                               
     1402      dis.itemState = 0;               
     1403    dis.hwndItem = hwnd;                /* */
     1404    dis.hDC      = hdc;         
     1405    dis.rcItem   = *drawRect;           /* */
    14061406    dis.itemData = infoPtr->items[iItem].lParam;
    14071407
     
    15381538    if(lStyle & TCS_VERTICAL)
    15391539    {
    1540       if (!GetObjectA((infoPtr->hFont) ?
     1540      if (!GetObjectA((infoPtr->hFont) ? 
    15411541                infoPtr->hFont : GetStockObject(SYSTEM_FONT),
    15421542                sizeof(LOGFONTA),&logfont))
     
    15451545
    15461546        lstrcpyA(logfont.lfFaceName, "Arial");
    1547         logfont.lfHeight = -MulDiv(iPointSize, GetDeviceCaps(hdc, LOGPIXELSY),
     1547        logfont.lfHeight = -MulDiv(iPointSize, GetDeviceCaps(hdc, LOGPIXELSY), 
    15481548                                    72);
    15491549        logfont.lfWeight = FW_NORMAL;
     
    16041604 *
    16051605 * This method is used to draw a single tab into the tab control.
    1606  */
     1606 */         
    16071607static void TAB_DrawItem(
    1608   HWND hwnd,
    1609   HDC  hdc,
     1608  HWND hwnd, 
     1609  HDC  hdc, 
    16101610  INT  iItem)
    16111611{
     
    16211621   */
    16221622  isVisible = TAB_InternalGetItemRect(hwnd,
    1623                       infoPtr,
    1624                       iItem,
    1625                       &itemRect,
    1626                       &selectedRect);
     1623                                      infoPtr,
     1624                                      iItem,
     1625                                      &itemRect,
     1626                                      &selectedRect);
    16271627
    16281628  if (isVisible)
    16291629  {
    1630     HBRUSH hbr       = CreateSolidBrush (GetSysColor(COLOR_BTNFACE));
     1630    HBRUSH hbr       = CreateSolidBrush (GetSysColor(COLOR_BTNFACE));   
    16311631    HPEN   hwPen     = GetSysColorPen (COLOR_3DHILIGHT);
    16321632    HPEN hbPen  = GetSysColorPen (COLOR_3DDKSHADOW);
     
    16451645      /* Separators between flat buttons */
    16461646      /* FIXME: test and correct this if necessary for TCS_FLATBUTTONS style */
    1647       if (lStyle & TCS_FLATBUTTONS)
     1647      if (lStyle & TCS_FLATBUTTONS) 
    16481648      {
    16491649        int x = r.right + FLAT_BTN_SPACINGX - 2;
     
    16691669        /* Background color */
    16701670        if (!((lStyle & TCS_OWNERDRAWFIXED) && infoPtr->fSizeSet))
    1671     {
     1671        {
    16721672              COLORREF bk = GetSysColor(COLOR_3DHILIGHT);
    16731673              DeleteObject(hbr);
     
    16851685
    16861686              deleteBrush = FALSE;
    1687     }
     1687        }
    16881688
    16891689        /* Erase the background */
     
    17041704        LineTo   (hdc, r.right, r.bottom);
    17051705        LineTo   (hdc, r.right, r.top + 1);
    1706 
     1706       
    17071707        /* shadow */
    17081708        SelectObject(hdc, hbPen);
     
    17211721        FillRect(hdc, &r, hbr);
    17221722
    1723     if (!(lStyle & TCS_FLATBUTTONS))
    1724     {
     1723        if (!(lStyle & TCS_FLATBUTTONS))
     1724        {
    17251725          /* highlight */
    17261726          MoveToEx (hdc, r.left, r.bottom, NULL);
    17271727          LineTo   (hdc, r.left, r.top);
    17281728          LineTo   (hdc, r.right, r.top);
    1729 
     1729         
    17301730          /* shadow */
    17311731          SelectObject(hdc, hbPen);
     
    17381738          LineTo   (hdc, r.right - 1, r.bottom - 1);
    17391739          LineTo   (hdc, r.left + 1, r.bottom - 1);
    1740     }
     1740        }
    17411741      }
    17421742    }
     
    17451745      /* Background color */
    17461746      DeleteObject(hbr);
    1747       hbr = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
     1747      hbr = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));   
    17481748
    17491749      /* We draw a rectangle of different sizes depending on the selection
     
    17561756      /*
    17571757       * Erase the background.
    1758        * This is necessary when drawing the selected item since it is larger
    1759        * than the others, it might overlap with stuff already drawn by the
     1758       * This is necessary when drawing the selected item since it is larger 
     1759       * than the others, it might overlap with stuff already drawn by the 
    17601760       * other tabs
    1761        */
     1761       */     
    17621762      FillRect(hdc, &r, hbr);
    17631763
     
    17701770      r.right--;
    17711771      r.bottom--;
    1772 
     1772     
    17731773      holdPen = SelectObject (hdc, hwPen);
    17741774      if(lStyle & TCS_VERTICAL)
     
    18591859      }
    18601860    }
    1861 
     1861 
    18621862    /* This modifies r to be the text rectangle. */
    18631863{
     
    18681868    /* Draw the focus rectangle */
    18691869    if (((lStyle & TCS_FOCUSNEVER) == 0) &&
    1870     (GetFocus() == hwnd) &&
    1871     (iItem == infoPtr->uFocus) )
     1870        (GetFocus() == hwnd) &&
     1871        (iItem == infoPtr->uFocus) )
    18721872    {
    18731873      r = itemRect;
     
    18881888 * This method is used to draw the raised border around the tab control
    18891889 * "content" area.
    1890  */
     1890 */         
    18911891static void TAB_DrawBorder (HWND hwnd, HDC hdc)
    18921892{
     
    19571957 *
    19581958 * This method repaints the tab control..
    1959  */
     1959 */             
    19601960static void TAB_Refresh (HWND hwnd, HDC hdc)
    19611961{
     
    19711971  if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BUTTONS)
    19721972  {
    1973     for (i = 0; i < infoPtr->uNumItem; i++)
     1973    for (i = 0; i < infoPtr->uNumItem; i++) 
    19741974      TAB_DrawItem (hwnd, hdc, i);
    19751975  }
     
    19771977  {
    19781978    /* Draw all the non selected item first */
    1979     for (i = 0; i < infoPtr->uNumItem; i++)
     1979    for (i = 0; i < infoPtr->uNumItem; i++) 
    19801980    {
    19811981      if (i != infoPtr->iSelected)
    1982     TAB_DrawItem (hwnd, hdc, i);
     1982        TAB_DrawItem (hwnd, hdc, i);
    19831983    }
    19841984
     
    20112011{
    20122012    TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    2013 
     2013 
    20142014  infoPtr->DoRedraw=(BOOL) wParam;
    20152015  return 0;
     
    20172017
    20182018static LRESULT TAB_EraseBackground(
    2019   HWND hwnd,
     2019  HWND hwnd, 
    20202020  HDC  givenDC)
    20212021{
     
    22072207  HDC hdc;
    22082208  PAINTSTRUCT ps;
    2209 
     2209   
    22102210  hdc = wParam== 0 ? BeginPaint (hwnd, &ps) : (HDC)wParam;
    22112211  TAB_Refresh (hwnd, hdc);
    2212 
     2212   
    22132213  if(!wParam)
    22142214    EndPaint (hwnd, &ps);
     
    22192219static LRESULT
    22202220TAB_InsertItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    2221 {
     2221{   
    22222222  TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    22232223  TCITEMA *pti;
    22242224  INT iItem;
    22252225  RECT rect;
    2226 
     2226 
    22272227  GetClientRect (hwnd, &rect);
    22282228  TRACE("Rect: %x T %i, L %i, B %i, R %i\n", hwnd,
    2229         rect.top, rect.left, rect.bottom, rect.right);
    2230 
     2229        rect.top, rect.left, rect.bottom, rect.right); 
     2230 
    22312231  pti = (TCITEMA *)lParam;
    22322232  iItem = (INT)wParam;
    2233 
     2233 
    22342234  if (iItem < 0) return -1;
    22352235  if (iItem > infoPtr->uNumItem)
    22362236    iItem = infoPtr->uNumItem;
    2237 
     2237 
    22382238  if (infoPtr->uNumItem == 0) {
    22392239    infoPtr->items = COMCTL32_Alloc (sizeof (TAB_ITEM));
     
    22432243  else {
    22442244    TAB_ITEM *oldItems = infoPtr->items;
    2245 
     2245   
    22462246    infoPtr->uNumItem++;
    22472247    infoPtr->items = COMCTL32_Alloc (sizeof (TAB_ITEM) * infoPtr->uNumItem);
    2248 
     2248   
    22492249    /* pre insert copy */
    22502250    if (iItem > 0) {
    22512251      memcpy (&infoPtr->items[0], &oldItems[0],
    2252           iItem * sizeof(TAB_ITEM));
    2253     }
    2254 
     2252              iItem * sizeof(TAB_ITEM));
     2253    }
     2254   
    22552255    /* post insert copy */
    22562256    if (iItem < infoPtr->uNumItem - 1) {
    22572257      memcpy (&infoPtr->items[iItem+1], &oldItems[iItem],
    2258           (infoPtr->uNumItem - iItem - 1) * sizeof(TAB_ITEM));
    2259 
     2258              (infoPtr->uNumItem - iItem - 1) * sizeof(TAB_ITEM));
     2259     
    22602260    }
    22612261
     
    22652265    COMCTL32_Free (oldItems);
    22662266  }
    2267 
     2267 
    22682268  infoPtr->items[iItem].mask = pti->mask;
    22692269  if (pti->mask & TCIF_TEXT)
     
    22722272  if (pti->mask & TCIF_IMAGE)
    22732273    infoPtr->items[iItem].iImage = pti->iImage;
    2274 
     2274 
    22752275  if (pti->mask & TCIF_PARAM)
    22762276    infoPtr->items[iItem].lParam = pti->lParam;
    2277 
     2277 
    22782278  TAB_SetItemBounds(hwnd);
    22792279  TAB_InvalidateTabArea(hwnd, infoPtr);
    2280 
     2280 
    22812281  TRACE("[%04x]: added item %d '%s'\n",
    2282     hwnd, iItem, debugstr_w(infoPtr->items[iItem].pszText));
     2282        hwnd, iItem, debugstr_w(infoPtr->items[iItem].pszText));
    22832283
    22842284  return iItem;
     
    23192319    if (iItem > 0) {
    23202320      memcpy (&infoPtr->items[0], &oldItems[0],
    2321           iItem * sizeof(TAB_ITEM));
     2321              iItem * sizeof(TAB_ITEM));
    23222322    }
    23232323
     
    23252325    if (iItem < infoPtr->uNumItem - 1) {
    23262326      memcpy (&infoPtr->items[iItem+1], &oldItems[iItem],
    2327           (infoPtr->uNumItem - iItem - 1) * sizeof(TAB_ITEM));
    2328 
    2329   }
    2330 
     2327              (infoPtr->uNumItem - iItem - 1) * sizeof(TAB_ITEM));
     2328
     2329  }
     2330 
    23312331    if (iItem <= infoPtr->iSelected)
    23322332      infoPtr->iSelected++;
     
    23412341  if (pti->mask & TCIF_IMAGE)
    23422342    infoPtr->items[iItem].iImage = pti->iImage;
    2343 
     2343 
    23442344  if (pti->mask & TCIF_PARAM)
    23452345    infoPtr->items[iItem].lParam = pti->lParam;
    2346 
     2346 
    23472347  TAB_SetItemBounds(hwnd);
    23482348  TAB_InvalidateTabArea(hwnd, infoPtr);
    2349 
     2349 
    23502350  TRACE("[%04x]: added item %d '%s'\n",
    2351     hwnd, iItem, debugstr_w(infoPtr->items[iItem].pszText));
     2351        hwnd, iItem, debugstr_w(infoPtr->items[iItem].pszText));
    23522352
    23532353  return iItem;
     
    23552355
    23562356
    2357 static LRESULT
     2357static LRESULT 
    23582358TAB_SetItemSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
    23592359{
     
    23732373}
    23742374
    2375 static LRESULT
     2375static LRESULT 
    23762376TAB_SetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    23772377{
    23782378  TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    2379   TCITEMA *tabItem;
     2379  TCITEMA *tabItem; 
    23802380  TAB_ITEM *wineItem;
    23812381  INT    iItem;
     
    23952395    wineItem->lParam = tabItem->lParam;
    23962396
    2397   if (tabItem->mask & TCIF_RTLREADING)
     2397  if (tabItem->mask & TCIF_RTLREADING) 
    23982398    FIXME("TCIF_RTLREADING\n");
    23992399
    2400   if (tabItem->mask & TCIF_STATE)
     2400  if (tabItem->mask & TCIF_STATE) 
    24012401    wineItem->dwState = tabItem->dwState;
    24022402
     
    24512451
    24522452
    2453 static LRESULT
     2453static LRESULT 
    24542454TAB_GetItemCount (HWND hwnd, WPARAM wParam, LPARAM lParam)
    24552455{
     
    24602460
    24612461
    2462 static LRESULT
     2462static LRESULT 
    24632463TAB_GetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    24642464{
     
    24762476  wineItem = &infoPtr->items[iItem];
    24772477
    2478   if (tabItem->mask & TCIF_IMAGE)
     2478  if (tabItem->mask & TCIF_IMAGE) 
    24792479    tabItem->iImage = wineItem->iImage;
    24802480
    2481   if (tabItem->mask & TCIF_PARAM)
     2481  if (tabItem->mask & TCIF_PARAM) 
    24822482    tabItem->lParam = wineItem->lParam;
    24832483
    2484   if (tabItem->mask & TCIF_RTLREADING)
     2484  if (tabItem->mask & TCIF_RTLREADING) 
    24852485    FIXME("TCIF_RTLREADING\n");
    24862486
    2487   if (tabItem->mask & TCIF_STATE)
     2487  if (tabItem->mask & TCIF_STATE) 
    24882488    tabItem->dwState = wineItem->dwState;
    24892489
    2490   if (tabItem->mask & TCIF_TEXT)
     2490  if (tabItem->mask & TCIF_TEXT) 
    24912491   Str_GetPtrWtoA (wineItem->pszText, tabItem->pszText, tabItem->cchTextMax);
    24922492
     
    24952495
    24962496
    2497 static LRESULT
     2497static LRESULT 
    24982498TAB_GetItemW (HWND hwnd, WPARAM wParam, LPARAM lParam)
    24992499{
     
    25302530
    25312531
    2532 static LRESULT
     2532static LRESULT 
    25332533TAB_DeleteItem (HWND hwnd, WPARAM wParam, LPARAM lParam)
    25342534{
     
    25402540  {
    25412541    TAB_ITEM *oldItems = infoPtr->items;
    2542 
     2542   
    25432543    infoPtr->uNumItem--;
    25442544    infoPtr->items = COMCTL32_Alloc(sizeof (TAB_ITEM) * infoPtr->uNumItem);
    2545 
    2546     if (iItem > 0)
     2545   
     2546    if (iItem > 0) 
    25472547      memcpy(&infoPtr->items[0], &oldItems[0], iItem * sizeof(TAB_ITEM));
    2548 
    2549     if (iItem < infoPtr->uNumItem)
     2548   
     2549    if (iItem < infoPtr->uNumItem) 
    25502550      memcpy(&infoPtr->items[iItem], &oldItems[iItem + 1],
    25512551              (infoPtr->uNumItem - iItem) * sizeof(TAB_ITEM));
    2552 
     2552   
    25532553    COMCTL32_Free(oldItems);
    25542554
     
    25562556    if ((iItem == infoPtr->iSelected) && (iItem > 0))
    25572557      infoPtr->iSelected--;
    2558 
     2558     
    25592559    if (iItem < infoPtr->iSelected)
    25602560      infoPtr->iSelected--;
     
    25732573}
    25742574
    2575 static LRESULT
     2575static LRESULT 
    25762576TAB_DeleteAllItems (HWND hwnd, WPARAM wParam, LPARAM lParam)
    25772577{
     
    25842584    KillTimer(hwnd, TAB_HOTTRACK_TIMER);
    25852585  infoPtr->iHotTracked = -1;
    2586 
     2586 
    25872587  TAB_SetItemBounds(hwnd);
    25882588  TAB_InvalidateTabArea(hwnd,infoPtr);
     
    26052605{
    26062606  TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    2607 
     2607 
    26082608  TRACE("%x %lx\n",wParam, lParam);
    2609 
     2609 
    26102610  infoPtr->hFont = (HFONT)wParam;
    2611 
     2611 
    26122612  TAB_SetItemBounds(hwnd);
    26132613
     
    26762676    cx=LOWORD (lParam);
    26772677    cy=HIWORD (lParam);
    2678     if (GetWindowLongA(hwnd, GWL_STYLE) & CCS_NORESIZE)
     2678    if (GetWindowLongA(hwnd, GWL_STYLE) & CCS_NORESIZE) 
    26792679        uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
    26802680
     
    26952695
    26962696
    2697 static LRESULT
     2697static LRESULT 
    26982698TAB_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
    26992699{
     
    27112711
    27122712  SetWindowLongA(hwnd, 0, (DWORD)infoPtr);
    2713 
     2713   
    27142714  infoPtr->uNumItem        = 0;
    27152715  infoPtr->uNumRows        = 0;
     
    27192719  infoPtr->iSelected       = -1;
    27202720  infoPtr->iHotTracked     = -1;
    2721   infoPtr->uFocus          = -1;
     2721  infoPtr->uFocus          = -1; 
    27222722  infoPtr->hwndToolTip     = 0;
    27232723  infoPtr->DoRedraw        = TRUE;
     
    27252725  infoPtr->hwndUpDown      = 0;
    27262726  infoPtr->leftmostVisible = 0;
    2727   infoPtr->fSizeSet    = FALSE;
    2728   infoPtr->bUnicode    = IsWindowUnicode (hwnd);
    2729 
    2730   TRACE("Created tab control, hwnd [%04x]\n", hwnd);
    2731 
    2732   /* The tab control always has the WS_CLIPSIBLINGS style. Even
    2733      if you don't specify it in CreateWindow. This is necessary in
     2727  infoPtr->fSizeSet        = FALSE;
     2728  infoPtr->bUnicode        = IsWindowUnicode (hwnd);
     2729 
     2730  TRACE("Created tab control, hwnd [%04x]\n", hwnd); 
     2731
     2732  /* The tab control always has the WS_CLIPSIBLINGS style. Even 
     2733     if you don't specify it in CreateWindow. This is necessary in 
    27342734     order for paint to work correctly. This follows windows behaviour. */
    27352735  dwStyle = GetWindowLongA(hwnd, GWL_STYLE);
     
    27402740    infoPtr->hwndToolTip =
    27412741      CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
    2742                CW_USEDEFAULT, CW_USEDEFAULT,
    2743                CW_USEDEFAULT, CW_USEDEFAULT,
    2744                hwnd, 0, 0, 0);
    2745 
     2742                       CW_USEDEFAULT, CW_USEDEFAULT,
     2743                       CW_USEDEFAULT, CW_USEDEFAULT,
     2744                       hwnd, 0, 0, 0);
     2745   
    27462746    /* Send NM_TOOLTIPSCREATED notification */
    27472747    if (infoPtr->hwndToolTip) {
    27482748      NMTOOLTIPSCREATED nmttc;
    2749 
     2749     
    27502750      nmttc.hdr.hwndFrom = hwnd;
    27512751      nmttc.hdr.idFrom = GetWindowLongA(hwnd, GWL_ID);
    27522752      nmttc.hdr.code = NM_TOOLTIPSCREATED;
    27532753      nmttc.hwndToolTips = infoPtr->hwndToolTip;
    2754 
     2754     
    27552755      SendMessageA (GetParent (hwnd), WM_NOTIFY,
    2756             (WPARAM)GetWindowLongA(hwnd, GWL_ID), (LPARAM)&nmttc);
    2757     }
    2758   }
    2759 
     2756                    (WPARAM)GetWindowLongA(hwnd, GWL_ID), (LPARAM)&nmttc);
     2757    }
     2758  } 
     2759   
    27602760  /*
    27612761   * We need to get text information so we need a DC and we need to select
    27622762   * a font.
    27632763   */
    2764   hdc = GetDC(hwnd);
     2764  hdc = GetDC(hwnd); 
    27652765  hOldFont = SelectObject (hdc, GetStockObject (SYSTEM_FONT));
    27662766
     
    27692769
    27702770  /*
    2771    * Make sure there is enough space for the letters + growing the
    2772    * selected item + extra space for the selected item.
     2771   * Make sure there is enough space for the letters + growing the 
     2772   * selected item + extra space for the selected item.   
    27732773   */
    27742774  infoPtr->tabHeight = fontMetrics.tmHeight + 2 * VERTICAL_ITEM_PADDING +
     
    27962796    for (iItem = 0; iItem < infoPtr->uNumItem; iItem++) {
    27972797      if (infoPtr->items[iItem].pszText)
    2798     COMCTL32_Free (infoPtr->items[iItem].pszText);
     2798        COMCTL32_Free (infoPtr->items[iItem].pszText);
    27992799    }
    28002800    COMCTL32_Free (infoPtr->items);
    28012801  }
    2802 
    2803   if (infoPtr->hwndToolTip)
     2802 
     2803  if (infoPtr->hwndToolTip) 
    28042804    DestroyWindow (infoPtr->hwndToolTip);
    2805 
     2805 
    28062806  if (infoPtr->hwndUpDown)
    28072807    DestroyWindow(infoPtr->hwndUpDown);
     
    28272827    case TCM_GETIMAGELIST:
    28282828      return TAB_GetImageList (hwnd, wParam, lParam);
    2829 
     2829     
    28302830    case TCM_SETIMAGELIST:
    28312831      return TAB_SetImageList (hwnd, wParam, lParam);
    2832 
     2832     
    28332833    case TCM_GETITEMCOUNT:
    28342834      return TAB_GetItemCount (hwnd, wParam, lParam);
    2835 
     2835     
    28362836    case TCM_GETITEMA:
    28372837      return TAB_GetItemA (hwnd, wParam, lParam);
    2838 
     2838     
    28392839    case TCM_GETITEMW:
    28402840      return TAB_GetItemW (hwnd, wParam, lParam);
    2841 
     2841     
    28422842    case TCM_SETITEMA:
    28432843      return TAB_SetItemA (hwnd, wParam, lParam);
    2844 
     2844     
    28452845    case TCM_SETITEMW:
    28462846      return TAB_SetItemW (hwnd, wParam, lParam);
    2847 
     2847     
    28482848    case TCM_DELETEITEM:
    28492849      return TAB_DeleteItem (hwnd, wParam, lParam);
    2850 
     2850     
    28512851    case TCM_DELETEALLITEMS:
    28522852     return TAB_DeleteAllItems (hwnd, wParam, lParam);
    2853 
     2853     
    28542854    case TCM_GETITEMRECT:
    28552855     return TAB_GetItemRect (hwnd, wParam, lParam);
    2856 
     2856     
    28572857    case TCM_GETCURSEL:
    28582858      return TAB_GetCurSel (hwnd);
    2859 
     2859     
    28602860    case TCM_HITTEST:
    28612861      return TAB_HitTest (hwnd, wParam, lParam);
    2862 
     2862     
    28632863    case TCM_SETCURSEL:
    28642864      return TAB_SetCurSel (hwnd, wParam);
    2865 
     2865     
    28662866    case TCM_INSERTITEMA:
    28672867      return TAB_InsertItemA (hwnd, wParam, lParam);
    2868 
     2868     
    28692869    case TCM_INSERTITEMW:
    28702870      return TAB_InsertItemW (hwnd, wParam, lParam);
    2871 
     2871     
    28722872    case TCM_SETITEMEXTRA:
    28732873      FIXME("Unimplemented msg TCM_SETITEMEXTRA\n");
    28742874      return 0;
    2875 
     2875     
    28762876    case TCM_ADJUSTRECT:
    28772877      return TAB_AdjustRect (hwnd, (BOOL)wParam, (LPRECT)lParam);
    2878 
     2878     
    28792879    case TCM_SETITEMSIZE:
    28802880      return TAB_SetItemSize (hwnd, wParam, lParam);
    2881 
     2881     
    28822882    case TCM_REMOVEIMAGE:
    28832883      FIXME("Unimplemented msg TCM_REMOVEIMAGE\n");
    28842884      return 0;
    2885 
     2885     
    28862886    case TCM_SETPADDING:
    28872887      FIXME("Unimplemented msg TCM_SETPADDING\n");
    28882888      return 0;
    2889 
     2889     
    28902890    case TCM_GETROWCOUNT:
    28912891      return TAB_GetRowCount(hwnd);
     
    29002900      FIXME("Unimplemented msg TCM_HIGHLIGHTITEM\n");
    29012901      return 0;
    2902 
     2902     
    29032903    case TCM_GETTOOLTIPS:
    29042904      return TAB_GetToolTips (hwnd, wParam, lParam);
    2905 
     2905     
    29062906    case TCM_SETTOOLTIPS:
    29072907      return TAB_SetToolTips (hwnd, wParam, lParam);
    2908 
     2908     
    29092909    case TCM_GETCURFOCUS:
    29102910      return TAB_GetCurFocus (hwnd);
    2911 
     2911     
    29122912    case TCM_SETCURFOCUS:
    29132913      return TAB_SetCurFocus (hwnd, wParam);
    2914 
     2914     
    29152915    case TCM_SETMINTABWIDTH:
    29162916      FIXME("Unimplemented msg TCM_SETMINTABWIDTH\n");
    29172917      return 0;
    2918 
     2918     
    29192919    case TCM_DESELECTALL:
    29202920      FIXME("Unimplemented msg TCM_DESELECTALL\n");
    29212921      return 0;
    2922 
     2922     
    29232923    case TCM_GETEXTENDEDSTYLE:
    29242924      FIXME("Unimplemented msg TCM_GETEXTENDEDSTYLE\n");
     
    29312931    case WM_GETFONT:
    29322932      return TAB_GetFont (hwnd, wParam, lParam);
    2933 
     2933     
    29342934    case WM_SETFONT:
    29352935      return TAB_SetFont (hwnd, wParam, lParam);
    2936 
     2936     
    29372937    case WM_CREATE:
    29382938      return TAB_Create (hwnd, wParam, lParam);
    2939 
     2939     
    29402940    case WM_NCDESTROY:
    29412941      return TAB_Destroy (hwnd, wParam, lParam);
    2942 
     2942     
    29432943    case WM_GETDLGCODE:
    29442944      return DLGC_WANTARROWS | DLGC_WANTCHARS;
    2945 
     2945     
    29462946    case WM_LBUTTONDOWN:
    29472947      return TAB_LButtonDown (hwnd, wParam, lParam);
    2948 
     2948     
    29492949    case WM_LBUTTONUP:
    29502950      return TAB_LButtonUp (hwnd, wParam, lParam);
    2951 
     2951     
    29522952    case WM_RBUTTONDOWN:
    29532953      return TAB_RButtonDown (hwnd, wParam, lParam);
    2954 
     2954     
    29552955    case WM_MOUSEMOVE:
    29562956      return TAB_MouseMove (hwnd, wParam, lParam);
    2957 
     2957     
    29582958    case WM_ERASEBKGND:
    29592959      return TAB_EraseBackground (hwnd, (HDC)wParam);
     
    29642964    case WM_SIZE:
    29652965      return TAB_Size (hwnd, wParam, lParam);
    2966 
     2966     
    29672967    case WM_SETREDRAW:
    29682968      return TAB_SetRedraw (hwnd, wParam);
     
    29752975      InvalidateRect(hwnd, NULL, TRUE);
    29762976      return 0;
    2977 
     2977     
    29782978    case WM_KILLFOCUS:
    29792979    case WM_SETFOCUS:
     
    29872987    default:
    29882988      if (uMsg >= WM_USER)
    2989     WARN("unknown msg %04x wp=%08x lp=%08lx\n",
    2990          uMsg, wParam, lParam);
     2989        WARN("unknown msg %04x wp=%08x lp=%08lx\n",
     2990             uMsg, wParam, lParam);
    29912991#ifdef __WIN32OS2__
    29922992      return defComCtl32ProcA (hwnd, uMsg, wParam, lParam);
     
    30133013  wndClass.hbrBackground = (HBRUSH)NULL;
    30143014  wndClass.lpszClassName = WC_TABCONTROLA;
    3015 
     3015 
    30163016  RegisterClassA (&wndClass);
    30173017}
Note: See TracChangeset for help on using the changeset viewer.