Changeset 6644 for trunk/src


Ignore:
Timestamp:
Sep 5, 2001, 2:05:03 PM (24 years ago)
Author:
bird
Message:

Added $Id:$ keyword.

Location:
trunk/src
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/avifil32/api.c

    r6386 r6644  
    1 /*
     1/* $Id: api.c,v 1.2 2001-09-05 12:00:53 bird Exp $
     2 *
    23 * Copyright 1999 Marcus Meissner
    34 * Copyright 2001 Hidenori TAKESHIMA <hidenori@a2.ctktv.ne.jp>
     
    2223
    2324/***********************************************************************
    24  *              AVIFileInit (AVIFILE.100)
    25  *              AVIFileInit (AVIFIL32.@)
     25 *      AVIFileInit (AVIFILE.100)
     26 *      AVIFileInit (AVIFIL32.@)
    2627 */
    2728void WINAPI AVIFileInit(void)
    2829{
    29         TRACE("()\n");
    30         if ( AVIFILE_data.dwAVIFileRef == 0 )
    31         {
    32                 if ( FAILED(CoInitialize(NULL)) )
    33                         AVIFILE_data.fInitCOM = FALSE;
    34                 else
    35                         AVIFILE_data.fInitCOM = TRUE;
    36         }
    37         AVIFILE_data.dwAVIFileRef ++;
    38 }
    39 
    40 /***********************************************************************
    41  *              AVIFileExit (AVIFILE.101)
    42  *              AVIFileExit (AVIFIL32.@)
     30    TRACE("()\n");
     31    if ( AVIFILE_data.dwAVIFileRef == 0 )
     32    {
     33        if ( FAILED(CoInitialize(NULL)) )
     34            AVIFILE_data.fInitCOM = FALSE;
     35        else
     36            AVIFILE_data.fInitCOM = TRUE;
     37    }
     38    AVIFILE_data.dwAVIFileRef ++;
     39}
     40
     41/***********************************************************************
     42 *      AVIFileExit (AVIFILE.101)
     43 *      AVIFileExit (AVIFIL32.@)
    4344 */
    4445void WINAPI AVIFileExit(void)
    4546{
    46         TRACE("()\n");
    47         if ( AVIFILE_data.dwAVIFileRef == 0 )
    48         {
    49                 ERR( "unexpected AVIFileExit()\n" );
    50                 return;
    51         }
    52 
    53         AVIFILE_data.dwAVIFileRef --;
    54         if ( AVIFILE_data.dwAVIFileRef == 0 )
    55         {
    56                 if ( AVIFILE_data.fInitCOM )
    57                 {
    58                         CoUninitialize();
    59                         AVIFILE_data.fInitCOM = FALSE;
    60                 }
    61         }
    62 }
    63 
    64 /***********************************************************************
    65  *              AVIFileAddRef (AVIFIL32.@)
     47    TRACE("()\n");
     48    if ( AVIFILE_data.dwAVIFileRef == 0 )
     49    {
     50        ERR( "unexpected AVIFileExit()\n" );
     51        return;
     52    }
     53
     54    AVIFILE_data.dwAVIFileRef --;
     55    if ( AVIFILE_data.dwAVIFileRef == 0 )
     56    {
     57        if ( AVIFILE_data.fInitCOM )
     58        {
     59            CoUninitialize();
     60            AVIFILE_data.fInitCOM = FALSE;
     61        }
     62    }
     63}
     64
     65/***********************************************************************
     66 *      AVIFileAddRef (AVIFIL32.@)
    6667 */
    6768ULONG WINAPI AVIFileAddRef(PAVIFILE pfile)
    6869{
    69         return IAVIFile_AddRef( pfile );
    70 }
    71 
    72 /***********************************************************************
    73  *              AVIFileRelease (AVIFILE.141)
    74  *              AVIFileRelease (AVIFIL32.@)
     70    return IAVIFile_AddRef( pfile );
     71}
     72
     73/***********************************************************************
     74 *      AVIFileRelease (AVIFILE.141)
     75 *      AVIFileRelease (AVIFIL32.@)
    7576 */
    7677ULONG WINAPI AVIFileRelease(PAVIFILE pfile)
    7778{
    78         return IAVIFile_Release( pfile );
    79 }
    80 
    81 /***********************************************************************
    82  *              AVIFileOpen  (AVIFILE.102)
    83  *              AVIFileOpenA (AVIFIL32.@)
     79    return IAVIFile_Release( pfile );
     80}
     81
     82/***********************************************************************
     83 *      AVIFileOpen  (AVIFILE.102)
     84 *      AVIFileOpenA (AVIFIL32.@)
    8485 */
    8586HRESULT WINAPI AVIFileOpenA(
    86         PAVIFILE* ppfile,LPCSTR szFile,UINT uMode,LPCLSID lpHandler )
    87 {
    88         WCHAR*  pwsz;
    89         HRESULT hr;
    90 
    91         TRACE("(%p,%p,%u,%p)\n",ppfile,szFile,uMode,lpHandler);
    92         pwsz = AVIFILE_strdupAtoW( szFile );
    93         if ( pwsz == NULL )
    94                 return AVIERR_MEMORY;
    95         hr = AVIFileOpenW(ppfile,pwsz,uMode,lpHandler);
    96         HeapFree( AVIFILE_data.hHeap, 0, pwsz );
    97         return hr;
    98 }
    99 
    100 /***********************************************************************
    101  *              AVIFileOpenW (AVIFIL32.@)
     87    PAVIFILE* ppfile,LPCSTR szFile,UINT uMode,LPCLSID lpHandler )
     88{
     89    WCHAR*  pwsz;
     90    HRESULT hr;
     91
     92    TRACE("(%p,%p,%u,%p)\n",ppfile,szFile,uMode,lpHandler);
     93    pwsz = AVIFILE_strdupAtoW( szFile );
     94    if ( pwsz == NULL )
     95        return AVIERR_MEMORY;
     96    hr = AVIFileOpenW(ppfile,pwsz,uMode,lpHandler);
     97    HeapFree( AVIFILE_data.hHeap, 0, pwsz );
     98    return hr;
     99}
     100
     101/***********************************************************************
     102 *      AVIFileOpenW (AVIFIL32.@)
    102103 */
    103104HRESULT WINAPI AVIFileOpenW(
    104         PAVIFILE* ppfile,LPCWSTR szFile,UINT uMode,LPCLSID lpHandler )
    105 {
    106         HRESULT hr;
    107         IClassFactory*  pcf;
    108         CLSID   clsRIFF;
    109 
    110         TRACE("(%p,%p,%u,%p)\n",ppfile,szFile,uMode,lpHandler);
    111         *ppfile = (PAVIFILE)NULL;
    112 
    113         if ( lpHandler == NULL )
    114         {
    115                 /* FIXME - check RIFF type and get a handler from registry
    116                 *         if IAVIFile::Open is worked...
    117                 */
    118                 memcpy( &clsRIFF, &CLSID_AVIFile, sizeof(CLSID) );
    119                 lpHandler = &clsRIFF;
    120         }
    121 
    122         /*
    123         * FIXME - MS says IAVIFile::Open will be called,
    124         *         but no such method in vfw.h... why????
    125         */
    126         if ( !IsEqualGUID( lpHandler, &CLSID_AVIFile ) )
    127                 return REGDB_E_CLASSNOTREG;
    128 
    129         hr = AVIFILE_DllGetClassObject(&CLSID_AVIFile,
    130                                        &IID_IClassFactory,(void**)&pcf);
    131         if ( hr != S_OK )
    132                 return hr;
    133 
    134         hr = IClassFactory_CreateInstance( pcf, NULL, &IID_IAVIFile,
    135                                            (void**)ppfile );
    136         IClassFactory_Release( pcf );
    137 
    138         if ( hr == S_OK )
    139         {
    140                 /* FIXME??? */
    141                 hr = AVIFILE_IAVIFile_Open( *ppfile, szFile, uMode );
    142                 if ( hr != S_OK )
    143                 {
    144                         IAVIFile_Release( (*ppfile) );
    145                         *ppfile = NULL;
    146                 }
    147         }
    148 
    149         return hr;
    150 }
    151 
    152 /***********************************************************************
    153  *              AVIFileInfoW (AVIFIL32.@)
     105    PAVIFILE* ppfile,LPCWSTR szFile,UINT uMode,LPCLSID lpHandler )
     106{
     107    HRESULT hr;
     108    IClassFactory*  pcf;
     109    CLSID   clsRIFF;
     110
     111    TRACE("(%p,%p,%u,%p)\n",ppfile,szFile,uMode,lpHandler);
     112    *ppfile = (PAVIFILE)NULL;
     113
     114    if ( lpHandler == NULL )
     115    {
     116        /* FIXME - check RIFF type and get a handler from registry
     117        *         if IAVIFile::Open is worked...
     118        */
     119        memcpy( &clsRIFF, &CLSID_AVIFile, sizeof(CLSID) );
     120        lpHandler = &clsRIFF;
     121    }
     122
     123    /*
     124    * FIXME - MS says IAVIFile::Open will be called,
     125    *         but no such method in vfw.h... why????
     126    */
     127    if ( !IsEqualGUID( lpHandler, &CLSID_AVIFile ) )
     128        return REGDB_E_CLASSNOTREG;
     129
     130    hr = AVIFILE_DllGetClassObject(&CLSID_AVIFile,
     131                       &IID_IClassFactory,(void**)&pcf);
     132    if ( hr != S_OK )
     133        return hr;
     134
     135    hr = IClassFactory_CreateInstance( pcf, NULL, &IID_IAVIFile,
     136                       (void**)ppfile );
     137    IClassFactory_Release( pcf );
     138
     139    if ( hr == S_OK )
     140    {
     141        /* FIXME??? */
     142        hr = AVIFILE_IAVIFile_Open( *ppfile, szFile, uMode );
     143        if ( hr != S_OK )
     144        {
     145            IAVIFile_Release( (*ppfile) );
     146            *ppfile = NULL;
     147        }
     148    }
     149
     150    return hr;
     151}
     152
     153/***********************************************************************
     154 *      AVIFileInfoW (AVIFIL32.@)
    154155 */
    155156HRESULT WINAPI AVIFileInfoW(PAVIFILE pfile,AVIFILEINFOW* pfi,LONG lSize)
    156157{
    157         return IAVIFile_Info( pfile, pfi, lSize );
    158 }
    159 
    160 /***********************************************************************
    161  *              AVIFileInfo  (AVIFIL32.@)
    162  *              AVIFileInfoA (AVIFIL32.@)
     158    return IAVIFile_Info( pfile, pfi, lSize );
     159}
     160
     161/***********************************************************************
     162 *      AVIFileInfo  (AVIFIL32.@)
     163 *      AVIFileInfoA (AVIFIL32.@)
    163164 */
    164165HRESULT WINAPI AVIFileInfoA(PAVIFILE pfile,AVIFILEINFOA* pfi,LONG lSize)
    165166{
    166         AVIFILEINFOW    fiw;
    167         HRESULT         hr;
    168 
    169         if ( lSize < sizeof(AVIFILEINFOA) )
    170                 return AVIERR_BADSIZE;
    171         hr = AVIFileInfoW( pfile, &fiw, sizeof(AVIFILEINFOW) );
    172         if ( hr != S_OK )
    173                 return hr;
    174         memcpy( pfi,&fiw,sizeof(AVIFILEINFOA) );
    175         AVIFILE_strncpyWtoA( pfi->szFileType, fiw.szFileType,
    176                              sizeof(pfi->szFileType) );
    177         pfi->szFileType[sizeof(pfi->szFileType)-1] = 0;
    178 
    179         return S_OK;
    180 }
    181 
    182 /***********************************************************************
    183  *              AVIFileGetStream (AVIFILE.143)
    184  *              AVIFileGetStream (AVIFIL32.@)
     167    AVIFILEINFOW    fiw;
     168    HRESULT     hr;
     169
     170    if ( lSize < sizeof(AVIFILEINFOA) )
     171        return AVIERR_BADSIZE;
     172    hr = AVIFileInfoW( pfile, &fiw, sizeof(AVIFILEINFOW) );
     173    if ( hr != S_OK )
     174        return hr;
     175    memcpy( pfi,&fiw,sizeof(AVIFILEINFOA) );
     176    AVIFILE_strncpyWtoA( pfi->szFileType, fiw.szFileType,
     177                 sizeof(pfi->szFileType) );
     178    pfi->szFileType[sizeof(pfi->szFileType)-1] = 0;
     179
     180    return S_OK;
     181}
     182
     183/***********************************************************************
     184 *      AVIFileGetStream (AVIFILE.143)
     185 *      AVIFileGetStream (AVIFIL32.@)
    185186 */
    186187HRESULT WINAPI AVIFileGetStream(PAVIFILE pfile,PAVISTREAM* pas,DWORD fccType,LONG lParam)
    187188{
    188         return IAVIFile_GetStream(pfile,pas,fccType,lParam);
    189 }
    190 
    191 /***********************************************************************
    192  *              AVIFileCreateStreamW (AVIFIL32.@)
     189    return IAVIFile_GetStream(pfile,pas,fccType,lParam);
     190}
     191
     192/***********************************************************************
     193 *      AVIFileCreateStreamW (AVIFIL32.@)
    193194 */
    194195HRESULT WINAPI AVIFileCreateStreamW(PAVIFILE pfile,PAVISTREAM* ppas,AVISTREAMINFOW* pasi)
    195196{
    196         return IAVIFile_CreateStream(pfile,ppas,pasi);
    197 }
    198 
    199 /***********************************************************************
    200  *              AVIFileCreateStreamA (AVIFIL32.@)
     197    return IAVIFile_CreateStream(pfile,ppas,pasi);
     198}
     199
     200/***********************************************************************
     201 *      AVIFileCreateStreamA (AVIFIL32.@)
    201202 */
    202203HRESULT WINAPI AVIFileCreateStreamA(PAVIFILE pfile,PAVISTREAM* ppas,AVISTREAMINFOA* pasi)
    203204{
    204         AVISTREAMINFOW  siw;
    205         HRESULT         hr;
    206 
    207         memcpy( &siw,pasi,sizeof(AVISTREAMINFOA) );
    208         AVIFILE_strncpyAtoW( siw.szName, pasi->szName,
    209                 sizeof(siw.szName)/sizeof(siw.szName[0]) );
    210         siw.szName[sizeof(siw.szName)/sizeof(siw.szName[0])-1] = 0;
    211 
    212         hr = AVIFileCreateStreamW(pfile,ppas,&siw);
    213 
    214         return hr;
    215 }
    216 
    217 /***********************************************************************
    218  *              AVIFileWriteData (AVIFIL32.@)
     205    AVISTREAMINFOW  siw;
     206    HRESULT     hr;
     207
     208    memcpy( &siw,pasi,sizeof(AVISTREAMINFOA) );
     209    AVIFILE_strncpyAtoW( siw.szName, pasi->szName,
     210        sizeof(siw.szName)/sizeof(siw.szName[0]) );
     211    siw.szName[sizeof(siw.szName)/sizeof(siw.szName[0])-1] = 0;
     212
     213    hr = AVIFileCreateStreamW(pfile,ppas,&siw);
     214
     215    return hr;
     216}
     217
     218/***********************************************************************
     219 *      AVIFileWriteData (AVIFIL32.@)
    219220 */
    220221HRESULT WINAPI AVIFileWriteData(
    221         PAVIFILE pfile,DWORD dwChunkId,LPVOID lpvData,LONG cbData )
    222 {
    223         return IAVIFile_WriteData( pfile,dwChunkId,lpvData,cbData );
    224 }
    225 
    226 /***********************************************************************
    227  *              AVIFileReadData (AVIFIL32.@)
     222    PAVIFILE pfile,DWORD dwChunkId,LPVOID lpvData,LONG cbData )
     223{
     224    return IAVIFile_WriteData( pfile,dwChunkId,lpvData,cbData );
     225}
     226
     227/***********************************************************************
     228 *      AVIFileReadData (AVIFIL32.@)
    228229 */
    229230HRESULT WINAPI AVIFileReadData(
    230         PAVIFILE pfile,DWORD dwChunkId,LPVOID lpvData,LPLONG pcbData )
    231 {
    232         return IAVIFile_ReadData( pfile,dwChunkId,lpvData,pcbData );
    233 }
    234 
    235 /***********************************************************************
    236  *              AVIFileEndRecord (AVIFIL32.@)
     231    PAVIFILE pfile,DWORD dwChunkId,LPVOID lpvData,LPLONG pcbData )
     232{
     233    return IAVIFile_ReadData( pfile,dwChunkId,lpvData,pcbData );
     234}
     235
     236/***********************************************************************
     237 *      AVIFileEndRecord (AVIFIL32.@)
    237238 */
    238239HRESULT WINAPI AVIFileEndRecord( PAVIFILE pfile )
    239240{
    240         return IAVIFile_EndRecord( pfile );
    241 }
    242 
    243 /***********************************************************************
    244  *              AVIStreamAddRef (AVIFIL32.@)
     241    return IAVIFile_EndRecord( pfile );
     242}
     243
     244/***********************************************************************
     245 *      AVIStreamAddRef (AVIFIL32.@)
    245246 */
    246247ULONG WINAPI AVIStreamAddRef(PAVISTREAM pas)
    247248{
    248         return IAVIStream_Release(pas);
    249 }
    250 
    251 /***********************************************************************
    252  *              AVIStreamRelease (AVIFIL32.@)
     249    return IAVIStream_Release(pas);
     250}
     251
     252/***********************************************************************
     253 *      AVIStreamRelease (AVIFIL32.@)
    253254 */
    254255ULONG WINAPI AVIStreamRelease(PAVISTREAM pas)
    255256{
    256         return IAVIStream_Release(pas);
    257 }
    258 
    259 /***********************************************************************
    260  *              AVIStreamInfoW (AVIFIL32.@)
     257    return IAVIStream_Release(pas);
     258}
     259
     260/***********************************************************************
     261 *      AVIStreamInfoW (AVIFIL32.@)
    261262 */
    262263HRESULT WINAPI AVIStreamInfoW(PAVISTREAM pas,AVISTREAMINFOW* psi,LONG lSize)
    263264{
    264         return IAVIStream_Info(pas,psi,lSize);
    265 }
    266 
    267 /***********************************************************************
    268  *              AVIStreamInfo  (AVIFIL32.@)
    269  *              AVIStreamInfoA (AVIFIL32.@)
     265    return IAVIStream_Info(pas,psi,lSize);
     266}
     267
     268/***********************************************************************
     269 *      AVIStreamInfo  (AVIFIL32.@)
     270 *      AVIStreamInfoA (AVIFIL32.@)
    270271 */
    271272HRESULT WINAPI AVIStreamInfoA(PAVISTREAM pas,AVISTREAMINFOA* psi,LONG lSize)
    272273{
    273         AVISTREAMINFOW  siw;
    274         HRESULT         hr;
    275 
    276         if (lSize < sizeof(AVISTREAMINFOA))
    277                 return AVIERR_BADSIZE;
    278         hr = AVIStreamInfoW(pas,&siw,sizeof(AVISTREAMINFOW));
    279         if ( hr != S_OK )
    280                 return hr;
    281         memcpy( psi,&siw,sizeof(AVIFILEINFOA) );
    282         AVIFILE_strncpyWtoA( psi->szName, siw.szName, sizeof(psi->szName) );
    283         psi->szName[sizeof(psi->szName)-1] = 0;
    284 
    285         return hr;
    286 }
    287 
    288 /***********************************************************************
    289  *              AVIStreamFindSample (AVIFIL32.@)
     274    AVISTREAMINFOW  siw;
     275    HRESULT     hr;
     276
     277    if (lSize < sizeof(AVISTREAMINFOA))
     278        return AVIERR_BADSIZE;
     279    hr = AVIStreamInfoW(pas,&siw,sizeof(AVISTREAMINFOW));
     280    if ( hr != S_OK )
     281        return hr;
     282    memcpy( psi,&siw,sizeof(AVIFILEINFOA) );
     283    AVIFILE_strncpyWtoA( psi->szName, siw.szName, sizeof(psi->szName) );
     284    psi->szName[sizeof(psi->szName)-1] = 0;
     285
     286    return hr;
     287}
     288
     289/***********************************************************************
     290 *      AVIStreamFindSample (AVIFIL32.@)
    290291 */
    291292LONG WINAPI AVIStreamFindSample(PAVISTREAM pas,LONG lPos,LONG lFlags)
    292293{
    293         return IAVIStream_FindSample(pas,lPos,lFlags);
    294 }
    295 
    296 /***********************************************************************
    297  *              AVIStreamReadFormat (AVIFIL32.@)
     294    return IAVIStream_FindSample(pas,lPos,lFlags);
     295}
     296
     297/***********************************************************************
     298 *      AVIStreamReadFormat (AVIFIL32.@)
    298299 */
    299300HRESULT WINAPI AVIStreamReadFormat(PAVISTREAM pas,LONG pos,LPVOID format,LONG *formatsize) {
    300         return IAVIStream_ReadFormat(pas,pos,format,formatsize);
    301 }
    302 
    303 /***********************************************************************
    304  *              AVIStreamSetFormat (AVIFIL32.@)
     301    return IAVIStream_ReadFormat(pas,pos,format,formatsize);
     302}
     303
     304/***********************************************************************
     305 *      AVIStreamSetFormat (AVIFIL32.@)
    305306 */
    306307HRESULT WINAPI AVIStreamSetFormat(PAVISTREAM pas,LONG pos,LPVOID format,LONG formatsize) {
    307         return IAVIStream_SetFormat(pas,pos,format,formatsize);
    308 }
    309 
    310 /***********************************************************************
    311  *              AVIStreamReadData (AVIFIL32.@)
     308    return IAVIStream_SetFormat(pas,pos,format,formatsize);
     309}
     310
     311/***********************************************************************
     312 *      AVIStreamReadData (AVIFIL32.@)
    312313 */
    313314HRESULT WINAPI AVIStreamReadData(PAVISTREAM pas,DWORD fcc,LPVOID lp,LONG *lpread) {
    314         return IAVIStream_ReadData(pas,fcc,lp,lpread);
    315 }
    316 
    317 /***********************************************************************
    318  *              AVIStreamWriteData (AVIFIL32.@)
     315    return IAVIStream_ReadData(pas,fcc,lp,lpread);
     316}
     317
     318/***********************************************************************
     319 *      AVIStreamWriteData (AVIFIL32.@)
    319320 */
    320321HRESULT WINAPI AVIStreamWriteData(PAVISTREAM pas,DWORD fcc,LPVOID lp,LONG size) {
    321         return IAVIStream_WriteData(pas,fcc,lp,size);
    322 }
    323 
    324 /***********************************************************************
    325  *              AVIStreamRead (AVIFIL32.@)
     322    return IAVIStream_WriteData(pas,fcc,lp,size);
     323}
     324
     325/***********************************************************************
     326 *      AVIStreamRead (AVIFIL32.@)
    326327 */
    327328HRESULT WINAPI AVIStreamRead(PAVISTREAM pas,LONG start,LONG samples,LPVOID buffer,LONG buffersize,LONG *bytesread,LONG *samplesread)
    328329{
    329         return IAVIStream_Read(pas,start,samples,buffer,buffersize,bytesread,samplesread);
    330 }
    331 
    332 /***********************************************************************
    333  *              AVIStreamWrite (AVIFIL32.@)
     330    return IAVIStream_Read(pas,start,samples,buffer,buffersize,bytesread,samplesread);
     331}
     332
     333/***********************************************************************
     334 *      AVIStreamWrite (AVIFIL32.@)
    334335 */
    335336HRESULT WINAPI AVIStreamWrite(PAVISTREAM pas,LONG start,LONG samples,LPVOID buffer,LONG buffersize,DWORD flags,LONG *sampwritten,LONG *byteswritten) {
    336         return IAVIStream_Write(pas,start,samples,buffer,buffersize,flags,sampwritten,byteswritten);
    337 }
    338 
    339 
    340 /***********************************************************************
    341  *              AVIStreamStart (AVIFIL32.@)
     337    return IAVIStream_Write(pas,start,samples,buffer,buffersize,flags,sampwritten,byteswritten);
     338}
     339
     340
     341/***********************************************************************
     342 *      AVIStreamStart (AVIFIL32.@)
    342343 */
    343344LONG WINAPI AVIStreamStart(PAVISTREAM pas)
    344345{
    345         AVISTREAMINFOW  si;
    346         HRESULT                 hr;
    347 
    348         hr = IAVIStream_Info(pas,&si,sizeof(si));
    349         if (hr != S_OK)
    350                 return -1;
    351         return (LONG)si.dwStart;
    352 }
    353 
    354 /***********************************************************************
    355  *              AVIStreamLength (AVIFIL32.@)
     346    AVISTREAMINFOW  si;
     347    HRESULT         hr;
     348
     349    hr = IAVIStream_Info(pas,&si,sizeof(si));
     350    if (hr != S_OK)
     351        return -1;
     352    return (LONG)si.dwStart;
     353}
     354
     355/***********************************************************************
     356 *      AVIStreamLength (AVIFIL32.@)
    356357 */
    357358LONG WINAPI AVIStreamLength(PAVISTREAM pas)
    358359{
    359         AVISTREAMINFOW  si;
    360         HRESULT                 hr;
    361 
    362         hr = IAVIStream_Info(pas,&si,sizeof(si));
    363         if (hr != S_OK)
    364                 return -1;
    365         return (LONG)si.dwLength;
    366 }
    367 
    368 /***********************************************************************
    369  *              AVIStreamTimeToSample (AVIFIL32.@)
     360    AVISTREAMINFOW  si;
     361    HRESULT         hr;
     362
     363    hr = IAVIStream_Info(pas,&si,sizeof(si));
     364    if (hr != S_OK)
     365        return -1;
     366    return (LONG)si.dwLength;
     367}
     368
     369/***********************************************************************
     370 *      AVIStreamTimeToSample (AVIFIL32.@)
    370371 */
    371372LONG WINAPI AVIStreamTimeToSample(PAVISTREAM pas,LONG lTime)
    372373{
    373         AVISTREAMINFOW  si;
    374         HRESULT                 hr;
    375 
    376         hr = IAVIStream_Info(pas,&si,sizeof(si));
    377         if (hr != S_OK)
    378                 return -1;
    379 
    380         /* I am too lazy... */
    381         FIXME("(%p,%ld)",pas,lTime);
    382         return (LONG)-1L;
    383 }
    384 
    385 /***********************************************************************
    386  *              AVIStreamSampleToTime (AVIFIL32.@)
     374    AVISTREAMINFOW  si;
     375    HRESULT         hr;
     376
     377    hr = IAVIStream_Info(pas,&si,sizeof(si));
     378    if (hr != S_OK)
     379        return -1;
     380
     381    /* I am too lazy... */
     382    FIXME("(%p,%ld)",pas,lTime);
     383    return (LONG)-1L;
     384}
     385
     386/***********************************************************************
     387 *      AVIStreamSampleToTime (AVIFIL32.@)
    387388 */
    388389LONG WINAPI AVIStreamSampleToTime(PAVISTREAM pas,LONG lSample)
    389390{
    390         AVISTREAMINFOW  si;
    391         HRESULT                 hr;
    392 
    393         hr = IAVIStream_Info(pas,&si,sizeof(si));
    394         if (hr != S_OK)
    395                 return -1;
    396 
    397         /* I am too lazy... */
    398         FIXME("(%p,%ld)",pas,lSample);
    399         return (LONG)-1L;
    400 }
    401 
    402 /***********************************************************************
    403  *              AVIStreamBeginStreaming (AVIFIL32.@)
     391    AVISTREAMINFOW  si;
     392    HRESULT         hr;
     393
     394    hr = IAVIStream_Info(pas,&si,sizeof(si));
     395    if (hr != S_OK)
     396        return -1;
     397
     398    /* I am too lazy... */
     399    FIXME("(%p,%ld)",pas,lSample);
     400    return (LONG)-1L;
     401}
     402
     403/***********************************************************************
     404 *      AVIStreamBeginStreaming (AVIFIL32.@)
    404405 */
    405406HRESULT WINAPI AVIStreamBeginStreaming(PAVISTREAM pas,LONG lStart,LONG lEnd,LONG lRate)
    406407{
    407         FIXME("(%p)->(%ld,%ld,%ld),stub!\n",pas,lStart,lEnd,lRate);
    408         return E_FAIL;
    409 }
    410 
    411 /***********************************************************************
    412  *              AVIStreamEndStreaming (AVIFIL32.@)
     408    FIXME("(%p)->(%ld,%ld,%ld),stub!\n",pas,lStart,lEnd,lRate);
     409    return E_FAIL;
     410}
     411
     412/***********************************************************************
     413 *      AVIStreamEndStreaming (AVIFIL32.@)
    413414 */
    414415HRESULT WINAPI AVIStreamEndStreaming(PAVISTREAM pas)
    415416{
    416         FIXME("(%p)->(),stub!\n",pas);
    417         return E_FAIL;
    418 }
    419 
    420 /***********************************************************************
    421  *              AVIStreamGetFrameOpen (AVIFIL32.@)
     417    FIXME("(%p)->(),stub!\n",pas);
     418    return E_FAIL;
     419}
     420
     421/***********************************************************************
     422 *      AVIStreamGetFrameOpen (AVIFIL32.@)
    422423 */
    423424PGETFRAME WINAPI AVIStreamGetFrameOpen(PAVISTREAM pas,LPBITMAPINFOHEADER pbi)
    424425{
    425         IGetFrame*      pgf;
    426         HRESULT         hr;
    427         AVISTREAMINFOW  si;
    428 
    429         FIXME("(%p,%p)\n",pas,pbi);
    430 
    431         hr = IAVIStream_Info(pas,&si,sizeof(si));
    432         if (hr != S_OK)
    433                 return NULL;
    434 
    435         hr = AVIFILE_CreateIGetFrame((void**)&pgf,pas,pbi);
    436         if ( hr != S_OK )
    437                 return NULL;
    438         hr = IGetFrame_Begin( pgf, si.dwStart, si.dwLength, 1000 );
    439         if ( hr != S_OK )
    440         {
    441                 IGetFrame_Release( pgf );
    442                 return NULL;
    443         }
    444 
    445         return pgf;
    446 }
    447 
    448 /***********************************************************************
    449  *              AVIStreamGetFrame (AVIFIL32.@)
     426    IGetFrame*  pgf;
     427    HRESULT     hr;
     428    AVISTREAMINFOW  si;
     429
     430    FIXME("(%p,%p)\n",pas,pbi);
     431
     432    hr = IAVIStream_Info(pas,&si,sizeof(si));
     433    if (hr != S_OK)
     434        return NULL;
     435
     436    hr = AVIFILE_CreateIGetFrame((void**)&pgf,pas,pbi);
     437    if ( hr != S_OK )
     438        return NULL;
     439    hr = IGetFrame_Begin( pgf, si.dwStart, si.dwLength, 1000 );
     440    if ( hr != S_OK )
     441    {
     442        IGetFrame_Release( pgf );
     443        return NULL;
     444    }
     445
     446    return pgf;
     447}
     448
     449/***********************************************************************
     450 *      AVIStreamGetFrame (AVIFIL32.@)
    450451 */
    451452LPVOID WINAPI AVIStreamGetFrame(PGETFRAME pgf, LONG lPos)
    452453{
    453         return IGetFrame_GetFrame(pgf,lPos);
    454 }
    455 
    456 /***********************************************************************
    457  *              AVIStreamGetFrameClose (AVIFIL32.@)
     454    return IGetFrame_GetFrame(pgf,lPos);
     455}
     456
     457/***********************************************************************
     458 *      AVIStreamGetFrameClose (AVIFIL32.@)
    458459 */
    459460HRESULT WINAPI AVIStreamGetFrameClose(PGETFRAME pgf)
    460461{
    461         return IGetFrame_End(pgf);
    462 }
    463 
    464 /***********************************************************************
    465  *              AVIStreamOpenFromFileA (AVIFIL32.@)
     462    return IGetFrame_End(pgf);
     463}
     464
     465/***********************************************************************
     466 *      AVIStreamOpenFromFileA (AVIFIL32.@)
    466467 */
    467468HRESULT WINAPI AVIStreamOpenFromFileA(PAVISTREAM* ppas, LPCSTR szFile, DWORD fccType, LONG lParam, UINT uMode, CLSID* lpHandler)
    468469{
    469         WCHAR*  pwsz;
    470         HRESULT hr;
    471 
    472         pwsz = AVIFILE_strdupAtoW( szFile );
    473         if ( pwsz == NULL )
    474                 return AVIERR_MEMORY;
    475         hr = AVIStreamOpenFromFileW(ppas,pwsz,fccType,lParam,uMode,lpHandler);
    476         HeapFree( AVIFILE_data.hHeap, 0, pwsz );
    477         return hr;
    478 }
    479 
    480 /***********************************************************************
    481  *              AVIStreamOpenFromFileW (AVIFIL32.@)
     470    WCHAR*  pwsz;
     471    HRESULT hr;
     472
     473    pwsz = AVIFILE_strdupAtoW( szFile );
     474    if ( pwsz == NULL )
     475        return AVIERR_MEMORY;
     476    hr = AVIStreamOpenFromFileW(ppas,pwsz,fccType,lParam,uMode,lpHandler);
     477    HeapFree( AVIFILE_data.hHeap, 0, pwsz );
     478    return hr;
     479}
     480
     481/***********************************************************************
     482 *      AVIStreamOpenFromFileW (AVIFIL32.@)
    482483 */
    483484HRESULT WINAPI AVIStreamOpenFromFileW(PAVISTREAM* ppas, LPCWSTR szFile, DWORD fccType, LONG lParam, UINT uMode, CLSID* lpHandler)
    484485{
    485         HRESULT hr;
    486         PAVIFILE        paf;
    487         AVIFILEINFOW    fi;
    488 
    489         *ppas = NULL;
    490         hr = AVIFileOpenW(&paf,szFile,uMode,lpHandler);
    491         if ( hr != S_OK )
    492                 return hr;
    493         hr = AVIFileInfoW(paf,&fi,sizeof(AVIFILEINFOW));
    494         if ( hr == S_OK )
    495                 hr = AVIFileGetStream(paf,ppas,fccType,lParam);
    496 
    497         IAVIFile_Release(paf);
    498 
    499         return hr;
    500 }
    501 
    502 /***********************************************************************
    503  *              AVIStreamCreate (AVIFIL32.@)
     486    HRESULT hr;
     487    PAVIFILE    paf;
     488    AVIFILEINFOW    fi;
     489
     490    *ppas = NULL;
     491    hr = AVIFileOpenW(&paf,szFile,uMode,lpHandler);
     492    if ( hr != S_OK )
     493        return hr;
     494    hr = AVIFileInfoW(paf,&fi,sizeof(AVIFILEINFOW));
     495    if ( hr == S_OK )
     496        hr = AVIFileGetStream(paf,ppas,fccType,lParam);
     497
     498    IAVIFile_Release(paf);
     499
     500    return hr;
     501}
     502
     503/***********************************************************************
     504 *      AVIStreamCreate (AVIFIL32.@)
    504505 */
    505506HRESULT WINAPI AVIStreamCreate(PAVISTREAM* ppas, LONG lParam1, LONG lParam2, CLSID* lpHandler)
    506507{
    507         HRESULT hr;
    508         IClassFactory*  pcf;
    509 
    510         *ppas = NULL;
    511 
    512         if ( lpHandler == NULL )
    513         {
    514                 hr = AVIFILE_DllGetClassObject(&CLSID_AVIFile,
    515                                                &IID_IClassFactory,(void**)&pcf);
    516         }
    517         else
    518         {
    519                 if ( !AVIFILE_data.fInitCOM )
    520                         return E_UNEXPECTED;
    521                 hr = CoGetClassObject(lpHandler,CLSCTX_INPROC_SERVER,
    522                                       NULL,&IID_IClassFactory,(void**)&pcf);
    523         }
    524         if ( hr != S_OK )
    525                 return hr;
    526 
    527         hr = IClassFactory_CreateInstance( pcf, NULL, &IID_IAVIStream,
    528                                            (void**)ppas );
    529         IClassFactory_Release( pcf );
    530 
    531         if ( hr == S_OK )
    532         {
    533                 hr = IAVIStream_Create((*ppas),lParam1,lParam2);
    534                 if ( hr != S_OK )
    535                 {
    536                         IAVIStream_Release((*ppas));
    537                         *ppas = NULL;
    538                 }
    539         }
    540 
    541         return hr;
    542 }
    543 
    544 /***********************************************************************
    545  *              AVIMakeCompressedStream (AVIFIL32.@)
     508    HRESULT hr;
     509    IClassFactory*  pcf;
     510
     511    *ppas = NULL;
     512
     513    if ( lpHandler == NULL )
     514    {
     515        hr = AVIFILE_DllGetClassObject(&CLSID_AVIFile,
     516                           &IID_IClassFactory,(void**)&pcf);
     517    }
     518    else
     519    {
     520        if ( !AVIFILE_data.fInitCOM )
     521            return E_UNEXPECTED;
     522        hr = CoGetClassObject(lpHandler,CLSCTX_INPROC_SERVER,
     523                      NULL,&IID_IClassFactory,(void**)&pcf);
     524    }
     525    if ( hr != S_OK )
     526        return hr;
     527
     528    hr = IClassFactory_CreateInstance( pcf, NULL, &IID_IAVIStream,
     529                       (void**)ppas );
     530    IClassFactory_Release( pcf );
     531
     532    if ( hr == S_OK )
     533    {
     534        hr = IAVIStream_Create((*ppas),lParam1,lParam2);
     535        if ( hr != S_OK )
     536        {
     537            IAVIStream_Release((*ppas));
     538            *ppas = NULL;
     539        }
     540    }
     541
     542    return hr;
     543}
     544
     545/***********************************************************************
     546 *      AVIMakeCompressedStream (AVIFIL32.@)
    546547 */
    547548HRESULT WINAPI AVIMakeCompressedStream(PAVISTREAM *ppsCompressed,PAVISTREAM ppsSource,AVICOMPRESSOPTIONS *aco,CLSID *pclsidHandler)
    548549{
    549         FIXME("(%p,%p,%p,%p)\n",ppsCompressed,ppsSource,aco,pclsidHandler);
    550         return E_FAIL;
    551 }
    552 
     550    FIXME("(%p,%p,%p,%p)\n",ppsCompressed,ppsSource,aco,pclsidHandler);
     551    return E_FAIL;
     552}
     553
  • trunk/src/avifil32/comentry.c

    r6386 r6644  
    1 /*
     1/* $Id: comentry.c,v 1.2 2001-09-05 12:00:53 bird Exp $
     2 *
    23 * Copyright 2001 Hidenori TAKESHIMA <hidenori@a2.ctktv.ne.jp>
    34 */
     
    2728static ICOM_VTABLE(IClassFactory) iclassfact =
    2829{
    29         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
    30         IClassFactory_fnQueryInterface,
    31         IClassFactory_fnAddRef,
    32         IClassFactory_fnRelease,
    33         IClassFactory_fnCreateInstance,
    34         IClassFactory_fnLockServer
     30    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
     31    IClassFactory_fnQueryInterface,
     32    IClassFactory_fnAddRef,
     33    IClassFactory_fnRelease,
     34    IClassFactory_fnCreateInstance,
     35    IClassFactory_fnLockServer
    3536};
    3637
    3738typedef struct
    3839{
    39         /* IUnknown fields */
    40         ICOM_VFIELD(IClassFactory);
    41         DWORD   ref;
     40    /* IUnknown fields */
     41    ICOM_VFIELD(IClassFactory);
     42    DWORD   ref;
    4243} IClassFactoryImpl;
    4344
     
    4950IClassFactory_fnQueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
    5051{
    51         ICOM_THIS(IClassFactoryImpl,iface);
     52    ICOM_THIS(IClassFactoryImpl,iface);
    5253
    53         TRACE("(%p)->(%p,%p)\n",This,riid,ppobj);
    54         if ( ( IsEqualGUID( &IID_IUnknown, riid ) ) ||
    55              ( IsEqualGUID( &IID_IClassFactory, riid ) ) )
    56         {
    57                 *ppobj = iface;
    58                 IClassFactory_AddRef(iface);
    59                 return S_OK;
    60         }
     54    TRACE("(%p)->(%p,%p)\n",This,riid,ppobj);
     55    if ( ( IsEqualGUID( &IID_IUnknown, riid ) ) ||
     56         ( IsEqualGUID( &IID_IClassFactory, riid ) ) )
     57    {
     58        *ppobj = iface;
     59        IClassFactory_AddRef(iface);
     60        return S_OK;
     61    }
    6162
    62         return E_NOINTERFACE;
     63    return E_NOINTERFACE;
    6364}
    6465
    6566static ULONG WINAPI IClassFactory_fnAddRef(LPCLASSFACTORY iface)
    6667{
    67         ICOM_THIS(IClassFactoryImpl,iface);
     68    ICOM_THIS(IClassFactoryImpl,iface);
    6869
    69         TRACE("(%p)->()\n",This);
    70         if ( (This->ref) == 0 )
    71                 AVIFILE_data.dwClassObjRef ++;
     70    TRACE("(%p)->()\n",This);
     71    if ( (This->ref) == 0 )
     72        AVIFILE_data.dwClassObjRef ++;
    7273
    73         return ++(This->ref);
     74    return ++(This->ref);
    7475}
    7576
    7677static ULONG WINAPI IClassFactory_fnRelease(LPCLASSFACTORY iface)
    7778{
    78         ICOM_THIS(IClassFactoryImpl,iface);
     79    ICOM_THIS(IClassFactoryImpl,iface);
    7980
    80         TRACE("(%p)->()\n",This);
    81         if ( (--(This->ref)) > 0 )
    82                 return This->ref;
     81    TRACE("(%p)->()\n",This);
     82    if ( (--(This->ref)) > 0 )
     83        return This->ref;
    8384
    84         AVIFILE_data.dwClassObjRef --;
    85         return 0;
     85    AVIFILE_data.dwClassObjRef --;
     86    return 0;
    8687}
    8788
     
    9091    /*ICOM_THIS(IClassFactoryImpl,iface);*/
    9192
    92         *ppobj = NULL;
    93         if ( pOuter != NULL )
    94                 return E_FAIL;
     93    *ppobj = NULL;
     94    if ( pOuter != NULL )
     95        return E_FAIL;
    9596
    96         if ( IsEqualGUID( &IID_IAVIFile, riid ) )
    97                 return AVIFILE_CreateIAVIFile(ppobj);
    98         if ( IsEqualGUID( &IID_IAVIStream, riid ) )
    99                 return AVIFILE_CreateIAVIStream(ppobj);
     97    if ( IsEqualGUID( &IID_IAVIFile, riid ) )
     98        return AVIFILE_CreateIAVIFile(ppobj);
     99    if ( IsEqualGUID( &IID_IAVIStream, riid ) )
     100        return AVIFILE_CreateIAVIStream(ppobj);
    100101
    101         return E_NOINTERFACE;
     102    return E_NOINTERFACE;
    102103}
    103104
    104105static HRESULT WINAPI IClassFactory_fnLockServer(LPCLASSFACTORY iface,BOOL dolock)
    105106{
    106         ICOM_THIS(IClassFactoryImpl,iface);
    107         HRESULT hr;
     107    ICOM_THIS(IClassFactoryImpl,iface);
     108    HRESULT hr;
    108109
    109         FIXME("(%p)->(%d),stub!\n",This,dolock);
    110         if (dolock)
    111                 hr = IClassFactory_AddRef(iface);
    112         else
    113                 hr = IClassFactory_Release(iface);
     110    FIXME("(%p)->(%d),stub!\n",This,dolock);
     111    if (dolock)
     112        hr = IClassFactory_AddRef(iface);
     113    else
     114        hr = IClassFactory_Release(iface);
    114115
    115         return hr;
     116    return hr;
    116117}
    117118
    118119
    119120/***********************************************************************
    120  *              DllGetClassObject (AVIFIL32.@)
     121 *      DllGetClassObject (AVIFIL32.@)
    121122 */
    122123HRESULT WINAPI AVIFILE_DllGetClassObject(const CLSID* pclsid,const IID* piid,void** ppv)
    123124{
    124         *ppv = NULL;
    125         if ( IsEqualCLSID( &IID_IClassFactory, piid ) )
    126         {
    127                 *ppv = (LPVOID)&AVIFILE_GlobalCF;
    128                 IClassFactory_AddRef((IClassFactory*)*ppv);
    129                 return S_OK;
    130         }
     125    *ppv = NULL;
     126    if ( IsEqualCLSID( &IID_IClassFactory, piid ) )
     127    {
     128        *ppv = (LPVOID)&AVIFILE_GlobalCF;
     129        IClassFactory_AddRef((IClassFactory*)*ppv);
     130        return S_OK;
     131    }
    131132
    132         return CLASS_E_CLASSNOTAVAILABLE;
     133    return CLASS_E_CLASSNOTAVAILABLE;
    133134}
    134135
    135136/*****************************************************************************
    136  *              DllCanUnloadNow (AVIFIL32.@)
     137 *      DllCanUnloadNow (AVIFIL32.@)
    137138 */
    138139DWORD WINAPI AVIFILE_DllCanUnloadNow(void)
    139140{
    140         return ( AVIFILE_data.dwClassObjRef == 0 ) ? S_OK : S_FALSE;
     141    return ( AVIFILE_data.dwClassObjRef == 0 ) ? S_OK : S_FALSE;
    141142}
    142143
  • trunk/src/comctl32/animate.c

    r5630 r6644  
    11/* -*- tab-width: 8; c-basic-offset: 4 -*- */
     2/* $Id: animate.c,v 1.14 2001-09-05 12:04:56 bird Exp $ */
    23/*
    34 * Animation control
    45 *
    56 * Copyright 1998, 1999 Eric Kohl
    6  *                 1999 Eric Pouech
     7 *         1999 Eric Pouech
    78 *
    89 * NOTES
     
    3334#endif
    3435   /* reference to input stream (file or resource) */
    35    HGLOBAL              hRes;
    36    HMMIO                hMMio;  /* handle to mmio stream */
    37    HWND                 hWnd;
     36   HGLOBAL      hRes;
     37   HMMIO        hMMio;  /* handle to mmio stream */
     38   HWND         hWnd;
    3839   /* information on the loaded AVI file */
    39    MainAVIHeader        mah;
    40    AVIStreamHeader      ash;
    41    LPBITMAPINFOHEADER   inbih;
    42    LPDWORD              lpIndex;
     40   MainAVIHeader    mah;
     41   AVIStreamHeader  ash;
     42   LPBITMAPINFOHEADER   inbih;
     43   LPDWORD      lpIndex;
    4344   /* data for the decompressor */
    44    HIC                  hic;
    45    LPBITMAPINFOHEADER   outbih;
    46    LPVOID               indata;
    47    LPVOID               outdata;
     45   HIC          hic;
     46   LPBITMAPINFOHEADER   outbih;
     47   LPVOID       indata;
     48   LPVOID       outdata;
    4849   /* data for the background mechanism */
    49    CRITICAL_SECTION     cs;
    50    HANDLE               hThread;
    51    UINT                 uTimer;
     50   CRITICAL_SECTION cs;
     51   HANDLE       hThread;
     52   UINT         uTimer;
    5253   /* data for playing the file */
    53    int                  nFromFrame;
    54    int                  nToFrame;
    55    int                  nLoop;
    56    int                  currFrame;
     54   int          nFromFrame;
     55   int          nToFrame;
     56   int          nLoop;
     57   int          currFrame;
    5758   /* tranparency info*/
    58    COLORREF             transparentColor;   
    59    HBRUSH               hbrushBG;
    60    HBITMAP              hbmPrevFrame;
     59   COLORREF             transparentColor;
     60   HBRUSH               hbrushBG;
     61   HBITMAP              hbmPrevFrame;
    6162} ANIMATE_INFO;
    6263
    6364#define ANIMATE_GetInfoPtr(hWnd) ((ANIMATE_INFO *)GetWindowLongA(hWnd, 0))
    64 #define ANIMATE_COLOR_NONE      0xffffffff
     65#define ANIMATE_COLOR_NONE      0xffffffff
    6566
    6667static void ANIMATE_Notify(ANIMATE_INFO* infoPtr, UINT notif)
    6768{
    68     SendMessageA(GetParent(infoPtr->hWnd), WM_COMMAND, 
    69                  MAKEWPARAM(GetDlgCtrlID(infoPtr->hWnd), notif),
    70                 (LPARAM)infoPtr->hWnd);
     69    SendMessageA(GetParent(infoPtr->hWnd), WM_COMMAND,
     70         MAKEWPARAM(GetDlgCtrlID(infoPtr->hWnd), notif),
     71        (LPARAM)infoPtr->hWnd);
    7172}
    7273
     
    7778#endif
    7879{
    79     HRSRC       hrsrc;
    80     MMIOINFO    mminfo;
    81     LPVOID      lpAvi;
    82    
     80    HRSRC   hrsrc;
     81    MMIOINFO    mminfo;
     82    LPVOID  lpAvi;
     83
    8384#ifdef __WIN32OS2__
    8485    if (unicode)
     
    9091#endif
    9192    if (!hrsrc)
    92         return FALSE;
    93    
     93    return FALSE;
     94
    9495    infoPtr->hRes = LoadResource(hInst, hrsrc);
    9596    if (!infoPtr->hRes)
    96         return FALSE;
    97    
     97    return FALSE;
     98
    9899    lpAvi = LockResource(infoPtr->hRes);
    99100    if (!lpAvi)
    100         return FALSE;
    101    
     101    return FALSE;
     102
    102103    memset(&mminfo, 0, sizeof(mminfo));
    103104    mminfo.fccIOProc = FOURCC_MEM;
     
    106107    infoPtr->hMMio = mmioOpenA(NULL, &mminfo, MMIO_READ);
    107108    if (!infoPtr->hMMio) {
    108         GlobalFree((HGLOBAL)lpAvi);
    109         return FALSE;
     109    GlobalFree((HGLOBAL)lpAvi);
     110    return FALSE;
    110111    }
    111112
     
    127128#else
    128129    infoPtr->hMMio = mmioOpenA((LPSTR)lpName, NULL,
    129                                MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE);
     130                   MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE);
    130131#endif
    131132    if (!infoPtr->hMMio)
    132         return FALSE;
    133    
     133    return FALSE;
     134
    134135    return TRUE;
    135136}
     
    141142
    142143    /* should stop playing */
    143     if (infoPtr->hThread) 
     144    if (infoPtr->hThread)
    144145    {
    145146        if (!TerminateThread(infoPtr->hThread,0))
    146147            WARN("could not destroy animation thread!\n");
    147             infoPtr->hThread = 0;
     148        infoPtr->hThread = 0;
    148149    }
    149150    if (infoPtr->uTimer) {
    150         KillTimer(infoPtr->hWnd, infoPtr->uTimer);
    151         infoPtr->uTimer = 0;
     151    KillTimer(infoPtr->hWnd, infoPtr->uTimer);
     152    infoPtr->uTimer = 0;
    152153    }
    153154
     
    163164{
    164165    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         }
     166    ANIMATE_DoStop(infoPtr);
     167    mmioClose(infoPtr->hMMio, 0);
     168    if (infoPtr->hRes) {
     169        FreeResource(infoPtr->hRes);
     170        infoPtr->hRes = 0;
     171    }
     172    if (infoPtr->lpIndex) {
     173        HeapFree(GetProcessHeap(), 0, infoPtr->lpIndex);
     174        infoPtr->lpIndex = NULL;
     175    }
     176    if (infoPtr->hic) {
     177        ICClose(infoPtr->hic);
     178        infoPtr->hic = 0;
     179    }
     180    if (infoPtr->inbih) {
     181        HeapFree(GetProcessHeap(), 0, infoPtr->inbih);
     182        infoPtr->inbih = NULL;
     183    }
     184    if (infoPtr->outbih) {
     185        HeapFree(GetProcessHeap(), 0, infoPtr->outbih);
     186        infoPtr->outbih = NULL;
     187    }
    187188        if( infoPtr->indata )
    188189        {
    189         HeapFree(GetProcessHeap(), 0, infoPtr->indata);
     190    HeapFree(GetProcessHeap(), 0, infoPtr->indata);
    190191            infoPtr->indata = NULL;
    191192        }
    192         if( infoPtr->outdata )
     193        if( infoPtr->outdata )
    193194        {
    194         HeapFree(GetProcessHeap(), 0, infoPtr->outdata);
     195    HeapFree(GetProcessHeap(), 0, infoPtr->outdata);
    195196            infoPtr->outdata = NULL;
    196197        }
    197         if( infoPtr->hbmPrevFrame )
     198        if( infoPtr->hbmPrevFrame )
    198199        {
    199             DeleteObject(infoPtr->hbmPrevFrame);
     200        DeleteObject(infoPtr->hbmPrevFrame);
    200201            infoPtr->hbmPrevFrame = 0;
    201202        }
    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;   
     203    infoPtr->indata = infoPtr->outdata = NULL;
     204    infoPtr->hWnd = 0;
     205    infoPtr->hMMio = 0;
     206
     207    memset(&infoPtr->mah, 0, sizeof(infoPtr->mah));
     208    memset(&infoPtr->ash, 0, sizeof(infoPtr->ash));
     209    infoPtr->nFromFrame = infoPtr->nToFrame = infoPtr->nLoop = infoPtr->currFrame = 0;
     210    }
     211    infoPtr->transparentColor = ANIMATE_COLOR_NONE;
    211212}
    212213
    213214static void ANIMATE_TransparentBlt(ANIMATE_INFO* infoPtr, HDC hdcDest, HDC hdcSource)
    214 {       
     215{
    215216    HDC hdcMask;
    216217    HBITMAP hbmMask;
    217     HBITMAP hbmOld;           
    218    
     218    HBITMAP hbmOld;
     219
    219220    /* create a transparency mask */
    220221    hdcMask = CreateCompatibleDC(hdcDest);
    221     hbmMask = CreateBitmap(infoPtr->inbih->biWidth, infoPtr->inbih->biHeight, 1,1,NULL);   
    222     hbmOld = SelectObject(hdcMask, hbmMask);             
     222    hbmMask = CreateBitmap(infoPtr->inbih->biWidth, infoPtr->inbih->biHeight, 1,1,NULL);
     223    hbmOld = SelectObject(hdcMask, hbmMask);
    223224
    224225    SetBkColor(hdcSource,infoPtr->transparentColor);
    225226    BitBlt(hdcMask,0,0,infoPtr->inbih->biWidth, infoPtr->inbih->biHeight,hdcSource,0,0,SRCCOPY);
    226            
     227
    227228    /* mask the source bitmap */
    228     SetBkColor(hdcSource, RGB(0,0,0));         
    229     SetTextColor(hdcSource, RGB(255,255,255)); 
     229    SetBkColor(hdcSource, RGB(0,0,0));
     230    SetTextColor(hdcSource, RGB(255,255,255));
    230231    BitBlt(hdcSource, 0, 0, infoPtr->inbih->biWidth, infoPtr->inbih->biHeight, hdcMask, 0, 0, SRCAND);
    231232
    232233    /* mask the destination bitmap */
    233     SetBkColor(hdcDest, RGB(255,255,255));   
    234     SetTextColor(hdcDest, RGB(0,0,0));         
     234    SetBkColor(hdcDest, RGB(255,255,255));
     235    SetTextColor(hdcDest, RGB(0,0,0));
    235236    BitBlt(hdcDest, 0, 0, infoPtr->inbih->biWidth, infoPtr->inbih->biHeight, hdcMask, 0, 0, SRCAND);
    236237
     
    258259
    259260    if (!hDC || !infoPtr->inbih)
    260         return TRUE;
     261    return TRUE;
    261262
    262263    if (infoPtr->hic )
     
    266267
    267268        nWidth = infoPtr->outbih->biWidth;
    268         nHeight = infoPtr->outbih->biHeight; 
     269        nHeight = infoPtr->outbih->biHeight;
    269270    } else
    270     { 
     271    {
    271272        pBitmapData = infoPtr->indata;
    272273        pBitmapInfo = (LPBITMAPINFO)infoPtr->inbih;
    273274
    274275        nWidth = infoPtr->inbih->biWidth;
    275         nHeight = infoPtr->inbih->biHeight; 
    276     } 
     276        nHeight = infoPtr->inbih->biHeight;
     277    }
    277278
    278279    if(!infoPtr->hbmPrevFrame)
     
    281282    }
    282283
    283     SetDIBits(hDC, infoPtr->hbmPrevFrame, 0, nHeight, pBitmapData, (LPBITMAPINFO)pBitmapInfo, DIB_RGB_COLORS); 
    284    
     284    SetDIBits(hDC, infoPtr->hbmPrevFrame, 0, nHeight, pBitmapData, (LPBITMAPINFO)pBitmapInfo, DIB_RGB_COLORS);
     285
    285286    hdcMem = CreateCompatibleDC(hDC);
    286287    hbmOld = SelectObject(hdcMem, infoPtr->hbmPrevFrame);
    287288
    288     /* 
    289      * we need to get the transparent color even without ACS_TRANSPARENT, 
     289    /*
     290     * we need to get the transparent color even without ACS_TRANSPARENT,
    290291     * because the style can be changed later on and the color should always
    291      * be obtained in the first frame 
     292     * be obtained in the first frame
    292293     */
    293294    if(infoPtr->transparentColor == ANIMATE_COLOR_NONE)
    294295    {
    295296        infoPtr->transparentColor = GetPixel(hdcMem,0,0);
    296     } 
    297 
    298     if(GetWindowLongA(infoPtr->hWnd, GWL_STYLE) & ACS_TRANSPARENT) 
    299     { 
     297    }
     298
     299    if(GetWindowLongA(infoPtr->hWnd, GWL_STYLE) & ACS_TRANSPARENT)
     300    {
    300301        HDC hdcFinal = CreateCompatibleDC(hDC);
    301302        HBITMAP hbmFinal = CreateCompatibleBitmap(hDC,nWidth, nHeight);
    302303        HBITMAP hbmOld2 = SelectObject(hdcFinal, hbmFinal);
    303304        RECT rect;
    304        
     305
    305306        rect.left = 0;
    306307        rect.top = 0;
    307308        rect.right = nWidth;
    308309        rect.bottom = nHeight;
    309        
     310
    310311        if(!infoPtr->hbrushBG)
    311312            infoPtr->hbrushBG = GetCurrentObject(hDC, OBJ_BRUSH);
     
    320321        infoPtr->hbmPrevFrame = hbmFinal;
    321322         }
    322    
    323     if (GetWindowLongA(infoPtr->hWnd, GWL_STYLE) & ACS_CENTER) 
    324     {
    325        RECT rect;   
     323
     324    if (GetWindowLongA(infoPtr->hWnd, GWL_STYLE) & ACS_CENTER)
     325    {
     326       RECT rect;
    326327
    327328       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);   
     329       nOffsetX = ((rect.right - rect.left) - nWidth)/2;
     330       nOffsetY = ((rect.bottom - rect.top) - nHeight)/2;
     331    }
     332    BitBlt(hDC, nOffsetX, nOffsetY, nWidth, nHeight, hdcMem, 0, 0, SRCCOPY);
    332333
    333334    SelectObject(hdcMem, hbmOld);
     
    338339static LRESULT ANIMATE_DrawFrame(ANIMATE_INFO* infoPtr)
    339340{
    340     HDC         hDC;
     341    HDC     hDC;
    341342
    342343    TRACE("Drawing frame %d (loop %d)\n", infoPtr->currFrame, infoPtr->nLoop);
     
    346347    mmioSeek(infoPtr->hMMio, infoPtr->lpIndex[infoPtr->currFrame], SEEK_SET);
    347348    mmioRead(infoPtr->hMMio, infoPtr->indata, infoPtr->ash.dwSuggestedBufferSize);
    348    
     349
    349350    if (infoPtr->hic &&
    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;
     351    ICDecompress(infoPtr->hic, 0, infoPtr->inbih, infoPtr->indata,
     352             infoPtr->outbih, infoPtr->outdata) != ICERR_OK) {
     353    LeaveCriticalSection(&infoPtr->cs);
     354    WARN("Decompression error\n");
     355    return FALSE;
    355356    }
    356357
    357358    if ((hDC = GetDC(infoPtr->hWnd)) != 0) {
    358         ANIMATE_PaintFrame(infoPtr, hDC);
    359         ReleaseDC(infoPtr->hWnd, hDC);
     359    ANIMATE_PaintFrame(infoPtr, hDC);
     360    ReleaseDC(infoPtr->hWnd, hDC);
    360361    }
    361362
    362363    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         }
     364    infoPtr->currFrame = infoPtr->nFromFrame;
     365    if (infoPtr->nLoop != -1) {
     366        if (--infoPtr->nLoop == 0) {
     367        ANIMATE_DoStop(infoPtr);
     368        }
     369    }
    369370    }
    370371    LeaveCriticalSection(&infoPtr->cs);
     
    375376static DWORD CALLBACK ANIMATE_AnimationThread(LPVOID ptr_)
    376377{
    377     ANIMATE_INFO*       infoPtr = (ANIMATE_INFO*)ptr_;
     378    ANIMATE_INFO*   infoPtr = (ANIMATE_INFO*)ptr_;
    378379    HDC hDC;
    379    
     380
    380381    if(!infoPtr)
    381382    {
     
    385386
    386387    while(1)
    387     {   
    388         if(GetWindowLongA(infoPtr->hWnd, GWL_STYLE) & ACS_TRANSPARENT) 
     388    {
     389        if(GetWindowLongA(infoPtr->hWnd, GWL_STYLE) & ACS_TRANSPARENT)
    389390        {
    390391            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 */
     392        /* sometimes the animation window will be destroyed in between
     393         * by the main program, so a ReleaseDC() error msg is possible */
    393394            infoPtr->hbrushBG = SendMessageA(GetParent(infoPtr->hWnd),WM_CTLCOLORSTATIC,hDC, infoPtr->hWnd);
    394395            ReleaseDC(infoPtr->hWnd,hDC);
    395396        }
    396        
     397
    397398        EnterCriticalSection(&infoPtr->cs);
    398399        ANIMATE_DrawFrame(infoPtr);
    399400        LeaveCriticalSection(&infoPtr->cs);
    400    
     401
    401402        /* time is in microseconds, we should convert it to milliseconds */
    402403        Sleep((infoPtr->mah.dwMicroSecPerFrame+500)/1000);
     
    411412    /* nothing opened */
    412413    if (!infoPtr->hMMio)
    413         return FALSE;
     414    return FALSE;
    414415
    415416    if (infoPtr->hThread || infoPtr->uTimer) {
    416         FIXME("Already playing ? what should I do ??\n");
    417         ANIMATE_DoStop(infoPtr);
     417    FIXME("Already playing ? what should I do ??\n");
     418    ANIMATE_DoStop(infoPtr);
    418419    }
    419420
     
    423424
    424425    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);
     426    infoPtr->nToFrame = infoPtr->mah.dwTotalFrames - 1;
     427
     428    TRACE("(repeat=%d from=%d to=%d);\n",
     429      infoPtr->nLoop, infoPtr->nFromFrame, infoPtr->nToFrame);
    429430
    430431    if (infoPtr->nFromFrame >= infoPtr->nToFrame ||
    431         infoPtr->nToFrame >= infoPtr->mah.dwTotalFrames)
    432         return FALSE;
     432    infoPtr->nToFrame >= infoPtr->mah.dwTotalFrames)
     433    return FALSE;
    433434
    434435    infoPtr->currFrame = infoPtr->nFromFrame;
    435436
    436437    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);
     438    TRACE("Using a timer\n");
     439    /* create a timer to display AVI */
     440    infoPtr->uTimer = SetTimer(hWnd, 1, infoPtr->mah.dwMicroSecPerFrame / 1000, NULL);
    440441    } else {
    441442        DWORD threadID;
    442443
    443         TRACE("Using an animation thread\n");
     444    TRACE("Using an animation thread\n");
    444445        infoPtr->hThread = CreateThread(0,0,ANIMATE_AnimationThread,(LPVOID)infoPtr,0,0 &threadID);
    445446        if(!infoPtr->hThread)
     
    448449           return FALSE;
    449450    }
    450        
    451     }
    452        
     451
     452    }
     453
    453454    ANIMATE_Notify(infoPtr, ACN_START);
    454455
     
    459460static BOOL ANIMATE_GetAviInfo(ANIMATE_INFO *infoPtr)
    460461{
    461     MMCKINFO            ckMainRIFF;
    462     MMCKINFO            mmckHead;
    463     MMCKINFO            mmckList;
    464     MMCKINFO            mmckInfo;
    465     DWORD               numFrame;
    466     DWORD               insize;
     462    MMCKINFO        ckMainRIFF;
     463    MMCKINFO        mmckHead;
     464    MMCKINFO        mmckList;
     465    MMCKINFO        mmckInfo;
     466    DWORD       numFrame;
     467    DWORD       insize;
    467468
    468469    if (mmioDescend(infoPtr->hMMio, &ckMainRIFF, NULL, 0) != 0) {
    469         WARN("Can't find 'RIFF' chunk\n");
    470         return FALSE;
     470    WARN("Can't find 'RIFF' chunk\n");
     471    return FALSE;
    471472    }
    472473
    473474    if ((ckMainRIFF.ckid != FOURCC_RIFF) ||
    474         (ckMainRIFF.fccType != mmioFOURCC('A', 'V', 'I', ' '))) {
    475         WARN("Can't find 'AVI ' chunk\n");
    476         return FALSE;
     475    (ckMainRIFF.fccType != mmioFOURCC('A', 'V', 'I', ' '))) {
     476    WARN("Can't find 'AVI ' chunk\n");
     477    return FALSE;
    477478    }
    478479
    479480    mmckHead.fccType = mmioFOURCC('h', 'd', 'r', 'l');
    480481    if (mmioDescend(infoPtr->hMMio, &mmckHead, &ckMainRIFF, MMIO_FINDLIST) != 0) {
    481         WARN("Can't find 'hdrl' list\n");
    482         return FALSE;
     482    WARN("Can't find 'hdrl' list\n");
     483    return FALSE;
    483484    }
    484485
    485486    mmckInfo.ckid = mmioFOURCC('a', 'v', 'i', 'h');
    486487    if (mmioDescend(infoPtr->hMMio, &mmckInfo, &mmckHead, MMIO_FINDCHUNK) != 0) {
    487         WARN("Can't find 'avih' chunk\n");
    488         return FALSE;
     488    WARN("Can't find 'avih' chunk\n");
     489    return FALSE;
    489490    }
    490491
    491492    mmioRead(infoPtr->hMMio, (LPSTR)&infoPtr->mah, sizeof(infoPtr->mah));
    492493
    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);
     494    TRACE("mah.dwMicroSecPerFrame=%ld\n",   infoPtr->mah.dwMicroSecPerFrame);
     495    TRACE("mah.dwMaxBytesPerSec=%ld\n",     infoPtr->mah.dwMaxBytesPerSec);
     496    TRACE("mah.dwPaddingGranularity=%ld\n",     infoPtr->mah.dwPaddingGranularity);
     497    TRACE("mah.dwFlags=%ld\n",          infoPtr->mah.dwFlags);
     498    TRACE("mah.dwTotalFrames=%ld\n",        infoPtr->mah.dwTotalFrames);
     499    TRACE("mah.dwInitialFrames=%ld\n",      infoPtr->mah.dwInitialFrames);
     500    TRACE("mah.dwStreams=%ld\n",        infoPtr->mah.dwStreams);
     501    TRACE("mah.dwSuggestedBufferSize=%ld\n",    infoPtr->mah.dwSuggestedBufferSize);
     502    TRACE("mah.dwWidth=%ld\n",          infoPtr->mah.dwWidth);
     503    TRACE("mah.dwHeight=%ld\n",         infoPtr->mah.dwHeight);
    503504
    504505    mmioAscend(infoPtr->hMMio, &mmckInfo, 0);
     
    506507    mmckList.fccType = mmioFOURCC('s', 't', 'r', 'l');
    507508    if (mmioDescend(infoPtr->hMMio, &mmckList, &mmckHead, MMIO_FINDLIST) != 0) {
    508         WARN("Can't find 'strl' list\n");
    509         return FALSE;
     509    WARN("Can't find 'strl' list\n");
     510    return FALSE;
    510511    }
    511512
    512513    mmckInfo.ckid = mmioFOURCC('s', 't', 'r', 'h');
    513514    if (mmioDescend(infoPtr->hMMio, &mmckInfo, &mmckList, MMIO_FINDCHUNK) != 0) {
    514         WARN("Can't find 'strh' chunk\n");
    515         return FALSE;
     515    WARN("Can't find 'strh' chunk\n");
     516    return FALSE;
    516517    }
    517518
    518519    mmioRead(infoPtr->hMMio, (LPSTR)&infoPtr->ash, sizeof(infoPtr->ash));
    519520
    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);
     521    TRACE("ash.fccType='%c%c%c%c'\n",       LOBYTE(LOWORD(infoPtr->ash.fccType)),
     522                                            HIBYTE(LOWORD(infoPtr->ash.fccType)),
     523                                            LOBYTE(HIWORD(infoPtr->ash.fccType)),
     524                                            HIBYTE(HIWORD(infoPtr->ash.fccType)));
     525    TRACE("ash.fccHandler='%c%c%c%c'\n",    LOBYTE(LOWORD(infoPtr->ash.fccHandler)),
     526                                            HIBYTE(LOWORD(infoPtr->ash.fccHandler)),
     527                                            LOBYTE(HIWORD(infoPtr->ash.fccHandler)),
     528                                            HIBYTE(HIWORD(infoPtr->ash.fccHandler)));
     529    TRACE("ash.dwFlags=%ld\n",          infoPtr->ash.dwFlags);
     530    TRACE("ash.wPriority=%d\n",         infoPtr->ash.wPriority);
     531    TRACE("ash.wLanguage=%d\n",         infoPtr->ash.wLanguage);
     532    TRACE("ash.dwInitialFrames=%ld\n",      infoPtr->ash.dwInitialFrames);
     533    TRACE("ash.dwScale=%ld\n",          infoPtr->ash.dwScale);
     534    TRACE("ash.dwRate=%ld\n",           infoPtr->ash.dwRate);
     535    TRACE("ash.dwStart=%ld\n",          infoPtr->ash.dwStart);
     536    TRACE("ash.dwLength=%ld\n",         infoPtr->ash.dwLength);
     537    TRACE("ash.dwSuggestedBufferSize=%ld\n",    infoPtr->ash.dwSuggestedBufferSize);
     538    TRACE("ash.dwQuality=%ld\n",        infoPtr->ash.dwQuality);
     539    TRACE("ash.dwSampleSize=%ld\n",         infoPtr->ash.dwSampleSize);
     540    TRACE("ash.rcFrame=(%d,%d,%d,%d)\n",    infoPtr->ash.rcFrame.top, infoPtr->ash.rcFrame.left,
     541      infoPtr->ash.rcFrame.bottom, infoPtr->ash.rcFrame.right);
    541542
    542543    mmioAscend(infoPtr->hMMio, &mmckInfo, 0);
     
    544545    mmckInfo.ckid = mmioFOURCC('s', 't', 'r', 'f');
    545546    if (mmioDescend(infoPtr->hMMio, &mmckInfo, &mmckList, MMIO_FINDCHUNK) != 0) {
    546         WARN("Can't find 'strh' chunk\n");
    547         return FALSE;
     547    WARN("Can't find 'strh' chunk\n");
     548    return FALSE;
    548549    }
    549550
    550551    infoPtr->inbih = HeapAlloc(GetProcessHeap(), 0, mmckInfo.cksize);
    551552    if (!infoPtr->inbih) {
    552         WARN("Can't alloc input BIH\n");
    553         return FALSE;
     553    WARN("Can't alloc input BIH\n");
     554    return FALSE;
    554555    }
    555556
    556557    mmioRead(infoPtr->hMMio, (LPSTR)infoPtr->inbih, mmckInfo.cksize);
    557558
    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);
     559    TRACE("bih.biSize=%ld\n",       infoPtr->inbih->biSize);
     560    TRACE("bih.biWidth=%ld\n",      infoPtr->inbih->biWidth);
     561    TRACE("bih.biHeight=%ld\n",     infoPtr->inbih->biHeight);
     562    TRACE("bih.biPlanes=%d\n",      infoPtr->inbih->biPlanes);
     563    TRACE("bih.biBitCount=%d\n",    infoPtr->inbih->biBitCount);
     564    TRACE("bih.biCompression=%ld\n",    infoPtr->inbih->biCompression);
     565    TRACE("bih.biSizeImage=%ld\n",  infoPtr->inbih->biSizeImage);
     566    TRACE("bih.biXPelsPerMeter=%ld\n",  infoPtr->inbih->biXPelsPerMeter);
     567    TRACE("bih.biYPelsPerMeter=%ld\n",  infoPtr->inbih->biYPelsPerMeter);
     568    TRACE("bih.biClrUsed=%ld\n",    infoPtr->inbih->biClrUsed);
     569    TRACE("bih.biClrImportant=%ld\n",   infoPtr->inbih->biClrImportant);
    569570
    570571    mmioAscend(infoPtr->hMMio, &mmckInfo, 0);
    571572
    572573    mmioAscend(infoPtr->hMMio, &mmckList, 0);
    573    
     574
    574575#if 0
    575576    /* 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 
     577     * an audio stream, so only one strl is allowed
    577578     */
    578579    mmckList.fccType = mmioFOURCC('s', 't', 'r', 'l');
    579580    if (mmioDescend(infoPtr->hMMio, &mmckList, &mmckHead, MMIO_FINDLIST) == 0) {
    580         WARN("There should be a single 'strl' list\n");
    581         return FALSE;
     581    WARN("There should be a single 'strl' list\n");
     582    return FALSE;
    582583    }
    583584#endif
     
    589590    mmckList.fccType = mmioFOURCC('m', 'o', 'v', 'i');
    590591    if (mmioDescend(infoPtr->hMMio, &mmckList, &ckMainRIFF, MMIO_FINDLIST) != 0) {
    591         WARN("Can't find 'movi' list\n");
    592         return FALSE;
     592    WARN("Can't find 'movi' list\n");
     593    return FALSE;
    593594    }
    594595
    595596    /* FIXME: should handle the 'rec ' LIST when present */
    596597
    597     infoPtr->lpIndex = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 
    598                                 infoPtr->mah.dwTotalFrames * sizeof(DWORD));
     598    infoPtr->lpIndex = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
     599                infoPtr->mah.dwTotalFrames * sizeof(DWORD));
    599600    if (!infoPtr->lpIndex) {
    600         WARN("Can't alloc index array\n");
    601         return FALSE;
     601    WARN("Can't alloc index array\n");
     602    return FALSE;
    602603    }
    603604
    604605    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);
     606    while (mmioDescend(infoPtr->hMMio, &mmckInfo, &mmckList, 0) == 0 &&
     607       numFrame < infoPtr->mah.dwTotalFrames) {
     608    infoPtr->lpIndex[numFrame] = mmckInfo.dwDataOffset;
     609    if (insize < mmckInfo.cksize)
     610        insize = mmckInfo.cksize;
     611    numFrame++;
     612    mmioAscend(infoPtr->hMMio, &mmckInfo, 0);
    612613    }
    613614    if (numFrame != infoPtr->mah.dwTotalFrames) {
    614         WARN("Found %ld frames (/%ld)\n", numFrame, infoPtr->mah.dwTotalFrames);
    615         return FALSE;
     615    WARN("Found %ld frames (/%ld)\n", numFrame, infoPtr->mah.dwTotalFrames);
     616    return FALSE;
    616617    }
    617618    if (insize > infoPtr->ash.dwSuggestedBufferSize) {
    618         WARN("insize=%ld suggestedSize=%ld\n", insize, infoPtr->ash.dwSuggestedBufferSize);
    619         infoPtr->ash.dwSuggestedBufferSize = insize;
     619    WARN("insize=%ld suggestedSize=%ld\n", insize, infoPtr->ash.dwSuggestedBufferSize);
     620    infoPtr->ash.dwSuggestedBufferSize = insize;
    620621    }
    621622
    622623    infoPtr->indata = HeapAlloc(GetProcessHeap(), 0, infoPtr->ash.dwSuggestedBufferSize);
    623624    if (!infoPtr->indata) {
    624         WARN("Can't alloc input buffer\n");
    625         return FALSE;
     625    WARN("Can't alloc input buffer\n");
     626    return FALSE;
    626627    }
    627628
     
    632633static BOOL    ANIMATE_GetAviCodec(ANIMATE_INFO *infoPtr)
    633634{
    634     DWORD       outSize;
     635    DWORD   outSize;
    635636
    636637    /* check uncompressed AVI */
     
    638639       (infoPtr->ash.fccHandler == mmioFOURCC('R', 'L', 'E', ' ')))
    639640    {
    640         infoPtr->hic = 0;             
    641         return TRUE;
     641        infoPtr->hic = 0;
     642    return TRUE;
    642643    }
    643644
     
    645646    infoPtr->hic = ICOpen(ICTYPE_VIDEO, infoPtr->ash.fccHandler, ICMODE_DECOMPRESS);
    646647    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);
     648    WARN("Can't load codec for the file\n");
     649    return FALSE;
     650    }
     651
     652    outSize = ICSendMessage(infoPtr->hic, ICM_DECOMPRESS_GET_FORMAT,
     653                (DWORD)infoPtr->inbih, 0L);
    653654
    654655    infoPtr->outbih = HeapAlloc(GetProcessHeap(), 0, outSize);
    655656    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;
     657    WARN("Can't alloc output BIH\n");
     658    return FALSE;
     659    }
     660
     661    if (ICSendMessage(infoPtr->hic, ICM_DECOMPRESS_GET_FORMAT,
     662              (DWORD)infoPtr->inbih, (DWORD)infoPtr->outbih) != ICERR_OK) {
     663    WARN("Can't get output BIH\n");
     664    return FALSE;
    664665    }
    665666
    666667    infoPtr->outdata = HeapAlloc(GetProcessHeap(), 0, infoPtr->outbih->biSizeImage);
    667668    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;
     669    WARN("Can't alloc output buffer\n");
     670    return FALSE;
     671    }
     672
     673    if (ICSendMessage(infoPtr->hic, ICM_DECOMPRESS_BEGIN,
     674              (DWORD)infoPtr->inbih, (DWORD)infoPtr->outbih) != ICERR_OK) {
     675    WARN("Can't begin decompression\n");
     676    return FALSE;
    676677    }
    677678
     
    691692
    692693    if (!lParam) {
    693         TRACE("Closing avi!\n");
    694         return TRUE;
    695     }
    696    
     694    TRACE("Closing avi!\n");
     695    return TRUE;
     696    }
     697
    697698    if (!hInstance)
    698699       hInstance = GetWindowLongA(hWnd, GWL_HINSTANCE);
     
    719720#else
    720721    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         }
     722    TRACE("(\"%s\");\n", (LPSTR)lParam);
     723
     724    if (!ANIMATE_LoadResA(infoPtr, hInstance, (LPSTR)lParam)) {
     725        TRACE("No AVI resource found!\n");
     726        if (!ANIMATE_LoadFileA(infoPtr, (LPSTR)lParam)) {
     727        WARN("No AVI file found!\n");
     728        return FALSE;
     729        }
     730    }
    730731    } 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         }
     732    TRACE("(%u);\n", (WORD)LOWORD(lParam));
     733
     734    if (!ANIMATE_LoadResA(infoPtr, hInstance,
     735                  MAKEINTRESOURCEA((INT)lParam))) {
     736        WARN("No AVI resource found!\n");
     737        return FALSE;
     738    }
    738739    }
    739740#endif
    740741    if (!ANIMATE_GetAviInfo(infoPtr)) {
    741         WARN("Can't get AVI information\n");
    742         ANIMATE_Free(infoPtr);
    743         return FALSE;
     742    WARN("Can't get AVI information\n");
     743    ANIMATE_Free(infoPtr);
     744    return FALSE;
    744745    }
    745746
    746747    if (!ANIMATE_GetAviCodec(infoPtr)) {
    747         WARN("Can't get AVI Codec\n");
    748         ANIMATE_Free(infoPtr);
    749         return FALSE;
     748    WARN("Can't get AVI Codec\n");
     749    ANIMATE_Free(infoPtr);
     750    return FALSE;
    750751    }
    751752
    752753    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);
     754    SetWindowPos(hWnd, 0, 0, 0, infoPtr->mah.dwWidth, infoPtr->mah.dwHeight,
     755             SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER);
    755756    }
    756757
    757758    if (GetWindowLongA(hWnd, GWL_STYLE) & ACS_AUTOPLAY) {
    758         return ANIMATE_Play(hWnd, -1, (LPARAM)MAKELONG(0, infoPtr->mah.dwTotalFrames-1));
     759    return ANIMATE_Play(hWnd, -1, (LPARAM)MAKELONG(0, infoPtr->mah.dwTotalFrames-1));
    759760    }
    760761
     
    771772    /* nothing opened */
    772773    if (!infoPtr->hMMio)
    773         return FALSE;
     774    return FALSE;
    774775
    775776    ANIMATE_DoStop(infoPtr);
     
    780781static LRESULT ANIMATE_Create(HWND hWnd, WPARAM wParam, LPARAM lParam)
    781782{
    782     ANIMATE_INFO*       infoPtr;
     783    ANIMATE_INFO*   infoPtr;
    783784
    784785    /* allocate memory for info structure */
     
    789790#endif
    790791    if (!infoPtr) {
    791         ERR("could not allocate info memory!\n");
    792         return 0;
     792    ERR("could not allocate info memory!\n");
     793    return 0;
    793794    }
    794795
     
    802803
    803804    InitializeCriticalSection(&infoPtr->cs);
    804    
     805
    805806    return 0;
    806807}
     
    826827{
    827828    RECT rect;
    828     HBRUSH hBrush = 0;       
    829 
    830     if(GetWindowLongA(hWnd, GWL_STYLE) & ACS_TRANSPARENT) 
    831     {
    832         hBrush = SendMessageA(GetParent(hWnd),WM_CTLCOLORSTATIC,(HDC)wParam, hWnd);   
     829    HBRUSH hBrush = 0;
     830
     831    if(GetWindowLongA(hWnd, GWL_STYLE) & ACS_TRANSPARENT)
     832    {
     833        hBrush = SendMessageA(GetParent(hWnd),WM_CTLCOLORSTATIC,(HDC)wParam, hWnd);
    833834    }
    834835
     
    842843{
    843844    if (GetWindowLongA(hWnd, GWL_STYLE) & ACS_CENTER) {
    844         InvalidateRect(hWnd, NULL, TRUE);
     845    InvalidateRect(hWnd, NULL, TRUE);
    845846    }
    846847    return TRUE;
     
    851852    TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n", hWnd, uMsg, wParam, lParam);
    852853    if (!ANIMATE_GetInfoPtr(hWnd) && (uMsg != WM_NCCREATE))
    853         return DefWindowProcA(hWnd, uMsg, wParam, lParam);
     854    return DefWindowProcA(hWnd, uMsg, wParam, lParam);
    854855    switch (uMsg)
    855856    {
     
    862863#else
    863864    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        
     865    return ANIMATE_OpenA(hWnd, wParam, lParam);
     866
     867    /*  case ACM_OPEN32W: FIXME!! */
     868    /*      return ANIMATE_Open32W(hWnd, wParam, lParam); */
     869#endif
     870
    870871    case ACM_PLAY:
    871         return ANIMATE_Play(hWnd, wParam, lParam);
    872        
     872    return ANIMATE_Play(hWnd, wParam, lParam);
     873
    873874    case ACM_STOP:
    874         return ANIMATE_Stop(hWnd, wParam, lParam);
    875        
     875    return ANIMATE_Stop(hWnd, wParam, lParam);
     876
    876877    case WM_NCCREATE:
    877         ANIMATE_Create(hWnd, wParam, lParam);
    878         return DefWindowProcA(hWnd, uMsg, wParam, lParam);
    879        
     878    ANIMATE_Create(hWnd, wParam, lParam);
     879    return DefWindowProcA(hWnd, uMsg, wParam, lParam);
     880
    880881    case WM_NCHITTEST:
    881         return HTTRANSPARENT;
     882    return HTTRANSPARENT;
    882883
    883884    case WM_DESTROY:
    884         ANIMATE_Destroy(hWnd, wParam, lParam);
    885         return DefWindowProcA(hWnd, uMsg, wParam, lParam);
    886        
     885    ANIMATE_Destroy(hWnd, wParam, lParam);
     886    return DefWindowProcA(hWnd, uMsg, wParam, lParam);
     887
    887888    case WM_ERASEBKGND:
    888         ANIMATE_EraseBackground(hWnd, wParam, lParam);
    889         break;
    890 
    891     /*  case WM_STYLECHANGED: FIXME shall we do something ?? */
     889    ANIMATE_EraseBackground(hWnd, wParam, lParam);
     890    break;
     891
     892    /*  case WM_STYLECHANGED: FIXME shall we do something ?? */
    892893
    893894    case WM_TIMER:
    894         if (GetWindowLongA(hWnd, GWL_STYLE) & ACS_TRANSPARENT)
     895        if (GetWindowLongA(hWnd, GWL_STYLE) & ACS_TRANSPARENT)
    895896        {
    896897            ANIMATE_INFO* infoPtr = ANIMATE_GetInfoPtr(hWnd);
    897898            infoPtr->hbrushBG = SendMessageA(GetParent(hWnd),WM_CTLCOLORSTATIC,(HDC)wParam, hWnd);
    898899        }
    899         return ANIMATE_DrawFrame(ANIMATE_GetInfoPtr(hWnd));
    900        
     900    return ANIMATE_DrawFrame(ANIMATE_GetInfoPtr(hWnd));
     901
    901902    case WM_CLOSE:
    902         ANIMATE_Free(ANIMATE_GetInfoPtr(hWnd));
    903         return TRUE;
     903    ANIMATE_Free(ANIMATE_GetInfoPtr(hWnd));
     904    return TRUE;
    904905
    905906    case WM_PAINT:
    906907        {
    907908            ANIMATE_INFO* infoPtr = ANIMATE_GetInfoPtr(hWnd);
    908                
     909
    909910            /* 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            
     911        if(!infoPtr->uTimer && !infoPtr->hThread)
     912        /* default paint handling */
     913            return DefWindowProcA(hWnd, uMsg, wParam, lParam);
     914
    914915            if (GetWindowLongA(hWnd, GWL_STYLE) & ACS_TRANSPARENT)
    915916                infoPtr->hbrushBG = SendMessageA(GetParent(hWnd), WM_CTLCOLORSTATIC,
    916                                                  (HDC)wParam, hWnd);
    917    
     917                                         (HDC)wParam, hWnd);
     918
    918919            if (wParam)
    919920            {
     
    924925            else
    925926            {
    926                 PAINTSTRUCT ps;
    927                 HDC hDC = BeginPaint(hWnd, &ps);
     927            PAINTSTRUCT ps;
     928            HDC hDC = BeginPaint(hWnd, &ps);
    928929
    929930                EnterCriticalSection(&infoPtr->cs);
    930931                ANIMATE_PaintFrame(infoPtr, hDC);
    931932                LeaveCriticalSection(&infoPtr->cs);
    932    
    933                 EndPaint(hWnd, &ps);
    934             }
    935         }
    936         break;
     933
     934            EndPaint(hWnd, &ps);
     935        }
     936        }
     937    break;
    937938
    938939    case WM_SIZE:
    939         ANIMATE_Size(hWnd, wParam, lParam);
    940         return DefWindowProcA(hWnd, uMsg, wParam, lParam);
     940    ANIMATE_Size(hWnd, wParam, lParam);
     941    return DefWindowProcA(hWnd, uMsg, wParam, lParam);
    941942
    942943    default:
    943         if (uMsg >= WM_USER)
    944             ERR("unknown msg %04x wp=%08x lp=%08lx\n", uMsg, wParam, lParam);
    945        
     944    if (uMsg >= WM_USER)
     945        ERR("unknown msg %04x wp=%08x lp=%08lx\n", uMsg, wParam, lParam);
     946
    946947#ifdef __WIN32OS2__
    947948        return defComCtl32ProcA (hWnd, uMsg, wParam, lParam);
    948949#else
    949         return DefWindowProcA(hWnd, uMsg, wParam, lParam);
     950    return DefWindowProcA(hWnd, uMsg, wParam, lParam);
    950951#endif
    951952    }
     
    966967    wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
    967968    wndClass.lpszClassName = ANIMATE_CLASSA;
    968  
     969
    969970    RegisterClassA(&wndClass);
    970971}
  • trunk/src/comctl32/comboex.c

    r6380 r6644  
     1/* $Id: comboex.c,v 1.12 2001-09-05 12:04:56 bird Exp $ */
    12/*
    23 * TODO   <-------------
     
    45 *     result in a FIXME:
    56 *           CBES_EX_NOEDITIMAGEINDENT
    6  *           CBES_EX_PATHWORDBREAKPROC
    7  *           CBES_EX_NOSIZELIMIT
    8  *           CBES_EX_CASESENSITIVE
     7 *       CBES_EX_PATHWORDBREAKPROC
     8 *       CBES_EX_NOSIZELIMIT
     9 *       CBES_EX_CASESENSITIVE
    910 *  2. None of the following callback items are implemented. Therefor
    1011 *     no CBEN_GETDISPINFO notifies are issued. Use in either CBEM_INSERTITEM
     
    3738 *      generate message sequence similar to native DLL.
    3839 *   2. Handle case where CBEM_SETITEM is called to display data in EDIT
    39  *      Control. 
     40 *      Control.
    4041 *   3. Add override for WNDPROC for the EDIT control (reqed for VK_RETURN).
    4142 *   4. Dump input data for things using COMBOBOXEXITEM{A|W}.
     
    5556 *   3. Lock image selected status to focus state of edit control if
    5657 *      edit control exists. Mimics native actions.
    57  *   4. Implemented WM_SETFOCUS in EditWndProc to track status of 
     58 *   4. Implemented WM_SETFOCUS in EditWndProc to track status of
    5859 *      focus for 3 above.
    5960 *   5. The LBN_SELCHANGE is just for documentation purposes.
     
    7071 *
    7172 *  mod 6
    72  *   1. Add support for WM_NOTIFYFORMAT (both incoming and outgoing) and do 
     73 *   1. Add support for WM_NOTIFYFORMAT (both incoming and outgoing) and do
    7374 *      WM_NOTIFY correctly based on results.
    7475 *   2. Fix memory leaks of text strings in COMBOEX_WM_DELETEITEM.
    7576 *   3. Add routines to handle special cases of NMCBEENDEDIT and NMCOMBOXEX
    76  *      so translation to ANSI is done correctly. 
     77 *      so translation to ANSI is done correctly.
    7778 *   4. Fix some issues with COMBOEX_DrawItem.
    7879 *
     
    150151/*
    151152 * 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 
     153 * the ComboEx version of the Combo Window Proc so that when the
     154 * WM_DRAWITEM message is then passed to ComboEx, we know that this
    154155 * particular WM_DRAWITEM message is for listbox only items. Any messasges
    155156 * without this flag is then for the Edit control field.
    156157 *
    157  * We really cannot use the ODS_COMBOBOXEDIT flag because MSDN states that 
     158 * We really cannot use the ODS_COMBOBOXEDIT flag because MSDN states that
    158159 * only version 4.0 applications will have ODS_COMBOBOXEDIT set.
    159160 */
     
    189190    if (TRACE_ON(comboex)){
    190191      TRACE("item %p - mask=%08x, pszText=%p, cchTM=%d, iImage=%d\n",
    191             item, item->mask, item->pszText, item->cchTextMax,
    192             item->iImage);
     192        item, item->mask, item->pszText, item->cchTextMax,
     193        item->iImage);
    193194      TRACE("item %p - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n",
    194             item, item->iSelectedImage, item->iOverlay, item->iIndent, item->lParam);
     195        item, item->iSelectedImage, item->iOverlay, item->iIndent, item->lParam);
    195196      if ((item->mask & CBEIF_TEXT) && item->pszText)
    196           TRACE("item %p - pszText=%s\n",
    197                 item, debugstr_w((const WCHAR *)item->pszText));
     197      TRACE("item %p - pszText=%s\n",
     198        item, debugstr_w((const WCHAR *)item->pszText));
    198199    }
    199200}
     
    205206    if (TRACE_ON(comboex)){
    206207      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);
     208        input->mask, input->iItem, input->pszText, input->cchTextMax,
     209        input->iImage);
    209210      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));
     211      if (true_for_w)
     212          TRACE("input - pszText=<%s>\n",
     213            debugstr_w((const WCHAR *)input->pszText));
     214      else
     215          TRACE("input - pszText=<%s>\n",
     216            debugstr_a((const char *)input->pszText));
    216217      }
    217218      TRACE("input - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n",
    218             input->iSelectedImage, input->iOverlay, input->iIndent, input->lParam);
     219        input->iSelectedImage, input->iOverlay, input->iIndent, input->lParam);
    219220    }
    220221}
     
    226227    COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    227228
    228     if (infoPtr->hwndCombo)   
    229         return SendMessageA (infoPtr->hwndCombo, uMsg, wParam, lParam);
     229    if (infoPtr->hwndCombo)
     230    return SendMessageA (infoPtr->hwndCombo, uMsg, wParam, lParam);
    230231
    231232    return 0;
     
    241242    hdr->code = code;
    242243    if (infoPtr->NtfUnicode)
    243         return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
    244                              (LPARAM)hdr);
     244    return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
     245                 (LPARAM)hdr);
    245246    else
    246         return SendMessageA (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
    247                              (LPARAM)hdr);
     247    return SendMessageA (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
     248                 (LPARAM)hdr);
    248249}
    249250
     
    259260    hdr->hdr.code = code;
    260261    if (infoPtr->NtfUnicode)
    261         return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
    262                              (LPARAM)hdr);
     262    return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
     263                 (LPARAM)hdr);
    263264    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;
     265    LPWSTR str, ostr = NULL;
     266    INT ret, len = 0;
     267
     268    if (hdr->ceItem.mask & CBEIF_TEXT) {
     269        ostr = hdr->ceItem.pszText;
     270        str = ostr;
     271        if (!str) str = (LPWSTR)L"";
     272        len = WideCharToMultiByte (CP_ACP, 0, str, -1, 0, 0, NULL, NULL);
     273        if (len > 0) {
     274        hdr->ceItem.pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(CHAR));
     275        WideCharToMultiByte (CP_ACP, 0, str, -1, (LPSTR)hdr->ceItem.pszText,
     276                     len, NULL, NULL);
     277        }
     278    }
     279
     280    ret = SendMessageA (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
     281                (LPARAM)hdr);
     282    if (hdr->ceItem.mask & CBEIF_TEXT) {
     283        if (len > 0)
     284        COMCTL32_Free (hdr->ceItem.pszText);
     285        hdr->ceItem.pszText = ostr;
     286    }
     287    return ret;
    287288    }
    288289}
     
    299300    hdr->hdr.code = (infoPtr->NtfUnicode) ? CBEN_ENDEDITW : CBEN_ENDEDITA;
    300301    if (infoPtr->NtfUnicode)
    301         return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
    302                              (LPARAM)hdr);
     302    return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
     303                 (LPARAM)hdr);
    303304    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);
     305    NMCBEENDEDITA ansi;
     306
     307    memcpy (&ansi.hdr, &hdr->hdr, sizeof(NMHDR));
     308    ansi.fChanged = hdr->fChanged;
     309    ansi.iNewSelection = hdr->iNewSelection;
     310    WideCharToMultiByte (CP_ACP, 0, itemText, -1,
     311                 (LPSTR)&ansi.szText, CBEMAXSTRLEN, NULL, NULL);
     312    ansi.iWhy = hdr->iWhy;
     313    return SendMessageA (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0,
     314                 (LPARAM)&ansi);
    314315    }
    315316}
     
    340341    }
    341342    if (cit->mask & CBEIF_IMAGE)
    342         cit->iImage         = item->iImage;
     343    cit->iImage         = item->iImage;
    343344    if (cit->mask & CBEIF_SELECTEDIMAGE)
    344         cit->iSelectedImage = item->iSelectedImage;
     345    cit->iSelectedImage = item->iSelectedImage;
    345346    if (cit->mask & CBEIF_OVERLAY)
    346         cit->iOverlay       = item->iOverlay;
     347    cit->iOverlay       = item->iOverlay;
    347348    if (cit->mask & CBEIF_INDENT)
    348         cit->iIndent        = item->iIndent;
     349    cit->iIndent        = item->iIndent;
    349350    if (cit->mask & CBEIF_LPARAM)
    350         cit->lParam         = item->lParam;
     351    cit->lParam         = item->lParam;
    351352
    352353}
     
    364365    iinfo.rcImage.left = iinfo.rcImage.right = 0;
    365366    if (infoPtr->himl) {
    366         ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo);
    367         xoff = iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP;
     367    ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo);
     368    xoff = iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP;
    368369    }
    369370    GetClientRect (infoPtr->hwndCombo, &rect);
     
    380381
    381382    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);
     383      rect.left, rect.top, rect.right, rect.bottom,
     384      x, y, x + w, y + h);
    384385    SetWindowPos(infoPtr->hwndEdit, HWND_TOP,
    385                 x, y,
    386                 w, h,
    387                 SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER);
     386        x, y,
     387        w, h,
     388        SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER);
    388389}
    389390
     
    399400    cy = mysize.cy + CBE_EXTRA;
    400401    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);
     402    ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo);
     403    cy = max (iinfo.rcImage.bottom - iinfo.rcImage.top, cy);
     404    TRACE("upgraded height due to image:  height=%d\n", cy);
    404405    }
    405406    SendMessageW (hwnd, CB_SETITEMHEIGHT, (WPARAM) -1, (LPARAM) cy);
    406407    if (infoPtr->hwndCombo)
    407408        SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT,
    408                       (WPARAM) 0, (LPARAM) cy);
     409              (WPARAM) 0, (LPARAM) cy);
    409410}
    410411
     
    419420    /*      EM_SETSEL32 (0,-1)      */
    420421    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  
     422    SendMessageW (infoPtr->hwndEdit, WM_SETTEXT, 0, (LPARAM)item->pszText);
     423    SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, 0);
     424    SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, -1);
     425    }
     426}
     427
     428
    428429static CBE_ITEMDATA *
    429430COMBOEX_FindItem(COMBOEX_INFO *infoPtr, INT index)
     
    433434
    434435    if ((index > infoPtr->nb_items) || (index < -1))
    435         return 0;
     436    return 0;
    436437    if (index == -1)
    437         return infoPtr->edit;
     438    return infoPtr->edit;
    438439    item = infoPtr->items;
    439440    i = infoPtr->nb_items - 1;
     
    441442    /* find the item in the list */
    442443    while (item && (i > index)) {
    443         item = (CBE_ITEMDATA *)item->next;
    444         i--;
     444    item = (CBE_ITEMDATA *)item->next;
     445    i--;
    445446    }
    446447    if (!item || (i != index)) {
    447         FIXME("COMBOBOXEX item structures broken. Please report!\n");
    448         return 0;
     448    FIXME("COMBOBOXEX item structures broken. Please report!\n");
     449    return 0;
    449450    }
    450451    return item;
     
    456457{
    457458    if (item->pszText == LPSTR_TEXTCALLBACKW)
    458         FIXME("Callback not implemented yet for pszText\n");
     459    FIXME("Callback not implemented yet for pszText\n");
    459460    if (item->iImage == I_IMAGECALLBACK)
    460         FIXME("Callback not implemented yet for iImage\n");
     461    FIXME("Callback not implemented yet for iImage\n");
    461462    if (item->iSelectedImage == I_IMAGECALLBACK)
    462         FIXME("Callback not implemented yet for iSelectedImage\n");
     463    FIXME("Callback not implemented yet for iSelectedImage\n");
    463464    if (item->iOverlay == I_IMAGECALLBACK)
    464         FIXME("Callback not implemented yet for iOverlay\n");
     465    FIXME("Callback not implemented yet for iOverlay\n");
    465466    if (item->iIndent == I_INDENTCALLBACK)
    466         FIXME("Callback not implemented yet for iIndent\n");
     467    FIXME("Callback not implemented yet for iIndent\n");
    467468}
    468469
     
    482483    /* if item number requested does not exist then return failure */
    483484    if ((index > infoPtr->nb_items) || (index < 0)) {
    484         ERR("attempt to delete item that does not exist\n");
    485         return CB_ERR;
     485    ERR("attempt to delete item that does not exist\n");
     486    return CB_ERR;
    486487    }
    487488
    488489    if (!(item = COMBOEX_FindItem(infoPtr, index))) {
    489         ERR("attempt to delete item that was not found!\n");
    490         return CB_ERR;
     490    ERR("attempt to delete item that was not found!\n");
     491    return CB_ERR;
    491492    }
    492493
     
    515516
    516517    if ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN)
    517         return 0;
     518    return 0;
    518519
    519520    TRACE("-- 0x%x\n", infoPtr->hwndEdit);
     
    560561    /* if item number requested does not exist then return failure */
    561562    if ((index > infoPtr->nb_items) || (index < -1)) {
    562         ERR("attempt to get item that does not exist\n");
    563         return 0;
     563    ERR("attempt to get item that does not exist\n");
     564    return 0;
    564565    }
    565566
    566567    /* if the item is the edit control and there is no edit control, skip */
    567     if ((index == -1) && 
     568    if ((index == -1) &&
    568569        ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN))
    569             return 0;
     570        return 0;
    570571
    571572    if (!(item = COMBOEX_FindItem(infoPtr, index))) {
    572         ERR("attempt to get item that was not found!\n");
    573         return 0;
     573    ERR("attempt to get item that was not found!\n");
     574    return 0;
    574575    }
    575576
     
    594595
    595596    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);
     597    if (len > 0)
     598    WideCharToMultiByte (CP_ACP, 0, tmpcit.pszText, -1,
     599                 cit->pszText, cit->cchTextMax, NULL, NULL);
    599600
    600601    cit->iImage = tmpcit.iImage;
     
    613614    COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd);
    614615
    615     TRACE("%s hwnd=0x%x\n", 
    616            infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
     616    TRACE("%s hwnd=0x%x\n",
     617       infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
    617618
    618619    return infoPtr->bUnicode;
     
    626627
    627628    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;
     629    return FALSE;
     630    if ((infoPtr->flags & (WCBE_ACTEDIT | WCBE_EDITCHG)) ==
     631    (WCBE_ACTEDIT | WCBE_EDITCHG))
     632    return TRUE;
    632633    return FALSE;
    633634}
     
    661662        /* fast path for iItem = -1 */
    662663        item->next = infoPtr->items;
    663         infoPtr->items = item;
     664    infoPtr->items = item;
    664665    }
    665666    else {
    666667        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;
     668    CBE_ITEMDATA *moving = infoPtr->items;
     669
     670    while ((i > index) && moving) {
     671        moving = (CBE_ITEMDATA *)moving->next;
     672        i--;
     673    }
     674    if (!moving) {
     675        FIXME("COMBOBOXEX item structures broken. Please report!\n");
     676        COMCTL32_Free(item);
     677        return -1;
     678    }
     679    item->next = moving->next;
     680    moving->next = item;
    680681    }
    681682
     
    684685    if (item->mask & CBEIF_TEXT) {
    685686        LPWSTR str;
    686         INT len;
     687    INT len;
    687688
    688689        str = cit->pszText;
    689690        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;
     691    len = strlenW (str);
     692    if (len > 0) {
     693        item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     694        strcpyW (item->pszText, str);
     695    }
     696    else
     697        item->pszText = NULL;
    697698        item->cchTextMax   = cit->cchTextMax;
    698699    }
     
    713714    COMBOEX_DumpItem (item);
    714715
    715     SendMessageW (infoPtr->hwndCombo, CB_INSERTSTRING, 
    716                   (WPARAM)cit->iItem, (LPARAM)item);
     716    SendMessageW (infoPtr->hwndCombo, CB_INSERTSTRING,
     717          (WPARAM)cit->iItem, (LPARAM)item);
    717718
    718719    COMBOEX_CopyItem (infoPtr, item, &nmcit.ceItem);
     
    727728COMBOEX_InsertItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    728729{
    729     COMBOBOXEXITEMA     *cit = (COMBOBOXEXITEMA *) lParam;
    730     COMBOBOXEXITEMW     citW;
    731     LRESULT             ret;
     730    COMBOBOXEXITEMA *cit = (COMBOBOXEXITEMA *) lParam;
     731    COMBOBOXEXITEMW citW;
     732    LRESULT     ret;
    732733
    733734    memcpy(&citW,cit,sizeof(COMBOBOXEXITEMA));
    734735    if (cit->mask & CBEIF_TEXT) {
    735736        LPSTR str;
    736         INT len;
     737    INT len;
    737738
    738739        str = cit->pszText;
    739740        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         }
     741    len = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
     742    if (len > 0) {
     743        citW.pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     744        MultiByteToWideChar (CP_ACP, 0, str, -1, citW.pszText, len);
     745    }
    745746    }
    746747    ret = COMBOEX_InsertItemW(hwnd,wParam,(LPARAM)&citW);;
    747748
    748749    if (cit->mask & CBEIF_TEXT)
    749         COMCTL32_Free(citW.pszText);
     750    COMCTL32_Free(citW.pszText);
    750751    return ret;
    751752}
     
    763764
    764765    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);
     766          CBES_EX_PATHWORDBREAKPROC |
     767          CBES_EX_NOSIZELIMIT |
     768          CBES_EX_CASESENSITIVE))
     769    FIXME("Extended style not implemented %08lx\n", lParam);
    769770
    770771    if ((DWORD)wParam) {
    771         infoPtr->dwExtStyle = (infoPtr->dwExtStyle & ~(DWORD)wParam) | (DWORD)lParam;
     772    infoPtr->dwExtStyle = (infoPtr->dwExtStyle & ~(DWORD)wParam) | (DWORD)lParam;
    772773    }
    773774    else
    774         infoPtr->dwExtStyle = (DWORD)lParam;
     775    infoPtr->dwExtStyle = (DWORD)lParam;
    775776
    776777    /*
     
    778779     */
    779780    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);
     781    (dwTemp & CBES_EX_NOEDITIMAGE)) {
     782    /* if state of EX_NOEDITIMAGE changes, invalidate all */
     783    TRACE("EX_NOEDITIMAGE state changed to %ld\n",
     784        infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE);
     785    InvalidateRect (hwnd, NULL, TRUE);
     786    COMBOEX_AdjustEditPos (infoPtr);
     787    if (infoPtr->hwndEdit)
     788        InvalidateRect (infoPtr->hwndEdit, NULL, TRUE);
    788789    }
    789790
     
    826827    /* if item number requested does not exist then return failure */
    827828    if ((index > infoPtr->nb_items) || (index < -1)) {
    828         ERR("attempt to set item that does not exist yet!\n");
    829         return 0;
     829    ERR("attempt to set item that does not exist yet!\n");
     830    return 0;
    830831    }
    831832
    832833    /* if the item is the edit control and there is no edit control, skip */
    833     if ((index == -1) && 
     834    if ((index == -1) &&
    834835        ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN))
    835             return 0;
     836        return 0;
    836837
    837838    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 */ 
     839    ERR("attempt to set item that was not found!\n");
     840    return 0;
     841    }
     842
     843    /* add/change stuff to the internal item structure */
    843844    item->mask |= cit->mask;
    844845    if (cit->mask & CBEIF_TEXT) {
    845846        LPWSTR str;
    846         INT len;
    847         WCHAR emptystr[1] = {0};
     847    INT len;
     848    WCHAR emptystr[1] = {0};
    848849
    849850        str = cit->pszText;
    850851        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         }
     852    len = strlenW(str);
     853    if (len > 0) {
     854        item->pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     855        strcpyW(item->pszText,str);
     856    }
    856857        item->cchTextMax   = cit->cchTextMax;
    857858    }
     
    873874    /* if original request was to update edit control, do some fast foot work */
    874875    if (cit->iItem == -1) {
    875         COMBOEX_SetEditText (infoPtr, item);
    876         RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE | RDW_INVALIDATE);
     876    COMBOEX_SetEditText (infoPtr, item);
     877    RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE | RDW_INVALIDATE);
    877878    }
    878879    return TRUE;
     
    882883COMBOEX_SetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    883884{
    884     COMBOBOXEXITEMA     *cit = (COMBOBOXEXITEMA *) lParam;
    885     COMBOBOXEXITEMW     citW;
    886     LRESULT             ret;
     885    COMBOBOXEXITEMA *cit = (COMBOBOXEXITEMA *) lParam;
     886    COMBOBOXEXITEMW citW;
     887    LRESULT     ret;
    887888
    888889    memcpy(&citW,cit,sizeof(COMBOBOXEXITEMA));
    889890    if (cit->mask & CBEIF_TEXT) {
    890891        LPSTR str;
    891         INT len;
     892    INT len;
    892893
    893894        str = cit->pszText;
    894895        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         }
     896    len = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
     897    if (len > 0) {
     898        citW.pszText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     899        MultiByteToWideChar (CP_ACP, 0, str, -1, citW.pszText, len);
     900    }
    900901    }
    901902    ret = COMBOEX_SetItemW(hwnd,wParam,(LPARAM)&citW);;
    902903
    903904    if (cit->mask & CBEIF_TEXT)
    904         COMCTL32_Free(citW.pszText);
     905    COMCTL32_Free(citW.pszText);
    905906    return ret;
    906907}
     
    913914    BOOL bTemp = infoPtr->bUnicode;
    914915
    915     TRACE("to %s hwnd=0x%04x, was %s\n", 
    916           ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd,
    917           (bTemp) ? "TRUE" : "FALSE");
     916    TRACE("to %s hwnd=0x%04x, was %s\n",
     917      ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd,
     918      (bTemp) ? "TRUE" : "FALSE");
    918919
    919920    infoPtr->bUnicode = (BOOL)wParam;
     
    937938    i = MultiByteToWideChar (CP_ACP, 0, (LPSTR)lParam, -1, NULL, 0);
    938939    if (i > 0) {
    939         desired = (LPWSTR)COMCTL32_Alloc ((i + 1)*sizeof(WCHAR));
    940         MultiByteToWideChar (CP_ACP, 0, (LPSTR)lParam, -1, desired, i);
     940    desired = (LPWSTR)COMCTL32_Alloc ((i + 1)*sizeof(WCHAR));
     941    MultiByteToWideChar (CP_ACP, 0, (LPSTR)lParam, -1, desired, i);
    941942    }
    942943
     
    945946    /* now search from after starting loc and wrapping back to start */
    946947    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         }
     948    item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
     949              CB_GETITEMDATA, (WPARAM)i, 0);
     950    TRACE("desired=%s, item=%s\n",
     951          debugstr_w(desired), debugstr_w(item->pszText));
     952    if (lstrcmpiW(item->pszText, desired) == 0) {
     953        COMCTL32_Free (desired);
     954        return i;
     955    }
    955956    }
    956957    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         }
     958    item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
     959              CB_GETITEMDATA, (WPARAM)i, 0);
     960    TRACE("desired=%s, item=%s\n",
     961          debugstr_w(desired), debugstr_w(item->pszText));
     962    if (lstrcmpiW(item->pszText, desired) == 0) {
     963        COMCTL32_Free (desired);
     964        return i;
     965    }
    965966    }
    966967    COMCTL32_Free(desired);
     
    977978    LRESULT lret = 0;
    978979
    979     item1 = (CBE_ITEMDATA *)COMBOEX_Forward (hwnd, CB_GETITEMDATA, 
    980                                              wParam, lParam);
     980    item1 = (CBE_ITEMDATA *)COMBOEX_Forward (hwnd, CB_GETITEMDATA,
     981                         wParam, lParam);
    981982    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;
     983    item2 = COMBOEX_FindItem (infoPtr, index);
     984    if (item2 != item1) {
     985        ERR("data structures damaged!\n");
     986        return CB_ERR;
     987    }
     988    if (item1->mask & CBEIF_LPARAM)
     989        lret = (LRESULT) item1->lParam;
     990    TRACE("returning 0x%08lx\n", lret);
     991    return lret;
    991992    }
    992993    lret = (LRESULT)item1;
     
    10051006
    10061007    if (!(item = COMBOEX_FindItem(infoPtr, index))) {
    1007         /* FIXME: need to clear selection */
    1008         return CB_ERR;
     1008    /* FIXME: need to clear selection */
     1009    return CB_ERR;
    10091010    }
    10101011
    10111012    TRACE("selecting item %d text=%s\n", index, (item->pszText) ?
    1012           debugstr_w(item->pszText) : "<null>");
     1013      debugstr_w(item->pszText) : "<null>");
    10131014    infoPtr->selected = index;
    10141015
     
    10261027    CBE_ITEMDATA *item1, *item2;
    10271028
    1028     item1 = (CBE_ITEMDATA *)COMBOEX_Forward (hwnd, CB_GETITEMDATA, 
    1029                                              wParam, lParam);
     1029    item1 = (CBE_ITEMDATA *)COMBOEX_Forward (hwnd, CB_GETITEMDATA,
     1030                         wParam, lParam);
    10301031    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;
     1032    item2 = COMBOEX_FindItem (infoPtr, index);
     1033    if (item2 != item1) {
     1034        ERR("data structures damaged!\n");
     1035        return CB_ERR;
     1036    }
     1037    item1->mask |= CBEIF_LPARAM;
     1038    item1->lParam = lParam;
     1039    TRACE("setting lparam to 0x%08lx\n", lParam);
     1040    return 0;
    10401041    }
    10411042    TRACE("non-valid result from combo 0x%08lx\n", (DWORD)item1);
     
    10541055    /* First, lets forward the message to the normal combo control
    10551056       just like Windows.     */
    1056     if (infoPtr->hwndCombo)   
     1057    if (infoPtr->hwndCombo)
    10571058       SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT, wParam, lParam);
    10581059
     
    10601061    GetWindowRect (hwnd, &cbx_wrect);
    10611062    GetClientRect (hwnd, &cbx_crect);
    1062     /* the height of comboex as height of the combo + comboex border */ 
     1063    /* the height of comboex as height of the combo + comboex border */
    10631064    height = cb_wrect.bottom-cb_wrect.top
    10641065             + cbx_wrect.bottom-cbx_wrect.top
    10651066             - (cbx_crect.bottom-cbx_crect.top);
    10661067    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);
     1068      cbx_wrect.left, cbx_wrect.top, cbx_wrect.right, cbx_wrect.bottom,
     1069      cbx_crect.left, cbx_crect.top, cbx_crect.right, cbx_crect.bottom);
    10691070    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);
     1071      cb_wrect.left, cb_wrect.top, cb_wrect.right, cb_wrect.bottom,
     1072      cbx_wrect.right-cbx_wrect.left, height);
    10721073    SetWindowPos (hwnd, HWND_TOP, 0, 0,
    1073                   cbx_wrect.right-cbx_wrect.left,
    1074                   height,
    1075                   SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE);
     1074          cbx_wrect.right-cbx_wrect.left,
     1075          height,
     1076          SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE);
    10761077
    10771078    return ret;
     
    11011102#endif
    11021103    if (infoPtr == NULL) {
    1103         ERR("could not allocate info memory!\n");
    1104         return 0;
     1104    ERR("could not allocate info memory!\n");
     1105    return 0;
    11051106    }
    11061107
     
    11151116
    11161117    i = SendMessageA(GetParent (hwnd),
    1117                      WM_NOTIFYFORMAT, hwnd, NF_QUERY);
     1118             WM_NOTIFYFORMAT, hwnd, NF_QUERY);
    11181119    if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
    1119         ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
    1120             i);
    1121         i = NFR_ANSI;
     1120    ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
     1121        i);
     1122    i = NFR_ANSI;
    11221123    }
    11231124    infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
     
    11271128    /* create combo box */
    11281129    dwComboStyle = GetWindowLongA (hwnd, GWL_STYLE) &
    1129                         (CBS_SIMPLE|CBS_DROPDOWN|CBS_DROPDOWNLIST|WS_CHILD);
     1130            (CBS_SIMPLE|CBS_DROPDOWN|CBS_DROPDOWNLIST|WS_CHILD);
    11301131
    11311132    GetWindowRect(hwnd, &wnrc1);
    11321133    GetClientRect(hwnd, &clrc1);
    11331134    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);
     1135      wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
     1136      clrc1.left, clrc1.top, clrc1.right, clrc1.bottom);
    11361137    TRACE("combo style=%08lx, adding style=%08lx\n", dwComboStyle,
    11371138          WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VSCROLL |
    11381139          CBS_NOINTEGRALHEIGHT | CBS_DROPDOWNLIST |
    1139           WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED);
     1140      WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED);
    11401141
    11411142    /* Native version of ComboEx creates the ComboBox with DROPDOWNLIST */
     
    11471148
    11481149    infoPtr->hwndCombo = CreateWindowA ("ComboBox", "",
    1149                         /* following line added to match native */
     1150            /* following line added to match native */
    11501151                         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     /* 
     1152                         CBS_NOINTEGRALHEIGHT | CBS_DROPDOWNLIST |
     1153            /* was base and is necessary */
     1154            WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED | dwComboStyle,
     1155            cs->y, cs->x, cs->cx, cs->cy, hwnd,
     1156            (HMENU) GetWindowLongA (hwnd, GWL_ID),
     1157            GetWindowLongA (hwnd, GWL_HINSTANCE), NULL);
     1158
     1159    /*
    11591160     * native does the following at this point according to trace:
    11601161     *  GetWindowThreadProcessId(hwndCombo,0)
     
    11651166
    11661167    /*
    1167      * Setup a property to hold the pointer to the COMBOBOXEX 
     1168     * Setup a property to hold the pointer to the COMBOBOXEX
    11681169     * data structure.
    11691170     */
    11701171    test = GetPropA(infoPtr->hwndCombo, (LPCSTR)(LONG)ComboExInfo);
    11711172    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);
     1173    SetPropA(infoPtr->hwndCombo, "CC32SubclassInfo", (LONG)infoPtr);
     1174    }
     1175    infoPtr->prevComboWndProc = (WNDPROC)SetWindowLongA(infoPtr->hwndCombo,
     1176                            GWL_WNDPROC, (LONG)COMBOEX_ComboWndProc);
    11761177    infoPtr->font = SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
    11771178
     
    11821183     */
    11831184    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);
     1185    infoPtr->hwndEdit = CreateWindowExA (0, "EDIT", "",
     1186            WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | ES_AUTOHSCROLL,
     1187            0, 0, 0, 0,  /* will set later */
     1188            infoPtr->hwndCombo,
     1189            (HMENU) GetWindowLongA (hwnd, GWL_ID),
     1190            GetWindowLongA (hwnd, GWL_HINSTANCE),
     1191            NULL);
     1192
     1193    /* native does the following at this point according to trace:
     1194    *  GetWindowThreadProcessId(hwndEdit,0)
     1195    *  GetCurrentThreadId()
     1196    *  GetWindowThreadProcessId(hwndEdit, &???)
     1197    *  GetCurrentProcessId()
     1198    */
     1199
     1200    /*
     1201     * Setup a property to hold the pointer to the COMBOBOXEX
     1202    * data structure.
     1203    */
     1204    test = GetPropA(infoPtr->hwndEdit, (LPCSTR)(LONG)ComboExInfo);
     1205    if (!test || ((COMBOEX_INFO *)test != infoPtr)) {
     1206        SetPropA(infoPtr->hwndEdit, "CC32SubclassInfo", (LONG)infoPtr);
     1207    }
     1208    infoPtr->prevEditWndProc = (WNDPROC)SetWindowLongA(infoPtr->hwndEdit,
     1209                GWL_WNDPROC, (LONG)COMBOEX_EditWndProc);
     1210    infoPtr->font = SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0);
    12101211    }
    12111212    else {
    1212         infoPtr->hwndEdit = 0;
    1213         infoPtr->font = 0;
     1213    infoPtr->hwndEdit = 0;
     1214    infoPtr->font = 0;
    12141215    }
    12151216
     
    12191220     */
    12201221    if (!infoPtr->font) {
    1221         SystemParametersInfoA (SPI_GETICONTITLELOGFONT, sizeof(mylogfont),
    1222                                &mylogfont, 0);
    1223         infoPtr->font = CreateFontIndirectA (&mylogfont);
     1222    SystemParametersInfoA (SPI_GETICONTITLELOGFONT, sizeof(mylogfont),
     1223                   &mylogfont, 0);
     1224    infoPtr->font = CreateFontIndirectA (&mylogfont);
    12241225    }
    12251226    SendMessageW (infoPtr->hwndCombo, WM_SETFONT, (WPARAM)infoPtr->font, 0);
    12261227    if (infoPtr->hwndEdit) {
    1227         SendMessageW (infoPtr->hwndEdit, WM_SETFONT, (WPARAM)infoPtr->font, 0);
    1228         SendMessageW (infoPtr->hwndEdit, EM_SETMARGINS, (WPARAM)EC_USEFONTINFO, 0);
     1228    SendMessageW (infoPtr->hwndEdit, WM_SETFONT, (WPARAM)infoPtr->font, 0);
     1229    SendMessageW (infoPtr->hwndEdit, EM_SETMARGINS, (WPARAM)EC_USEFONTINFO, 0);
    12291230    }
    12301231
     
    12371238    GetWindowRect(infoPtr->hwndCombo, &cmbwrc);
    12381239    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);
     1240      wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
     1241      clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
     1242      cmbwrc.left, cmbwrc.top, cmbwrc.right, cmbwrc.bottom);
     1243    SetWindowPos(infoPtr->hwndCombo, HWND_TOP,
     1244        0, 0, wnrc1.right-wnrc1.left, wnrc1.bottom-wnrc1.top,
     1245        SWP_NOACTIVATE | SWP_NOREDRAW);
    12451246
    12461247    GetWindowRect(infoPtr->hwndCombo, &cmbwrc);
    12471248    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);
     1249      cmbwrc.left, cmbwrc.top, cmbwrc.right, cmbwrc.bottom);
     1250    SetWindowPos(hwnd, HWND_TOP,
     1251        0, 0, cmbwrc.right-cmbwrc.left, cmbwrc.bottom-cmbwrc.top,
     1252        SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE);
    12521253
    12531254    COMBOEX_AdjustEditPos (infoPtr);
    12541255
    12551256    /*
    1256      * Create an item structure to represent the data in the 
     1257     * Create an item structure to represent the data in the
    12571258     * EDIT control.
    12581259     */
     
    12841285    {
    12851286    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;
     1287    SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
     1288                 (LPARAM)hwnd);
     1289    /*
     1290     * from native trace of first dropdown after typing in URL in IE4
     1291    *  CB_GETCURSEL(Combo)
     1292    *  GetWindowText(Edit)
     1293    *  CB_GETCURSEL(Combo)
     1294    *  CB_GETCOUNT(Combo)
     1295    *  CB_GETITEMDATA(Combo, n)
     1296    *  WM_NOTIFY(parent, CBEN_ENDEDITA|W)
     1297    *  CB_GETCURSEL(Combo)
     1298    *  CB_SETCURSEL(COMBOEX, n)
     1299    *  SetFocus(Combo)
     1300     * the rest is supposition
     1301    */
     1302    cursel = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
     1303    if (cursel == -1) {
     1304        /* find match from edit against those in Combobox */
     1305        GetWindowTextW (infoPtr->hwndEdit, wintext, 520);
     1306        n = SendMessageW (infoPtr->hwndCombo, CB_GETCOUNT, 0, 0);
     1307        for (cursel = 0; cursel < n; cursel++){
     1308        item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
     1309                             CB_GETITEMDATA,
     1310                             cursel, 0);
     1311        if ((INT)item == CB_ERR) break;
     1312        if (lstrcmpiW(item->pszText, wintext) == 0) break;
     1313        }
     1314        if ((cursel == n) || ((INT)item == CB_ERR)) {
     1315        TRACE("failed to find match??? item=%p cursel=%d\n",
     1316              item, cursel);
     1317        if (infoPtr->hwndEdit)
     1318            SetFocus(infoPtr->hwndEdit);
     1319        return 0;
     1320        }
     1321    }
     1322    else {
     1323        item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
     1324                         CB_GETITEMDATA,
     1325                        cursel, 0);
     1326        if ((INT)item == CB_ERR) {
     1327        TRACE("failed to find match??? item=%p cursel=%d\n",
     1328              item, cursel);
     1329        if (infoPtr->hwndEdit)
     1330            SetFocus(infoPtr->hwndEdit);
     1331        return 0;
     1332        }
     1333    }
     1334
     1335    /* Save flags for testing and reset them */
     1336    oldflags = infoPtr->flags;
     1337    infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
     1338
     1339    if (oldflags & WCBE_ACTEDIT) {
     1340        cbeend.fChanged = (oldflags & WCBE_EDITCHG);
     1341        cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
     1342                        CB_GETCURSEL, 0, 0);
     1343        cbeend.iWhy = CBENF_DROPDOWN;
     1344
     1345        if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, item->pszText)) {
     1346        /* abort the change */
     1347        TRACE("Notify requested abort of change\n");
     1348        return 0;
     1349        }
     1350    }
     1351
     1352    /* if selection has changed the set the new current selection */
     1353    cursel = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
     1354    if ((oldflags & WCBE_EDITCHG) || (cursel != infoPtr->selected)) {
     1355        infoPtr->selected = cursel;
     1356        SendMessageW (hwnd, CB_SETCURSEL, cursel, 0);
     1357        SetFocus(infoPtr->hwndCombo);
     1358    }
     1359    return 0;
    13591360
    13601361    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);
     1362    /*
     1363    * CB_GETCURSEL(Combo)
     1364    * CB_GETITEMDATA(Combo)   < simulated by COMBOEX_FindItem
     1365    * lstrlenA
     1366    * WM_SETTEXT(Edit)
     1367    * WM_GETTEXTLENGTH(Edit)
     1368    * WM_GETTEXT(Edit)
     1369    * EM_SETSEL(Edit, 0,0)
     1370    * WM_GETTEXTLENGTH(Edit)
     1371    * WM_GETTEXT(Edit)
     1372    * EM_SETSEL(Edit, 0,len)
     1373    * return WM_COMMAND to parent
     1374    */
     1375    oldItem = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0);
     1376    if (!(item = COMBOEX_FindItem(infoPtr, oldItem))) {
     1377        ERR("item %d not found. Problem!\n", oldItem);
     1378        break;
     1379    }
     1380    infoPtr->selected = oldItem;
     1381    COMBOEX_SetEditText (infoPtr, item);
     1382    return SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
     1383                 (LPARAM)hwnd);
    13831384
    13841385    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);
     1386    /*
     1387    * We have to change the handle since we are the control
     1388    * issuing the message. IE4 depends on this.
     1389    */
     1390    return SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
     1391                 (LPARAM)hwnd);
    13911392
    13921393    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;
     1394    /*
     1395    * from native trace:
     1396    *
     1397    *  pass to parent
     1398    *  WM_GETTEXT(Edit, 104)
     1399    *  CB_GETCURSEL(Combo) rets -1
     1400    *  WM_NOTIFY(CBEN_ENDEDITA) with CBENF_KILLFOCUS
     1401    *  CB_GETCURSEL(Combo)
     1402    *  InvalidateRect(Combo, 0, 0)
     1403    *  return 0
     1404    */
     1405    SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
     1406                 (LPARAM)hwnd);
     1407    if (infoPtr->flags & WCBE_ACTEDIT) {
     1408        GetWindowTextW (infoPtr->hwndEdit, wintext, 260);
     1409        cbeend.fChanged = (infoPtr->flags & WCBE_EDITCHG);
     1410        cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
     1411                        CB_GETCURSEL, 0, 0);
     1412        cbeend.iWhy = CBENF_KILLFOCUS;
     1413
     1414        infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
     1415        if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, wintext)) {
     1416        /* abort the change */
     1417        TRACE("Notify requested abort of change\n");
     1418        return 0;
     1419        }
     1420    }
     1421    /* possible CB_GETCURSEL */
     1422    InvalidateRect (infoPtr->hwndCombo, 0, 0);
     1423    return 0;
    14231424
    14241425    case CBN_CLOSEUP:
    14251426    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;
     1427    /*
     1428    * We have to change the handle since we are the control
     1429    * issuing the message. IE4 depends on this.
     1430    * We also need to set the focus back to the Edit control
     1431    * after passing the command to the parent of the ComboEx.
     1432    */
     1433    lret = SendMessageW (GetParent (hwnd), WM_COMMAND, wParam,
     1434                 (LPARAM)hwnd);
     1435    if (infoPtr->hwndEdit)
     1436        SetFocus(infoPtr->hwndEdit);
     1437    return lret;
    14371438    }
    14381439    return 0;
     
    14501451
    14511452    TRACE("CtlType=%08x, CtlID=%08x, itemID=%08x, hwnd=%x, data=%08lx\n",
    1452           dis->CtlType, dis->CtlID, dis->itemID, dis->hwndItem, dis->itemData);
     1453      dis->CtlType, dis->CtlID, dis->itemID, dis->hwndItem, dis->itemData);
    14531454
    14541455    if ((dis->itemID >= infoPtr->nb_items) || (dis->itemID < 0)) return FALSE;
     
    14581459
    14591460    if (i == dis->itemID) {
    1460         infoPtr->items = infoPtr->items->next;
     1461    infoPtr->items = infoPtr->items->next;
    14611462    }
    14621463    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;
     1464    item = olditem;
     1465    i--;
     1466
     1467    /* find the prior item in the list */
     1468    while (item->next && (i > dis->itemID)) {
     1469        item = (CBE_ITEMDATA *)item->next;
     1470        i--;
     1471    }
     1472    if (!item->next || (i != dis->itemID)) {
     1473        FIXME("COMBOBOXEX item structures broken. Please report!\n");
     1474        return FALSE;
     1475    }
     1476    olditem = item->next;
     1477    item->next = (CBE_ITEMDATA *)((CBE_ITEMDATA *)item->next)->next;
    14771478    }
    14781479    infoPtr->nb_items--;
     
    14821483
    14831484    if (olditem->pszText)
    1484         COMCTL32_Free(olditem->pszText);
     1485    COMCTL32_Free(olditem->pszText);
    14851486    COMCTL32_Free(olditem);
    14861487
     
    15101511    /* dump the DRAWITEMSTRUCT if tracing "comboex" but not "message" */
    15111512    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);
     1513    TRACE("DRAWITEMSTRUCT: CtlType=0x%08x CtlID=0x%08x\n",
     1514          dis->CtlType, dis->CtlID);
     1515    TRACE("itemID=0x%08x itemAction=0x%08x itemState=0x%08x\n",
     1516          dis->itemID, dis->itemAction, dis->itemState);
     1517    TRACE("hWnd=0x%04x hDC=0x%04x (%d,%d)-(%d,%d) itemData=0x%08lx\n",
     1518          dis->hwndItem, dis->hDC, dis->rcItem.left,
     1519          dis->rcItem.top, dis->rcItem.right, dis->rcItem.bottom,
     1520          dis->itemData);
    15201521    }
    15211522
     
    15321533    /*      though the list box or combo box has the focus.             */
    15331534    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         }
     1535    if ( ( (dis->itemAction & ODA_FOCUS) && (dis->itemState & ODS_SELECTED)) ||
     1536         ( (dis->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)) && (dis->itemState & ODS_FOCUS) ) ) {
     1537
     1538        TRACE("drawing item -1 special focus, rect=(%d,%d)-(%d,%d)\n",
     1539          dis->rcItem.left, dis->rcItem.top,
     1540          dis->rcItem.right, dis->rcItem.bottom);
     1541    }
     1542    else if ((dis->CtlType == ODT_COMBOBOX) &&
     1543        (dis->itemAction == ODA_DRAWENTIRE)) {
     1544        /* draw of edit control data */
     1545
     1546        /* testing */
     1547        {
     1548        RECT exrc, cbrc, edrc;
     1549        GetWindowRect (hwnd, &exrc);
     1550        GetWindowRect (infoPtr->hwndCombo, &cbrc);
     1551        edrc.left=edrc.top=edrc.right=edrc.bottom=-1;
     1552        if (infoPtr->hwndEdit)
     1553            GetWindowRect (infoPtr->hwndEdit, &edrc);
     1554        TRACE("window rects ex=(%d,%d)-(%d,%d), cb=(%d,%d)-(%d,%d), ed=(%d,%d)-(%d,%d)\n",
     1555              exrc.left, exrc.top, exrc.right, exrc.bottom,
     1556              cbrc.left, cbrc.top, cbrc.right, cbrc.bottom,
     1557              edrc.left, edrc.top, edrc.right, edrc.bottom);
     1558        }
     1559    }
     1560    else {
     1561        ERR("NOT drawing item  -1 special focus, rect=(%d,%d)-(%d,%d), action=%08x, state=%08x\n",
     1562        dis->rcItem.left, dis->rcItem.top,
     1563        dis->rcItem.right, dis->rcItem.bottom,
     1564        dis->itemAction, dis->itemState);
     1565        return 0;
     1566    }
    15661567    }
    15671568
    15681569    /* If draw item is -1 (edit control) setup the item pointer */
    15691570    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         }
     1571    CHAR str[260];
     1572    INT wlen, alen;
     1573
     1574    item = infoPtr->edit;
     1575
     1576    if (infoPtr->hwndEdit) {
     1577
     1578        /* free previous text of edit item */
     1579        if (item->pszText) {
     1580        COMCTL32_Free(item->pszText);
     1581        item->pszText = 0;
     1582        item->mask &= ~CBEIF_TEXT;
     1583        }
     1584        alen = SendMessageA (infoPtr->hwndEdit, WM_GETTEXT, 260, (LPARAM)&str);
     1585        TRACE("edit control hwndEdit=%0x, text len=%d str=<%s>\n",
     1586          infoPtr->hwndEdit, alen, str);
     1587        if (alen > 0) {
     1588        item->mask |= CBEIF_TEXT;
     1589        wlen = MultiByteToWideChar (CP_ACP, 0, str, -1, NULL, 0);
     1590        if (wlen > 0) {
     1591            item->pszText = (LPWSTR)COMCTL32_Alloc ((wlen + 1)*sizeof(WCHAR));
     1592            MultiByteToWideChar (CP_ACP, 0, str, -1, item->pszText, wlen);
     1593        }
     1594        }
     1595    }
    15951596    }
    15961597
    15971598    /* if the item pointer is not set, then get the data and locate it */
    15981599    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             }
     1600    item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo,
     1601                 CB_GETITEMDATA, (WPARAM)dis->itemID, 0);
     1602    if (item == (CBE_ITEMDATA *)CB_ERR)
     1603        {
     1604        FIXME("invalid item for id %d \n",dis->itemID);
     1605        return 0;
     1606        }
    16061607    }
    16071608
     
    16121613        xbase += (item->iIndent * CBE_INDENT);
    16131614    if (item->mask & CBEIF_IMAGE) {
    1614         ImageList_GetImageInfo(infoPtr->himl, item->iImage, &iinfo);
    1615         xioff = (iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP);
     1615    ImageList_GetImageInfo(infoPtr->himl, item->iImage, &iinfo);
     1616    xioff = (iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP);
    16161617    }
    16171618
     
    16191620    case ODA_FOCUS:
    16201621        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         }
     1622        if ((item->mask & CBEIF_TEXT) && item->pszText) {
     1623        RECT rect2;
     1624
     1625            len = strlenW (item->pszText);
     1626        GetTextExtentPointW (dis->hDC, item->pszText, len, &txtsize);
     1627        rect.left = xbase + xioff - 1;
     1628        rect.right = rect.left + txtsize.cx + 2;
     1629        rect.top = dis->rcItem.top;
     1630        rect.bottom = dis->rcItem.bottom;
     1631        GetClipBox (dis->hDC, &rect2);
     1632        TRACE("drawing item %d focus, rect=(%d,%d)-(%d,%d)\n",
     1633              dis->itemID, rect.left, rect.top,
     1634              rect.right, rect.bottom);
     1635        TRACE("                      clip=(%d,%d)-(%d,%d)\n",
     1636              rect2.left, rect2.top,
     1637              rect2.right, rect2.bottom);
     1638
     1639        DrawFocusRect(dis->hDC, &rect);
     1640        }
     1641        else {
     1642        FIXME("ODA_FOCUS and ODS_SELECTED but no text\n");
     1643        }
     1644    }
     1645    else {
     1646        FIXME("ODA_FOCUS but not ODS_SELECTED\n");
     1647    }
    16471648        break;
    16481649    case ODA_SELECT:
    16491650    case ODA_DRAWENTIRE:
    16501651        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;
     1652    drawstate = ILD_NORMAL;
     1653    if (!(infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE)) {
     1654        if (item->mask & CBEIF_IMAGE)
     1655        drawimage = item->iImage;
     1656        if (dis->itemState & ODS_COMBOEXLBOX) {
     1657        /* drawing listbox entry */
     1658        if (dis->itemState & ODS_SELECTED) {
     1659            if (item->mask & CBEIF_SELECTEDIMAGE)
     1660            drawimage = item->iSelectedImage;
     1661            drawstate = ILD_SELECTED;
     1662        }
     1663        }
     1664        else {
     1665        /* drawing combo/edit entry */
     1666        if (infoPtr->hwndEdit) {
     1667            /* if we have an edit control, the slave the
     1668                     * selection state to the Edit focus state
     1669             */
     1670            if (infoPtr->flags & WCBE_EDITFOCUSED) {
     1671            if (item->mask & CBEIF_SELECTEDIMAGE)
     1672                drawimage = item->iSelectedImage;
     1673            drawstate = ILD_SELECTED;
     1674            }
     1675        }
     1676        else {
     1677            /* if we don't have an edit control, use
     1678             * the requested state.
     1679             */
     1680            if (dis->itemState & ODS_SELECTED) {
     1681            if (item->mask & CBEIF_SELECTEDIMAGE)
     1682                drawimage = item->iSelectedImage;
     1683            drawstate = ILD_SELECTED;
     1684            }
     1685        }
     1686        }
     1687    }
     1688    if (drawimage != -1) {
     1689        TRACE("drawing image state=%d\n", dis->itemState & ODS_SELECTED);
     1690        ImageList_Draw (infoPtr->himl, drawimage, dis->hDC,
     1691                xbase, dis->rcItem.top, drawstate);
     1692    }
     1693
     1694    /* setup pointer to text to be drawn */
     1695    if ((item->mask & CBEIF_TEXT) && item->pszText)
     1696        str = item->pszText;
     1697    else
     1698        str = (LPWSTR) L"";
     1699
     1700    /* now draw the text */
     1701    len = lstrlenW (str);
     1702    GetTextExtentPointW (dis->hDC, str, len, &txtsize);
     1703    nbkc = GetSysColor ((dis->itemState & ODS_SELECTED) ?
     1704                COLOR_HIGHLIGHT : COLOR_WINDOW);
     1705    SetBkColor (dis->hDC, nbkc);
     1706    ntxc = GetSysColor ((dis->itemState & ODS_SELECTED) ?
     1707                COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT);
     1708    SetTextColor (dis->hDC, ntxc);
     1709    x = xbase + xioff;
     1710    y = dis->rcItem.top +
     1711        (dis->rcItem.bottom - dis->rcItem.top - txtsize.cy) / 2;
     1712    rect.left = x;
     1713    rect.right = x + txtsize.cx;
     1714    rect.top = dis->rcItem.top + 1;
     1715    rect.bottom = dis->rcItem.bottom - 1;
     1716    TRACE("drawing item %d text, rect=(%d,%d)-(%d,%d)\n",
     1717          dis->itemID, rect.left, rect.top, rect.right, rect.bottom);
     1718    ExtTextOutW (dis->hDC, x, y, ETO_OPAQUE | ETO_CLIPPED,
     1719             &rect, str, len, 0);
     1720    if (dis->itemState & ODS_FOCUS) {
     1721        rect.top -= 1;
     1722        rect.bottom += 1;
     1723        rect.left -= 1;
     1724        rect.right += 1;
     1725        TRACE("drawing item %d focus after text, rect=(%d,%d)-(%d,%d)\n",
     1726          dis->itemID, rect.left, rect.top, rect.right, rect.bottom);
     1727        DrawFocusRect (dis->hDC, &rect);
     1728    }
     1729    break;
    17291730    default:
    1730         FIXME("unknown action hwnd=%08x, wparam=%08x, lparam=%08lx, action=%d\n", 
    1731               hwnd, wParam, lParam, dis->itemAction);
     1731        FIXME("unknown action hwnd=%08x, wparam=%08x, lparam=%08lx, action=%d\n",
     1732          hwnd, wParam, lParam, dis->itemAction);
    17321733    }
    17331734
     
    17421743
    17431744    if (infoPtr->hwndCombo)
    1744         DestroyWindow (infoPtr->hwndCombo);
     1745    DestroyWindow (infoPtr->hwndCombo);
    17451746
    17461747    if (infoPtr->edit) {
    1747         COMCTL32_Free (infoPtr->edit);
    1748         infoPtr->edit = 0;
     1748    COMCTL32_Free (infoPtr->edit);
     1749    infoPtr->edit = 0;
    17491750    }
    17501751
     
    17521753        CBE_ITEMDATA *this, *next;
    17531754
    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         }
     1755    this = infoPtr->items;
     1756    while (this) {
     1757        next = (CBE_ITEMDATA *)this->next;
     1758        if ((this->mask & CBEIF_TEXT) && this->pszText)
     1759            COMCTL32_Free (this->pszText);
     1760        COMCTL32_Free (this);
     1761        this = next;
     1762    }
    17621763    }
    17631764
     
    17851786
    17861787    TRACE("adjusted height hwnd=%08x, height=%d\n",
    1787           hwnd, mis->itemHeight);
     1788      hwnd, mis->itemHeight);
    17881789
    17891790    return 0;
     
    18001801    newstyle = oldstyle & ~(WS_VSCROLL | WS_HSCROLL);
    18011802    if (newstyle != oldstyle) {
    1802         TRACE("req style %08lx, reseting style %08lx\n",
    1803               oldstyle, newstyle);
    1804         SetWindowLongA (hwnd, GWL_STYLE, newstyle);
     1803    TRACE("req style %08lx, reseting style %08lx\n",
     1804          oldstyle, newstyle);
     1805    SetWindowLongA (hwnd, GWL_STYLE, newstyle);
    18051806    }
    18061807    return 1;
     
    18151816
    18161817    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;
     1818    i = SendMessageA(GetParent (hwnd),
     1819            WM_NOTIFYFORMAT, infoPtr->hwndSelf, NF_QUERY);
     1820    if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
     1821        ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
     1822        i);
     1823        i = NFR_ANSI;
     1824    }
     1825    infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
     1826    return (LRESULT)i;
    18261827    }
    18271828    return (LRESULT)((infoPtr->bUnicode) ? NFR_UNICODE : NFR_ANSI);
     
    18371838    GetWindowRect (hwnd, &rect);
    18381839    TRACE("my rect (%d,%d)-(%d,%d)\n",
    1839           rect.left, rect.top, rect.right, rect.bottom);
     1840      rect.left, rect.top, rect.right, rect.bottom);
    18401841
    18411842    MoveWindow (infoPtr->hwndCombo, 0, 0, rect.right -rect.left,
    1842                   rect.bottom - rect.top, TRUE);
     1843          rect.bottom - rect.top, TRUE);
    18431844
    18441845    COMBOEX_AdjustEditPos (infoPtr);
     
    18621863    /* width is winpos value + border width of comboex */
    18631864    width = wp->cx
    1864             + (cbx_wrect.right-cbx_wrect.left)
    1865             - (cbx_crect.right-cbx_crect.left); 
     1865        + (cbx_wrect.right-cbx_wrect.left)
     1866            - (cbx_crect.right-cbx_crect.left);
    18661867
    18671868    TRACE("winpos=(%d,%d %dx%d) flags=0x%08x\n",
    1868           wp->x, wp->y, wp->cx, wp->cy, wp->flags);
     1869      wp->x, wp->y, wp->cx, wp->cy, wp->flags);
    18691870    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);
     1871      cbx_wrect.left, cbx_wrect.top, cbx_wrect.right, cbx_wrect.bottom,
     1872      cbx_crect.left, cbx_crect.top, cbx_crect.right, cbx_crect.bottom);
    18721873    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);
     1874      cb_wrect.left, cb_wrect.top, cb_wrect.right, cb_wrect.bottom,
     1875      width, cb_wrect.bottom-cb_wrect.top);
    18751876
    18761877    if (width) SetWindowPos (infoPtr->hwndCombo, HWND_TOP, 0, 0,
    1877                              width,
    1878                              cb_wrect.bottom-cb_wrect.top,
    1879                              SWP_NOACTIVATE);
     1878                 width,
     1879                 cb_wrect.bottom-cb_wrect.top,
     1880                 SWP_NOACTIVATE);
    18801881
    18811882    GetWindowRect (infoPtr->hwndCombo, &cb_wrect);
     
    18831884    /* height is combo window height plus border width of comboex */
    18841885    height =   (cb_wrect.bottom-cb_wrect.top)
    1885              + (cbx_wrect.bottom-cbx_wrect.top)
     1886         + (cbx_wrect.bottom-cbx_wrect.top)
    18861887             - (cbx_crect.bottom-cbx_crect.top);
    18871888    if (wp->cy < height) wp->cy = height;
    18881889    if (infoPtr->hwndEdit) {
    1889         COMBOEX_AdjustEditPos (infoPtr);
    1890         InvalidateRect (infoPtr->hwndCombo, 0, TRUE);
     1890    COMBOEX_AdjustEditPos (infoPtr);
     1891    InvalidateRect (infoPtr->hwndCombo, 0, TRUE);
    18911892    }
    18921893
     
    19061907    LRESULT lret;
    19071908
    1908     TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx, info_ptr=%p\n", 
    1909           hwnd, uMsg, wParam, lParam, infoPtr);
     1909    TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx, info_ptr=%p\n",
     1910      hwnd, uMsg, wParam, lParam, infoPtr);
    19101911
    19111912    if (!infoPtr) return 0;
     
    19151916
    19161917    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);
     1918        /* handle (ignore) the return character */
     1919        if (wParam == VK_RETURN) return 0;
     1920        /* all other characters pass into the real Edit */
     1921        return CallWindowProcA (infoPtr->prevEditWndProc,
     1922                   hwnd, uMsg, wParam, lParam);
    19221923
    19231924    case WM_ERASEBKGND:
    1924             /*
    1925              * The following was determined by traces of the native
    1926              */
     1925        /*
     1926         * The following was determined by traces of the native
     1927         */
    19271928            hDC = (HDC) wParam;
    1928             nbkc = GetSysColor (COLOR_WINDOW);
    1929             obkc = SetBkColor (hDC, nbkc);
     1929        nbkc = GetSysColor (COLOR_WINDOW);
     1930        obkc = SetBkColor (hDC, nbkc);
    19301931            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);
     1932        TRACE("erasing (%d,%d)-(%d,%d)\n",
     1933          rect.left, rect.top, rect.right, rect.bottom);
     1934        ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0);
    19341935            SetBkColor (hDC, obkc);
    1935             return CallWindowProcA (infoPtr->prevEditWndProc,
    1936                                    hwnd, uMsg, wParam, lParam);
     1936        return CallWindowProcA (infoPtr->prevEditWndProc,
     1937                   hwnd, uMsg, wParam, lParam);
    19371938
    19381939    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;
    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;
     1940        INT oldItem, selected;
     1941        CBE_ITEMDATA *item;
     1942
     1943        switch ((INT)wParam)
     1944        {
     1945        case VK_ESCAPE:
     1946        /* native version seems to do following for COMBOEX */
     1947        /*
     1948         *   GetWindowTextA(Edit,&?, 0x104)             x
     1949         *   CB_GETCURSEL to Combo rets -1              x
     1950         *   WM_NOTIFY to COMBOEX parent (rebar)        x
     1951         *     (CBEN_ENDEDIT{A|W}
     1952         *      fChanged = FALSE                        x
     1953         *      inewSelection = -1                      x
     1954         *      txt="www.hoho"                          x
     1955         *      iWhy = 3                                x
     1956         *   CB_GETCURSEL to Combo rets -1              x
     1957         *   InvalidateRect(Combo, 0)                   x
     1958         *   WM_SETTEXT to Edit                         x
     1959         *   EM_SETSEL to Edit (0,0)                    x
     1960         *   EM_SETSEL to Edit (0,-1)                   x
     1961         *   RedrawWindow(Combo, 0, 0, 5)               x
     1962         */
     1963        TRACE("special code for VK_ESCAPE\n");
     1964
     1965        GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
     1966
     1967        infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
     1968        cbeend.fChanged = FALSE;
     1969        cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
     1970                             CB_GETCURSEL, 0, 0);
     1971        cbeend.iWhy = CBENF_ESCAPE;
     1972
     1973        if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) {
     1974            /* abort the change */
     1975            TRACE("Notify requested abort of change\n");
     1976            return 0;
     1977        }
     1978        oldItem = SendMessageW (infoPtr->hwndCombo,CB_GETCURSEL, 0, 0);
     1979        InvalidateRect (infoPtr->hwndCombo, 0, 0);
     1980        if (!(item = COMBOEX_FindItem(infoPtr, oldItem))) {
     1981            ERR("item %d not found. Problem!\n", oldItem);
     1982            break;
     1983        }
     1984        infoPtr->selected = oldItem;
     1985        COMBOEX_SetEditText (infoPtr, item);
     1986        RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE |
     1987                  RDW_INVALIDATE);
     1988        break;
     1989
     1990        case VK_RETURN:
     1991        /* native version seems to do following for COMBOEX */
     1992        /*
     1993         *   GetWindowTextA(Edit,&?, 0x104)             x
     1994         *   CB_GETCURSEL to Combo  rets -1             x
     1995         *   CB_GETCOUNT to Combo  rets 0
     1996         *   if >0 loop
     1997         *       CB_GETITEMDATA to match
     1998         * *** above 3 lines simulated by FindItem      x
     1999         *   WM_NOTIFY to COMBOEX parent (rebar)        x
     2000         *     (CBEN_ENDEDIT{A|W}                       x
     2001         *        fChanged = TRUE (-1)                  x
     2002         *        iNewSelection = -1 or selected        x
     2003         *        txt=                                  x
     2004         *        iWhy = 2 (CBENF_RETURN)               x
     2005         *   CB_GETCURSEL to Combo  rets -1             x
     2006         *   if -1 send CB_SETCURSEL to Combo -1        x
     2007         *   InvalidateRect(Combo, 0, 0)                x
     2008         *   SetFocus(Edit)                             x
     2009         *   CallWindowProc(406615a8, Edit, 0x100, 0xd, 0x1c0001)
     2010         */
     2011
     2012        TRACE("special code for VK_RETURN\n");
     2013
     2014        GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
     2015
     2016        infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
     2017        selected = SendMessageW (infoPtr->hwndCombo,
     2018                     CB_GETCURSEL, 0, 0);
     2019
     2020        if (selected != -1) {
     2021            item = COMBOEX_FindItem (infoPtr, selected);
     2022            TRACE("handling VK_RETURN, selected = %d, selected_text=%s\n",
     2023              selected, debugstr_w(item->pszText));
     2024            TRACE("handling VK_RETURN, edittext=%s\n",
     2025              debugstr_w(edit_text));
     2026            if (lstrcmpiW (item->pszText, edit_text)) {
     2027            /* strings not equal -- indicate edit has changed */
     2028            selected = -1;
    20572029            }
     2030        }
     2031
     2032        cbeend.iNewSelection = selected;
     2033        cbeend.fChanged = TRUE;
     2034        cbeend.iWhy = CBENF_RETURN;
     2035        if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) {
     2036            /* abort the change, restore previous */
     2037            TRACE("Notify requested abort of change\n");
     2038            COMBOEX_SetEditText (infoPtr, infoPtr->edit);
     2039            RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE |
     2040                  RDW_INVALIDATE);
     2041            return 0;
     2042        }
     2043        oldItem = SendMessageW (infoPtr->hwndCombo,CB_GETCURSEL, 0, 0);
     2044        if (oldItem != -1) {
     2045            /* if something is selected, then deselect it */
     2046            SendMessageW (infoPtr->hwndCombo, CB_SETCURSEL,
     2047                  (WPARAM)-1, 0);
     2048        }
     2049        InvalidateRect (infoPtr->hwndCombo, 0, 0);
     2050        SetFocus(infoPtr->hwndEdit);
     2051        break;
     2052
     2053        default:
     2054        return CallWindowProcA (infoPtr->prevEditWndProc,
     2055                       hwnd, uMsg, wParam, lParam);
     2056        }
     2057        return 0;
     2058            }
    20582059
    20592060    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;
     2061        /* remember the focus to set state of icon */
     2062        lret = CallWindowProcA (infoPtr->prevEditWndProc,
     2063                   hwnd, uMsg, wParam, lParam);
     2064        infoPtr->flags |= WCBE_EDITFOCUSED;
     2065        return lret;
    20652066
    20662067    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 */
     2068        /*
     2069         * do NOTIFY CBEN_ENDEDIT with CBENF_KILLFOCUS
     2070         */
     2071        infoPtr->flags &= ~WCBE_EDITFOCUSED;
     2072        if (infoPtr->flags & WCBE_ACTEDIT) {
     2073        infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
     2074
     2075        GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
     2076        cbeend.fChanged = FALSE;
     2077        cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
     2078                             CB_GETCURSEL, 0, 0);
     2079        cbeend.iWhy = CBENF_KILLFOCUS;
     2080
     2081        COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text);
     2082        }
     2083        /* fall through */
    20832084
    20842085    default:
    2085             return CallWindowProcA (infoPtr->prevEditWndProc,
    2086                                    hwnd, uMsg, wParam, lParam);
     2086        return CallWindowProcA (infoPtr->prevEditWndProc,
     2087                   hwnd, uMsg, wParam, lParam);
    20872088    }
    20882089    return 0;
     
    21022103    WCHAR edit_text[260];
    21032104
    2104     TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx, info_ptr=%p\n", 
    2105           hwnd, uMsg, wParam, lParam, infoPtr);
     2105    TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx, info_ptr=%p\n",
     2106      hwnd, uMsg, wParam, lParam, infoPtr);
    21062107
    21072108    if (!infoPtr) return 0;
     
    21112112
    21122113    case CB_FINDSTRINGEXACT:
    2113             return COMBOEX_FindStringExact (infoPtr, wParam, lParam);
     2114        return COMBOEX_FindStringExact (infoPtr, wParam, lParam);
    21142115
    21152116    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);
     2117        /*
     2118         * The only way this message should come is from the
     2119         * child Listbox issuing the message. Flag this so
     2120         * that ComboEx knows this is listbox.
     2121         */
     2122        ((DRAWITEMSTRUCT *)lParam)->itemState |= ODS_COMBOEXLBOX;
     2123        return CallWindowProcA (infoPtr->prevComboWndProc,
     2124                   hwnd, uMsg, wParam, lParam);
    21242125
    21252126    case WM_ERASEBKGND:
    2126             /*
    2127              * The following was determined by traces of the native
    2128              */
     2127        /*
     2128         * The following was determined by traces of the native
     2129         */
    21292130            hDC = (HDC) wParam;
    2130             nbkc = GetSysColor (COLOR_WINDOW);
    2131             obkc = SetBkColor (hDC, nbkc);
     2131        nbkc = GetSysColor (COLOR_WINDOW);
     2132        obkc = SetBkColor (hDC, nbkc);
    21322133            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);
     2134        TRACE("erasing (%d,%d)-(%d,%d)\n",
     2135          rect.left, rect.top, rect.right, rect.bottom);
     2136        ExtTextOutW (hDC, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0);
    21362137            SetBkColor (hDC, obkc);
    2137             return CallWindowProcA (infoPtr->prevComboWndProc,
    2138                                    hwnd, uMsg, wParam, lParam);
     2138        return CallWindowProcA (infoPtr->prevComboWndProc,
     2139                   hwnd, uMsg, wParam, lParam);
    21392140
    21402141    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);
     2142        /*
     2143         *  WM_NOTIFY to comboex parent (rebar)
     2144         *   with NM_SETCURSOR with extra words of 0,0,0,0,0x02010001
     2145         *  CallWindowProc (previous)
     2146         */
     2147        nmmse.dwItemSpec = 0;
     2148        nmmse.dwItemData = 0;
     2149        nmmse.pt.x = 0;
     2150        nmmse.pt.y = 0;
     2151        nmmse.dwHitInfo = lParam;
     2152        COMBOEX_Notify (infoPtr, NM_SETCURSOR, (NMHDR *)&nmmse);
     2153        return CallWindowProcA (infoPtr->prevComboWndProc,
     2154                   hwnd, uMsg, wParam, lParam);
    21542155
    21552156    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 */
     2157        switch (HIWORD(wParam)) {
     2158
     2159        case EN_UPDATE:
     2160        /* traces show that COMBOEX does not issue CBN_EDITUPDATE
     2161        * on the EN_UPDATE
     2162        */
     2163        return 0;
     2164
     2165        case EN_KILLFOCUS:
     2166        /*
     2167        * Native does:
     2168        *
     2169        *  GetFocus() retns AA
     2170        *  GetWindowTextA(Edit)
     2171        *  CB_GETCURSEL(Combo) (got -1)
     2172        *  WM_NOTIFY(CBEN_ENDEDITA) with CBENF_KILLFOCUS
     2173        *  CB_GETCURSEL(Combo) (got -1)
     2174        *  InvalidateRect(Combo, 0, 0)
     2175        *  WM_KILLFOCUS(Combo, AA)
     2176        *  return 0;
     2177        */
     2178        focusedhwnd = GetFocus();
     2179        if (infoPtr->flags & WCBE_ACTEDIT) {
     2180            GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
     2181            cbeend.fChanged = (infoPtr->flags & WCBE_EDITCHG);
     2182            cbeend.iNewSelection = SendMessageW (infoPtr->hwndCombo,
     2183                            CB_GETCURSEL, 0, 0);
     2184            cbeend.iWhy = CBENF_KILLFOCUS;
     2185
     2186            infoPtr->flags &= ~(WCBE_ACTEDIT | WCBE_EDITCHG);
     2187            if (COMBOEX_NotifyEndEdit (infoPtr, &cbeend, edit_text)) {
     2188            /* abort the change */
     2189            TRACE("Notify requested abort of change\n");
     2190            return 0;
     2191            }
     2192        }
     2193        /* possible CB_GETCURSEL */
     2194        InvalidateRect (infoPtr->hwndCombo, 0, 0);
     2195        if (focusedhwnd)
     2196            SendMessageW (infoPtr->hwndCombo, WM_KILLFOCUS,
     2197                  (WPARAM)focusedhwnd, 0);
     2198        return 0;
     2199
     2200        case EN_SETFOCUS: {
     2201        /*
     2202        * For EN_SETFOCUS this issues the same calls and messages
     2203        *  as the native seems to do.
     2204        *
     2205        * for some cases however native does the following:
     2206        *   (noticed after SetFocus during LBUTTONDOWN on
     2207        *    on dropdown arrow)
     2208        *  WM_GETTEXTLENGTH (Edit);
     2209        *  WM_GETTEXT (Edit, len+1, str);
     2210        *  EM_SETSEL (Edit, 0, 0);
     2211        *  WM_GETTEXTLENGTH (Edit);
     2212        *  WM_GETTEXT (Edit, len+1, str);
     2213        *  EM_SETSEL (Edit, 0, len);
     2214        *  WM_NOTIFY (parent, CBEN_BEGINEDIT)
     2215        */
     2216        NMHDR hdr;
     2217
     2218        SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, 0);
     2219        SendMessageW (infoPtr->hwndEdit, EM_SETSEL, 0, -1);
     2220        COMBOEX_Notify (infoPtr, CBEN_BEGINEDIT, &hdr);
     2221        infoPtr->flags |= WCBE_ACTEDIT;
     2222        infoPtr->flags &= ~WCBE_EDITCHG; /* no change yet */
     2223        return 0;
     2224            }
     2225
     2226        case EN_CHANGE: {
     2227        /*
     2228        * For EN_CHANGE this issues the same calls and messages
     2229        *  as the native seems to do.
     2230        */
     2231        WCHAR edit_text[260];
     2232        WCHAR *lastwrk;
     2233        INT selected, cnt;
     2234        CBE_ITEMDATA *item;
     2235
     2236        selected = SendMessageW (infoPtr->hwndCombo,
     2237                    CB_GETCURSEL, 0, 0);
     2238
     2239        /* lstrlenA( lastworkingURL ) */
     2240
     2241        GetWindowTextW (infoPtr->hwndEdit, edit_text, 260);
     2242        if (selected == -1) {
     2243            lastwrk = infoPtr->edit->pszText;
     2244            cnt = lstrlenW (lastwrk);
     2245            if (cnt >= 259) cnt = 259;
     2246        }
     2247        else {
     2248            item = COMBOEX_FindItem (infoPtr, selected);
     2249            cnt = lstrlenW (item->pszText);
     2250            lastwrk = item->pszText;
     2251            if (cnt >= 259) cnt = 259;
     2252        }
     2253
     2254        TRACE("handling EN_CHANGE, selected = %d, selected_text=%s\n",
     2255            selected, debugstr_w(lastwrk));
     2256        TRACE("handling EN_CHANGE, edittext=%s\n",
     2257              debugstr_w(edit_text));
     2258
     2259        /* lstrcmpiW is between lastworkingURL and GetWindowText */
     2260
     2261        if (lstrcmpiW (lastwrk, edit_text)) {
     2262            /* strings not equal -- indicate edit has changed */
     2263            infoPtr->flags |= WCBE_EDITCHG;
     2264        }
     2265        SendMessageW ( GetParent(infoPtr->hwndSelf), WM_COMMAND,
     2266                   MAKEWPARAM(GetDlgCtrlID (infoPtr->hwndSelf),
     2267                      CBN_EDITCHANGE),
     2268                   infoPtr->hwndSelf);
     2269        return 0;
     2270            }
     2271
     2272        case LBN_SELCHANGE:
     2273        /*
     2274        * Therefore from traces there is no additional code here
     2275        */
     2276
     2277        /*
     2278        * Using native COMCTL32 gets the following:
     2279        *  1 == SHDOCVW.DLL  issues call/message
     2280        *  2 == COMCTL32.DLL  issues call/message
     2281        *  3 == WINE  issues call/message
     2282        *
     2283        *
     2284        * for LBN_SELCHANGE:
     2285        *    1  CB_GETCURSEL(ComboEx)
     2286        *    1  CB_GETDROPPEDSTATE(ComboEx)
     2287        *    1  CallWindowProc( *2* for WM_COMMAND(LBN_SELCHANGE)
     2288        *    2  CallWindowProc( *3* for WM_COMMAND(LBN_SELCHANGE)
     2289        **   call CBRollUp( xxx, TRUE for LBN_SELCHANGE, TRUE)
     2290        *    3  WM_COMMAND(ComboEx, CBN_SELENDOK)
     2291        *      WM_USER+49(ComboLB, 1,0)  <=============!!!!!!!!!!!
     2292        *    3  ShowWindow(ComboLB, SW_HIDE)
     2293        *    3  RedrawWindow(Combo,  RDW_UPDATENOW)
     2294        *    3  WM_COMMAND(ComboEX, CBN_CLOSEUP)
     2295        **   end of CBRollUp
     2296        *    3  WM_COMMAND(ComboEx, CBN_SELCHANGE)  (echo to parent)
     2297        *    ?  LB_GETCURSEL              <==|
     2298        *    ?  LB_GETTEXTLEN                |
     2299        *    ?  LB_GETTEXT                   | Needs to be added to
     2300        *    ?  WM_CTLCOLOREDIT(ComboEx)     | Combo processing
     2301        *    ?  LB_GETITEMDATA               |
     2302        *    ?  WM_DRAWITEM(ComboEx)      <==|
     2303        */
     2304        default:
     2305        break;
     2306        }/* fall through */
    23062307    default:
    2307             return CallWindowProcA (infoPtr->prevComboWndProc,
    2308                                    hwnd, uMsg, wParam, lParam);
     2308        return CallWindowProcA (infoPtr->prevComboWndProc,
     2309                   hwnd, uMsg, wParam, lParam);
    23092310    }
    23102311    return 0;
     
    23202321
    23212322    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);
     2323    if (uMsg == WM_CREATE)
     2324        return COMBOEX_Create (hwnd, wParam, lParam);
     2325    if (uMsg == WM_NCCREATE)
     2326        COMBOEX_NCCreate (hwnd, wParam, lParam);
    23262327        return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    23272328    }
     
    23302331    {
    23312332        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);
     2333        return COMBOEX_DeleteItem (hwnd, wParam, lParam);
     2334
     2335    case CBEM_GETCOMBOCONTROL:
     2336        return COMBOEX_GetComboControl (hwnd, wParam, lParam);
     2337
     2338    case CBEM_GETEDITCONTROL:
     2339        return COMBOEX_GetEditControl (hwnd, wParam, lParam);
     2340
     2341    case CBEM_GETEXTENDEDSTYLE:
     2342        return COMBOEX_GetExtendedStyle (hwnd, wParam, lParam);
     2343
     2344    case CBEM_GETIMAGELIST:
     2345        return COMBOEX_GetImageList (hwnd, wParam, lParam);
     2346
     2347    case CBEM_GETITEMA:
     2348        return COMBOEX_GetItemA (hwnd, wParam, lParam);
     2349
     2350    case CBEM_GETITEMW:
     2351        return COMBOEX_GetItemW (hwnd, wParam, lParam);
     2352
     2353    case CBEM_GETUNICODEFORMAT:
     2354        return COMBOEX_GetUnicodeFormat (hwnd, wParam, lParam);
     2355
     2356    case CBEM_HASEDITCHANGED:
     2357        return COMBOEX_HasEditChanged (hwnd, wParam, lParam);
     2358
     2359    case CBEM_INSERTITEMA:
     2360        return COMBOEX_InsertItemA (hwnd, wParam, lParam);
     2361
     2362    case CBEM_INSERTITEMW:
     2363        return COMBOEX_InsertItemW (hwnd, wParam, lParam);
     2364
     2365    case CBEM_SETEXSTYLE:   /* FIXME: obsoleted, should be the same as: */
     2366    case CBEM_SETEXTENDEDSTYLE:
     2367        return COMBOEX_SetExtendedStyle (hwnd, wParam, lParam);
     2368
     2369    case CBEM_SETIMAGELIST:
     2370        return COMBOEX_SetImageList (hwnd, wParam, lParam);
     2371
     2372    case CBEM_SETITEMA:
     2373        return COMBOEX_SetItemA (hwnd, wParam, lParam);
     2374
     2375    case CBEM_SETITEMW:
     2376        return COMBOEX_SetItemW (hwnd, wParam, lParam);
     2377
     2378    case CBEM_SETUNICODEFORMAT:
     2379        return COMBOEX_SetUnicodeFormat (hwnd, wParam, lParam);
    23792380
    23802381
    23812382/*   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);
     2383    case CB_GETDROPPEDCONTROLRECT:
     2384    case CB_GETITEMHEIGHT:
     2385    case CB_GETLBTEXT:
     2386    case CB_GETLBTEXTLEN:
     2387    case CB_GETEXTENDEDUI:
     2388    case CB_LIMITTEXT:
     2389    case CB_RESETCONTENT:
     2390    case CB_SELECTSTRING:
     2391    case WM_SETTEXT:
     2392    case WM_GETTEXT:
     2393        FIXME("(0x%x 0x%x 0x%lx): possibly missing function\n",
     2394          uMsg, wParam, lParam);
     2395        return COMBOEX_Forward (hwnd, uMsg, wParam, lParam);
    23952396
    23962397/*   Combo messages OK to just forward to the regular COMBO */
    2397         case CB_GETCOUNT:       
    2398         case CB_GETCURSEL:
    2399         case CB_GETDROPPEDSTATE:
     2398    case CB_GETCOUNT:
     2399    case CB_GETCURSEL:
     2400    case CB_GETDROPPEDSTATE:
    24002401        case CB_SETDROPPEDWIDTH:
    24012402        case CB_SETEXTENDEDUI:
    24022403        case CB_SHOWDROPDOWN:
    2403             return COMBOEX_Forward (hwnd, uMsg, wParam, lParam);
     2404        return COMBOEX_Forward (hwnd, uMsg, wParam, lParam);
    24042405
    24052406/*   Combo messages we need to process specially */
    24062407        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);
     2408        return COMBOEX_FindStringExact (COMBOEX_GetInfoPtr (hwnd),
     2409                        wParam, lParam);
     2410
     2411    case CB_GETITEMDATA:
     2412        return COMBOEX_GetItemData (hwnd, wParam, lParam);
     2413
     2414    case CB_SETCURSEL:
     2415        return COMBOEX_SetCursel (hwnd, wParam, lParam);
     2416
     2417    case CB_SETITEMDATA:
     2418        return COMBOEX_SetItemData (hwnd, wParam, lParam);
     2419
     2420    case CB_SETITEMHEIGHT:
     2421        return COMBOEX_SetItemHeight (hwnd, wParam, lParam);
    24212422
    24222423
    24232424
    24242425/*   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);
     2426    case WM_COMMAND:
     2427        return COMBOEX_Command (hwnd, wParam, lParam);
     2428
     2429    case WM_NOTIFY:
     2430        if (infoPtr->NtfUnicode)
     2431        return SendMessageW (GetParent (hwnd),
     2432                     uMsg, wParam, lParam);
     2433        else
     2434        return SendMessageA (GetParent (hwnd),
     2435                     uMsg, wParam, lParam);
    24352436
    24362437
    24372438/*   Window messages we need to process */
    24382439        case WM_DELETEITEM:
    2439             return COMBOEX_WM_DeleteItem (hwnd, wParam, lParam);
     2440        return COMBOEX_WM_DeleteItem (hwnd, wParam, lParam);
    24402441
    24412442        case WM_DRAWITEM:
    24422443            return COMBOEX_DrawItem (hwnd, wParam, lParam);
    24432444
    2444         case WM_DESTROY:
    2445             return COMBOEX_Destroy (hwnd, wParam, lParam);
     2445    case WM_DESTROY:
     2446        return COMBOEX_Destroy (hwnd, wParam, lParam);
    24462447
    24472448        case WM_MEASUREITEM:
     
    24492450
    24502451        case WM_NOTIFYFORMAT:
    2451             return COMBOEX_NotifyFormat (hwnd, wParam, lParam);
    2452 
    2453         case WM_SIZE:
    2454             return COMBOEX_Size (hwnd, wParam, lParam);
     2452        return COMBOEX_NotifyFormat (hwnd, wParam, lParam);
     2453
     2454    case WM_SIZE:
     2455        return COMBOEX_Size (hwnd, wParam, lParam);
    24552456
    24562457        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);
     2458        return COMBOEX_WindowPosChanging (hwnd, wParam, lParam);
     2459
     2460    default:
     2461        if (uMsg >= WM_USER)
     2462        ERR("unknown msg %04x wp=%08x lp=%08lx\n",
     2463             uMsg, wParam, lParam);
    24632464#ifdef __WIN32OS2__
    24642465            return defComCtl32ProcA (hwnd, uMsg, wParam, lParam);
    24652466#else
    2466             return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     2467        return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    24672468#endif
    24682469    }
     
    24842485    wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
    24852486    wndClass.lpszClassName = WC_COMBOBOXEXA;
    2486  
     2487
    24872488    RegisterClassA (&wndClass);
    24882489
  • trunk/src/comctl32/comctl32.c

    r5416 r6644  
    1 /*             
     1/* $Id: comctl32.c,v 1.18 2001-09-05 12:04:56 bird Exp $ */
     2/*
    23 * Common controls functions
    34 *
     
    99100
    100101    switch (fdwReason) {
    101         case DLL_PROCESS_ATTACH:
     102    case DLL_PROCESS_ATTACH:
    102103            COMCTL32_hModule = (HMODULE)hinstDLL;
    103104
     
    130131            break;
    131132
    132         case DLL_PROCESS_DETACH:
     133    case DLL_PROCESS_DETACH:
    133134            /* unregister all common control classes */
    134135            ANIMATE_Unregister ();
     
    204205VOID WINAPI
    205206MenuHelp (UINT uMsg, WPARAM wParam, LPARAM lParam, HMENU hMainMenu,
    206           HINSTANCE hInst, HWND hwndStatus, LPUINT lpwIDs)
     207      HINSTANCE hInst, HWND hwndStatus, LPUINT lpwIDs)
    207208{
    208209    UINT uMenuID = 0;
    209210
    210211    if (!IsWindow (hwndStatus))
    211         return;
     212    return;
    212213
    213214    switch (uMsg) {
    214         case WM_MENUSELECT:
    215             TRACE("WM_MENUSELECT wParam=0x%X lParam=0x%lX\n",
    216                    wParam, lParam);
     215    case WM_MENUSELECT:
     216        TRACE("WM_MENUSELECT wParam=0x%X lParam=0x%lX\n",
     217           wParam, lParam);
    217218
    218219            if ((HIWORD(wParam) == 0xFFFF) && (lParam == 0)) {
    219220                /* menu was closed */
    220                 TRACE("menu was closed!\n");
     221        TRACE("menu was closed!\n");
    221222                SendMessageA (hwndStatus, SB_SIMPLE, FALSE, 0);
    222223            }
    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;
     224        else {
     225        /* menu item was selected */
     226        if (HIWORD(wParam) & MF_POPUP)
     227            uMenuID = (UINT)*(lpwIDs+1);
     228        else
     229            uMenuID = (UINT)LOWORD(wParam);
     230        TRACE("uMenuID = %u\n", uMenuID);
     231
     232        if (uMenuID) {
     233            CHAR szText[256];
     234
     235            if (!LoadStringA (hInst, uMenuID, szText, 256))
     236            szText[0] = '\0';
     237
     238            SendMessageA (hwndStatus, SB_SETTEXTA,
     239                    255 | SBT_NOBORDERS, (LPARAM)szText);
     240            SendMessageA (hwndStatus, SB_SIMPLE, TRUE, 0);
     241        }
     242        }
     243        break;
    243244
    244245        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
     246        TRACE("WM_COMMAND wParam=0x%X lParam=0x%lX\n",
     247           wParam, lParam);
     248        /* WM_COMMAND is not invalid since it is documented
     249         * in the windows api reference. So don't output
    249250             * any FIXME for WM_COMMAND
    250251             */
    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] 
     252        WARN("We don't care about the WM_COMMAND\n");
     253        break;
     254
     255    default:
     256        FIXME("Invalid Message 0x%x!\n", uMsg);
     257        break;
     258    }
     259}
     260
     261
     262/***********************************************************************
     263 * ShowHideMenuCtl [COMCTL32.3]
    263264 *
    264265 * Shows or hides controls and updates the corresponding menu item.
     
    297298
    298299    if (lpInfo == NULL)
    299         return FALSE;
     300    return FALSE;
    300301
    301302    if (!(lpInfo[0]) || !(lpInfo[1]))
    302         return FALSE;
     303    return FALSE;
    303304
    304305    /* search for control */
    305306    lpMenuId = &lpInfo[2];
    306307    while (*lpMenuId != uFlags)
    307         lpMenuId += 2;
     308    lpMenuId += 2;
    308309
    309310    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);
     311    /* uncheck menu item */
     312    CheckMenuItem (lpInfo[0], *lpMenuId, MF_BYCOMMAND | MF_UNCHECKED);
     313
     314    /* hide control */
     315    lpMenuId++;
     316    SetWindowPos (GetDlgItem (hwnd, *lpMenuId), 0, 0, 0, 0, 0,
     317            SWP_HIDEWINDOW);
    317318    }
    318319    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);
     320    /* check menu item */
     321    CheckMenuItem (lpInfo[0], *lpMenuId, MF_BYCOMMAND | MF_CHECKED);
     322
     323    /* show control */
     324    lpMenuId++;
     325    SetWindowPos (GetDlgItem (hwnd, *lpMenuId), 0, 0, 0, 0, 0,
     326            SWP_SHOWWINDOW);
    326327    }
    327328
     
    357358
    358359    TRACE("(0x%08lx 0x%08lx 0x%08lx)\n",
    359            (DWORD)hwnd, (DWORD)lpRect, (DWORD)lpInfo);
     360       (DWORD)hwnd, (DWORD)lpRect, (DWORD)lpInfo);
    360361
    361362    GetClientRect (hwnd, lpRect);
     
    363364
    364365    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++;
     366    lpRun += 2;
     367    if (*lpRun == 0)
     368        return;
     369    lpRun++;
     370    hwndCtrl = GetDlgItem (hwnd, *lpRun);
     371    if (GetWindowLongA (hwndCtrl, GWL_STYLE) & WS_VISIBLE) {
     372        TRACE("control id 0x%x\n", *lpRun);
     373        GetWindowRect (hwndCtrl, &rcCtrl);
     374        MapWindowPoints ((HWND)0, hwnd, (LPPOINT)&rcCtrl, 2);
     375        SubtractRect (lpRect, lpRect, &rcCtrl);
     376    }
     377    lpRun++;
    377378    } while (*lpRun);
    378379}
     
    416417      r.left += 3;
    417418      DrawTextA (hdc, text, lstrlenA(text),
    418                    &r, DT_LEFT|DT_VCENTER|DT_SINGLELINE); 
     419           &r, DT_LEFT|DT_VCENTER|DT_SINGLELINE);
    419420      if (oldbkmode != TRANSPARENT)
    420         SetBkMode(hdc, oldbkmode);
     421    SetBkMode(hdc, oldbkmode);
    421422    }
    422423}
     
    466467CreateStatusWindowA (INT style, LPCSTR text, HWND parent, UINT wid)
    467468{
    468     return CreateWindowA(STATUSCLASSNAMEA, text, style, 
    469                            CW_USEDEFAULT, CW_USEDEFAULT,
    470                            CW_USEDEFAULT, CW_USEDEFAULT,
    471                            parent, wid, 0, 0);
     469    return CreateWindowA(STATUSCLASSNAMEA, text, style,
     470               CW_USEDEFAULT, CW_USEDEFAULT,
     471               CW_USEDEFAULT, CW_USEDEFAULT,
     472               parent, wid, 0, 0);
    472473}
    473474
     
    491492{
    492493    return CreateWindowW(STATUSCLASSNAMEW, text, style,
    493                            CW_USEDEFAULT, CW_USEDEFAULT,
    494                            CW_USEDEFAULT, CW_USEDEFAULT,
    495                            parent, wid, 0, 0);
     494               CW_USEDEFAULT, CW_USEDEFAULT,
     495               CW_USEDEFAULT, CW_USEDEFAULT,
     496               parent, wid, 0, 0);
    496497}
    497498
     
    521522HWND WINAPI
    522523CreateUpDownControl (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)
     524             HWND parent, INT id, HINSTANCE inst,
     525             HWND buddy, INT maxVal, INT minVal, INT curVal)
    525526{
    526527    HWND hUD =
    527         CreateWindowA (UPDOWN_CLASSA, 0, style, x, y, cx, cy,
    528                         parent, id, inst, 0);
     528    CreateWindowA (UPDOWN_CLASSA, 0, style, x, y, cx, cy,
     529            parent, id, inst, 0);
    529530    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));     
     531    SendMessageA (hUD, UDM_SETBUDDY, buddy, 0);
     532    SendMessageA (hUD, UDM_SETRANGE, 0, MAKELONG(maxVal, minVal));
     533    SendMessageA (hUD, UDM_SETPOS, 0, MAKELONG(curVal, 0));
    533534    }
    534535
     
    584585
    585586    if (!lpInitCtrls)
    586         return FALSE;
     587    return FALSE;
    587588    if (lpInitCtrls->dwSize != sizeof(INITCOMMONCONTROLSEX))
    588         return FALSE;
     589    return FALSE;
    589590
    590591    TRACE("(0x%08lx)\n", lpInitCtrls->dwICC);
    591592
    592593    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         }
     594    dwMask = 1 << cCount;
     595    if (!(lpInitCtrls->dwICC & dwMask))
     596        continue;
     597
     598    switch (lpInitCtrls->dwICC & dwMask) {
     599        /* dummy initialization */
     600        case ICC_ANIMATE_CLASS:
     601        case ICC_BAR_CLASSES:
     602        case ICC_LISTVIEW_CLASSES:
     603        case ICC_TREEVIEW_CLASSES:
     604        case ICC_TAB_CLASSES:
     605        case ICC_UPDOWN_CLASS:
     606        case ICC_PROGRESS_CLASS:
     607        case ICC_HOTKEY_CLASS:
     608        break;
     609
     610        /* advanced classes - not included in Win95 */
     611        case ICC_DATE_CLASSES:
     612        MONTHCAL_Register ();
     613        DATETIME_Register ();
     614        break;
     615
     616        case ICC_USEREX_CLASSES:
     617        COMBOEX_Register ();
     618        break;
     619
     620        case ICC_COOL_CLASSES:
     621        REBAR_Register ();
     622        break;
     623
     624        case ICC_INTERNET_CLASSES:
     625        IPADDRESS_Register ();
     626        break;
     627
     628        case ICC_PAGESCROLLER_CLASS:
     629        PAGER_Register ();
     630        break;
     631
     632        case ICC_NATIVEFNTCTL_CLASS:
     633        NATIVEFONT_Register ();
     634        break;
     635
     636        default:
     637        FIXME("Unknown class! dwICC=0x%lX\n", dwMask);
     638        break;
     639    }
    639640    }
    640641
     
    681682    hwndTB =
    682683        CreateWindowExA (0, TOOLBARCLASSNAMEA, "", style|WS_CHILD, 0, 0, 0, 0,
    683                            hwnd, (HMENU)wID, 0, NULL);
     684               hwnd, (HMENU)wID, 0, NULL);
    684685    if(hwndTB) {
    685         TBADDBITMAP tbab;
     686    TBADDBITMAP tbab;
    686687
    687688        SendMessageA (hwndTB, TB_BUTTONSTRUCTSIZE,
    688                         (WPARAM)uStructSize, 0);
     689            (WPARAM)uStructSize, 0);
    689690
    690691       /* set bitmap and button size */
     
    705706
    706707
    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);
     708    /* add bitmaps */
     709    if (nBitmaps > 0)
     710    {
     711    tbab.hInst = hBMInst;
     712    tbab.nID   = wBMID;
     713
     714    SendMessageA (hwndTB, TB_ADDBITMAP,
     715            (WPARAM)nBitmaps, (LPARAM)&tbab);
     716    }
     717    /* add buttons */
     718    if(iNumButtons > 0)
     719    SendMessageA (hwndTB, TB_ADDBUTTONSA,
     720            (WPARAM)iNumButtons, (LPARAM)lpButtons);
    720721    }
    721722
     
    741742HBITMAP WINAPI
    742743CreateMappedBitmap (HINSTANCE hInstance, INT idBitmap, UINT wFlags,
    743                     LPCOLORMAP lpColorMap, INT iNumMaps)
     744            LPCOLORMAP lpColorMap, INT iNumMaps)
    744745{
    745746    HGLOBAL hglb;
     
    754755    COLORREF cRef;
    755756    COLORMAP internalColorMap[4] =
    756         {{0x000000, 0}, {0x808080, 0}, {0xC0C0C0, 0}, {0xFFFFFF, 0}};
     757    {{0x000000, 0}, {0x808080, 0}, {0xC0C0C0, 0}, {0xFFFFFF, 0}};
    757758
    758759    /* initialize pointer to colortable and default color table */
    759760    if (lpColorMap) {
    760         iMaps = iNumMaps;
    761         sysColorMap = lpColorMap;
     761    iMaps = iNumMaps;
     762    sysColorMap = lpColorMap;
    762763    }
    763764    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;
     765    internalColorMap[0].to = GetSysColor (COLOR_BTNTEXT);
     766    internalColorMap[1].to = GetSysColor (COLOR_BTNSHADOW);
     767    internalColorMap[2].to = GetSysColor (COLOR_BTNFACE);
     768    internalColorMap[3].to = GetSysColor (COLOR_BTNHIGHLIGHT);
     769    iMaps = 4;
     770    sysColorMap = (LPCOLORMAP)internalColorMap;
    770771    }
    771772
    772773    hRsrc = FindResourceA (hInstance, (LPSTR)idBitmap, RT_BITMAPA);
    773774    if (hRsrc == 0)
    774         return 0;
     775    return 0;
    775776    hglb = LoadResource (hInstance, hRsrc);
    776777    if (hglb == 0)
    777         return 0;
     778    return 0;
    778779    lpBitmap = (LPBITMAPINFOHEADER)LockResource (hglb);
    779780    if (lpBitmap == NULL)
    780         return 0;
     781    return 0;
    781782
    782783    nColorTableSize = (1 << lpBitmap->biBitCount);
     
    784785    lpBitmapInfo = (LPBITMAPINFOHEADER)GlobalAlloc (GMEM_FIXED, nSize);
    785786    if (lpBitmapInfo == NULL)
    786         return 0;
     787    return 0;
    787788    RtlMoveMemory (lpBitmapInfo, lpBitmap, nSize);
    788789
     
    790791
    791792    for (iColor = 0; iColor < nColorTableSize; iColor++) {
    792         for (i = 0; i < iMaps; i++) {
     793    for (i = 0; i < iMaps; i++) {
    793794            cRef = RGB(pColorTable[iColor].rgbRed,
    794795                       pColorTable[iColor].rgbGreen,
    795796                       pColorTable[iColor].rgbBlue);
    796             if ( cRef  == sysColorMap[i].from) {
     797        if ( cRef  == sysColorMap[i].from) {
    797798#if 0
    798                 if (wFlags & CBS_MASKED) {
    799                     if (sysColorMap[i].to != COLOR_BTNTEXT)
    800                         pColorTable[iColor] = RGB(255, 255, 255);
    801                 }
    802                 else
     799        if (wFlags & CBS_MASKED) {
     800            if (sysColorMap[i].to != COLOR_BTNTEXT)
     801            pColorTable[iColor] = RGB(255, 255, 255);
     802        }
     803        else
    803804#endif
    804805                    pColorTable[iColor].rgbBlue  = GetBValue(sysColorMap[i].to);
    805806                    pColorTable[iColor].rgbGreen = GetGValue(sysColorMap[i].to);
    806807                    pColorTable[iColor].rgbRed   = GetRValue(sysColorMap[i].to);
    807                 break;
    808             }
    809         }
     808        break;
     809        }
     810    }
    810811    }
    811812    nWidth  = (INT)lpBitmapInfo->biWidth;
     
    814815    hbm = CreateCompatibleBitmap (hdcScreen, nWidth, nHeight);
    815816    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);
     817    HDC hdcDst = CreateCompatibleDC (hdcScreen);
     818    HBITMAP hbmOld = SelectObject (hdcDst, hbm);
     819    LPBYTE lpBits = (LPBYTE)(lpBitmap + 1);
     820    lpBits += (1 << (lpBitmapInfo->biBitCount)) * sizeof(RGBQUAD);
     821    StretchDIBits (hdcDst, 0, 0, nWidth, nHeight, 0, 0, nWidth, nHeight,
     822                 lpBits, (LPBITMAPINFO)lpBitmapInfo, DIB_RGB_COLORS,
     823                 SRCCOPY);
     824    SelectObject (hdcDst, hbmOld);
     825    DeleteDC (hdcDst);
    825826    }
    826827    ReleaseDC ((HWND)0, hdcScreen);
     
    855856HWND WINAPI
    856857CreateToolbar (HWND hwnd, DWORD style, UINT wID, INT nBitmaps,
    857                HINSTANCE hBMInst, UINT wBMID,
    858                LPCOLDTBBUTTON lpButtons,INT iNumButtons)
     858           HINSTANCE hBMInst, UINT wBMID,
     859           LPCOLDTBBUTTON lpButtons,INT iNumButtons)
    859860{
    860861    return CreateToolbarEx (hwnd, style | CCS_NODIVIDER, wID, nBitmaps,
    861                             hBMInst, wBMID, (LPCTBBUTTON)lpButtons,
    862                             iNumButtons, 0, 0, 0, 0, sizeof (OLDTBBUTTON));
     862                hBMInst, wBMID, (LPCTBBUTTON)lpButtons,
     863                iNumButtons, 0, 0, 0, 0, sizeof (OLDTBBUTTON));
    863864}
    864865
     
    885886    if (pdvi->cbSize != sizeof(DLLVERSIONINFO)) {
    886887        WARN("wrong DLLVERSIONINFO size from app");
    887         return E_INVALIDARG;
     888    return E_INVALIDARG;
    888889    }
    889890
     
    894895
    895896    TRACE("%lu.%lu.%lu.%lu\n",
    896            pdvi->dwMajorVersion, pdvi->dwMinorVersion,
    897            pdvi->dwBuildNumber, pdvi->dwPlatformID);
     897       pdvi->dwMajorVersion, pdvi->dwMinorVersion,
     898       pdvi->dwBuildNumber, pdvi->dwPlatformID);
    898899
    899900    return S_OK;
     
    901902
    902903/***********************************************************************
    903  *              DllInstall (COMCTL32.@)
     904 *      DllInstall (COMCTL32.@)
    904905 */
    905906HRESULT WINAPI COMCTL32_DllInstall(BOOL bInstall, LPCWSTR cmdline)
    906907{
    907   FIXME("(%s, %s): stub\n", bInstall?"TRUE":"FALSE", 
    908         debugstr_w(cmdline));
     908  FIXME("(%s, %s): stub\n", bInstall?"TRUE":"FALSE",
     909    debugstr_w(cmdline));
    909910
    910911  return S_OK;
     
    916917    POINT pos; /* center of hover rectangle */
    917918    INT iHoverTime; /* elapsed time the cursor has been inside of the hover rect */
    918 } _TRACKINGLIST; 
     919} _TRACKINGLIST;
    919920
    920921static _TRACKINGLIST TrackingList[10];
     
    955956        if(TrackingList[i].tme.dwFlags & TME_HOVER) {
    956957            /* add the timer interval to the hovering time */
    957             TrackingList[i].iHoverTime+=iTimerInterval; 
    958      
     958            TrackingList[i].iHoverTime+=iTimerInterval;
     959
    959960            /* has the cursor moved outside the rectangle centered around pos? */
    960961            if((abs(pos.x - TrackingList[i].pos.x) > (hoverwidth / 2.0))
     
    985986        }
    986987    }
    987        
     988
    988989    /* stop the timer if the tracking list is empty */
    989990    if(iTrackMax == 0) {
     
    10361037
    10371038    flags = ptme->dwFlags;
    1038    
     1039
    10391040    /* if HOVER_DEFAULT was specified replace this with the systems current value */
    10401041    if(ptme->dwHoverTime == HOVER_DEFAULT)
     
    10421043
    10431044    GetCursorPos(&pos);
    1044     hwnd = WindowFromPoint(pos);   
     1045    hwnd = WindowFromPoint(pos);
    10451046
    10461047    if ( flags & TME_CANCEL ) {
     
    10481049        cancel = 1;
    10491050    }
    1050    
     1051
    10511052    if ( flags & TME_HOVER  ) {
    10521053        flags &= ~ TME_HOVER;
    10531054        hover = 1;
    10541055    }
    1055    
     1056
    10561057    if ( flags & TME_LEAVE ) {
    10571058        flags &= ~ TME_LEAVE;
     
    10751076        else
    10761077            ptme->dwFlags = 0;
    1077    
     1078
    10781079        return TRUE; /* return here, TME_QUERY is retrieving information */
    10791080    }
     
    10981099            {
    10991100                TrackingList[i] = TrackingList[--iTrackMax];
    1100        
     1101
    11011102                if(iTrackMax == 0) {
    11021103                    KillTimer(0, timer);
     
    11191120                        TrackingList[i].tme.dwHoverTime = ptme->dwHoverTime;
    11201121                    }
    1121  
     1122
    11221123                    if(leave)
    11231124                        TrackingList[i].tme.dwFlags |= TME_LEAVE;
    11241125
    11251126                    /* reset iHoverTime as per winapi specs */
    1126                     TrackingList[i].iHoverTime = 0;                 
    1127  
     1127                    TrackingList[i].iHoverTime = 0;
     1128
    11281129                    return TRUE;
    11291130                }
    1130             }           
     1131            }
    11311132
    11321133            /* if the tracking list is full return FALSE */
     
    11981199
    11991200    hwndToolTip = CreateWindowExA(0, TOOLTIPS_CLASSA, NULL, 0,
    1200                                   CW_USEDEFAULT, CW_USEDEFAULT,
    1201                                   CW_USEDEFAULT, CW_USEDEFAULT, hwndOwner,
    1202                                   0, 0, 0);
     1201                  CW_USEDEFAULT, CW_USEDEFAULT,
     1202                  CW_USEDEFAULT, CW_USEDEFAULT, hwndOwner,
     1203                  0, 0, 0);
    12031204
    12041205    /* Send NM_TOOLTIPSCREATED notification */
    12051206    if (hwndToolTip)
    12061207    {
    1207         NMTOOLTIPSCREATED nmttc;
     1208    NMTOOLTIPSCREATED nmttc;
    12081209        /* true owner can be different if hwndOwner is a child window */
    12091210        HWND hwndTrueOwner = GetWindow(hwndToolTip, GW_OWNER);
    12101211        nmttc.hdr.hwndFrom = hwndTrueOwner;
    12111212        nmttc.hdr.idFrom = GetWindowLongA(hwndTrueOwner, GWL_ID);
    1212         nmttc.hdr.code = NM_TOOLTIPSCREATED;
    1213         nmttc.hwndToolTips = hwndToolTip;
     1213    nmttc.hdr.code = NM_TOOLTIPSCREATED;
     1214    nmttc.hwndToolTips = hwndToolTip;
    12141215
    12151216       SendMessageA(GetParent(hwndTrueOwner), WM_NOTIFY,
    12161217                    (WPARAM)GetWindowLongA(hwndTrueOwner, GWL_ID),
    1217                      (LPARAM)&nmttc);
     1218             (LPARAM)&nmttc);
    12181219    }
    12191220
  • trunk/src/comctl32/comctl32undoc.c

    r6380 r6644  
     1/* $Id: comctl32undoc.c,v 1.22 2001-09-05 12:04:57 bird Exp $ */
    12/*
    23 * Undocumented functions from COMCTL32.DLL
     
    9899
    99100    FIXME ("phDpa=%p loadProc=%p pStream=%p lParam=%lx\n",
    100            phDpa, loadProc, pStream, lParam);
     101       phDpa, loadProc, pStream, lParam);
    101102
    102103    if (!phDpa || !loadProc || !pStream)
    103         return E_INVALIDARG;
     104    return E_INVALIDARG;
    104105
    105106    *phDpa = (HDPA)NULL;
     
    110111    errCode = IStream_Seek (pStream, position, STREAM_SEEK_CUR, &newPosition);
    111112    if (errCode != S_OK)
    112         return errCode;
     113    return errCode;
    113114
    114115    errCode = IStream_Read (pStream, &streamData, sizeof(STREAMDATA), &ulRead);
    115116    if (errCode != S_OK)
    116         return errCode;
     117    return errCode;
    117118
    118119    FIXME ("dwSize=%lu dwData2=%lu dwItems=%lu\n",
    119            streamData.dwSize, streamData.dwData2, streamData.dwItems);
     120       streamData.dwSize, streamData.dwData2, streamData.dwItems);
    120121
    121122    if (lParam < sizeof(STREAMDATA) ||
    122         streamData.dwSize < sizeof(STREAMDATA) ||
    123         streamData.dwData2 < 1) {
    124         errCode = E_FAIL;
     123    streamData.dwSize < sizeof(STREAMDATA) ||
     124    streamData.dwData2 < 1) {
     125    errCode = E_FAIL;
    125126    }
    126127
     
    128129    hDpa = DPA_Create (streamData.dwItems);
    129130    if (!hDpa)
    130         return E_OUTOFMEMORY;
     131    return E_OUTOFMEMORY;
    131132
    132133    if (!DPA_Grow (hDpa, streamData.dwItems))
    133         return E_OUTOFMEMORY;
     134    return E_OUTOFMEMORY;
    134135
    135136    /* load data from the stream into the dpa */
     
    137138    for (loadData.nCount = 0; loadData.nCount < streamData.dwItems; loadData.nCount++) {
    138139        errCode = (loadProc)(&loadData, pStream, lParam);
    139         if (errCode != S_OK) {
    140             errCode = S_FALSE;
    141             break;
    142         }
    143 
    144         *ptr = loadData.ptr;
    145         ptr++;
     140    if (errCode != S_OK) {
     141        errCode = S_FALSE;
     142        break;
     143    }
     144
     145    *ptr = loadData.ptr;
     146    ptr++;
    146147    }
    147148
     
    177178
    178179    FIXME ("hDpa=%p loadProc=%p pStream=%p lParam=%lx\n",
    179            hDpa, loadProc, pStream, lParam);
     180       hDpa, loadProc, pStream, lParam);
    180181
    181182    return E_FAIL;
     
    200201BOOL WINAPI
    201202DPA_Merge (const HDPA hdpa1, const HDPA hdpa2, DWORD dwFlags,
    202            PFNDPACOMPARE pfnCompare, PFNDPAMERGE pfnMerge, LPARAM lParam)
     203       PFNDPACOMPARE pfnCompare, PFNDPAMERGE pfnMerge, LPARAM lParam)
    203204{
    204205    INT nCount;
     
    208209
    209210    TRACE("%p %p %08lx %p %p %08lx)\n",
    210            hdpa1, hdpa2, dwFlags, pfnCompare, pfnMerge, lParam);
     211       hdpa1, hdpa2, dwFlags, pfnCompare, pfnMerge, lParam);
    211212
    212213    if (IsBadWritePtr (hdpa1, sizeof(DPA)))
    213         return FALSE;
     214    return FALSE;
    214215
    215216    if (IsBadWritePtr (hdpa2, sizeof(DPA)))
    216         return FALSE;
     217    return FALSE;
    217218
    218219    if (IsBadCodePtr ((FARPROC)pfnCompare))
    219         return FALSE;
     220    return FALSE;
    220221
    221222    if (IsBadCodePtr ((FARPROC)pfnMerge))
    222         return FALSE;
     223    return FALSE;
    223224
    224225    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");
     226    TRACE("sorting dpa's!\n");
     227    if (hdpa1->nItemCount > 0)
     228    DPA_Sort (hdpa1, pfnCompare, lParam);
     229    TRACE ("dpa 1 sorted!\n");
     230    if (hdpa2->nItemCount > 0)
     231    DPA_Sort (hdpa2, pfnCompare, lParam);
     232    TRACE ("dpa 2 sorted!\n");
    232233    }
    233234
    234235    if (hdpa2->nItemCount < 1)
    235         return TRUE;
     236    return TRUE;
    236237
    237238    TRACE("hdpa1->nItemCount=%d hdpa2->nItemCount=%d\n",
    238            hdpa1->nItemCount, hdpa2->nItemCount);
     239       hdpa1->nItemCount, hdpa2->nItemCount);
    239240
    240241
     
    250251    {
    251252        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         }
     253    nResult = (pfnCompare)(*pWork1, *pWork2, lParam);
     254    TRACE("compare result=%d, dpa1.cnt=%d, dpa2.cnt=%d\n",
     255          nResult, nIndex, nCount);
     256
     257    if (nResult == 0)
     258    {
     259        PVOID ptr;
     260
     261        ptr = (pfnMerge)(1, *pWork1, *pWork2, lParam);
     262        if (!ptr)
     263        return FALSE;
     264
     265        nCount--;
     266        pWork2--;
     267        *pWork1 = ptr;
     268        nIndex--;
     269        pWork1--;
     270    }
     271    else if (nResult < 0)
     272    {
     273        if (!dwFlags & 8)
     274        {
     275        PVOID ptr;
     276
     277        ptr = DPA_DeletePtr (hdpa1, hdpa1->nItemCount - 1);
     278
     279        (pfnMerge)(2, ptr, NULL, lParam);
     280        }
     281        nIndex--;
     282        pWork1--;
     283    }
     284    else
     285    {
     286        if (!dwFlags & 4)
     287        {
     288        PVOID ptr;
     289
     290        ptr = (pfnMerge)(3, *pWork2, NULL, lParam);
     291        if (!ptr)
     292            return FALSE;
     293        DPA_InsertPtr (hdpa1, nIndex, ptr);
     294        }
     295        nCount--;
     296        pWork2--;
     297    }
    297298
    298299    }
     
    358359
    359360    if (lpSrc)
    360         lpDest = HeapReAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, lpSrc, dwSize);
     361    lpDest = HeapReAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, lpSrc, dwSize);
    361362    else
    362         lpDest = HeapAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, dwSize);
     363    lpDest = HeapAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, dwSize);
    363364
    364365    TRACE("-- ret=%p\n", lpDest);
     
    458459HANDLE WINAPI
    459460CreateMRUListLazyA (LPCREATEMRULIST lpcml, DWORD dwParam2,
    460                     DWORD dwParam3, DWORD dwParam4);
     461            DWORD dwParam3, DWORD dwParam4);
    461462
    462463
     
    490491#if 0
    491492    if (!(hmru->dwParam1 & 1001)) {
    492         RegSetValueExA (hmru->hKeyMRU, "MRUList", 0, REG_SZ,
    493                           hmru->lpszMRUString,
    494                           strlen (hmru->lpszMRUString));
     493    RegSetValueExA (hmru->hKeyMRU, "MRUList", 0, REG_SZ,
     494              hmru->lpszMRUString,
     495              strlen (hmru->lpszMRUString));
    495496    }
    496497
     
    506507/**************************************************************************
    507508 *              AddMRUData [COMCTL32.167]
    508  * 
     509 *
    509510 * Add item to MRU binary list.  If item already exists in list then it is
    510511 * simply moved up to the top of the list and not added again.  If list is
     
    530531/**************************************************************************
    531532 *              AddMRUStringA [COMCTL32.153]
    532  * 
     533 *
    533534 * Add item to MRU string list.  If item already exists in list them it is
    534535 * simply moved up to the top of the list and not added again.  If list is
     
    572573/**************************************************************************
    573574 *                  FindMRUData [COMCTL32.169]
    574  * 
     575 *
    575576 * Searches binary list for item that matches lpData of length cbData.
    576577 * Returns position in list order 0 -> MRU and if lpRegNum != NULL then value
     
    590591{
    591592    FIXME("(%08x, %p, %ld, %p) empty stub!\n",
    592            hList, lpData, cbData, lpRegNum);
     593       hList, lpData, cbData, lpRegNum);
    593594
    594595    return 0;
     
    597598/**************************************************************************
    598599 *                  FindMRUStringA [COMCTL32.155]
    599  * 
     600 *
    600601 * Searches string list for item that matches lpszString.
    601602 * Returns position in list order 0 -> MRU and if lpRegNum != NULL then value
     
    614615{
    615616    FIXME("(%08x, %s, %p) empty stub!\n", hList, debugstr_a(lpszString),
    616           lpRegNum);
     617      lpRegNum);
    617618
    618619    return 0;
     
    640641
    641642    if (lpcml == NULL)
    642         return 0;
     643    return 0;
    643644
    644645    if (lpcml->cbSize < sizeof(CREATEMRULIST))
    645         return 0;
     646    return 0;
    646647
    647648    FIXME("(%lu %lu %lx %lx \"%s\" %p)\n",
    648           lpcml->cbSize, lpcml->nMaxItems, lpcml->dwFlags,
    649           (DWORD)lpcml->hKey, lpcml->lpszSubKey, lpcml->lpfnCompare);
     649      lpcml->cbSize, lpcml->nMaxItems, lpcml->dwFlags,
     650      (DWORD)lpcml->hKey, lpcml->lpszSubKey, lpcml->lpfnCompare);
    650651
    651652    /* dummy pointer creation */
     
    659660/**************************************************************************
    660661 *                EnumMRUListA [COMCTL32.154]
    661  * 
     662 *
    662663 * Enumerate item in a list
    663664 *
     
    673674 *    of list returns -1.
    674675 *    If lpBuffer == NULL or nItemPos is -ve return value is no. of items in
    675  *    the list. 
     676 *    the list.
    676677 */
    677678INT WINAPI EnumMRUListA(HANDLE hList, INT nItemPos, LPVOID lpBuffer,
     
    679680{
    680681    FIXME("(%08x, %d, %p, %ld): stub\n", hList, nItemPos, lpBuffer,
    681           nBufferSize);
     682      nBufferSize);
    682683    return 0;
    683684}
     
    702703
    703704    if (!lpDest && lpSrc)
    704         return strlen (lpSrc);
     705    return strlen (lpSrc);
    705706
    706707    if (nMaxLen == 0)
    707         return 0;
     708    return 0;
    708709
    709710    if (lpSrc == NULL) {
    710         lpDest[0] = '\0';
    711         return 0;
     711    lpDest[0] = '\0';
     712    return 0;
    712713    }
    713714
    714715    len = strlen (lpSrc);
    715716    if (len >= nMaxLen)
    716         len = nMaxLen - 1;
     717    len = nMaxLen - 1;
    717718
    718719    RtlMoveMemory (lpDest, lpSrc, len);
     
    737738{
    738739    TRACE("(%p %p)\n", lppDest, lpSrc);
    739  
     740
    740741    if (lpSrc) {
    741         LPSTR ptr = COMCTL32_ReAlloc (*lppDest, strlen (lpSrc) + 1);
    742         if (!ptr)
    743             return FALSE;
    744         strcpy (ptr, lpSrc);
    745         *lppDest = ptr;
     742    LPSTR ptr = COMCTL32_ReAlloc (*lppDest, strlen (lpSrc) + 1);
     743    if (!ptr)
     744        return FALSE;
     745    strcpy (ptr, lpSrc);
     746    *lppDest = ptr;
    746747    }
    747748    else {
    748         if (*lppDest) {
    749             COMCTL32_Free (*lppDest);
    750             *lppDest = NULL;
    751         }
     749    if (*lppDest) {
     750        COMCTL32_Free (*lppDest);
     751        *lppDest = NULL;
     752    }
    752753    }
    753754
     
    775776
    776777    if (!lpDest && lpSrc)
    777         return strlenW (lpSrc);
     778    return strlenW (lpSrc);
    778779
    779780    if (nMaxLen == 0)
    780         return 0;
     781    return 0;
    781782
    782783    if (lpSrc == NULL) {
    783         lpDest[0] = L'\0';
    784         return 0;
     784    lpDest[0] = L'\0';
     785    return 0;
    785786    }
    786787
    787788    len = strlenW (lpSrc);
    788789    if (len >= nMaxLen)
    789         len = nMaxLen - 1;
     790    len = nMaxLen - 1;
    790791
    791792    RtlMoveMemory (lpDest, lpSrc, len*sizeof(WCHAR));
     
    810811{
    811812    TRACE("(%p %p)\n", lppDest, lpSrc);
    812  
     813
    813814    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;
     815    INT len = strlenW (lpSrc) + 1;
     816    LPWSTR ptr = COMCTL32_ReAlloc (*lppDest, len * sizeof(WCHAR));
     817    if (!ptr)
     818        return FALSE;
     819    strcpyW (ptr, lpSrc);
     820    *lppDest = ptr;
    820821    }
    821822    else {
    822         if (*lppDest) {
    823             COMCTL32_Free (*lppDest);
    824             *lppDest = NULL;
    825         }
     823    if (*lppDest) {
     824        COMCTL32_Free (*lppDest);
     825        *lppDest = NULL;
     826    }
    826827    }
    827828
     
    852853
    853854    if (!lpDest && lpSrc)
    854         return WideCharToMultiByte(CP_ACP, 0, lpSrc, -1, 0, 0, NULL, NULL);
     855    return WideCharToMultiByte(CP_ACP, 0, lpSrc, -1, 0, 0, NULL, NULL);
    855856
    856857    if (nMaxLen == 0)
    857         return 0;
     858    return 0;
    858859
    859860    if (lpSrc == NULL) {
    860         lpDest[0] = '\0';
    861         return 0;
     861    lpDest[0] = '\0';
     862    return 0;
    862863    }
    863864
    864865    len = WideCharToMultiByte(CP_ACP, 0, lpSrc, -1, 0, 0, NULL, NULL);
    865866    if (len >= nMaxLen)
    866         len = nMaxLen - 1;
     867    len = nMaxLen - 1;
    867868
    868869    WideCharToMultiByte(CP_ACP, 0, lpSrc, -1, lpDest, len, NULL, NULL);
     
    897898
    898899    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;
     900    INT len = MultiByteToWideChar(CP_ACP,0,lpSrc,-1,NULL,0);
     901    LPWSTR ptr = COMCTL32_ReAlloc (*lppDest, len*sizeof(WCHAR));
     902
     903    if (!ptr)
     904        return FALSE;
     905    MultiByteToWideChar(CP_ACP,0,lpSrc,-1,ptr,len);
     906    *lppDest = ptr;
    906907    }
    907908    else {
    908         if (*lppDest) {
    909             COMCTL32_Free (*lppDest);
    910             *lppDest = NULL;
    911         }
     909    if (*lppDest) {
     910        COMCTL32_Free (*lppDest);
     911        *lppDest = NULL;
     912    }
    912913    }
    913914
     
    944945    if (hdsa)
    945946    {
    946         hdsa->nItemCount = 0;
     947    hdsa->nItemCount = 0;
    947948        hdsa->pData = NULL;
    948         hdsa->nMaxCount = 0;
    949         hdsa->nItemSize = nSize;
    950         hdsa->nGrow = max(1, nGrow);
     949    hdsa->nMaxCount = 0;
     950    hdsa->nItemSize = nSize;
     951    hdsa->nGrow = max(1, nGrow);
    951952    }
    952953
     
    972973
    973974    if (!hdsa)
    974         return FALSE;
     975    return FALSE;
    975976
    976977    if (hdsa->pData && (!COMCTL32_Free (hdsa->pData)))
    977         return FALSE;
     978    return FALSE;
    978979
    979980    return COMCTL32_Free (hdsa);
     
    982983
    983984/**************************************************************************
    984  * DSA_GetItem [COMCTL32.322] 
     985 * DSA_GetItem [COMCTL32.322]
    985986 *
    986987 * PARAMS
     
    10001001
    10011002    TRACE("(%p %d %p)\n", hdsa, nIndex, pDest);
    1002    
     1003
    10031004    if (!hdsa)
    1004         return FALSE;
     1005    return FALSE;
    10051006    if ((nIndex < 0) || (nIndex >= hdsa->nItemCount))
    1006         return FALSE;
     1007    return FALSE;
    10071008
    10081009    pSrc = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
     
    10141015
    10151016/**************************************************************************
    1016  * DSA_GetItemPtr [COMCTL32.323] 
     1017 * DSA_GetItemPtr [COMCTL32.323]
    10171018 *
    10181019 * Retrieves a pointer to the specified item.
     
    10351036
    10361037    if (!hdsa)
    1037         return NULL;
     1038    return NULL;
    10381039    if ((nIndex < 0) || (nIndex >= hdsa->nItemCount))
    1039         return NULL;
     1040    return NULL;
    10401041
    10411042    pSrc = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
    1042    
     1043
    10431044    TRACE("-- ret=%p\n", pSrc);
    10441045
     
    10481049
    10491050/**************************************************************************
    1050  * DSA_SetItem [COMCTL32.325] 
     1051 * DSA_SetItem [COMCTL32.325]
    10511052 *
    10521053 * Sets the contents of an item in the array.
     
    10671068    INT  nSize, nNewItems;
    10681069    LPVOID pDest, lpTemp;
    1069    
     1070
    10701071    TRACE("(%p %d %p)\n", hdsa, nIndex, pSrc);
    10711072
    10721073    if ((!hdsa) || nIndex < 0)
    1073         return FALSE;
    1074      
     1074    return FALSE;
     1075
    10751076    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         }   
     1077    /* within the old array */
     1078    if (hdsa->nMaxCount > nIndex) {
     1079        /* within the allocated space, set a new boundary */
     1080        hdsa->nItemCount = nIndex + 1;
     1081    }
     1082    else {
     1083        /* resize the block of memory */
     1084        nNewItems =
     1085        hdsa->nGrow * ((INT)(((nIndex + 1) - 1) / hdsa->nGrow) + 1);
     1086        nSize = hdsa->nItemSize * nNewItems;
     1087
     1088        lpTemp = (LPVOID)COMCTL32_ReAlloc (hdsa->pData, nSize);
     1089        if (!lpTemp)
     1090        return FALSE;
     1091
     1092        hdsa->nMaxCount = nNewItems;
     1093        hdsa->nItemCount = nIndex + 1;
     1094        hdsa->pData = lpTemp;
     1095    }
    10951096    }
    10961097
     
    10981099    pDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
    10991100    TRACE("-- move dest=%p src=%p size=%d\n",
    1100            pDest, pSrc, hdsa->nItemSize);
     1101       pDest, pSrc, hdsa->nItemSize);
    11011102    memmove (pDest, pSrc, hdsa->nItemSize);
    11021103
     
    11061107
    11071108/**************************************************************************
    1108  * DSA_InsertItem [COMCTL32.324] 
     1109 * DSA_InsertItem [COMCTL32.324]
    11091110 *
    11101111 * PARAMS
     
    11241125    LPVOID  lpTemp, lpDest;
    11251126    LPDWORD p;
    1126    
     1127
    11271128    TRACE("(%p %d %p)\n", hdsa, nIndex, pSrc);
    11281129
    11291130    if ((!hdsa) || nIndex < 0)
    1130         return -1;
     1131    return -1;
    11311132
    11321133    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    
     1134    p = *(DWORD**)((char *) pSrc + i);
     1135    if (IsBadStringPtrA ((char*)p, 256))
     1136        TRACE("-- %d=%p\n", i, (DWORD*)p);
     1137    else
     1138        TRACE("-- %d=%p [%s]\n", i, p, debugstr_a((char*)p));
     1139    }
     1140
    11401141    /* when nIndex >= nItemCount then append */
    11411142    if (nIndex >= hdsa->nItemCount)
    1142         nIndex = hdsa->nItemCount;
     1143    nIndex = hdsa->nItemCount;
    11431144
    11441145    /* do we need to resize ? */
    11451146    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;         
     1147    nNewItems = hdsa->nMaxCount + hdsa->nGrow;
     1148    nSize = hdsa->nItemSize * nNewItems;
     1149
     1150    lpTemp = (LPVOID)COMCTL32_ReAlloc (hdsa->pData, nSize);
     1151    if (!lpTemp)
     1152        return -1;
     1153
     1154    hdsa->nMaxCount = nNewItems;
     1155    hdsa->pData = lpTemp;
    11551156    }
    11561157
    11571158    /* do we need to move elements ? */
    11581159    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);
     1160    lpTemp = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
     1161    lpDest = (char *) lpTemp + hdsa->nItemSize;
     1162    nSize = (hdsa->nItemCount - nIndex) * hdsa->nItemSize;
     1163    TRACE("-- move dest=%p src=%p size=%d\n",
     1164           lpDest, lpTemp, nSize);
     1165    memmove (lpDest, lpTemp, nSize);
    11651166    }
    11661167
     
    11691170    lpDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
    11701171    TRACE("-- move dest=%p src=%p size=%d\n",
    1171            lpDest, pSrc, hdsa->nItemSize);
     1172       lpDest, pSrc, hdsa->nItemSize);
    11721173    memmove (lpDest, pSrc, hdsa->nItemSize);
    11731174
     
    11771178
    11781179/**************************************************************************
    1179  * DSA_DeleteItem [COMCTL32.326] 
     1180 * DSA_DeleteItem [COMCTL32.326]
    11801181 *
    11811182 * PARAMS
     
    11931194    LPVOID lpDest,lpSrc;
    11941195    INT  nSize;
    1195    
     1196
    11961197    TRACE("(%p %d)\n", hdsa, nIndex);
    11971198
    11981199    if (!hdsa)
    1199         return -1;
     1200    return -1;
    12001201    if (nIndex < 0 || nIndex >= hdsa->nItemCount)
    1201         return -1;
     1202    return -1;
    12021203
    12031204    /* do we need to move ? */
    12041205    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    
     1206    lpDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
     1207    lpSrc = (char *) lpDest + hdsa->nItemSize;
     1208    nSize = hdsa->nItemSize * (hdsa->nItemCount - nIndex - 1);
     1209    TRACE("-- move dest=%p src=%p size=%d\n",
     1210           lpDest, lpSrc, nSize);
     1211    memmove (lpDest, lpSrc, nSize);
     1212    }
     1213
    12131214    hdsa->nItemCount--;
    1214    
     1215
    12151216    /* free memory ? */
    12161217    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;
     1218    nSize = hdsa->nItemSize * hdsa->nItemCount;
     1219
     1220    lpDest = (LPVOID)COMCTL32_ReAlloc (hdsa->pData, nSize);
     1221    if (!lpDest)
     1222        return -1;
     1223
     1224    hdsa->nMaxCount = hdsa->nItemCount;
     1225    hdsa->pData = lpDest;
    12251226    }
    12261227
     
    12471248    TRACE("(%p)\n", hdsa);
    12481249
    1249     if (!hdsa) 
    1250         return FALSE;
     1250    if (!hdsa)
     1251    return FALSE;
    12511252    if (hdsa->pData && (!COMCTL32_Free (hdsa->pData)))
    1252         return FALSE;
     1253    return FALSE;
    12531254
    12541255    hdsa->nItemCount = 0;
     
    12851286    hdpa = (HDPA)COMCTL32_Alloc (sizeof(DPA));
    12861287    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));
     1288    hdpa->nGrow = max(8, nGrow);
     1289    hdpa->hHeap = COMCTL32_hHeap;
     1290    hdpa->nMaxCount = hdpa->nGrow * 2;
     1291    hdpa->ptrs =
     1292        (LPVOID*)COMCTL32_Alloc (hdpa->nMaxCount * sizeof(LPVOID));
    12921293    }
    12931294
     
    13151316
    13161317    if (!hdpa)
    1317         return FALSE;
     1318    return FALSE;
    13181319
    13191320    if (hdpa->ptrs && (!HeapFree (hdpa->hHeap, 0, hdpa->ptrs)))
    1320         return FALSE;
     1321    return FALSE;
    13211322
    13221323    return HeapFree (hdpa->hHeap, 0, hdpa);
     
    13441345
    13451346    if (!hdpa)
    1346         return FALSE;
     1347    return FALSE;
    13471348
    13481349    hdpa->nGrow = max(8, nGrow);
     
    13791380
    13801381    if (!hdpa)
    1381         return NULL;
     1382    return NULL;
    13821383
    13831384    TRACE("(%p %p)\n", hdpa, hdpaNew);
    13841385
    13851386    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;
     1387    /* create a new DPA */
     1388    hdpaTemp = (HDPA)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
     1389                    sizeof(DPA));
     1390    hdpaTemp->hHeap = hdpa->hHeap;
     1391    hdpaTemp->nGrow = hdpa->nGrow;
    13911392    }
    13921393    else
    1393         hdpaTemp = hdpaNew;
     1394    hdpaTemp = hdpaNew;
    13941395
    13951396    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;
     1397    /* remove old pointer array */
     1398    HeapFree (hdpaTemp->hHeap, 0, hdpaTemp->ptrs);
     1399    hdpaTemp->ptrs = NULL;
     1400    hdpaTemp->nItemCount = 0;
     1401    hdpaTemp->nMaxCount = 0;
    14011402    }
    14021403
    14031404    /* create a new pointer array */
    14041405    nNewItems = hdpaTemp->nGrow *
    1405                 ((INT)((hdpa->nItemCount - 1) / hdpaTemp->nGrow) + 1);
     1406        ((INT)((hdpa->nItemCount - 1) / hdpaTemp->nGrow) + 1);
    14061407    nSize = nNewItems * sizeof(LPVOID);
    14071408    hdpaTemp->ptrs =
    1408         (LPVOID*)HeapAlloc (hdpaTemp->hHeap, HEAP_ZERO_MEMORY, nSize);
     1409    (LPVOID*)HeapAlloc (hdpaTemp->hHeap, HEAP_ZERO_MEMORY, nSize);
    14091410    hdpaTemp->nMaxCount = nNewItems;
    14101411
     
    14121413    hdpaTemp->nItemCount = hdpa->nItemCount;
    14131414    memmove (hdpaTemp->ptrs, hdpa->ptrs,
    1414              hdpaTemp->nItemCount * sizeof(LPVOID));
     1415         hdpaTemp->nItemCount * sizeof(LPVOID));
    14151416
    14161417    return hdpaTemp;
     
    14381439
    14391440    if (!hdpa)
    1440         return NULL;
     1441    return NULL;
    14411442    if (!hdpa->ptrs) {
    1442         WARN("no pointer array.\n");
    1443         return NULL;
     1443    WARN("no pointer array.\n");
     1444    return NULL;
    14441445    }
    14451446    if ((i < 0) || (i >= hdpa->nItemCount)) {
    1446         WARN("not enough pointers in array (%d vs %d).\n",i,hdpa->nItemCount);
    1447         return NULL;
     1447    WARN("not enough pointers in array (%d vs %d).\n",i,hdpa->nItemCount);
     1448    return NULL;
    14481449    }
    14491450
     
    14741475
    14751476    if (!hdpa->ptrs)
    1476         return -1;
     1477    return -1;
    14771478
    14781479    for (i = 0; i < hdpa->nItemCount; i++) {
    1479         if (hdpa->ptrs[i] == p)
    1480             return i;
     1480    if (hdpa->ptrs[i] == p)
     1481        return i;
    14811482    }
    14821483
     
    15091510
    15101511    if ((!hdpa) || (i < 0))
    1511         return -1;
     1512    return -1;
    15121513
    15131514    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;
     1515    hdpa->ptrs =
     1516        (LPVOID*)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
     1517                2 * hdpa->nGrow * sizeof(LPVOID));
     1518    if (!hdpa->ptrs)
     1519        return -1;
     1520    hdpa->nMaxCount = hdpa->nGrow * 2;
    15201521        nIndex = 0;
    15211522    }
    15221523    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         }
     1524    if (hdpa->nItemCount >= hdpa->nMaxCount) {
     1525        TRACE("-- resizing\n");
     1526        nNewItems = hdpa->nMaxCount + hdpa->nGrow;
     1527        nSize = nNewItems * sizeof(LPVOID);
     1528
     1529        lpTemp = (LPVOID*)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
     1530                       hdpa->ptrs, nSize);
     1531        if (!lpTemp)
     1532        return -1;
     1533        hdpa->nMaxCount = nNewItems;
     1534        hdpa->ptrs = lpTemp;
     1535    }
     1536
     1537    if (i >= hdpa->nItemCount) {
     1538        nIndex = hdpa->nItemCount;
     1539        TRACE("-- appending at %d\n", nIndex);
     1540    }
     1541    else {
     1542        TRACE("-- inserting at %d\n", i);
     1543        lpTemp = hdpa->ptrs + i;
     1544        lpDest = lpTemp + 1;
     1545        nSize  = (hdpa->nItemCount - i) * sizeof(LPVOID);
     1546        TRACE("-- move dest=%p src=%p size=%x\n",
     1547           lpDest, lpTemp, nSize);
     1548        memmove (lpDest, lpTemp, nSize);
     1549        nIndex = i;
     1550    }
    15501551    }
    15511552
     
    15771578{
    15781579    LPVOID *lpTemp;
    1579    
     1580
    15801581    TRACE("(%p %d %p)\n", hdpa, i, p);
    15811582
    15821583    if ((!hdpa) || i < 0)
    1583         return FALSE;
    1584      
     1584    return FALSE;
     1585
    15851586    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         }   
     1587    /* within the old array */
     1588    if (hdpa->nMaxCount > i) {
     1589        /* within the allocated space, set a new boundary */
     1590        hdpa->nItemCount = i+1;
     1591    }
     1592    else {
     1593        /* resize the block of memory */
     1594        INT nNewItems =
     1595        hdpa->nGrow * ((INT)(((i+1) - 1) / hdpa->nGrow) + 1);
     1596        INT nSize = nNewItems * sizeof(LPVOID);
     1597
     1598        lpTemp = (LPVOID*)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
     1599                       hdpa->ptrs, nSize);
     1600        if (!lpTemp)
     1601        return FALSE;
     1602
     1603        hdpa->nItemCount = nNewItems;
     1604        hdpa->ptrs = lpTemp;
     1605    }
    16051606    }
    16061607
     
    16311632    LPVOID *lpDest, *lpSrc, lpTemp = NULL;
    16321633    INT  nSize;
    1633    
     1634
    16341635    TRACE("(%p %d)\n", hdpa, i);
    16351636
    16361637    if ((!hdpa) || i < 0 || i >= hdpa->nItemCount)
    1637         return NULL;
     1638    return NULL;
    16381639
    16391640    lpTemp = hdpa->ptrs[i];
     
    16411642    /* do we need to move ?*/
    16421643    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    
     1644    lpDest = hdpa->ptrs + i;
     1645    lpSrc = lpDest + 1;
     1646    nSize = (hdpa->nItemCount - i - 1) * sizeof(LPVOID);
     1647    TRACE("-- move dest=%p src=%p size=%x\n",
     1648           lpDest, lpSrc, nSize);
     1649    memmove (lpDest, lpSrc, nSize);
     1650    }
     1651
    16511652    hdpa->nItemCount --;
    1652    
     1653
    16531654    /* free memory ?*/
    16541655    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;         
     1656    INT nNewItems = max(hdpa->nGrow * 2, hdpa->nItemCount);
     1657    nSize = nNewItems * sizeof(LPVOID);
     1658    lpDest = (LPVOID)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
     1659                      hdpa->ptrs, nSize);
     1660    if (!lpDest)
     1661        return NULL;
     1662
     1663    hdpa->nMaxCount = nNewItems;
     1664    hdpa->ptrs = (LPVOID*)lpDest;
    16641665    }
    16651666
     
    16861687    TRACE("(%p)\n", hdpa);
    16871688
    1688     if (!hdpa) 
    1689         return FALSE;
     1689    if (!hdpa)
     1690    return FALSE;
    16901691
    16911692    if (hdpa->ptrs && (!HeapFree (hdpa->hHeap, 0, hdpa->ptrs)))
    1692         return FALSE;
     1693    return FALSE;
    16931694
    16941695    hdpa->nItemCount = 0;
    16951696    hdpa->nMaxCount = hdpa->nGrow * 2;
    16961697    hdpa->ptrs = (LPVOID*)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
    1697                                      hdpa->nMaxCount * sizeof(LPVOID));
     1698                     hdpa->nMaxCount * sizeof(LPVOID));
    16981699
    16991700    return TRUE;
     
    17191720static VOID
    17201721DPA_QuickSort (LPVOID *lpPtrs, INT l, INT r,
    1721                PFNDPACOMPARE pfnCompare, LPARAM lParam)
     1722           PFNDPACOMPARE pfnCompare, LPARAM lParam)
    17221723{
    17231724    INT m;
     
    17251726
    17261727    TRACE("l=%i r=%i\n", l, r);
    1727  
     1728
    17281729    if (l==r)    /* one element is always sorted */
    17291730        return;
    17301731    if (r<l)     /* oops, got it in the wrong order */
    1731         {
     1732    {
    17321733        DPA_QuickSort(lpPtrs, r, l, pfnCompare, lParam);
    17331734        return;
    1734         }
     1735    }
    17351736    m = (l+r)/2; /* divide by two */
    17361737    DPA_QuickSort(lpPtrs, l, m, pfnCompare, lParam);
     
    17381739
    17391740    /* join the two sides */
    1740     while( (l<=m) && (m<r) ) 
     1741    while( (l<=m) && (m<r) )
    17411742    {
    17421743        if(pfnCompare(lpPtrs[l],lpPtrs[m+1],lParam)>0)
     
    17721773{
    17731774    if (!hdpa || !pfnCompare)
    1774         return FALSE;
     1775    return FALSE;
    17751776
    17761777    TRACE("(%p %p 0x%lx)\n", hdpa, pfnCompare, lParam);
    17771778
    17781779    if ((hdpa->nItemCount > 1) && (hdpa->ptrs))
    1779         DPA_QuickSort (hdpa->ptrs, 0, hdpa->nItemCount - 1,
    1780                        pfnCompare, lParam);
     1780    DPA_QuickSort (hdpa->ptrs, 0, hdpa->nItemCount - 1,
     1781               pfnCompare, lParam);
    17811782
    17821783    return TRUE;
     
    18091810INT WINAPI
    18101811DPA_Search (const HDPA hdpa, LPVOID pFind, INT nStart,
    1811             PFNDPACOMPARE pfnCompare, LPARAM lParam, UINT uOptions)
     1812        PFNDPACOMPARE pfnCompare, LPARAM lParam, UINT uOptions)
    18121813{
    18131814    if (!hdpa || !pfnCompare || !pFind)
    1814         return -1;
     1815    return -1;
    18151816
    18161817    TRACE("(%p %p %d %p 0x%08lx 0x%08x)\n",
    1817            hdpa, pFind, nStart, pfnCompare, lParam, uOptions);
     1818       hdpa, pFind, nStart, pfnCompare, lParam, uOptions);
    18181819
    18191820    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         }
     1821    /* array is sorted --> use binary search */
     1822    INT l, r, x, n;
     1823    LPVOID *lpPtr;
     1824
     1825    TRACE("binary search\n");
     1826
     1827    l = (nStart == -1) ? 0 : nStart;
     1828    r = hdpa->nItemCount - 1;
     1829    lpPtr = hdpa->ptrs;
     1830    while (r >= l) {
     1831        x = (l + r) / 2;
     1832        n = (pfnCompare)(pFind, lpPtr[x], lParam);
     1833        if (n < 0)
     1834        r = x - 1;
     1835        else
     1836        l = x + 1;
     1837        if (n == 0) {
     1838        TRACE("-- ret=%d\n", n);
     1839        return n;
     1840        }
     1841    }
     1842
     1843    if (uOptions & DPAS_INSERTBEFORE) {
     1844        TRACE("-- ret=%d\n", r);
     1845        return r;
     1846    }
     1847
     1848    if (uOptions & DPAS_INSERTAFTER) {
     1849        TRACE("-- ret=%d\n", l);
     1850        return l;
     1851    }
    18511852    }
    18521853    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         }
     1854    /* array is not sorted --> use linear search */
     1855    LPVOID *lpPtr;
     1856    INT  nIndex;
     1857
     1858    TRACE("linear search\n");
     1859
     1860    nIndex = (nStart == -1)? 0 : nStart;
     1861    lpPtr = hdpa->ptrs;
     1862    for (; nIndex < hdpa->nItemCount; nIndex++) {
     1863        if ((pfnCompare)(pFind, lpPtr[nIndex], lParam) == 0) {
     1864        TRACE("-- ret=%d\n", nIndex);
     1865        return nIndex;
     1866        }
     1867    }
    18671868    }
    18681869
     
    18941895
    18951896    if (hHeap)
    1896         hdpa = (HDPA)HeapAlloc (hHeap, HEAP_ZERO_MEMORY, sizeof(DPA));
     1897    hdpa = (HDPA)HeapAlloc (hHeap, HEAP_ZERO_MEMORY, sizeof(DPA));
    18971898    else
    1898         hdpa = (HDPA)COMCTL32_Alloc (sizeof(DPA));
     1899    hdpa = (HDPA)COMCTL32_Alloc (sizeof(DPA));
    18991900
    19001901    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));
     1902    hdpa->nGrow = min(8, nGrow);
     1903    hdpa->hHeap = hHeap ? hHeap : COMCTL32_hHeap;
     1904    hdpa->nMaxCount = hdpa->nGrow * 2;
     1905    hdpa->ptrs =
     1906        (LPVOID*)HeapAlloc (hHeap, HEAP_ZERO_MEMORY,
     1907                hdpa->nMaxCount * sizeof(LPVOID));
    19071908    }
    19081909
     
    19401941
    19411942    TRACE("(0x%04x 0x%04x %d %p 0x%08lx)\n",
    1942            lpNotify->hwndFrom, lpNotify->hwndTo, uCode, lpHdr,
    1943            lpNotify->dwParam5);
     1943       lpNotify->hwndFrom, lpNotify->hwndTo, uCode, lpHdr,
     1944       lpNotify->dwParam5);
    19441945
    19451946    if (!lpNotify->hwndTo)
    1946         return 0;
     1947    return 0;
    19471948
    19481949    if (lpNotify->hwndFrom == -1) {
    1949         lpNmh = lpHdr;
    1950         idFrom = lpHdr->idFrom;
     1950    lpNmh = lpHdr;
     1951    idFrom = lpHdr->idFrom;
    19511952    }
    19521953    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;
     1954    if (lpNotify->hwndFrom) {
     1955        HWND hwndParent = GetParent (lpNotify->hwndFrom);
     1956        if (hwndParent) {
     1957        hwndParent = GetWindow (lpNotify->hwndFrom, GW_OWNER);
     1958        if (hwndParent)
     1959            idFrom = GetDlgCtrlID (lpNotify->hwndFrom);
     1960        }
     1961    }
     1962
     1963    lpNmh = (lpHdr) ? lpHdr : &nmhdr;
     1964
     1965    lpNmh->hwndFrom = lpNotify->hwndFrom;
     1966    lpNmh->idFrom = idFrom;
     1967    lpNmh->code = uCode;
    19671968    }
    19681969
     
    19871988LRESULT WINAPI
    19881989COMCTL32_SendNotify (HWND hwndFrom, HWND hwndTo,
    1989                      UINT uCode, LPNMHDR lpHdr)
     1990             UINT uCode, LPNMHDR lpHdr)
    19901991{
    19911992    NOTIFYDATA notify;
    19921993
    19931994    TRACE("(0x%04x 0x%04x %d %p)\n",
    1994            hwndFrom, hwndTo, uCode, lpHdr);
     1995       hwndFrom, hwndTo, uCode, lpHdr);
    19951996
    19961997    notify.hwndFrom = hwndFrom;
     
    20202021LRESULT WINAPI
    20212022COMCTL32_SendNotifyEx (HWND hwndTo, HWND hwndFrom, UINT uCode,
    2022                        LPNMHDR lpHdr, DWORD dwParam5)
     2023               LPNMHDR lpHdr, DWORD dwParam5)
    20232024{
    20242025    NOTIFYDATA notify;
     
    20262027
    20272028    TRACE("(0x%04x 0x%04x %d %p 0x%08lx)\n",
    2028            hwndFrom, hwndTo, uCode, lpHdr, dwParam5);
     2029       hwndFrom, hwndTo, uCode, lpHdr, dwParam5);
    20292030
    20302031    hwndNotify = hwndTo;
    20312032    if (!hwndTo) {
    2032         if (IsWindow (hwndFrom)) {
    2033             hwndNotify = GetParent (hwndFrom);
    2034             if (!hwndNotify)
    2035                 return 0;
    2036         }
     2033    if (IsWindow (hwndFrom)) {
     2034        hwndNotify = GetParent (hwndFrom);
     2035        if (!hwndNotify)
     2036        return 0;
     2037    }
    20372038    }
    20382039
     
    20692070
    20702071    if (*lpStr2 == 0)
    2071         return ((LPSTR)lpStr1);
     2072    return ((LPSTR)lpStr1);
    20722073    len1 = 0;
    20732074    while (lpStr1[len1] != 0) ++len1;
     
    20752076    while (lpStr2[len2] != 0) ++len2;
    20762077    if (len2 == 0)
    2077         return ((LPSTR)(lpStr1 + len1));
     2078    return ((LPSTR)(lpStr1 + len1));
    20782079    first = tolower (*lpStr2);
    20792080    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);
     2081    if (tolower(*lpStr1) == first) {
     2082        for (i = 1; i < len2; ++i)
     2083        if (tolower (lpStr1[i]) != tolower(lpStr2[i]))
     2084            break;
     2085        if (i >= len2)
     2086        return ((LPSTR)lpStr1);
    20862087        }
    2087         ++lpStr1; --len1;
     2088    ++lpStr1; --len1;
    20882089    }
    20892090    return (NULL);
     
    21162117 *
    21172118 * 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 
    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.
    21532119 *
    21542120 * PARAMS
     
    21582124 *
    21592125 * RETURNS
     2126 *     none
     2127 */
     2128
     2129VOID WINAPI
     2130DPA_EnumCallback (const HDPA hdpa, DPAENUMPROC enumProc, LPARAM lParam)
     2131{
     2132    INT i;
     2133
     2134    TRACE("(%p %p %08lx)\n", hdpa, enumProc, lParam);
     2135
     2136    if (!hdpa)
     2137    return;
     2138    if (hdpa->nItemCount <= 0)
     2139    return;
     2140
     2141    for (i = 0; i < hdpa->nItemCount; i++) {
     2142    if ((enumProc)(hdpa->ptrs[i], lParam) == 0)
     2143        return;
     2144    }
     2145
     2146    return;
     2147}
     2148
     2149
     2150/**************************************************************************
     2151 * DPA_DestroyCallback [COMCTL32.386]
     2152 *
     2153 * Enumerates all items in a dynamic pointer array and destroys it.
     2154 *
     2155 * PARAMS
     2156 *     hdpa     [I] handle to the dynamic pointer array
     2157 *     enumProc [I]
     2158 *     lParam   [I]
     2159 *
     2160 * RETURNS
    21602161 *     Success: TRUE
    21612162 *     Failure: FALSE
     
    21952196
    21962197    if (!hdsa)
    2197         return;
     2198    return;
    21982199    if (hdsa->nItemCount <= 0)
    2199         return;
     2200    return;
    22002201
    22012202    for (i = 0; i < hdsa->nItemCount; i++) {
    2202         LPVOID lpItem = DSA_GetItemPtr (hdsa, i);
    2203         if ((enumProc)(lpItem, lParam) == 0)
    2204             return;
     2203    LPVOID lpItem = DSA_GetItemPtr (hdsa, i);
     2204    if ((enumProc)(lpItem, lParam) == 0)
     2205        return;
    22052206    }
    22062207
     
    23012302        if (dbcs && lpStart[1] != HIBYTE(wMatch)) continue;
    23022303        lpGotIt = lpStart;
    2303     }   
     2304    }
    23042305    return (LPSTR)lpGotIt;
    23052306}
     
    23552356    if( strchrW(lpSet, *(WORD*)lpLoop))
    23562357      return (INT)(lpLoop-lpStr);
    2357  
     2358
    23582359  return (INT)(lpLoop-lpStr);
    23592360}
     
    23992400
    24002401    if (IsWindow (hwnd) == FALSE)
    2401         return FALSE;
     2402    return FALSE;
    24022403
    24032404    if (b == 0)
    2404         return FALSE;
     2405    return FALSE;
    24052406
    24062407
  • trunk/src/comctl32/datetime.c

    r6470 r6644  
     1/* $Id: datetime.c,v 1.18 2001-09-05 12:04:57 bird Exp $ */
    12/*
    23 * Date and time picker control
     
    3435        COMCTL32_HEADER header;
    3536#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];
     37    HWND hMonthCal;
     38    HWND hUpdown;
     39    SYSTEMTIME date;
     40    BOOL dateValid;
     41    HWND hwndCheckbut;
     42    RECT rcClient; /* rect around the edge of the window */
     43    RECT rcDraw; /* rect inside of the border */
     44    RECT checkbox;  /* checkbox allowing the control to be enabled/disabled */
     45    RECT calbutton; /* button that toggles the dropdown of the monthcal control */
     46    BOOL bCalDepressed; /* TRUE = cal button is depressed */
     47    int  select;
     48    HFONT hFont;
     49    int nrFieldsAllocated;
     50    int nrFields;
     51    int haveFocus;
     52    int *fieldspec;
     53    RECT *fieldRect;
     54    int  *buflen;
     55    char textbuf[256];
    5556        POINT monthcal_pos;
    5657} DATETIME_INFO, *LPDATETIME_INFO;
     
    6162/* this list of defines is closely related to `allowedformatchars' defined
    6263 * in datetime.c; the high nibble indicates the `base type' of the format
    63  * specifier. 
     64 * specifier.
    6465 * Do not change without first reading DATETIME_UseFormat.
    65  * 
     66 *
    6667 */
    6768
    68 #define DT_END_FORMAT      0 
    69 #define ONEDIGITDAY     0x01
    70 #define TWODIGITDAY     0x02
    71 #define THREECHARDAY    0x03
     69#define DT_END_FORMAT      0
     70#define ONEDIGITDAY     0x01
     71#define TWODIGITDAY     0x02
     72#define THREECHARDAY    0x03
    7273#define FULLDAY         0x04
    7374#define ONEDIGIT12HOUR  0x11
     
    9495#define FORMATCALLBACK  0x81      /* -> maximum of 0x80 callbacks possible */
    9596#define FORMATCALLMASK  0x80
    96 #define DT_STRING       0x0100
     97#define DT_STRING   0x0100
    9798
    9899#define DTHT_DATEFIELD  0xff      /* for hit-testing */
    99100
    100101#define DTHT_NONE     0
    101 #define DTHT_CHECKBOX 0x200     /* these should end at '00' , to make */
     102#define DTHT_CHECKBOX 0x200 /* these should end at '00' , to make */
    102103#define DTHT_MCPOPUP  0x300     /* & DTHT_DATEFIELD 0 when DATETIME_KeyDown */
    103104#define DTHT_GOTFOCUS 0x400     /* tests for date-fields */
     
    126127  if (!lParam) return GDT_NONE;
    127128
    128   if ((dwStyle & DTS_SHOWNONE) && 
     129  if ((dwStyle & DTS_SHOWNONE) &&
    129130       (SendMessageA (infoPtr->hwndCheckbut, BM_GETCHECK, 0, 0)))
    130131        return GDT_NONE;
     
    145146  if (!lParam) return 0;
    146147
    147   if (lParam==GDT_VALID) 
    148         MONTHCAL_CopyTime (lprgSysTimeArray, &infoPtr->date);
     148  if (lParam==GDT_VALID)
     149    MONTHCAL_CopyTime (lprgSysTimeArray, &infoPtr->date);
    149150  if (lParam==GDT_NONE) {
    150         infoPtr->dateValid=FALSE;
     151    infoPtr->dateValid=FALSE;
    151152    SendMessageA (infoPtr->hwndCheckbut, BM_SETCHECK, 0, 0);
    152         }
     153    }
    153154  return 1;
    154155}
     
    228229
    229230
    230 /* 
    231    Split up a formattxt in actions. 
     231/*
     232   Split up a formattxt in actions.
    232233   See ms documentation for the meaning of the letter codes/'specifiers'.
    233234
    234    Notes: 
     235   Notes:
    235236   *'dddddd' is handled as 'dddd' plus 'dd'.
    236    *unrecognized formats are strings (here given the type DT_STRING; 
     237   *unrecognized formats are strings (here given the type DT_STRING;
    237238   start of the string is encoded in lower bits of DT_STRING.
    238239   Therefore, 'string' ends finally up as '<show seconds>tring'.
     
    241242
    242243
    243 static void 
     244static void
    244245DATETIME_UseFormat (DATETIME_INFO *infoPtr, const char *formattxt)
    245246{
     
    256257
    257258 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         }
     259    TRACE ("\n%d %c:",i, formattxt[i]);
     260    for (j=0; j<len; j++) {
     261        if (allowedformatchars[j]==formattxt[i]) {
     262            TRACE ("%c[%d,%x]",allowedformatchars[j], *nrFields,
     263                            infoPtr->fieldspec[*nrFields]);
     264            if ((*nrFields==0) && (infoPtr->fieldspec[*nrFields]==0)) {
     265                infoPtr->fieldspec[*nrFields]=(j<<4) +1;
     266                break;
     267            }
     268            if (infoPtr->fieldspec[*nrFields]>>4!=j) {
     269                (*nrFields)++;
     270                infoPtr->fieldspec[*nrFields]=(j<<4) +1;
     271                break;
     272            }
     273            if ((infoPtr->fieldspec[*nrFields] & 0x0f)==maxrepetition[j]) {
     274                (*nrFields)++;
     275                infoPtr->fieldspec[*nrFields]=(j<<4) +1;
     276                break;
     277            }
     278            infoPtr->fieldspec[*nrFields]++;
     279            break;
     280        }   /* if allowedformatchar */
     281    } /* for j */
     282
     283
     284            /* char is not a specifier: handle char like a string */
     285    if (j==len) {
     286        if ((*nrFields==0) && (infoPtr->fieldspec[*nrFields]==0)) {
     287            infoPtr->fieldspec[*nrFields]=DT_STRING+k;
     288            infoPtr->buflen[*nrFields]=0;
     289        } else
     290        if ((infoPtr->fieldspec[*nrFields] & DT_STRING)!=DT_STRING)  {
     291            (*nrFields)++;
     292            infoPtr->fieldspec[*nrFields]=DT_STRING+k;
     293            infoPtr->buflen[*nrFields]=0;
     294        }
     295        infoPtr->textbuf[k]=formattxt[i];
     296        k++;
     297        infoPtr->buflen[*nrFields]++;
     298    }   /* if j=len */
     299
     300    if (*nrFields==infoPtr->nrFieldsAllocated) {
     301        FIXME ("out of memory; should reallocate. crash ahead.\n");
     302    }
    302303
    303304  } /* for i */
     
    309310
    310311
    311 static LRESULT 
     312static LRESULT
    312313DATETIME_SetFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
    313314{
     
    318319 TRACE("%04x %08lx\n",wParam,lParam);
    319320 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;
     321    DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
     322
     323    if (dwStyle & DTS_LONGDATEFORMAT)
     324        format_item=LOCALE_SLONGDATE;
     325    else if (dwStyle & DTS_TIMEFORMAT)
     326        format_item=LOCALE_STIMEFORMAT;
    326327        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  }     
     328        format_item=LOCALE_SSHORTDATE;
     329    GetLocaleInfoA( GetSystemDefaultLCID(), format_item,format_buf,sizeof(format_buf));
     330    DATETIME_UseFormat (infoPtr, format_buf);
     331 }
    331332 else
    332         DATETIME_UseFormat (infoPtr, (char *) lParam);
     333    DATETIME_UseFormat (infoPtr, (char *) lParam);
    333334
    334335 return infoPtr->nrFields;
     
    336337
    337338
    338 static LRESULT 
     339static LRESULT
    339340DATETIME_SetFormatW (HWND hwnd, WPARAM wParam, LPARAM lParam)
    340341
     
    342343 TRACE("%04x %08lx\n",wParam,lParam);
    343344 if (lParam) {
    344         LPSTR buf;
    345         int retval;
     345    LPSTR buf;
     346    int retval;
    346347        int len = WideCharToMultiByte( CP_ACP, 0, (LPWSTR)lParam, -1, NULL, 0, NULL, NULL );
    347348
    348         buf = (LPSTR) COMCTL32_Alloc (len);
     349    buf = (LPSTR) COMCTL32_Alloc (len);
    349350        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  } 
     351    retval=DATETIME_SetFormat (hwnd, 0, (LPARAM) buf);
     352    COMCTL32_Free (buf);
     353    return retval;
     354 }
    354355 else
    355         return DATETIME_SetFormat (hwnd, 0, 0);
    356 
    357 }
    358 
    359 
    360 static void 
     356    return DATETIME_SetFormat (hwnd, 0, 0);
     357
     358}
     359
     360
     361static void
    361362DATETIME_ReturnTxt (DATETIME_INFO *infoPtr, int count, char *result)
    362363{
     
    368369 TRACE ("%d,%d\n", infoPtr->nrFields, count);
    369370 if ((count>infoPtr->nrFields) || (count<0)) {
    370         WARN ("buffer overrun, have %d want %d\n", infoPtr->nrFields, count);
    371         return;
     371    WARN ("buffer overrun, have %d want %d\n", infoPtr->nrFields, count);
     372    return;
    372373 }
    373374
    374375 if (!infoPtr->fieldspec) return;
    375  
     376
    376377 spec=infoPtr->fieldspec[count];
    377378 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;
     379    int txtlen=infoPtr->buflen[count];
     380
     381    strncpy (result, infoPtr->textbuf + (spec &~ DT_STRING), txtlen);
     382    result[txtlen]=0;
     383    TRACE ("arg%d=%x->[%s]\n",count,infoPtr->fieldspec[count],result);
     384    return;
    384385 }
    385386
    386                
     387
    387388 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,
     389    case DT_END_FORMAT:
     390        *result=0;
     391        break;
     392    case ONEDIGITDAY:
     393        sprintf (result,"%d",date.wDay);
     394        break;
     395    case TWODIGITDAY:
     396        sprintf (result,"%.2d",date.wDay);
     397        break;
     398    case THREECHARDAY:
     399            GetLocaleInfoA( LOCALE_USER_DEFAULT, LOCALE_SABBREVDAYNAME1+(date.wDayOfWeek+6)%7,
     400                result,4);
     401        /*sprintf (result,"%.3s",days[date.wDayOfWeek]);*/
     402        break;
     403    case FULLDAY:
     404            GetLocaleInfoA( LOCALE_USER_DEFAULT,LOCALE_SDAYNAME1+ (date.wDayOfWeek+6)%7,
     405                buffer,sizeof(buffer));
     406        strcpy  (result,buffer);
     407        break;
     408    case ONEDIGIT12HOUR:
     409        if (date.wHour>12)
     410            sprintf (result,"%d",date.wHour-12);
     411        else
     412            sprintf (result,"%d",date.wHour);
     413        break;
     414    case TWODIGIT12HOUR:
     415        if (date.wHour>12)
     416            sprintf (result,"%.2d",date.wHour-12);
     417        else
     418            sprintf (result,"%.2d",date.wHour);
     419        break;
     420    case ONEDIGIT24HOUR:
     421        sprintf (result,"%d",date.wHour);
     422        break;
     423    case TWODIGIT24HOUR:
     424        sprintf (result,"%.2d",date.wHour);
     425        break;
     426    case ONEDIGITSECOND:
     427        sprintf (result,"%d",date.wSecond);
     428        break;
     429    case TWODIGITSECOND:
     430        sprintf (result,"%.2d",date.wSecond);
     431        break;
     432    case ONEDIGITMINUTE:
     433        sprintf (result,"%d",date.wMinute);
     434        break;
     435    case TWODIGITMINUTE:
     436        sprintf (result,"%.2d",date.wMinute);
     437        break;
     438    case ONEDIGITMONTH:
     439        sprintf (result,"%d",date.wMonth);
     440        break;
     441    case TWODIGITMONTH:
     442        sprintf (result,"%.2d",date.wMonth);
     443        break;
     444    case THREECHARMONTH:
     445        GetLocaleInfoA( GetSystemDefaultLCID(),LOCALE_SMONTHNAME1+date.wMonth -1,
     446          buffer,sizeof(buffer));
     447        sprintf (result,"%.3s",buffer);
     448        break;
     449    case FULLMONTH:
     450        GetLocaleInfoA( GetSystemDefaultLCID(),LOCALE_SMONTHNAME1+date.wMonth -1,
    450451#ifdef __WIN32OS2__
    451                                 buffer,sizeof(buffer));
    452                 strcpy  (result,buffer);
     452                buffer,sizeof(buffer));
     453        strcpy  (result,buffer);
    453454#else
    454                   result,sizeof(result));
     455          result,sizeof(result));
    455456#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;
     457        break;
     458    case ONELETTERAMPM:
     459        if (date.wHour<12)
     460            strcpy (result,"A");
     461        else
     462            strcpy (result,"P");
     463        break;
     464    case TWOLETTERAMPM:
     465        if (date.wHour<12)
     466            strcpy (result,"AM");
     467        else
     468            strcpy (result,"PM");
     469        break;
     470    case FORMATCALLBACK:
     471        FIXME ("Not implemented\n");
     472        strcpy (result,"xxx");
     473        break;
     474    case ONEDIGITYEAR:
     475        sprintf (result,"%d",date.wYear-10* (int) floor(date.wYear/10));
     476        break;
     477    case TWODIGITYEAR:
     478        sprintf (result,"%.2d",date.wYear-100* (int) floor(date.wYear/100));
     479        break;
     480    case FULLYEAR:
     481        sprintf (result,"%d",date.wYear);
     482        break;
    482483    }
    483        
    484         TRACE ("arg%d=%x->[%s]\n",count,infoPtr->fieldspec[count],result);
    485 }
    486 
    487 
    488 static void 
     484
     485    TRACE ("arg%d=%x->[%s]\n",count,infoPtr->fieldspec[count],result);
     486}
     487
     488
     489static void
    489490DATETIME_IncreaseField (DATETIME_INFO *infoPtr, int number)
    490491{
     
    497498 spec=infoPtr->fieldspec[number];
    498499 if ((spec & DTHT_DATEFIELD)==0) return;
    499                
     500
    500501 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 
     502    case ONEDIGITDAY:
     503    case TWODIGITDAY:
     504    case THREECHARDAY:
     505    case FULLDAY:
     506        date->wDay++;
     507        if (date->wDay>MONTHCAL_MonthLength(date->wMonth,date->wYear))
     508          date->wDay=1;
     509        break;
     510    case ONEDIGIT12HOUR:
     511    case TWODIGIT12HOUR:
     512    case ONEDIGIT24HOUR:
     513    case TWODIGIT24HOUR:
     514        date->wHour++;
     515        if (date->wHour>23) date->wHour=0;
     516        break;
     517    case ONEDIGITSECOND:
     518    case TWODIGITSECOND:
     519        date->wSecond++;
     520        if (date->wSecond>59) date->wSecond=0;
     521        break;
     522    case ONEDIGITMINUTE:
     523    case TWODIGITMINUTE:
     524        date->wMinute++;
     525        if (date->wMinute>59) date->wMinute=0;
     526        break;
     527    case ONEDIGITMONTH:
     528    case TWODIGITMONTH:
     529    case THREECHARMONTH:
     530    case FULLMONTH:
     531        date->wMonth++;
     532        if (date->wMonth>12) date->wMonth=1;
     533        if (date->wDay>MONTHCAL_MonthLength(date->wMonth,date->wYear))
     534            date->wDay=MONTHCAL_MonthLength(date->wMonth,date->wYear);
     535        break;
     536    case ONELETTERAMPM:
     537    case TWOLETTERAMPM:
     538        date->wHour+=12;
     539        if (date->wHour>23) date->wHour-=24;
     540        break;
     541    case FORMATCALLBACK:
     542        FIXME ("Not implemented\n");
     543        break;
     544    case ONEDIGITYEAR:
     545    case TWODIGITYEAR:
     546    case FULLYEAR:
     547        date->wYear++;
     548        break;
     549    }
     550
     551}
     552
     553
     554static void
    554555DATETIME_DecreaseField (DATETIME_INFO *infoPtr, int number)
    555556{
     
    562563 spec = infoPtr->fieldspec[number];
    563564 if ((spec & DTHT_DATEFIELD)==0) return;
    564                
     565
    565566 TRACE ("%x\n",spec);
    566567
    567568 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 
     569    case ONEDIGITDAY:
     570    case TWODIGITDAY:
     571    case THREECHARDAY:
     572    case FULLDAY:
     573        date->wDay--;
     574        if (date->wDay<1)
     575          date->wDay=MONTHCAL_MonthLength(date->wMonth,date->wYear);
     576        break;
     577    case ONEDIGIT12HOUR:
     578    case TWODIGIT12HOUR:
     579    case ONEDIGIT24HOUR:
     580    case TWODIGIT24HOUR:
     581        if (date->wHour)
     582            date->wHour--;
     583        else
     584            date->wHour=23;
     585        break;
     586    case ONEDIGITSECOND:
     587    case TWODIGITSECOND:
     588        if (date->wHour)
     589            date->wSecond--;
     590        else
     591            date->wHour=59;
     592        break;
     593    case ONEDIGITMINUTE:
     594    case TWODIGITMINUTE:
     595        if (date->wMinute)
     596            date->wMinute--;
     597        else
     598            date->wMinute=59;
     599        break;
     600    case ONEDIGITMONTH:
     601    case TWODIGITMONTH:
     602    case THREECHARMONTH:
     603    case FULLMONTH:
     604        if (date->wMonth>1)
     605            date->wMonth--;
     606        else
     607            date->wMonth=12;
     608        if (date->wDay>MONTHCAL_MonthLength(date->wMonth,date->wYear))
     609            date->wDay=MONTHCAL_MonthLength(date->wMonth,date->wYear);
     610        break;
     611    case ONELETTERAMPM:
     612    case TWOLETTERAMPM:
     613        if (date->wHour<12)
     614            date->wHour+=12;
     615        else
     616            date->wHour-=12;
     617        break;
     618    case FORMATCALLBACK:
     619        FIXME ("Not implemented\n");
     620        break;
     621    case ONEDIGITYEAR:
     622    case TWODIGITYEAR:
     623    case FULLYEAR:
     624        date->wYear--;
     625        break;
     626    }
     627
     628}
     629
     630
     631static void
    631632DATETIME_ResetFieldDown (DATETIME_INFO *infoPtr, int number)
    632633{
     
    639640 spec = infoPtr->fieldspec[number];
    640641 if ((spec & DTHT_DATEFIELD)==0) return;
    641                
     642
    642643
    643644 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:
     645    case ONEDIGITDAY:
     646    case TWODIGITDAY:
     647    case THREECHARDAY:
     648    case FULLDAY:
     649        date->wDay = 1;
     650        break;
     651    case ONEDIGIT12HOUR:
     652    case TWODIGIT12HOUR:
     653    case ONEDIGIT24HOUR:
     654    case TWODIGIT24HOUR:
     655    case ONELETTERAMPM:
     656    case TWOLETTERAMPM:
     657        date->wHour = 0;
     658        break;
     659    case ONEDIGITSECOND:
     660    case TWODIGITSECOND:
     661        date->wSecond = 0;
     662        break;
     663    case ONEDIGITMINUTE:
     664    case TWODIGITMINUTE:
     665        date->wMinute = 0;
     666        break;
     667    case ONEDIGITMONTH:
     668    case TWODIGITMONTH:
     669    case THREECHARMONTH:
     670    case FULLMONTH:
     671        date->wMonth = 1;
     672    case FORMATCALLBACK:
     673        FIXME ("Not implemented\n");
     674        break;
     675    case ONEDIGITYEAR:
     676    case TWODIGITYEAR:
    676677        /* FYI: On 9/14/1752 the calender changed and England and the American */
    677678        /* colonies changed to the Gregorian calender.  This change involved */
    678679        /* having September 14th following September 2nd.  So no date algorithms */
    679680        /* 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 
     681    case FULLYEAR:
     682        date->wSecond = 0;
     683        date->wMinute = 0;
     684        date->wHour = 0;
     685        date->wDay = 14;        /* overactive ms-programmers..*/
     686        date->wMonth = 9;
     687        date->wYear = 1752;
     688        break;
     689    }
     690
     691}
     692
     693
     694static void
    694695DATETIME_ResetFieldUp (DATETIME_INFO *infoPtr, int number)
    695696{
     
    702703 spec=infoPtr->fieldspec[number];
    703704 if ((spec & DTHT_DATEFIELD)==0) return;
    704                
     705
    705706 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         }
     707    case ONEDIGITDAY:
     708    case TWODIGITDAY:
     709    case THREECHARDAY:
     710    case FULLDAY:
     711        date->wDay=MONTHCAL_MonthLength(date->wMonth,date->wYear);
     712        break;
     713    case ONEDIGIT12HOUR:
     714    case TWODIGIT12HOUR:
     715    case ONEDIGIT24HOUR:
     716    case TWODIGIT24HOUR:
     717    case ONELETTERAMPM:
     718    case TWOLETTERAMPM:
     719        date->wHour=23;
     720        break;
     721    case ONEDIGITSECOND:
     722    case TWODIGITSECOND:
     723        date->wSecond=59;
     724        break;
     725    case ONEDIGITMINUTE:
     726    case TWODIGITMINUTE:
     727        date->wMinute=59;
     728        break;
     729    case ONEDIGITMONTH:
     730    case TWODIGITMONTH:
     731    case THREECHARMONTH:
     732    case FULLMONTH:
     733        date->wMonth=12;
     734    case FORMATCALLBACK:
     735        FIXME ("Not implemented\n");
     736        break;
     737    case ONEDIGITYEAR:
     738    case TWODIGITYEAR:
     739    case FULLYEAR:
     740        date->wYear=9999;    /* Y10K problem? naaah. */
     741        break;
     742    }
    742743
    743744}
     
    758759  SIZE size;
    759760  COLORREF oldBk, oldTextColor;
    760  
     761
    761762  /* draw control edge */
    762763  TRACE("\n");
     
    764765  FillRect(hdc, rcClient, hbr);
    765766  DrawEdge(hdc, rcClient, EDGE_SUNKEN, BF_RECT);
    766   DeleteObject(hbr);   
    767        
     767  DeleteObject(hbr);
     768
    768769  if (infoPtr->dateValid) {
    769770    char txt[80];
     
    798799              DT_RIGHT | DT_VCENTER | DT_SINGLELINE );
    799800        SetBkColor (hdc, oldBk);
    800                 SetTextColor (hdc, oldTextColor);
     801        SetTextColor (hdc, oldTextColor);
    801802      }
    802803      else
     
    832833    if (PtInRect (&infoPtr->fieldRect[i], pt)) {
    833834      retval = i;
    834       TRACE("Hit in date text in field %d\n", i);           
     835      TRACE("Hit in date text in field %d\n", i);
    835836      break;
    836837    }
     
    845846DATETIME_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
    846847{
    847   DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 
     848  DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
    848849  DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
    849850  int old, new;
     
    874875      infoPtr->monthcal_pos.x = infoPtr->rcClient.right - ((infoPtr->calbutton.right -
    875876                                infoPtr->calbutton.left) + 145);
    876     else 
     877    else
    877878      infoPtr->monthcal_pos.x = 8;
    878879
     
    888889
    889890    TRACE ("dt:%x mc:%x mc parent:%x, desktop:%x, mcpp:%x\n",
    890               hwnd,infoPtr->hMonthCal, 
     891              hwnd,infoPtr->hMonthCal,
    891892              GetParent (infoPtr->hMonthCal),
    892893              GetDesktopWindow (),
     
    904905DATETIME_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
    905906{
    906   DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 
     907  DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
    907908
    908909  TRACE("\n");
    909  
     910
    910911  if(infoPtr->bCalDepressed == TRUE) {
    911912    infoPtr->bCalDepressed = FALSE;
     
    934935DATETIME_ParentNotify (HWND hwnd, WPARAM wParam, LPARAM lParam)
    935936{
    936  DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);   
     937 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
    937938 LPNMHDR lpnmh = (LPNMHDR) lParam;
    938939
     
    954955
    955956{
    956  DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);   
     957 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
    957958 LPNMHDR lpnmh = (LPNMHDR) lParam;
    958959
     
    964965
    965966
    966 static LRESULT 
     967static LRESULT
    967968DATETIME_KeyDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
    968969{
     
    978979
    979980 if (infoPtr->select & FORMATCALLMASK) {
    980         FIXME ("Callbacks not implemented yet\n");
     981    FIXME ("Callbacks not implemented yet\n");
    981982 }
    982983
    983984 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;
    1022         }
     985    case VK_ADD:
     986        case VK_UP:
     987        DATETIME_IncreaseField (infoPtr,FieldNum);
     988        DATETIME_SendDateTimeChangeNotify (hwnd);
     989        break;
     990    case VK_SUBTRACT:
     991    case VK_DOWN:
     992        DATETIME_DecreaseField (infoPtr,FieldNum);
     993        DATETIME_SendDateTimeChangeNotify (hwnd);
     994        break;
     995    case VK_HOME:
     996        DATETIME_ResetFieldDown (infoPtr,FieldNum);
     997        DATETIME_SendDateTimeChangeNotify (hwnd);
     998        break;
     999    case VK_END:
     1000        DATETIME_ResetFieldUp(infoPtr,FieldNum);
     1001        DATETIME_SendDateTimeChangeNotify (hwnd);
     1002        break;
     1003    case VK_LEFT:
     1004        do {
     1005            if (infoPtr->select==0) {
     1006                infoPtr->select = infoPtr->nrFields - 1;
     1007                wrap++;
     1008            } else
     1009            infoPtr->select--;
     1010        }
     1011        while ((infoPtr->fieldspec[infoPtr->select] & DT_STRING) && (wrap<2));
     1012        break;
     1013    case VK_RIGHT:
     1014        do {
     1015            infoPtr->select++;
     1016            if (infoPtr->select==infoPtr->nrFields) {
     1017                infoPtr->select = 0;
     1018                wrap++;
     1019            }
     1020            }
     1021        while ((infoPtr->fieldspec[infoPtr->select] & DT_STRING) && (wrap<2));
     1022        break;
     1023    }
    10231024
    10241025  InvalidateRect(hwnd, NULL, FALSE);
     
    10311032DATETIME_KillFocus (HWND hwnd, WPARAM wParam, LPARAM lParam)
    10321033{
    1033     DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);       
     1034    DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
    10341035
    10351036    TRACE ("\n");
    10361037
    10371038    if (infoPtr->haveFocus) {
    1038         DATETIME_SendSimpleNotify (hwnd, NM_KILLFOCUS);
    1039         infoPtr->haveFocus = 0;
     1039    DATETIME_SendSimpleNotify (hwnd, NM_KILLFOCUS);
     1040    infoPtr->haveFocus = 0;
    10401041    }
    10411042
     
    10491050DATETIME_SetFocus (HWND hwnd, WPARAM wParam, LPARAM lParam)
    10501051{
    1051     DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);       
     1052    DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
    10521053
    10531054    TRACE ("\n");
    10541055
    10551056    if (infoPtr->haveFocus==0) {
    1056         DATETIME_SendSimpleNotify (hwnd, NM_SETFOCUS); 
    1057         infoPtr->haveFocus = DTHT_GOTFOCUS;
     1057    DATETIME_SendSimpleNotify (hwnd, NM_SETFOCUS);
     1058    infoPtr->haveFocus = DTHT_GOTFOCUS;
    10581059    }
    10591060
     
    10681069
    10691070{
    1070  DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);   
     1071 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
    10711072 NMDATETIMECHANGE dtdtc;
    10721073
     
    11361137    infoPtr->monthcal_pos.x = infoPtr->rcClient.right - ((infoPtr->calbutton.right -
    11371138                                infoPtr->calbutton.left) + 145);
    1138   else 
     1139  else
    11391140    infoPtr->monthcal_pos.x = 8;
    11401141
     
    11721173
    11731174  if (dwStyle & DTS_SHOWNONE) {
    1174     infoPtr->hwndCheckbut=CreateWindowExA (0,"button", 0, 
    1175          WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, 
     1175    infoPtr->hwndCheckbut=CreateWindowExA (0,"button", 0,
     1176         WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
    11761177         2,2,13,13,
    1177          hwnd, 
     1178         hwnd,
    11781179         0, GetWindowLongA  (hwnd, GWL_HINSTANCE), 0);
    11791180         SendMessageA (infoPtr->hwndCheckbut, BM_SETCHECK, 1, 0);
     
    11961197
    11971198  /* 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);
     1199    infoPtr->hMonthCal = CreateWindowExA (0,"SysMonthCal32", 0,
     1200    WS_BORDER | WS_POPUP | WS_CLIPSIBLINGS,
     1201    0, 0, 0, 0,
     1202    GetParent(hwnd),
     1203    0, 0, 0);
    12031204
    12041205  /* initialize info structure */
     
    12141215{
    12151216    DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
    1216        
     1217
    12171218    TRACE("\n");
    12181219    COMCTL32_Free (infoPtr);
     
    12271228
    12281229    if (!DATETIME_GetInfoPtr(hwnd) && (uMsg != WM_CREATE))
    1229         return DefWindowProcA( hwnd, uMsg, wParam, lParam );
    1230    
     1230    return DefWindowProcA( hwnd, uMsg, wParam, lParam );
     1231
    12311232    switch (uMsg)
    12321233    {
     
    12361237
    12371238    case DTM_SETSYSTEMTIME:
    1238         return DATETIME_SetSystemTime (hwnd, wParam, lParam);
     1239    return DATETIME_SetSystemTime (hwnd, wParam, lParam);
    12391240
    12401241    case DTM_GETRANGE:
     
    12661267
    12671268    case WM_PARENTNOTIFY:
    1268         return DATETIME_ParentNotify (hwnd, wParam, lParam);
     1269    return DATETIME_ParentNotify (hwnd, wParam, lParam);
    12691270
    12701271    case WM_NOTIFY:
    1271         return DATETIME_Notify (hwnd, wParam, lParam);
     1272    return DATETIME_Notify (hwnd, wParam, lParam);
    12721273
    12731274    case WM_GETDLGCODE:
     
    12961297
    12971298    case WM_CREATE:
    1298         return DATETIME_Create (hwnd, wParam, lParam);
     1299    return DATETIME_Create (hwnd, wParam, lParam);
    12991300
    13001301    case WM_DESTROY:
    1301         return DATETIME_Destroy (hwnd, wParam, lParam);
     1302    return DATETIME_Destroy (hwnd, wParam, lParam);
    13021303
    13031304    default:
    1304         if (uMsg >= WM_USER)
    1305                 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
    1306                      uMsg, wParam, lParam);
     1305    if (uMsg >= WM_USER)
     1306        ERR("unknown msg %04x wp=%08x lp=%08lx\n",
     1307             uMsg, wParam, lParam);
    13071308#ifdef __WIN32OS2__
    13081309        return defComCtl32ProcA (hwnd, uMsg, wParam, lParam);
    13091310#else
    1310         return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     1311    return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    13111312#endif
    13121313    }
     
    13291330    wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
    13301331    wndClass.lpszClassName = DATETIMEPICK_CLASSA;
    1331  
     1332
    13321333    RegisterClassA (&wndClass);
    13331334}
  • trunk/src/comctl32/flatsb.c

    r5416 r6644  
     1/* $Id: flatsb.c,v 1.10 2001-09-05 12:04:58 bird Exp $ */
    12/*
    23 * Flat Scrollbar control
     
    3940
    4041/***********************************************************************
    41  *              InitializeFlatSB
    42  *
    43  *      returns nonzero if successful, zero otherwise
     42 *      InitializeFlatSB
     43 *
     44 *  returns nonzero if successful, zero otherwise
    4445 *
    4546 */
     
    5253
    5354/***********************************************************************
    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
     55 *      UninitializeFlatSB
     56 *
     57 *  returns:
     58 *  E_FAIL      if one of the scroll bars is currently in use
     59 *  S_FALSE     if InitializeFlatSB was never called on this hwnd
     60 *  S_OK        otherwise
    6061 *
    6162 */
     
    6869
    6970/***********************************************************************
    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 
     71 *      FlatSB_GetScrollProp
     72 *
     73 *  Returns nonzero if successful, or zero otherwise. If index is WSB_PROP_HSTYLE,
     74 *  the return is nonzero if InitializeFlatSB has been called for this window, or
     75 *  zero otherwise.
     76 *
     77 */
     78BOOL WINAPI
    7879FlatSB_GetScrollProp(HWND hwnd, INT propIndex, LPINT prop)
    7980{
     
    8485
    8586/***********************************************************************
    86  *              FlatSB_SetScrollProp
    87  */
    88 BOOL WINAPI 
     87 *      FlatSB_SetScrollProp
     88 */
     89BOOL WINAPI
    8990FlatSB_SetScrollProp(HWND hwnd, UINT index, INT newValue, BOOL flag)
    9091{
     
    9596
    9697/***********************************************************************
    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 
     98 *  From the Microsoft docs:
     99 *  "If flat scroll bars haven't been initialized for the
     100 *  window, the flat scroll bar APIs will defer to the corresponding
     101 *  standard APIs.  This allows the developer to turn flat scroll
     102 *  bars on and off without having to write conditional code."
     103 *
     104 *  So, if we just call the standard functions until we implement
     105 *  the flat scroll bar functions, flat scroll bars will show up and
     106 *  behave properly, as though they had simply not been setup to
     107 *  have flat properties.
     108 *
     109 *  Susan <sfarley@codeweavers.com>
     110 *
     111 */
     112
     113/***********************************************************************
     114 *      FlatSB_EnableScrollBar
     115 */
     116BOOL WINAPI
    116117FlatSB_EnableScrollBar(HWND hwnd, int nBar, UINT flags)
    117118{
     
    120121
    121122/***********************************************************************
    122  *              FlatSB_ShowScrollBar
    123  */
    124 BOOL WINAPI 
     123 *      FlatSB_ShowScrollBar
     124 */
     125BOOL WINAPI
    125126FlatSB_ShowScrollBar(HWND hwnd, int nBar, BOOL fShow)
    126127{
     
    129130
    130131/***********************************************************************
    131  *              FlatSB_GetScrollRange
    132  */
    133 BOOL WINAPI 
     132 *      FlatSB_GetScrollRange
     133 */
     134BOOL WINAPI
    134135FlatSB_GetScrollRange(HWND hwnd, int nBar, LPINT min, LPINT max)
    135136{
     
    138139
    139140/***********************************************************************
    140  *              FlatSB_GetScrollInfo
    141  */
    142 BOOL WINAPI 
     141 *      FlatSB_GetScrollInfo
     142 */
     143BOOL WINAPI
    143144FlatSB_GetScrollInfo(HWND hwnd, int nBar, LPSCROLLINFO info)
    144145{
     
    147148
    148149/***********************************************************************
    149  *              FlatSB_GetScrollPos
    150  */
    151 INT WINAPI 
     150 *      FlatSB_GetScrollPos
     151 */
     152INT WINAPI
    152153FlatSB_GetScrollPos(HWND hwnd, int nBar)
    153154{
     
    156157
    157158/***********************************************************************
    158  *              FlatSB_SetScrollPos
    159  */
    160 INT WINAPI 
     159 *      FlatSB_SetScrollPos
     160 */
     161INT WINAPI
    161162FlatSB_SetScrollPos(HWND hwnd, int nBar, INT pos, BOOL bRedraw)
    162163{
     
    165166
    166167/***********************************************************************
    167  *              FlatSB_SetScrollInfo
    168  */
    169 INT WINAPI 
     168 *      FlatSB_SetScrollInfo
     169 */
     170INT WINAPI
    170171FlatSB_SetScrollInfo(HWND hwnd, int nBar, LPSCROLLINFO info, BOOL bRedraw)
    171172{
     
    174175
    175176/***********************************************************************
    176  *              FlatSB_SetScrollRange
    177  */
    178 INT WINAPI 
     177 *      FlatSB_SetScrollRange
     178 */
     179INT WINAPI
    179180FlatSB_SetScrollRange(HWND hwnd, int nBar, INT min, INT max, BOOL bRedraw)
    180181{
     
    212213    switch (uMsg)
    213214    {
    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",
     215    case WM_CREATE:
     216        return FlatSB_Create (hwnd, wParam, lParam);
     217
     218    case WM_DESTROY:
     219        return FlatSB_Destroy (hwnd, wParam, lParam);
     220
     221    default:
     222        if (uMsg >= WM_USER)
     223        ERR("unknown msg %04x wp=%08x lp=%08lx\n",
    223224                    uMsg, wParam, lParam);
    224225#ifdef __WIN32OS2__
    225226            return defComCtl32ProcA (hwnd, uMsg, wParam, lParam);
    226227#else
    227             return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     228        return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    228229#endif
    229230    }
     
    245246    wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
    246247    wndClass.lpszClassName = FLATSB_CLASSA;
    247  
     248
    248249    RegisterClassA (&wndClass);
    249250}
  • trunk/src/comctl32/imagelist.c

    r6380 r6644  
     1/* $Id: imagelist.c,v 1.15 2001-09-05 12:04:58 bird Exp $ */
    12/*
    23 *  ImageList implementation
     
    2021 *    - ImageList_Draw, ImageList_DrawEx and ImageList_GetIcon use
    2122 *      ImageList_DrawIndirect. Since ImageList_DrawIndirect is still
    22  *      partially implemented, the functions mentioned above will be 
     23 *      partially implemented, the functions mentioned above will be
    2324 *      limited in functionality too.
    2425 */
     
    6970
    7071/*************************************************************************
    71  * IMAGELIST_InternalExpandBitmaps [Internal] 
     72 * IMAGELIST_InternalExpandBitmaps [Internal]
    7273 *
    7374 * Expands the bitmaps of an image list by the given number of images.
     
    9293    if ((himl->cCurImage + nImageCount < himl->cMaxImage)
    9394        && (himl->cy >= cy))
    94         return;
     95    return;
    9596
    9697    if (cy == 0) cy = himl->cy;
     
    116117
    117118    if (himl->hbmMask) {
    118         hbmNewBitmap = 
     119        hbmNewBitmap =
    119120            CreateBitmap (nNewWidth, cy, 1, 1, NULL);
    120121
     
    138139
    139140/*************************************************************************
    140  * IMAGELIST_InternalDraw [Internal] 
     141 * IMAGELIST_InternalDraw [Internal]
    141142 *
    142143 * Draws the image in the ImageList (without the mask)
     
    151152 *
    152153 * NOTES
    153  *     This function is used by ImageList_DrawIndirect, when it is 
     154 *     This function is used by ImageList_DrawIndirect, when it is
    154155 *     required to draw only the Image (without the mask) to the screen.
    155156 *
     
    164165    hImageDC = CreateCompatibleDC(0);
    165166    hOldBitmap = SelectObject(hImageDC, pimldp->himl->hbmImage);
    166     BitBlt(pimldp->hdcDst, 
     167    BitBlt(pimldp->hdcDst,
    167168        pimldp->x, pimldp->y, cx, cy,
    168         hImageDC, 
    169         pimldp->himl->cx * pimldp->i, 0, 
     169        hImageDC,
     170        pimldp->himl->cx * pimldp->i, 0,
    170171        SRCCOPY);
    171172
     
    176177
    177178/*************************************************************************
    178  * IMAGELIST_InternalDrawMask [Internal] 
     179 * IMAGELIST_InternalDrawMask [Internal]
    179180 *
    180181 * Draws the image in the ImageList with the mask
     
    189190 *
    190191 * NOTES
    191  *     This function is used by ImageList_DrawIndirect, when it is 
     192 *     This function is used by ImageList_DrawIndirect, when it is
    192193 *     required to draw the Image with the mask to the screen.
    193194 *
     
    205206    UINT fStyle = pimldp->fStyle & (~ILD_OVERLAYMASK);
    206207
    207     /* 
    208      * We need a dc and bitmap to draw on that is 
     208    /*
     209     * We need a dc and bitmap to draw on that is
    209210     * not on the screen.
    210211     */
     
    221222    hOffScreenDC = CreateCompatibleDC( pimldp->hdcDst );
    222223
    223     if ( hOffScreenDC ) 
     224    if ( hOffScreenDC )
    224225    {
    225226        hOffScreenBmp = CreateCompatibleBitmap( pimldp->hdcDst, cx, cy );
    226227
    227         if ( hOffScreenBmp ) 
     228        if ( hOffScreenBmp )
    228229            SelectObject( hOffScreenDC, hOffScreenBmp  );
    229230        else
     
    235236    hOldBitmapImage = SelectObject(hImageDC, himlLocal->hbmImage);
    236237    hOldBitmapMask = SelectObject(hMaskDC, himlLocal->hbmMask);
    237    
    238     /* 
    239      * Get a copy of the image for the masking operations. 
     238
     239    /*
     240     * Get a copy of the image for the masking operations.
    240241     * We will use the copy, and this dc for all the various
    241242     * blitting, and then do one final blit to the screen dc.
    242243     * This should clean up most of the flickering.
    243244     */
    244     BitBlt( hOffScreenDC, 0, 0, cx, cy, pimldp->hdcDst, pimldp->x, 
     245    BitBlt( hOffScreenDC, 0, 0, cx, cy, pimldp->hdcDst, pimldp->x,
    245246            pimldp->y, SRCCOPY);
    246247
    247     /* 
     248    /*
    248249     * Draw the Background for the appropriate Styles
    249250     */
    250     if( bUseCustomBackground && (fStyle == ILD_NORMAL || fStyle & ILD_IMAGE 
     251    if( bUseCustomBackground && (fStyle == ILD_NORMAL || fStyle & ILD_IMAGE
    251252         || bBlendFlag) )
    252253    {
    253        
     254
    254255        hBrush = CreateSolidBrush (himlLocal->clrBk);
    255256        hOldBrush = SelectObject (pimldp->hdcDst, hBrush);
    256        
     257
    257258        PatBlt( hOffScreenDC, pimldp->x, pimldp->y, cx, cy, PATCOPY );
    258259
     
    260261    }
    261262
    262     /* 
     263    /*
    263264     * Draw Image Transparently over the current background
    264265     */
    265     if(fStyle == ILD_NORMAL || (fStyle & ILD_TRANSPARENT) || 
    266        ((fStyle & ILD_IMAGE) && bUseCustomBackground) || bBlendFlag) 
    267     {   /* 
     266    if(fStyle == ILD_NORMAL || (fStyle & ILD_TRANSPARENT) ||
     267       ((fStyle & ILD_IMAGE) && bUseCustomBackground) || bBlendFlag)
     268    {   /*
    268269         * To obtain a transparent look, background color should be set
    269          * to white and foreground color to black when blting the 
    270          * monochrome mask. 
     270         * to white and foreground color to black when blting the
     271         * monochrome mask.
    271272         */
    272        
    273         oldBkColor = SetBkColor( hOffScreenDC, RGB( 0xff, 0xff, 0xff ) ); 
     273
     274        oldBkColor = SetBkColor( hOffScreenDC, RGB( 0xff, 0xff, 0xff ) );
    274275        oldFgColor = SetTextColor( hOffScreenDC, RGB( 0, 0, 0 ) );
    275276
     
    279280        BitBlt( hOffScreenDC, 0, 0, cx, cy, hImageDC,himlLocal->cx * pimldp->i,
    280281                0, SRCPAINT );
    281    
    282     }
    283    
     282
     283    }
     284
    284285    /*
    285286     * Draw the image when no Background is specified
     
    287288    else if((fStyle & ILD_IMAGE) && !bUseCustomBackground)
    288289    {
    289         BitBlt( hOffScreenDC, 0, 0, cx, cy, hImageDC, 
     290        BitBlt( hOffScreenDC, 0, 0, cx, cy, hImageDC,
    290291                himlLocal->cx * pimldp->i, 0, SRCCOPY);
    291292    }
    292     /* 
     293    /*
    293294     * Draw the mask with or without a background
    294295     */
     
    298299                0, bUseCustomBackground ? SRCCOPY : SRCAND);
    299300    }
    300    
     301
    301302    /*
    302303     * Blit the bitmap to the screen now.
     
    305306            hOffScreenDC, 0, 0, SRCCOPY);
    306307
    307    
     308
    308309    SelectObject(hImageDC, hOldBitmapImage);
    309310    SelectObject(hMaskDC, hOldBitmapMask);
    310    
     311
    311312cleanup:
    312    
     313
    313314    DeleteDC(hImageDC);
    314315    DeleteDC(hMaskDC);
    315    
     316
    316317    DeleteDC( hOffScreenDC );
    317318    DeleteObject( hOffScreenBmp );
    318    
     319
    319320    return;
    320321}
    321322
    322323/*************************************************************************
    323  * IMAGELIST_InternalDrawBlend [Internal] 
    324  *
    325  * Draws the Blend over the current image 
     324 * IMAGELIST_InternalDrawBlend [Internal]
     325 *
     326 * Draws the Blend over the current image
    326327 *
    327328 * PARAMS
     
    334335 *
    335336 * NOTES
    336  *     This functions is used by ImageList_DrawIndirect, when it is 
    337  *     required to add the blend to the current image. 
    338  *     
     337 *     This functions is used by ImageList_DrawIndirect, when it is
     338 *     required to add the blend to the current image.
     339 *
    339340 */
    340341static VOID
     
    375376
    376377        BitBlt(hBlendMaskDC,
    377             0,0, cx, cy, 
     378            0,0, cx, cy,
    378379            hMaskDC,
    379380            himlLocal->cx * pimldp->i,0,
     
    381382
    382383        BitBlt(hBlendMaskDC,
    383             0,0, cx, cy, 
     384            0,0, cx, cy,
    384385            hBlendMaskDC,
    385             0,0, 
     386            0,0,
    386387            NOTSRCCOPY);
    387388
     
    397398    hOldBrush = (HBRUSH) SelectObject (pimldp->hdcDst, hBlendColorBrush);
    398399
    399     BitBlt (pimldp->hdcDst, 
    400         pimldp->x, pimldp->y, cx, cy, 
    401         hBlendMaskDC, 
    402         0, 0, 
     400    BitBlt (pimldp->hdcDst,
     401        pimldp->x, pimldp->y, cx, cy,
     402        hBlendMaskDC,
     403        0, 0,
    403404        0xB8074A); /* PSDPxax */
    404405
     
    413414
    414415/*************************************************************************
    415  * IMAGELIST_InternalDrawOverlay [Internal] 
    416  *
    417  * Draws the overlay image 
     416 * IMAGELIST_InternalDrawOverlay [Internal]
     417 *
     418 * Draws the overlay image
    418419 *
    419420 * PARAMS
     
    426427 *
    427428 * NOTES
    428  *     This functions is used by ImageList_DrawIndirect, when it is 
     429 *     This functions is used by ImageList_DrawIndirect, when it is
    429430 *     required to draw the overlay
    430431 *
    431  *     
    432  */
    433 static VOID 
     432 *
     433 */
     434static VOID
    434435IMAGELIST_InternalDrawOverlay(IMAGELISTDRAWPARAMS *pimldp, INT cx, INT cy)
    435436{
     
    447448            if (pimldp->himl->hbmMask)
    448449            {
    449                 hOldBitmap = (HBITMAP) SelectObject (hImageDC, 
     450                hOldBitmap = (HBITMAP) SelectObject (hImageDC,
    450451                    pimldp->himl->hbmMask);
    451452
    452                 BitBlt (pimldp->hdcDst, 
     453                BitBlt (pimldp->hdcDst,
    453454                    pimldp->x, pimldp->y, cx, cy,
    454455                    hImageDC, pimldp->himl->cx * nOvlIdx, 0,
     
    457458                SelectObject(hImageDC, hOldBitmap);
    458459            }
    459             hOldBitmap = (HBITMAP) SelectObject (hImageDC, 
     460            hOldBitmap = (HBITMAP) SelectObject (hImageDC,
    460461                pimldp->himl->hbmImage);
    461462
    462             BitBlt (pimldp->hdcDst, 
    463                 pimldp->x, pimldp->y, cx, cy, 
     463            BitBlt (pimldp->hdcDst,
     464                pimldp->x, pimldp->y, cx, cy,
    464465                hImageDC,
    465466                pimldp->himl->cx * nOvlIdx, 0,
     
    492493
    493494INT WINAPI
    494 ImageList_Add (HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask)
     495ImageList_Add (HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask)
    495496{
    496497    HDC     hdcImage, hdcBitmap;
     
    531532        hOldBitmapTemp = (HBITMAP) SelectObject(hdcTemp, hbmMask);
    532533
    533         BitBlt (hdcMask, 
     534        BitBlt (hdcMask,
    534535            nStartX, 0, bmp.bmWidth, bmp.bmHeight,
    535             hdcTemp, 
    536             0, 0, 
     536            hdcTemp,
     537            0, 0,
    537538            SRCCOPY);
    538539
     
    542543        /* Remove the background from the image
    543544        */
    544         BitBlt (hdcImage, 
     545        BitBlt (hdcImage,
    545546            nStartX, 0, bmp.bmWidth, bmp.bmHeight,
    546             hdcMask, 
    547             nStartX, 0, 
     547            hdcMask,
     548            nStartX, 0,
    548549            0x220326); /* NOTSRCAND */
    549550
     
    586587
    587588/*************************************************************************
    588  * ImageList_AddMasked [COMCTL32.42] 
     589 * ImageList_AddMasked [COMCTL32.42]
    589590 *
    590591 * Adds an image or images to an image list and creates a mask from the
     
    651652        GetPixel (hdcBitmap, 0, 0);
    652653    SetBkColor (hdcBitmap, bkColor);
    653     BitBlt (hdcMask, 
     654    BitBlt (hdcMask,
    654655        nMaskXOffset, 0, bmp.bmWidth, bmp.bmHeight,
    655         hdcBitmap, 0, 0, 
     656        hdcBitmap, 0, 0,
    656657        SRCCOPY);
    657658
     
    668669        This is here in case some apps rely on this bug
    669670    */
    670     BitBlt(hdcBitmap, 
     671    BitBlt(hdcBitmap,
    671672        0, 0, bmp.bmWidth, bmp.bmHeight,
    672         hdcMask, 
    673         nMaskXOffset, 0, 
     673        hdcMask,
     674        nMaskXOffset, 0,
    674675        0x220326); /* NOTSRCAND */
    675676    /* Copy result to the imagelist
    676677    */
    677     BitBlt (hdcImage, 
     678    BitBlt (hdcImage,
    678679        nIndex * himl->cx, 0, bmp.bmWidth, bmp.bmHeight,
    679         hdcBitmap, 
    680         0, 0, 
     680        hdcBitmap,
     681        0, 0,
    681682        SRCCOPY);
    682683    /* Clean up
     
    698699
    699700/*************************************************************************
    700  * ImageList_BeginDrag [COMCTL32.43] 
     701 * ImageList_BeginDrag [COMCTL32.43]
    701702 *
    702703 * Creates a temporary image list that contains one image. It will be used
     
    716717BOOL WINAPI
    717718ImageList_BeginDrag (HIMAGELIST himlTrack, INT iTrack,
    718                      INT dxHotspot, INT dyHotspot)
     719                 INT dxHotspot, INT dyHotspot)
    719720{
    720721    HDC hdcSrc, hdcDst;
     
    723724
    724725    if (himlTrack == NULL)
    725         return FALSE;
     726    return FALSE;
    726727
    727728    if (himlInternalDrag)
     
    729730
    730731    himlInternalDrag =
    731         ImageList_Create (himlTrack->cx, himlTrack->cy,
    732                           himlTrack->flags, 1, 1);
     732    ImageList_Create (himlTrack->cx, himlTrack->cy,
     733              himlTrack->flags, 1, 1);
    733734    if (himlInternalDrag == NULL) {
    734735        ERR("Error creating drag image list!\n");
     
    764765
    765766/*************************************************************************
    766  * ImageList_Copy [COMCTL32.44] 
    767  *
    768  *  Copies an image of the source image list to an image of the 
     767 * ImageList_Copy [COMCTL32.44]
     768 *
     769 *  Copies an image of the source image list to an image of the
    769770 *  destination image list. Images can be copied or swapped.
    770771 *
     
    787788
    788789BOOL WINAPI
    789 ImageList_Copy (HIMAGELIST himlDst, INT iDst,   HIMAGELIST himlSrc,
    790                 INT iSrc, INT uFlags)
    791 {
    792     HDC hdcSrc, hdcDst;   
     790ImageList_Copy (HIMAGELIST himlDst, INT iDst,   HIMAGELIST himlSrc,
     791        INT iSrc, INT uFlags)
     792{
     793    HDC hdcSrc, hdcDst;
    793794
    794795    TRACE("iDst=%d  iSrc=%d\n", iDst, iSrc);
    795796
    796797    if ((himlSrc == NULL) || (himlDst == NULL))
    797         return FALSE;
     798    return FALSE;
    798799    if ((iDst < 0) || (iDst >= himlDst->cCurImage))
    799         return FALSE;
     800    return FALSE;
    800801    if ((iSrc < 0) || (iSrc >= himlSrc->cCurImage))
    801         return FALSE;
     802    return FALSE;
    802803
    803804    hdcSrc = CreateCompatibleDC (0);
     
    815816                                       himlSrc->uBitsPixel, NULL);
    816817        hbmTempMask = CreateBitmap (himlSrc->cx, himlSrc->cy, 1,
    817                                       1, NULL);
     818                      1, NULL);
    818819
    819820        /* copy (and stretch) destination to temporary bitmaps.(save) */
     
    908909HIMAGELIST WINAPI
    909910ImageList_Create (INT cx, INT cy, UINT flags,
    910                   INT cInitial, INT cGrow)
     911          INT cInitial, INT cGrow)
    911912{
    912913    HIMAGELIST himl;
     
    914915    INT      nCount;
    915916    HBITMAP  hbmTemp;
    916     static WORD aBitBlend25[] = 
     917    static WORD aBitBlend25[] =
    917918        {0xAA, 0x00, 0x55, 0x00, 0xAA, 0x00, 0x55, 0x00};
    918919
     
    948949    if (himl->cMaxImage > 0) {
    949950        himl->hbmImage =
    950           CreateBitmap (himl->cx * himl->cMaxImage, himl->cy,
     951      CreateBitmap (himl->cx * himl->cMaxImage, himl->cy,
    951952                        1, himl->uBitsPixel, NULL);
    952         if (himl->hbmImage == 0) {
    953             ERR("Error creating image bitmap!\n");
    954             return NULL;
    955         }
     953    if (himl->hbmImage == 0) {
     954        ERR("Error creating image bitmap!\n");
     955        return NULL;
     956    }
    956957    }
    957958    else
    958959        himl->hbmImage = 0;
    959    
     960
    960961    if ( (himl->cMaxImage > 0) && (himl->flags & ILC_MASK)) {
    961962        himl->hbmMask = CreateBitmap (himl->cx * himl->cMaxImage, himl->cy,
    962                                         1, 1, NULL);
     963                    1, 1, NULL);
    963964        if (himl->hbmMask == 0) {
    964965            ERR("Error creating mask bitmap!\n");
     
    986987
    987988/*************************************************************************
    988  * ImageList_Destroy [COMCTL32.46] 
     989 * ImageList_Destroy [COMCTL32.46]
    989990 *
    990991 * Destroys an image list.
     
    10001001BOOL WINAPI
    10011002ImageList_Destroy (HIMAGELIST himl)
    1002 { 
     1003{
    10031004    if (!himl)
    1004         return FALSE;
     1005    return FALSE;
    10051006
    10061007    /* delete image bitmaps */
     
    10151016    if (himl->hbrBlend50)
    10161017        DeleteObject (himl->hbrBlend50);
    1017        
     1018
    10181019    COMCTL32_Free (himl);
    10191020
     
    10231024
    10241025/*************************************************************************
    1025  * ImageList_DragEnter [COMCTL32.47] 
     1026 * ImageList_DragEnter [COMCTL32.47]
    10261027 *
    10271028 * Locks window update and displays the drag image at the given position.
     
    10451046{
    10461047    if (himlInternalDrag == NULL)
    1047         return FALSE;
     1048    return FALSE;
    10481049
    10491050    if (hwndLock)
    1050         hwndInternalDrag = hwndLock;
     1051    hwndInternalDrag = hwndLock;
    10511052    else
    1052         hwndInternalDrag = GetDesktopWindow ();
     1053    hwndInternalDrag = GetDesktopWindow ();
    10531054
    10541055    xInternalPos = x;
     
    10571058    hdcBackBuffer = CreateCompatibleDC (0);
    10581059    hbmBackBuffer = CreateCompatibleBitmap (hdcBackBuffer,
    1059                 himlInternalDrag->cx, himlInternalDrag->cy);
     1060        himlInternalDrag->cx, himlInternalDrag->cy);
    10601061
    10611062    ImageList_DragShowNolock (TRUE);
     
    10661067
    10671068/*************************************************************************
    1068  * ImageList_DragLeave [COMCTL32.48] 
     1069 * ImageList_DragLeave [COMCTL32.48]
    10691070 *
    10701071 * Unlocks window update and hides the drag image.
     
    10821083{
    10831084    if (hwndLock)
    1084         hwndInternalDrag = hwndLock;
     1085    hwndInternalDrag = hwndLock;
    10851086    else
    1086         hwndInternalDrag = GetDesktopWindow ();
     1087    hwndInternalDrag = GetDesktopWindow ();
    10871088
    10881089    ImageList_DragShowNolock (FALSE);
     
    10961097
    10971098/*************************************************************************
    1098  * ImageList_DragMove [COMCTL32.49] 
     1099 * ImageList_DragMove [COMCTL32.49]
    10991100 *
    11001101 * Moves the drag image.
     
    11281129
    11291130/*************************************************************************
    1130  * ImageList_DragShowNolock [COMCTL32.50] 
     1131 * ImageList_DragShowNolock [COMCTL32.50]
    11311132 *
    11321133 * Shows or hides the drag image.
     
    11521153
    11531154    hdcDrag = GetDCEx (hwndInternalDrag, 0,
    1154                         DCX_WINDOW | DCX_CACHE | DCX_LOCKWINDOWUPDATE);
     1155            DCX_WINDOW | DCX_CACHE | DCX_LOCKWINDOWUPDATE);
    11551156
    11561157    if (bShow) {
    1157         /* show drag image */
    1158 
    1159         /* save background */
    1160 
    1161         /* draw drag image */
     1158    /* show drag image */
     1159
     1160    /* save background */
     1161
     1162    /* draw drag image */
    11621163
    11631164    }
    11641165    else {
    1165         /* hide drag image */
    1166 
    1167         /* restore background */
     1166    /* hide drag image */
     1167
     1168    /* restore background */
    11681169
    11691170    }
     
    11991200BOOL WINAPI
    12001201ImageList_Draw (HIMAGELIST himl, INT i, HDC hdc,
    1201                 INT x, INT y, UINT fStyle)
     1202        INT x, INT y, UINT fStyle)
    12021203{
    12031204    IMAGELISTDRAWPARAMS imldp;
     
    12521253BOOL WINAPI
    12531254ImageList_DrawEx (HIMAGELIST himl, INT i, HDC hdc, INT x, INT y,
    1254                   INT dx, INT dy, COLORREF rgbBk, COLORREF rgbFg,
    1255                   UINT fStyle)
     1255          INT dx, INT dy, COLORREF rgbBk, COLORREF rgbFg,
     1256          UINT fStyle)
    12561257{
    12571258    IMAGELISTDRAWPARAMS imldp;
     
    12771278
    12781279/*************************************************************************
    1279  * ImageList_DrawIndirect [COMCTL32.53] 
     1280 * ImageList_DrawIndirect [COMCTL32.53]
    12801281 *
    12811282 * Draws an image using ...
     
    12921293ImageList_DrawIndirect (IMAGELISTDRAWPARAMS *pimldp)
    12931294{
    1294     INT      cx, cy;   
    1295     /* 
     1295    INT      cx, cy;
     1296    /*
    12961297        Do some Error Checking
    12971298    */
     
    13031304        return FALSE;
    13041305    if ((pimldp->i < 0) || (pimldp->i >= pimldp->himl->cCurImage)) {
    1305         ERR("%d not within range (max %d)\n",pimldp->i,pimldp->himl->cCurImage-1);
     1306    ERR("%d not within range (max %d)\n",pimldp->i,pimldp->himl->cCurImage-1);
    13061307        return FALSE;
    13071308    }
     
    13221323        IMAGELIST_InternalDraw(pimldp, cx, cy);
    13231324    }
    1324     /* 
     1325    /*
    13251326        Apply the blend if needed to the Image
    13261327    */
     
    13871388        DeleteDC (hdcSrc);
    13881389
    1389         himlDst->cCurImage = himlSrc->cCurImage;
    1390         himlDst->cMaxImage = himlSrc->cMaxImage;
     1390    himlDst->cCurImage = himlSrc->cCurImage;
     1391    himlDst->cMaxImage = himlSrc->cMaxImage;
    13911392    }
    13921393    return himlDst;
     
    14471448{
    14481449    if (himl == NULL)
    1449         return CLR_NONE;
     1450    return CLR_NONE;
    14501451
    14511452    return himl->clrBk;
     
    14831484
    14841485/*************************************************************************
    1485  * ImageList_GetIcon [COMCTL32.59] 
     1486 * ImageList_GetIcon [COMCTL32.59]
    14861487 *
    14871488 * Creates an icon from a masked image of an image list.
     
    15061507
    15071508    if ((himl == NULL) || (i < 0) || (i >= himl->cCurImage)) {
    1508         FIXME("(%p,%d,%x), params out of range!\n",himl,i,fStyle);
    1509         return 0;
     1509    FIXME("(%p,%d,%x), params out of range!\n",himl,i,fStyle);
     1510    return 0;
    15101511   }
    15111512
     
    15191520    hOldDstBitmap = (HBITMAP)SelectObject (hdcDst, ii.hbmMask);
    15201521    if (himl->hbmMask) {
    1521         SelectObject (hdcSrc, himl->hbmMask);
    1522         BitBlt (hdcDst, 0, 0, himl->cx, himl->cy,
    1523                   hdcSrc, i * himl->cx, 0, SRCCOPY);
     1522    SelectObject (hdcSrc, himl->hbmMask);
     1523    BitBlt (hdcDst, 0, 0, himl->cx, himl->cy,
     1524          hdcSrc, i * himl->cx, 0, SRCCOPY);
    15241525    }
    15251526    else
    1526         PatBlt (hdcDst, 0, 0, himl->cx, himl->cy, BLACKNESS);
     1527    PatBlt (hdcDst, 0, 0, himl->cx, himl->cy, BLACKNESS);
    15271528
    15281529    /* draw image*/
     
    15311532    SelectObject (hdcDst, ii.hbmColor);
    15321533    BitBlt (hdcDst, 0, 0, himl->cx, himl->cy,
    1533               hdcSrc, i * himl->cx, 0, SRCCOPY);
     1534          hdcSrc, i * himl->cx, 0, SRCCOPY);
    15341535
    15351536    /*
    15361537     * CreateIconIndirect requires us to deselect the bitmaps from
    1537      * the DCs before calling 
     1538     * the DCs before calling
    15381539     */
    15391540    SelectObject(hdcSrc, hOldSrcBitmap);
    15401541    SelectObject(hdcDst, hOldDstBitmap);
    15411542
    1542     hIcon = CreateIconIndirect (&ii);   
     1543    hIcon = CreateIconIndirect (&ii);
    15431544
    15441545    DeleteDC (hdcSrc);
     
    15731574{
    15741575    if (himl == NULL)
    1575         return FALSE;
     1576    return FALSE;
    15761577    if ((himl->cx <= 0) || (himl->cy <= 0))
    1577         return FALSE;
     1578    return FALSE;
    15781579
    15791580    if (cx)
    1580         *cx = himl->cx;
     1581    *cx = himl->cx;
    15811582    if (cy)
    1582         *cy = himl->cy;
     1583    *cy = himl->cy;
    15831584
    15841585    return TRUE;
     
    16031604{
    16041605    if (himl == NULL)
    1605         return 0;
     1606    return 0;
    16061607
    16071608    return himl->cCurImage;
     
    16281629{
    16291630    if ((himl == NULL) || (pImageInfo == NULL))
    1630         return FALSE;
     1631    return FALSE;
    16311632    if ((i < 0) || (i >= himl->cCurImage))
    1632         return FALSE;
     1633    return FALSE;
    16331634
    16341635    pImageInfo->hbmImage = himl->hbmImage;
    16351636    pImageInfo->hbmMask  = himl->hbmMask;
    1636    
     1637
    16371638    pImageInfo->rcImage.top    = 0;
    16381639    pImageInfo->rcImage.bottom = himl->cy;
    16391640    pImageInfo->rcImage.left   = i * himl->cx;
    16401641    pImageInfo->rcImage.right  = (i+1) * himl->cx;
    1641    
     1642
    16421643    return TRUE;
    16431644}
     
    16451646
    16461647/*************************************************************************
    1647  * ImageList_GetImageRect [COMCTL32.63] 
     1648 * ImageList_GetImageRect [COMCTL32.63]
    16481649 *
    16491650 * Retrieves the rectangle of the specified image in an image list.
     
    16661667{
    16671668    if ((himl == NULL) || (lpRect == NULL))
    1668         return FALSE;
     1669    return FALSE;
    16691670    if ((i < 0) || (i >= himl->cCurImage))
    1670         return FALSE;
     1671    return FALSE;
    16711672
    16721673    lpRect->left   = i * himl->cx;
     
    17041705HIMAGELIST WINAPI
    17051706ImageList_LoadImageA (HINSTANCE hi, LPCSTR lpbmp, INT cx, INT cGrow,
    1706                         COLORREF clrMask, UINT uType, UINT uFlags)
     1707            COLORREF clrMask, UINT uType, UINT uFlags)
    17071708{
    17081709    HIMAGELIST himl = NULL;
     
    17441745        GetIconInfo (handle, &ii);
    17451746        GetObjectA (ii.hbmColor, sizeof(BITMAP), (LPVOID)&bmp);
    1746         himl = ImageList_Create (bmp.bmWidth, bmp.bmHeight, 
     1747        himl = ImageList_Create (bmp.bmWidth, bmp.bmHeight,
    17471748                                 ILC_MASK | ILC_COLOR, 1, cGrow);
    17481749        ImageList_Add (himl, ii.hbmColor, ii.hbmMask);
     
    17521753
    17531754    DeleteObject (handle);
    1754    
     1755
    17551756    return himl;
    17561757}
     
    17811782HIMAGELIST WINAPI
    17821783ImageList_LoadImageW (HINSTANCE hi, LPCWSTR lpbmp, INT cx, INT cGrow,
    1783                         COLORREF clrMask, UINT uType,   UINT uFlags)
     1784            COLORREF clrMask, UINT uType,   UINT uFlags)
    17841785{
    17851786    HIMAGELIST himl = NULL;
     
    18081809        GetIconInfo (handle, &ii);
    18091810        GetObjectA (ii.hbmMask, sizeof(BITMAP), (LPVOID)&bmp);
    1810         himl = ImageList_Create (bmp.bmWidth, bmp.bmHeight, 
     1811        himl = ImageList_Create (bmp.bmWidth, bmp.bmHeight,
    18111812                                 ILC_MASK | ILC_COLOR, 1, cGrow);
    18121813        ImageList_Add (himl, ii.hbmColor, ii.hbmMask);
     
    18161817
    18171818    DeleteObject (handle);
    1818    
     1819
    18191820    return himl;
    18201821}
     
    18221823
    18231824/*************************************************************************
    1824  * ImageList_Merge [COMCTL32.67] 
     1825 * ImageList_Merge [COMCTL32.67]
    18251826 *
    18261827 * Creates a new image list that contains a merged image from the specified
     
    18421843HIMAGELIST WINAPI
    18431844ImageList_Merge (HIMAGELIST himl1, INT i1, HIMAGELIST himl2, INT i2,
    1844                 INT dx, INT dy)
     1845        INT dx, INT dy)
    18451846{
    18461847    HIMAGELIST himlDst = NULL;
     
    18511852
    18521853    if ((himl1 == NULL) || (himl2 == NULL))
    1853         return NULL;
     1854    return NULL;
    18541855
    18551856    /* check indices */
     
    19031904        nX1 = i1 * himl1->cx;
    19041905        nX2 = i2 * himl2->cx;
    1905        
     1906
    19061907        /* copy image */
    19071908        SelectObject (hdcSrcImage, himl1->hbmImage);
    19081909        SelectObject (hdcDstImage, himlDst->hbmImage);
    1909         BitBlt (hdcDstImage, 0, 0, cxDst, cyDst, 
     1910        BitBlt (hdcDstImage, 0, 0, cxDst, cyDst,
    19101911                  hdcSrcImage, 0, 0, BLACKNESS);
    1911         BitBlt (hdcDstImage, xOff1, yOff1, himl1->cx, himl1->cy, 
     1912        BitBlt (hdcDstImage, xOff1, yOff1, himl1->cx, himl1->cy,
    19121913                  hdcSrcImage, nX1, 0, SRCCOPY);
    19131914
    19141915        SelectObject (hdcSrcImage, himl2->hbmMask);
    1915         BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 
     1916        BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy,
    19161917                  hdcSrcImage, nX2, 0, SRCAND);
    19171918
    19181919        SelectObject (hdcSrcImage, himl2->hbmImage);
    1919         BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 
     1920        BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy,
    19201921                  hdcSrcImage, nX2, 0, SRCPAINT);
    19211922
     
    19231924        SelectObject (hdcSrcImage, himl1->hbmMask);
    19241925        SelectObject (hdcDstImage, himlDst->hbmMask);
    1925         BitBlt (hdcDstImage, 0, 0, cxDst, cyDst, 
     1926        BitBlt (hdcDstImage, 0, 0, cxDst, cyDst,
    19261927                  hdcSrcImage, 0, 0, WHITENESS);
    1927         BitBlt (hdcDstImage, xOff1, yOff1, himl1->cx, himl1->cy, 
     1928        BitBlt (hdcDstImage, xOff1, yOff1, himl1->cx, himl1->cy,
    19281929                  hdcSrcImage, nX1, 0, SRCCOPY);
    19291930
    19301931        SelectObject (hdcSrcImage, himl2->hbmMask);
    1931         BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 
     1932        BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy,
    19321933                  hdcSrcImage, nX2, 0, SRCAND);
    19331934
     
    19351936        DeleteDC (hdcDstImage);
    19361937    }
    1937    
     1938
    19381939    return himlDst;
    19391940}
     
    19451946    int bitspixel = GetDeviceCaps(hdc,BITSPIXEL)*GetDeviceCaps(hdc,PLANES);
    19461947    if (bitspixel>8)
    1947         return TRUE;
     1948    return TRUE;
    19481949    if (bitspixel<=4)
    1949         return FALSE;
     1950    return FALSE;
    19501951    return GetDeviceCaps(hdc,CAPS1) & C1_DIBENGINE;
    19511952}
     
    19541955/* helper for ImageList_Read, see comments below */
    19551956static 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))
     1957    HDC         xdc = 0;
     1958    BITMAPFILEHEADER    bmfh;
     1959    BITMAPINFOHEADER    bmih;
     1960    int         bitsperpixel,palspace,longsperline,width,height;
     1961    LPBITMAPINFOHEADER  bmihc = NULL;
     1962    int         result = 0;
     1963    HBITMAP     hbitmap = 0;
     1964    LPBYTE      bits = NULL,nbits = NULL;
     1965    int         nbytesperline,bytesperline;
     1966
     1967    if (!SUCCEEDED(IStream_Read ( pstm, &bmfh, sizeof(bmfh), NULL)) ||
     1968        (bmfh.bfType != (('M'<<8)|'B'))                 ||
     1969        !SUCCEEDED(IStream_Read ( pstm, &bmih, sizeof(bmih), NULL)) ||
     1970        (bmih.biSize != sizeof(bmih))
    19701971    )
    1971         return 0;
     1972    return 0;
    19721973
    19731974    bitsperpixel = bmih.biPlanes * bmih.biBitCount;
    19741975    if (bitsperpixel<=8)
    1975         palspace = (1<<bitsperpixel)*sizeof(RGBQUAD);
     1976        palspace = (1<<bitsperpixel)*sizeof(RGBQUAD);
    19761977    else
    1977         palspace = 0;
     1978        palspace = 0;
    19781979    width = bmih.biWidth;
    19791980    height = bmih.biHeight;
    19801981    bmihc = (LPBITMAPINFOHEADER)LocalAlloc(LMEM_ZEROINIT,sizeof(bmih)+palspace);
    19811982    memcpy(bmihc,&bmih,sizeof(bmih));
    1982     longsperline        = ((width*bitsperpixel+31)&~0x1f)>>5;
    1983     bmihc->biSizeImage  = (longsperline*height)<<2;
     1983    longsperline    = ((width*bitsperpixel+31)&~0x1f)>>5;
     1984    bmihc->biSizeImage  = (longsperline*height)<<2;
    19841985
    19851986    /* read the palette right after the end of the bitmapinfoheader */
    19861987    if (palspace)
    1987         if (!SUCCEEDED(IStream_Read ( pstm, bmihc+1, palspace, NULL)))
    1988             goto ret1;
     1988    if (!SUCCEEDED(IStream_Read ( pstm, bmihc+1, palspace, NULL)))
     1989        goto ret1;
    19891990
    19901991    xdc = GetDC(0);
    19911992#if 0 /* Magic for NxM -> 1x(N*M) not implemented for DIB Sections */
    19921993    if ((bitsperpixel>1) &&
    1993         ((ilcFlag!=ILC_COLORDDB) && (!ilcFlag || may_use_dibsection(xdc)))
     1994    ((ilcFlag!=ILC_COLORDDB) && (!ilcFlag || may_use_dibsection(xdc)))
    19941995     ) {
    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;
     1996    hbitmap = CreateDIBSection(xdc,(BITMAPINFO*)bmihc,0,(LPVOID*)&bits,0,0);
     1997    if (!hbitmap)
     1998        goto ret1;
     1999    if (!SUCCEEDED(IStream_Read( pstm, bits, bmihc->biSizeImage, NULL)))
     2000        goto ret1;
     2001    result = 1;
    20012002    } else
    20022003#endif
    20032004    {
    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;
     2005    int i,nwidth,nheight;
     2006
     2007    nwidth  = width*(height/cy);
     2008    nheight = cy;
     2009
     2010    if (bitsperpixel==1)
     2011        hbitmap = CreateBitmap(nwidth,nheight,1,1,NULL);
     2012    else
     2013        hbitmap = CreateCompatibleBitmap(xdc,nwidth,nheight);
     2014
     2015    /* Might be a bit excessive memory use here */
     2016    bits = (LPBYTE)LocalAlloc(LMEM_ZEROINIT,bmihc->biSizeImage);
     2017    nbits = (LPBYTE)LocalAlloc(LMEM_ZEROINIT,bmihc->biSizeImage);
     2018    if (!SUCCEEDED(IStream_Read ( pstm, bits, bmihc->biSizeImage, NULL)))
     2019        goto ret1;
     2020
     2021    /* Copy the NxM bitmap into a 1x(N*M) bitmap we need, linewise */
     2022    /* Do not forget that windows bitmaps are bottom->top */
     2023    bytesperline    = longsperline*4;
     2024    nbytesperline   = (height/cy)*bytesperline;
     2025    for (i=0;i<height;i++) {
     2026        memcpy(
     2027        nbits+((height-1-i)%cy)*nbytesperline+(i/cy)*bytesperline,
     2028        bits+bytesperline*(height-1-i),
     2029        bytesperline
     2030        );
     2031    }
     2032    bmihc->biWidth  = nwidth;
     2033    bmihc->biHeight = nheight;
     2034    if (!SetDIBits(xdc,hbitmap,0,nheight,nbits,(BITMAPINFO*)bmihc,0))
     2035        goto ret1;
     2036    LocalFree((HLOCAL)nbits);
     2037    LocalFree((HLOCAL)bits);
     2038    result = 1;
    20382039    }
    20392040ret1:
    2040     if (xdc)    ReleaseDC(0,xdc);
    2041     if (bmihc)  LocalFree((HLOCAL)bmihc);
     2041    if (xdc)    ReleaseDC(0,xdc);
     2042    if (bmihc)  LocalFree((HLOCAL)bmihc);
    20422043    if (!result) {
    2043         if (hbitmap) {
    2044             DeleteObject(hbitmap);
    2045             hbitmap = 0;
    2046         }
     2044    if (hbitmap) {
     2045        DeleteObject(hbitmap);
     2046        hbitmap = 0;
     2047    }
    20472048    }
    20482049    return hbitmap;
     
    20622063 *
    20632064 * The format is like this:
    2064  *      ILHEAD                  ilheadstruct;
     2065 *  ILHEAD          ilheadstruct;
    20652066 *
    20662067 * for the color image part:
    2067  *      BITMAPFILEHEADER        bmfh;
    2068  *      BITMAPINFOHEADER        bmih;
     2068 *  BITMAPFILEHEADER    bmfh;
     2069 *  BITMAPINFOHEADER    bmih;
    20692070 * only if it has a palette:
    2070  *      RGBQUAD         rgbs[nr_of_paletted_colors];
    2071  *
    2072  *      BYTE                    colorbits[imagesize];
     2071 *  RGBQUAD     rgbs[nr_of_paletted_colors];
     2072 *
     2073 *  BYTE            colorbits[imagesize];
    20732074 *
    20742075 * the following only if the ILC_MASK bit is set in ILHEAD.ilFlags:
    2075  *      BITMAPFILEHEADER        bmfh_mask;
    2076  *      BITMAPINFOHEADER        bmih_mask;
     2076 *  BITMAPFILEHEADER    bmfh_mask;
     2077 *  BITMAPINFOHEADER    bmih_mask;
    20772078 * only if it has a palette (it usually does not):
    2078  *      RGBQUAD         rgbs[nr_of_paletted_colors];
    2079  *
    2080  *      BYTE                    maskbits[imagesize];
     2079 *  RGBQUAD     rgbs[nr_of_paletted_colors];
     2080 *
     2081 *  BYTE            maskbits[imagesize];
    20812082 *
    20822083 * CAVEAT: Those images are within a NxM bitmap, not the 1xN we expect.
     
    20852086HIMAGELIST WINAPI ImageList_Read (LPSTREAM pstm)
    20862087{
    2087     ILHEAD      ilHead;
    2088     HIMAGELIST  himl;
    2089     HBITMAP     hbmColor=0,hbmMask=0;
    2090     int         i;
     2088    ILHEAD  ilHead;
     2089    HIMAGELIST  himl;
     2090    HBITMAP hbmColor=0,hbmMask=0;
     2091    int     i;
    20912092
    20922093    if (!SUCCEEDED(IStream_Read (pstm, &ilHead, sizeof(ILHEAD), NULL)))
    2093         return NULL;
     2094        return NULL;
    20942095    if (ilHead.usMagic != (('L' << 8) | 'I'))
    2095         return NULL;
     2096    return NULL;
    20962097    if (ilHead.usVersion != 0x101) /* probably version? */
    2097         return NULL;
     2098    return NULL;
    20982099
    20992100#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]);
     2101    FIXME(" ilHead.cCurImage = %d\n",ilHead.cCurImage);
     2102    FIXME(" ilHead.cMaxImage = %d\n",ilHead.cMaxImage);
     2103    FIXME(" ilHead.cGrow = %d\n",ilHead.cGrow);
     2104    FIXME(" ilHead.cx = %d\n",ilHead.cx);
     2105    FIXME(" ilHead.cy = %d\n",ilHead.cy);
     2106    FIXME(" ilHead.flags = %x\n",ilHead.flags);
     2107    FIXME(" ilHead.ovls[0] = %d\n",ilHead.ovls[0]);
     2108    FIXME(" ilHead.ovls[1] = %d\n",ilHead.ovls[1]);
     2109    FIXME(" ilHead.ovls[2] = %d\n",ilHead.ovls[2]);
     2110    FIXME(" ilHead.ovls[3] = %d\n",ilHead.ovls[3]);
    21102111#endif
    21112112
    21122113    hbmColor = _read_bitmap(pstm,ilHead.flags & ~ILC_MASK,ilHead.cx,ilHead.cy);
    21132114    if (!hbmColor)
    2114         return NULL;
     2115    return NULL;
    21152116    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         }
     2117    hbmMask = _read_bitmap(pstm,0,ilHead.cx,ilHead.cy);
     2118    if (!hbmMask) {
     2119        DeleteObject(hbmColor);
     2120        return NULL;
     2121    }
    21212122    }
    21222123
    21232124    himl = ImageList_Create (
    2124                     ilHead.cx,
    2125                     ilHead.cy,
    2126                     ilHead.flags,
    2127                     1,          /* initial */
    2128                     ilHead.cGrow
     2125            ilHead.cx,
     2126            ilHead.cy,
     2127            ilHead.flags,
     2128            1,      /* initial */
     2129            ilHead.cGrow
    21292130    );
    21302131    if (!himl) {
    2131         DeleteObject(hbmColor);
    2132         DeleteObject(hbmMask);
    2133         return NULL;
     2132    DeleteObject(hbmColor);
     2133    DeleteObject(hbmMask);
     2134    return NULL;
    21342135    }
    21352136    himl->hbmImage = hbmColor;
     
    21402141    ImageList_SetBkColor(himl,ilHead.bkcolor);
    21412142    for (i=0;i<4;i++)
    2142         ImageList_SetOverlayImage(himl,ilHead.ovls[i],i+1);
     2143        ImageList_SetOverlayImage(himl,ilHead.ovls[i],i+1);
    21432144    return himl;
    21442145}
     
    21682169        return FALSE;
    21692170    }
    2170    
     2171
    21712172    if ((i < -1) || (i >= himl->cCurImage)) {
    21722173        ERR("index out of range! %d\n", i);
     
    22112212        TRACE(" - Max. number of images: %d / %d (Old/New)\n",
    22122213                 himl->cMaxImage, himl->cCurImage + himl->cGrow - 1);
    2213        
     2214
    22142215        hbmNewImage =
    22152216            CreateBitmap (cxNew, himl->cy, 1, himl->uBitsPixel, NULL);
     
    22262227        if (i > 0) {
    22272228            TRACE("Pre image copy: Copy %d images\n", i);
    2228        
     2229
    22292230            SelectObject (hdcSrc, himl->hbmImage);
    22302231            SelectObject (hdcDst, hbmNewImage);
     
    22772278
    22782279/*************************************************************************
    2279  * ImageList_Replace [COMCTL32.70] 
     2280 * ImageList_Replace [COMCTL32.70]
    22802281 *
    22812282 * Replaces an image in an image list with a new image.
     
    22942295BOOL WINAPI
    22952296ImageList_Replace (HIMAGELIST himl, INT i, HBITMAP hbmImage,
    2296                    HBITMAP hbmMask)
     2297           HBITMAP hbmMask)
    22972298{
    22982299    HDC hdcImageList, hdcImage;
     
    23032304        return FALSE;
    23042305    }
    2305    
     2306
    23062307    if ((i >= himl->cMaxImage) || (i < 0)) {
    23072308        ERR("Invalid image index!\n");
     
    23332334        */
    23342335        SelectObject (hdcImageList, himl->hbmImage);
    2335         StretchBlt (hdcImageList, 
     2336        StretchBlt (hdcImageList,
    23362337            i*himl->cx, 0, himl->cx, himl->cy,
    2337             hdcImage, 
    2338             0, 0, bmp.bmWidth, bmp.bmHeight, 
     2338            hdcImage,
     2339            0, 0, bmp.bmWidth, bmp.bmHeight,
    23392340            0x220326); /* NOTSRCAND */
    23402341    }
     
    23752376
    23762377    if (himl == NULL)
    2377         return -1;
     2378    return -1;
    23782379    if ((i >= himl->cMaxImage) || (i < -1))
    2379         return -1;
     2380    return -1;
    23802381
    23812382    hBestFitIcon = CopyImage(
    2382         hIcon, IMAGE_ICON, 
    2383         himl->cx, himl->cy, 
     2383        hIcon, IMAGE_ICON,
     2384        himl->cx, himl->cy,
    23842385        LR_COPYFROMRESOURCE);
    23852386
    23862387    GetIconInfo (hBestFitIcon, &ii);
    23872388    if (ii.hbmMask == 0)
    2388         ERR("no mask!\n");
     2389    ERR("no mask!\n");
    23892390    if (ii.hbmColor == 0)
    2390         ERR("no color!\n");
     2391    ERR("no color!\n");
    23912392    GetObjectA (ii.hbmMask, sizeof(BITMAP), (LPVOID)&bmp);
    23922393
     
    24042405    TRACE("hdcImageList=0x%x!\n", hdcImageList);
    24052406    if (hdcImageList == 0)
    2406         ERR("invalid hdcImageList!\n");
     2407    ERR("invalid hdcImageList!\n");
    24072408
    24082409    hdcImage = CreateCompatibleDC (0);
    24092410    TRACE("hdcImage=0x%x!\n", hdcImage);
    24102411    if (hdcImage == 0)
    2411         ERR("invalid hdcImage!\n");
     2412    ERR("invalid hdcImage!\n");
    24122413
    24132414    hbmOldDst = SelectObject (hdcImageList, himl->hbmImage);
     
    24292430
    24302431    if(hBestFitIcon)
    2431         DestroyIcon(hBestFitIcon);
     2432    DestroyIcon(hBestFitIcon);
    24322433    if (hdcImageList)
    2433         DeleteDC (hdcImageList);
     2434    DeleteDC (hdcImageList);
    24342435    if (hdcImage)
    2435         DeleteDC (hdcImage);
     2436    DeleteDC (hdcImage);
    24362437    if (ii.hbmColor)
    2437         DeleteObject (ii.hbmColor);
     2438    DeleteObject (ii.hbmColor);
    24382439    if (ii.hbmMask)
    2439         DeleteObject (ii.hbmMask);
     2440    DeleteObject (ii.hbmMask);
    24402441
    24412442    return nIndex;
     
    24442445
    24452446/*************************************************************************
    2446  * ImageList_SetBkColor [COMCTL32.76] 
     2447 * ImageList_SetBkColor [COMCTL32.76]
    24472448 *
    24482449 * Sets the background color of an image list.
     
    24632464
    24642465    if (himl == NULL)
    2465         return CLR_NONE;
     2466    return CLR_NONE;
    24662467
    24672468    clrOldBk = himl->clrBk;
     
    24922493BOOL WINAPI
    24932494ImageList_SetDragCursorImage (HIMAGELIST himlDrag, INT iDrag,
    2494                               INT dxHotspot, INT dyHotspot)
     2495                  INT dxHotspot, INT dyHotspot)
    24952496{
    24962497    HIMAGELIST himlTemp;
     
    24992500
    25002501    if (himlInternalDrag == NULL)
    2501         return FALSE;
     2502    return FALSE;
    25022503
    25032504    TRACE(" dxH=%d dyH=%d nX=%d nY=%d\n",
    2504            dxHotspot, dyHotspot, nInternalDragHotspotX, nInternalDragHotspotY);
     2505       dxHotspot, dyHotspot, nInternalDragHotspotX, nInternalDragHotspotY);
    25052506
    25062507    himlTemp = ImageList_Merge (himlInternalDrag, 0, himlDrag, iDrag,
    2507                                 dxHotspot, dyHotspot);
     2508                dxHotspot, dyHotspot);
    25082509
    25092510    ImageList_Destroy (himlInternalDrag);
     
    25182519
    25192520/*************************************************************************
    2520  * ImageList_SetFilter [COMCTL32.78] 
     2521 * ImageList_SetFilter [COMCTL32.78]
    25212522 *
    25222523 * Sets a filter (or does something completely different)!!???
     
    25402541{
    25412542    FIXME("(%p 0x%x 0x%lx):empty stub!\n",
    2542            himl, i, dwFilter);
     2543       himl, i, dwFilter);
    25432544
    25442545    return FALSE;
     
    25672568
    25682569    if (!himl)
    2569         return FALSE;
     2570    return FALSE;
    25702571
    25712572    /* remove all images */
     
    26172618
    26182619    if (!himl)
    2619         return FALSE;
     2620    return FALSE;
    26202621    if (himl->cCurImage >= iImageCount)
    2621         return FALSE;
     2622    return FALSE;
    26222623    if (himl->cMaxImage > iImageCount)
    2623         return TRUE;
     2624    return TRUE;
    26242625
    26252626    nNewCount = iImageCount + himl->cGrow;
     
    26362637        SelectObject (hdcBitmap, hbmNewBitmap);
    26372638
    2638         /* copy images */
     2639    /* copy images */
    26392640        BitBlt (hdcBitmap, 0, 0, nCopyCount * himl->cx, himl->cy,
    26402641                  hdcImageList, 0, 0, SRCCOPY);
    26412642#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);
     2643    /* delete 'empty' image space */
     2644    SetBkColor (hdcBitmap, RGB(255, 255, 255));
     2645    SetTextColor (hdcBitmap, RGB(0, 0, 0));
     2646    PatBlt (hdcBitmap,  nCopyCount * himl->cx, 0,
     2647          (nNewCount - nCopyCount) * himl->cx, himl->cy, BLACKNESS);
    26472648#endif
    2648         DeleteObject (himl->hbmImage);
    2649         himl->hbmImage = hbmNewBitmap;
     2649    DeleteObject (himl->hbmImage);
     2650    himl->hbmImage = hbmNewBitmap;
    26502651    }
    26512652    else
    2652         ERR("Could not create new image bitmap !\n");
     2653    ERR("Could not create new image bitmap !\n");
    26532654
    26542655    if (himl->hbmMask)
     
    26612662            SelectObject (hdcBitmap, hbmNewBitmap);
    26622663
    2663             /* copy images */
     2664        /* copy images */
    26642665            BitBlt (hdcBitmap, 0, 0, nCopyCount * himl->cx, himl->cy,
    26652666                      hdcImageList, 0, 0, SRCCOPY);
    26662667#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);
     2668        /* delete 'empty' image space */
     2669        SetBkColor (hdcBitmap, RGB(255, 255, 255));
     2670        SetTextColor (hdcBitmap, RGB(0, 0, 0));
     2671            PatBlt (hdcBitmap,  nCopyCount * himl->cx, 0,
     2672              (nNewCount - nCopyCount) * himl->cx, himl->cy, BLACKNESS);
    26722673#endif
    26732674            DeleteObject (himl->hbmMask);
     
    27092710{
    27102711    if (!himl)
    2711         return FALSE;
     2712    return FALSE;
    27122713    if ((iOverlay < 1) || (iOverlay > MAX_OVERLAYIMAGE))
    2713         return FALSE;
     2714    return FALSE;
    27142715    if ((iImage!=-1) && ((iImage < 0) || (iImage > himl->cCurImage)))
    2715         return FALSE;
     2716    return FALSE;
    27162717    himl->nOvlIdx[iOverlay - 1] = iImage;
    27172718    return TRUE;
     
    27442745{
    27452746    if (!himl)
    2746         return FALSE;
     2747    return FALSE;
    27472748
    27482749    FIXME("empty stub!\n");
  • trunk/src/comctl32/initcomctl32.cpp

    r6401 r6644  
     1/* $Id: initcomctl32.cpp,v 1.3 2001-09-05 12:04:58 bird Exp $ */
    12/*
    23 * COMCTL32 DLL entry point
     
    2627#define  INCL_DOSMODULEMGR
    2728#define  INCL_DOSPROCESS
    28 #include <os2wrap.h>    //Odin32 OS/2 api wrappers
     29#include <os2wrap.h>    //Odin32 OS/2 api wrappers
    2930#include <stdlib.h>
    3031#include <stdio.h>
     
    5960   {
    6061        BOOL ret = COMCTL32_LibMain(hinstDLL, fdwReason, fImpLoad);
    61         return ret;
     62    return ret;
    6263   }
    6364   }
     
    8586   switch (ulFlag) {
    8687      case 0 :
    87         dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&comctl32_PEResTab,
     88    dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&comctl32_PEResTab,
    8889                                   COMCTL32_MAJORIMAGE_VERSION, COMCTL32_MINORIMAGE_VERSION,
    8990                                   IMAGE_SUBSYSTEM_WINDOWS_GUI);
    90          if(dllHandle == 0) 
    91                 return 0UL;
     91         if(dllHandle == 0)
     92        return 0UL;
    9293
    9394         break;
    9495      case 1 :
    9596         if(dllHandle) {
    96                 UnregisterLxDll(dllHandle);
     97        UnregisterLxDll(dllHandle);
    9798         }
    9899         break;
  • trunk/src/comctl32/initterm.cpp

    r6375 r6644  
     1/* $Id: initterm.cpp,v 1.16 2001-09-05 12:04:59 bird Exp $ */
    12/*
    23 * COMCTL32 DLL entry point
     
    2627#define  INCL_DOSMODULEMGR
    2728#define  INCL_DOSPROCESS
    28 #include <os2wrap.h>    //Odin32 OS/2 api wrappers
     29#include <os2wrap.h>    //Odin32 OS/2 api wrappers
    2930#include <stdlib.h>
    3031#include <stdio.h>
  • trunk/src/comctl32/listview.c

    r6320 r6644  
     1/* $Id: listview.c,v 1.33 2001-09-05 12:04:59 bird Exp $ */
    12/*
    23 * Listview control
  • trunk/src/comctl32/monthcal.c

    r5416 r6644  
     1/* $Id: monthcal.c,v 1.12 2001-09-05 12:05:00 bird Exp $ */
    12/* Month calendar control
    2 
     3 *
    34 *
    45 * Copyright 1998, 1999 Eric Kohl (ekohl@abo.rhein-zeitung.de)
    56 * Copyright 1999 Alex Priem (alexp@sci.kun.nl)
    67 * Copyright 1999 Chris Morgan <cmorgan@wpi.edu> and
    7  *                James Abbatiello <abbeyj@wpi.edu>
     8 *        James Abbatiello <abbeyj@wpi.edu>
    89 * Copyright 2000 Uwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
    910 *
     
    1314 *
    1415 *  FIXME: handle resources better (doesn't work now); also take care
    15            of internationalization.
     16 *         of internationalization.
    1617 *  FIXME: keyboard handling.
    1718 */
     
    4344DEFAULT_DEBUG_CHANNEL(monthcal);
    4445
    45 #define MC_SEL_LBUTUP       1   /* Left button released */
    46 #define MC_SEL_LBUTDOWN     2   /* Left button pressed in calendar */
     46#define MC_SEL_LBUTUP       1   /* Left button released */
     47#define MC_SEL_LBUTDOWN     2   /* Left button pressed in calendar */
    4748#define MC_PREVPRESSED      4   /* Prev month button pressed */
    4849#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                   
     50#define MC_NEXTMONTHDELAY   350 /* when continuously pressing `next */
     51                                        /* month', wait 500 ms before going */
     52                                        /* to the next month */
     53#define MC_NEXTMONTHTIMER   1           /* Timer ID's */
     54#define MC_PREVMONTHTIMER   2
    5455
    5556typedef struct
     
    5859    COMCTL32_HEADER header;
    5960#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 */
     61    COLORREF    bk;
     62    COLORREF    txt;
     63    COLORREF    titlebk;
     64    COLORREF    titletxt;
     65    COLORREF    monthbk;
     66    COLORREF    trailingtxt;
     67    HFONT   hFont;
     68    HFONT   hBoldFont;
     69    int     textHeight;
     70    int     textWidth;
     71    int     height_increment;
     72    int     width_increment;
     73    int     left_offset;
     74    int     top_offset;
     75    int     firstDayplace; /* place of the first day of the current month */
     76    int     delta;  /* scroll rate; # of months that the */
    7677                        /* 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;
     78    int     visible;    /* # of months visible */
     79    int     firstDay;   /* Start month calendar with firstDay's day */
     80    int     monthRange;
    8081    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 */
     82    SYSTEMTIME  todaysDate;
     83    DWORD   currentMonth;
     84    DWORD   currentYear;
     85    int     status;     /* See MC_SEL flags */
     86    int     curSelDay;  /* current selected day */
     87    int     firstSelDay;    /* first selected day */
     88    int     maxSelCount;
     89    SYSTEMTIME  minSel;
     90    SYSTEMTIME  maxSel;
     91    DWORD   rangeValid;
     92    SYSTEMTIME  minDate;
     93    SYSTEMTIME  maxDate;
     94
     95    RECT rcClient;  /* rect for whole client area */
     96    RECT rcDraw;    /* rect for drawable portion of client area */
     97    RECT title;     /* rect for the header above the calendar */
     98    RECT titlebtnnext;  /* the `next month' button in the header */
     99    RECT titlebtnprev;  /* the `prev month' button in the header */
     100    RECT titlemonth;    /* the `month name' txt in the header */
     101    RECT titleyear; /* the `year number' txt in the header */
     102    RECT wdays;     /* week days at top */
     103    RECT days;      /* calendar area */
     104    RECT weeknums;  /* week numbers at left side */
     105    RECT todayrect; /* `today: xx/xx/xx' text rect */
    105106    HWND hWndYearEdit;  /* Window Handle of edit box to handle years */
    106107    HWND hWndYearUpDown;/* Window Handle of updown box to handle years */
     
    141142
    142143/* make sure that time is valid */
    143 static int MONTHCAL_ValidateTime(SYSTEMTIME time) 
     144static int MONTHCAL_ValidateTime(SYSTEMTIME time)
    144145{
    145146  if(time.wMonth > 12) return FALSE;
    146147  if(time.wDayOfWeek > 6) return FALSE;
    147148  if(time.wDay > MONTHCAL_MonthLength(time.wMonth, time.wYear))
    148           return FALSE;
     149      return FALSE;
    149150  if(time.wHour > 23) return FALSE;
    150151  if(time.wMinute > 59) return FALSE;
     
    156157
    157158
    158 void MONTHCAL_CopyTime(const SYSTEMTIME *from, SYSTEMTIME *to) 
     159void MONTHCAL_CopyTime(const SYSTEMTIME *from, SYSTEMTIME *to)
    159160{
    160161  to->wYear = from->wYear;
     
    169170
    170171
    171 /* Note:Depending on DST, this may be offset by a day. 
     172/* Note:Depending on DST, this may be offset by a day.
    172173   Need to find out if we're on a DST place & adjust the clock accordingly.
    173174   Above function assumes we have a valid data.
     
    182183  year-=(month < 3);
    183184
    184   return((year + year/4 - year/100 + year/400 + 
     185  return((year + year/4 - year/100 + year/400 +
    185186         DayOfWeekTable[month-1] + day - 1 ) % 7);
    186187}
     
    189190   and day in the calendar. day== 0 mean the last day of tha last month
    190191*/
    191 static int MONTHCAL_CalcDayFromPos(MONTHCAL_INFO *infoPtr, int x, int y, 
    192                                    int *daypos,int *weekpos)
     192static int MONTHCAL_CalcDayFromPos(MONTHCAL_INFO *infoPtr, int x, int y,
     193                   int *daypos,int *weekpos)
    193194{
    194195  int retval, firstDay;
     
    202203  *daypos = (x - infoPtr->days.left ) / infoPtr->width_increment;
    203204  *weekpos = (y - infoPtr->days.top ) / infoPtr->height_increment;
    204    
     205
    205206  firstDay = (MONTHCAL_CalculateDayOfWeek(1, infoPtr->currentMonth, infoPtr->currentYear)+6 - infoPtr->firstDay)%7;
    206207  retval = *daypos + (7 * *weekpos) - firstDay;
     
    211212/* sets x and y to be the position of the day */
    212213/* x == day, y == week where(0,0) == firstDay, 1st week */
    213 static void MONTHCAL_CalcDayXY(MONTHCAL_INFO *infoPtr, int day, int month, 
     214static void MONTHCAL_CalcDayXY(MONTHCAL_INFO *infoPtr, int day, int month,
    214215                                 int *x, int *y)
    215216{
     
    227228    if(prevMonth==0)
    228229       prevMonth = 12;
    229    
     230
    230231    *x = (MONTHCAL_MonthLength(prevMonth, infoPtr->currentYear) - firstDay) % 7;
    231232    *y = 0;
     
    240241
    241242/* x: column(day), y: row(week) */
    242 static void MONTHCAL_CalcDayRect(MONTHCAL_INFO *infoPtr, RECT *r, int x, int y) 
     243static void MONTHCAL_CalcDayRect(MONTHCAL_INFO *infoPtr, RECT *r, int x, int y)
    243244{
    244245  r->left = infoPtr->days.left + x * infoPtr->width_increment;
     
    252253/* day is the day value of the month(1 == 1st), month is the month */
    253254/* value(january == 1, december == 12) */
    254 static inline void MONTHCAL_CalcPosFromDay(MONTHCAL_INFO *infoPtr, 
     255static inline void MONTHCAL_CalcPosFromDay(MONTHCAL_INFO *infoPtr,
    255256                                            int day, int month, RECT *r)
    256257{
     
    278279  x = day_rect.left;
    279280  y = day_rect.top;
    280        
     281
    281282  points[0].x = x;
    282283  points[0].y = y - 1;
     
    287288  points[3].x = x + infoPtr->width_increment;
    288289  points[3].y = y + 0.5 * infoPtr->height_increment;
    289        
     290
    290291  points[4].x = x + infoPtr->width_increment;
    291292  points[4].y = y + 0.9 * infoPtr->height_increment;
     
    294295  points[6].x = x + 0.5 * infoPtr->width_increment;
    295296  points[6].y = y + 0.9 * infoPtr->height_increment; /* bring the bottom up just
    296                                 a hair to fit inside the day rectangle */
    297        
     297                a hair to fit inside the day rectangle */
     298
    298299  points[7].x = x + 0.2 * infoPtr->width_increment;
    299300  points[7].y = y + 0.8 * infoPtr->height_increment;
     
    309310  points[12].x = x + 0.4 * infoPtr->width_increment;
    310311  points[12].y = y + 0.2 * infoPtr->height_increment;
    311  
     312
    312313  PolyBezier(hdc, points, 13);
    313314  DeleteObject(hRedPen);
     
    329330  sprintf(buf, "%d", day);
    330331
    331 /* No need to check styles: when selection is not valid, it is set to zero. 
     332/* No need to check styles: when selection is not valid, it is set to zero.
    332333 * 1<day<31, so evertyhing's OK.
    333334 */
     
    349350
    350351    /* FIXME: this may need to be changed now b/c of the other
    351         drawing changes 11/3/99 CMM */
     352    drawing changes 11/3/99 CMM */
    352353    r2.left   = r.left - 0.25 * infoPtr->textWidth;
    353354    r2.top    = r.top;
     
    390391
    391392/* CHECKME: For `todays date', do we need to check the locale?*/
    392 static void MONTHCAL_Refresh(HWND hwnd, HDC hdc, PAINTSTRUCT* ps) 
     393static void MONTHCAL_Refresh(HWND hwnd, HDC hdc, PAINTSTRUCT* ps)
    393394{
    394395  MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd);
     
    425426  hbr = CreateSolidBrush (infoPtr->bk);
    426427  FillRect(hdc, rcClient, hbr);
    427   DeleteObject(hbr);       
     428  DeleteObject(hbr);
    428429
    429430  /* draw header */
     
    434435    DeleteObject(hbr);
    435436  }
    436        
     437
    437438  /* if the previous button is pressed draw it depressed */
    438439  if(IntersectRect(&rcTemp, &(ps->rcPaint), prev))
    439   { 
     440  {
    440441    if((infoPtr->status & MC_PREVPRESSED))
    441442        DrawFrameControl(hdc, prev, DFC_SCROLL,
    442            DFCS_SCROLLLEFT | DFCS_PUSHED |
     443       DFCS_SCROLLLEFT | DFCS_PUSHED |
    443444          (dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0));
    444445    else /* if the previous button is pressed draw it depressed */
    445446      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 */   
     447       DFCS_SCROLLLEFT |(dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0));
     448  }
     449
     450  /* if next button is depressed draw it depressed */
    450451  if(IntersectRect(&rcTemp, &(ps->rcPaint), next))
    451452  {
    452453    if((infoPtr->status & MC_NEXTPRESSED))
    453454      DrawFrameControl(hdc, next, DFC_SCROLL,
    454            DFCS_SCROLLRIGHT | DFCS_PUSHED |
     455           DFCS_SCROLLRIGHT | DFCS_PUSHED |
    455456           (dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0));
    456457    else /* if the next button is pressed draw it depressed */
     
    466467  titlemonth->left   = title->left;
    467468  titlemonth->right  = title->right;
    468  
     469
    469470  GetLocaleInfoA( LOCALE_USER_DEFAULT,LOCALE_SMONTHNAME1+infoPtr->currentMonth -1,
    470                   buf1,sizeof(buf1));
     471          buf1,sizeof(buf1));
    471472  sprintf(buf, "%s %ld", buf1, infoPtr->currentYear);
    472  
     473
    473474  if(IntersectRect(&rcTemp, &(ps->rcPaint), titlemonth))
    474475  {
    475     DrawTextA(hdc, buf, strlen(buf), titlemonth, 
     476    DrawTextA(hdc, buf, strlen(buf), titlemonth,
    476477                        DT_CENTER | DT_VCENTER | DT_SINGLELINE);
    477478  }
     
    481482/* titlemonth left/right contained rect for whole titletxt('June  1999')
    482483  * MCM_HitTestInfo wants month & year rects, so prepare these now.
    483   *(no, we can't draw them separately; the whole text is centered) 
     484  *(no, we can't draw them separately; the whole text is centered)
    484485  */
    485486  GetTextExtentPoint32A(hdc, buf, strlen(buf), &size);
     
    489490  titlemonth->right = titlemonth->left + size.cx;
    490491  titleyear->left = titlemonth->right;
    491  
     492
    492493  /* draw month area */
    493494  rcTemp.top=infoPtr->wdays.top;
     
    501502    DeleteObject(hbr);
    502503  }
    503        
     504
    504505/* draw line under day abbreviatons */
    505506
    506507  MoveToEx(hdc, infoPtr->days.left + 3, title->bottom + textHeight + 1, NULL);
    507      
     508
    508509  LineTo(hdc, rcDraw->right - 3, title->bottom + textHeight + 1);
    509  
     510
    510511  prevMonth = infoPtr->currentMonth - 1;
    511512  if(prevMonth == 0) /* if currentMonth is january(1) prevMonth is */
     
    529530  for(j=0; j<7; j++) {
    530531    GetLocaleInfoA( LOCALE_USER_DEFAULT,LOCALE_SABBREVDAYNAME1 + (i +j)%7,
    531                     buf,sizeof(buf));
     532            buf,sizeof(buf));
    532533    DrawTextA(hdc, buf, strlen(buf), days,
    533534                         DT_CENTER | DT_VCENTER | DT_SINGLELINE );
     
    537538
    538539/* draw day numbers; first, the previous month */
    539  
     540
    540541  firstDay = MONTHCAL_CalculateDayOfWeek(1, infoPtr->currentMonth, infoPtr->currentYear);
    541  
    542   day = MONTHCAL_MonthLength(prevMonth, infoPtr->currentYear)  + 
     542
     543  day = MONTHCAL_MonthLength(prevMonth, infoPtr->currentYear)  +
    543544    (infoPtr->firstDay + 7  - firstDay)%7 + 1;
    544545  if (day > MONTHCAL_MonthLength(prevMonth, infoPtr->currentYear))
     
    553554    if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay))
    554555    {
    555       MONTHCAL_DrawDay(hdc, infoPtr, day, prevMonth, i, 0, 
     556      MONTHCAL_DrawDay(hdc, infoPtr, day, prevMonth, i, 0,
    556557          infoPtr->monthdayState[m] & mask);
    557558    }
     
    577578    {
    578579
    579       MONTHCAL_DrawDay(hdc, infoPtr, day, infoPtr->currentMonth, i, 0, 
    580         infoPtr->monthdayState[m] & mask);
     580      MONTHCAL_DrawDay(hdc, infoPtr, day, infoPtr->currentMonth, i, 0,
     581    infoPtr->monthdayState[m] & mask);
    581582
    582583      if((infoPtr->currentMonth==infoPtr->todaysDate.wMonth) &&
    583584          (day==infoPtr->todaysDate.wDay) &&
    584           (infoPtr->currentYear == infoPtr->todaysDate.wYear)) {
     585      (infoPtr->currentYear == infoPtr->todaysDate.wYear)) {
    585586        if(!(dwStyle & MCS_NOTODAYCIRCLE))
    586           MONTHCAL_CircleDay(hdc, infoPtr, day, infoPtr->currentMonth);
     587      MONTHCAL_CircleDay(hdc, infoPtr, day, infoPtr->currentMonth);
    587588      }
    588589    }
     
    595596  j = 1; /* move to the 2nd week of the current month */
    596597  i = 0; /* move back to sunday */
    597   while(day <= MONTHCAL_MonthLength(infoPtr->currentMonth, infoPtr->currentYear)) {     
     598  while(day <= MONTHCAL_MonthLength(infoPtr->currentMonth, infoPtr->currentYear)) {
    598599    MONTHCAL_CalcDayRect(infoPtr, &rcDay, i, j);
    599600    if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay))
     
    604605      if((infoPtr->currentMonth==infoPtr->todaysDate.wMonth) &&
    605606          (day==infoPtr->todaysDate.wDay) &&
    606           (infoPtr->currentYear == infoPtr->todaysDate.wYear)) 
    607         if(!(dwStyle & MCS_NOTODAYCIRCLE)) 
    608           MONTHCAL_CircleDay(hdc, infoPtr, day, infoPtr->currentMonth);
     607          (infoPtr->currentYear == infoPtr->todaysDate.wYear))
     608        if(!(dwStyle & MCS_NOTODAYCIRCLE))
     609      MONTHCAL_CircleDay(hdc, infoPtr, day, infoPtr->currentMonth);
    609610    }
    610611    mask<<=1;
     
    627628    MONTHCAL_CalcDayRect(infoPtr, &rcDay, i, j);
    628629    if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay))
    629     {   
     630    {
    630631      MONTHCAL_DrawDay(hdc, infoPtr, day, infoPtr->currentMonth + 1, i, j,
    631                 infoPtr->monthdayState[m] & mask);
     632        infoPtr->monthdayState[m] & mask);
    632633    }
    633634
    634635    mask<<=1;
    635636    day++;
    636     i++;       
     637    i++;
    637638    if(i==7) { /* past saturday, go to next week's sunday */
    638639      i = 0;
     
    650651    if(!(dwStyle & MCS_NOTODAYCIRCLE))  {
    651652      /*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);
     653      MONTHCAL_CircleDay(hdc, infoPtr,
     654             day+MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear),
     655            infoPtr->currentMonth);
    655656      offset+=textWidth;
    656657    }
    657658    if (!LoadStringA(COMCTL32_hModule,IDM_TODAY,buf1,sizeof(buf1)))
    658659      {
    659         WARN("Can't load resource\n");
    660         strcpy(buf1,"Today:");
     660    WARN("Can't load resource\n");
     661    strcpy(buf1,"Today:");
    661662      }
    662663    MONTHCAL_CalcDayRect(infoPtr, &rtoday, 1, 6);
     
    674675  }
    675676
    676 /*eventually draw week numbers*/   
     677/*eventually draw week numbers*/
    677678  if(dwStyle & MCS_WEEKNUMBERS)  {
    678679    /* display weeknumbers*/
     
    682683       LOCALE_IFIRSTWEEKOFYEAR == 0 (e.g US?):
    683684       The week containing Jan 1 is the first week of year
    684        LOCALE_IFIRSTWEEKOFYEAR == 2 (e.g. Germany): 
     685       LOCALE_IFIRSTWEEKOFYEAR == 2 (e.g. Germany):
    685686       First week of year must contain 4 days of the new year
    686687       LOCALE_IFIRSTWEEKOFYEAR == 1  (what contries?)
     
    688689    */
    689690    GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_IFIRSTWEEKOFYEAR,
    690                      buf, sizeof(buf));
     691             buf, sizeof(buf));
    691692    sscanf(buf, "%d", &weeknum);
    692693    switch (weeknum)
    693694      {
    694695      case 1: mindays = 6;
    695         break;
     696    break;
    696697      case 2: mindays = 3;
    697         break;
     698    break;
    698699      case 0:
    699700      default:
    700         mindays = 0;
     701    mindays = 0;
    701702      }
    702703    if (infoPtr->currentMonth < 2)
    703704      {
    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           }
     705    /* calculate all those exceptions for january */
     706    weeknum1=MONTHCAL_CalculateDayOfWeek(1,1,infoPtr->currentYear);
     707    if ((infoPtr->firstDay +7 - weeknum1)%7 > mindays)
     708        weeknum =1;
     709    else
     710      {
     711        weeknum = 0;
     712        for(i=0; i<11; i++)
     713          weeknum+=MONTHCAL_MonthLength(i+1, infoPtr->currentYear-1);
     714        weeknum +=startofprescal+ 7;
     715        weeknum /=7;
     716        weeknum1=MONTHCAL_CalculateDayOfWeek(1,1,infoPtr->currentYear-1);
     717        if ((infoPtr->firstDay + 7 - weeknum1)%7 > mindays)
     718          weeknum++;
     719      }
    719720      }
    720721    else
    721722      {
    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++;
     723    weeknum = 0;
     724    for(i=0; i<prevMonth-1; i++)
     725      weeknum+=MONTHCAL_MonthLength(i+1, infoPtr->currentYear);
     726    weeknum +=startofprescal+ 7;
     727    weeknum /=7;
     728    weeknum1=MONTHCAL_CalculateDayOfWeek(1,1,infoPtr->currentYear);
     729    if ((infoPtr->firstDay + 7 - weeknum1)%7 > mindays)
     730      weeknum++;
    730731      }
    731732    days->left = infoPtr->weeknums.left;
     
    735736    for(i=0; i<6; i++) {
    736737      if((i==0)&&(weeknum>50))
    737         {
    738           sprintf(buf, "%d", weeknum);
    739           weeknum=0;
    740         }
     738    {
     739      sprintf(buf, "%d", weeknum);
     740      weeknum=0;
     741    }
    741742      else if((i==5)&&(weeknum>47))
    742         {
    743           sprintf(buf, "%d", 1);
    744         }
     743    {
     744      sprintf(buf, "%d", 1);
     745    }
    745746      else
    746         sprintf(buf, "%d", weeknum + i);
     747    sprintf(buf, "%d", weeknum + i);
    747748      DrawTextA(hdc, buf, -1, days, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
    748749      days->top+=infoPtr->height_increment;
    749750      days->bottom+=infoPtr->height_increment;
    750751    }
    751                        
     752
    752753    MoveToEx(hdc, infoPtr->weeknums.right, infoPtr->weeknums.top + 3 , NULL);
    753754    LineTo(hdc,   infoPtr->weeknums.right, infoPtr->weeknums.bottom );
    754                
     755
    755756  }
    756757  /* currentFont was font at entering Refresh */
    757758
    758759  SetBkColor(hdc, oldBkColor);
    759   SelectObject(hdc, currentFont);     
     760  SelectObject(hdc, currentFont);
    760761  SetTextColor(hdc, oldTextColor);
    761762}
    762763
    763764
    764 static LRESULT 
     765static LRESULT
    765766MONTHCAL_GetMinReqRect(HWND hwnd, WPARAM wParam, LPARAM lParam)
    766767{
     
    768769  LPRECT lpRect = (LPRECT) lParam;
    769770  TRACE("%x %lx\n", wParam, lParam);
    770        
     771
    771772  /* validate parameters */
    772773
     
    781782
    782783
    783 static LRESULT 
     784static LRESULT
    784785MONTHCAL_GetColor(HWND hwnd, WPARAM wParam, LPARAM lParam)
    785786{
     
    807808
    808809
    809 static LRESULT 
     810static LRESULT
    810811MONTHCAL_SetColor(HWND hwnd, WPARAM wParam, LPARAM lParam)
    811812{
     
    847848
    848849
    849 static LRESULT 
     850static LRESULT
    850851MONTHCAL_GetMonthDelta(HWND hwnd, WPARAM wParam, LPARAM lParam)
    851852{
     
    853854
    854855  TRACE("%x %lx\n", wParam, lParam);
    855  
     856
    856857  if(infoPtr->delta)
    857858    return infoPtr->delta;
     
    861862
    862863
    863 static LRESULT 
     864static LRESULT
    864865MONTHCAL_SetMonthDelta(HWND hwnd, WPARAM wParam, LPARAM lParam)
    865866{
     
    868869
    869870  TRACE("%x %lx\n", wParam, lParam);
    870        
     871
    871872  infoPtr->delta = (int)wParam;
    872873  return prev;
     
    874875
    875876
    876 static LRESULT 
     877static LRESULT
    877878MONTHCAL_GetFirstDayOfWeek(HWND hwnd, WPARAM wParam, LPARAM lParam)
    878879{
    879880  MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
    880        
     881
    881882  return infoPtr->firstDay;
    882883}
     
    887888/* FIXME: this needs to be implemented properly in MONTHCAL_Refresh() */
    888889/* FIXME: we need more error checking here */
    889 static LRESULT 
     890static LRESULT
    890891MONTHCAL_SetFirstDayOfWeek(HWND hwnd, WPARAM wParam, LPARAM lParam)
    891892{
     
    903904    {
    904905      GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_IFIRSTDAYOFWEEK,
    905                      buf, sizeof(buf));
     906             buf, sizeof(buf));
    906907      TRACE("%s %d\n", buf, strlen(buf));
    907908      if(sscanf(buf, "%d", &day) == 1)
    908         infoPtr->firstDay = day;
     909    infoPtr->firstDay = day;
    909910      else
    910         infoPtr->firstDay = 0;
     911    infoPtr->firstDay = 0;
    911912    }
    912913  return prev;
     
    916917/* FIXME: fill this in */
    917918static LRESULT
    918 MONTHCAL_GetMonthRange(HWND hwnd, WPARAM wParam, LPARAM lParam) 
     919MONTHCAL_GetMonthRange(HWND hwnd, WPARAM wParam, LPARAM lParam)
    919920{
    920921  MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd);
     
    937938
    938939/* FIXME: are validated times taken from current date/time or simply
    939  * copied? 
     940 * copied?
    940941 * FIXME:    check whether MCM_GETMONTHRANGE shows correct result after
    941942 *            adjusting range with MCM_SETRANGE
     
    950951
    951952  TRACE("%x %lx\n", wParam, lParam);
    952  
     953
    953954  if(wParam & GDTR_MAX) {
    954955    if(MONTHCAL_ValidateTime(lprgSysTimeArray[1])){
     
    973974  infoPtr->monthRange = infoPtr->maxDate.wMonth - infoPtr->minDate.wMonth;
    974975
    975   if(infoPtr->monthRange!=prev) { 
    976         COMCTL32_ReAlloc(infoPtr->monthdayState,
    977                 infoPtr->monthRange * sizeof(MONTHDAYSTATE));
     976  if(infoPtr->monthRange!=prev) {
     977    COMCTL32_ReAlloc(infoPtr->monthdayState,
     978        infoPtr->monthRange * sizeof(MONTHDAYSTATE));
    978979  }
    979980
     
    983984
    984985/* CHECKME: At the moment, we copy ranges anyway,regardless of
    985  * infoPtr->rangeValid; a invalid range is simply filled with zeros in 
     986 * infoPtr->rangeValid; a invalid range is simply filled with zeros in
    986987 * SetRange.  Is this the right behavior?
    987988*/
     
    10151016  if(iMonths!=infoPtr->monthRange) return 0;
    10161017
    1017   for(i=0; i<iMonths; i++) 
     1018  for(i=0; i<iMonths; i++)
    10181019    infoPtr->monthdayState[i] = dayStates[i];
    10191020  return 1;
    10201021}
    10211022
    1022 static LRESULT 
     1023static LRESULT
    10231024MONTHCAL_GetCurSel(HWND hwnd, WPARAM wParam, LPARAM lParam)
    10241025{
     
    10361037/* FIXME: if the specified date is not visible, make it visible */
    10371038/* FIXME: redraw? */
    1038 static LRESULT 
     1039static LRESULT
    10391040MONTHCAL_SetCurSel(HWND hwnd, WPARAM wParam, LPARAM lParam)
    10401041{
     
    10571058
    10581059
    1059 static LRESULT 
     1060static LRESULT
    10601061MONTHCAL_GetMaxSelCount(HWND hwnd, WPARAM wParam, LPARAM lParam)
    10611062{
     
    10671068
    10681069
    1069 static LRESULT 
     1070static LRESULT
    10701071MONTHCAL_SetMaxSelCount(HWND hwnd, WPARAM wParam, LPARAM lParam)
    10711072{
     
    10811082
    10821083
    1083 static LRESULT 
     1084static LRESULT
    10841085MONTHCAL_GetSelRange(HWND hwnd, WPARAM wParam, LPARAM lParam)
    10851086{
     
    11001101    return TRUE;
    11011102  }
    1102  
     1103
    11031104  return FALSE;
    11041105}
    11051106
    11061107
    1107 static LRESULT 
     1108static LRESULT
    11081109MONTHCAL_SetSelRange(HWND hwnd, WPARAM wParam, LPARAM lParam)
    11091110{
     
    11241125    return TRUE;
    11251126  }
    1126  
     1127
    11271128  return FALSE;
    11281129}
    11291130
    11301131
    1131 static LRESULT 
     1132static LRESULT
    11321133MONTHCAL_GetToday(HWND hwnd, WPARAM wParam, LPARAM lParam)
    11331134{
     
    11451146
    11461147
    1147 static LRESULT 
     1148static LRESULT
    11481149MONTHCAL_SetToday(HWND hwnd, WPARAM wParam, LPARAM lParam)
    11491150{
     
    11701171  DWORD retval;
    11711172  int day,wday,wnum;
    1172  
    1173  
     1173
     1174
    11741175  x = lpht->pt.x;
    11751176  y = lpht->pt.y;
    11761177  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);
     1178
     1179
     1180  /* Comment in for debugging...
     1181  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,
     1182    infoPtr->wdays.left, infoPtr->wdays.right,
     1183    infoPtr->wdays.top, infoPtr->wdays.bottom,
     1184    infoPtr->days.left, infoPtr->days.right,
     1185    infoPtr->days.top, infoPtr->days.bottom,
     1186    infoPtr->todayrect.left, infoPtr->todayrect.right,
     1187    infoPtr->todayrect.top, infoPtr->todayrect.bottom,
     1188    infoPtr->weeknums.left, infoPtr->weeknums.right,
     1189    infoPtr->weeknums.top, infoPtr->weeknums.bottom);
    11891190  */
    11901191
    11911192  /* are we in the header? */
    1192  
     1193
    11931194  if(PtInRect(&infoPtr->title, lpht->pt)) {
    11941195    if(PtInRect(&infoPtr->titlebtnprev, lpht->pt)) {
     
    12081209      goto done;
    12091210    }
    1210    
     1211
    12111212    retval = MCHT_TITLE;
    12121213    goto done;
    12131214  }
    1214  
     1215
    12151216  day = MONTHCAL_CalcDayFromPos(infoPtr,x,y,&wday,&wnum);
    12161217  if(PtInRect(&infoPtr->wdays, lpht->pt)) {
     
    12181219    lpht->st.wYear  = infoPtr->currentYear;
    12191220    lpht->st.wMonth = (day < 1)? infoPtr->currentMonth -1 : infoPtr->currentMonth;
    1220     lpht->st.wDay   = (day < 1)? 
     1221    lpht->st.wDay   = (day < 1)?
    12211222      MONTHCAL_MonthLength(infoPtr->currentMonth-1,infoPtr->currentYear) -day : day;
    12221223    goto done;
    12231224  }
    1224   if(PtInRect(&infoPtr->weeknums, lpht->pt)) { 
    1225     retval = MCHT_CALENDARWEEKNUM; 
     1225  if(PtInRect(&infoPtr->weeknums, lpht->pt)) {
     1226    retval = MCHT_CALENDARWEEKNUM;
    12261227    lpht->st.wYear  = infoPtr->currentYear;
    1227     lpht->st.wMonth = (day < 1) ? infoPtr->currentMonth -1 : 
    1228       (day > MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear)) ? 
     1228    lpht->st.wMonth = (day < 1) ? infoPtr->currentMonth -1 :
     1229      (day > MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear)) ?
    12291230      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)) ? 
     1231    lpht->st.wDay   = (day < 1 ) ?
     1232      MONTHCAL_MonthLength(infoPtr->currentMonth-1,infoPtr->currentYear) -day :
     1233      (day > MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear)) ?
    12331234      day - MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear) : day;
    1234     goto done;                             
    1235   }
    1236   if(PtInRect(&infoPtr->days, lpht->pt)) 
     1235    goto done;
     1236  }
     1237  if(PtInRect(&infoPtr->days, lpht->pt))
    12371238    {
    12381239      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         }
     1240      if ( day < 1)
     1241    {
     1242      retval = MCHT_CALENDARDATEPREV;
     1243      lpht->st.wMonth = infoPtr->currentMonth - 1;
     1244      if (lpht->st.wMonth <1)
     1245        {
     1246          lpht->st.wMonth = 12;
     1247          lpht->st.wYear--;
     1248        }
     1249      lpht->st.wDay   = MONTHCAL_MonthLength(lpht->st.wMonth,lpht->st.wYear) -day;
     1250    }
    12501251      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         }
     1252    {
     1253      retval = MCHT_CALENDARDATENEXT;
     1254      lpht->st.wMonth = infoPtr->currentMonth + 1;
     1255      if (lpht->st.wMonth <12)
     1256        {
     1257          lpht->st.wMonth = 1;
     1258          lpht->st.wYear++;
     1259        }
     1260      lpht->st.wDay   = day - MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear) ;
     1261    }
    12611262      else {
    1262         retval = MCHT_CALENDARDATE;
    1263         lpht->st.wMonth = infoPtr->currentMonth;
    1264         lpht->st.wDay   = day;
     1263    retval = MCHT_CALENDARDATE;
     1264    lpht->st.wMonth = infoPtr->currentMonth;
     1265    lpht->st.wDay   = day;
    12651266      }
    12661267      goto done;
    12671268    }
    12681269  if(PtInRect(&infoPtr->todayrect, lpht->pt)) {
    1269     retval = MCHT_TODAYLINK; 
     1270    retval = MCHT_TODAYLINK;
    12701271    goto done;
    12711272  }
    1272  
    1273  
     1273
     1274
    12741275  /* Hit nothing special? What's left must be background :-) */
    1275  
    1276   retval = MCHT_CALENDARBK;       
    1277  done: 
     1276
     1277  retval = MCHT_CALENDARBK;
     1278 done:
    12781279  lpht->uHit = retval;
    12791280  return retval;
     
    13001301    nmds.nmhdr.idFrom   = GetWindowLongA(hwnd, GWL_ID);
    13011302    nmds.nmhdr.code     = MCN_GETDAYSTATE;
    1302     nmds.cDayState      = infoPtr->monthRange;
    1303     nmds.prgDayState    = COMCTL32_Alloc(infoPtr->monthRange * sizeof(MONTHDAYSTATE));
     1303    nmds.cDayState  = infoPtr->monthRange;
     1304    nmds.prgDayState    = COMCTL32_Alloc(infoPtr->monthRange * sizeof(MONTHDAYSTATE));
    13041305
    13051306    SendMessageA(GetParent(hwnd), WM_NOTIFY,
     
    13301331    nmds.nmhdr.idFrom   = GetWindowLongA(hwnd, GWL_ID);
    13311332    nmds.nmhdr.code     = MCN_GETDAYSTATE;
    1332     nmds.cDayState      = infoPtr->monthRange;
    1333     nmds.prgDayState    = COMCTL32_Alloc
     1333    nmds.cDayState  = infoPtr->monthRange;
     1334    nmds.prgDayState    = COMCTL32_Alloc
    13341335                        (infoPtr->monthRange * sizeof(MONTHDAYSTATE));
    13351336
     
    13481349  POINT menupoint;
    13491350  char buf[32];
    1350  
     1351
    13511352  hMenu = CreatePopupMenu();
    13521353  if (!LoadStringA(COMCTL32_hModule,IDM_GOTODAY,buf,sizeof(buf)))
     
    13601361  ClientToScreen(hwnd, &menupoint);
    13611362  if( TrackPopupMenu(hMenu,TPM_RIGHTBUTTON| TPM_NONOTIFY|TPM_RETURNCMD,
    1362                      menupoint.x,menupoint.y,0,hwnd,NULL))
     1363             menupoint.x,menupoint.y,0,hwnd,NULL))
    13631364    {
    13641365      infoPtr->currentMonth=infoPtr->todaysDate.wMonth;
    13651366      infoPtr->currentYear=infoPtr->todaysDate.wYear;
    13661367      InvalidateRect(hwnd, NULL, FALSE);
    1367     }   
     1368    }
    13681369  return 0;
    13691370}
     
    13811382  POINT menupoint;
    13821383  TRACE("%x %lx\n", wParam, lParam);
    1383        
     1384
    13841385  if (infoPtr->hWndYearUpDown)
    13851386    {
    13861387      infoPtr->currentYear=SendMessageA( infoPtr->hWndYearUpDown, UDM_SETPOS,   (WPARAM) 0,(LPARAM)0);
    13871388      if(!DestroyWindow(infoPtr->hWndYearUpDown))
    1388         {
    1389           FIXME("Can't destroy Updown Control\n");
    1390         }
     1389    {
     1390      FIXME("Can't destroy Updown Control\n");
     1391    }
    13911392      else
    1392         infoPtr->hWndYearUpDown=0;
     1393    infoPtr->hWndYearUpDown=0;
    13931394      if(!DestroyWindow(infoPtr->hWndYearEdit))
    1394         {
    1395           FIXME("Can't destroy Updown Control\n");
    1396         }
     1395    {
     1396      FIXME("Can't destroy Updown Control\n");
     1397    }
    13971398      else
    1398         infoPtr->hWndYearEdit=0;
     1399    infoPtr->hWndYearEdit=0;
    13991400      InvalidateRect(hwnd, NULL, FALSE);
    14001401    }
    1401  
     1402
    14021403  ht.pt.x = (INT)LOWORD(lParam);
    14031404  ht.pt.y = (INT)HIWORD(lParam);
     
    14141415    return TRUE;
    14151416  }
    1416   if(hit == MCHT_TITLEBTNPREV){ 
     1417  if(hit == MCHT_TITLEBTNPREV){
    14171418    MONTHCAL_GoToPrevMonth(hwnd, infoPtr);
    14181419    infoPtr->status = MC_PREVPRESSED;
     
    14241425  if(hit == MCHT_TITLEMONTH) {
    14251426    hMenu = CreatePopupMenu();
    1426    
     1427
    14271428    for (i=0; i<12;i++)
    14281429      {
    1429         GetLocaleInfoA( LOCALE_USER_DEFAULT,LOCALE_SMONTHNAME1+i,
    1430                   buf,sizeof(buf));
    1431         AppendMenuA(hMenu, MF_STRING|MF_ENABLED,i+1, buf);
     1430    GetLocaleInfoA( LOCALE_USER_DEFAULT,LOCALE_SMONTHNAME1+i,
     1431          buf,sizeof(buf));
     1432    AppendMenuA(hMenu, MF_STRING|MF_ENABLED,i+1, buf);
    14321433      }
    14331434    menupoint.x=infoPtr->titlemonth.right;
     
    14351436    ClientToScreen(hwnd, &menupoint);
    14361437    i= TrackPopupMenu(hMenu,TPM_LEFTALIGN | TPM_NONOTIFY | TPM_RIGHTBUTTON | TPM_RETURNCMD,
    1437                       menupoint.x,menupoint.y,0,hwnd,NULL);
     1438              menupoint.x,menupoint.y,0,hwnd,NULL);
    14381439    if ((i>0) && (i<13))
    14391440      {
    1440         infoPtr->currentMonth=i;
    1441         InvalidateRect(hwnd, NULL, FALSE);
     1441    infoPtr->currentMonth=i;
     1442    InvalidateRect(hwnd, NULL, FALSE);
    14421443      }
    14431444  }
    14441445  if(hit == MCHT_TITLEYEAR) {
    14451446    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);
     1447            "EDIT",
     1448               0,
     1449            WS_VISIBLE | WS_CHILD |UDS_SETBUDDYINT,
     1450            infoPtr->titleyear.left+3,infoPtr->titlebtnnext.top,
     1451            infoPtr->titleyear.right-infoPtr->titleyear.left,
     1452            infoPtr->textHeight,
     1453            hwnd,
     1454             (HMENU)NULL,
     1455             (HINSTANCE)NULL,
     1456            NULL);
    14561457    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);
     1458            UPDOWN_CLASSA,
     1459               0,
     1460            WS_VISIBLE | WS_CHILD |UDS_SETBUDDYINT|UDS_NOTHOUSANDS|UDS_ARROWKEYS,
     1461            infoPtr->titleyear.right+6,infoPtr->titlebtnnext.top,
     1462            20,
     1463            infoPtr->textHeight,
     1464            hwnd,
     1465             (HMENU)NULL,
     1466             (HINSTANCE)NULL,
     1467            NULL);
    14671468    SendMessageA( infoPtr->hWndYearUpDown, UDM_SETRANGE, (WPARAM) 0, MAKELONG (9999, 1753));
    14681469    SendMessageA( infoPtr->hWndYearUpDown, UDM_SETBUDDY, (WPARAM) infoPtr->hWndYearEdit, (LPARAM)0 );
    14691470    SendMessageA( infoPtr->hWndYearUpDown, UDM_SETPOS,   (WPARAM) 0,(LPARAM)infoPtr->currentYear );
    14701471    return TRUE;
    1471          
     1472
    14721473  }
    14731474  if(hit == MCHT_TODAYLINK) {
     
    14871488    MONTHCAL_CopyTime(&nmsc.stSelStart, &infoPtr->minSel);
    14881489    MONTHCAL_CopyTime(&nmsc.stSelEnd, &infoPtr->maxSel);
    1489        
     1490
    14901491    SendMessageA(GetParent(hwnd), WM_NOTIFY,
    14911492           (WPARAM)nmsc.nmhdr.idFrom,(LPARAM)&nmsc);
     
    14931494    MONTHCAL_CopyTime(&ht.st, &selArray[0]);
    14941495    MONTHCAL_CopyTime(&ht.st, &selArray[1]);
    1495     MONTHCAL_SetSelRange(hwnd,0,(LPARAM) &selArray); 
     1496    MONTHCAL_SetSelRange(hwnd,0,(LPARAM) &selArray);
    14961497
    14971498    /* redraw both old and new days if the selected day changed */
     
    15461547    return TRUE;
    15471548  }
    1548   if(hit == MCHT_CALENDARDATEPREV){ 
     1549  if(hit == MCHT_CALENDARDATEPREV){
    15491550    MONTHCAL_GoToPrevMonth(hwnd, infoPtr);
    15501551    InvalidateRect(hwnd, NULL, FALSE);
     
    15641565  MONTHCAL_CopyTime(&nmsc.stSelStart, &infoPtr->minSel);
    15651566  MONTHCAL_CopyTime(&nmsc.stSelEnd, &infoPtr->maxSel);
    1566        
     1567
    15671568  SendMessageA(GetParent(hwnd), WM_NOTIFY,
    15681569           (WPARAM)nmsc.nmhdr.idFrom, (LPARAM)&nmsc);
    1569  
     1570
    15701571  /* redraw if necessary */
    15711572  if(redraw)
    15721573    InvalidateRect(hwnd, NULL, FALSE);
    1573        
     1574
    15741575  return 0;
    15751576}
     
    15861587
    15871588  switch(wParam) {
    1588   case MC_NEXTMONTHTIMER: 
     1589  case MC_NEXTMONTHTIMER:
    15891590    redraw = TRUE;
    15901591    MONTHCAL_GoToNextMonth(hwnd, infoPtr);
     
    16181619  ht.pt.x = LOWORD(lParam);
    16191620  ht.pt.y = HIWORD(lParam);
    1620        
     1621
    16211622  hit = MONTHCAL_HitTest(hwnd, (LPARAM)&ht);
    1622  
     1623
    16231624  /* not on the calendar date numbers? bail out */
    16241625  TRACE("hit:%x\n",hit);
     
    16381639    if(infoPtr->firstSelDay==selArray[0].wDay) i=1;
    16391640    TRACE("oldRange:%d %d %d %d\n", infoPtr->firstSelDay, selArray[0].wDay, selArray[1].wDay, i);
    1640     if(infoPtr->firstSelDay==selArray[1].wDay) { 
     1641    if(infoPtr->firstSelDay==selArray[1].wDay) {
    16411642      /* 1st time we get here: selArray[0]=selArray[1])  */
    16421643      /* if we're still at the first selected date, return */
     
    16441645      if(selday<infoPtr->firstSelDay) i = 0;
    16451646    }
    1646                        
     1647
    16471648    if(abs(infoPtr->firstSelDay - selday) >= infoPtr->maxSelCount) {
    16481649      if(selday>infoPtr->firstSelDay)
     
    16511652        selday = infoPtr->firstSelDay - infoPtr->maxSelCount;
    16521653    }
    1653                
     1654
    16541655    if(selArray[i].wDay!=selday) {
    16551656      TRACE("newRange:%d %d %d %d\n", infoPtr->firstSelDay, selArray[0].wDay, selArray[1].wDay, i);
    1656                        
     1657
    16571658      selArray[i].wDay = selday;
    16581659
     
    17121713{
    17131714  TRACE("\n");
    1714  
     1715
    17151716  InvalidateRect(hwnd, NULL, FALSE);
    17161717
     
    17691770
    17701771  /* 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 
     1772  /* FIXME: We use up all available width. This will inhibit having multiple
     1773     calendars in a row, like win doesn
    17731774  */
    17741775  if(dwStyle & MCS_WEEKNUMBERS)
     
    17761777  else
    17771778    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; 
     1779  infoPtr->width_increment = (infoPtr->rcDraw.right - infoPtr->rcDraw.left) / xdiv;
     1780  infoPtr->height_increment = (infoPtr->rcDraw.bottom - infoPtr->rcDraw.top) / 10.0;
    17801781  infoPtr->left_offset = (infoPtr->rcDraw.right - infoPtr->rcDraw.left) - (infoPtr->width_increment * xdiv);
    17811782  infoPtr->top_offset = (infoPtr->rcDraw.bottom - infoPtr->rcDraw.top) - (infoPtr->height_increment * 10.0);
     
    17901791    rcDraw->bottom = rcDraw->top + 9 * infoPtr->textHeight + 5;
    17911792    }*/
    1792    
     1793
    17931794  /* calculate title area */
    17941795  title->top    = rcClient->top;
     
    18051806  next->right  = title->right - 6;
    18061807  next->left   = next->right - (title->bottom - title->top);
    1807  
     1808
    18081809  /* titlemonth->left and right change based upon the current month */
    18091810  /* and are recalculated in refresh as the current month may change */
     
    18111812  titlemonth->top    = titleyear->top    = title->top    + (infoPtr->height_increment)/2;
    18121813  titlemonth->bottom = titleyear->bottom = title->bottom - (infoPtr->height_increment)/2;
    1813  
     1814
    18141815  /* setup the dimensions of the rectangle we draw the names of the */
    18151816  /* days of the week in */
    18161817  weeknumrect->left =infoPtr->left_offset;
    1817   if(dwStyle & MCS_WEEKNUMBERS) 
     1818  if(dwStyle & MCS_WEEKNUMBERS)
    18181819    weeknumrect->right=prev->right;
    18191820  else
     
    18231824  wdays->top    = title->bottom ;
    18241825  wdays->bottom = wdays->top + infoPtr->height_increment;
    1825  
     1826
    18261827  days->top    = weeknumrect->top = wdays->bottom ;
    18271828  days->bottom = weeknumrect->bottom = days->top     + 6 * infoPtr->height_increment;
    1828  
     1829
    18291830  todayrect->left   = rcClient->left;
    18301831  todayrect->right  = rcClient->right;
     
    18321833  todayrect->bottom = days->bottom + infoPtr->height_increment;
    18331834
    1834   /* uncomment for excessive debugging 
     1835  /* uncomment for excessive debugging
    18351836  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);
     1837    infoPtr->width_increment,infoPtr->height_increment,
     1838    rcClient->left, rcClient->right, rcClient->top, rcClient->bottom,
     1839        title->left,    title->right,    title->top,    title->bottom,
     1840        wdays->left,    wdays->right,    wdays->top,    wdays->bottom,
     1841         days->left,     days->right,     days->top,     days->bottom,
     1842    todayrect->left,todayrect->right,todayrect->top,todayrect->bottom);
    18421843  */
    1843  
     1844
    18441845  /* restore the originally selected font */
    1845   SelectObject(hdc, currentFont);     
     1846  SelectObject(hdc, currentFont);
    18461847
    18471848  ReleaseDC(hwnd, hdc);
     
    18651866{
    18661867  MONTHCAL_INFO *infoPtr;
    1867   LOGFONTA      logFont;
     1868  LOGFONTA  logFont;
    18681869
    18691870  /* allocate memory for info structure */
     
    19001901  infoPtr->maxSelCount  = 7;
    19011902  infoPtr->monthRange = 3;
    1902   infoPtr->monthdayState = COMCTL32_Alloc 
     1903  infoPtr->monthdayState = COMCTL32_Alloc
    19031904                         (infoPtr->monthRange * sizeof(MONTHDAYSTATE));
    19041905  infoPtr->titlebk     = GetSysColor(COLOR_ACTIVECAPTION);
     
    19071908  infoPtr->trailingtxt = GetSysColor(COLOR_GRAYTEXT);
    19081909  infoPtr->bk          = GetSysColor(COLOR_WINDOW);
    1909   infoPtr->txt         = GetSysColor(COLOR_WINDOWTEXT);
     1910  infoPtr->txt         = GetSysColor(COLOR_WINDOWTEXT);
    19101911
    19111912  /* call MONTHCAL_UpdateSize to set all of the dimensions */
     
    20622063  wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
    20632064  wndClass.lpszClassName = MONTHCAL_CLASSA;
    2064  
     2065
    20652066  RegisterClassA(&wndClass);
    20662067}
  • trunk/src/comctl32/pager.c

    r6380 r6644  
     1/* $Id: pager.c,v 1.9 2001-09-05 12:05:01 bird Exp $ */
    12/*
    23 * Pager control
     
    3940    INT    nPos;       /* scroll position */
    4041    INT    nWidth;     /* from child wnd's response to PGN_CALCSIZE */
    41     INT    nHeight;    /* from child wnd's response to PGN_CALCSIZE */ 
     42    INT    nHeight;    /* from child wnd's response to PGN_CALCSIZE */
    4243    BOOL   bForward;   /* forward WM_MOUSEMOVE msgs to the contained wnd */
    4344    INT    TLbtnState; /* state of top or left btn */
     
    5758#define REPEAT_DELAY     50
    5859
    59 /* the horizontal arrows are: 
     60/* the horizontal arrows are:
    6061 *
    6162 * 01234    01234
     
    6667 * 5 **      **
    6768 * 6  *      *
    68  * 7 
     69 * 7
    6970 *
    7071 */
     
    7475    INT x, y, w, h;
    7576    HPEN hOldPen;
    76    
     77
    7778    w = r.right - r.left + 1;
    7879    h = r.bottom - r.top + 1;
     
    107108}
    108109
    109 /* the vertical arrows are: 
     110/* the vertical arrows are:
    110111 *
    111112 * 01234567    01234567
    112  * 1******        ** 
     113 * 1******        **
    113114 * 2 ****        ****
    114115 * 3  **        ******
     
    121122    INT x, y, w, h;
    122123    HPEN hOldPen;
    123    
     124
    124125    w = r.right - r.left + 1;
    125126    h = r.bottom - r.top + 1;
     
    165166
    166167    if ((rc.right - rc.left <= 0) || (rc.bottom - rc.top <= 0))
    167         return; 
     168        return;
    168169
    169170    hBrush = CreateSolidBrush(clrBk);
     
    172173    FillRect(hdc, &rc, hBrush);
    173174
    174     if (btnState == PGF_HOT) 
     175    if (btnState == PGF_HOT)
    175176    {
    176177       DrawEdge( hdc, &rc, BDR_RAISEDINNER, BF_RECT);
     
    180181           PAGER_DrawVertArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft);
    181182    }
    182     else if (btnState == PGF_NORMAL) 
     183    else if (btnState == PGF_NORMAL)
    183184    {
    184185       DrawEdge (hdc, &rc, BDR_OUTER, BF_FLAT);
     
    188189           PAGER_DrawVertArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft);
    189190    }
    190     else if (btnState == PGF_DEPRESSED) 
     191    else if (btnState == PGF_DEPRESSED)
    191192    {
    192193       DrawEdge( hdc, &rc, BDR_SUNKENOUTER, BF_RECT);
     
    196197           PAGER_DrawVertArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft);
    197198    }
    198     else if (btnState == PGF_GRAYED) 
     199    else if (btnState == PGF_GRAYED)
    199200    {
    200201       DrawEdge (hdc, &rc, BDR_OUTER, BF_FLAT);
     
    233234PAGER_GetButtonState (HWND hwnd, WPARAM wParam, LPARAM lParam)
    234235{
    235     PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 
     236    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
    236237    LRESULT btnState = PGF_INVISIBLE;
    237238    INT btn = (INT)lParam;
     
    250251PAGER_GetPos(HWND hwnd)
    251252{
    252     PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 
     253    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
    253254    TRACE("[%04x] returns %d\n", hwnd, infoPtr->nPos);
    254255    return (LRESULT)infoPtr->nPos;
     
    258259PAGER_GetButtonSize(HWND hwnd)
    259260{
    260     PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 
     261    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
    261262    TRACE("[%04x] returns %d\n", hwnd, infoPtr->nButtonSize);
    262263    return (LRESULT)infoPtr->nButtonSize;
     
    266267PAGER_GetBorder(HWND hwnd)
    267268{
    268     PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 
     269    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
    269270    TRACE("[%04x] returns %d\n", hwnd, infoPtr->nBorder);
    270271    return (LRESULT)infoPtr->nBorder;
     
    274275PAGER_GetBkColor(HWND hwnd)
    275276{
    276     PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 
     277    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
    277278    TRACE("[%04x] returns %06lx\n", hwnd, infoPtr->clrBk);
    278279    return (LRESULT)infoPtr->clrBk;
    279280}
    280281
    281 static void 
    282 PAGER_CalcSize (HWND hwnd, INT* size, BOOL getWidth) 
     282static void
     283PAGER_CalcSize (HWND hwnd, INT* size, BOOL getWidth)
    283284{
    284285    NMPGCALCSIZE nmpgcs;
     
    333334                infoPtr->nHeight = wndSize;
    334335
    335             TRACE("[%04x] SWP %dx%d at (%d,%d)\n", hwnd, 
     336            TRACE("[%04x] SWP %dx%d at (%d,%d)\n", hwnd,
    336337                         infoPtr->nWidth, infoPtr->nHeight,
    337338                         0, -nPos);
     
    379380}
    380381
    381 static void 
     382static void
    382383PAGER_GrayAndRestoreBtns(PAGER_INFO* infoPtr, INT scrollRange,
    383384                         BOOL* needsResize, BOOL* needsRepaint)
     
    416417
    417418
    418 static void 
     419static void
    419420PAGER_NormalizeBtns(PAGER_INFO* infoPtr, BOOL* needsRepaint)
    420421{
     
    432433}
    433434
    434 static void 
     435static void
    435436PAGER_HideGrayBtns(PAGER_INFO* infoPtr, BOOL* needsResize)
    436437{
     
    464465
    465466    if (resizeClient) /* initiate NCCalcSize to resize client wnd */
    466         SetWindowPos(hwnd, 0,0,0,0,0, 
     467        SetWindowPos(hwnd, 0,0,0,0,0,
    467468                     SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE |
    468469                     SWP_NOZORDER | SWP_NOACTIVATE);
    469470
    470471    if (repaintBtns)
    471         SendMessageA(hwnd, WM_NCPAINT, 0, 0); 
    472 }
    473 
    474 static LRESULT 
     472        SendMessageA(hwnd, WM_NCPAINT, 0, 0);
     473}
     474
     475static LRESULT
    475476PAGER_SetPos(HWND hwnd, INT newPos, BOOL fromBtnPress)
    476477{
     
    518519}
    519520
    520 static void 
     521static void
    521522PAGER_SetFixedWidth(HWND hwnd, PAGER_INFO* infoPtr)
    522523{
     
    544545
    545546    /* adjust non-scrollable dimension to fit the child */
    546     SetWindowPos(hwnd, 0, 0,0, infoPtr->nWidth, h, 
     547    SetWindowPos(hwnd, 0, 0,0, infoPtr->nWidth, h,
    547548                 SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER);
    548549
    549550
    550551    TRACE("[%04x] infoPtr->nWidth set to %d\n",
    551                hwnd, infoPtr->nWidth);
    552 }
    553 
    554 static void 
     552           hwnd, infoPtr->nWidth);
     553}
     554
     555static void
    555556PAGER_SetFixedHeight(HWND hwnd, PAGER_INFO* infoPtr)
    556557{
     
    578579
    579580    /* adjust non-scrollable dimension to fit the child */
    580     SetWindowPos(hwnd, 0, 0,0, w, infoPtr->nHeight, 
     581    SetWindowPos(hwnd, 0, 0,0, w, infoPtr->nHeight,
    581582                 SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER);
    582583
    583584    TRACE("[%04x] infoPtr->nHeight set to %d\n",
    584                hwnd, infoPtr->nHeight);
     585           hwnd, infoPtr->nHeight);
    585586}
    586587
     
    601602            PAGER_SetPos(hwnd, 0, FALSE);
    602603        }
    603         else 
     604        else
    604605        {
    605606            PAGER_UpdateBtns(hwnd, infoPtr, scrollRange, TRUE);
     
    700701        nmpgScroll.hdr.code = PGN_SCROLL;
    701702
    702         GetWindowRect(hwnd, &rcWnd); 
    703         GetClientRect(hwnd, &nmpgScroll.rcParent); 
     703        GetWindowRect(hwnd, &rcWnd);
     704        GetClientRect(hwnd, &nmpgScroll.rcParent);
    704705        nmpgScroll.iXpos = nmpgScroll.iYpos = 0;
    705706        nmpgScroll.iDir = dir;
     
    716717        }
    717718        nmpgScroll.iScroll -= 2*infoPtr->nButtonSize;
    718  
     719
    719720        SendMessageA (hwnd, WM_NOTIFY,
    720721                    (WPARAM)nmpgScroll.hdr.idFrom, (LPARAM)&nmpgScroll);
    721  
     722
    722723        TRACE("[%04x] PGN_SCROLL returns iScroll=%d\n", hwnd, nmpgScroll.iScroll);
    723724
     
    769770        FIXME("[%04x] Drag and Drop style is not implemented yet.\n", hwnd);
    770771    /*
    771         * If neither horizontal nor vertical style specified, default to vertical.
    772         * This is probably not necessary, since the style may be set later on as
    773         * the control is initialized, but just in case it isn't, set it here.
    774         */
     772    * If neither horizontal nor vertical style specified, default to vertical.
     773    * This is probably not necessary, since the style may be set later on as
     774    * the control is initialized, but just in case it isn't, set it here.
     775    */
    775776    if (!(dwStyle & PGS_HORZ) && !(dwStyle & PGS_VERT))
    776777    {
     
    800801    /*
    801802     * lParam points to a RECT struct.  On entry, the struct
    802      * contains the proposed wnd rectangle for the window. 
     803     * contains the proposed wnd rectangle for the window.
    803804     * On exit, the struct should contain the screen
    804805     * coordinates of the corresponding window's client area.
    805806     */
    806        
     807
    807808    if (PAGER_IsHorizontal(hwnd))
    808809    {
    809810        if (infoPtr->TLbtnState) /* != PGF_INVISIBLE */
    810811            lpRect->left += infoPtr->nButtonSize;
    811         if (infoPtr->BRbtnState) 
     812        if (infoPtr->BRbtnState)
    812813            lpRect->right -= infoPtr->nButtonSize;
    813814    }
     
    863864                     bHorizontal, TRUE, infoPtr->TLbtnState);
    864865    PAGER_DrawButton(hdc, infoPtr->clrBk, rcBottomRight,
    865                      bHorizontal, FALSE, infoPtr->BRbtnState); 
     866                     bHorizontal, FALSE, infoPtr->BRbtnState);
    866867
    867868    ReleaseDC( hwnd, hdc );
     
    869870}
    870871
    871 static INT 
     872static INT
    872873PAGER_HitTest (HWND hwnd, LPPOINT pt)
    873874{
     
    976977        if(!(trackinfo.dwFlags & TME_LEAVE)) {
    977978            trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */
    978  
     979
    979980           /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
    980981           /* and can properly deactivate the hot button */
     
    982983        }
    983984
    984         SendMessageA(hwnd, WM_NCPAINT, 0, 0); 
     985        SendMessageA(hwnd, WM_NCPAINT, 0, 0);
    985986    }
    986987
     
    10251026
    10261027    TRACE("[%04x]\n", hwnd);
    1027        
     1028
    10281029    hit = PAGER_HitTest(hwnd, &pt);
    10291030
     
    10331034        repaintBtns = infoPtr->TLbtnState != PGF_DEPRESSED;
    10341035        infoPtr->TLbtnState = PGF_DEPRESSED;
    1035         SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0); 
     1036        SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0);
    10361037    }
    10371038    else if (hit == HTRIGHT || hit == HTBOTTOM)
     
    10391040        repaintBtns = infoPtr->BRbtnState != PGF_DEPRESSED;
    10401041        infoPtr->BRbtnState = PGF_DEPRESSED;
    1041         SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0); 
     1042        SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0);
    10421043    }
    10431044
    10441045    if (repaintBtns)
    1045         SendMessageA(hwnd, WM_NCPAINT, 0, 0); 
     1046        SendMessageA(hwnd, WM_NCPAINT, 0, 0);
    10461047
    10471048    switch(hit)
     
    11301131
    11311132    if (!infoPtr && (uMsg != WM_CREATE))
    1132         return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     1133    return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    11331134
    11341135    switch (uMsg)
     
    11561157        case PGM_RECALCSIZE:
    11571158            return PAGER_RecalcSize(hwnd);
    1158    
     1159
    11591160        case PGM_SETBKCOLOR:
    11601161            return PAGER_SetBkColor (hwnd, wParam, lParam);
     
    12041205            if (infoPtr->bForward && infoPtr->hwndChild)
    12051206                PostMessageA(infoPtr->hwndChild, WM_MOUSEMOVE, wParam, lParam);
    1206             return TRUE;                       
     1207            return TRUE;
    12071208
    12081209        case WM_MOUSELEAVE:
    1209             return PAGER_MouseLeave (hwnd, wParam, lParam);     
     1210            return PAGER_MouseLeave (hwnd, wParam, lParam);
    12101211
    12111212        case WM_LBUTTONDOWN:
     
    12191220/*
    12201221        case WM_PAINT:
    1221             return PAGER_Paint (hwnd, wParam); 
     1222            return PAGER_Paint (hwnd, wParam);
    12221223*/
    12231224        case WM_TIMER:
     
    12331234            {
    12341235                PAGER_Scroll(hwnd, infoPtr->direction);
    1235                 SetTimer(hwnd, TIMERID2, REPEAT_DELAY, 0);         
     1236                SetTimer(hwnd, TIMERID2, REPEAT_DELAY, 0);
    12361237            }
    12371238            break;
     
    12661267    wndClass.hbrBackground = 0;
    12671268    wndClass.lpszClassName = WC_PAGESCROLLERA;
    1268  
     1269
    12691270    RegisterClassA (&wndClass);
    12701271}
  • trunk/src/comctl32/rebar.c

    r6380 r6644  
     1/* $Id: rebar.c,v 1.16 2001-09-05 12:05:01 bird Exp $ */
    12/*
    23 *
     
    2122 *   - vertical placement
    2223 *   - ComboBox and ComboBoxEx placement
    23  *   - center image 
     24 *   - center image
    2425 *   - Layout code.
    2526 *   - Display code.
     
    3031 *  rev 2,3,4
    3132 *   - Implement initial version of row grouping, row separators,
    32  *     text and background colors. Support additional messages. 
     33 *     text and background colors. Support additional messages.
    3334 *     Support RBBS_BREAK. Implement ERASEBKGND and improve painting.
    3435 *  rev 5
    3536 *   - implement support for dragging Gripper left or right in a row. Supports
    36  *     WM_LBUTTONDOWN, WM_LBUTTONUP, and WM_MOUSEMOVE. Also support 
     37 *     WM_LBUTTONDOWN, WM_LBUTTONUP, and WM_MOUSEMOVE. Also support
    3738 *     RBS_BANDBORDERS.
    3839 *  rev 6
     
    6263 * 12. Correct drawing of rebar borders and handling of RBS_BORDERS.
    6364 * rev 7d
    64  * 13. Support WM_NOTIFYFORMAT (both incoming and outgoing) and do 
     65 * 13. Support WM_NOTIFYFORMAT (both incoming and outgoing) and do
    6566 *     WM_NOTIFY correctly based on results.
    6667 * 14. Implement WM_SETREDRAW.
    6768 * 15. Native WM_ERASEBKGND draws horz and vert separators between bands and
    68  *     rows, and fills in the background color for each band. The gripper, 
     69 *     rows, and fills in the background color for each band. The gripper,
    6970 *     image, and text for each band is drawn by the WM_PAINT process. Change
    7071 *     this code to match.
     
    9596 *  2. Following still not handled: RBBS_FIXEDBMP, RBBS_CHILDEDGE,
    9697 *            RBBS_USECHEVRON
    97  *  3. Following are only partially handled: 
     98 *  3. Following are only partially handled:
    9899 *            RBS_AUTOSIZE, RBBS_VARIABLEHEIGHT
    99100 *  5. Native uses (on each draw!!) SM_CYBORDER (or SM_CXBORDER for CCS_VERT)
    100  *     to set the size of the separator width (the value SEP_WIDTH_SIZE 
     101 *     to set the size of the separator width (the value SEP_WIDTH_SIZE
    101102 *     in here). Should be fixed!!
    102103 *  6. The following messages are not implemented:
     
    211212    BOOL     NtfUnicode;  /* TRUE if parent wants notify in W format */
    212213    BOOL     DoRedraw;    /* TRUE to acutally draw bands */
    213     UINT     fStatus;     /* Status flags (see below)  */ 
     214    UINT     fStatus;     /* Status flags (see below)  */
    214215    HCURSOR  hcurArrow;   /* handle to the arrow cursor */
    215216    HCURSOR  hcurHorz;    /* handle to the EW cursor */
     
    263264
    264265/* This is the increment that is used over the band height */
    265 /* Determined by experiment.                               */ 
     266/* Determined by experiment.                               */
    266267#define REBARSPACE      4
    267268
     
    274275#define rcBrb(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.bottom : b->rcBand.right)
    275276#define rcBw(b)  ((infoPtr->dwStyle & CCS_VERT) ? (b->rcBand.bottom - b->rcBand.top) : \
    276                   (b->rcBand.right - b->rcBand.left))
     277          (b->rcBand.right - b->rcBand.left))
    277278#define ircBlt(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.left : b->rcBand.top)
    278279#define ircBrb(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.right : b->rcBand.bottom)
    279280#define ircBw(b)  ((infoPtr->dwStyle & CCS_VERT) ? (b->rcBand.right - b->rcBand.left) : \
    280                   (b->rcBand.bottom - b->rcBand.top))
     281          (b->rcBand.bottom - b->rcBand.top))
    281282
    282283/*  The following define determines if a given band is hidden      */
     
    338339    *line = 0;
    339340    while (band_stylename[i]) {
    340         if (style & (1<<i)) {
    341             if (*line != 0) strcat(line, " | ");
    342             strcat(line, band_stylename[i]);
    343         }
    344         i++;
     341    if (style & (1<<i)) {
     342        if (*line != 0) strcat(line, " | ");
     343        strcat(line, band_stylename[i]);
     344    }
     345    i++;
    345346    }
    346347    return line;
     
    355356    *line = 0;
    356357    while (band_maskname[i]) {
    357         if (mask & (1<<i)) {
    358             if (*line != 0) strcat(line, " | ");
    359             strcat(line, band_maskname[i]);
    360         }
    361         i++;
     358    if (mask & (1<<i)) {
     359        if (*line != 0) strcat(line, " | ");
     360        strcat(line, band_maskname[i]);
     361    }
     362    i++;
    362363    }
    363364    return line;
     
    370371    if( !TRACE_ON(rebar) ) return;
    371372    TRACE("band info: ID=%u, size=%u, child=%04x, clrF=0x%06lx, clrB=0x%06lx\n",
    372           pB->wID, pB->cbSize, pB->hwndChild, pB->clrFore, pB->clrBack);
     373      pB->wID, pB->cbSize, pB->hwndChild, pB->clrFore, pB->clrBack);
    373374    TRACE("band info: mask=0x%08x (%s)\n", pB->fMask, REBAR_FmtMask(pB->fMask));
    374375    if (pB->fMask & RBBIM_STYLE)
    375         TRACE("band info: style=0x%08x (%s)\n", pB->fStyle, REBAR_FmtStyle(pB->fStyle));
     376    TRACE("band info: style=0x%08x (%s)\n", pB->fStyle, REBAR_FmtStyle(pB->fStyle));
    376377    if (pB->fMask & (RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_HEADERSIZE | RBBIM_LPARAM )) {
    377         TRACE("band info:");
    378         if (pB->fMask & RBBIM_SIZE)
    379             DPRINTF(" cx=%u", pB->cx);
    380         if (pB->fMask & RBBIM_IDEALSIZE)
    381             DPRINTF(" xIdeal=%u", pB->cxIdeal);
    382         if (pB->fMask & RBBIM_HEADERSIZE)
    383             DPRINTF(" xHeader=%u", pB->cxHeader);
    384         if (pB->fMask & RBBIM_LPARAM)
    385             DPRINTF(" lParam=0x%08lx", pB->lParam);
    386         DPRINTF("\n");
     378    TRACE("band info:");
     379    if (pB->fMask & RBBIM_SIZE)
     380        DPRINTF(" cx=%u", pB->cx);
     381    if (pB->fMask & RBBIM_IDEALSIZE)
     382        DPRINTF(" xIdeal=%u", pB->cxIdeal);
     383    if (pB->fMask & RBBIM_HEADERSIZE)
     384        DPRINTF(" xHeader=%u", pB->cxHeader);
     385    if (pB->fMask & RBBIM_LPARAM)
     386        DPRINTF(" lParam=0x%08lx", pB->lParam);
     387    DPRINTF("\n");
    387388    }
    388389    if (pB->fMask & RBBIM_CHILDSIZE)
    389         TRACE("band info: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
    390               pB->cxMinChild,
    391               pB->cyMinChild, pB->cyChild, pB->cyMaxChild, pB->cyIntegral);
     390    TRACE("band info: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
     391          pB->cxMinChild,
     392          pB->cyMinChild, pB->cyChild, pB->cyMaxChild, pB->cyIntegral);
    392393}
    393394
     
    400401    if(! TRACE_ON(rebar) ) return;
    401402
    402     TRACE("hwnd=%04x: color=%08lx/%08lx, bands=%u, rows=%u, cSize=%ld,%ld\n", 
    403           iP->hwndSelf, iP->clrText, iP->clrBk, iP->uNumBands, iP->uNumRows,
    404           iP->calcSize.cx, iP->calcSize.cy);
     403    TRACE("hwnd=%04x: color=%08lx/%08lx, bands=%u, rows=%u, cSize=%ld,%ld\n",
     404      iP->hwndSelf, iP->clrText, iP->clrBk, iP->uNumBands, iP->uNumRows,
     405      iP->calcSize.cx, iP->calcSize.cy);
    405406    TRACE("hwnd=%04x: flags=%08x, dragStart=%d,%d, dragNow=%d,%d, ihitBand=%d\n",
    406           iP->hwndSelf, iP->fStatus, iP->dragStart.x, iP->dragStart.y,
    407           iP->dragNow.x, iP->dragNow.y,
    408           iP->ihitBand);
     407      iP->hwndSelf, iP->fStatus, iP->dragStart.x, iP->dragStart.y,
     408      iP->dragNow.x, iP->dragNow.y,
     409      iP->ihitBand);
    409410    TRACE("hwnd=%04x: style=%08lx, I'm Unicode=%s, notify in Unicode=%s, redraw=%s\n",
    410           iP->hwndSelf, iP->dwStyle, (iP->bUnicode)?"TRUE":"FALSE",
    411           (iP->NtfUnicode)?"TRUE":"FALSE", (iP->DoRedraw)?"TRUE":"FALSE");
     411      iP->hwndSelf, iP->dwStyle, (iP->bUnicode)?"TRUE":"FALSE",
     412      (iP->NtfUnicode)?"TRUE":"FALSE", (iP->DoRedraw)?"TRUE":"FALSE");
    412413    for (i = 0; i < iP->uNumBands; i++) {
    413         pB = &iP->bands[i];
    414         TRACE("band # %u: ID=%u, child=%04x, row=%u, clrF=0x%06lx, clrB=0x%06lx\n",
    415               i, pB->wID, pB->hwndChild, pB->iRow, pB->clrFore, pB->clrBack);
    416         TRACE("band # %u: mask=0x%08x (%s)\n", i, pB->fMask, REBAR_FmtMask(pB->fMask));
    417         if (pB->fMask & RBBIM_STYLE)
    418             TRACE("band # %u: style=0x%08x (%s)\n",
    419                   i, pB->fStyle, REBAR_FmtStyle(pB->fStyle));
    420         TRACE("band # %u: uMinH=%u xHeader=%u",
    421               i, pB->uMinHeight, pB->cxHeader);
    422         if (pB->fMask & (RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_LPARAM )) {
    423             if (pB->fMask & RBBIM_SIZE)
    424                 DPRINTF(" cx=%u", pB->cx);
    425             if (pB->fMask & RBBIM_IDEALSIZE)
    426                 DPRINTF(" xIdeal=%u", pB->cxIdeal);
    427             if (pB->fMask & RBBIM_LPARAM)
    428                 DPRINTF(" lParam=0x%08lx", pB->lParam);
    429         }
    430         DPRINTF("\n");
    431         if (RBBIM_CHILDSIZE)
    432             TRACE("band # %u: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
    433                   i, pB->cxMinChild, pB->cyMinChild, pB->cyChild, pB->cyMaxChild, pB->cyIntegral);
    434         TRACE("band # %u: lcx=%u, ccx=%u, hcx=%u, lcy=%u, ccy=%u, hcy=%u, offChild=%ld,%ld\n",
    435               i, pB->lcx, pB->ccx, pB->hcx, pB->lcy, pB->ccy, pB->hcy, pB->offChild.cx, pB->offChild.cy);
    436         TRACE("band # %u: fStatus=%08x, fDraw=%08x, Band=(%d,%d)-(%d,%d), Grip=(%d,%d)-(%d,%d)\n",
    437               i, pB->fStatus, pB->fDraw,
    438               pB->rcBand.left, pB->rcBand.top, pB->rcBand.right, pB->rcBand.bottom,
    439               pB->rcGripper.left, pB->rcGripper.top, pB->rcGripper.right, pB->rcGripper.bottom);
    440         TRACE("band # %u: Img=(%d,%d)-(%d,%d), Txt=(%d,%d)-(%d,%d), Child=(%d,%d)-(%d,%d)\n",
    441               i,
    442               pB->rcCapImage.left, pB->rcCapImage.top, pB->rcCapImage.right, pB->rcCapImage.bottom,
    443               pB->rcCapText.left, pB->rcCapText.top, pB->rcCapText.right, pB->rcCapText.bottom,
    444               pB->rcChild.left, pB->rcChild.top, pB->rcChild.right, pB->rcChild.bottom);
     414    pB = &iP->bands[i];
     415    TRACE("band # %u: ID=%u, child=%04x, row=%u, clrF=0x%06lx, clrB=0x%06lx\n",
     416          i, pB->wID, pB->hwndChild, pB->iRow, pB->clrFore, pB->clrBack);
     417    TRACE("band # %u: mask=0x%08x (%s)\n", i, pB->fMask, REBAR_FmtMask(pB->fMask));
     418    if (pB->fMask & RBBIM_STYLE)
     419        TRACE("band # %u: style=0x%08x (%s)\n",
     420          i, pB->fStyle, REBAR_FmtStyle(pB->fStyle));
     421    TRACE("band # %u: uMinH=%u xHeader=%u",
     422          i, pB->uMinHeight, pB->cxHeader);
     423    if (pB->fMask & (RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_LPARAM )) {
     424        if (pB->fMask & RBBIM_SIZE)
     425        DPRINTF(" cx=%u", pB->cx);
     426        if (pB->fMask & RBBIM_IDEALSIZE)
     427        DPRINTF(" xIdeal=%u", pB->cxIdeal);
     428        if (pB->fMask & RBBIM_LPARAM)
     429        DPRINTF(" lParam=0x%08lx", pB->lParam);
     430    }
     431    DPRINTF("\n");
     432    if (RBBIM_CHILDSIZE)
     433        TRACE("band # %u: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n",
     434          i, pB->cxMinChild, pB->cyMinChild, pB->cyChild, pB->cyMaxChild, pB->cyIntegral);
     435    TRACE("band # %u: lcx=%u, ccx=%u, hcx=%u, lcy=%u, ccy=%u, hcy=%u, offChild=%ld,%ld\n",
     436          i, pB->lcx, pB->ccx, pB->hcx, pB->lcy, pB->ccy, pB->hcy, pB->offChild.cx, pB->offChild.cy);
     437    TRACE("band # %u: fStatus=%08x, fDraw=%08x, Band=(%d,%d)-(%d,%d), Grip=(%d,%d)-(%d,%d)\n",
     438          i, pB->fStatus, pB->fDraw,
     439          pB->rcBand.left, pB->rcBand.top, pB->rcBand.right, pB->rcBand.bottom,
     440          pB->rcGripper.left, pB->rcGripper.top, pB->rcGripper.right, pB->rcGripper.bottom);
     441    TRACE("band # %u: Img=(%d,%d)-(%d,%d), Txt=(%d,%d)-(%d,%d), Child=(%d,%d)-(%d,%d)\n",
     442          i,
     443          pB->rcCapImage.left, pB->rcCapImage.top, pB->rcCapImage.right, pB->rcCapImage.bottom,
     444          pB->rcCapText.left, pB->rcCapText.top, pB->rcCapText.right, pB->rcCapText.bottom,
     445          pB->rcChild.left, pB->rcChild.top, pB->rcChild.right, pB->rcChild.bottom);
    445446    }
    446447
     
    456457    if (!parent) {
    457458        parent = GetParent (infoPtr->hwndSelf);
    458         owner = GetWindow (infoPtr->hwndSelf, GW_OWNER);
    459         if (owner) parent = owner;
     459    owner = GetWindow (infoPtr->hwndSelf, GW_OWNER);
     460    if (owner) parent = owner;
    460461    }
    461462    return parent;
     
    474475
    475476    TRACE("window %04x, code=%08x, %s\n", parent, code,
    476           (infoPtr->NtfUnicode) ? "via Unicode" : "via ANSI");
     477      (infoPtr->NtfUnicode) ? "via Unicode" : "via ANSI");
    477478
    478479    if (infoPtr->NtfUnicode)
    479         return SendMessageW (parent, WM_NOTIFY, (WPARAM) nmhdr->idFrom,
    480                              (LPARAM)nmhdr);
     480    return SendMessageW (parent, WM_NOTIFY, (WPARAM) nmhdr->idFrom,
     481                 (LPARAM)nmhdr);
    481482    else
    482         return SendMessageA (parent, WM_NOTIFY, (WPARAM) nmhdr->idFrom,
    483                              (LPARAM)nmhdr);
     483    return SendMessageA (parent, WM_NOTIFY, (WPARAM) nmhdr->idFrom,
     484                 (LPARAM)nmhdr);
    484485}
    485486
     
    492493    notify_rebar.dwMask = 0;
    493494    if (uBand!=-1) {
    494         lpBand = &infoPtr->bands[uBand];
    495         if (lpBand->fMask & RBBIM_ID) {
    496             notify_rebar.dwMask |= RBNM_ID;
    497             notify_rebar.wID = lpBand->wID;
    498         }
    499         if (lpBand->fMask & RBBIM_LPARAM) {
    500             notify_rebar.dwMask |= RBNM_LPARAM;
    501             notify_rebar.lParam = lpBand->lParam;
    502         }
    503         if (lpBand->fMask & RBBIM_STYLE) {
    504             notify_rebar.dwMask |= RBNM_STYLE;
    505             notify_rebar.fStyle = lpBand->fStyle;
    506         }
     495    lpBand = &infoPtr->bands[uBand];
     496    if (lpBand->fMask & RBBIM_ID) {
     497        notify_rebar.dwMask |= RBNM_ID;
     498        notify_rebar.wID = lpBand->wID;
     499    }
     500    if (lpBand->fMask & RBBIM_LPARAM) {
     501        notify_rebar.dwMask |= RBNM_LPARAM;
     502        notify_rebar.lParam = lpBand->lParam;
     503    }
     504    if (lpBand->fMask & RBBIM_STYLE) {
     505        notify_rebar.dwMask |= RBNM_STYLE;
     506        notify_rebar.fStyle = lpBand->fStyle;
     507    }
    507508    }
    508509    notify_rebar.uBand = uBand;
     
    521522    /* draw caption image */
    522523    if (lpBand->fDraw & DRAW_IMAGE) {
    523         POINT pt;
    524 
    525         /* center image */
    526         pt.y = (lpBand->rcCapImage.bottom + lpBand->rcCapImage.top - infoPtr->imageSize.cy)/2;
    527         pt.x = (lpBand->rcCapImage.right + lpBand->rcCapImage.left - infoPtr->imageSize.cx)/2;
    528 
    529         ImageList_Draw (infoPtr->himl, lpBand->iImage, hdc,
    530                         pt.x, pt.y,
    531                         ILD_TRANSPARENT);
     524    POINT pt;
     525
     526    /* center image */
     527    pt.y = (lpBand->rcCapImage.bottom + lpBand->rcCapImage.top - infoPtr->imageSize.cy)/2;
     528    pt.x = (lpBand->rcCapImage.right + lpBand->rcCapImage.left - infoPtr->imageSize.cx)/2;
     529
     530    ImageList_Draw (infoPtr->himl, lpBand->iImage, hdc,
     531            pt.x, pt.y,
     532            ILD_TRANSPARENT);
    532533    }
    533534
    534535    /* draw caption text */
    535536    if (lpBand->fDraw & DRAW_TEXT) {
    536         HFONT hOldFont = SelectObject (hdc, infoPtr->hFont);
    537         INT oldBkMode = SetBkMode (hdc, TRANSPARENT);
    538         COLORREF oldcolor = CLR_NONE;
    539         oldcolor = SetTextColor (hdc, (lpBand->clrFore != CLR_NONE) ?
    540                                 lpBand->clrFore : infoPtr->clrBtnText);
    541         DrawTextW (hdc, lpBand->lpText, -1, &lpBand->rcCapText,
    542                    DT_CENTER | DT_VCENTER | DT_SINGLELINE);
    543         if (oldBkMode != TRANSPARENT)
    544             SetBkMode (hdc, oldBkMode);
    545         SetTextColor (hdc, oldcolor);
    546         SelectObject (hdc, hOldFont);
     537    HFONT hOldFont = SelectObject (hdc, infoPtr->hFont);
     538    INT oldBkMode = SetBkMode (hdc, TRANSPARENT);
     539    COLORREF oldcolor = CLR_NONE;
     540    oldcolor = SetTextColor (hdc, (lpBand->clrFore != CLR_NONE) ?
     541                lpBand->clrFore : infoPtr->clrBtnText);
     542    DrawTextW (hdc, lpBand->lpText, -1, &lpBand->rcCapText,
     543           DT_CENTER | DT_VCENTER | DT_SINGLELINE);
     544    if (oldBkMode != TRANSPARENT)
     545        SetBkMode (hdc, oldBkMode);
     546    SetTextColor (hdc, oldcolor);
     547    SelectObject (hdc, hOldFont);
    547548    }
    548549}
     
    559560    oldrow = infoPtr->bands[0].iRow;
    560561    for (i = 0; i < infoPtr->uNumBands; i++) {
    561         lpBand = &infoPtr->bands[i];
    562 
    563         if (HIDDENBAND(lpBand)) continue;
    564 
    565         /* now draw the band */
    566         REBAR_DrawBand (hdc, infoPtr, lpBand);
     562    lpBand = &infoPtr->bands[i];
     563
     564    if (HIDDENBAND(lpBand)) continue;
     565
     566    /* now draw the band */
     567    REBAR_DrawBand (hdc, infoPtr, lpBand);
    567568
    568569    }
     
    572573static void
    573574REBAR_FixVert (REBAR_INFO *infoPtr, UINT rowstart, UINT rowend,
    574                    INT mcy)
    575      /* Function:                                                    */ 
     575           INT mcy)
     576     /* Function:                                                    */
    576577     /*   Cycle through bands in row and fix height of each band.    */
    577578     /*   Also determine whether each band has changed.              */
     
    585586    for (i = (INT)rowstart; i<=(INT)rowend; i++) {
    586587        lpBand = &infoPtr->bands[i];
    587         if (HIDDENBAND(lpBand)) continue;
    588 
    589         /* adjust height of bands in row to "mcy" value */
    590         if (infoPtr->dwStyle & CCS_VERT) {
    591             if (lpBand->rcBand.right != lpBand->rcBand.left + mcy)
    592                 lpBand->rcBand.right = lpBand->rcBand.left + mcy;
    593         }
    594         else {
    595             if (lpBand->rcBand.bottom != lpBand->rcBand.top + mcy)
    596                 lpBand->rcBand.bottom = lpBand->rcBand.top + mcy;
    597 
    598         }
    599 
    600         /* mark whether we need to invalidate this band and trace */
    601         if ((lpBand->rcoldBand.left !=lpBand->rcBand.left) ||
    602             (lpBand->rcoldBand.top !=lpBand->rcBand.top) ||
    603             (lpBand->rcoldBand.right !=lpBand->rcBand.right) ||
    604             (lpBand->rcoldBand.bottom !=lpBand->rcBand.bottom)) {
    605             lpBand->fDraw |= NTF_INVALIDATE;
    606             TRACE("band %d row=%d: changed to (%d,%d)-(%d,%d) from (%d,%d)-(%d,%d)\n",
    607                   i, lpBand->iRow,
    608                   lpBand->rcBand.left, lpBand->rcBand.top,
    609                   lpBand->rcBand.right, lpBand->rcBand.bottom,
    610                   lpBand->rcoldBand.left, lpBand->rcoldBand.top,
    611                   lpBand->rcoldBand.right, lpBand->rcoldBand.bottom);
    612         }
    613         else
    614             TRACE("band %d row=%d: unchanged (%d,%d)-(%d,%d)\n",
    615                   i, lpBand->iRow,
    616                   lpBand->rcBand.left, lpBand->rcBand.top,
    617                   lpBand->rcBand.right, lpBand->rcBand.bottom);
     588    if (HIDDENBAND(lpBand)) continue;
     589
     590    /* adjust height of bands in row to "mcy" value */
     591    if (infoPtr->dwStyle & CCS_VERT) {
     592        if (lpBand->rcBand.right != lpBand->rcBand.left + mcy)
     593            lpBand->rcBand.right = lpBand->rcBand.left + mcy;
     594    }
     595    else {
     596        if (lpBand->rcBand.bottom != lpBand->rcBand.top + mcy)
     597            lpBand->rcBand.bottom = lpBand->rcBand.top + mcy;
     598
     599    }
     600
     601    /* mark whether we need to invalidate this band and trace */
     602    if ((lpBand->rcoldBand.left !=lpBand->rcBand.left) ||
     603        (lpBand->rcoldBand.top !=lpBand->rcBand.top) ||
     604        (lpBand->rcoldBand.right !=lpBand->rcBand.right) ||
     605        (lpBand->rcoldBand.bottom !=lpBand->rcBand.bottom)) {
     606        lpBand->fDraw |= NTF_INVALIDATE;
     607        TRACE("band %d row=%d: changed to (%d,%d)-(%d,%d) from (%d,%d)-(%d,%d)\n",
     608          i, lpBand->iRow,
     609          lpBand->rcBand.left, lpBand->rcBand.top,
     610          lpBand->rcBand.right, lpBand->rcBand.bottom,
     611          lpBand->rcoldBand.left, lpBand->rcoldBand.top,
     612          lpBand->rcoldBand.right, lpBand->rcoldBand.bottom);
     613    }
     614    else
     615        TRACE("band %d row=%d: unchanged (%d,%d)-(%d,%d)\n",
     616          i, lpBand->iRow,
     617          lpBand->rcBand.left, lpBand->rcBand.top,
     618          lpBand->rcBand.right, lpBand->rcBand.bottom);
    618619    }
    619620}
     
    622623static void
    623624REBAR_AdjustBands (REBAR_INFO *infoPtr, UINT rowstart, UINT rowend,
    624                    INT maxx, INT mcy)
     625           INT maxx, INT mcy)
    625626     /* Function: This routine distributes the extra space in a row. */
    626627     /*  See algorithm below.                                        */
     
    634635
    635636    TRACE("start=%u, end=%u, max x=%d, max y=%d\n",
    636           rowstart, rowend, maxx, mcy);
     637      rowstart, rowend, maxx, mcy);
    637638
    638639    /* *******************  Phase 1  ************************ */
     
    642643    /*         or band's ->ccx reached.                       */
    643644    /*  If any band modified, add any space left to last band */
    644     /*  adjusted.                                             */ 
     645    /*  adjusted.                                             */
    645646    /*                                                        */
    646647    /* ****************************************************** */
     
    650651    last_adjusted = 0;
    651652    for (i=(INT)rowstart; i<=(INT)rowend; i++) {
    652         lpBand = &infoPtr->bands[i];
    653         if (HIDDENBAND(lpBand)) continue;
    654         xsep = (x == 0) ? 0 : SEP_WIDTH;
    655         curwidth = rcBw(lpBand);
    656 
    657         /* set new left/top point */
    658         if (infoPtr->dwStyle & CCS_VERT)
    659             lpBand->rcBand.top = x + xsep;
    660         else
    661             lpBand->rcBand.left = x + xsep;
    662 
    663         /* compute new width */
    664         if (lpBand->hwndChild && extra) {
    665             /* set to the "current" band size less the header */
    666             fudge = lpBand->ccx;
    667             last_adjusted = i;
    668             if ((lpBand->fMask & RBBIM_SIZE) && (lpBand->cx > 0) &&
    669                 (fudge > curwidth)) {
    670                 TRACE("adjusting band %d by %d, fudge=%d, curwidth=%d, extra=%d\n",
    671                       i, fudge-curwidth, fudge, curwidth, extra);
    672                 if ((fudge - curwidth) > extra)
    673                     fudge = curwidth + extra;
    674                 extra -= (fudge - curwidth);
    675                 curwidth = fudge;
    676             }
    677             else {
    678                 TRACE("adjusting band %d by %d, fudge=%d, curwidth=%d\n",
    679                       i, extra, fudge, curwidth);
    680                 curwidth += extra;
    681                 extra = 0;
    682             }
    683         }
    684 
    685         /* set new right/bottom point */
    686         if (infoPtr->dwStyle & CCS_VERT)
    687             lpBand->rcBand.bottom = lpBand->rcBand.top + curwidth;
    688         else
    689             lpBand->rcBand.right = lpBand->rcBand.left + curwidth;
    690         TRACE("Phase 1 band %d, (%d,%d)-(%d,%d), orig x=%d, xsep=%d\n",
    691               i, lpBand->rcBand.left, lpBand->rcBand.top,
    692               lpBand->rcBand.right, lpBand->rcBand.bottom, x, xsep);
    693         x = rcBrb(lpBand);
     653    lpBand = &infoPtr->bands[i];
     654    if (HIDDENBAND(lpBand)) continue;
     655    xsep = (x == 0) ? 0 : SEP_WIDTH;
     656    curwidth = rcBw(lpBand);
     657
     658    /* set new left/top point */
     659    if (infoPtr->dwStyle & CCS_VERT)
     660        lpBand->rcBand.top = x + xsep;
     661    else
     662        lpBand->rcBand.left = x + xsep;
     663
     664    /* compute new width */
     665    if (lpBand->hwndChild && extra) {
     666        /* set to the "current" band size less the header */
     667        fudge = lpBand->ccx;
     668        last_adjusted = i;
     669        if ((lpBand->fMask & RBBIM_SIZE) && (lpBand->cx > 0) &&
     670        (fudge > curwidth)) {
     671        TRACE("adjusting band %d by %d, fudge=%d, curwidth=%d, extra=%d\n",
     672              i, fudge-curwidth, fudge, curwidth, extra);
     673        if ((fudge - curwidth) > extra)
     674            fudge = curwidth + extra;
     675        extra -= (fudge - curwidth);
     676        curwidth = fudge;
     677        }
     678        else {
     679        TRACE("adjusting band %d by %d, fudge=%d, curwidth=%d\n",
     680              i, extra, fudge, curwidth);
     681        curwidth += extra;
     682        extra = 0;
     683        }
     684    }
     685
     686    /* set new right/bottom point */
     687    if (infoPtr->dwStyle & CCS_VERT)
     688        lpBand->rcBand.bottom = lpBand->rcBand.top + curwidth;
     689    else
     690        lpBand->rcBand.right = lpBand->rcBand.left + curwidth;
     691    TRACE("Phase 1 band %d, (%d,%d)-(%d,%d), orig x=%d, xsep=%d\n",
     692          i, lpBand->rcBand.left, lpBand->rcBand.top,
     693          lpBand->rcBand.right, lpBand->rcBand.bottom, x, xsep);
     694    x = rcBrb(lpBand);
    694695    }
    695696    if ((x >= maxx) || last_adjusted) {
    696         if (x > maxx) {
    697             ERR("Phase 1 failed, x=%d, maxx=%d, start=%u, end=%u\n",
    698                 x, maxx,  rowstart, rowend);
    699         }
    700         /* done, so spread extra space */
    701         if (x < maxx) {
    702             fudge = maxx - x;
    703             TRACE("Need to spread %d on last adjusted band %d\n",
    704                 fudge, last_adjusted);
    705             for (i=(INT)last_adjusted; i<=(INT)rowend; i++) {
    706                 lpBand = &infoPtr->bands[i];
    707                 if (HIDDENBAND(lpBand)) continue;
    708 
    709                 /* set right/bottom point */
    710                 if (i != last_adjusted) {
    711                     if (infoPtr->dwStyle & CCS_VERT)
    712                         lpBand->rcBand.top += fudge;
    713                     else
    714                         lpBand->rcBand.left += fudge;
    715                 }
    716 
    717                 /* set left/bottom point */
    718                 if (infoPtr->dwStyle & CCS_VERT)
    719                     lpBand->rcBand.bottom += fudge;
    720                 else
    721                     lpBand->rcBand.right += fudge;
    722             }
    723         }
    724         TRACE("Phase 1 succeeded, used x=%d\n", x);
    725         REBAR_FixVert (infoPtr, rowstart, rowend, mcy);
    726         return;
     697    if (x > maxx) {
     698        ERR("Phase 1 failed, x=%d, maxx=%d, start=%u, end=%u\n",
     699        x, maxx,  rowstart, rowend);
     700    }
     701    /* done, so spread extra space */
     702    if (x < maxx) {
     703        fudge = maxx - x;
     704        TRACE("Need to spread %d on last adjusted band %d\n",
     705        fudge, last_adjusted);
     706        for (i=(INT)last_adjusted; i<=(INT)rowend; i++) {
     707        lpBand = &infoPtr->bands[i];
     708        if (HIDDENBAND(lpBand)) continue;
     709
     710        /* set right/bottom point */
     711        if (i != last_adjusted) {
     712            if (infoPtr->dwStyle & CCS_VERT)
     713            lpBand->rcBand.top += fudge;
     714            else
     715            lpBand->rcBand.left += fudge;
     716        }
     717
     718        /* set left/bottom point */
     719        if (infoPtr->dwStyle & CCS_VERT)
     720            lpBand->rcBand.bottom += fudge;
     721        else
     722            lpBand->rcBand.right += fudge;
     723        }
     724    }
     725    TRACE("Phase 1 succeeded, used x=%d\n", x);
     726    REBAR_FixVert (infoPtr, rowstart, rowend, mcy);
     727    return;
    727728    }
    728729
     
    736737    x = 0;
    737738    for (i=(INT)rowstart; i<=(INT)rowend; i++) {
    738         lpBand = &infoPtr->bands[i];
    739         if (HIDDENBAND(lpBand)) continue;
    740         xsep = (x == 0) ? 0 : SEP_WIDTH;
    741         curwidth = rcBw(lpBand);
    742 
    743         /* set new left/top point */
    744         if (infoPtr->dwStyle & CCS_VERT)
    745             lpBand->rcBand.top = x + xsep;
    746         else
    747             lpBand->rcBand.left = x + xsep;
    748 
    749         /* compute new width */
    750         if (extra) {
    751             curwidth += extra;
    752             extra = 0;
    753         }
    754 
    755         /* set new right/bottom point */
    756         if (infoPtr->dwStyle & CCS_VERT)
    757             lpBand->rcBand.bottom = lpBand->rcBand.top + curwidth;
    758         else
    759             lpBand->rcBand.right = lpBand->rcBand.left + curwidth;
    760         TRACE("Phase 2 band %d, (%d,%d)-(%d,%d), orig x=%d, xsep=%d\n",
    761               i, lpBand->rcBand.left, lpBand->rcBand.top,
    762               lpBand->rcBand.right, lpBand->rcBand.bottom, x, xsep);
    763         x = rcBrb(lpBand);
     739    lpBand = &infoPtr->bands[i];
     740    if (HIDDENBAND(lpBand)) continue;
     741    xsep = (x == 0) ? 0 : SEP_WIDTH;
     742    curwidth = rcBw(lpBand);
     743
     744    /* set new left/top point */
     745    if (infoPtr->dwStyle & CCS_VERT)
     746        lpBand->rcBand.top = x + xsep;
     747    else
     748        lpBand->rcBand.left = x + xsep;
     749
     750    /* compute new width */
     751    if (extra) {
     752        curwidth += extra;
     753        extra = 0;
     754    }
     755
     756    /* set new right/bottom point */
     757    if (infoPtr->dwStyle & CCS_VERT)
     758        lpBand->rcBand.bottom = lpBand->rcBand.top + curwidth;
     759    else
     760        lpBand->rcBand.right = lpBand->rcBand.left + curwidth;
     761    TRACE("Phase 2 band %d, (%d,%d)-(%d,%d), orig x=%d, xsep=%d\n",
     762          i, lpBand->rcBand.left, lpBand->rcBand.top,
     763          lpBand->rcBand.right, lpBand->rcBand.bottom, x, xsep);
     764    x = rcBrb(lpBand);
    764765    }
    765766    if (x >= maxx) {
    766         if (x > maxx) {
    767             ERR("Phase 2 failed, x=%d, maxx=%d, start=%u, end=%u\n",
    768                 x, maxx,  rowstart, rowend);
    769         }
    770         /* done, so spread extra space */
    771         TRACE("Phase 2 succeeded, used x=%d\n", x);
    772         REBAR_FixVert (infoPtr, rowstart, rowend, mcy);
    773         return;
     767    if (x > maxx) {
     768        ERR("Phase 2 failed, x=%d, maxx=%d, start=%u, end=%u\n",
     769        x, maxx,  rowstart, rowend);
     770    }
     771    /* done, so spread extra space */
     772    TRACE("Phase 2 succeeded, used x=%d\n", x);
     773    REBAR_FixVert (infoPtr, rowstart, rowend, mcy);
     774    return;
    774775    }
    775776
     
    781782    lpBand = &infoPtr->bands[rowstart];
    782783    ERR("Serious problem adjusting row %d, start band %d, end band %d\n",
    783         lpBand->iRow, rowstart, rowend);
     784    lpBand->iRow, rowstart, rowend);
    784785    REBAR_DumpBand (infoPtr);
    785786    return;
     
    805806      if (HIDDENBAND(lpBand)) {
    806807          SetRect (&lpBand->rcChild,
    807                    lpBand->rcBand.right, lpBand->rcBand.top,
    808                    lpBand->rcBand.right, lpBand->rcBand.bottom);
    809           continue;
     808           lpBand->rcBand.right, lpBand->rcBand.top,
     809           lpBand->rcBand.right, lpBand->rcBand.bottom);
     810      continue;
    810811      }
    811812
     
    814815      /* set initial gripper rectangle */
    815816      SetRect (&lpBand->rcGripper, lpBand->rcBand.left, lpBand->rcBand.top,
    816                lpBand->rcBand.left, lpBand->rcBand.bottom);
     817           lpBand->rcBand.left, lpBand->rcBand.bottom);
    817818
    818819      /* calculate gripper rectangle */
    819820      if ( lpBand->fStatus & HAS_GRIPPER) {
    820           lpBand->fDraw |= DRAW_GRIPPER;
    821           lpBand->rcGripper.left   += REBAR_PRE_GRIPPER;
    822           lpBand->rcGripper.right  = lpBand->rcGripper.left + GRIPPER_WIDTH;
    823           lpBand->rcGripper.top    += 2;
    824           lpBand->rcGripper.bottom -= 2;
    825 
    826           SetRect (&lpBand->rcCapImage,
    827                    lpBand->rcGripper.right+REBAR_ALWAYS_SPACE, lpBand->rcBand.top,
    828                    lpBand->rcGripper.right+REBAR_ALWAYS_SPACE, lpBand->rcBand.bottom);
     821      lpBand->fDraw |= DRAW_GRIPPER;
     822      lpBand->rcGripper.left   += REBAR_PRE_GRIPPER;
     823      lpBand->rcGripper.right  = lpBand->rcGripper.left + GRIPPER_WIDTH;
     824      lpBand->rcGripper.top    += 2;
     825      lpBand->rcGripper.bottom -= 2;
     826
     827      SetRect (&lpBand->rcCapImage,
     828           lpBand->rcGripper.right+REBAR_ALWAYS_SPACE, lpBand->rcBand.top,
     829           lpBand->rcGripper.right+REBAR_ALWAYS_SPACE, lpBand->rcBand.bottom);
    829830      }
    830831      else {  /* no gripper will be drawn */
    831           xoff = 0;
    832           if (lpBand->fStatus & (HAS_IMAGE | HAS_TEXT))
    833               /* if no gripper but either image or text, then leave space */
    834               xoff = REBAR_ALWAYS_SPACE;
    835           SetRect (&lpBand->rcCapImage,
    836                    lpBand->rcBand.left+xoff, lpBand->rcBand.top,
    837                    lpBand->rcBand.left+xoff, lpBand->rcBand.bottom);
     832      xoff = 0;
     833      if (lpBand->fStatus & (HAS_IMAGE | HAS_TEXT))
     834          /* if no gripper but either image or text, then leave space */
     835          xoff = REBAR_ALWAYS_SPACE;
     836      SetRect (&lpBand->rcCapImage,
     837           lpBand->rcBand.left+xoff, lpBand->rcBand.top,
     838           lpBand->rcBand.left+xoff, lpBand->rcBand.bottom);
    838839      }
    839840
    840841      /* image is visible */
    841842      if (lpBand->fStatus & HAS_IMAGE) {
    842           lpBand->fDraw |= DRAW_IMAGE;
    843           lpBand->rcCapImage.right  += infoPtr->imageSize.cx;
    844           lpBand->rcCapImage.bottom = lpBand->rcCapImage.top + infoPtr->imageSize.cy;
    845 
    846           /* set initial caption text rectangle */
    847           SetRect (&lpBand->rcCapText,
    848                    lpBand->rcCapImage.right+REBAR_POST_IMAGE, lpBand->rcBand.top+1,
    849                    lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.bottom-1);
    850           /* update band height
    851           if (lpBand->uMinHeight < infoPtr->imageSize.cy + 2) {
    852               lpBand->uMinHeight = infoPtr->imageSize.cy + 2;
    853               lpBand->rcBand.bottom = lpBand->rcBand.top + lpBand->uMinHeight;
    854           }  */
     843      lpBand->fDraw |= DRAW_IMAGE;
     844      lpBand->rcCapImage.right  += infoPtr->imageSize.cx;
     845      lpBand->rcCapImage.bottom = lpBand->rcCapImage.top + infoPtr->imageSize.cy;
     846
     847      /* set initial caption text rectangle */
     848      SetRect (&lpBand->rcCapText,
     849           lpBand->rcCapImage.right+REBAR_POST_IMAGE, lpBand->rcBand.top+1,
     850           lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.bottom-1);
     851      /* update band height
     852      if (lpBand->uMinHeight < infoPtr->imageSize.cy + 2) {
     853          lpBand->uMinHeight = infoPtr->imageSize.cy + 2;
     854          lpBand->rcBand.bottom = lpBand->rcBand.top + lpBand->uMinHeight;
     855      }  */
    855856      }
    856857      else {
    857           /* set initial caption text rectangle */
    858           SetRect (&lpBand->rcCapText, lpBand->rcCapImage.right, lpBand->rcBand.top+1,
    859                    lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.bottom-1);
     858      /* set initial caption text rectangle */
     859      SetRect (&lpBand->rcCapText, lpBand->rcCapImage.right, lpBand->rcBand.top+1,
     860           lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.bottom-1);
    860861      }
    861862
    862863      /* text is visible */
    863864      if (lpBand->fStatus & HAS_TEXT) {
    864           lpBand->fDraw |= DRAW_TEXT;
    865           lpBand->rcCapText.right = max(lpBand->rcCapText.left,
    866                                         lpBand->rcCapText.right-REBAR_POST_TEXT);
     865      lpBand->fDraw |= DRAW_TEXT;
     866      lpBand->rcCapText.right = max(lpBand->rcCapText.left,
     867                    lpBand->rcCapText.right-REBAR_POST_TEXT);
    867868      }
    868869
    869870      /* set initial child window rectangle if there is a child */
    870871      if (lpBand->fMask & RBBIM_CHILD) {
    871           xoff = lpBand->offChild.cx;
    872           yoff = lpBand->offChild.cy;
    873           SetRect (&lpBand->rcChild,
    874                    lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.top+yoff,
    875                    lpBand->rcBand.right-xoff, lpBand->rcBand.bottom-yoff);
     872      xoff = lpBand->offChild.cx;
     873      yoff = lpBand->offChild.cy;
     874      SetRect (&lpBand->rcChild,
     875           lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.top+yoff,
     876           lpBand->rcBand.right-xoff, lpBand->rcBand.bottom-yoff);
    876877      }
    877878      else {
    878879          SetRect (&lpBand->rcChild,
    879                    lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.top,
    880                    lpBand->rcBand.right, lpBand->rcBand.bottom);
     880           lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.top,
     881           lpBand->rcBand.right, lpBand->rcBand.bottom);
    881882      }
    882883
    883884      /* flag if notify required and invalidate rectangle */
    884       if (notify && 
    885           ((oldChild.right-oldChild.left != lpBand->rcChild.right-lpBand->rcChild.left) ||
    886            (oldChild.bottom-oldChild.top != lpBand->rcChild.bottom-lpBand->rcChild.top))) {
    887           TRACE("Child rectangle changed for band %u\n", i);
    888           TRACE("    from (%d,%d)-(%d,%d)  to (%d,%d)-(%d,%d)\n",
    889                 oldChild.left, oldChild.top,
    890                 oldChild.right, oldChild.bottom,
    891                 lpBand->rcChild.left, lpBand->rcChild.top,
    892                 lpBand->rcChild.right, lpBand->rcChild.bottom);
     885      if (notify &&
     886      ((oldChild.right-oldChild.left != lpBand->rcChild.right-lpBand->rcChild.left) ||
     887       (oldChild.bottom-oldChild.top != lpBand->rcChild.bottom-lpBand->rcChild.top))) {
     888      TRACE("Child rectangle changed for band %u\n", i);
     889      TRACE("    from (%d,%d)-(%d,%d)  to (%d,%d)-(%d,%d)\n",
     890        oldChild.left, oldChild.top,
     891            oldChild.right, oldChild.bottom,
     892        lpBand->rcChild.left, lpBand->rcChild.top,
     893            lpBand->rcChild.right, lpBand->rcChild.bottom);
    893894      }
    894895      if (lpBand->fDraw & NTF_INVALIDATE) {
    895           TRACE("invalidating (%d,%d)-(%d,%d)\n",
    896                 lpBand->rcBand.left,
    897                 lpBand->rcBand.top,
    898                 lpBand->rcBand.right + ((lpBand->fDraw & DRAW_RIGHTSEP) ? SEP_WIDTH_SIZE : 0),
    899                 lpBand->rcBand.bottom + ((lpBand->fDraw & DRAW_BOTTOMSEP) ? SEP_WIDTH_SIZE : 0));
    900           lpBand->fDraw &= ~NTF_INVALIDATE;
    901           work = lpBand->rcBand;
    902           if (lpBand->fDraw & DRAW_RIGHTSEP) work.right += SEP_WIDTH_SIZE;
    903           if (lpBand->fDraw & DRAW_BOTTOMSEP) work.bottom += SEP_WIDTH_SIZE;
    904           InvalidateRect(infoPtr->hwndSelf, &work, TRUE);
     896      TRACE("invalidating (%d,%d)-(%d,%d)\n",
     897        lpBand->rcBand.left,
     898        lpBand->rcBand.top,
     899        lpBand->rcBand.right + ((lpBand->fDraw & DRAW_RIGHTSEP) ? SEP_WIDTH_SIZE : 0),
     900        lpBand->rcBand.bottom + ((lpBand->fDraw & DRAW_BOTTOMSEP) ? SEP_WIDTH_SIZE : 0));
     901      lpBand->fDraw &= ~NTF_INVALIDATE;
     902      work = lpBand->rcBand;
     903      if (lpBand->fDraw & DRAW_RIGHTSEP) work.right += SEP_WIDTH_SIZE;
     904      if (lpBand->fDraw & DRAW_BOTTOMSEP) work.bottom += SEP_WIDTH_SIZE;
     905      InvalidateRect(infoPtr->hwndSelf, &work, TRUE);
    905906      }
    906907
     
    925926
    926927    for(i=rstart; i<rend; i++){
    927         lpBand = &infoPtr->bands[i];
    928         if (HIDDENBAND(lpBand)) continue;
    929         oldChild = lpBand->rcChild;
    930 
    931         /* set initial gripper rectangle */
    932         SetRect (&lpBand->rcGripper, lpBand->rcBand.left, lpBand->rcBand.top,
    933                 lpBand->rcBand.right, lpBand->rcBand.top);
    934 
    935         /* calculate gripper rectangle */
    936         if (lpBand->fStatus & HAS_GRIPPER) {
    937             lpBand->fDraw |= DRAW_GRIPPER;
    938 
    939             if (infoPtr->dwStyle & RBS_VERTICALGRIPPER) {
    940                 /*  vertical gripper  */
    941                 lpBand->rcGripper.left   += 3;
    942                 lpBand->rcGripper.right  = lpBand->rcGripper.left + GRIPPER_WIDTH;
    943                 lpBand->rcGripper.top    += REBAR_PRE_GRIPPER;
    944                 lpBand->rcGripper.bottom = lpBand->rcGripper.top + GRIPPER_HEIGHT;
    945 
    946                 /* initialize Caption image rectangle  */
    947                 SetRect (&lpBand->rcCapImage, lpBand->rcBand.left,
    948                         lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE,
    949                         lpBand->rcBand.right,
    950                         lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE);
    951             }
    952             else {
    953                 /*  horizontal gripper  */
    954                 lpBand->rcGripper.left   += 3;
    955                 lpBand->rcGripper.right  -= 3;
    956                 lpBand->rcGripper.top    += REBAR_PRE_GRIPPER;
    957                 lpBand->rcGripper.bottom  = lpBand->rcGripper.top + GRIPPER_WIDTH;
    958 
    959                 /* initialize Caption image rectangle  */
    960                 SetRect (&lpBand->rcCapImage, lpBand->rcBand.left,
    961                         lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE,
    962                         lpBand->rcBand.right,
    963                         lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE);
    964             }
    965         }
    966         else {  /* no gripper will be drawn */
    967             xoff = 0;
    968             if (lpBand->fStatus & (HAS_IMAGE | HAS_TEXT))
    969                 /* if no gripper but either image or text, then leave space */
    970                 xoff = REBAR_ALWAYS_SPACE;
    971             /* initialize Caption image rectangle  */
    972             SetRect (&lpBand->rcCapImage,
    973                      lpBand->rcBand.left, lpBand->rcBand.top+xoff,
    974                      lpBand->rcBand.right, lpBand->rcBand.top+xoff);
    975         }
    976 
    977         /* image is visible */
    978         if (lpBand->fStatus & HAS_IMAGE) {
    979             lpBand->fDraw |= DRAW_IMAGE;
    980 
    981             lpBand->rcCapImage.right  = lpBand->rcCapImage.left + infoPtr->imageSize.cx;
    982             lpBand->rcCapImage.bottom += infoPtr->imageSize.cy;
    983 
    984             /* set initial caption text rectangle */
    985             SetRect (&lpBand->rcCapText,
    986                      lpBand->rcBand.left, lpBand->rcCapImage.bottom+REBAR_POST_IMAGE,
    987                      lpBand->rcBand.right, lpBand->rcBand.top+lpBand->cxHeader);
    988             /* update band height *
    989                if (lpBand->uMinHeight < infoPtr->imageSize.cx + 2) {
    990                lpBand->uMinHeight = infoPtr->imageSize.cx + 2;
    991                lpBand->rcBand.right = lpBand->rcBand.left + lpBand->uMinHeight;
    992                } */
    993         }
    994         else {
    995             /* set initial caption text rectangle */
    996             SetRect (&lpBand->rcCapText,
    997                      lpBand->rcBand.left, lpBand->rcCapImage.bottom,
    998                      lpBand->rcBand.right, lpBand->rcBand.top+lpBand->cxHeader);
    999         }
    1000 
    1001         /* text is visible */
    1002         if (lpBand->fStatus & HAS_TEXT) {
    1003             lpBand->fDraw |= DRAW_TEXT;
    1004             lpBand->rcCapText.bottom = max(lpBand->rcCapText.top,
    1005                                            lpBand->rcCapText.bottom-REBAR_POST_TEXT);
    1006         }
    1007 
    1008         /* set initial child window rectangle if there is a child */
    1009         if (lpBand->fMask & RBBIM_CHILD) {
    1010             yoff = lpBand->offChild.cx;
    1011             xoff = lpBand->offChild.cy;
    1012             SetRect (&lpBand->rcChild,
    1013                      lpBand->rcBand.left+xoff, lpBand->rcBand.top+lpBand->cxHeader,
    1014                      lpBand->rcBand.right-xoff, lpBand->rcBand.bottom-yoff);
    1015         }
    1016         else {
    1017             SetRect (&lpBand->rcChild,
    1018                      lpBand->rcBand.left, lpBand->rcBand.top+lpBand->cxHeader,
    1019                      lpBand->rcBand.right, lpBand->rcBand.bottom);
    1020         }
    1021 
    1022         /* flag if notify required and invalidate rectangle */
    1023         if (notify &&
    1024             ((oldChild.right-oldChild.left != lpBand->rcChild.right-lpBand->rcChild.left) ||
    1025              (oldChild.bottom-oldChild.top != lpBand->rcChild.bottom-lpBand->rcChild.top))) {
    1026             TRACE("Child rectangle changed for band %u\n", i);
    1027             TRACE("    from (%d,%d)-(%d,%d)  to (%d,%d)-(%d,%d)\n",
    1028                   oldChild.left, oldChild.top,
    1029                   oldChild.right, oldChild.bottom,
    1030                   lpBand->rcChild.left, lpBand->rcChild.top,
    1031                   lpBand->rcChild.right, lpBand->rcChild.bottom);
    1032         }
    1033         if (lpBand->fDraw & NTF_INVALIDATE) {
    1034             TRACE("invalidating (%d,%d)-(%d,%d)\n",
    1035                   lpBand->rcBand.left,
    1036                   lpBand->rcBand.top,
    1037                   lpBand->rcBand.right + ((lpBand->fDraw & DRAW_BOTTOMSEP) ? SEP_WIDTH_SIZE : 0),
    1038                   lpBand->rcBand.bottom + ((lpBand->fDraw & DRAW_RIGHTSEP) ? SEP_WIDTH_SIZE : 0));
    1039             lpBand->fDraw &= ~NTF_INVALIDATE;
    1040             work = lpBand->rcBand;
    1041             if (lpBand->fDraw & DRAW_RIGHTSEP) work.bottom += SEP_WIDTH_SIZE;
    1042             if (lpBand->fDraw & DRAW_BOTTOMSEP) work.right += SEP_WIDTH_SIZE;
    1043             InvalidateRect(infoPtr->hwndSelf, &work, TRUE);
    1044         }
     928    lpBand = &infoPtr->bands[i];
     929    if (HIDDENBAND(lpBand)) continue;
     930    oldChild = lpBand->rcChild;
     931
     932    /* set initial gripper rectangle */
     933    SetRect (&lpBand->rcGripper, lpBand->rcBand.left, lpBand->rcBand.top,
     934        lpBand->rcBand.right, lpBand->rcBand.top);
     935
     936    /* calculate gripper rectangle */
     937    if (lpBand->fStatus & HAS_GRIPPER) {
     938        lpBand->fDraw |= DRAW_GRIPPER;
     939
     940        if (infoPtr->dwStyle & RBS_VERTICALGRIPPER) {
     941        /*  vertical gripper  */
     942        lpBand->rcGripper.left   += 3;
     943        lpBand->rcGripper.right  = lpBand->rcGripper.left + GRIPPER_WIDTH;
     944        lpBand->rcGripper.top    += REBAR_PRE_GRIPPER;
     945        lpBand->rcGripper.bottom = lpBand->rcGripper.top + GRIPPER_HEIGHT;
     946
     947        /* initialize Caption image rectangle  */
     948        SetRect (&lpBand->rcCapImage, lpBand->rcBand.left,
     949            lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE,
     950            lpBand->rcBand.right,
     951            lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE);
     952        }
     953        else {
     954        /*  horizontal gripper  */
     955        lpBand->rcGripper.left   += 3;
     956        lpBand->rcGripper.right  -= 3;
     957        lpBand->rcGripper.top    += REBAR_PRE_GRIPPER;
     958        lpBand->rcGripper.bottom  = lpBand->rcGripper.top + GRIPPER_WIDTH;
     959
     960        /* initialize Caption image rectangle  */
     961        SetRect (&lpBand->rcCapImage, lpBand->rcBand.left,
     962            lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE,
     963            lpBand->rcBand.right,
     964            lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE);
     965        }
     966    }
     967    else {  /* no gripper will be drawn */
     968        xoff = 0;
     969        if (lpBand->fStatus & (HAS_IMAGE | HAS_TEXT))
     970        /* if no gripper but either image or text, then leave space */
     971        xoff = REBAR_ALWAYS_SPACE;
     972        /* initialize Caption image rectangle  */
     973        SetRect (&lpBand->rcCapImage,
     974             lpBand->rcBand.left, lpBand->rcBand.top+xoff,
     975             lpBand->rcBand.right, lpBand->rcBand.top+xoff);
     976    }
     977
     978    /* image is visible */
     979    if (lpBand->fStatus & HAS_IMAGE) {
     980        lpBand->fDraw |= DRAW_IMAGE;
     981
     982        lpBand->rcCapImage.right  = lpBand->rcCapImage.left + infoPtr->imageSize.cx;
     983        lpBand->rcCapImage.bottom += infoPtr->imageSize.cy;
     984
     985        /* set initial caption text rectangle */
     986        SetRect (&lpBand->rcCapText,
     987             lpBand->rcBand.left, lpBand->rcCapImage.bottom+REBAR_POST_IMAGE,
     988             lpBand->rcBand.right, lpBand->rcBand.top+lpBand->cxHeader);
     989        /* update band height *
     990           if (lpBand->uMinHeight < infoPtr->imageSize.cx + 2) {
     991           lpBand->uMinHeight = infoPtr->imageSize.cx + 2;
     992           lpBand->rcBand.right = lpBand->rcBand.left + lpBand->uMinHeight;
     993           } */
     994    }
     995    else {
     996        /* set initial caption text rectangle */
     997        SetRect (&lpBand->rcCapText,
     998             lpBand->rcBand.left, lpBand->rcCapImage.bottom,
     999             lpBand->rcBand.right, lpBand->rcBand.top+lpBand->cxHeader);
     1000    }
     1001
     1002    /* text is visible */
     1003    if (lpBand->fStatus & HAS_TEXT) {
     1004        lpBand->fDraw |= DRAW_TEXT;
     1005        lpBand->rcCapText.bottom = max(lpBand->rcCapText.top,
     1006                       lpBand->rcCapText.bottom-REBAR_POST_TEXT);
     1007    }
     1008
     1009    /* set initial child window rectangle if there is a child */
     1010    if (lpBand->fMask & RBBIM_CHILD) {
     1011        yoff = lpBand->offChild.cx;
     1012        xoff = lpBand->offChild.cy;
     1013        SetRect (&lpBand->rcChild,
     1014             lpBand->rcBand.left+xoff, lpBand->rcBand.top+lpBand->cxHeader,
     1015             lpBand->rcBand.right-xoff, lpBand->rcBand.bottom-yoff);
     1016    }
     1017    else {
     1018        SetRect (&lpBand->rcChild,
     1019             lpBand->rcBand.left, lpBand->rcBand.top+lpBand->cxHeader,
     1020             lpBand->rcBand.right, lpBand->rcBand.bottom);
     1021    }
     1022
     1023    /* flag if notify required and invalidate rectangle */
     1024    if (notify &&
     1025        ((oldChild.right-oldChild.left != lpBand->rcChild.right-lpBand->rcChild.left) ||
     1026         (oldChild.bottom-oldChild.top != lpBand->rcChild.bottom-lpBand->rcChild.top))) {
     1027        TRACE("Child rectangle changed for band %u\n", i);
     1028        TRACE("    from (%d,%d)-(%d,%d)  to (%d,%d)-(%d,%d)\n",
     1029          oldChild.left, oldChild.top,
     1030          oldChild.right, oldChild.bottom,
     1031          lpBand->rcChild.left, lpBand->rcChild.top,
     1032          lpBand->rcChild.right, lpBand->rcChild.bottom);
     1033    }
     1034    if (lpBand->fDraw & NTF_INVALIDATE) {
     1035        TRACE("invalidating (%d,%d)-(%d,%d)\n",
     1036          lpBand->rcBand.left,
     1037          lpBand->rcBand.top,
     1038          lpBand->rcBand.right + ((lpBand->fDraw & DRAW_BOTTOMSEP) ? SEP_WIDTH_SIZE : 0),
     1039          lpBand->rcBand.bottom + ((lpBand->fDraw & DRAW_RIGHTSEP) ? SEP_WIDTH_SIZE : 0));
     1040        lpBand->fDraw &= ~NTF_INVALIDATE;
     1041        work = lpBand->rcBand;
     1042        if (lpBand->fDraw & DRAW_RIGHTSEP) work.bottom += SEP_WIDTH_SIZE;
     1043        if (lpBand->fDraw & DRAW_BOTTOMSEP) work.right += SEP_WIDTH_SIZE;
     1044        InvalidateRect(infoPtr->hwndSelf, &work, TRUE);
     1045    }
    10451046
    10461047    }
     
    10631064
    10641065    TRACE( " old [%ld x %ld], new [%ld x %ld], client [%d x %d]\n",
    1065            infoPtr->oldSize.cx, infoPtr->oldSize.cy,
    1066            infoPtr->calcSize.cx, infoPtr->calcSize.cy,
    1067            rc.right, rc.bottom);
     1066       infoPtr->oldSize.cx, infoPtr->oldSize.cy,
     1067       infoPtr->calcSize.cx, infoPtr->calcSize.cy,
     1068       rc.right, rc.bottom);
    10681069
    10691070    /* If we need to shrink client, then skip size test */
    10701071    if ((infoPtr->calcSize.cy >= rc.bottom) &&
    1071         (infoPtr->calcSize.cx >= rc.right)) {
    1072 
    1073         /* if size did not change then skip process */
    1074         if ((infoPtr->oldSize.cx == infoPtr->calcSize.cx) &&
    1075             (infoPtr->oldSize.cy == infoPtr->calcSize.cy) &&
    1076             !(infoPtr->fStatus & RESIZE_ANYHOW))
    1077             {
    1078                 TRACE("skipping reset\n");
    1079                 return;
    1080             }
     1072    (infoPtr->calcSize.cx >= rc.right)) {
     1073
     1074    /* if size did not change then skip process */
     1075    if ((infoPtr->oldSize.cx == infoPtr->calcSize.cx) &&
     1076        (infoPtr->oldSize.cy == infoPtr->calcSize.cy) &&
     1077        !(infoPtr->fStatus & RESIZE_ANYHOW))
     1078        {
     1079        TRACE("skipping reset\n");
     1080        return;
     1081        }
    10811082    }
    10821083
     
    10941095#if 0
    10951096    if (GetWindowLongA (infoPtr->hwndSelf, GWL_STYLE) & WS_BORDER) {
    1096         InflateRect (&rc, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE));
     1097    InflateRect (&rc, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE));
    10971098    }
    10981099#endif
    10991100
    11001101    TRACE("setting to (0,0)-(%d,%d)\n",
    1101           rc.right - rc.left, rc.bottom - rc.top);
     1102      rc.right - rc.left, rc.bottom - rc.top);
    11021103    SetWindowPos (infoPtr->hwndSelf, 0, 0, 0,
    1103                     rc.right - rc.left, rc.bottom - rc.top,
    1104                     SWP_NOMOVE | SWP_NOZORDER | SWP_SHOWWINDOW);
     1104            rc.right - rc.left, rc.bottom - rc.top,
     1105            SWP_NOMOVE | SWP_NOZORDER | SWP_SHOWWINDOW);
    11051106}
    11061107
     
    11201121
    11211122    for (i = start; i < endplus; i++) {
    1122         lpBand = &infoPtr->bands[i];
    1123 
    1124         if (HIDDENBAND(lpBand)) continue;
    1125         if (lpBand->hwndChild) {
    1126             TRACE("hwndChild = %x\n", lpBand->hwndChild);
    1127 
    1128             /* Always geterate the RBN_CHILDSIZE even it child
    1129                    did not change */
    1130             rbcz.uBand = i;
    1131             rbcz.wID = lpBand->wID;
    1132             rbcz.rcChild = lpBand->rcChild;
    1133             rbcz.rcBand = lpBand->rcBand;
    1134             rbcz.rcBand.left += lpBand->cxHeader;
    1135             REBAR_Notify ((NMHDR *)&rbcz, infoPtr, RBN_CHILDSIZE);
    1136             if (!EqualRect (&lpBand->rcChild, &rbcz.rcChild)) {
    1137                 TRACE("Child rect changed by NOTIFY for band %u\n", i);
    1138                 TRACE("    from (%d,%d)-(%d,%d)  to (%d,%d)-(%d,%d)\n",
    1139                       lpBand->rcChild.left, lpBand->rcChild.top,
    1140                       lpBand->rcChild.right, lpBand->rcChild.bottom,
    1141                       rbcz.rcChild.left, rbcz.rcChild.top,
    1142                       rbcz.rcChild.right, rbcz.rcChild.bottom);
    1143             }
    1144 
    1145             GetClassNameA (lpBand->hwndChild, szClassName, 40);
    1146             if (!lstrcmpA (szClassName, "ComboBox") ||
    1147                 !lstrcmpA (szClassName, WC_COMBOBOXEXA)) {
    1148                 INT nEditHeight, yPos;
    1149                 RECT rc;
    1150 
    1151                 /* special placement code for combo or comboex box */
    1152 
    1153 
    1154                 /* get size of edit line */
    1155                 GetWindowRect (lpBand->hwndChild, &rc);
    1156                 nEditHeight = rc.bottom - rc.top;
    1157                 yPos = (lpBand->rcChild.bottom + lpBand->rcChild.top - nEditHeight)/2;
    1158 
    1159                 /* center combo box inside child area */
    1160                 TRACE("moving child (Combo(Ex)) %04x to (%d,%d) for (%d,%d)\n",
    1161                       lpBand->hwndChild,
    1162                       lpBand->rcChild.left, yPos,
    1163                       lpBand->rcChild.right - lpBand->rcChild.left,
    1164                       nEditHeight);
    1165                 deferpos = DeferWindowPos (deferpos, lpBand->hwndChild, HWND_TOP,
    1166                                            lpBand->rcChild.left,
    1167                                            /*lpBand->rcChild.top*/ yPos,
    1168                                            lpBand->rcChild.right - lpBand->rcChild.left,
    1169                                            nEditHeight,
    1170                                            SWP_NOZORDER);
    1171                 if (!deferpos)
    1172                     ERR("DeferWindowPos returned NULL\n");
    1173             }
    1174             else {
    1175                 TRACE("moving child (Other) %04x to (%d,%d) for (%d,%d)\n",
    1176                       lpBand->hwndChild,
    1177                       lpBand->rcChild.left, lpBand->rcChild.top,
    1178                       lpBand->rcChild.right - lpBand->rcChild.left,
    1179                       lpBand->rcChild.bottom - lpBand->rcChild.top);
    1180                 deferpos = DeferWindowPos (deferpos, lpBand->hwndChild, HWND_TOP,
    1181                                            lpBand->rcChild.left,
    1182                                            lpBand->rcChild.top,
    1183                                            lpBand->rcChild.right - lpBand->rcChild.left,
    1184                                            lpBand->rcChild.bottom - lpBand->rcChild.top,
    1185                                            SWP_NOZORDER);
    1186                 if (!deferpos)
    1187                     ERR("DeferWindowPos returned NULL\n");
    1188             }
    1189         }
     1123    lpBand = &infoPtr->bands[i];
     1124
     1125    if (HIDDENBAND(lpBand)) continue;
     1126    if (lpBand->hwndChild) {
     1127        TRACE("hwndChild = %x\n", lpBand->hwndChild);
     1128
     1129        /* Always geterate the RBN_CHILDSIZE even it child
     1130           did not change */
     1131        rbcz.uBand = i;
     1132        rbcz.wID = lpBand->wID;
     1133        rbcz.rcChild = lpBand->rcChild;
     1134        rbcz.rcBand = lpBand->rcBand;
     1135        rbcz.rcBand.left += lpBand->cxHeader;
     1136        REBAR_Notify ((NMHDR *)&rbcz, infoPtr, RBN_CHILDSIZE);
     1137        if (!EqualRect (&lpBand->rcChild, &rbcz.rcChild)) {
     1138        TRACE("Child rect changed by NOTIFY for band %u\n", i);
     1139        TRACE("    from (%d,%d)-(%d,%d)  to (%d,%d)-(%d,%d)\n",
     1140              lpBand->rcChild.left, lpBand->rcChild.top,
     1141              lpBand->rcChild.right, lpBand->rcChild.bottom,
     1142              rbcz.rcChild.left, rbcz.rcChild.top,
     1143              rbcz.rcChild.right, rbcz.rcChild.bottom);
     1144        }
     1145
     1146        GetClassNameA (lpBand->hwndChild, szClassName, 40);
     1147        if (!lstrcmpA (szClassName, "ComboBox") ||
     1148        !lstrcmpA (szClassName, WC_COMBOBOXEXA)) {
     1149        INT nEditHeight, yPos;
     1150        RECT rc;
     1151
     1152        /* special placement code for combo or comboex box */
     1153
     1154
     1155        /* get size of edit line */
     1156        GetWindowRect (lpBand->hwndChild, &rc);
     1157        nEditHeight = rc.bottom - rc.top;
     1158        yPos = (lpBand->rcChild.bottom + lpBand->rcChild.top - nEditHeight)/2;
     1159
     1160        /* center combo box inside child area */
     1161        TRACE("moving child (Combo(Ex)) %04x to (%d,%d) for (%d,%d)\n",
     1162              lpBand->hwndChild,
     1163              lpBand->rcChild.left, yPos,
     1164              lpBand->rcChild.right - lpBand->rcChild.left,
     1165              nEditHeight);
     1166        deferpos = DeferWindowPos (deferpos, lpBand->hwndChild, HWND_TOP,
     1167                       lpBand->rcChild.left,
     1168                       /*lpBand->rcChild.top*/ yPos,
     1169                       lpBand->rcChild.right - lpBand->rcChild.left,
     1170                       nEditHeight,
     1171                       SWP_NOZORDER);
     1172        if (!deferpos)
     1173            ERR("DeferWindowPos returned NULL\n");
     1174        }
     1175        else {
     1176        TRACE("moving child (Other) %04x to (%d,%d) for (%d,%d)\n",
     1177              lpBand->hwndChild,
     1178              lpBand->rcChild.left, lpBand->rcChild.top,
     1179              lpBand->rcChild.right - lpBand->rcChild.left,
     1180              lpBand->rcChild.bottom - lpBand->rcChild.top);
     1181        deferpos = DeferWindowPos (deferpos, lpBand->hwndChild, HWND_TOP,
     1182                       lpBand->rcChild.left,
     1183                       lpBand->rcChild.top,
     1184                       lpBand->rcChild.right - lpBand->rcChild.left,
     1185                       lpBand->rcChild.bottom - lpBand->rcChild.top,
     1186                       SWP_NOZORDER);
     1187        if (!deferpos)
     1188            ERR("DeferWindowPos returned NULL\n");
     1189        }
     1190    }
    11901191    }
    11911192    if (!EndDeferWindowPos(deferpos))
     
    12121213
    12131214    if (!(infoPtr->fStatus & BAND_NEEDS_LAYOUT)) {
    1214         TRACE("no layout done. No band changed.\n");
    1215         REBAR_DumpBand (infoPtr);
    1216         return;
     1215    TRACE("no layout done. No band changed.\n");
     1216    REBAR_DumpBand (infoPtr);
     1217    return;
    12171218    }
    12181219    infoPtr->fStatus &= ~BAND_NEEDS_LAYOUT;
     
    12211222    GetClientRect (infoPtr->hwndSelf, &rcClient);
    12221223    TRACE("Client is (%d,%d)-(%d,%d)\n",
    1223           rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
     1224      rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
    12241225
    12251226    if (lpRect) {
    1226         rcAdj = *lpRect;
    1227         TRACE("adjustment rect is (%d,%d)-(%d,%d)\n",
    1228               rcAdj.left, rcAdj.top, rcAdj.right, rcAdj.bottom);
     1227    rcAdj = *lpRect;
     1228    TRACE("adjustment rect is (%d,%d)-(%d,%d)\n",
     1229          rcAdj.left, rcAdj.top, rcAdj.right, rcAdj.bottom);
    12291230    }
    12301231    else {
     
    12431244
    12441245    if (!infoPtr->DoRedraw && (clientcx == 0) && (clientcy == 0)) {
    1245         ERR("no redraw and client is zero, skip layout\n");
    1246         infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
    1247         return;
     1246    ERR("no redraw and client is zero, skip layout\n");
     1247    infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
     1248    return;
    12481249    }
    12491250
    12501251    /* save height of original control */
    1251     if (infoPtr->dwStyle & CCS_VERT) 
     1252    if (infoPtr->dwStyle & CCS_VERT)
    12521253        origheight = infoPtr->calcSize.cx;
    12531254    else
     
    12581259
    12591260    TRACE("band loop constants, clientcx=%d, clientcy=%d\n",
    1260           clientcx, clientcy);
     1261      clientcx, clientcy);
    12611262    x = 0;
    12621263    y = 0;
     
    12681269
    12691270    for (i = 0; i < infoPtr->uNumBands; i++) {
    1270         lpBand = &infoPtr->bands[i];
    1271         lpBand->fDraw = 0;
    1272         lpBand->iRow = row;
    1273 
    1274         if (HIDDENBAND(lpBand)) continue;
    1275 
    1276         lpBand->rcoldBand = lpBand->rcBand;
    1277 
    1278         /* separator from previous band */
    1279         cxsep = ( ((infoPtr->dwStyle & CCS_VERT) ? y : x)==0) ? 0 : SEP_WIDTH; 
    1280 
    1281         /* Header: includes gripper, text, image */
    1282         cx = lpBand->cxHeader;   
    1283         if (lpBand->fStyle & RBBS_FIXEDSIZE) cx = lpBand->lcx;
    1284 
    1285         if (infoPtr->dwStyle & CCS_VERT)
    1286             dobreak = (y + cx + cxsep > adjcy);
     1271    lpBand = &infoPtr->bands[i];
     1272    lpBand->fDraw = 0;
     1273    lpBand->iRow = row;
     1274
     1275    if (HIDDENBAND(lpBand)) continue;
     1276
     1277    lpBand->rcoldBand = lpBand->rcBand;
     1278
     1279    /* separator from previous band */
     1280    cxsep = ( ((infoPtr->dwStyle & CCS_VERT) ? y : x)==0) ? 0 : SEP_WIDTH;
     1281
     1282    /* Header: includes gripper, text, image */
     1283    cx = lpBand->cxHeader;
     1284    if (lpBand->fStyle & RBBS_FIXEDSIZE) cx = lpBand->lcx;
     1285
     1286    if (infoPtr->dwStyle & CCS_VERT)
     1287        dobreak = (y + cx + cxsep > adjcy);
    12871288        else
    1288             dobreak = (x + cx + cxsep > adjcx);
    1289 
    1290         /* This is the check for whether we need to start a new row */
    1291         if ( ( (lpBand->fStyle & RBBS_BREAK) && (i != 0) ) ||
    1292              ( ((infoPtr->dwStyle & CCS_VERT) ? (y != 0) : (x != 0)) && dobreak)) {
    1293 
    1294             for (j = rowstart; j < i; j++) {
    1295                 REBAR_BAND *lpB;
    1296                 lpB = &infoPtr->bands[j];
    1297                 if (infoPtr->dwStyle & CCS_VERT) {
    1298                     lpB->rcBand.right  = lpB->rcBand.left + mcy;
    1299                 }
    1300                 else {
    1301                     lpB->rcBand.bottom = lpB->rcBand.top + mcy;
    1302                 }
    1303             }
    1304 
    1305             TRACE("Spliting to new row %d on band %u\n", row+1, i);
    1306             if (infoPtr->dwStyle & CCS_VERT) {
    1307                 y = 0;
    1308                 x += (mcy + SEP_WIDTH);
    1309             }
    1310             else {
    1311                 x = 0;
    1312                 y += (mcy + SEP_WIDTH);
    1313             }
    1314 
    1315             mcy = 0;
    1316             cxsep = 0;
    1317             row++;
    1318             lpBand->iRow = row;
    1319             prevBand = NULL;
    1320             rowstart = i;
    1321         }
    1322 
    1323         if (mcy < lpBand->lcy + REBARSPACE) mcy = lpBand->lcy + REBARSPACE;
    1324 
    1325         /* if boundary rect specified then limit mcy */
    1326         if (lpRect) {
    1327             if (infoPtr->dwStyle & CCS_VERT) {
    1328                 if (x+mcy > adjcx) {
    1329                     mcy = adjcx - x;
    1330                     TRACE("row %u limiting mcy=%d, adjcx=%d, x=%d\n",
    1331                           i, mcy, adjcx, x);
    1332                 }
    1333             }
    1334             else {
    1335                 if (y+mcy > adjcy) {
    1336                     mcy = adjcy - y;
    1337                     TRACE("row %u limiting mcy=%d, adjcy=%d, y=%d\n",
    1338                           i, mcy, adjcy, y);
    1339                 }
    1340             }
    1341         }
    1342 
    1343         TRACE("band %u, row %d, x=%d, y=%d, cxsep=%d, cx=%d\n",
    1344               i, row,
    1345               x, y, cxsep, cx);
    1346         if (infoPtr->dwStyle & CCS_VERT) {
    1347             /* bound the bottom side if we have a bounding rectangle */
    1348             rightx = clientcx;
    1349             bottomy = (lpRect) ? min(clientcy, y+cxsep+cx) : y+cxsep+cx;
    1350             lpBand->rcBand.left   = x;
    1351             lpBand->rcBand.right  = x + min(mcy, lpBand->lcy+REBARSPACE);
    1352             lpBand->rcBand.top    = min(bottomy, y + cxsep);
    1353             lpBand->rcBand.bottom = bottomy;
    1354             lpBand->uMinHeight = lpBand->lcy;
    1355             y = bottomy;
    1356         }
    1357         else {
    1358             /* bound the right side if we have a bounding rectangle */
    1359             rightx = (lpRect) ? min(clientcx, x+cxsep+cx) : x+cxsep+cx;
    1360             bottomy = clientcy;
    1361             lpBand->rcBand.left   = min(rightx, x + cxsep);
    1362             lpBand->rcBand.right  = rightx;
    1363             lpBand->rcBand.top    = y;
    1364             lpBand->rcBand.bottom = y + min(mcy, lpBand->lcy+REBARSPACE);
    1365             lpBand->uMinHeight = lpBand->lcy;
    1366             x = rightx;
    1367         }
    1368         TRACE("band %u, row %d, (%d,%d)-(%d,%d)\n",
    1369               i, row,
    1370               lpBand->rcBand.left, lpBand->rcBand.top,
    1371               lpBand->rcBand.right, lpBand->rcBand.bottom);
    1372         prevBand = lpBand;
     1289        dobreak = (x + cx + cxsep > adjcx);
     1290
     1291    /* This is the check for whether we need to start a new row */
     1292    if ( ( (lpBand->fStyle & RBBS_BREAK) && (i != 0) ) ||
     1293         ( ((infoPtr->dwStyle & CCS_VERT) ? (y != 0) : (x != 0)) && dobreak)) {
     1294
     1295        for (j = rowstart; j < i; j++) {
     1296        REBAR_BAND *lpB;
     1297        lpB = &infoPtr->bands[j];
     1298        if (infoPtr->dwStyle & CCS_VERT) {
     1299            lpB->rcBand.right  = lpB->rcBand.left + mcy;
     1300        }
     1301        else {
     1302            lpB->rcBand.bottom = lpB->rcBand.top + mcy;
     1303        }
     1304        }
     1305
     1306        TRACE("Spliting to new row %d on band %u\n", row+1, i);
     1307        if (infoPtr->dwStyle & CCS_VERT) {
     1308        y = 0;
     1309        x += (mcy + SEP_WIDTH);
     1310        }
     1311        else {
     1312        x = 0;
     1313        y += (mcy + SEP_WIDTH);
     1314        }
     1315
     1316        mcy = 0;
     1317        cxsep = 0;
     1318        row++;
     1319        lpBand->iRow = row;
     1320        prevBand = NULL;
     1321        rowstart = i;
     1322    }
     1323
     1324    if (mcy < lpBand->lcy + REBARSPACE) mcy = lpBand->lcy + REBARSPACE;
     1325
     1326    /* if boundary rect specified then limit mcy */
     1327    if (lpRect) {
     1328        if (infoPtr->dwStyle & CCS_VERT) {
     1329            if (x+mcy > adjcx) {
     1330            mcy = adjcx - x;
     1331            TRACE("row %u limiting mcy=%d, adjcx=%d, x=%d\n",
     1332              i, mcy, adjcx, x);
     1333        }
     1334        }
     1335        else {
     1336            if (y+mcy > adjcy) {
     1337            mcy = adjcy - y;
     1338            TRACE("row %u limiting mcy=%d, adjcy=%d, y=%d\n",
     1339              i, mcy, adjcy, y);
     1340        }
     1341        }
     1342    }
     1343
     1344    TRACE("band %u, row %d, x=%d, y=%d, cxsep=%d, cx=%d\n",
     1345          i, row,
     1346          x, y, cxsep, cx);
     1347    if (infoPtr->dwStyle & CCS_VERT) {
     1348        /* bound the bottom side if we have a bounding rectangle */
     1349        rightx = clientcx;
     1350        bottomy = (lpRect) ? min(clientcy, y+cxsep+cx) : y+cxsep+cx;
     1351        lpBand->rcBand.left   = x;
     1352        lpBand->rcBand.right  = x + min(mcy, lpBand->lcy+REBARSPACE);
     1353        lpBand->rcBand.top    = min(bottomy, y + cxsep);
     1354        lpBand->rcBand.bottom = bottomy;
     1355        lpBand->uMinHeight = lpBand->lcy;
     1356        y = bottomy;
     1357    }
     1358    else {
     1359        /* bound the right side if we have a bounding rectangle */
     1360        rightx = (lpRect) ? min(clientcx, x+cxsep+cx) : x+cxsep+cx;
     1361        bottomy = clientcy;
     1362        lpBand->rcBand.left   = min(rightx, x + cxsep);
     1363        lpBand->rcBand.right  = rightx;
     1364        lpBand->rcBand.top    = y;
     1365        lpBand->rcBand.bottom = y + min(mcy, lpBand->lcy+REBARSPACE);
     1366        lpBand->uMinHeight = lpBand->lcy;
     1367        x = rightx;
     1368    }
     1369    TRACE("band %u, row %d, (%d,%d)-(%d,%d)\n",
     1370          i, row,
     1371          lpBand->rcBand.left, lpBand->rcBand.top,
     1372          lpBand->rcBand.right, lpBand->rcBand.bottom);
     1373    prevBand = lpBand;
    13731374
    13741375    } /* for (i = 0; i < infoPtr->uNumBands... */
     
    13801381
    13811382    for (j = rowstart; j < infoPtr->uNumBands; j++) {
    1382         lpBand = &infoPtr->bands[j];
    1383         if (infoPtr->dwStyle & CCS_VERT) {
    1384             lpBand->rcBand.right  = lpBand->rcBand.left + mcy;
    1385         }
    1386         else {
    1387             lpBand->rcBand.bottom = lpBand->rcBand.top + mcy;
    1388         }
     1383    lpBand = &infoPtr->bands[j];
     1384    if (infoPtr->dwStyle & CCS_VERT) {
     1385        lpBand->rcBand.right  = lpBand->rcBand.left + mcy;
     1386    }
     1387    else {
     1388        lpBand->rcBand.bottom = lpBand->rcBand.top + mcy;
     1389    }
    13891390    }
    13901391
     
    13991400    mmcy = 0;
    14001401    if (!(infoPtr->dwStyle & RBS_VARHEIGHT)) {
    1401         INT xy;
    1402 
    1403         /* get the max height of all bands */
    1404         for (i=0; i<infoPtr->uNumBands; i++) {
    1405             lpBand = &infoPtr->bands[i];
    1406             if (HIDDENBAND(lpBand)) continue;
    1407             if (infoPtr->dwStyle & CCS_VERT)
    1408                 mmcy = max(mmcy, lpBand->rcBand.right - lpBand->rcBand.left);
    1409             else
    1410                 mmcy = max(mmcy, lpBand->rcBand.bottom - lpBand->rcBand.top);
    1411         }
    1412 
    1413         /* now adjust all rectangles by using the height found above */
    1414         xy = 0;
    1415         row = 1;
    1416         for (i=0; i<infoPtr->uNumBands; i++) {
    1417             lpBand = &infoPtr->bands[i];
    1418             if (HIDDENBAND(lpBand)) continue;
    1419             if (lpBand->iRow != row)
    1420                 xy += (mmcy + SEP_WIDTH);
    1421             if (infoPtr->dwStyle & CCS_VERT) {
    1422                 lpBand->rcBand.left = xy;
    1423                 lpBand->rcBand.right = xy + mmcy;
    1424             }
    1425             else {
    1426                 lpBand->rcBand.top = xy;
    1427                 lpBand->rcBand.bottom = xy + mmcy;
    1428             }
    1429         }
    1430 
    1431         /* set the x/y values to the correct maximum */
    1432         if (infoPtr->dwStyle & CCS_VERT)
    1433             x = xy + mmcy;
    1434         else
    1435             y = xy + mmcy;
     1402    INT xy;
     1403
     1404    /* get the max height of all bands */
     1405    for (i=0; i<infoPtr->uNumBands; i++) {
     1406        lpBand = &infoPtr->bands[i];
     1407        if (HIDDENBAND(lpBand)) continue;
     1408        if (infoPtr->dwStyle & CCS_VERT)
     1409        mmcy = max(mmcy, lpBand->rcBand.right - lpBand->rcBand.left);
     1410        else
     1411        mmcy = max(mmcy, lpBand->rcBand.bottom - lpBand->rcBand.top);
     1412    }
     1413
     1414    /* now adjust all rectangles by using the height found above */
     1415    xy = 0;
     1416    row = 1;
     1417    for (i=0; i<infoPtr->uNumBands; i++) {
     1418        lpBand = &infoPtr->bands[i];
     1419        if (HIDDENBAND(lpBand)) continue;
     1420        if (lpBand->iRow != row)
     1421        xy += (mmcy + SEP_WIDTH);
     1422        if (infoPtr->dwStyle & CCS_VERT) {
     1423        lpBand->rcBand.left = xy;
     1424        lpBand->rcBand.right = xy + mmcy;
     1425        }
     1426        else {
     1427        lpBand->rcBand.top = xy;
     1428        lpBand->rcBand.bottom = xy + mmcy;
     1429        }
     1430    }
     1431
     1432    /* set the x/y values to the correct maximum */
     1433    if (infoPtr->dwStyle & CCS_VERT)
     1434        x = xy + mmcy;
     1435    else
     1436        y = xy + mmcy;
    14361437    }
    14371438
     
    14451446    if (lpRect) {
    14461447        INT i, j, prev_rh, new_rh, adj_rh, prev_idx, current_idx;
    1447         REBAR_BAND *prev, *current, *walk;
     1448    REBAR_BAND *prev, *current, *walk;
    14481449
    14491450/* FIXME:  problem # 2 */
    1450         if (((infoPtr->dwStyle & CCS_VERT) ?
     1451    if (((infoPtr->dwStyle & CCS_VERT) ?
    14511452#if PROBLEM2
    1452              (x < adjcx) : (y < adjcy)
     1453         (x < adjcx) : (y < adjcy)
    14531454#else
    1454              (adjcx - x > 4) : (adjcy - y > 4)
     1455         (adjcx - x > 4) : (adjcy - y > 4)
    14551456#endif
    1456              ) &&
    1457             (infoPtr->uNumBands > 1)) {
    1458             for (i=(INT)infoPtr->uNumBands-2; i>=0; i--) {
    1459                 TRACE("adjcx=%d, adjcy=%d, x=%d, y=%d\n",
    1460                       adjcx, adjcy, x, y);
    1461 
    1462                 /* find the current band (starts at i+1) */
    1463                 current = &infoPtr->bands[i+1];
    1464                 current_idx = i+1;
    1465                 while (HIDDENBAND(current)) {
    1466                     i--;
    1467                     if (i < 0) break; /* out of bands */
    1468                     current = &infoPtr->bands[i+1];
    1469                     current_idx = i+1;
    1470                 }
    1471                 if (i < 0) break; /* out of bands */
    1472 
    1473                 /* now find the prev band (starts at i) */
    1474                 prev = &infoPtr->bands[i];
    1475                 prev_idx = i;
    1476                 while (HIDDENBAND(prev)) {
    1477                     i--;
    1478                     if (i < 0) break; /* out of bands */
    1479                     prev = &infoPtr->bands[i];
    1480                     prev_idx = i;
    1481                 }
    1482                 if (i < 0) break; /* out of bands */
    1483 
    1484                 prev_rh = ircBw(prev);
    1485                 if (prev->iRow == current->iRow) {
    1486                     new_rh = (infoPtr->dwStyle & RBS_VARHEIGHT) ?
    1487                         current->lcy + REBARSPACE :
    1488                         mmcy;
    1489                     adj_rh = new_rh + SEP_WIDTH;
    1490                     infoPtr->uNumRows++;
    1491                     current->fDraw |= NTF_INVALIDATE;
    1492                     current->iRow++;
    1493                     if (infoPtr->dwStyle & CCS_VERT) {
    1494                         current->rcBand.top = 0;
    1495                         current->rcBand.bottom = clientcy;
    1496                         current->rcBand.left += (prev_rh + SEP_WIDTH);
    1497                         current->rcBand.right = current->rcBand.left + new_rh;
    1498                         x += adj_rh;
    1499                     }
    1500                     else {
    1501                         current->rcBand.left = 0;
    1502                         current->rcBand.right = clientcx;
    1503                         current->rcBand.top += (prev_rh + SEP_WIDTH);
    1504                         current->rcBand.bottom = current->rcBand.top + new_rh;
    1505                         y += adj_rh;
    1506                     }
    1507                     TRACE("moving band %d to own row at (%d,%d)-(%d,%d)\n",
    1508                           current_idx,
    1509                           current->rcBand.left, current->rcBand.top,
    1510                           current->rcBand.right, current->rcBand.bottom);
    1511                     TRACE("prev band %d at (%d,%d)-(%d,%d)\n",
    1512                           prev_idx,
    1513                           prev->rcBand.left, prev->rcBand.top,
    1514                           prev->rcBand.right, prev->rcBand.bottom);
    1515                     TRACE("values: prev_rh=%d, new_rh=%d, adj_rh=%d\n",
    1516                           prev_rh, new_rh, adj_rh);
    1517                     /* for bands below current adjust row # and top/bottom */
    1518                     for (j = current_idx+1; j<infoPtr->uNumBands; j++) {
    1519                         walk = &infoPtr->bands[j];
    1520                         if (HIDDENBAND(walk)) continue;
    1521                         walk->fDraw |= NTF_INVALIDATE;
    1522                         walk->iRow++;
    1523                         if (infoPtr->dwStyle & CCS_VERT) {
    1524                             walk->rcBand.left += adj_rh;
    1525                             walk->rcBand.right += adj_rh;
    1526                         }
    1527                         else {
    1528                             walk->rcBand.top += adj_rh;
    1529                             walk->rcBand.bottom += adj_rh;
    1530                         }
    1531                     }
    1532                     if ((infoPtr->dwStyle & CCS_VERT) ? (x >= adjcx) : (y >= adjcy))
    1533                         break; /* all done */
    1534                 }
    1535             }
    1536         }
     1457         ) &&
     1458        (infoPtr->uNumBands > 1)) {
     1459        for (i=(INT)infoPtr->uNumBands-2; i>=0; i--) {
     1460        TRACE("adjcx=%d, adjcy=%d, x=%d, y=%d\n",
     1461              adjcx, adjcy, x, y);
     1462
     1463        /* find the current band (starts at i+1) */
     1464        current = &infoPtr->bands[i+1];
     1465        current_idx = i+1;
     1466        while (HIDDENBAND(current)) {
     1467            i--;
     1468            if (i < 0) break; /* out of bands */
     1469            current = &infoPtr->bands[i+1];
     1470            current_idx = i+1;
     1471        }
     1472        if (i < 0) break; /* out of bands */
     1473
     1474        /* now find the prev band (starts at i) */
     1475            prev = &infoPtr->bands[i];
     1476        prev_idx = i;
     1477        while (HIDDENBAND(prev)) {
     1478            i--;
     1479            if (i < 0) break; /* out of bands */
     1480            prev = &infoPtr->bands[i];
     1481            prev_idx = i;
     1482        }
     1483        if (i < 0) break; /* out of bands */
     1484
     1485        prev_rh = ircBw(prev);
     1486        if (prev->iRow == current->iRow) {
     1487            new_rh = (infoPtr->dwStyle & RBS_VARHEIGHT) ?
     1488            current->lcy + REBARSPACE :
     1489            mmcy;
     1490            adj_rh = new_rh + SEP_WIDTH;
     1491            infoPtr->uNumRows++;
     1492            current->fDraw |= NTF_INVALIDATE;
     1493            current->iRow++;
     1494            if (infoPtr->dwStyle & CCS_VERT) {
     1495                current->rcBand.top = 0;
     1496            current->rcBand.bottom = clientcy;
     1497            current->rcBand.left += (prev_rh + SEP_WIDTH);
     1498            current->rcBand.right = current->rcBand.left + new_rh;
     1499            x += adj_rh;
     1500            }
     1501            else {
     1502                current->rcBand.left = 0;
     1503            current->rcBand.right = clientcx;
     1504            current->rcBand.top += (prev_rh + SEP_WIDTH);
     1505            current->rcBand.bottom = current->rcBand.top + new_rh;
     1506            y += adj_rh;
     1507            }
     1508            TRACE("moving band %d to own row at (%d,%d)-(%d,%d)\n",
     1509              current_idx,
     1510              current->rcBand.left, current->rcBand.top,
     1511              current->rcBand.right, current->rcBand.bottom);
     1512            TRACE("prev band %d at (%d,%d)-(%d,%d)\n",
     1513              prev_idx,
     1514              prev->rcBand.left, prev->rcBand.top,
     1515              prev->rcBand.right, prev->rcBand.bottom);
     1516            TRACE("values: prev_rh=%d, new_rh=%d, adj_rh=%d\n",
     1517              prev_rh, new_rh, adj_rh);
     1518            /* for bands below current adjust row # and top/bottom */
     1519            for (j = current_idx+1; j<infoPtr->uNumBands; j++) {
     1520                walk = &infoPtr->bands[j];
     1521            if (HIDDENBAND(walk)) continue;
     1522            walk->fDraw |= NTF_INVALIDATE;
     1523            walk->iRow++;
     1524            if (infoPtr->dwStyle & CCS_VERT) {
     1525                walk->rcBand.left += adj_rh;
     1526                walk->rcBand.right += adj_rh;
     1527            }
     1528            else {
     1529                walk->rcBand.top += adj_rh;
     1530                walk->rcBand.bottom += adj_rh;
     1531            }
     1532            }
     1533            if ((infoPtr->dwStyle & CCS_VERT) ? (x >= adjcx) : (y >= adjcy))
     1534                break; /* all done */
     1535        }
     1536        }
     1537    }
    15371538    }
    15381539
     
    15451546    /*   clientcy/clientcx     height/width of client area           */
    15461547
    1547     /* **** FIXME FIXME FIXME 
     1548    /* **** FIXME FIXME FIXME
    15481549     *   this does not take into account that more than one band
    15491550     *   is in a row!!!!!!!!!
     
    15511552
    15521553    if (((infoPtr->dwStyle & CCS_VERT) ? clientcx > x : clientcy > y) &&
    1553         infoPtr->uNumBands) {
    1554         INT diff, i, j;
    1555 
    1556         diff = (infoPtr->dwStyle & CCS_VERT) ? clientcx - x : clientcy - y;
    1557         for (i = infoPtr->uNumBands-1; i >= 0; i--) {
    1558             lpBand = &infoPtr->bands[i];
    1559             if(HIDDENBAND(lpBand)) continue;
    1560             if (!lpBand->fMask & RBBS_VARIABLEHEIGHT) continue;
    1561             if (((INT)lpBand->cyMaxChild < 1) ||
    1562                 ((INT)lpBand->cyIntegral < 1)) {
    1563                 if (lpBand->cyMaxChild + lpBand->cyIntegral == 0) continue;
    1564                 ERR("band %u RBBS_VARIABLEHEIGHT set but cyMax=%d, cyInt=%d\n",
    1565                     i, lpBand->cyMaxChild, lpBand->cyIntegral);
    1566                 continue;
    1567             }
    1568             /* j is now the maximum height/width in the client area */
    1569             j = ((diff / lpBand->cyIntegral) * lpBand->cyIntegral) +
    1570                 ircBw(lpBand);
    1571             if (j > lpBand->cyMaxChild + REBARSPACE)
    1572                 j = lpBand->cyMaxChild + REBARSPACE;
    1573             diff -= (j - ircBw(lpBand));
    1574             if (infoPtr->dwStyle & CCS_VERT)
    1575                 lpBand->rcBand.right = lpBand->rcBand.left + j;
    1576             else
    1577                 lpBand->rcBand.bottom = lpBand->rcBand.top + j;
    1578             TRACE("P2a band %d, row %d changed to (%d,%d)-(%d,%d)\n",
    1579                   i, lpBand->iRow,
    1580                   lpBand->rcBand.left, lpBand->rcBand.top,
    1581                   lpBand->rcBand.right, lpBand->rcBand.bottom);
    1582             if (diff <= 0) break;
    1583         }
    1584         if (diff < 0) {
    1585             ERR("allocated more than available, diff=%d\n", diff);
    1586             diff = 0;
    1587         }
    1588         if (infoPtr->dwStyle & CCS_VERT)
    1589             x = clientcx - diff;
    1590         else
    1591             y = clientcy - diff;
     1554    infoPtr->uNumBands) {
     1555    INT diff, i, j;
     1556
     1557    diff = (infoPtr->dwStyle & CCS_VERT) ? clientcx - x : clientcy - y;
     1558    for (i = infoPtr->uNumBands-1; i >= 0; i--) {
     1559        lpBand = &infoPtr->bands[i];
     1560        if(HIDDENBAND(lpBand)) continue;
     1561        if (!lpBand->fMask & RBBS_VARIABLEHEIGHT) continue;
     1562        if (((INT)lpBand->cyMaxChild < 1) ||
     1563        ((INT)lpBand->cyIntegral < 1)) {
     1564        if (lpBand->cyMaxChild + lpBand->cyIntegral == 0) continue;
     1565        ERR("band %u RBBS_VARIABLEHEIGHT set but cyMax=%d, cyInt=%d\n",
     1566            i, lpBand->cyMaxChild, lpBand->cyIntegral);
     1567        continue;
     1568        }
     1569        /* j is now the maximum height/width in the client area */
     1570        j = ((diff / lpBand->cyIntegral) * lpBand->cyIntegral) +
     1571        ircBw(lpBand);
     1572        if (j > lpBand->cyMaxChild + REBARSPACE)
     1573        j = lpBand->cyMaxChild + REBARSPACE;
     1574        diff -= (j - ircBw(lpBand));
     1575        if (infoPtr->dwStyle & CCS_VERT)
     1576        lpBand->rcBand.right = lpBand->rcBand.left + j;
     1577        else
     1578        lpBand->rcBand.bottom = lpBand->rcBand.top + j;
     1579        TRACE("P2a band %d, row %d changed to (%d,%d)-(%d,%d)\n",
     1580          i, lpBand->iRow,
     1581          lpBand->rcBand.left, lpBand->rcBand.top,
     1582          lpBand->rcBand.right, lpBand->rcBand.bottom);
     1583        if (diff <= 0) break;
     1584    }
     1585    if (diff < 0) {
     1586        ERR("allocated more than available, diff=%d\n", diff);
     1587        diff = 0;
     1588    }
     1589    if (infoPtr->dwStyle & CCS_VERT)
     1590        x = clientcx - diff;
     1591    else
     1592        y = clientcy - diff;
    15921593    }
    15931594
     
    15981599
    15991600    if (infoPtr->uNumBands) {
    1600         INT bandnum, bandnum_start, bandnum_end;
    1601 
    1602         /* If RBS_BANDBORDERS set then indicate to draw bottom separator */
    1603         /* on all bands in all rows but last row.                        */
    1604         /* Also indicate to draw the right separator for each band in    */
    1605         /* each row but the rightmost band.                              */
    1606         if (infoPtr->dwStyle & RBS_BANDBORDERS) {
    1607             REBAR_BAND *prevband;
    1608             INT currow;
    1609 
    1610             prevband = NULL;
    1611             currow = -1;
    1612             for (i = 0; i < infoPtr->uNumBands; i++) {
    1613                 lpBand = &infoPtr->bands[i];
    1614                 if (HIDDENBAND(lpBand)) continue;
    1615 
    1616                 if (lpBand->iRow < infoPtr->uNumRows)
    1617                     lpBand->fDraw |= DRAW_BOTTOMSEP;
    1618 
    1619                 if (lpBand->iRow != currow) prevband = NULL;
    1620                 currow = lpBand->iRow;
    1621                 if (prevband) prevband->fDraw |= DRAW_RIGHTSEP;
    1622                 prevband = lpBand;
    1623             }
    1624         }
    1625 
    1626         /* Distribute the extra space on the horizontal and adjust  */
    1627         /* all bands in row to same height.                         */
    1628         bandnum = 0;
    1629         for (i=1; i<=infoPtr->uNumRows; i++) {
    1630             bandnum_start = -1;
    1631             bandnum_end = -1;
    1632             mcy = 0;
    1633             TRACE("processing row %d, starting band %d\n", i, bandnum);
    1634             while (TRUE) {
    1635                 lpBand = &infoPtr->bands[bandnum];
    1636                 if ((bandnum >= infoPtr->uNumBands) ||
    1637                     ((lpBand->iRow != i) &&
    1638                      !HIDDENBAND(lpBand))) {
    1639                     if ((bandnum_start == -1) ||
    1640                         (bandnum_end == -1)) {
    1641                         ERR("logic error? bands=%d, rows=%d, start=%d, end=%d\n",
    1642                             infoPtr->uNumBands, infoPtr->uNumRows,
    1643                             (INT)bandnum_start, (INT)bandnum_end);
    1644                         ERR("  current row=%d, band=%d\n",
    1645                             i, bandnum);
    1646                         break;
    1647                     }
    1648                     REBAR_AdjustBands (infoPtr, bandnum_start, bandnum_end,
    1649                                        (infoPtr->dwStyle & CCS_VERT) ?
    1650                                        clientcy : clientcx, mcy);
    1651                     break;
    1652                 }
    1653                 if (!HIDDENBAND(lpBand)) {
    1654                     if (bandnum_start == -1) bandnum_start = bandnum;
    1655                     if (bandnum_end < bandnum) bandnum_end = bandnum;
    1656                     if (mcy < ircBw(lpBand))
    1657                         mcy = ircBw(lpBand);
    1658                 }
    1659                 bandnum++;
    1660                 TRACE("point 1, bandnum=%d\n", bandnum);
    1661             }
    1662             TRACE("point 2, i=%d, numrows=%d, bandnum=%d\n",
    1663                   i, infoPtr->uNumRows, bandnum);
    1664         }
    1665         TRACE("point 3\n");
    1666 
    1667         /* Calculate the other rectangles in each band */
    1668         if (infoPtr->dwStyle & CCS_VERT) {
    1669             REBAR_CalcVertBand (infoPtr, 0, infoPtr->uNumBands,
    1670                                 notify);
    1671         }
    1672         else {
    1673             REBAR_CalcHorzBand (infoPtr, 0, infoPtr->uNumBands,
    1674                                 notify);
    1675         }
     1601    INT bandnum, bandnum_start, bandnum_end;
     1602
     1603    /* If RBS_BANDBORDERS set then indicate to draw bottom separator */
     1604    /* on all bands in all rows but last row.                        */
     1605    /* Also indicate to draw the right separator for each band in    */
     1606    /* each row but the rightmost band.                              */
     1607    if (infoPtr->dwStyle & RBS_BANDBORDERS) {
     1608        REBAR_BAND *prevband;
     1609        INT currow;
     1610
     1611        prevband = NULL;
     1612        currow = -1;
     1613        for (i = 0; i < infoPtr->uNumBands; i++) {
     1614            lpBand = &infoPtr->bands[i];
     1615        if (HIDDENBAND(lpBand)) continue;
     1616
     1617        if (lpBand->iRow < infoPtr->uNumRows)
     1618            lpBand->fDraw |= DRAW_BOTTOMSEP;
     1619
     1620        if (lpBand->iRow != currow) prevband = NULL;
     1621        currow = lpBand->iRow;
     1622        if (prevband) prevband->fDraw |= DRAW_RIGHTSEP;
     1623        prevband = lpBand;
     1624        }
     1625    }
     1626
     1627    /* Distribute the extra space on the horizontal and adjust  */
     1628    /* all bands in row to same height.                         */
     1629    bandnum = 0;
     1630    for (i=1; i<=infoPtr->uNumRows; i++) {
     1631        bandnum_start = -1;
     1632        bandnum_end = -1;
     1633        mcy = 0;
     1634        TRACE("processing row %d, starting band %d\n", i, bandnum);
     1635        while (TRUE) {
     1636        lpBand = &infoPtr->bands[bandnum];
     1637        if ((bandnum >= infoPtr->uNumBands) ||
     1638            ((lpBand->iRow != i) &&
     1639             !HIDDENBAND(lpBand))) {
     1640            if ((bandnum_start == -1) ||
     1641            (bandnum_end == -1)) {
     1642            ERR("logic error? bands=%d, rows=%d, start=%d, end=%d\n",
     1643                infoPtr->uNumBands, infoPtr->uNumRows,
     1644                (INT)bandnum_start, (INT)bandnum_end);
     1645            ERR("  current row=%d, band=%d\n",
     1646                i, bandnum);
     1647            break;
     1648            }
     1649            REBAR_AdjustBands (infoPtr, bandnum_start, bandnum_end,
     1650                       (infoPtr->dwStyle & CCS_VERT) ?
     1651                       clientcy : clientcx, mcy);
     1652            break;
     1653        }
     1654        if (!HIDDENBAND(lpBand)) {
     1655            if (bandnum_start == -1) bandnum_start = bandnum;
     1656            if (bandnum_end < bandnum) bandnum_end = bandnum;
     1657            if (mcy < ircBw(lpBand))
     1658            mcy = ircBw(lpBand);
     1659        }
     1660        bandnum++;
     1661        TRACE("point 1, bandnum=%d\n", bandnum);
     1662        }
     1663        TRACE("point 2, i=%d, numrows=%d, bandnum=%d\n",
     1664          i, infoPtr->uNumRows, bandnum);
     1665    }
     1666    TRACE("point 3\n");
     1667
     1668    /* Calculate the other rectangles in each band */
     1669    if (infoPtr->dwStyle & CCS_VERT) {
     1670        REBAR_CalcVertBand (infoPtr, 0, infoPtr->uNumBands,
     1671                notify);
     1672    }
     1673    else {
     1674        REBAR_CalcHorzBand (infoPtr, 0, infoPtr->uNumBands,
     1675                notify);
     1676    }
    16761677    }
    16771678
     
    16811682    infoPtr->oldSize = infoPtr->calcSize;
    16821683    if (infoPtr->dwStyle & CCS_VERT) {
    1683         infoPtr->calcSize.cx = x;
    1684         infoPtr->calcSize.cy = clientcy;
    1685         TRACE("vert, notify=%d, x=%d, origheight=%d\n",
    1686               notify, x, origheight);
    1687         if (notify && (x != origheight)) infoPtr->fStatus |= NTF_HGHTCHG;
     1684    infoPtr->calcSize.cx = x;
     1685    infoPtr->calcSize.cy = clientcy;
     1686    TRACE("vert, notify=%d, x=%d, origheight=%d\n",
     1687          notify, x, origheight);
     1688    if (notify && (x != origheight)) infoPtr->fStatus |= NTF_HGHTCHG;
    16881689    }
    16891690    else {
    1690         infoPtr->calcSize.cx = clientcx;
    1691         infoPtr->calcSize.cy = y;
    1692         TRACE("horz, notify=%d, y=%d, origheight=%d\n",
    1693               notify, y, origheight);
    1694         if (notify && (y != origheight)) infoPtr->fStatus |= NTF_HGHTCHG;
     1691    infoPtr->calcSize.cx = clientcx;
     1692    infoPtr->calcSize.cy = y;
     1693    TRACE("horz, notify=%d, y=%d, origheight=%d\n",
     1694          notify, y, origheight);
     1695    if (notify && (y != origheight)) infoPtr->fStatus |= NTF_HGHTCHG;
    16951696    }
    16961697
     
    17491750    /* calculate gripper rectangle */
    17501751    if (  (!(lpBand->fStyle & RBBS_NOGRIPPER)) &&
    1751           ( (lpBand->fStyle & RBBS_GRIPPERALWAYS) ||
    1752             ( !(lpBand->fStyle & RBBS_FIXEDSIZE) && (infoPtr->uNumBands > 1)))
     1752      ( (lpBand->fStyle & RBBS_GRIPPERALWAYS) ||
     1753        ( !(lpBand->fStyle & RBBS_FIXEDSIZE) && (infoPtr->uNumBands > 1)))
    17531754       ) {
    1754         lpBand->fStatus |= HAS_GRIPPER;
     1755    lpBand->fStatus |= HAS_GRIPPER;
    17551756        if (infoPtr->dwStyle & CCS_VERT)
    1756             if (infoPtr->dwStyle & RBS_VERTICALGRIPPER)
     1757        if (infoPtr->dwStyle & RBS_VERTICALGRIPPER)
    17571758                header += (GRIPPER_HEIGHT + REBAR_PRE_GRIPPER);
    17581759            else
    1759                 header += (GRIPPER_WIDTH + REBAR_PRE_GRIPPER);
     1760            header += (GRIPPER_WIDTH + REBAR_PRE_GRIPPER);
    17601761        else
    17611762            header += (REBAR_PRE_GRIPPER + GRIPPER_WIDTH);
     
    17661767    /* image is visible */
    17671768    if ((lpBand->fMask & RBBIM_IMAGE) && (infoPtr->himl)) {
    1768         lpBand->fStatus |= HAS_IMAGE;
     1769    lpBand->fStatus |= HAS_IMAGE;
    17691770        if (infoPtr->dwStyle & CCS_VERT) {
    1770            header += (infoPtr->imageSize.cy + REBAR_POST_IMAGE);
    1771            lpBand->lcy = infoPtr->imageSize.cx + 2;
    1772         }
    1773         else {
    1774            header += (infoPtr->imageSize.cx + REBAR_POST_IMAGE);
    1775            lpBand->lcy = infoPtr->imageSize.cy + 2;
    1776         }
     1771       header += (infoPtr->imageSize.cy + REBAR_POST_IMAGE);
     1772       lpBand->lcy = infoPtr->imageSize.cx + 2;
     1773    }
     1774    else {
     1775       header += (infoPtr->imageSize.cx + REBAR_POST_IMAGE);
     1776       lpBand->lcy = infoPtr->imageSize.cy + 2;
     1777    }
    17771778    }
    17781779
    17791780    /* text is visible */
    17801781    if ((lpBand->fMask & RBBIM_TEXT) && (lpBand->lpText)) {
    1781         HDC hdc = GetDC (0);
    1782         HFONT hOldFont = SelectObject (hdc, infoPtr->hFont);
    1783         SIZE size;
    1784 
    1785         lpBand->fStatus |= HAS_TEXT;
    1786         GetTextExtentPoint32W (hdc, lpBand->lpText,
    1787                                lstrlenW (lpBand->lpText), &size);
    1788         header += ((infoPtr->dwStyle & CCS_VERT) ? (size.cy + REBAR_POST_TEXT) : (size.cx + REBAR_POST_TEXT));
    1789         textheight = (infoPtr->dwStyle & CCS_VERT) ? 0 : size.cy;
    1790 
    1791         SelectObject (hdc, hOldFont);
    1792         ReleaseDC (0, hdc);
     1782    HDC hdc = GetDC (0);
     1783    HFONT hOldFont = SelectObject (hdc, infoPtr->hFont);
     1784    SIZE size;
     1785
     1786    lpBand->fStatus |= HAS_TEXT;
     1787    GetTextExtentPoint32W (hdc, lpBand->lpText,
     1788                   lstrlenW (lpBand->lpText), &size);
     1789    header += ((infoPtr->dwStyle & CCS_VERT) ? (size.cy + REBAR_POST_TEXT) : (size.cx + REBAR_POST_TEXT));
     1790    textheight = (infoPtr->dwStyle & CCS_VERT) ? 0 : size.cy;
     1791
     1792    SelectObject (hdc, hOldFont);
     1793    ReleaseDC (0, hdc);
    17931794    }
    17941795
    17951796    /* if no gripper but either image or text, then leave space */
    17961797    if ((lpBand->fStatus & (HAS_IMAGE | HAS_TEXT)) &&
    1797         !(lpBand->fStatus & HAS_GRIPPER)) {
    1798         header += REBAR_ALWAYS_SPACE;
     1798    !(lpBand->fStatus & HAS_GRIPPER)) {
     1799    header += REBAR_ALWAYS_SPACE;
    17991800    }
    18001801
     
    18101811    lpBand->ccy = lpBand->lcy;
    18111812    if (lpBand->fMask & RBBIM_CHILDSIZE) {
    1812         if (!(lpBand->fStyle & RBBS_FIXEDSIZE)) {
    1813             lpBand->offChild.cx = 4;
    1814             lpBand->offChild.cy = 2;
     1813    if (!(lpBand->fStyle & RBBS_FIXEDSIZE)) {
     1814        lpBand->offChild.cx = 4;
     1815        lpBand->offChild.cy = 2;
    18151816        }
    18161817        lpBand->lcx = lpBand->cxMinChild;
    18171818
    1818         /* Set the .cy values for CHILDSIZE case */
     1819    /* Set the .cy values for CHILDSIZE case */
    18191820        lpBand->lcy = max(lpBand->lcy, lpBand->cyMinChild);
    1820         lpBand->ccy = lpBand->lcy;
     1821    lpBand->ccy = lpBand->lcy;
    18211822        lpBand->hcy = lpBand->lcy;
    18221823        if (lpBand->cyMaxChild != 0xffffffff) {
    1823             lpBand->hcy = lpBand->cyMaxChild;
    1824         }
    1825         if (lpBand->cyChild != 0xffffffff)
    1826             lpBand->ccy = max (lpBand->cyChild, lpBand->lcy);
     1824        lpBand->hcy = lpBand->cyMaxChild;
     1825        }
     1826    if (lpBand->cyChild != 0xffffffff)
     1827        lpBand->ccy = max (lpBand->cyChild, lpBand->lcy);
    18271828
    18281829        TRACE("_CHILDSIZE\n");
     
    18511852
    18521853    if (lprbbi->fMask & RBBIM_STYLE)
    1853         lpBand->fStyle = lprbbi->fStyle;
     1854    lpBand->fStyle = lprbbi->fStyle;
    18541855
    18551856    if (lprbbi->fMask & RBBIM_COLORS) {
    1856         lpBand->clrFore = lprbbi->clrFore;
    1857         lpBand->clrBack = lprbbi->clrBack;
     1857    lpBand->clrFore = lprbbi->clrFore;
     1858    lpBand->clrBack = lprbbi->clrBack;
    18581859    }
    18591860
    18601861    if (lprbbi->fMask & RBBIM_IMAGE)
    1861         lpBand->iImage = lprbbi->iImage;
     1862    lpBand->iImage = lprbbi->iImage;
    18621863
    18631864    if (lprbbi->fMask & RBBIM_CHILD) {
    1864         if (lprbbi->hwndChild) {
    1865             lpBand->hwndChild = lprbbi->hwndChild;
    1866             lpBand->hwndPrevParent =
    1867                 SetParent (lpBand->hwndChild, hwnd);
    1868             /* below in trace fro WinRAR */
    1869             ShowWindow(lpBand->hwndChild, SW_SHOWNOACTIVATE | SW_SHOWNORMAL);
    1870             /* above in trace fro WinRAR */
    1871         }
    1872         else {
    1873             TRACE("child: 0x%x  prev parent: 0x%x\n",
    1874                    lpBand->hwndChild, lpBand->hwndPrevParent);
    1875             lpBand->hwndChild = 0;
    1876             lpBand->hwndPrevParent = 0;
    1877         }
     1865    if (lprbbi->hwndChild) {
     1866        lpBand->hwndChild = lprbbi->hwndChild;
     1867        lpBand->hwndPrevParent =
     1868        SetParent (lpBand->hwndChild, hwnd);
     1869        /* below in trace fro WinRAR */
     1870        ShowWindow(lpBand->hwndChild, SW_SHOWNOACTIVATE | SW_SHOWNORMAL);
     1871        /* above in trace fro WinRAR */
     1872    }
     1873    else {
     1874        TRACE("child: 0x%x  prev parent: 0x%x\n",
     1875           lpBand->hwndChild, lpBand->hwndPrevParent);
     1876        lpBand->hwndChild = 0;
     1877        lpBand->hwndPrevParent = 0;
     1878    }
    18781879    }
    18791880
    18801881    if (lprbbi->fMask & RBBIM_CHILDSIZE) {
    1881         lpBand->cxMinChild = lprbbi->cxMinChild;
    1882         lpBand->cyMinChild = lprbbi->cyMinChild;
    1883         if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
    1884             lpBand->cyChild    = lprbbi->cyChild;
    1885             lpBand->cyMaxChild = lprbbi->cyMaxChild;
    1886             lpBand->cyIntegral = lprbbi->cyIntegral;
    1887         }
    1888         else { /* special case - these should be zeroed out since   */
    1889                /* RBBIM_CHILDSIZE added these in WIN32_IE >= 0x0400 */
    1890             lpBand->cyChild    = 0;
    1891             lpBand->cyMaxChild = 0;
    1892             lpBand->cyIntegral = 0;
    1893         }
     1882    lpBand->cxMinChild = lprbbi->cxMinChild;
     1883    lpBand->cyMinChild = lprbbi->cyMinChild;
     1884    if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
     1885        lpBand->cyChild    = lprbbi->cyChild;
     1886        lpBand->cyMaxChild = lprbbi->cyMaxChild;
     1887        lpBand->cyIntegral = lprbbi->cyIntegral;
     1888    }
     1889    else { /* special case - these should be zeroed out since   */
     1890           /* RBBIM_CHILDSIZE added these in WIN32_IE >= 0x0400 */
     1891        lpBand->cyChild    = 0;
     1892        lpBand->cyMaxChild = 0;
     1893        lpBand->cyIntegral = 0;
     1894    }
    18941895    }
    18951896
    18961897    if (lprbbi->fMask & RBBIM_SIZE)
    1897         lpBand->cx = lprbbi->cx;
     1898    lpBand->cx = lprbbi->cx;
    18981899
    18991900    if (lprbbi->fMask & RBBIM_BACKGROUND)
    1900         lpBand->hbmBack = lprbbi->hbmBack;
     1901    lpBand->hbmBack = lprbbi->hbmBack;
    19011902
    19021903    if (lprbbi->fMask & RBBIM_ID)
    1903         lpBand->wID = lprbbi->wID;
     1904    lpBand->wID = lprbbi->wID;
    19041905
    19051906    /* check for additional data */
    19061907    if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
    1907         if (lprbbi->fMask & RBBIM_IDEALSIZE)
    1908             lpBand->cxIdeal = lprbbi->cxIdeal;
    1909 
    1910         if (lprbbi->fMask & RBBIM_LPARAM)
    1911             lpBand->lParam = lprbbi->lParam;
    1912 
    1913         if (lprbbi->fMask & RBBIM_HEADERSIZE)
    1914             lpBand->cxHeader = lprbbi->cxHeader;
     1908    if (lprbbi->fMask & RBBIM_IDEALSIZE)
     1909        lpBand->cxIdeal = lprbbi->cxIdeal;
     1910
     1911    if (lprbbi->fMask & RBBIM_LPARAM)
     1912        lpBand->lParam = lprbbi->lParam;
     1913
     1914    if (lprbbi->fMask & RBBIM_HEADERSIZE)
     1915        lpBand->cxHeader = lprbbi->cxHeader;
    19151916    }
    19161917}
     
    19321933    for(i=0; i<infoPtr->uNumBands; i++) {
    19331934        lpBand = &infoPtr->bands[i];
    1934         if (HIDDENBAND(lpBand)) continue;
    1935 
    1936         /* draw band separator between rows */
    1937         if (lpBand->iRow != oldrow) {
    1938             oldrow = lpBand->iRow;
    1939             if (lpBand->fDraw & DRAW_BOTTOMSEP) {
    1940                 RECT rcRowSep;
    1941                 rcRowSep = lpBand->rcBand;
    1942                 if (infoPtr->dwStyle & CCS_VERT) {
    1943                     rcRowSep.right += SEP_WIDTH_SIZE;
    1944                     rcRowSep.bottom = infoPtr->calcSize.cy;
    1945                     DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_RIGHT);
    1946                 }
    1947                 else {
    1948                     rcRowSep.bottom += SEP_WIDTH_SIZE;
    1949                     rcRowSep.right = infoPtr->calcSize.cx;
    1950                     DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_BOTTOM);
    1951                 }
    1952                 TRACE ("drawing band separator bottom (%d,%d)-(%d,%d)\n",
    1953                        rcRowSep.left, rcRowSep.top,
    1954                        rcRowSep.right, rcRowSep.bottom);
    1955             }
    1956         }
    1957 
    1958         /* draw band separator between bands in a row */
    1959         if (lpBand->fDraw & DRAW_RIGHTSEP) {
    1960             RECT rcSep;
    1961             rcSep = lpBand->rcBand;
    1962             if (infoPtr->dwStyle & CCS_VERT) {
    1963                 rcSep.bottom += SEP_WIDTH_SIZE;
    1964                 DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_BOTTOM);
    1965             }
    1966             else {
    1967                 rcSep.right += SEP_WIDTH_SIZE;
    1968                 DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_RIGHT);
    1969             }
    1970             TRACE("drawing band separator right (%d,%d)-(%d,%d)\n",
    1971                   rcSep.left, rcSep.top, rcSep.right, rcSep.bottom);
    1972         }
    1973 
    1974         /* draw the actual background */
    1975         if (lpBand->clrBack != CLR_NONE)
    1976             new = lpBand->clrBack;
    1977         else
    1978             new = infoPtr->clrBtnFace;
    1979         rect = lpBand->rcBand;
    1980         old = SetBkColor (hdc, new);
    1981         TRACE("%s backround color=0x%06lx, band (%d,%d)-(%d,%d), clip (%d,%d)-(%d,%d)\n",
    1982               (lpBand->clrBack == CLR_NONE) ? "std" : "",
    1983               new,
    1984               lpBand->rcBand.left,lpBand->rcBand.top,
    1985               lpBand->rcBand.right,lpBand->rcBand.bottom,
    1986               clip->left, clip->top,
    1987               clip->right, clip->bottom);
    1988         ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, 0);
    1989         SetBkColor (hdc, old);
     1935    if (HIDDENBAND(lpBand)) continue;
     1936
     1937    /* draw band separator between rows */
     1938    if (lpBand->iRow != oldrow) {
     1939        oldrow = lpBand->iRow;
     1940        if (lpBand->fDraw & DRAW_BOTTOMSEP) {
     1941        RECT rcRowSep;
     1942        rcRowSep = lpBand->rcBand;
     1943        if (infoPtr->dwStyle & CCS_VERT) {
     1944            rcRowSep.right += SEP_WIDTH_SIZE;
     1945            rcRowSep.bottom = infoPtr->calcSize.cy;
     1946            DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_RIGHT);
     1947        }
     1948        else {
     1949            rcRowSep.bottom += SEP_WIDTH_SIZE;
     1950            rcRowSep.right = infoPtr->calcSize.cx;
     1951            DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_BOTTOM);
     1952        }
     1953        TRACE ("drawing band separator bottom (%d,%d)-(%d,%d)\n",
     1954               rcRowSep.left, rcRowSep.top,
     1955               rcRowSep.right, rcRowSep.bottom);
     1956        }
     1957    }
     1958
     1959    /* draw band separator between bands in a row */
     1960    if (lpBand->fDraw & DRAW_RIGHTSEP) {
     1961        RECT rcSep;
     1962        rcSep = lpBand->rcBand;
     1963        if (infoPtr->dwStyle & CCS_VERT) {
     1964        rcSep.bottom += SEP_WIDTH_SIZE;
     1965        DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_BOTTOM);
     1966        }
     1967        else {
     1968        rcSep.right += SEP_WIDTH_SIZE;
     1969        DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_RIGHT);
     1970        }
     1971        TRACE("drawing band separator right (%d,%d)-(%d,%d)\n",
     1972          rcSep.left, rcSep.top, rcSep.right, rcSep.bottom);
     1973    }
     1974
     1975    /* draw the actual background */
     1976    if (lpBand->clrBack != CLR_NONE)
     1977        new = lpBand->clrBack;
     1978    else
     1979        new = infoPtr->clrBtnFace;
     1980    rect = lpBand->rcBand;
     1981    old = SetBkColor (hdc, new);
     1982    TRACE("%s backround color=0x%06lx, band (%d,%d)-(%d,%d), clip (%d,%d)-(%d,%d)\n",
     1983          (lpBand->clrBack == CLR_NONE) ? "std" : "",
     1984          new,
     1985          lpBand->rcBand.left,lpBand->rcBand.top,
     1986          lpBand->rcBand.right,lpBand->rcBand.bottom,
     1987          clip->left, clip->top,
     1988          clip->right, clip->bottom);
     1989    ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, 0);
     1990    SetBkColor (hdc, old);
    19901991    }
    19911992    return TRUE;
     
    20042005    if (PtInRect (&rect, *lpPt))
    20052006    {
    2006         if (infoPtr->uNumBands == 0) {
    2007             *pFlags = RBHT_NOWHERE;
    2008             if (pBand)
    2009                 *pBand = -1;
    2010             TRACE("NOWHERE\n");
    2011             return;
    2012         }
    2013         else {
    2014             /* somewhere inside */
    2015             infoPtr->ihitBand = -1;
    2016             for (iCount = 0; iCount < infoPtr->uNumBands; iCount++) {
    2017                 lpBand = &infoPtr->bands[iCount];
    2018                 if (HIDDENBAND(lpBand)) continue;
    2019                 if (PtInRect (&lpBand->rcBand, *lpPt)) {
    2020                     if (pBand)
    2021                         *pBand = iCount;
    2022                     if (PtInRect (&lpBand->rcGripper, *lpPt)) {
    2023                         *pFlags = RBHT_GRABBER;
    2024                         infoPtr->ihitBand = iCount;
    2025                         TRACE("ON GRABBER %d\n", iCount);
    2026                         return;
    2027                     }
    2028                     else if (PtInRect (&lpBand->rcCapImage, *lpPt)) {
    2029                         *pFlags = RBHT_CAPTION;
    2030                         TRACE("ON CAPTION %d\n", iCount);
    2031                         return;
    2032                     }
    2033                     else if (PtInRect (&lpBand->rcCapText, *lpPt)) {
    2034                         *pFlags = RBHT_CAPTION;
    2035                         TRACE("ON CAPTION %d\n", iCount);
    2036                         return;
    2037                     }
    2038                     else if (PtInRect (&lpBand->rcChild, *lpPt)) {
    2039                         *pFlags = RBHT_CLIENT;
    2040                         TRACE("ON CLIENT %d\n", iCount);
    2041                         return;
    2042                     }
    2043                     else {
    2044                         *pFlags = RBHT_NOWHERE;
    2045                         TRACE("NOWHERE %d\n", iCount);
    2046                         return;
    2047                     }
    2048                 }
    2049             }
    2050 
    2051             *pFlags = RBHT_NOWHERE;
    2052             if (pBand)
    2053                 *pBand = -1;
    2054 
    2055             TRACE("NOWHERE\n");
    2056             return;
    2057         }
     2007    if (infoPtr->uNumBands == 0) {
     2008        *pFlags = RBHT_NOWHERE;
     2009        if (pBand)
     2010        *pBand = -1;
     2011        TRACE("NOWHERE\n");
     2012        return;
    20582013    }
    20592014    else {
    2060         *pFlags = RBHT_NOWHERE;
    2061         if (pBand)
    2062             *pBand = -1;
    2063         TRACE("NOWHERE\n");
    2064         return;
     2015        /* somewhere inside */
     2016        infoPtr->ihitBand = -1;
     2017        for (iCount = 0; iCount < infoPtr->uNumBands; iCount++) {
     2018        lpBand = &infoPtr->bands[iCount];
     2019        if (HIDDENBAND(lpBand)) continue;
     2020        if (PtInRect (&lpBand->rcBand, *lpPt)) {
     2021            if (pBand)
     2022            *pBand = iCount;
     2023            if (PtInRect (&lpBand->rcGripper, *lpPt)) {
     2024            *pFlags = RBHT_GRABBER;
     2025            infoPtr->ihitBand = iCount;
     2026            TRACE("ON GRABBER %d\n", iCount);
     2027            return;
     2028            }
     2029            else if (PtInRect (&lpBand->rcCapImage, *lpPt)) {
     2030            *pFlags = RBHT_CAPTION;
     2031            TRACE("ON CAPTION %d\n", iCount);
     2032            return;
     2033            }
     2034            else if (PtInRect (&lpBand->rcCapText, *lpPt)) {
     2035            *pFlags = RBHT_CAPTION;
     2036            TRACE("ON CAPTION %d\n", iCount);
     2037            return;
     2038            }
     2039            else if (PtInRect (&lpBand->rcChild, *lpPt)) {
     2040            *pFlags = RBHT_CLIENT;
     2041            TRACE("ON CLIENT %d\n", iCount);
     2042            return;
     2043            }
     2044            else {
     2045            *pFlags = RBHT_NOWHERE;
     2046            TRACE("NOWHERE %d\n", iCount);
     2047            return;
     2048            }
     2049        }
     2050        }
     2051
     2052        *pFlags = RBHT_NOWHERE;
     2053        if (pBand)
     2054        *pBand = -1;
     2055
     2056        TRACE("NOWHERE\n");
     2057        return;
     2058    }
     2059    }
     2060    else {
     2061    *pFlags = RBHT_NOWHERE;
     2062    if (pBand)
     2063        *pBand = -1;
     2064    TRACE("NOWHERE\n");
     2065    return;
    20652066    }
    20662067
     
    20912092        /* if this band is not shrinkable, then just move it */
    20922093        Leadjust = Readjust = movement;
    2093         ret = movement;
     2094    ret = movement;
    20942095    }
    20952096    else {
    20962097        if (movement < 0) {
    2097             /* Drag to left */
    2098             if (avail <= abs(movement)) {
    2099                 Readjust = movement;
    2100                 Leadjust = movement + avail;
    2101                 ret = Leadjust;
    2102             }
    2103             else {
    2104                 Readjust = movement;
    2105                 Leadjust = 0;
    2106                 ret = 0;
    2107             }
    2108         }
    2109         else {
    2110             /* Drag to right */
    2111             if (avail <= abs(movement)) {
    2112                 Leadjust = movement;
    2113                 Readjust = movement - avail;
    2114                 ret = Readjust;
    2115             }
    2116             else {
    2117                 Leadjust = movement;
    2118                 Readjust = 0;
    2119                 ret = 0;
    2120             }
    2121         }
     2098        /* Drag to left */
     2099        if (avail <= abs(movement)) {
     2100            Readjust = movement;
     2101        Leadjust = movement + avail;
     2102        ret = Leadjust;
     2103        }
     2104        else {
     2105            Readjust = movement;
     2106        Leadjust = 0;
     2107        ret = 0;
     2108        }
     2109    }
     2110    else {
     2111        /* Drag to right */
     2112        if (avail <= abs(movement)) {
     2113            Leadjust = movement;
     2114        Readjust = movement - avail;
     2115        ret = Readjust;
     2116        }
     2117        else {
     2118            Leadjust = movement;
     2119        Readjust = 0;
     2120        ret = 0;
     2121        }
     2122    }
    21222123    }
    21232124
     
    21252126    if (rcBlt(band) + Leadjust < 0) {
    21262127        ERR("adjustment will fail, band %d: left=%d, right=%d, move=%d, rtn=%d\n",
    2127             i, Leadjust, Readjust, movement, ret);
     2128        i, Leadjust, Readjust, movement, ret);
    21282129    }
    21292130
     
    21322133
    21332134    TRACE("band %d:  left=%d, right=%d, move=%d, rtn=%d, rcBand=(%d,%d)-(%d,%d)\n",
    2134           i, Leadjust, Readjust, movement, ret,
    2135           band->rcBand.left, band->rcBand.top,
    2136           band->rcBand.right, band->rcBand.bottom);
     2135      i, Leadjust, Readjust, movement, ret,
     2136      band->rcBand.left, band->rcBand.top,
     2137      band->rcBand.right, band->rcBand.bottom);
    21372138    return ret;
    21382139}
     
    21572158
    21582159    if (!(infoPtr->fStatus & BEGIN_DRAG_ISSUED)) {
    2159         if (REBAR_Notify_NMREBAR (infoPtr, -1, RBN_BEGINDRAG)) {
    2160             /* Notify returned TRUE - abort drag */
    2161             infoPtr->dragStart.x = 0;
    2162             infoPtr->dragStart.y = 0;
    2163             infoPtr->dragNow = infoPtr->dragStart;
    2164             infoPtr->ihitBand = -1;
    2165             ReleaseCapture ();
    2166             return ;
    2167         }
    2168         infoPtr->fStatus |= BEGIN_DRAG_ISSUED;
     2160    if (REBAR_Notify_NMREBAR (infoPtr, -1, RBN_BEGINDRAG)) {
     2161        /* Notify returned TRUE - abort drag */
     2162        infoPtr->dragStart.x = 0;
     2163        infoPtr->dragStart.y = 0;
     2164        infoPtr->dragNow = infoPtr->dragStart;
     2165        infoPtr->ihitBand = -1;
     2166        ReleaseCapture ();
     2167        return ;
     2168    }
     2169    infoPtr->fStatus |= BEGIN_DRAG_ISSUED;
    21692170    }
    21702171
     
    21762177    for (i=0; i<infoPtr->uNumBands; i++) {
    21772178        band = &infoPtr->bands[i];
    2178         if (HIDDENBAND(band)) continue;
    2179         if (band->iRow == hitBand->iRow) {
    2180             imaxdBand = i;
    2181             if (imindBand == -1) imindBand = i;
    2182             /* minimum size of each band is size of header plus            */
    2183             /* size of minimum child plus offset of child from header plus */
    2184             /* a one to separate each band.                                */
    2185             if (i < ihitBand)
    2186                 LHeaderSum += (band->lcx + SEP_WIDTH);
    2187             else
    2188                 RHeaderSum += (band->lcx + SEP_WIDTH);
    2189 
    2190         }
     2179    if (HIDDENBAND(band)) continue;
     2180    if (band->iRow == hitBand->iRow) {
     2181        imaxdBand = i;
     2182        if (imindBand == -1) imindBand = i;
     2183        /* minimum size of each band is size of header plus            */
     2184        /* size of minimum child plus offset of child from header plus */
     2185        /* a one to separate each band.                                */
     2186        if (i < ihitBand)
     2187            LHeaderSum += (band->lcx + SEP_WIDTH);
     2188        else
     2189            RHeaderSum += (band->lcx + SEP_WIDTH);
     2190
     2191    }
    21912192    }
    21922193    if (RHeaderSum) RHeaderSum -= SEP_WIDTH; /* no separator afterlast band */
     
    22002201    /* limit movement to inside adjustable bands - Left */
    22012202    if ( (ptsmove->x < mindBand->rcBand.left) ||
    2202         (ptsmove->x > maxdBand->rcBand.right) ||
    2203         (ptsmove->y < mindBand->rcBand.top) ||
    2204         (ptsmove->y > maxdBand->rcBand.bottom))
     2203    (ptsmove->x > maxdBand->rcBand.right) ||
     2204    (ptsmove->y < mindBand->rcBand.top) ||
     2205    (ptsmove->y > maxdBand->rcBand.bottom))
    22052206        return; /* should swap bands */
    22062207
    22072208    if (infoPtr->dwStyle & CCS_VERT)
    22082209        movement = ptsmove->y - ((hitBand->rcBand.top+REBAR_PRE_GRIPPER) -
    2209                              infoPtr->ihitoffset);
     2210                 infoPtr->ihitoffset);
    22102211    else
    22112212        movement = ptsmove->x - ((hitBand->rcBand.left+REBAR_PRE_GRIPPER) -
    2212                              infoPtr->ihitoffset);
     2213                 infoPtr->ihitoffset);
    22132214    infoPtr->dragNow = *ptsmove;
    22142215
    22152216    TRACE("before: movement=%d (%d,%d), imindBand=%d, ihitBand=%d, imaxdBand=%d, LSum=%d, RSum=%d\n",
    2216           movement, ptsmove->x, ptsmove->y, imindBand, ihitBand,
    2217           imaxdBand, LHeaderSum, RHeaderSum);
     2217      movement, ptsmove->x, ptsmove->y, imindBand, ihitBand,
     2218      imaxdBand, LHeaderSum, RHeaderSum);
    22182219    REBAR_DumpBand (infoPtr);
    22192220
    2220     if (movement < 0) { 
     2221    if (movement < 0) {
    22212222
    22222223        /* ***  Drag left/up *** */
    22232224        compress = rcBlt(hitBand) - rcBlt(mindBand) -
    2224                    LHeaderSum;
    2225         if (compress < abs(movement)) {
    2226             TRACE("limiting left drag, was %d changed to %d\n",
    2227                   movement, -compress);
    2228             movement = -compress;
    2229         }
     2225               LHeaderSum;
     2226    if (compress < abs(movement)) {
     2227        TRACE("limiting left drag, was %d changed to %d\n",
     2228          movement, -compress);
     2229        movement = -compress;
     2230    }
    22302231
    22312232        for (i=ihitBand; i>=imindBand; i--) {
    2232             band = &infoPtr->bands[i];
    2233             if (HIDDENBAND(band)) continue;
    2234             if (i == ihitBand) {
    2235                 LEADJ(band, movement)
    2236             }
    2237             else
    2238                 movement = REBAR_Shrink (infoPtr, band, movement, i);
    2239             band->ccx = rcBw(band);
    2240         }
     2233        band = &infoPtr->bands[i];
     2234        if (HIDDENBAND(band)) continue;
     2235        if (i == ihitBand) {
     2236        LEADJ(band, movement)
     2237        }
     2238        else
     2239            movement = REBAR_Shrink (infoPtr, band, movement, i);
     2240        band->ccx = rcBw(band);
     2241    }
    22412242    }
    22422243    else {
    2243         BOOL first = TRUE;
     2244    BOOL first = TRUE;
    22442245
    22452246        /* ***  Drag right/down *** */
    22462247        compress = rcBrb(maxdBand) - rcBlt(hitBand) -
    2247                    RHeaderSum;
    2248         if (compress < abs(movement)) {
    2249             TRACE("limiting right drag, was %d changed to %d\n",
    2250                   movement, compress);
    2251             movement = compress;
    2252         }
     2248               RHeaderSum;
     2249    if (compress < abs(movement)) {
     2250        TRACE("limiting right drag, was %d changed to %d\n",
     2251          movement, compress);
     2252        movement = compress;
     2253    }
    22532254        for (i=ihitBand-1; i<=imaxdBand; i++) {
    2254             band = &infoPtr->bands[i];
    2255             if (HIDDENBAND(band)) continue;
    2256             if (first) {
    2257                 first = FALSE;
    2258                 READJ(band, movement)
    2259             }
    2260             else
    2261                 movement = REBAR_Shrink (infoPtr, band, movement, i);
    2262             band->ccx = rcBw(band);
    2263         }
     2255        band = &infoPtr->bands[i];
     2256        if (HIDDENBAND(band)) continue;
     2257        if (first) {
     2258        first = FALSE;
     2259        READJ(band, movement)
     2260        }
     2261        else
     2262            movement = REBAR_Shrink (infoPtr, band, movement, i);
     2263        band->ccx = rcBw(band);
     2264    }
    22642265    }
    22652266
    22662267    /* recompute all rectangles */
    22672268    if (infoPtr->dwStyle & CCS_VERT) {
    2268         REBAR_CalcVertBand (infoPtr, imindBand, imaxdBand+1,
    2269                             FALSE);
     2269    REBAR_CalcVertBand (infoPtr, imindBand, imaxdBand+1,
     2270                FALSE);
    22702271    }
    22712272    else {
    2272         REBAR_CalcHorzBand (infoPtr, imindBand, imaxdBand+1,
    2273                             FALSE);
     2273    REBAR_CalcHorzBand (infoPtr, imindBand, imaxdBand+1,
     2274                FALSE);
    22742275    }
    22752276
    22762277    TRACE("bands after adjustment, see band # %d, %d\n",
    2277           imindBand, imaxdBand);
     2278      imindBand, imaxdBand);
    22782279    REBAR_DumpBand (infoPtr);
    22792280
    2280     SetRect (&newrect, 
    2281              mindBand->rcBand.left,
    2282              mindBand->rcBand.top,
    2283              maxdBand->rcBand.right,
    2284              maxdBand->rcBand.bottom);
     2281    SetRect (&newrect,
     2282         mindBand->rcBand.left,
     2283         mindBand->rcBand.top,
     2284         maxdBand->rcBand.right,
     2285         maxdBand->rcBand.bottom);
    22852286
    22862287    REBAR_MoveChildWindows (infoPtr, imindBand, imaxdBand+1);
     
    23042305
    23052306    if (uBand >= infoPtr->uNumBands)
    2306         return FALSE;
     2307    return FALSE;
    23072308
    23082309    TRACE("deleting band %u!\n", uBand);
     
    23112312
    23122313    if (infoPtr->uNumBands == 1) {
    2313         TRACE(" simple delete!\n");
    2314         if ((lpBand->fMask & RBBIM_CHILD) && lpBand->hwndChild)
    2315             childhwnd = lpBand->hwndChild;
    2316         COMCTL32_Free (infoPtr->bands);
    2317         infoPtr->bands = NULL;
    2318         infoPtr->uNumBands = 0;
     2314    TRACE(" simple delete!\n");
     2315    if ((lpBand->fMask & RBBIM_CHILD) && lpBand->hwndChild)
     2316        childhwnd = lpBand->hwndChild;
     2317    COMCTL32_Free (infoPtr->bands);
     2318    infoPtr->bands = NULL;
     2319    infoPtr->uNumBands = 0;
    23192320    }
    23202321    else {
    2321         REBAR_BAND *oldBands = infoPtr->bands;
     2322    REBAR_BAND *oldBands = infoPtr->bands;
    23222323        TRACE("complex delete! [uBand=%u]\n", uBand);
    23232324
    2324         if ((lpBand->fMask & RBBIM_CHILD) && lpBand->hwndChild)
    2325             childhwnd = lpBand->hwndChild;
    2326 
    2327         infoPtr->uNumBands--;
    2328         infoPtr->bands = COMCTL32_Alloc (sizeof (REBAR_BAND) * infoPtr->uNumBands);
     2325    if ((lpBand->fMask & RBBIM_CHILD) && lpBand->hwndChild)
     2326        childhwnd = lpBand->hwndChild;
     2327
     2328    infoPtr->uNumBands--;
     2329    infoPtr->bands = COMCTL32_Alloc (sizeof (REBAR_BAND) * infoPtr->uNumBands);
    23292330        if (uBand > 0) {
    23302331            memcpy (&infoPtr->bands[0], &oldBands[0],
     
    23372338        }
    23382339
    2339         COMCTL32_Free (oldBands);
     2340    COMCTL32_Free (oldBands);
    23402341    }
    23412342
     
    23692370
    23702371    if (!lParam)
    2371         return 0;
     2372    return 0;
    23722373    if ((UINT)wParam >= infoPtr->uNumBands)
    2373         return 0;
     2374    return 0;
    23742375
    23752376    lpBand = &infoPtr->bands[(UINT)wParam];
     
    23812382    /* style.  -  GA                                                   */
    23822383    if (infoPtr->dwStyle & RBS_BANDBORDERS) {
    2383         if (infoPtr->dwStyle & CCS_VERT) {
    2384             lpRect->left = 1;
    2385             lpRect->top = lpBand->cxHeader + 4;
    2386             lpRect->right = 1;
    2387             lpRect->bottom = 0;
    2388         }
    2389         else {
    2390             lpRect->left = lpBand->cxHeader + 4;
    2391             lpRect->top = 1;
    2392             lpRect->right = 0;
    2393             lpRect->bottom = 1;
    2394         }
     2384    if (infoPtr->dwStyle & CCS_VERT) {
     2385        lpRect->left = 1;
     2386        lpRect->top = lpBand->cxHeader + 4;
     2387        lpRect->right = 1;
     2388        lpRect->bottom = 0;
    23952389    }
    23962390    else {
    2397         lpRect->left = lpBand->cxHeader;
     2391        lpRect->left = lpBand->cxHeader + 4;
     2392        lpRect->top = 1;
     2393        lpRect->right = 0;
     2394        lpRect->bottom = 1;
     2395    }
     2396    }
     2397    else {
     2398    lpRect->left = lpBand->cxHeader;
    23982399    }
    23992400    return 0;
     
    24172418
    24182419    if (lprbbi == NULL)
    2419         return FALSE;
     2420    return FALSE;
    24202421    if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
    2421         return FALSE;
     2422    return FALSE;
    24222423    if ((UINT)wParam >= infoPtr->uNumBands)
    2423         return FALSE;
     2424    return FALSE;
    24242425
    24252426    TRACE("index %u\n", (UINT)wParam);
     
    24292430
    24302431    if (lprbbi->fMask & RBBIM_STYLE)
    2431         lprbbi->fStyle = lpBand->fStyle;
     2432    lprbbi->fStyle = lpBand->fStyle;
    24322433
    24332434    if (lprbbi->fMask & RBBIM_COLORS) {
    2434         lprbbi->clrFore = lpBand->clrFore;
    2435         lprbbi->clrBack = lpBand->clrBack;
    2436         if (lprbbi->clrBack == CLR_NONE)
    2437             lprbbi->clrBack = infoPtr->clrBtnFace;
     2435    lprbbi->clrFore = lpBand->clrFore;
     2436    lprbbi->clrBack = lpBand->clrBack;
     2437    if (lprbbi->clrBack == CLR_NONE)
     2438        lprbbi->clrBack = infoPtr->clrBtnFace;
    24382439    }
    24392440
     
    24452446              lprbbi->lpText[lprbbi->cch-1] = 0;
    24462447      }
    2447       else 
    2448         *lprbbi->lpText = 0;
     2448      else
     2449    *lprbbi->lpText = 0;
    24492450    }
    24502451
    24512452    if (lprbbi->fMask & RBBIM_IMAGE) {
    24522453      if (lpBand->fMask & RBBIM_IMAGE)
    2453         lprbbi->iImage = lpBand->iImage;
     2454    lprbbi->iImage = lpBand->iImage;
    24542455      else
    2455         lprbbi->iImage = -1;
     2456    lprbbi->iImage = -1;
    24562457    }
    24572458
    24582459    if (lprbbi->fMask & RBBIM_CHILD)
    2459         lprbbi->hwndChild = lpBand->hwndChild;
     2460    lprbbi->hwndChild = lpBand->hwndChild;
    24602461
    24612462    if (lprbbi->fMask & RBBIM_CHILDSIZE) {
    2462         lprbbi->cxMinChild = lpBand->cxMinChild;
    2463         lprbbi->cyMinChild = lpBand->cyMinChild;
    2464         if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
    2465             lprbbi->cyChild    = lpBand->cyChild;
    2466             lprbbi->cyMaxChild = lpBand->cyMaxChild;
    2467             lprbbi->cyIntegral = lpBand->cyIntegral;
    2468         }
     2463    lprbbi->cxMinChild = lpBand->cxMinChild;
     2464    lprbbi->cyMinChild = lpBand->cyMinChild;
     2465    if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
     2466        lprbbi->cyChild    = lpBand->cyChild;
     2467        lprbbi->cyMaxChild = lpBand->cyMaxChild;
     2468        lprbbi->cyIntegral = lpBand->cyIntegral;
     2469    }
    24692470    }
    24702471
    24712472    if (lprbbi->fMask & RBBIM_SIZE)
    2472         lprbbi->cx = lpBand->cx;
     2473    lprbbi->cx = lpBand->cx;
    24732474
    24742475    if (lprbbi->fMask & RBBIM_BACKGROUND)
    2475         lprbbi->hbmBack = lpBand->hbmBack;
     2476    lprbbi->hbmBack = lpBand->hbmBack;
    24762477
    24772478    if (lprbbi->fMask & RBBIM_ID)
    2478         lprbbi->wID = lpBand->wID;
     2479    lprbbi->wID = lpBand->wID;
    24792480
    24802481    /* check for additional data */
    24812482    if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
    2482         if (lprbbi->fMask & RBBIM_IDEALSIZE)
    2483             lprbbi->cxIdeal = lpBand->cxIdeal;
    2484 
    2485         if (lprbbi->fMask & RBBIM_LPARAM)
    2486             lprbbi->lParam = lpBand->lParam;
    2487 
    2488         if (lprbbi->fMask & RBBIM_HEADERSIZE)
    2489             lprbbi->cxHeader = lpBand->cxHeader;
     2483    if (lprbbi->fMask & RBBIM_IDEALSIZE)
     2484        lprbbi->cxIdeal = lpBand->cxIdeal;
     2485
     2486    if (lprbbi->fMask & RBBIM_LPARAM)
     2487        lprbbi->lParam = lpBand->lParam;
     2488
     2489    if (lprbbi->fMask & RBBIM_HEADERSIZE)
     2490        lprbbi->cxHeader = lpBand->cxHeader;
    24902491    }
    24912492
     
    25032504
    25042505    if (lprbbi == NULL)
    2505         return FALSE;
     2506    return FALSE;
    25062507    if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
    2507         return FALSE;
     2508    return FALSE;
    25082509    if ((UINT)wParam >= infoPtr->uNumBands)
    2509         return FALSE;
     2510    return FALSE;
    25102511
    25112512    TRACE("index %u\n", (UINT)wParam);
     
    25152516
    25162517    if (lprbbi->fMask & RBBIM_STYLE)
    2517         lprbbi->fStyle = lpBand->fStyle;
     2518    lprbbi->fStyle = lpBand->fStyle;
    25182519
    25192520    if (lprbbi->fMask & RBBIM_COLORS) {
    2520         lprbbi->clrFore = lpBand->clrFore;
    2521         lprbbi->clrBack = lpBand->clrBack;
    2522         if (lprbbi->clrBack == CLR_NONE)
    2523             lprbbi->clrBack = infoPtr->clrBtnFace;
     2521    lprbbi->clrFore = lpBand->clrFore;
     2522    lprbbi->clrBack = lpBand->clrBack;
     2523    if (lprbbi->clrBack == CLR_NONE)
     2524        lprbbi->clrBack = infoPtr->clrBtnFace;
    25242525    }
    25252526
    25262527    if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
    25272528      if (lpBand->lpText && (lpBand->fMask & RBBIM_TEXT))
    2528         lstrcpynW (lprbbi->lpText, lpBand->lpText, lprbbi->cch);
    2529       else 
    2530         *lprbbi->lpText = 0;
     2529    lstrcpynW (lprbbi->lpText, lpBand->lpText, lprbbi->cch);
     2530      else
     2531    *lprbbi->lpText = 0;
    25312532    }
    25322533
    25332534    if (lprbbi->fMask & RBBIM_IMAGE) {
    25342535      if (lpBand->fMask & RBBIM_IMAGE)
    2535         lprbbi->iImage = lpBand->iImage;
     2536    lprbbi->iImage = lpBand->iImage;
    25362537      else
    2537         lprbbi->iImage = -1;
     2538    lprbbi->iImage = -1;
    25382539    }
    25392540
    25402541    if (lprbbi->fMask & RBBIM_CHILD)
    2541         lprbbi->hwndChild = lpBand->hwndChild;
     2542    lprbbi->hwndChild = lpBand->hwndChild;
    25422543
    25432544    if (lprbbi->fMask & RBBIM_CHILDSIZE) {
    2544         lprbbi->cxMinChild = lpBand->cxMinChild;
    2545         lprbbi->cyMinChild = lpBand->cyMinChild;
    2546         if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) {
    2547             lprbbi->cyChild    = lpBand->cyChild;
    2548             lprbbi->cyMaxChild = lpBand->cyMaxChild;
    2549             lprbbi->cyIntegral = lpBand->cyIntegral;
    2550         }
     2545    lprbbi->cxMinChild = lpBand->cxMinChild;
     2546    lprbbi->cyMinChild = lpBand->cyMinChild;
     2547    if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) {
     2548        lprbbi->cyChild    = lpBand->cyChild;
     2549        lprbbi->cyMaxChild = lpBand->cyMaxChild;
     2550        lprbbi->cyIntegral = lpBand->cyIntegral;
     2551    }
    25512552    }
    25522553
    25532554    if (lprbbi->fMask & RBBIM_SIZE)
    2554         lprbbi->cx = lpBand->cx;
     2555    lprbbi->cx = lpBand->cx;
    25552556
    25562557    if (lprbbi->fMask & RBBIM_BACKGROUND)
    2557         lprbbi->hbmBack = lpBand->hbmBack;
     2558    lprbbi->hbmBack = lpBand->hbmBack;
    25582559
    25592560    if (lprbbi->fMask & RBBIM_ID)
    2560         lprbbi->wID = lpBand->wID;
     2561    lprbbi->wID = lpBand->wID;
    25612562
    25622563    /* check for additional data */
    25632564    if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) {
    2564         if (lprbbi->fMask & RBBIM_IDEALSIZE)
    2565             lprbbi->cxIdeal = lpBand->cxIdeal;
    2566 
    2567         if (lprbbi->fMask & RBBIM_LPARAM)
    2568             lprbbi->lParam = lpBand->lParam;
    2569 
    2570         if (lprbbi->fMask & RBBIM_HEADERSIZE)
    2571             lprbbi->cxHeader = lpBand->cxHeader;
     2565    if (lprbbi->fMask & RBBIM_IDEALSIZE)
     2566        lprbbi->cxIdeal = lpBand->cxIdeal;
     2567
     2568    if (lprbbi->fMask & RBBIM_LPARAM)
     2569        lprbbi->lParam = lpBand->lParam;
     2570
     2571    if (lprbbi->fMask & RBBIM_HEADERSIZE)
     2572        lprbbi->cxHeader = lpBand->cxHeader;
    25722573    }
    25732574
     
    25972598
    25982599    if (lpInfo == NULL)
    2599         return FALSE;
     2600    return FALSE;
    26002601
    26012602    if (lpInfo->cbSize < sizeof (REBARINFO))
    2602         return FALSE;
     2603    return FALSE;
    26032604
    26042605    TRACE("getting bar info!\n");
    26052606
    26062607    if (infoPtr->himl) {
    2607         lpInfo->himl = infoPtr->himl;
    2608         lpInfo->fMask |= RBIM_IMAGELIST;
     2608    lpInfo->himl = infoPtr->himl;
     2609    lpInfo->fMask |= RBIM_IMAGELIST;
    26092610    }
    26102611
     
    26482649
    26492650    if ((iBand < 0) && ((UINT)iBand >= infoPtr->uNumBands))
    2650         return FALSE;
     2651    return FALSE;
    26512652    if (!lprc)
    2652         return FALSE;
     2653    return FALSE;
    26532654
    26542655    lpBand = &infoPtr->bands[iBand];
     
    26562657
    26572658    TRACE("band %d, (%d,%d)-(%d,%d)\n", iBand,
    2658           lprc->left, lprc->top, lprc->right, lprc->bottom);
     2659      lprc->left, lprc->top, lprc->right, lprc->bottom);
    26592660
    26602661    return TRUE;
     
    26802681
    26812682    for (i=0; i<infoPtr->uNumBands; i++) {
    2682         lpBand = &infoPtr->bands[i];
    2683         if (HIDDENBAND(lpBand)) continue;
    2684         if (lpBand->iRow != iRow) continue;
    2685         if (infoPtr->dwStyle & CCS_VERT)
    2686             j = lpBand->rcBand.right - lpBand->rcBand.left;
    2687         else
    2688             j = lpBand->rcBand.bottom - lpBand->rcBand.top;
    2689         if (j > ret) ret = j;
     2683    lpBand = &infoPtr->bands[i];
     2684    if (HIDDENBAND(lpBand)) continue;
     2685    if (lpBand->iRow != iRow) continue;
     2686    if (infoPtr->dwStyle & CCS_VERT)
     2687        j = lpBand->rcBand.right - lpBand->rcBand.left;
     2688    else
     2689        j = lpBand->rcBand.bottom - lpBand->rcBand.top;
     2690    if (j > ret) ret = j;
    26902691    }
    26912692
     
    27152716REBAR_GetUnicodeFormat (REBAR_INFO *infoPtr)
    27162717{
    2717     TRACE("%s hwnd=0x%x\n", 
    2718           infoPtr->bUnicode ? "TRUE" : "FALSE", infoPtr->hwndSelf);
     2718    TRACE("%s hwnd=0x%x\n",
     2719      infoPtr->bUnicode ? "TRUE" : "FALSE", infoPtr->hwndSelf);
    27192720
    27202721    return infoPtr->bUnicode;
     
    27332734REBAR_HitTest (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
    27342735{
    2735     LPRBHITTESTINFO lprbht = (LPRBHITTESTINFO)lParam; 
     2736    LPRBHITTESTINFO lprbht = (LPRBHITTESTINFO)lParam;
    27362737
    27372738    if (!lprbht)
    2738         return -1;
     2739    return -1;
    27392740
    27402741    REBAR_InternalHitTest (infoPtr, &lprbht->pt, &lprbht->flags, &lprbht->iBand);
     
    27502751
    27512752    if (infoPtr == NULL)
    2752         return -1;
     2753    return -1;
    27532754
    27542755    if (infoPtr->uNumBands < 1)
    2755         return -1;
     2756    return -1;
    27562757
    27572758    for (i = 0; i < infoPtr->uNumBands; i++) {
    2758         if (infoPtr->bands[i].wID == (UINT)wParam) {
    2759             TRACE("id %u is band %u found!\n", (UINT)wParam, i);
    2760             return i;
    2761         }
     2759    if (infoPtr->bands[i].wID == (UINT)wParam) {
     2760        TRACE("id %u is band %u found!\n", (UINT)wParam, i);
     2761        return i;
     2762    }
    27622763    }
    27632764
     
    27752776
    27762777    if (infoPtr == NULL)
    2777         return FALSE;
     2778    return FALSE;
    27782779    if (lprbbi == NULL)
    2779         return FALSE;
     2780    return FALSE;
    27802781    if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
    2781         return FALSE;
     2782    return FALSE;
    27822783
    27832784    /* trace the index as signed to see the -1 */
     
    27862787
    27872788    if (infoPtr->uNumBands == 0) {
    2788         infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND));
    2789         uIndex = 0;
     2789    infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND));
     2790    uIndex = 0;
    27902791    }
    27912792    else {
    2792         REBAR_BAND *oldBands = infoPtr->bands;
    2793         infoPtr->bands =
    2794             (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
    2795         if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
    2796             uIndex = infoPtr->uNumBands;
    2797 
    2798         /* pre insert copy */
    2799         if (uIndex > 0) {
    2800             memcpy (&infoPtr->bands[0], &oldBands[0],
    2801                     uIndex * sizeof(REBAR_BAND));
    2802         }
    2803 
    2804         /* post copy */
    2805         if (uIndex < infoPtr->uNumBands - 1) {
    2806             memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
    2807                     (infoPtr->uNumBands - uIndex - 1) * sizeof(REBAR_BAND));
    2808         }
    2809 
    2810         COMCTL32_Free (oldBands);
     2793    REBAR_BAND *oldBands = infoPtr->bands;
     2794    infoPtr->bands =
     2795        (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
     2796    if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
     2797        uIndex = infoPtr->uNumBands;
     2798
     2799    /* pre insert copy */
     2800    if (uIndex > 0) {
     2801        memcpy (&infoPtr->bands[0], &oldBands[0],
     2802            uIndex * sizeof(REBAR_BAND));
     2803    }
     2804
     2805    /* post copy */
     2806    if (uIndex < infoPtr->uNumBands - 1) {
     2807        memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
     2808            (infoPtr->uNumBands - uIndex - 1) * sizeof(REBAR_BAND));
     2809    }
     2810
     2811    COMCTL32_Free (oldBands);
    28112812    }
    28122813
     
    28312832            lpBand->lpText = (LPWSTR)COMCTL32_Alloc (len*sizeof(WCHAR));
    28322833            MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, lpBand->lpText, len );
    2833         }
     2834    }
    28342835    }
    28352836
     
    28372838    /* On insert of second band, revalidate band 1 to possible add gripper */
    28382839    if (infoPtr->uNumBands == 2)
    2839         REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]);
     2840    REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]);
    28402841
    28412842    REBAR_DumpBand (infoPtr);
     
    28552856
    28562857    if (infoPtr == NULL)
    2857         return FALSE;
     2858    return FALSE;
    28582859    if (lprbbi == NULL)
    2859         return FALSE;
     2860    return FALSE;
    28602861    if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
    2861         return FALSE;
     2862    return FALSE;
    28622863
    28632864    /* trace the index as signed to see the -1 */
     
    28662867
    28672868    if (infoPtr->uNumBands == 0) {
    2868         infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND));
    2869         uIndex = 0;
     2869    infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND));
     2870    uIndex = 0;
    28702871    }
    28712872    else {
    2872         REBAR_BAND *oldBands = infoPtr->bands;
    2873         infoPtr->bands =
    2874             (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
    2875         if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
    2876             uIndex = infoPtr->uNumBands;
    2877 
    2878         /* pre insert copy */
    2879         if (uIndex > 0) {
    2880             memcpy (&infoPtr->bands[0], &oldBands[0],
    2881                     uIndex * sizeof(REBAR_BAND));
    2882         }
    2883 
    2884         /* post copy */
    2885         if (uIndex < infoPtr->uNumBands - 1) {
    2886             memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
    2887                     (infoPtr->uNumBands - uIndex - 1) * sizeof(REBAR_BAND));
    2888         }
    2889 
    2890         COMCTL32_Free (oldBands);
     2873    REBAR_BAND *oldBands = infoPtr->bands;
     2874    infoPtr->bands =
     2875        (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
     2876    if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
     2877        uIndex = infoPtr->uNumBands;
     2878
     2879    /* pre insert copy */
     2880    if (uIndex > 0) {
     2881        memcpy (&infoPtr->bands[0], &oldBands[0],
     2882            uIndex * sizeof(REBAR_BAND));
     2883    }
     2884
     2885    /* post copy */
     2886    if (uIndex < infoPtr->uNumBands - 1) {
     2887        memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
     2888            (infoPtr->uNumBands - uIndex - 1) * sizeof(REBAR_BAND));
     2889    }
     2890
     2891    COMCTL32_Free (oldBands);
    28912892    }
    28922893
     
    29072908    lpBand->lpText = NULL;
    29082909    if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
    2909         INT len = lstrlenW (lprbbi->lpText);
    2910         if (len > 0) {
    2911             lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
    2912             strcpyW (lpBand->lpText, lprbbi->lpText);
    2913         }
     2910    INT len = lstrlenW (lprbbi->lpText);
     2911    if (len > 0) {
     2912        lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     2913        strcpyW (lpBand->lpText, lprbbi->lpText);
     2914    }
    29142915    }
    29152916
     
    29172918    /* On insert of second band, revalidate band 1 to possible add gripper */
    29182919    if (infoPtr->uNumBands == 2)
    2919         REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]);
     2920    REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]);
    29202921
    29212922    REBAR_DumpBand (infoPtr);
     
    29312932{
    29322933    FIXME("(uBand = %u fIdeal = %s) stub\n",
    2933            (UINT)wParam, lParam ? "TRUE" : "FALSE");
     2934       (UINT)wParam, lParam ? "TRUE" : "FALSE");
    29342935
    29352936    return 0;
     
    29542955    /* Validate */
    29552956    if ((infoPtr->uNumBands == 0) ||
    2956         ((INT)uBand < 0) || (uBand >= infoPtr->uNumBands)) {
    2957         /* error !!! */
    2958         ERR("Illegal MinimizeBand, requested=%d, current band count=%d\n",
    2959               (INT)uBand, infoPtr->uNumBands);
    2960         return FALSE;
     2957    ((INT)uBand < 0) || (uBand >= infoPtr->uNumBands)) {
     2958    /* error !!! */
     2959    ERR("Illegal MinimizeBand, requested=%d, current band count=%d\n",
     2960          (INT)uBand, infoPtr->uNumBands);
     2961        return FALSE;
    29612962    }
    29622963
     
    29652966
    29662967    if (infoPtr->dwStyle & CCS_VERT)
    2967         movement = lpBand->rcBand.bottom - lpBand->rcBand.top -
    2968             lpBand->cxHeader;
     2968    movement = lpBand->rcBand.bottom - lpBand->rcBand.top -
     2969        lpBand->cxHeader;
    29692970    else
    2970         movement = lpBand->rcBand.right - lpBand->rcBand.left -
    2971             lpBand->cxHeader;
     2971    movement = lpBand->rcBand.right - lpBand->rcBand.left -
     2972        lpBand->cxHeader;
    29722973    if (movement < 0) {
    2973         ERR("something is wrong, band=(%d,%d)-(%d,%d), cxheader=%d\n",
    2974             lpBand->rcBand.left, lpBand->rcBand.top,
    2975             lpBand->rcBand.right, lpBand->rcBand.bottom,
    2976             lpBand->cxHeader);
    2977         return FALSE;
     2974    ERR("something is wrong, band=(%d,%d)-(%d,%d), cxheader=%d\n",
     2975        lpBand->rcBand.left, lpBand->rcBand.top,
     2976        lpBand->rcBand.right, lpBand->rcBand.bottom,
     2977        lpBand->cxHeader);
     2978    return FALSE;
    29782979    }
    29792980
     
    29852986    for (i=0; i<infoPtr->uNumBands; i++) {
    29862987        band = &infoPtr->bands[i];
    2987         if (HIDDENBAND(band)) continue;
    2988         if (band->iRow == lpBand->iRow) {
    2989             imaxdBand = i;
    2990             if (imindBand == -1) imindBand = i;
    2991         }
     2988    if (HIDDENBAND(band)) continue;
     2989    if (band->iRow == lpBand->iRow) {
     2990        imaxdBand = i;
     2991        if (imindBand == -1) imindBand = i;
     2992    }
    29922993    }
    29932994
     
    29952996    /* next visible band                                        */
    29962997    if (imindBand == uBand) {
    2997         band = NULL;
    2998         movement = -movement;
    2999         /* find the first visible band to the right of the selected band */
    3000         for (i=uBand+1; i<=imaxdBand; i++) {
    3001             band = &infoPtr->bands[i];
    3002             if (!HIDDENBAND(band)) {
    3003                 iprevBand = i;
    3004                 LEADJ(band, movement);
    3005                 band->ccx = rcBw(band);
    3006                 break;
    3007             }
    3008         }
    3009         /* what case is this */
    3010         if (iprevBand == -1) {
    3011             ERR("no previous visible band\n");
    3012             return FALSE;
    3013         }
    3014         startBand = uBand;
    3015         endBand = iprevBand;
    3016         SetRect (&newrect,
    3017                 lpBand->rcBand.left,
    3018                 lpBand->rcBand.top,
    3019                 band->rcBand.right,
    3020                 band->rcBand.bottom);
     2998    band = NULL;
     2999    movement = -movement;
     3000    /* find the first visible band to the right of the selected band */
     3001    for (i=uBand+1; i<=imaxdBand; i++) {
     3002        band = &infoPtr->bands[i];
     3003        if (!HIDDENBAND(band)) {
     3004        iprevBand = i;
     3005        LEADJ(band, movement);
     3006        band->ccx = rcBw(band);
     3007        break;
     3008        }
     3009    }
     3010    /* what case is this */
     3011    if (iprevBand == -1) {
     3012        ERR("no previous visible band\n");
     3013        return FALSE;
     3014    }
     3015    startBand = uBand;
     3016    endBand = iprevBand;
     3017    SetRect (&newrect,
     3018        lpBand->rcBand.left,
     3019        lpBand->rcBand.top,
     3020        band->rcBand.right,
     3021        band->rcBand.bottom);
    30213022    }
    30223023    /* otherwise expand previous visible band                   */
    30233024    else {
    3024         band = NULL;
    3025         /* find the first visible band to the left of the selected band */
    3026         for (i=uBand-1; i>=imindBand; i--) {
    3027             band = &infoPtr->bands[i];
    3028             if (!HIDDENBAND(band)) {
    3029                 iprevBand = i;
    3030                 READJ(band, movement);
    3031                 band->ccx = rcBw(band);
    3032                 break;
    3033             }
    3034         }
    3035         /* what case is this */
    3036         if (iprevBand == -1) {
    3037             ERR("no previous visible band\n");
    3038             return FALSE;
    3039         }
    3040         startBand = iprevBand;
    3041         endBand = uBand;
    3042         SetRect (&newrect,
    3043                 band->rcBand.left,
    3044                 band->rcBand.top,
    3045                 lpBand->rcBand.right,
    3046                 lpBand->rcBand.bottom);
     3025    band = NULL;
     3026    /* find the first visible band to the left of the selected band */
     3027    for (i=uBand-1; i>=imindBand; i--) {
     3028        band = &infoPtr->bands[i];
     3029        if (!HIDDENBAND(band)) {
     3030        iprevBand = i;
     3031        READJ(band, movement);
     3032        band->ccx = rcBw(band);
     3033        break;
     3034        }
     3035    }
     3036    /* what case is this */
     3037    if (iprevBand == -1) {
     3038        ERR("no previous visible band\n");
     3039        return FALSE;
     3040    }
     3041    startBand = iprevBand;
     3042    endBand = uBand;
     3043    SetRect (&newrect,
     3044        band->rcBand.left,
     3045        band->rcBand.top,
     3046        lpBand->rcBand.right,
     3047        lpBand->rcBand.bottom);
    30473048    }
    30483049
     
    30513052    /* recompute all rectangles */
    30523053    if (infoPtr->dwStyle & CCS_VERT) {
    3053         REBAR_CalcVertBand (infoPtr, startBand, endBand+1,
    3054                             FALSE);
     3054    REBAR_CalcVertBand (infoPtr, startBand, endBand+1,
     3055                FALSE);
    30553056    }
    30563057    else {
    3057         REBAR_CalcHorzBand (infoPtr, startBand, endBand+1,
    3058                             FALSE);
     3058    REBAR_CalcHorzBand (infoPtr, startBand, endBand+1,
     3059                FALSE);
    30593060    }
    30603061
    30613062    TRACE("bands after minimize, see band # %d, %d\n",
    3062           startBand, endBand);
     3063      startBand, endBand);
    30633064    REBAR_DumpBand (infoPtr);
    30643065
     
    30813082    /* Validate */
    30823083    if ((infoPtr->uNumBands == 0) ||
    3083         ((INT)uFrom < 0) || (uFrom >= infoPtr->uNumBands) ||
    3084         ((INT)uTo < 0)   || (uTo >= infoPtr->uNumBands)) {
    3085         /* error !!! */
    3086         ERR("Illegal MoveBand, from=%d, to=%d, current band count=%d\n",
    3087               (INT)uFrom, (INT)uTo, infoPtr->uNumBands);
    3088         return FALSE;
     3084    ((INT)uFrom < 0) || (uFrom >= infoPtr->uNumBands) ||
     3085    ((INT)uTo < 0)   || (uTo >= infoPtr->uNumBands)) {
     3086    /* error !!! */
     3087    ERR("Illegal MoveBand, from=%d, to=%d, current band count=%d\n",
     3088          (INT)uFrom, (INT)uTo, infoPtr->uNumBands);
     3089        return FALSE;
    30893090    }
    30903091
     
    30943095    /* close up rest of bands (psuedo delete) */
    30953096    if (uFrom < infoPtr->uNumBands - 1) {
    3096         memcpy (&oldBands[uFrom], &oldBands[uFrom+1],
    3097                 (infoPtr->uNumBands - uFrom - 1) * sizeof(REBAR_BAND));
     3097    memcpy (&oldBands[uFrom], &oldBands[uFrom+1],
     3098        (infoPtr->uNumBands - uFrom - 1) * sizeof(REBAR_BAND));
    30983099    }
    30993100
    31003101    /* allocate new space and copy rest of bands into it */
    31013102    infoPtr->bands =
    3102         (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands)*sizeof(REBAR_BAND));
     3103    (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands)*sizeof(REBAR_BAND));
    31033104
    31043105    /* pre insert copy */
    31053106    if (uTo > 0) {
    3106         memcpy (&infoPtr->bands[0], &oldBands[0],
    3107                 uTo * sizeof(REBAR_BAND));
     3107    memcpy (&infoPtr->bands[0], &oldBands[0],
     3108        uTo * sizeof(REBAR_BAND));
    31083109    }
    31093110
     
    31133114    /* post copy */
    31143115    if (uTo < infoPtr->uNumBands - 1) {
    3115         memcpy (&infoPtr->bands[uTo+1], &oldBands[uTo],
    3116                 (infoPtr->uNumBands - uTo - 1) * sizeof(REBAR_BAND));
     3116    memcpy (&infoPtr->bands[uTo+1], &oldBands[uTo],
     3117        (infoPtr->uNumBands - uTo - 1) * sizeof(REBAR_BAND));
    31173118    }
    31183119
     
    31433144
    31443145    if (lprbbi == NULL)
    3145         return FALSE;
     3146    return FALSE;
    31463147    if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
    3147         return FALSE;
     3148    return FALSE;
    31483149    if ((UINT)wParam >= infoPtr->uNumBands)
    3149         return FALSE;
     3150    return FALSE;
    31503151
    31513152    TRACE("index %u\n", (UINT)wParam);
     
    31573158    REBAR_CommonSetupBand (infoPtr->hwndSelf, lprbbi, lpBand);
    31583159    if (lprbbi->fMask & RBBIM_TEXT) {
    3159         if (lpBand->lpText) {
    3160             COMCTL32_Free (lpBand->lpText);
    3161             lpBand->lpText = NULL;
    3162         }
    3163         if (lprbbi->lpText) {
     3160    if (lpBand->lpText) {
     3161        COMCTL32_Free (lpBand->lpText);
     3162        lpBand->lpText = NULL;
     3163    }
     3164    if (lprbbi->lpText) {
    31643165            INT len = MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, NULL, 0 );
    31653166            lpBand->lpText = (LPWSTR)COMCTL32_Alloc (len*sizeof(WCHAR));
    31663167            MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, lpBand->lpText, len );
    3167         }
     3168    }
    31683169    }
    31693170
     
    31733174
    31743175    if (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE))
    3175           REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
     3176      REBAR_Layout (infoPtr, NULL, TRUE, FALSE);
    31763177
    31773178    return TRUE;
     
    31863187
    31873188    if (lprbbi == NULL)
    3188         return FALSE;
     3189    return FALSE;
    31893190    if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
    3190         return FALSE;
     3191    return FALSE;
    31913192    if ((UINT)wParam >= infoPtr->uNumBands)
    3192         return FALSE;
     3193    return FALSE;
    31933194
    31943195    TRACE("index %u\n", (UINT)wParam);
     
    32003201    REBAR_CommonSetupBand (infoPtr->hwndSelf, (LPREBARBANDINFOA)lprbbi, lpBand);
    32013202    if (lprbbi->fMask & RBBIM_TEXT) {
    3202         if (lpBand->lpText) {
    3203             COMCTL32_Free (lpBand->lpText);
    3204             lpBand->lpText = NULL;
    3205         }
    3206         if (lprbbi->lpText) {
    3207             INT len = lstrlenW (lprbbi->lpText);
    3208             lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
    3209             strcpyW (lpBand->lpText, lprbbi->lpText);
    3210         }
     3203    if (lpBand->lpText) {
     3204        COMCTL32_Free (lpBand->lpText);
     3205        lpBand->lpText = NULL;
     3206    }
     3207    if (lprbbi->lpText) {
     3208        INT len = lstrlenW (lprbbi->lpText);
     3209        lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     3210        strcpyW (lpBand->lpText, lprbbi->lpText);
     3211    }
    32113212    }
    32123213
     
    32303231
    32313232    if (lpInfo == NULL)
    3232         return FALSE;
     3233    return FALSE;
    32333234
    32343235    if (lpInfo->cbSize < sizeof (REBARINFO))
    3235         return FALSE;
     3236    return FALSE;
    32363237
    32373238    TRACE("setting bar info!\n");
    32383239
    32393240    if (lpInfo->fMask & RBIM_IMAGELIST) {
    3240         infoPtr->himl = lpInfo->himl;
    3241         if (infoPtr->himl) {
     3241    infoPtr->himl = lpInfo->himl;
     3242    if (infoPtr->himl) {
    32423243            INT cx, cy;
    3243             ImageList_GetIconSize (infoPtr->himl, &cx, &cy);
    3244             infoPtr->imageSize.cx = cx;
    3245             infoPtr->imageSize.cy = cy;
    3246         }
    3247         else {
    3248             infoPtr->imageSize.cx = 0;
    3249             infoPtr->imageSize.cy = 0;
    3250         }
    3251         TRACE("new image cx=%ld, cy=%ld\n", infoPtr->imageSize.cx,
    3252               infoPtr->imageSize.cy);
     3244        ImageList_GetIconSize (infoPtr->himl, &cx, &cy);
     3245        infoPtr->imageSize.cx = cx;
     3246        infoPtr->imageSize.cy = cy;
     3247    }
     3248    else {
     3249        infoPtr->imageSize.cx = 0;
     3250        infoPtr->imageSize.cy = 0;
     3251    }
     3252    TRACE("new image cx=%ld, cy=%ld\n", infoPtr->imageSize.cx,
     3253          infoPtr->imageSize.cy);
    32533254    }
    32543255
     
    32563257    for (i=0; i<infoPtr->uNumBands; i++) {
    32573258        lpBand = &infoPtr->bands[i];
    3258         REBAR_ValidateBand (infoPtr, lpBand);
     3259    REBAR_ValidateBand (infoPtr, lpBand);
    32593260    }
    32603261
     
    33143315    BOOL bTemp = infoPtr->bUnicode;
    33153316
    3316     TRACE("to %s hwnd=0x%04x, was %s\n", 
    3317           ((BOOL)wParam) ? "TRUE" : "FALSE", infoPtr->hwndSelf,
    3318           (bTemp) ? "TRUE" : "FALSE");
     3317    TRACE("to %s hwnd=0x%04x, was %s\n",
     3318      ((BOOL)wParam) ? "TRUE" : "FALSE", infoPtr->hwndSelf,
     3319      (bTemp) ? "TRUE" : "FALSE");
    33193320
    33203321    infoPtr->bUnicode = (BOOL)wParam;
    3321  
     3322
    33223323   return bTemp;
    33233324}
     
    33303331
    33313332    if (iVersion > COMCTL32_VERSION)
    3332         return -1;
     3333    return -1;
    33333334
    33343335    infoPtr->iVersion = iVersion;
     
    33463347
    33473348    if (((INT)wParam < 0) || ((INT)wParam > infoPtr->uNumBands))
    3348         return FALSE;
     3349    return FALSE;
    33493350
    33503351    lpBand = &infoPtr->bands[(INT)wParam];
    33513352
    33523353    if ((BOOL)lParam) {
    3353         TRACE("show band %d\n", (INT)wParam);
    3354         lpBand->fStyle = lpBand->fStyle & ~RBBS_HIDDEN;
    3355         if (IsWindow (lpBand->hwndChild))
    3356             ShowWindow (lpBand->hwndChild, SW_SHOW);
     3354    TRACE("show band %d\n", (INT)wParam);
     3355    lpBand->fStyle = lpBand->fStyle & ~RBBS_HIDDEN;
     3356    if (IsWindow (lpBand->hwndChild))
     3357        ShowWindow (lpBand->hwndChild, SW_SHOW);
    33573358    }
    33583359    else {
    3359         TRACE("hide band %d\n", (INT)wParam);
    3360         lpBand->fStyle = lpBand->fStyle | RBBS_HIDDEN;
    3361         if (IsWindow (lpBand->hwndChild))
    3362             ShowWindow (lpBand->hwndChild, SW_HIDE);
     3360    TRACE("hide band %d\n", (INT)wParam);
     3361    lpBand->fStyle = lpBand->fStyle | RBBS_HIDDEN;
     3362    if (IsWindow (lpBand->hwndChild))
     3363        ShowWindow (lpBand->hwndChild, SW_HIDE);
    33633364    }
    33643365
     
    33793380
    33803381    TRACE("[%d %d %d %d]\n",
    3381           lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
     3382      lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
    33823383
    33833384    /*  what is going on???? */
    33843385    GetWindowRect(infoPtr->hwndSelf, &t1);
    33853386    TRACE("window rect [%d %d %d %d]\n",
    3386           t1.left, t1.top, t1.right, t1.bottom);
     3387      t1.left, t1.top, t1.right, t1.bottom);
    33873388    GetClientRect(infoPtr->hwndSelf, &t1);
    33883389    TRACE("client rect [%d %d %d %d]\n",
    3389           t1.left, t1.top, t1.right, t1.bottom);
     3390      t1.left, t1.top, t1.right, t1.bottom);
    33903391
    33913392    /* force full _Layout processing */
     
    34063407
    34073408    if (TRACE_ON(rebar)) {
    3408         GetWindowRect(infoPtr->hwndSelf, &wnrc1);
    3409         GetClientRect(infoPtr->hwndSelf, &clrc1);
    3410         TRACE("window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d) cs=(%d,%d %dx%d)\n",
    3411               wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
    3412               clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
    3413               cs->x, cs->y, cs->cx, cs->cy);
     3409    GetWindowRect(infoPtr->hwndSelf, &wnrc1);
     3410    GetClientRect(infoPtr->hwndSelf, &clrc1);
     3411    TRACE("window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d) cs=(%d,%d %dx%d)\n",
     3412          wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
     3413          clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
     3414          cs->x, cs->y, cs->cx, cs->cy);
    34143415    }
    34153416
     
    34283429    /* free rebar bands */
    34293430    if ((infoPtr->uNumBands > 0) && infoPtr->bands) {
    3430         /* clean up each band */
    3431         for (i = 0; i < infoPtr->uNumBands; i++) {
    3432             lpBand = &infoPtr->bands[i];
    3433 
    3434             /* delete text strings */
    3435             if (lpBand->lpText) {
    3436                 COMCTL32_Free (lpBand->lpText);
    3437                 lpBand->lpText = NULL;
    3438             }
    3439             /* destroy child window */
    3440             DestroyWindow (lpBand->hwndChild);
    3441         }
    3442 
    3443         /* free band array */
    3444         COMCTL32_Free (infoPtr->bands);
    3445         infoPtr->bands = NULL;
     3431    /* clean up each band */
     3432    for (i = 0; i < infoPtr->uNumBands; i++) {
     3433        lpBand = &infoPtr->bands[i];
     3434
     3435        /* delete text strings */
     3436        if (lpBand->lpText) {
     3437        COMCTL32_Free (lpBand->lpText);
     3438        lpBand->lpText = NULL;
     3439        }
     3440        /* destroy child window */
     3441        DestroyWindow (lpBand->hwndChild);
     3442    }
     3443
     3444    /* free band array */
     3445    COMCTL32_Free (infoPtr->bands);
     3446    infoPtr->bands = NULL;
    34463447    }
    34473448
     
    35223523    if (infoPtr->fStatus & BEGIN_DRAG_ISSUED) {
    35233524        REBAR_Notify((NMHDR *) &layout, infoPtr, RBN_LAYOUTCHANGED);
    3524         REBAR_Notify_NMREBAR (infoPtr, ihitBand, RBN_ENDDRAG);
    3525         infoPtr->fStatus &= ~BEGIN_DRAG_ISSUED;
     3525    REBAR_Notify_NMREBAR (infoPtr, ihitBand, RBN_ENDDRAG);
     3526    infoPtr->fStatus &= ~BEGIN_DRAG_ISSUED;
    35263527    }
    35273528
     
    35473548    /* if mouse did not move much, exit */
    35483549    if ((abs(ptsmove.x - infoPtr->dragNow.x) <= mindragx) &&
    3549         (abs(ptsmove.y - infoPtr->dragNow.y) <= mindragy)) return 0;
     3550    (abs(ptsmove.y - infoPtr->dragNow.y) <= mindragy)) return 0;
    35503551
    35513552    band1 = &infoPtr->bands[infoPtr->ihitBand-1];
     
    35543555    /* Test for valid drag case - must not be first band in row */
    35553556    if (infoPtr->dwStyle & CCS_VERT) {
    3556         if ((ptsmove.x < band2->rcBand.left) ||
    3557             (ptsmove.x > band2->rcBand.right) ||
    3558             ((infoPtr->ihitBand > 0) && (band1->iRow != band2->iRow))) {
    3559             FIXME("Cannot drag to other rows yet!!\n");
    3560         }
    3561         else {
    3562             REBAR_HandleLRDrag (infoPtr, &ptsmove);
    3563         }
     3557    if ((ptsmove.x < band2->rcBand.left) ||
     3558        (ptsmove.x > band2->rcBand.right) ||
     3559        ((infoPtr->ihitBand > 0) && (band1->iRow != band2->iRow))) {
     3560        FIXME("Cannot drag to other rows yet!!\n");
    35643561    }
    35653562    else {
    3566         if ((ptsmove.y < band2->rcBand.top) ||
    3567             (ptsmove.y > band2->rcBand.bottom) ||
    3568             ((infoPtr->ihitBand > 0) && (band1->iRow != band2->iRow))) {
    3569             FIXME("Cannot drag to other rows yet!!\n");
    3570         }
    3571         else {
    3572             REBAR_HandleLRDrag (infoPtr, &ptsmove);
    3573         }
     3563        REBAR_HandleLRDrag (infoPtr, &ptsmove);
     3564    }
     3565    }
     3566    else {
     3567    if ((ptsmove.y < band2->rcBand.top) ||
     3568        (ptsmove.y > band2->rcBand.bottom) ||
     3569        ((infoPtr->ihitBand > 0) && (band1->iRow != band2->iRow))) {
     3570        FIXME("Cannot drag to other rows yet!!\n");
     3571    }
     3572    else {
     3573        REBAR_HandleLRDrag (infoPtr, &ptsmove);
     3574    }
    35743575    }
    35753576    return 0;
     
    35883589#if 0
    35893590    if (GetWindowLongA (infoPtr->hwndSelf, GWL_STYLE) & WS_BORDER) {
    3590         ((LPRECT)lParam)->left   += GetSystemMetrics(SM_CXEDGE);
    3591         ((LPRECT)lParam)->top    += GetSystemMetrics(SM_CYEDGE);
    3592         ((LPRECT)lParam)->right  -= GetSystemMetrics(SM_CXEDGE);
    3593         ((LPRECT)lParam)->bottom -= GetSystemMetrics(SM_CYEDGE);
     3591    ((LPRECT)lParam)->left   += GetSystemMetrics(SM_CXEDGE);
     3592    ((LPRECT)lParam)->top    += GetSystemMetrics(SM_CYEDGE);
     3593    ((LPRECT)lParam)->right  -= GetSystemMetrics(SM_CXEDGE);
     3594    ((LPRECT)lParam)->bottom -= GetSystemMetrics(SM_CYEDGE);
    35943595    }
    35953596#endif
     
    36083609
    36093610    if (infoPtr != NULL) {
    3610         ERR("Strange info structure pointer *not* NULL\n");
    3611         return FALSE;
     3611    ERR("Strange info structure pointer *not* NULL\n");
     3612    return FALSE;
    36123613    }
    36133614
    36143615    if (TRACE_ON(rebar)) {
    3615         GetWindowRect(hwnd, &wnrc1);
    3616         GetClientRect(hwnd, &clrc1);
    3617         TRACE("window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d) cs=(%d,%d %dx%d)\n",
    3618               wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
    3619               clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
    3620               cs->x, cs->y, cs->cx, cs->cy);
     3616    GetWindowRect(hwnd, &wnrc1);
     3617    GetClientRect(hwnd, &clrc1);
     3618    TRACE("window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d) cs=(%d,%d %dx%d)\n",
     3619          wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom,
     3620          clrc1.left, clrc1.top, clrc1.right, clrc1.bottom,
     3621          cs->x, cs->y, cs->cx, cs->cy);
    36213622    }
    36223623
     
    36463647    /* issue WM_NOTIFYFORMAT to get unicode status of parent */
    36473648    i = SendMessageA(REBAR_GetNotifyParent (infoPtr),
    3648                      WM_NOTIFYFORMAT, hwnd, NF_QUERY);
     3649             WM_NOTIFYFORMAT, hwnd, NF_QUERY);
    36493650    if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
    3650         ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
    3651             i);
    3652         i = NFR_ANSI;
     3651    ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
     3652        i);
     3653    i = NFR_ANSI;
    36533654    }
    36543655    infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
     
    36593660
    36603661/* native does:
    3661             GetSysColor (numerous);
    3662             GetSysColorBrush (numerous) (see WM_SYSCOLORCHANGE);
    3663             GetStockObject (SYSTEM_FONT);
    3664            *SetWindowLong (hwnd, 0, info ptr);
    3665            *WM_NOTIFYFORMAT;
    3666            *SetWindowLong (hwnd, GWL_STYLE, style+0x10000001);
     3662        GetSysColor (numerous);
     3663        GetSysColorBrush (numerous) (see WM_SYSCOLORCHANGE);
     3664        GetStockObject (SYSTEM_FONT);
     3665       *SetWindowLong (hwnd, 0, info ptr);
     3666       *WM_NOTIFYFORMAT;
     3667       *SetWindowLong (hwnd, GWL_STYLE, style+0x10000001);
    36673668                                    WS_VISIBLE = 0x10000000;
    36683669                                    CCS_TOP    = 0x00000001;
    3669             SystemParametersInfo (SPI_GETNONCLIENTMETRICS...);
    3670             CreateFontIndirect (lfCaptionFont from above);
    3671             GetDC ();
    3672             SelectObject (hdc, fontabove);
    3673             GetTextMetrics (hdc, );    guessing is tmHeight
    3674             SelectObject (hdc, oldfont);
    3675             ReleaseDC ();
    3676             GetWindowRect ();
    3677             MapWindowPoints (0, parent, rectabove, 2);
    3678             GetWindowRect ();
    3679             GetClientRect ();
    3680             ClientToScreen (clientrect);
    3681             SetWindowPos (hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER);
     3670        SystemParametersInfo (SPI_GETNONCLIENTMETRICS...);
     3671        CreateFontIndirect (lfCaptionFont from above);
     3672        GetDC ();
     3673        SelectObject (hdc, fontabove);
     3674        GetTextMetrics (hdc, );    guessing is tmHeight
     3675        SelectObject (hdc, oldfont);
     3676        ReleaseDC ();
     3677        GetWindowRect ();
     3678        MapWindowPoints (0, parent, rectabove, 2);
     3679        GetWindowRect ();
     3680        GetClientRect ();
     3681        ClientToScreen (clientrect);
     3682        SetWindowPos (hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER);
    36823683 */
    36833684    return TRUE;
     
    37073708    clpt = pt;
    37083709    ScreenToClient (infoPtr->hwndSelf, &clpt);
    3709     REBAR_InternalHitTest (infoPtr, &clpt, &scrap, 
    3710                            (INT *)&nmmouse.dwItemSpec);
     3710    REBAR_InternalHitTest (infoPtr, &clpt, &scrap,
     3711               (INT *)&nmmouse.dwItemSpec);
    37113712    nmmouse.dwItemData = 0;
    37123713    nmmouse.pt = clpt;
    37133714    nmmouse.dwHitInfo = 0;
    37143715    if ((i = REBAR_Notify((NMHDR *) &nmmouse, infoPtr, NM_NCHITTEST))) {
    3715         TRACE("notify changed return value from %ld to %d\n",
    3716               ret, i);
    3717         ret = (LRESULT) i;
     3716    TRACE("notify changed return value from %ld to %d\n",
     3717          ret, i);
     3718    ret = (LRESULT) i;
    37183719    }
    37193720    TRACE("returning %ld, client point (%ld,%ld)\n", ret, clpt.x, clpt.y);
     
    37293730
    37303731    if (infoPtr->dwStyle & WS_MINIMIZE)
    3731         return 0; /* Nothing to do */
     3732    return 0; /* Nothing to do */
    37323733
    37333734    DefWindowProcA (infoPtr->hwndSelf, WM_NCPAINT, wParam, lParam);
    37343735
    37353736    if (!(hdc = GetDCEx( infoPtr->hwndSelf, 0, DCX_USESTYLE | DCX_WINDOW )))
    3736         return 0;
     3737    return 0;
    37373738
    37383739    if (infoPtr->dwStyle & WS_BORDER) {
    3739         GetWindowRect (infoPtr->hwndSelf, &rcWindow);
    3740         OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
    3741         TRACE("rect (%d,%d)-(%d,%d)\n",
    3742               rcWindow.left, rcWindow.top,
    3743               rcWindow.right, rcWindow.bottom);
    3744         /* see comments in _NCCalcSize for reason this is not done */
    3745         /* DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_RECT); */
    3746         DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_TOP | BF_BOTTOM);
     3740    GetWindowRect (infoPtr->hwndSelf, &rcWindow);
     3741    OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
     3742    TRACE("rect (%d,%d)-(%d,%d)\n",
     3743          rcWindow.left, rcWindow.top,
     3744          rcWindow.right, rcWindow.bottom);
     3745    /* see comments in _NCCalcSize for reason this is not done */
     3746    /* DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_RECT); */
     3747    DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_TOP | BF_BOTTOM);
    37473748    }
    37483749
     
    37593760
    37603761    if (lParam == NF_REQUERY) {
    3761         i = SendMessageA(REBAR_GetNotifyParent (infoPtr),
    3762                         WM_NOTIFYFORMAT, infoPtr->hwndSelf, NF_QUERY);
    3763         if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
    3764             ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
    3765                 i);
    3766             i = NFR_ANSI;
    3767         }
    3768         infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
    3769         return (LRESULT)i;
     3762    i = SendMessageA(REBAR_GetNotifyParent (infoPtr),
     3763            WM_NOTIFYFORMAT, infoPtr->hwndSelf, NF_QUERY);
     3764    if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
     3765        ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
     3766        i);
     3767        i = NFR_ANSI;
     3768    }
     3769    infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
     3770    return (LRESULT)i;
    37703771    }
    37713772    return (LRESULT)((infoPtr->bUnicode) ? NFR_UNICODE : NFR_ANSI);
     
    37843785
    37853786    TRACE("painting (%d,%d)-(%d,%d) client (%d,%d)-(%d,%d)\n",
    3786           ps.rcPaint.left, ps.rcPaint.top,
    3787           ps.rcPaint.right, ps.rcPaint.bottom,
    3788           rc.left, rc.top, rc.right, rc.bottom);
     3787      ps.rcPaint.left, ps.rcPaint.top,
     3788      ps.rcPaint.right, ps.rcPaint.bottom,
     3789      rc.left, rc.top, rc.right, rc.bottom);
    37893790
    37903791    if (ps.fErase) {
    3791         /* Erase area of paint if requested */
     3792    /* Erase area of paint if requested */
    37923793        REBAR_InternalEraseBkGnd (infoPtr, wParam, lParam, &ps.rcPaint);
    37933794    }
     
    37953796    REBAR_Refresh (infoPtr, hdc);
    37963797    if (!wParam)
    3797         EndPaint (infoPtr->hwndSelf, &ps);
     3798    EndPaint (infoPtr->hwndSelf, &ps);
    37983799    return 0;
    37993800}
     
    38143815
    38153816    if (flags == RBHT_GRABBER) {
    3816         if ((infoPtr->dwStyle & CCS_VERT) &&
    3817             !(infoPtr->dwStyle & RBS_VERTICALGRIPPER))
    3818             SetCursor (infoPtr->hcurVert);
    3819         else
    3820             SetCursor (infoPtr->hcurHorz);
     3817    if ((infoPtr->dwStyle & CCS_VERT) &&
     3818        !(infoPtr->dwStyle & RBS_VERTICALGRIPPER))
     3819        SetCursor (infoPtr->hcurVert);
     3820    else
     3821        SetCursor (infoPtr->hcurHorz);
    38213822    }
    38223823    else if (flags != RBHT_CLIENT)
    3823         SetCursor (infoPtr->hcurArrow);
     3824    SetCursor (infoPtr->hcurArrow);
    38243825
    38253826    return 0;
     
    38393840    for (i=0; i<infoPtr->uNumBands; i++) {
    38403841        lpBand = &infoPtr->bands[i];
    3841         REBAR_ValidateBand (infoPtr, lpBand);
     3842    REBAR_ValidateBand (infoPtr, lpBand);
    38423843    }
    38433844
     
    38603861      *
    38613862      * Documentation:
    3862       *  According to testing V4.71 of COMCTL32 returns the 
     3863      *  According to testing V4.71 of COMCTL32 returns the
    38633864      *  *previous* status of the redraw flag (either 0 or -1)
    38643865      *  instead of the MSDN documented value of 0 if handled
     
    38683869    BOOL oldredraw = infoPtr->DoRedraw;
    38693870
    3870     TRACE("set to %s, fStatus=%08x\n", 
    3871           (wParam) ? "TRUE" : "FALSE", infoPtr->fStatus);
     3871    TRACE("set to %s, fStatus=%08x\n",
     3872      (wParam) ? "TRUE" : "FALSE", infoPtr->fStatus);
    38723873    infoPtr->DoRedraw = (BOOL) wParam;
    38733874    if (wParam) {
    3874         if (infoPtr->fStatus & BAND_NEEDS_REDRAW) {
    3875             REBAR_MoveChildWindows (infoPtr, 0, infoPtr->uNumBands);
    3876             REBAR_ForceResize (infoPtr);
    3877             InvalidateRect (infoPtr->hwndSelf, 0, TRUE);
    3878         }
    3879         infoPtr->fStatus &= ~BAND_NEEDS_REDRAW;
     3875    if (infoPtr->fStatus & BAND_NEEDS_REDRAW) {
     3876        REBAR_MoveChildWindows (infoPtr, 0, infoPtr->uNumBands);
     3877        REBAR_ForceResize (infoPtr);
     3878        InvalidateRect (infoPtr->hwndSelf, 0, TRUE);
     3879    }
     3880    infoPtr->fStatus &= ~BAND_NEEDS_REDRAW;
    38803881    }
    38813882    return (oldredraw) ? -1 : 0;
     
    38903891    /* auto resize deadlock check */
    38913892    if (infoPtr->fStatus & AUTO_RESIZE) {
    3892         infoPtr->fStatus &= ~AUTO_RESIZE;
    3893         TRACE("AUTO_RESIZE was set, reset, fStatus=%08x lparam=%08lx\n",
    3894               infoPtr->fStatus, lParam);
    3895         return 0;
     3893    infoPtr->fStatus &= ~AUTO_RESIZE;
     3894    TRACE("AUTO_RESIZE was set, reset, fStatus=%08x lparam=%08lx\n",
     3895          infoPtr->fStatus, lParam);
     3896    return 0;
    38963897    }
    38973898
    38983899    if (infoPtr->fStatus & CREATE_RUNNING) {
    3899         /* still in CreateWindow */
    3900         RECT rcWin;
    3901 
    3902         TRACE("still in CreateWindow\n");
    3903         infoPtr->fStatus &= ~CREATE_RUNNING;
    3904         GetWindowRect ( infoPtr->hwndSelf, &rcWin);
    3905         TRACE("win rect (%d,%d)-(%d,%d)\n",
    3906               rcWin.left, rcWin.top, rcWin.right, rcWin.bottom);
    3907 
    3908         if ((lParam == 0) && (rcWin.right-rcWin.left == 0) &&
    3909             (rcWin.bottom-rcWin.top == 0)) {
    3910             /* native control seems to do this */
    3911             GetClientRect (GetParent(infoPtr->hwndSelf), &rcClient);
    3912             TRACE("sizing rebar, message and client zero, parent client (%d,%d)\n",
    3913                   rcClient.right, rcClient.bottom);
    3914         }
    3915         else {
    3916             INT cx, cy;
    3917 
    3918             cx = rcWin.right - rcWin.left;
    3919             cy = rcWin.bottom - rcWin.top;
    3920             if ((cx == LOWORD(lParam)) && (cy == HIWORD(lParam))) {
    3921                 return 0;
    3922             }
    3923 
    3924             /* do the actual WM_SIZE request */
    3925             GetClientRect (infoPtr->hwndSelf, &rcClient);
    3926             TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%d,%d)\n",
    3927                   infoPtr->calcSize.cx, infoPtr->calcSize.cy,
    3928                   LOWORD(lParam), HIWORD(lParam),
    3929                   rcClient.right, rcClient.bottom);
    3930         }
     3900    /* still in CreateWindow */
     3901    RECT rcWin;
     3902
     3903    TRACE("still in CreateWindow\n");
     3904    infoPtr->fStatus &= ~CREATE_RUNNING;
     3905    GetWindowRect ( infoPtr->hwndSelf, &rcWin);
     3906    TRACE("win rect (%d,%d)-(%d,%d)\n",
     3907          rcWin.left, rcWin.top, rcWin.right, rcWin.bottom);
     3908
     3909    if ((lParam == 0) && (rcWin.right-rcWin.left == 0) &&
     3910        (rcWin.bottom-rcWin.top == 0)) {
     3911        /* native control seems to do this */
     3912        GetClientRect (GetParent(infoPtr->hwndSelf), &rcClient);
     3913        TRACE("sizing rebar, message and client zero, parent client (%d,%d)\n",
     3914          rcClient.right, rcClient.bottom);
    39313915    }
    39323916    else {
    3933         /* Handle cases when outside of the CreateWindow process */
    3934 
    3935         GetClientRect (infoPtr->hwndSelf, &rcClient);
    3936         if ((lParam == 0) && (rcClient.right + rcClient.bottom != 0) &&
    3937             (infoPtr->dwStyle & RBS_AUTOSIZE)) {
    3938             /* on a WM_SIZE to zero and current client not zero and AUTOSIZE */
    3939             /* native seems to use the current client rect for the size      */
    3940             infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
    3941             TRACE("sizing rebar to client (%d,%d) size is zero but AUTOSIZE set\n",
    3942                   rcClient.right, rcClient.bottom);
    3943         }
    3944         else {
    3945             TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%d,%d)\n",
    3946                   infoPtr->calcSize.cx, infoPtr->calcSize.cy,
    3947                   LOWORD(lParam), HIWORD(lParam),
    3948                   rcClient.right, rcClient.bottom);
    3949         }
     3917        INT cx, cy;
     3918
     3919        cx = rcWin.right - rcWin.left;
     3920        cy = rcWin.bottom - rcWin.top;
     3921        if ((cx == LOWORD(lParam)) && (cy == HIWORD(lParam))) {
     3922        return 0;
     3923        }
     3924
     3925        /* do the actual WM_SIZE request */
     3926        GetClientRect (infoPtr->hwndSelf, &rcClient);
     3927        TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%d,%d)\n",
     3928          infoPtr->calcSize.cx, infoPtr->calcSize.cy,
     3929          LOWORD(lParam), HIWORD(lParam),
     3930          rcClient.right, rcClient.bottom);
     3931    }
     3932    }
     3933    else {
     3934    /* Handle cases when outside of the CreateWindow process */
     3935
     3936    GetClientRect (infoPtr->hwndSelf, &rcClient);
     3937    if ((lParam == 0) && (rcClient.right + rcClient.bottom != 0) &&
     3938        (infoPtr->dwStyle & RBS_AUTOSIZE)) {
     3939        /* on a WM_SIZE to zero and current client not zero and AUTOSIZE */
     3940        /* native seems to use the current client rect for the size      */
     3941        infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
     3942        TRACE("sizing rebar to client (%d,%d) size is zero but AUTOSIZE set\n",
     3943          rcClient.right, rcClient.bottom);
     3944    }
     3945    else {
     3946        TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%d,%d)\n",
     3947          infoPtr->calcSize.cx, infoPtr->calcSize.cy,
     3948          LOWORD(lParam), HIWORD(lParam),
     3949          rcClient.right, rcClient.bottom);
     3950    }
    39503951    }
    39513952
    39523953    if (infoPtr->dwStyle & RBS_AUTOSIZE) {
    3953         NMRBAUTOSIZE autosize;
    3954 
    3955         GetClientRect(infoPtr->hwndSelf, &autosize.rcTarget);
    3956         autosize.fChanged = 0;  /* ??? */
    3957         autosize.rcActual = autosize.rcTarget;  /* ??? */
    3958         REBAR_Notify((NMHDR *) &autosize, infoPtr, RBN_AUTOSIZE);
    3959         TRACE("RBN_AUTOSIZE client=(%d,%d), lp=%08lx\n",
    3960               autosize.rcTarget.right, autosize.rcTarget.bottom, lParam);
     3954    NMRBAUTOSIZE autosize;
     3955
     3956    GetClientRect(infoPtr->hwndSelf, &autosize.rcTarget);
     3957    autosize.fChanged = 0;  /* ??? */
     3958    autosize.rcActual = autosize.rcTarget;  /* ??? */
     3959    REBAR_Notify((NMHDR *) &autosize, infoPtr, RBN_AUTOSIZE);
     3960    TRACE("RBN_AUTOSIZE client=(%d,%d), lp=%08lx\n",
     3961          autosize.rcTarget.right, autosize.rcTarget.bottom, lParam);
    39613962    }
    39623963
    39633964    if ((infoPtr->calcSize.cx != rcClient.right) ||
    3964         (infoPtr->calcSize.cy != rcClient.bottom))
    3965         infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
     3965    (infoPtr->calcSize.cy != rcClient.bottom))
     3966    infoPtr->fStatus |= BAND_NEEDS_LAYOUT;
    39663967
    39673968    REBAR_Layout (infoPtr, &rcClient, TRUE, TRUE);
     
    39783979
    39793980    TRACE("current style=%08lx, styleOld=%08lx, style being set to=%08lx\n",
    3980           infoPtr->dwStyle, ss->styleOld, ss->styleNew);
     3981      infoPtr->dwStyle, ss->styleOld, ss->styleNew);
    39813982    infoPtr->dwStyle = ss->styleNew;
    39823983
     
    39903991    REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
    39913992
    3992     TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n", 
    3993           hwnd, uMsg, /* SPY_GetMsgName(uMsg), */ wParam, lParam);
     3993    TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n",
     3994      hwnd, uMsg, /* SPY_GetMsgName(uMsg), */ wParam, lParam);
    39943995    if (!infoPtr && (uMsg != WM_NCCREATE))
    3995             return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     3996        return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    39963997    switch (uMsg)
    39973998    {
    3998 /*      case RB_BEGINDRAG: */
    3999 
    4000         case RB_DELETEBAND:
    4001             return REBAR_DeleteBand (infoPtr, wParam, lParam);
    4002 
    4003 /*      case RB_DRAGMOVE: */
    4004 /*      case RB_ENDDRAG: */
    4005 
    4006         case RB_GETBANDBORDERS:
    4007             return REBAR_GetBandBorders (infoPtr, wParam, lParam);
    4008 
    4009         case RB_GETBANDCOUNT:
    4010             return REBAR_GetBandCount (infoPtr);
    4011 
    4012         case RB_GETBANDINFO:    /* obsoleted after IE3, but we have to
    4013                                    support it anyway. */
    4014         case RB_GETBANDINFOA:
    4015             return REBAR_GetBandInfoA (infoPtr, wParam, lParam);
    4016 
    4017         case RB_GETBANDINFOW:
    4018             return REBAR_GetBandInfoW (infoPtr, wParam, lParam);
    4019 
    4020         case RB_GETBARHEIGHT:
    4021             return REBAR_GetBarHeight (infoPtr, wParam, lParam);
    4022 
    4023         case RB_GETBARINFO:
    4024             return REBAR_GetBarInfo (infoPtr, wParam, lParam);
    4025 
    4026         case RB_GETBKCOLOR:
    4027             return REBAR_GetBkColor (infoPtr);
    4028 
    4029 /*      case RB_GETCOLORSCHEME: */
    4030 /*      case RB_GETDROPTARGET: */
    4031 
    4032         case RB_GETPALETTE:
    4033             return REBAR_GetPalette (infoPtr, wParam, lParam);
    4034 
    4035         case RB_GETRECT:
    4036             return REBAR_GetRect (infoPtr, wParam, lParam);
    4037 
    4038         case RB_GETROWCOUNT:
    4039             return REBAR_GetRowCount (infoPtr);
    4040 
    4041         case RB_GETROWHEIGHT:
    4042             return REBAR_GetRowHeight (infoPtr, wParam, lParam);
    4043 
    4044         case RB_GETTEXTCOLOR:
    4045             return REBAR_GetTextColor (infoPtr);
    4046 
    4047         case RB_GETTOOLTIPS:
    4048             return REBAR_GetToolTips (infoPtr);
    4049 
    4050         case RB_GETUNICODEFORMAT:
    4051             return REBAR_GetUnicodeFormat (infoPtr);
    4052 
    4053         case CCM_GETVERSION:
    4054             return REBAR_GetVersion (infoPtr);
    4055 
    4056         case RB_HITTEST:
    4057             return REBAR_HitTest (infoPtr, wParam, lParam);
    4058 
    4059         case RB_IDTOINDEX:
    4060             return REBAR_IdToIndex (infoPtr, wParam, lParam);
    4061 
    4062         case RB_INSERTBANDA:
    4063             return REBAR_InsertBandA (infoPtr, wParam, lParam);
    4064 
    4065         case RB_INSERTBANDW:
    4066             return REBAR_InsertBandW (infoPtr, wParam, lParam);
    4067 
    4068         case RB_MAXIMIZEBAND:
    4069             return REBAR_MaximizeBand (infoPtr, wParam, lParam);
    4070 
    4071         case RB_MINIMIZEBAND:
    4072             return REBAR_MinimizeBand (infoPtr, wParam, lParam);
    4073 
    4074         case RB_MOVEBAND:
    4075             return REBAR_MoveBand (infoPtr, wParam, lParam);
    4076 
    4077         case RB_SETBANDINFOA:
    4078             return REBAR_SetBandInfoA (infoPtr, wParam, lParam);
    4079 
    4080         case RB_SETBANDINFOW:
    4081             return REBAR_SetBandInfoW (infoPtr, wParam, lParam);
    4082 
    4083         case RB_SETBARINFO:
    4084             return REBAR_SetBarInfo (infoPtr, wParam, lParam);
    4085 
    4086         case RB_SETBKCOLOR:
    4087             return REBAR_SetBkColor (infoPtr, wParam, lParam);
    4088 
    4089 /*      case RB_SETCOLORSCHEME: */
    4090 /*      case RB_SETPALETTE: */
    4091 /*          return REBAR_GetPalette (infoPtr, wParam, lParam); */
    4092 
    4093         case RB_SETPARENT:
    4094             return REBAR_SetParent (infoPtr, wParam, lParam);
    4095 
    4096         case RB_SETTEXTCOLOR:
    4097             return REBAR_SetTextColor (infoPtr, wParam, lParam);
    4098 
    4099 /*      case RB_SETTOOLTIPS: */
    4100 
    4101         case RB_SETUNICODEFORMAT:
    4102             return REBAR_SetUnicodeFormat (infoPtr, wParam);
    4103 
    4104         case CCM_SETVERSION:
    4105             return REBAR_SetVersion (infoPtr, (INT)wParam);
    4106 
    4107         case RB_SHOWBAND:
    4108             return REBAR_ShowBand (infoPtr, wParam, lParam);
    4109 
    4110         case RB_SIZETORECT:
    4111             return REBAR_SizeToRect (infoPtr, wParam, lParam);
     3999/*  case RB_BEGINDRAG: */
     4000
     4001    case RB_DELETEBAND:
     4002        return REBAR_DeleteBand (infoPtr, wParam, lParam);
     4003
     4004/*  case RB_DRAGMOVE: */
     4005/*  case RB_ENDDRAG: */
     4006
     4007    case RB_GETBANDBORDERS:
     4008        return REBAR_GetBandBorders (infoPtr, wParam, lParam);
     4009
     4010    case RB_GETBANDCOUNT:
     4011        return REBAR_GetBandCount (infoPtr);
     4012
     4013    case RB_GETBANDINFO:    /* obsoleted after IE3, but we have to
     4014                   support it anyway. */
     4015    case RB_GETBANDINFOA:
     4016        return REBAR_GetBandInfoA (infoPtr, wParam, lParam);
     4017
     4018    case RB_GETBANDINFOW:
     4019        return REBAR_GetBandInfoW (infoPtr, wParam, lParam);
     4020
     4021    case RB_GETBARHEIGHT:
     4022        return REBAR_GetBarHeight (infoPtr, wParam, lParam);
     4023
     4024    case RB_GETBARINFO:
     4025        return REBAR_GetBarInfo (infoPtr, wParam, lParam);
     4026
     4027    case RB_GETBKCOLOR:
     4028        return REBAR_GetBkColor (infoPtr);
     4029
     4030/*  case RB_GETCOLORSCHEME: */
     4031/*  case RB_GETDROPTARGET: */
     4032
     4033    case RB_GETPALETTE:
     4034        return REBAR_GetPalette (infoPtr, wParam, lParam);
     4035
     4036    case RB_GETRECT:
     4037        return REBAR_GetRect (infoPtr, wParam, lParam);
     4038
     4039    case RB_GETROWCOUNT:
     4040        return REBAR_GetRowCount (infoPtr);
     4041
     4042    case RB_GETROWHEIGHT:
     4043        return REBAR_GetRowHeight (infoPtr, wParam, lParam);
     4044
     4045    case RB_GETTEXTCOLOR:
     4046        return REBAR_GetTextColor (infoPtr);
     4047
     4048    case RB_GETTOOLTIPS:
     4049        return REBAR_GetToolTips (infoPtr);
     4050
     4051    case RB_GETUNICODEFORMAT:
     4052        return REBAR_GetUnicodeFormat (infoPtr);
     4053
     4054    case CCM_GETVERSION:
     4055        return REBAR_GetVersion (infoPtr);
     4056
     4057    case RB_HITTEST:
     4058        return REBAR_HitTest (infoPtr, wParam, lParam);
     4059
     4060    case RB_IDTOINDEX:
     4061        return REBAR_IdToIndex (infoPtr, wParam, lParam);
     4062
     4063    case RB_INSERTBANDA:
     4064        return REBAR_InsertBandA (infoPtr, wParam, lParam);
     4065
     4066    case RB_INSERTBANDW:
     4067        return REBAR_InsertBandW (infoPtr, wParam, lParam);
     4068
     4069    case RB_MAXIMIZEBAND:
     4070        return REBAR_MaximizeBand (infoPtr, wParam, lParam);
     4071
     4072    case RB_MINIMIZEBAND:
     4073        return REBAR_MinimizeBand (infoPtr, wParam, lParam);
     4074
     4075    case RB_MOVEBAND:
     4076        return REBAR_MoveBand (infoPtr, wParam, lParam);
     4077
     4078    case RB_SETBANDINFOA:
     4079        return REBAR_SetBandInfoA (infoPtr, wParam, lParam);
     4080
     4081    case RB_SETBANDINFOW:
     4082        return REBAR_SetBandInfoW (infoPtr, wParam, lParam);
     4083
     4084    case RB_SETBARINFO:
     4085        return REBAR_SetBarInfo (infoPtr, wParam, lParam);
     4086
     4087    case RB_SETBKCOLOR:
     4088        return REBAR_SetBkColor (infoPtr, wParam, lParam);
     4089
     4090/*  case RB_SETCOLORSCHEME: */
     4091/*  case RB_SETPALETTE: */
     4092/*      return REBAR_GetPalette (infoPtr, wParam, lParam); */
     4093
     4094    case RB_SETPARENT:
     4095        return REBAR_SetParent (infoPtr, wParam, lParam);
     4096
     4097    case RB_SETTEXTCOLOR:
     4098        return REBAR_SetTextColor (infoPtr, wParam, lParam);
     4099
     4100/*  case RB_SETTOOLTIPS: */
     4101
     4102    case RB_SETUNICODEFORMAT:
     4103        return REBAR_SetUnicodeFormat (infoPtr, wParam);
     4104
     4105    case CCM_SETVERSION:
     4106        return REBAR_SetVersion (infoPtr, (INT)wParam);
     4107
     4108    case RB_SHOWBAND:
     4109        return REBAR_ShowBand (infoPtr, wParam, lParam);
     4110
     4111    case RB_SIZETORECT:
     4112        return REBAR_SizeToRect (infoPtr, wParam, lParam);
    41124113
    41134114
    41144115/*    Messages passed to parent */
    4115         case WM_COMMAND:
    4116         case WM_DRAWITEM:
    4117         case WM_NOTIFY:
    4118             if (infoPtr->NtfUnicode)
    4119                 return SendMessageW (REBAR_GetNotifyParent (infoPtr),
    4120                                      uMsg, wParam, lParam);
    4121             else
    4122                 return SendMessageA (REBAR_GetNotifyParent (infoPtr),
    4123                                      uMsg, wParam, lParam);
     4116    case WM_COMMAND:
     4117    case WM_DRAWITEM:
     4118    case WM_NOTIFY:
     4119        if (infoPtr->NtfUnicode)
     4120        return SendMessageW (REBAR_GetNotifyParent (infoPtr),
     4121                     uMsg, wParam, lParam);
     4122        else
     4123        return SendMessageA (REBAR_GetNotifyParent (infoPtr),
     4124                     uMsg, wParam, lParam);
    41244125
    41254126
    41264127/*      case WM_CHARTOITEM:     supported according to ControlSpy */
    41274128
    4128         case WM_CREATE:
    4129             return REBAR_Create (infoPtr, wParam, lParam);
    4130 
    4131         case WM_DESTROY:
    4132             return REBAR_Destroy (infoPtr, wParam, lParam);
     4129    case WM_CREATE:
     4130        return REBAR_Create (infoPtr, wParam, lParam);
     4131
     4132    case WM_DESTROY:
     4133        return REBAR_Destroy (infoPtr, wParam, lParam);
    41334134
    41344135        case WM_ERASEBKGND:
    4135             return REBAR_EraseBkGnd (infoPtr, wParam, lParam);
    4136 
    4137         case WM_GETFONT:
    4138             return REBAR_GetFont (infoPtr, wParam, lParam);
     4136        return REBAR_EraseBkGnd (infoPtr, wParam, lParam);
     4137
     4138    case WM_GETFONT:
     4139        return REBAR_GetFont (infoPtr, wParam, lParam);
    41394140
    41404141/*      case WM_LBUTTONDBLCLK:  supported according to ControlSpy */
    41414142
    4142         case WM_LBUTTONDOWN:
    4143             return REBAR_LButtonDown (infoPtr, wParam, lParam);
    4144 
    4145         case WM_LBUTTONUP:
    4146             return REBAR_LButtonUp (infoPtr, wParam, lParam);
     4143    case WM_LBUTTONDOWN:
     4144        return REBAR_LButtonDown (infoPtr, wParam, lParam);
     4145
     4146    case WM_LBUTTONUP:
     4147        return REBAR_LButtonUp (infoPtr, wParam, lParam);
    41474148
    41484149/*      case WM_MEASUREITEM:    supported according to ControlSpy */
    41494150
    4150         case WM_MOUSEMOVE:
    4151             return REBAR_MouseMove (infoPtr, wParam, lParam);
    4152 
    4153         case WM_NCCALCSIZE:
    4154             return REBAR_NCCalcSize (infoPtr, wParam, lParam);
     4151    case WM_MOUSEMOVE:
     4152        return REBAR_MouseMove (infoPtr, wParam, lParam);
     4153
     4154    case WM_NCCALCSIZE:
     4155        return REBAR_NCCalcSize (infoPtr, wParam, lParam);
    41554156
    41564157        case WM_NCCREATE:
    4157             return REBAR_NCCreate (hwnd, wParam, lParam);
     4158        return REBAR_NCCreate (hwnd, wParam, lParam);
    41584159
    41594160        case WM_NCHITTEST:
    4160             return REBAR_NCHitTest (infoPtr, wParam, lParam);
    4161 
    4162         case WM_NCPAINT:
    4163             return REBAR_NCPaint (infoPtr, wParam, lParam);
     4161        return REBAR_NCHitTest (infoPtr, wParam, lParam);
     4162
     4163    case WM_NCPAINT:
     4164        return REBAR_NCPaint (infoPtr, wParam, lParam);
    41644165
    41654166        case WM_NOTIFYFORMAT:
    4166             return REBAR_NotifyFormat (infoPtr, wParam, lParam);
    4167 
    4168         case WM_PAINT:
    4169             return REBAR_Paint (infoPtr, wParam, lParam);
     4167        return REBAR_NotifyFormat (infoPtr, wParam, lParam);
     4168
     4169    case WM_PAINT:
     4170        return REBAR_Paint (infoPtr, wParam, lParam);
    41704171
    41714172/*      case WM_PALETTECHANGED: supported according to ControlSpy */
     
    41754176/*      case WM_RBUTTONUP:      supported according to ControlSpy */
    41764177
    4177         case WM_SETCURSOR:
    4178             return REBAR_SetCursor (infoPtr, wParam, lParam);
    4179 
    4180         case WM_SETFONT:
    4181             return REBAR_SetFont (infoPtr, wParam, lParam);
     4178    case WM_SETCURSOR:
     4179        return REBAR_SetCursor (infoPtr, wParam, lParam);
     4180
     4181    case WM_SETFONT:
     4182        return REBAR_SetFont (infoPtr, wParam, lParam);
    41824183
    41834184        case WM_SETREDRAW:
    4184             return REBAR_SetRedraw (infoPtr, wParam, lParam);
    4185 
    4186         case WM_SIZE:
    4187             return REBAR_Size (infoPtr, wParam, lParam);
     4185        return REBAR_SetRedraw (infoPtr, wParam, lParam);
     4186
     4187    case WM_SIZE:
     4188        return REBAR_Size (infoPtr, wParam, lParam);
    41884189
    41894190        case WM_STYLECHANGED:
    4190             return REBAR_StyleChanged (infoPtr, wParam, lParam);
     4191        return REBAR_StyleChanged (infoPtr, wParam, lParam);
    41914192
    41924193/*      case WM_SYSCOLORCHANGE: supported according to ControlSpy */
    41934194/*      "Applications that have brushes using the existing system colors
    4194          should delete those brushes and recreate them using the new 
     4195         should delete those brushes and recreate them using the new
    41954196         system colors."  per MSDN                                */
    41964197
    41974198/*      case WM_VKEYTOITEM:     supported according to ControlSpy */
    4198 /*      case WM_WININICHANGE: */
    4199 
    4200         default:
    4201             if (uMsg >= WM_USER)
    4202                 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
    4203                      uMsg, wParam, lParam);
     4199/*  case WM_WININICHANGE: */
     4200
     4201    default:
     4202        if (uMsg >= WM_USER)
     4203        ERR("unknown msg %04x wp=%08x lp=%08lx\n",
     4204             uMsg, wParam, lParam);
    42044205#ifdef __WIN32OS2__
    42054206            return defComCtl32ProcA (hwnd, uMsg, wParam, lParam);
    42064207#else
    4207             return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     4208        return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    42084209#endif
    42094210    }
     
    42254226    wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
    42264227    wndClass.lpszClassName = REBARCLASSNAMEA;
    4227  
     4228
    42284229    RegisterClassA (&wndClass);
    42294230
  • trunk/src/comctl32/status.c

    r6391 r6644  
     1/* $Id: status.c,v 1.23 2001-09-05 12:05:02 bird Exp $ */
    12/*
    23 * Interface code to StatusWindow widget/control
     
    2627typedef struct
    2728{
    28     INT x;
    29     INT style;
    30     RECT        bound;
    31     LPWSTR      text;
     29    INT x;
     30    INT style;
     31    RECT    bound;
     32    LPWSTR  text;
    3233    HICON     hIcon;
    3334} STATUSWINDOWPART;
     
    4849    COLORREF            clrBk;     /* background color */
    4950    BOOL              bUnicode;  /* unicode flag */
    50     STATUSWINDOWPART    part0;     /* simple window */
     51    STATUSWINDOWPART    part0;     /* simple window */
    5152    STATUSWINDOWPART   *parts;
    5253} STATUSWINDOWINFO;
     
    9394    SelectObject (hdc, GetSysColorPen (COLOR_3DSHADOW));
    9495    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);
     96    MoveToEx (hdc, pt.x - i, pt.y, NULL);
     97    LineTo (hdc, pt.x, pt.y - i);
     98
     99    MoveToEx (hdc, pt.x - i-1, pt.y, NULL);
     100    LineTo (hdc, pt.x, pt.y - i-1);
    100101    }
    101102
    102103    SelectObject (hdc, GetSysColorPen (COLOR_3DHIGHLIGHT));
    103104    for (i = 3; i < 13; i += 4) {
    104         MoveToEx (hdc, pt.x - i, pt.y, NULL);
    105         LineTo (hdc, pt.x, pt.y - i);
     105    MoveToEx (hdc, pt.x - i, pt.y, NULL);
     106    LineTo (hdc, pt.x, pt.y - i);
    106107    }
    107108
     
    110111
    111112
    112 static void 
     113static void
    113114STATUSBAR_DrawPart (HDC hdc, STATUSWINDOWPART *part)
    114115{
     
    126127    /* draw the icon */
    127128    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;
     129    INT cy = r.bottom - r.top;
     130
     131    r.left += 2;
     132    DrawIconEx (hdc, r.left, r.top, part->hIcon, cy, cy, 0, 0, DI_NORMAL);
     133    r.left += cy;
    133134    }
    134135
     
    139140      UINT align = DT_LEFT;
    140141      if (*p == L'\t') {
    141         p++;
    142         align = DT_CENTER;
    143 
    144         if (*p == L'\t') {
    145           p++;
    146           align = DT_RIGHT;
    147         }
     142    p++;
     143    align = DT_CENTER;
     144
     145    if (*p == L'\t') {
     146      p++;
     147      align = DT_RIGHT;
     148    }
    148149      }
    149150      r.left += 3;
     
    151152      DrawTextW (hdc, p, -1, &r, align|DT_VCENTER|DT_SINGLELINE);
    152153      if (oldbkmode != TRANSPARENT)
    153         SetBkMode(hdc, oldbkmode);
     154    SetBkMode(hdc, oldbkmode);
    154155    }
    155156}
     
    169170
    170171    if (infoPtr->clrBk != CLR_DEFAULT)
    171         hbrBk = CreateSolidBrush (infoPtr->clrBk);
     172    hbrBk = CreateSolidBrush (infoPtr->clrBk);
    172173    else
    173         hbrBk = GetSysColorBrush (COLOR_3DFACE);
     174    hbrBk = GetSysColorBrush (COLOR_3DFACE);
    174175    FillRect(hdc, &part->bound, hbrBk);
    175176
     
    177178
    178179    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);
     180    DRAWITEMSTRUCT dis;
     181
     182    dis.CtlID = GetWindowLongA (hwnd, GWL_ID);
     183    dis.itemID = itemID;
     184    dis.hwndItem = hwnd;
     185    dis.hDC = hdc;
     186    dis.rcItem = part->bound;
     187    dis.itemData = (INT)part->text;
     188    SendMessageA (GetParent (hwnd), WM_DRAWITEM,
     189        (WPARAM)dis.CtlID, (LPARAM)&dis);
    189190    } else
    190         STATUSBAR_DrawPart (hdc, part);
     191    STATUSBAR_DrawPart (hdc, part);
    191192
    192193    SelectObject (hdc, hOldFont);
    193194
    194195    if (infoPtr->clrBk != CLR_DEFAULT)
    195         DeleteObject (hbrBk);
     196    DeleteObject (hbrBk);
    196197
    197198    if (GetWindowLongA (hwnd, GWL_STYLE) & SBARS_SIZEGRIP) {
    198         RECT rect;
    199 
    200         GetClientRect (hwnd, &rect);
    201         STATUSBAR_DrawSizeGrip (hdc, &rect);
     199    RECT rect;
     200
     201    GetClientRect (hwnd, &rect);
     202    STATUSBAR_DrawSizeGrip (hdc, &rect);
    202203    }
    203204}
     
    221222
    222223    if (infoPtr->clrBk != CLR_DEFAULT)
    223         hbrBk = CreateSolidBrush (infoPtr->clrBk);
     224    hbrBk = CreateSolidBrush (infoPtr->clrBk);
    224225    else
    225         hbrBk = GetSysColorBrush (COLOR_3DFACE);
     226    hbrBk = GetSysColorBrush (COLOR_3DFACE);
    226227    FillRect(hdc, &rect, hbrBk);
    227228
     
    229230
    230231    if (infoPtr->simple) {
    231         STATUSBAR_RefreshPart (infoPtr, hwnd, &infoPtr->part0, hdc, 0);
     232    STATUSBAR_RefreshPart (infoPtr, hwnd, &infoPtr->part0, hdc, 0);
    232233    } 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         }
     234    for (i = 0; i < infoPtr->numParts; i++) {
     235        if (infoPtr->parts[i].style & SBT_OWNERDRAW) {
     236        DRAWITEMSTRUCT dis;
     237
     238        dis.CtlID = GetWindowLongA (hwnd, GWL_ID);
     239        dis.itemID = i;
     240        dis.hwndItem = hwnd;
     241        dis.hDC = hdc;
     242        dis.rcItem = infoPtr->parts[i].bound;
     243        dis.itemData = (INT)infoPtr->parts[i].text;
     244        SendMessageA (GetParent (hwnd), WM_DRAWITEM,
     245            (WPARAM)dis.CtlID, (LPARAM)&dis);
     246        } else
     247        STATUSBAR_RefreshPart (infoPtr, hwnd, &infoPtr->parts[i], hdc, i);
     248    }
    248249    }
    249250
     
    251252
    252253    if (infoPtr->clrBk != CLR_DEFAULT)
    253         DeleteObject (hbrBk);
     254    DeleteObject (hbrBk);
    254255
    255256    if (GetWindowLongA(hwnd, GWL_STYLE) & SBARS_SIZEGRIP)
    256         STATUSBAR_DrawSizeGrip (hdc, &rect);
     257    STATUSBAR_DrawSizeGrip (hdc, &rect);
    257258
    258259    return TRUE;
     
    265266    STATUSWINDOWPART *part;
    266267    RECT rect, *r;
    267     int i;
     268    int i;
    268269
    269270    /* get our window size */
     
    278279    /* set bounds for non-simple rectangles */
    279280    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         }
     281    part = &infoPtr->parts[i];
     282    r = &infoPtr->parts[i].bound;
     283    r->top = rect.top;
     284    r->bottom = rect.bottom;
     285    if (i == 0)
     286        r->left = 0;
     287    else
     288        r->left = infoPtr->parts[i-1].bound.right + HORZ_GAP;
     289    if (part->x == -1)
     290        r->right = rect.right;
     291    else
     292        r->right = part->x;
     293
     294    if (infoPtr->hwndToolTip) {
     295        TTTOOLINFOA ti;
     296
     297        ti.cbSize = sizeof(TTTOOLINFOA);
     298        ti.hwnd = hwnd;
     299        ti.uId = i;
     300        ti.rect = *r;
     301        SendMessageA (infoPtr->hwndToolTip, TTM_NEWTOOLRECTA,
     302                0, (LPARAM)&ti);
     303    }
    303304    }
    304305}
     
    307308static VOID
    308309STATUSBAR_RelayEvent (HWND hwndTip, HWND hwndMsg, UINT uMsg,
    309                       WPARAM wParam, LPARAM lParam)
     310              WPARAM wParam, LPARAM lParam)
    310311{
    311312    MSG msg;
     
    345346    TRACE("%d\n", nPart);
    346347    if ((nPart < -1) || (nPart >= infoPtr->numParts))
    347         return 0;
     348    return 0;
    348349
    349350    if (nPart == -1)
     
    365366    parts = (LPINT) lParam;
    366367    if (parts) {
    367         for (i = 0; i < num_parts; i++) {
    368             parts[i] = infoPtr->parts[i].x;
    369         }
     368    for (i = 0; i < num_parts; i++) {
     369        parts[i] = infoPtr->parts[i].x;
     370    }
    370371    }
    371372    return (infoPtr->numParts);
     
    376377STATUSBAR_GetRect (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
    377378{
    378     int nPart;
     379    int nPart;
    379380    LPRECT  rect;
    380381
     
    383384    rect = (LPRECT) lParam;
    384385    if (infoPtr->simple)
    385         *rect = infoPtr->part0.bound;
     386    *rect = infoPtr->part0.bound;
    386387    else
    387         *rect = infoPtr->parts[nPart].bound;
     388    *rect = infoPtr->parts[nPart].bound;
    388389    return TRUE;
    389390}
     
    400401    TRACE("part %d\n", nPart);
    401402    if (infoPtr->simple)
    402         part = &infoPtr->part0;
     403    part = &infoPtr->part0;
    403404    else
    404405#ifdef __WIN32OS2__
    405406    {
    406407        if (nPart >= infoPtr->numParts)
    407             return FALSE;
    408         part = &infoPtr->parts[nPart];
     408        return FALSE;
     409    part = &infoPtr->parts[nPart];
    409410    }
    410411#else
    411         part = &infoPtr->parts[nPart];
     412    part = &infoPtr->parts[nPart];
    412413#endif
    413414
    414415    if (part->style & SBT_OWNERDRAW)
    415         result = (LRESULT)part->text;
     416    result = (LRESULT)part->text;
    416417    else {
    417418        DWORD len = part->text ? WideCharToMultiByte( CP_ACP, 0, part->text, -1,
     
    435436    TRACE("part %d\n", nPart);
    436437    if (infoPtr->simple)
    437         part = &infoPtr->part0;
     438    part = &infoPtr->part0;
    438439    else
    439440#ifdef __WIN32OS2__
    440441    {
    441442        if (nPart >= infoPtr->numParts)
    442             return FALSE;
    443         part = &infoPtr->parts[nPart];
     443        return FALSE;
     444    part = &infoPtr->parts[nPart];
    444445    }
    445446#else
    446         part = &infoPtr->parts[nPart];
     447    part = &infoPtr->parts[nPart];
    447448#endif
    448449
    449450    if (part->style & SBT_OWNERDRAW)
    450         result = (LRESULT)part->text;
     451    result = (LRESULT)part->text;
    451452    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);
     453    result = part->text ? strlenW (part->text) : 0;
     454    result |= (part->style << 16);
     455    if (part->text && lParam)
     456        strcpyW ((LPWSTR)lParam, part->text);
    456457    }
    457458    return result;
     
    471472
    472473    if (infoPtr->simple)
    473         part = &infoPtr->part0;
     474    part = &infoPtr->part0;
    474475    else
    475476#ifdef __WIN32OS2__
    476477    {
    477478        if (nPart >= infoPtr->numParts)
    478             return FALSE;
    479         part = &infoPtr->parts[nPart];
     479        return FALSE;
     480    part = &infoPtr->parts[nPart];
    480481    }
    481482#else
    482         part = &infoPtr->parts[nPart];
     483    part = &infoPtr->parts[nPart];
    483484#endif
    484485
    485486    if (part->text)
    486         result = strlenW(part->text);
     487    result = strlenW(part->text);
    487488    else
    488         result = 0;
     489    result = 0;
    489490
    490491    result |= (part->style << 16);
     
    526527        buf[0]=0;
    527528
    528         if (infoPtr->hwndToolTip) {
    529             TTTOOLINFOW ti;
    530             ti.cbSize = sizeof(TTTOOLINFOW);
    531             ti.hwnd = hwnd;
    532             ti.uId = LOWORD(wParam);
     529    if (infoPtr->hwndToolTip) {
     530        TTTOOLINFOW ti;
     531        ti.cbSize = sizeof(TTTOOLINFOW);
     532        ti.hwnd = hwnd;
     533        ti.uId = LOWORD(wParam);
    533534            ti.lpszText = buf;
    534             SendMessageW(infoPtr->hwndToolTip, TTM_GETTEXTW, 0, (LPARAM)&ti);
    535         }
    536         lstrcpynW(tip, buf, HIWORD(wParam));
     535        SendMessageW(infoPtr->hwndToolTip, TTM_GETTEXTW, 0, (LPARAM)&ti);
     536    }
     537    lstrcpynW(tip, buf, HIWORD(wParam));
    537538    }
    538539
     
    575576
    576577    if ((nPart < -1) || (nPart >= infoPtr->numParts))
    577         return FALSE;
     578    return FALSE;
    578579
    579580    TRACE("setting part %d, icon %lx\n",nPart,lParam);
    580581
    581582    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)
     583    if (infoPtr->part0.hIcon == (HICON)lParam) /* same as - no redraw */
     584        return TRUE;
     585    infoPtr->part0.hIcon = (HICON)lParam;
     586    if (infoPtr->simple)
    586587            InvalidateRect(hwnd, &infoPtr->part0.bound, FALSE);
    587588    } 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))
     589    if (infoPtr->parts[nPart].hIcon == (HICON)lParam) /* same as - no redraw */
     590        return TRUE;
     591
     592    infoPtr->parts[nPart].hIcon = (HICON)lParam;
     593    if (!(infoPtr->simple))
    593594            InvalidateRect(hwnd, &infoPtr->parts[nPart].bound, FALSE);
    594595    }
     
    603604    TRACE("\n");
    604605    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);
     606    HWND parent = GetParent (hwnd);
     607    INT  width, x, y;
     608    RECT parent_rect;
     609
     610    GetClientRect (parent, &parent_rect);
     611    infoPtr->height = (INT)wParam + VERT_BORDER;
     612    width = parent_rect.right - parent_rect.left;
     613    x = parent_rect.left;
     614    y = parent_rect.bottom - infoPtr->height;
     615    MoveWindow (hwnd, parent_rect.left,
     616              parent_rect.bottom - infoPtr->height,
     617              width, infoPtr->height, TRUE);
     618    STATUSBAR_SetPartBounds (infoPtr, hwnd);
    618619    }
    619620
     
    627628    STATUSWINDOWPART *tmp;
    628629    LPINT parts;
    629     int i;
    630     int oldNumParts;
     630    int i;
     631    int oldNumParts;
    631632
    632633    TRACE("(%d,%p)\n",wParam,(LPVOID)lParam);
     
    634635    /* FIXME: should return FALSE sometimes (maybe when wParam == 0 ?) */
    635636    if (infoPtr->simple)
    636         infoPtr->simple = FALSE;
     637    infoPtr->simple = FALSE;
    637638
    638639    oldNumParts = infoPtr->numParts;
     
    640641    parts = (LPINT) lParam;
    641642    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         }
     643    for (i = infoPtr->numParts ; i < oldNumParts; i++) {
     644        if (infoPtr->parts[i].text && !(infoPtr->parts[i].style & SBT_OWNERDRAW))
     645        COMCTL32_Free (infoPtr->parts[i].text);
     646    }
    646647    }
    647648    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;
     649    tmp = COMCTL32_Alloc (sizeof(STATUSWINDOWPART) * infoPtr->numParts);
     650    for (i = 0; i < oldNumParts; i++) {
     651        tmp[i] = infoPtr->parts[i];
     652    }
     653    if (infoPtr->parts)
     654        COMCTL32_Free (infoPtr->parts);
     655    infoPtr->parts = tmp;
    655656    }
    656657    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    
     658    for (i=0;i<oldNumParts;i++)
     659        if (infoPtr->parts[i].x != parts[i])
     660        break;
     661    if (i==oldNumParts) /* Unchanged? no need to redraw! */
     662        return TRUE;
     663    }
     664
    664665    for (i = 0; i < infoPtr->numParts; i++)
    665         infoPtr->parts[i].x = parts[i];
     666    infoPtr->parts[i].x = parts[i];
    666667
    667668    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         }
     669    INT nTipCount =
     670        SendMessageA (infoPtr->hwndToolTip, TTM_GETTOOLCOUNT, 0, 0);
     671
     672    if (nTipCount < infoPtr->numParts) {
     673        /* add tools */
     674        TTTOOLINFOA ti;
     675        INT i;
     676
     677        ZeroMemory (&ti, sizeof(TTTOOLINFOA));
     678        ti.cbSize = sizeof(TTTOOLINFOA);
     679        ti.hwnd = hwnd;
     680        for (i = nTipCount; i < infoPtr->numParts; i++) {
     681        TRACE("add tool %d\n", i);
     682        ti.uId = i;
     683        SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
     684                0, (LPARAM)&ti);
     685        }
     686    }
     687    else if (nTipCount > infoPtr->numParts) {
     688        /* delete tools */
     689        INT i;
     690
     691        for (i = nTipCount - 1; i >= infoPtr->numParts; i--) {
     692        FIXME("delete tool %d\n", i);
     693        }
     694    }
    694695    }
    695696    STATUSBAR_SetPartBounds (infoPtr, hwnd);
     
    703704{
    704705    STATUSWINDOWPART *part=NULL;
    705     int nPart;
    706     int style;
     706    int nPart;
     707    int style;
    707708    LPSTR text;
    708     BOOL        changed = FALSE;
     709    BOOL    changed = FALSE;
    709710
    710711    text = (LPSTR) lParam;
     
    715716
    716717    if (nPart==255)
    717         part = &infoPtr->part0;
     718    part = &infoPtr->part0;
    718719    else if (!infoPtr->simple && infoPtr->parts!=NULL)
    719720#ifdef __WIN32OS2__
    720721    {
    721722        if (nPart >= infoPtr->numParts)
    722             return FALSE;
    723         part = &infoPtr->parts[nPart];
     723        return FALSE;
     724    part = &infoPtr->parts[nPart];
    724725    }
    725726#else
    726         part = &infoPtr->parts[nPart];
     727    part = &infoPtr->parts[nPart];
    727728#endif
    728729    if (!part) return FALSE;
    729730
    730731    if (part->style != style)
    731         changed = TRUE;
     732    changed = TRUE;
    732733
    733734    part->style = style;
    734735    if (style & SBT_OWNERDRAW) {
    735         if (part->text == (LPWSTR)text)
    736             return TRUE;
    737         part->text = (LPWSTR)text;
     736    if (part->text == (LPWSTR)text)
     737        return TRUE;
     738    part->text = (LPWSTR)text;
    738739    } else {
    739         LPWSTR ntext;
    740 
    741         /* check if text is unchanged -> no need to redraw */
    742         if (text) {
     740    LPWSTR ntext;
     741
     742    /* check if text is unchanged -> no need to redraw */
     743    if (text) {
    743744            DWORD len = MultiByteToWideChar( CP_ACP, 0, text, -1, NULL, 0 );
    744             LPWSTR tmptext = COMCTL32_Alloc(len*sizeof(WCHAR));
     745        LPWSTR tmptext = COMCTL32_Alloc(len*sizeof(WCHAR));
    745746            MultiByteToWideChar( CP_ACP, 0, text, -1, tmptext, len );
    746747
    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;
     748        if (!changed && part->text && !lstrcmpW(tmptext,part->text)) {
     749        COMCTL32_Free(tmptext);
     750        return TRUE;
     751        }
     752        ntext = tmptext;
     753    } else {
     754        if (!changed && !part->text)
     755        return TRUE;
     756        ntext = 0;
     757    }
     758
     759    if (part->text)
     760        COMCTL32_Free (part->text);
     761    part->text = ntext;
    761762    }
    762763    InvalidateRect(hwnd, &part->bound, FALSE);
     
    780781    TRACE("part %d -> '%s' with style %04x\n", nPart, debugstr_w(text), style);
    781782    if ((infoPtr->simple) || (infoPtr->parts==NULL) || (nPart==255))
    782         part = &infoPtr->part0;
     783    part = &infoPtr->part0;
    783784    else
    784785#ifdef __WIN32OS2__
    785786    {
    786787        if (nPart >= infoPtr->numParts)
    787             return FALSE;
    788         part = &infoPtr->parts[nPart];
     788        return FALSE;
     789    part = &infoPtr->parts[nPart];
    789790    }
    790791#else
    791         part = &infoPtr->parts[nPart];
     792    part = &infoPtr->parts[nPart];
    792793#endif
    793794    if (!part) return FALSE;
     
    801802    if (style & SBT_OWNERDRAW)
    802803    {
    803         part->text = text;
     804    part->text = text;
    804805        bRedraw = TRUE;
    805806    } else if(!text)
     
    813814    } else if(!part->text || strcmpW(part->text, text)) /* see if the new string differs from the existing string */
    814815    {
    815         if(part->text) COMCTL32_Free(part->text);
     816    if(part->text) COMCTL32_Free(part->text);
    816817
    817818        len = strlenW(text);
    818819        part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
    819         strcpyW(part->text, text);
     820    strcpyW(part->text, text);
    820821        bRedraw = TRUE;
    821822    }
     
    833834    TRACE("part %d: \"%s\"\n", (INT)wParam, (LPSTR)lParam);
    834835    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);
     836    TTTOOLINFOA ti;
     837    ti.cbSize = sizeof(TTTOOLINFOA);
     838    ti.hwnd = hwnd;
     839    ti.uId = (INT)wParam;
     840    ti.hinst = 0;
     841    ti.lpszText = (LPSTR)lParam;
     842    SendMessageA (infoPtr->hwndToolTip, TTM_UPDATETIPTEXTA,
     843            0, (LPARAM)&ti);
    843844    }
    844845
     
    852853    TRACE("part %d: \"%s\"\n", (INT)wParam, (LPSTR)lParam);
    853854    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);
     855    TTTOOLINFOW ti;
     856    ti.cbSize = sizeof(TTTOOLINFOW);
     857    ti.hwnd = hwnd;
     858    ti.uId = (INT)wParam;
     859    ti.hinst = 0;
     860    ti.lpszText = (LPWSTR)lParam;
     861    SendMessageW (infoPtr->hwndToolTip, TTM_UPDATETIPTEXTW,
     862            0, (LPARAM)&ti);
    862863    }
    863864
     
    885886    TRACE("(is simple: %d)\n", wParam);
    886887    if (infoPtr->simple == wParam) /* no need to change */
    887         return TRUE;
     888    return TRUE;
    888889
    889890    infoPtr->simple = (BOOL)wParam;
     
    905906    NONCLIENTMETRICSA nclm;
    906907    DWORD dwStyle;
    907     RECT        rect;
    908     int         width, len;
    909     HDC hdc;
     908    RECT    rect;
     909    int         width, len;
     910    HDC hdc;
    910911    STATUSWINDOWINFO *infoPtr;
    911912
     
    951952
    952953    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         }
     954    infoPtr->bUnicode = TRUE;
     955    if (lpCreate->lpszName &&
     956        (len = strlenW ((LPCWSTR)lpCreate->lpszName))) {
     957        infoPtr->parts[0].text = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     958        strcpyW (infoPtr->parts[0].text, (LPCWSTR)lpCreate->lpszName);
     959    }
    959960    }
    960961    else {
    961         if (lpCreate->lpszName &&
    962             (len = strlen((LPCSTR)lpCreate->lpszName))) {
     962    if (lpCreate->lpszName &&
     963        (len = strlen((LPCSTR)lpCreate->lpszName))) {
    963964            DWORD lenW = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)lpCreate->lpszName, -1, NULL, 0 );
    964             infoPtr->parts[0].text = COMCTL32_Alloc (lenW*sizeof(WCHAR));
     965        infoPtr->parts[0].text = COMCTL32_Alloc (lenW*sizeof(WCHAR));
    965966            MultiByteToWideChar( CP_ACP, 0, (LPCSTR)lpCreate->lpszName, -1,
    966967                                 infoPtr->parts[0].text, lenW );
    967         }
     968    }
    968969    }
    969970
     
    977978#endif
    978979    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);
     980    TEXTMETRICA tm;
     981    HFONT hOldFont;
     982
     983    hOldFont = SelectObject (hdc,infoPtr->hDefaultFont);
     984    GetTextMetricsA(hdc, &tm);
     985    infoPtr->textHeight = tm.tmHeight;
     986    SelectObject (hdc, hOldFont);
     987    ReleaseDC(0, hdc);
    987988    }
    988989
    989990    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         }
     991    infoPtr->hwndToolTip =
     992        CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
     993                   CW_USEDEFAULT, CW_USEDEFAULT,
     994                   CW_USEDEFAULT, CW_USEDEFAULT,
     995                 hwnd, 0,
     996                 GetWindowLongA (hwnd, GWL_HINSTANCE), NULL);
     997
     998    if (infoPtr->hwndToolTip) {
     999        NMTOOLTIPSCREATED nmttc;
     1000
     1001        nmttc.hdr.hwndFrom = hwnd;
     1002        nmttc.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
     1003        nmttc.hdr.code = NM_TOOLTIPSCREATED;
     1004        nmttc.hwndToolTips = infoPtr->hwndToolTip;
     1005
     1006        SendMessageA (lpCreate->hwndParent, WM_NOTIFY,
     1007                (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc);
     1008    }
    10081009    }
    10091010
     
    10141015        infoPtr->height = infoPtr->textHeight + 4 + VERT_BORDER;
    10151016        SetWindowPos(hwnd, 0, lpCreate->x, lpCreate->y - 1,
    1016                         width, infoPtr->height, SWP_NOZORDER);
     1017            width, infoPtr->height, SWP_NOZORDER);
    10171018        STATUSBAR_SetPartBounds (infoPtr, hwnd);
    10181019    }
     
    10251026STATUSBAR_WMDestroy (STATUSWINDOWINFO *infoPtr, HWND hwnd)
    10261027{
    1027     int i;
     1028    int i;
    10281029
    10291030    TRACE("\n");
    10301031    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);
     1032    if (infoPtr->parts[i].text && !(infoPtr->parts[i].style & SBT_OWNERDRAW))
     1033        COMCTL32_Free (infoPtr->parts[i].text);
    10331034    }
    10341035    if (infoPtr->part0.text && !(infoPtr->part0.style & SBT_OWNERDRAW))
    1035         COMCTL32_Free (infoPtr->part0.text);
     1036    COMCTL32_Free (infoPtr->part0.text);
    10361037    COMCTL32_Free (infoPtr->parts);
    10371038
    10381039    /* delete default font */
    10391040    if (infoPtr->hDefaultFont)
    1040         DeleteObject (infoPtr->hDefaultFont);
     1041    DeleteObject (infoPtr->hDefaultFont);
    10411042
    10421043    /* delete tool tip control */
    10431044    if (infoPtr->hwndToolTip)
    1044         DestroyWindow (infoPtr->hwndToolTip);
     1045    DestroyWindow (infoPtr->hwndToolTip);
    10451046
    10461047    COMCTL32_Free (infoPtr);
     
    10741075
    10751076    if (wParam > len) {
    1076         if (infoPtr->bUnicode)
    1077             strcpyW ((LPWSTR)lParam, infoPtr->parts[0].text);
    1078         else
     1077    if (infoPtr->bUnicode)
     1078        strcpyW ((LPWSTR)lParam, infoPtr->parts[0].text);
     1079    else
    10791080            WideCharToMultiByte( CP_ACP, 0, infoPtr->parts[0].text, -1,
    10801081                                 (LPSTR)lParam, len+1, NULL, NULL );
    1081         return len;
     1082    return len;
    10821083    }
    10831084
     
    10901091{
    10911092    if (infoPtr->hwndToolTip)
    1092         STATUSBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
    1093                               WM_MOUSEMOVE, wParam, lParam);
     1093    STATUSBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
     1094                  WM_MOUSEMOVE, wParam, lParam);
    10941095    return 0;
    10951096}
     
    11001101{
    11011102    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;
     1103    RECT  rect;
     1104    POINT pt;
     1105
     1106    GetClientRect (hwnd, &rect);
     1107
     1108    pt.x = (INT)LOWORD(lParam);
     1109    pt.y = (INT)HIWORD(lParam);
     1110    ScreenToClient (hwnd, &pt);
     1111
     1112    rect.left = rect.right - 13;
     1113    rect.top += 2;
     1114
     1115    if (PtInRect (&rect, pt))
     1116        return HTBOTTOMRIGHT;
    11161117    }
    11171118
     
    11491150    STATUSBAR_Refresh (infoPtr, hwnd, hdc);
    11501151    if (!wParam)
    1151         EndPaint (hwnd, &ps);
     1152    EndPaint (hwnd, &ps);
    11521153
    11531154    return 0;
     
    11941195    TRACE("\n");
    11951196    if (infoPtr->numParts == 0)
    1196         return FALSE;
     1197    return FALSE;
    11971198
    11981199    part = &infoPtr->parts[0];
     
    12021203    part->text = 0;
    12031204    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         }
     1205    if (lParam && (len = strlenW((LPCWSTR)lParam))) {
     1206        part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
     1207        strcpyW (part->text, (LPCWSTR)lParam);
     1208    }
    12081209    }
    12091210    else {
    1210         if (lParam && (len = lstrlenA((LPCSTR)lParam))) {
     1211    if (lParam && (len = lstrlenA((LPCSTR)lParam))) {
    12111212            DWORD lenW = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)lParam, -1, NULL, 0 );
    12121213            part->text = COMCTL32_Alloc (lenW*sizeof(WCHAR));
    12131214            MultiByteToWideChar( CP_ACP, 0, (LPCSTR)lParam, -1, part->text, lenW );
    1214         }
     1215    }
    12151216    }
    12161217
     
    12401241    {
    12411242        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);
     1243        /* width and height don't apply */
     1244        GetClientRect (infoPtr->hwndParent, &parent_rect);
     1245        width = parent_rect.right - parent_rect.left;
     1246        x = parent_rect.left;
     1247        y = parent_rect.bottom - infoPtr->height;
     1248        MoveWindow (hwnd, parent_rect.left,
     1249              parent_rect.bottom - infoPtr->height,
     1250              width, infoPtr->height, TRUE);
     1251        STATUSBAR_SetPartBounds (infoPtr, hwnd);
    12511252        }
    1252         return 0; /* FIXME: ok to return here ? */
     1253    return 0; /* FIXME: ok to return here ? */
    12531254    }
    12541255
     
    12831284
    12841285    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:
     1286    case SB_GETBORDERS:
     1287        return STATUSBAR_GetBorders (lParam);
     1288
     1289    case SB_GETICON:
     1290        return STATUSBAR_GetIcon (infoPtr, hwnd, wParam);
     1291
     1292    case SB_GETPARTS:
     1293        return STATUSBAR_GetParts (infoPtr, hwnd, wParam, lParam);
     1294
     1295    case SB_GETRECT:
     1296        return STATUSBAR_GetRect (infoPtr, hwnd, wParam, lParam);
     1297
     1298    case SB_GETTEXTA:
     1299        return STATUSBAR_GetTextA (infoPtr, hwnd, wParam, lParam);
     1300
     1301    case SB_GETTEXTW:
     1302        return STATUSBAR_GetTextW (infoPtr, hwnd, wParam, lParam);
     1303
     1304    case SB_GETTEXTLENGTHA:
     1305    case SB_GETTEXTLENGTHW:
     1306        return STATUSBAR_GetTextLength (infoPtr, hwnd, wParam);
     1307
     1308    case SB_GETTIPTEXTA:
     1309        return STATUSBAR_GetTipTextA (infoPtr, hwnd, wParam, lParam);
     1310
     1311    case SB_GETTIPTEXTW:
     1312        return STATUSBAR_GetTipTextW (infoPtr, hwnd, wParam, lParam);
     1313
     1314    case SB_GETUNICODEFORMAT:
     1315        return STATUSBAR_GetUnicodeFormat (infoPtr, hwnd);
     1316
     1317    case SB_ISSIMPLE:
     1318        return STATUSBAR_IsSimple (infoPtr, hwnd);
     1319
     1320    case SB_SETBKCOLOR:
     1321        return STATUSBAR_SetBkColor (infoPtr, hwnd, wParam, lParam);
     1322
     1323    case SB_SETICON:
     1324        return STATUSBAR_SetIcon (infoPtr, hwnd, wParam, lParam);
     1325
     1326    case SB_SETMINHEIGHT:
     1327        return STATUSBAR_SetMinHeight (infoPtr, hwnd, wParam, lParam);
     1328
     1329    case SB_SETPARTS:
     1330        return STATUSBAR_SetParts (infoPtr, hwnd, wParam, lParam);
     1331
     1332    case SB_SETTEXTA:
     1333        return STATUSBAR_SetTextA (infoPtr, hwnd, wParam, lParam);
     1334
     1335    case SB_SETTEXTW:
     1336        return STATUSBAR_SetTextW (infoPtr, hwnd, wParam, lParam);
     1337
     1338    case SB_SETTIPTEXTA:
     1339        return STATUSBAR_SetTipTextA (infoPtr, hwnd, wParam, lParam);
     1340
     1341    case SB_SETTIPTEXTW:
     1342        return STATUSBAR_SetTipTextW (infoPtr, hwnd, wParam, lParam);
     1343
     1344    case SB_SETUNICODEFORMAT:
     1345        return STATUSBAR_SetUnicodeFormat (infoPtr, hwnd, wParam);
     1346
     1347    case SB_SIMPLE:
     1348        return STATUSBAR_Simple (infoPtr, hwnd, wParam, lParam);
     1349
     1350
     1351    case WM_CREATE:
     1352        return STATUSBAR_WMCreate (hwnd, wParam, lParam);
     1353
     1354    case WM_DESTROY:
     1355        return STATUSBAR_WMDestroy (infoPtr, hwnd);
     1356
     1357    case WM_GETFONT:
    13571358            return STATUSBAR_WMGetFont (infoPtr, hwnd);
    13581359
    1359         case WM_GETTEXT:
     1360    case WM_GETTEXT:
    13601361            return STATUSBAR_WMGetText (infoPtr, hwnd, wParam, lParam);
    13611362
    1362         case WM_GETTEXTLENGTH:
    1363             return STATUSBAR_GetTextLength (infoPtr, hwnd, 0);
    1364 
    1365         case WM_LBUTTONDBLCLK:
     1363    case WM_GETTEXTLENGTH:
     1364        return STATUSBAR_GetTextLength (infoPtr, hwnd, 0);
     1365
     1366    case WM_LBUTTONDBLCLK:
    13661367            return STATUSBAR_SendNotify (hwnd, NM_DBLCLK);
    13671368
    1368         case WM_LBUTTONUP:
    1369             return STATUSBAR_SendNotify (hwnd, NM_CLICK);
    1370 
    1371         case WM_MOUSEMOVE:
     1369    case WM_LBUTTONUP:
     1370        return STATUSBAR_SendNotify (hwnd, NM_CLICK);
     1371
     1372    case WM_MOUSEMOVE:
    13721373            return STATUSBAR_WMMouseMove (infoPtr, hwnd, wParam, lParam);
    13731374
    1374         case WM_NCHITTEST:
     1375    case WM_NCHITTEST:
    13751376            return STATUSBAR_WMNCHitTest (hwnd, wParam, lParam);
    13761377
    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);
     1378    case WM_NCLBUTTONDOWN:
     1379        return STATUSBAR_WMNCLButtonDown (hwnd, wParam, lParam);
     1380
     1381    case WM_NCLBUTTONUP:
     1382        return STATUSBAR_WMNCLButtonUp (hwnd, wParam, lParam);
     1383
     1384    case WM_PAINT:
     1385        return STATUSBAR_WMPaint (infoPtr, hwnd, wParam);
     1386
     1387    case WM_RBUTTONDBLCLK:
     1388        return STATUSBAR_SendNotify (hwnd, NM_RDBLCLK);
     1389
     1390    case WM_RBUTTONUP:
     1391        return STATUSBAR_SendNotify (hwnd, NM_RCLICK);
     1392
     1393    case WM_SETFONT:
     1394        return STATUSBAR_WMSetFont (infoPtr, hwnd, wParam, lParam);
     1395
     1396    case WM_SETTEXT:
     1397        return STATUSBAR_WMSetText (infoPtr, hwnd, wParam, lParam);
     1398
     1399    case WM_SIZE:
     1400        return STATUSBAR_WMSize (infoPtr, hwnd, wParam, lParam);
     1401
     1402    default:
     1403        if (msg >= WM_USER)
     1404        ERR("unknown msg %04x wp=%04x lp=%08lx\n",
     1405             msg, wParam, lParam);
    14051406#ifdef __WIN32OS2__
    14061407            return defComCtl32ProcA (hwnd, msg, wParam, lParam);
    14071408#else
    1408             return DefWindowProcA (hwnd, msg, wParam, lParam);
     1409        return DefWindowProcA (hwnd, msg, wParam, lParam);
    14091410#endif
    14101411    }
     
    14321433    wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
    14331434    wndClass.lpszClassName = STATUSCLASSNAMEA;
    1434  
     1435
    14351436    RegisterClassA (&wndClass);
    14361437}
  • trunk/src/comctl32/tab.c

    r5630 r6644  
     1/* $Id: tab.c,v 1.21 2001-09-05 12:05:02 bird Exp $ */
    12/*
    23 * Tab control
     
    3637  LPARAM lParam;
    3738  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                    * 
     39           * leftmost item (the leftmost item, 0, would have a
     40           * "left" member of 0 in this rectangle)
     41                   *
    4142                   * additionally the top member hold the row number
    4243                   * and bottom is unused and should be 0 */
     
    4950#endif
    5051  UINT       uNumItem;        /* number of tab items */
    51   UINT       uNumRows;        /* number of tab rows */
     52  UINT       uNumRows;        /* number of tab rows */
    5253  INT        tabHeight;       /* height of the tab row */
    5354  INT        tabWidth;        /* width of tabs */
     
    5758  HWND       hwndToolTip;     /* handle to tab's tooltip */
    5859  INT        leftmostVisible; /* Used for scrolling, this member contains
    59                                * the index of the first visible item */
     60                   * the index of the first visible item */
    6061  INT        iSelected;       /* the currently selected item */
    6162  INT        iHotTracked;     /* the highlighted item under the mouse */
     
    6364  TAB_ITEM*  items;           /* pointer to an array of TAB_ITEM's */
    6465  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? */
     66  BOOL       needsScrolling;  /* TRUE if the size of the tabs is greater than
     67                   * the size of the control */
     68  BOOL       fSizeSet;        /* was the size of the tabs explicitly set? */
    6869  BOOL       bUnicode;        /* Unicode control? */
    6970  HWND       hwndUpDown;      /* Updown control used for scrolling */
     
    8182#define CONTROL_BORDER_SIZEX    2
    8283#define CONTROL_BORDER_SIZEY    2
    83 #define BUTTON_SPACINGX         4 
     84#define BUTTON_SPACINGX         4
    8485#define BUTTON_SPACINGY         4
    8586#define FLAT_BTN_SPACINGX       8
     
    137138{
    138139    TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    139  
     140
    140141    return infoPtr->iSelected;
    141142}
     
    145146{
    146147    TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    147  
     148
    148149    return infoPtr->uFocus;
    149150}
     
    164165  INT iItem = (INT)wParam;
    165166  INT prevItem;
    166  
     167
    167168  prevItem = -1;
    168169  if ((iItem >= 0) && (iItem < infoPtr->uNumItem)) {
     
    180181  TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    181182  INT iItem=(INT) wParam;
    182  
     183
    183184  if ((iItem < 0) || (iItem >= infoPtr->uNumItem)) return 0;
    184185
    185186  if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BUTTONS) {
    186187    FIXME("Should set input focus\n");
    187   } else { 
     188  } else {
    188189    int oldFocus = infoPtr->uFocus;
    189190    if (infoPtr->iSelected != iItem || infoPtr->uFocus == -1 ) {
     
    232233  RECT tmpItemRect,clientRect;
    233234  LONG        lStyle  = GetWindowLongA(hwnd, GWL_STYLE);
    234  
     235
    235236  /* Perform a sanity check and a trivial visibility check. */
    236237  if ( (infoPtr->uNumItem <= 0) ||
     
    245246  if (itemRect == NULL)
    246247    itemRect = &tmpItemRect;
    247  
     248
    248249  /* Retrieve the unmodified item rect. */
    249250  *itemRect = infoPtr->items[itemIndex].rect;
     
    280281  else if(!(lStyle & TCS_VERTICAL) && !(lStyle & TCS_BOTTOM)) /* not TCS_BOTTOM and not TCS_VERTICAL */
    281282  {
    282     itemRect->bottom = clientRect.top + 
     283    itemRect->bottom = clientRect.top +
    283284                      infoPtr->tabHeight +
    284285                      itemRect->top * (infoPtr->tabHeight - 2) +
    285286                      ((lStyle & TCS_BUTTONS) ? itemRect->top * BUTTON_SPACINGY : 0);
    286     itemRect->top = clientRect.top + 
     287    itemRect->top = clientRect.top +
    287288                   SELECTED_TAB_OFFSET +
    288289                   itemRect->top * (infoPtr->tabHeight - 2) +
     
    291292
    292293  /*
    293    * "scroll" it to make sure the item at the very left of the 
     294   * "scroll" it to make sure the item at the very left of the
    294295   * tab control is the leftmost visible tab.
    295296   */
     
    297298  {
    298299    OffsetRect(itemRect,
    299              0,
    300              -(clientRect.bottom - infoPtr->items[infoPtr->leftmostVisible].rect.bottom));
     300         0,
     301         -(clientRect.bottom - infoPtr->items[infoPtr->leftmostVisible].rect.bottom));
    301302
    302303    /*
     
    305306     */
    306307    OffsetRect(itemRect,
    307              0,
    308              -SELECTED_TAB_OFFSET);
     308         0,
     309         -SELECTED_TAB_OFFSET);
    309310
    310311  } else
    311312  {
    312313    OffsetRect(itemRect,
    313              -infoPtr->items[infoPtr->leftmostVisible].rect.left,
    314              0);
     314         -infoPtr->items[infoPtr->leftmostVisible].rect.left,
     315         0);
    315316
    316317    /*
     
    319320     */
    320321    OffsetRect(itemRect,
    321              SELECTED_TAB_OFFSET,
    322              0);
     322         SELECTED_TAB_OFFSET,
     323         0);
    323324  }
    324325
     
    336337    /* If it also a bit higher. */
    337338    if ((lStyle & TCS_BOTTOM) && !(lStyle & TCS_VERTICAL))
    338     {     
     339    {
    339340      selectedRect->top -= 2; /* the border is thicker on the bottom */
    340341      selectedRect->bottom += SELECTED_TAB_OFFSET;
     
    362363static BOOL TAB_GetItemRect(HWND hwnd, WPARAM wParam, LPARAM lParam)
    363364{
    364   return TAB_InternalGetItemRect(hwnd, TAB_GetInfoPtr(hwnd), (INT)wParam, 
     365  return TAB_InternalGetItemRect(hwnd, TAB_GetInfoPtr(hwnd), (INT)wParam,
    365366                                 (LPRECT)lParam, (LPRECT)NULL);
    366367}
     
    372373 */
    373374static LRESULT TAB_KeyUp(
    374   HWND   hwnd, 
     375  HWND   hwnd,
    375376  WPARAM keyCode)
    376377{
     
    387388      break;
    388389  }
    389  
     390
    390391  /*
    391392   * If we changed to a valid item, change the selection
     
    416417 */
    417418static LRESULT TAB_FocusChanging(
    418   HWND   hwnd, 
    419   UINT   uMsg, 
    420   WPARAM wParam, 
     419  HWND   hwnd,
     420  UINT   uMsg,
     421  WPARAM wParam,
    421422  LPARAM lParam)
    422423{
     
    429430   */
    430431  isVisible = TAB_InternalGetItemRect(hwnd,
    431                                       infoPtr,
    432                                       infoPtr->uFocus,
    433                                       NULL,
    434                                       &selectedRect);
    435  
     432                      infoPtr,
     433                      infoPtr->uFocus,
     434                      NULL,
     435                      &selectedRect);
     436
    436437  /*
    437438   * If the rectangle is not completely invisible, invalidate that
     
    451452static HWND TAB_InternalHitTest (
    452453  HWND      hwnd,
    453   TAB_INFO* infoPtr, 
    454   POINT     pt, 
     454  TAB_INFO* infoPtr,
     455  POINT     pt,
    455456  UINT*     flags)
    456457
    457458{
    458459  RECT rect;
    459   int iCount; 
    460  
     460  int iCount;
     461
    461462  for (iCount = 0; iCount < infoPtr->uNumItem; iCount++)
    462463  {
     
    479480  TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    480481  LPTCHITTESTINFO lptest = (LPTCHITTESTINFO) lParam;
    481  
     482
    482483  return TAB_InternalHitTest (hwnd, infoPtr, lptest->pt, &lptest->flags);
    483484}
     
    521522  if (infoPtr->hwndToolTip)
    522523    TAB_RelayEvent (infoPtr->hwndToolTip, hwnd,
    523                     WM_LBUTTONDOWN, wParam, lParam);
     524            WM_LBUTTONDOWN, wParam, lParam);
    524525
    525526  if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_FOCUSONBUTTONDOWN ) {
     
    529530  if (infoPtr->hwndToolTip)
    530531    TAB_RelayEvent (infoPtr->hwndToolTip, hwnd,
    531                     WM_LBUTTONDOWN, wParam, lParam);
    532  
     532            WM_LBUTTONDOWN, wParam, lParam);
     533
    533534  pt.x = (INT)LOWORD(lParam);
    534535  pt.y = (INT)HIWORD(lParam);
    535  
     536
    536537  newItem = TAB_InternalHitTest (hwnd, infoPtr, pt, &dummy);
    537  
     538
    538539  TRACE("On Tab, item %d\n", newItem);
    539540
     
    619620    ** overlaps.  Note also that the case where the cursor stayed within our
    620621    ** window but has moved off the hot-tracked tab will be handled by the
    621     ** WM_MOUSEMOVE event. 
     622    ** WM_MOUSEMOVE event.
    622623    */
    623624    if (!GetCursorPos(&pt) || WindowFromPoint(pt) != hwnd)
     
    721722    if (item >= 0)
    722723    {
    723         /* Mark new hot-tracked to be redrawn to look highlighted */
     724    /* Mark new hot-tracked to be redrawn to look highlighted */
    724725      if (out_redrawEnter != NULL)
    725726        *out_redrawEnter = item;
     
    743744  if (infoPtr->hwndToolTip)
    744745    TAB_RelayEvent (infoPtr->hwndToolTip, hwnd,
    745                     WM_LBUTTONDOWN, wParam, lParam);
     746            WM_LBUTTONDOWN, wParam, lParam);
    746747
    747748  /* Determine which tab to highlight.  Redraw tabs which change highlight
     
    764765 */
    765766static LRESULT TAB_AdjustRect(
    766   HWND   hwnd, 
    767   WPARAM fLarger, 
     767  HWND   hwnd,
     768  WPARAM fLarger,
    768769  LPRECT prc)
    769770{
     
    845846 */
    846847static LRESULT TAB_OnHScroll(
    847   HWND    hwnd, 
     848  HWND    hwnd,
    848849  int     nScrollCode,
    849850  int     nPos,
     
    871872 * TAB_SetupScrolling
    872873 *
    873  * This method will check the current scrolling state and make sure the 
     874 * This method will check the current scrolling state and make sure the
    874875 * scrolling control is displayed (or not).
    875876 */
     
    930931    {
    931932      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);       
     933                      "",
     934                      WS_VISIBLE | WS_CHILD | UDS_HORZ,
     935                      controlPos.left, controlPos.top,
     936                      controlPos.right - controlPos.left,
     937                      controlPos.bottom - controlPos.top,
     938                      hwnd,
     939                      (HMENU)NULL,
     940                      (HINSTANCE)NULL,
     941                      NULL);
    941942    }
    942943    else
    943944    {
    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);                 
     945      SetWindowPos(infoPtr->hwndUpDown,
     946           (HWND)NULL,
     947           controlPos.left, controlPos.top,
     948           controlPos.right - controlPos.left,
     949           controlPos.bottom - controlPos.top,
     950           SWP_SHOWWINDOW | SWP_NOZORDER);
    950951    }
    951952
     
    10101011   * a font.
    10111012   */
    1012   hdc = GetDC(hwnd); 
    1013    
     1013  hdc = GetDC(hwnd);
     1014
    10141015  hFont = infoPtr->hFont ? infoPtr->hFont : GetStockObject (SYSTEM_FONT);
    10151016  hOldFont = SelectObject (hdc, hFont);
     
    10221023
    10231024  /* 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 
     1025     tabs along the top of the rectangle and we can just rotate them after
    10251026     rather than duplicate all of the below code */
    10261027  if(lStyle & TCS_VERTICAL)
     
    10541055
    10551056    /*
    1056      * Make sure there is enough space for the letters + icon + growing the 
    1057      * selected item + extra space for the selected item.   
     1057     * Make sure there is enough space for the letters + icon + growing the
     1058     * selected item + extra space for the selected item.
    10581059     */
    10591060    infoPtr->tabHeight = item_height + 2 * VERTICAL_ITEM_PADDING +
     
    10851086       * for button style tabs */
    10861087      if (lStyle & TCS_BUTTONS)
    1087               size.cx = max(size.cx, 2 * (infoPtr->tabHeight - 2));
     1088          size.cx = max(size.cx, 2 * (infoPtr->tabHeight - 2));
    10881089
    10891090      /* Add the icon width */
     
    10951096
    10961097      infoPtr->items[curItem].rect.right = infoPtr->items[curItem].rect.left +
    1097                                            size.cx + icon_width + 
     1098                                           size.cx + icon_width +
    10981099                                           num * HORIZONTAL_ITEM_PADDING;
    10991100    }
     
    11141115                                      infoPtr->items[curItem].rect.left;
    11151116
    1116         infoPtr->items[curItem].rect.left = 0;
     1117    infoPtr->items[curItem].rect.left = 0;
    11171118        curItemRowCount++;
    11181119    }
     
    11221123
    11231124    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); 
     1125    TRACE("Rect: T %i, L %i, B %i, R %i\n",
     1126      infoPtr->items[curItem].rect.top,
     1127      infoPtr->items[curItem].rect.left,
     1128      infoPtr->items[curItem].rect.bottom,
     1129      infoPtr->items[curItem].rect.right);
    11291130
    11301131    /*
     
    11521153    /* Don't need scrolling, then update infoPtr->leftmostVisible */
    11531154    if(!infoPtr->needsScrolling)
    1154       infoPtr->leftmostVisible = 0; 
     1155      infoPtr->leftmostVisible = 0;
    11551156
    11561157    TAB_SetupScrolling(hwnd, infoPtr, &clientRect);
     
    11931194
    11941195          /* shift the item to the left side of the clientRect */
    1195           infoPtr->items[iItm].rect.right -= 
     1196          infoPtr->items[iItm].rect.right -=
    11961197            infoPtr->items[iItm].rect.left;
    11971198          infoPtr->items[iItm].rect.left = 0;
     
    12021203          infoPtr->items[iItm].rect.top = iRow;
    12031204          if (lStyle & TCS_BUTTONS)
    1204           {
     1205      {
    12051206            curItemLeftPos = infoPtr->items[iItm].rect.right + 1;
    12061207            if (lStyle & TCS_FLATBUTTONS)
    1207               curItemLeftPos += FLAT_BTN_SPACINGX;
    1208           }
     1208          curItemLeftPos += FLAT_BTN_SPACINGX;
     1209      }
    12091210          else
    12101211            curItemLeftPos = infoPtr->items[iItm].rect.right;
    12111212      }
    1212          
     1213
    12131214      /*
    12141215       * Justify the rows
     
    12171218         while(iIndexStart < infoPtr->uNumItem)
    12181219        {
    1219         /* 
     1220        /*
    12201221         * find the indexs of the row
    12211222         */
    12221223        /* find the first item on the next row */
    12231224        for (iIndexEnd=iIndexStart;
    1224              (iIndexEnd < infoPtr->uNumItem) && 
    1225                (infoPtr->items[iIndexEnd].rect.top ==
     1225             (iIndexEnd < infoPtr->uNumItem) &&
     1226           (infoPtr->items[iIndexEnd].rect.top ==
    12261227                infoPtr->items[iIndexStart].rect.top) ;
    12271228            iIndexEnd++)
    12281229        /* intentionaly blank */;
    12291230
    1230         /* 
     1231        /*
    12311232         * we need to justify these tabs so they fill the whole given
    12321233         * client area
     
    12461247           widthDiff = widthDiff / iCount;
    12471248           /* add widthDiff/iCount, or extra space/items on row, to each item on this row */
    1248            for (iIndex=iIndexStart,iCount=0; iIndex < iIndexEnd; 
     1249           for (iIndex=iIndexStart,iCount=0; iIndex < iIndexEnd;
    12491250                iIndex++,iCount++)
    12501251           {
     
    12971298 * This method is used to draw the interior (text and icon) of a single tab
    12981299 * into the tab control.
    1299  */         
     1300 */
    13001301static void
    13011302TAB_DrawItemInterior
     
    13901391    id = GetWindowLongA( hwnd, GWL_ID );
    13911392
    1392     /* 
     1393    /*
    13931394     * put together the DRAWITEMSTRUCT
    13941395     */
    1395     dis.CtlType    = ODT_TAB;   
    1396     dis.CtlID      = id;               
    1397     dis.itemID     = iItem;             
    1398     dis.itemAction = ODA_DRAWENTIRE;   
     1396    dis.CtlType    = ODT_TAB;
     1397    dis.CtlID      = id;
     1398    dis.itemID     = iItem;
     1399    dis.itemAction = ODA_DRAWENTIRE;
    13991400    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;           /* */
     1401      dis.itemState = ODS_SELECTED;
     1402    else
     1403      dis.itemState = 0;
     1404    dis.hwndItem = hwnd;        /* */
     1405    dis.hDC      = hdc;
     1406    dis.rcItem   = *drawRect;       /* */
    14061407    dis.itemData = infoPtr->items[iItem].lParam;
    14071408
     
    15381539    if(lStyle & TCS_VERTICAL)
    15391540    {
    1540       if (!GetObjectA((infoPtr->hFont) ? 
     1541      if (!GetObjectA((infoPtr->hFont) ?
    15411542                infoPtr->hFont : GetStockObject(SYSTEM_FONT),
    15421543                sizeof(LOGFONTA),&logfont))
     
    15451546
    15461547        lstrcpyA(logfont.lfFaceName, "Arial");
    1547         logfont.lfHeight = -MulDiv(iPointSize, GetDeviceCaps(hdc, LOGPIXELSY), 
     1548        logfont.lfHeight = -MulDiv(iPointSize, GetDeviceCaps(hdc, LOGPIXELSY),
    15481549                                    72);
    15491550        logfont.lfWeight = FW_NORMAL;
     
    16041605 *
    16051606 * This method is used to draw a single tab into the tab control.
    1606  */         
     1607 */
    16071608static void TAB_DrawItem(
    1608   HWND hwnd, 
    1609   HDC  hdc, 
     1609  HWND hwnd,
     1610  HDC  hdc,
    16101611  INT  iItem)
    16111612{
     
    16211622   */
    16221623  isVisible = TAB_InternalGetItemRect(hwnd,
    1623                                       infoPtr,
    1624                                       iItem,
    1625                                       &itemRect,
    1626                                       &selectedRect);
     1624                      infoPtr,
     1625                      iItem,
     1626                      &itemRect,
     1627                      &selectedRect);
    16271628
    16281629  if (isVisible)
    16291630  {
    1630     HBRUSH hbr       = CreateSolidBrush (GetSysColor(COLOR_BTNFACE));   
     1631    HBRUSH hbr       = CreateSolidBrush (GetSysColor(COLOR_BTNFACE));
    16311632    HPEN   hwPen     = GetSysColorPen (COLOR_3DHILIGHT);
    16321633    HPEN hbPen  = GetSysColorPen (COLOR_3DDKSHADOW);
     
    16451646      /* Separators between flat buttons */
    16461647      /* FIXME: test and correct this if necessary for TCS_FLATBUTTONS style */
    1647       if (lStyle & TCS_FLATBUTTONS) 
     1648      if (lStyle & TCS_FLATBUTTONS)
    16481649      {
    16491650        int x = r.right + FLAT_BTN_SPACINGX - 2;
     
    16691670        /* Background color */
    16701671        if (!((lStyle & TCS_OWNERDRAWFIXED) && infoPtr->fSizeSet))
    1671         {
     1672    {
    16721673              COLORREF bk = GetSysColor(COLOR_3DHILIGHT);
    16731674              DeleteObject(hbr);
     
    16851686
    16861687              deleteBrush = FALSE;
    1687         }
     1688    }
    16881689
    16891690        /* Erase the background */
     
    17041705        LineTo   (hdc, r.right, r.bottom);
    17051706        LineTo   (hdc, r.right, r.top + 1);
    1706        
     1707
    17071708        /* shadow */
    17081709        SelectObject(hdc, hbPen);
     
    17211722        FillRect(hdc, &r, hbr);
    17221723
    1723         if (!(lStyle & TCS_FLATBUTTONS))
    1724         {
     1724    if (!(lStyle & TCS_FLATBUTTONS))
     1725    {
    17251726          /* highlight */
    17261727          MoveToEx (hdc, r.left, r.bottom, NULL);
    17271728          LineTo   (hdc, r.left, r.top);
    17281729          LineTo   (hdc, r.right, r.top);
    1729          
     1730
    17301731          /* shadow */
    17311732          SelectObject(hdc, hbPen);
     
    17381739          LineTo   (hdc, r.right - 1, r.bottom - 1);
    17391740          LineTo   (hdc, r.left + 1, r.bottom - 1);
    1740         }
     1741    }
    17411742      }
    17421743    }
     
    17451746      /* Background color */
    17461747      DeleteObject(hbr);
    1747       hbr = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));   
     1748      hbr = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
    17481749
    17491750      /* We draw a rectangle of different sizes depending on the selection
     
    17561757      /*
    17571758       * 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 
     1759       * This is necessary when drawing the selected item since it is larger
     1760       * than the others, it might overlap with stuff already drawn by the
    17601761       * other tabs
    1761        */     
     1762       */
    17621763      FillRect(hdc, &r, hbr);
    17631764
     
    17701771      r.right--;
    17711772      r.bottom--;
    1772      
     1773
    17731774      holdPen = SelectObject (hdc, hwPen);
    17741775      if(lStyle & TCS_VERTICAL)
     
    18591860      }
    18601861    }
    1861  
     1862
    18621863    /* This modifies r to be the text rectangle. */
    18631864{
     
    18681869    /* Draw the focus rectangle */
    18691870    if (((lStyle & TCS_FOCUSNEVER) == 0) &&
    1870         (GetFocus() == hwnd) &&
    1871         (iItem == infoPtr->uFocus) )
     1871    (GetFocus() == hwnd) &&
     1872    (iItem == infoPtr->uFocus) )
    18721873    {
    18731874      r = itemRect;
     
    18881889 * This method is used to draw the raised border around the tab control
    18891890 * "content" area.
    1890  */         
     1891 */
    18911892static void TAB_DrawBorder (HWND hwnd, HDC hdc)
    18921893{
     
    19571958 *
    19581959 * This method repaints the tab control..
    1959  */             
     1960 */
    19601961static void TAB_Refresh (HWND hwnd, HDC hdc)
    19611962{
     
    19711972  if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BUTTONS)
    19721973  {
    1973     for (i = 0; i < infoPtr->uNumItem; i++) 
     1974    for (i = 0; i < infoPtr->uNumItem; i++)
    19741975      TAB_DrawItem (hwnd, hdc, i);
    19751976  }
     
    19771978  {
    19781979    /* Draw all the non selected item first */
    1979     for (i = 0; i < infoPtr->uNumItem; i++) 
     1980    for (i = 0; i < infoPtr->uNumItem; i++)
    19801981    {
    19811982      if (i != infoPtr->iSelected)
    1982         TAB_DrawItem (hwnd, hdc, i);
     1983    TAB_DrawItem (hwnd, hdc, i);
    19831984    }
    19841985
     
    20112012{
    20122013    TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    2013  
     2014
    20142015  infoPtr->DoRedraw=(BOOL) wParam;
    20152016  return 0;
     
    20172018
    20182019static LRESULT TAB_EraseBackground(
    2019   HWND hwnd, 
     2020  HWND hwnd,
    20202021  HDC  givenDC)
    20212022{
     
    22072208  HDC hdc;
    22082209  PAINTSTRUCT ps;
    2209    
     2210
    22102211  hdc = wParam== 0 ? BeginPaint (hwnd, &ps) : (HDC)wParam;
    22112212  TAB_Refresh (hwnd, hdc);
    2212    
     2213
    22132214  if(!wParam)
    22142215    EndPaint (hwnd, &ps);
     
    22192220static LRESULT
    22202221TAB_InsertItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    2221 {   
     2222{
    22222223  TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    22232224  TCITEMA *pti;
    22242225  INT iItem;
    22252226  RECT rect;
    2226  
     2227
    22272228  GetClientRect (hwnd, &rect);
    22282229  TRACE("Rect: %x T %i, L %i, B %i, R %i\n", hwnd,
    2229         rect.top, rect.left, rect.bottom, rect.right); 
    2230  
     2230        rect.top, rect.left, rect.bottom, rect.right);
     2231
    22312232  pti = (TCITEMA *)lParam;
    22322233  iItem = (INT)wParam;
    2233  
     2234
    22342235  if (iItem < 0) return -1;
    22352236  if (iItem > infoPtr->uNumItem)
    22362237    iItem = infoPtr->uNumItem;
    2237  
     2238
    22382239  if (infoPtr->uNumItem == 0) {
    22392240    infoPtr->items = COMCTL32_Alloc (sizeof (TAB_ITEM));
     
    22432244  else {
    22442245    TAB_ITEM *oldItems = infoPtr->items;
    2245    
     2246
    22462247    infoPtr->uNumItem++;
    22472248    infoPtr->items = COMCTL32_Alloc (sizeof (TAB_ITEM) * infoPtr->uNumItem);
    2248    
     2249
    22492250    /* pre insert copy */
    22502251    if (iItem > 0) {
    22512252      memcpy (&infoPtr->items[0], &oldItems[0],
    2252               iItem * sizeof(TAB_ITEM));
    2253     }
    2254    
     2253          iItem * sizeof(TAB_ITEM));
     2254    }
     2255
    22552256    /* post insert copy */
    22562257    if (iItem < infoPtr->uNumItem - 1) {
    22572258      memcpy (&infoPtr->items[iItem+1], &oldItems[iItem],
    2258               (infoPtr->uNumItem - iItem - 1) * sizeof(TAB_ITEM));
    2259      
     2259          (infoPtr->uNumItem - iItem - 1) * sizeof(TAB_ITEM));
     2260
    22602261    }
    22612262
     
    22652266    COMCTL32_Free (oldItems);
    22662267  }
    2267  
     2268
    22682269  infoPtr->items[iItem].mask = pti->mask;
    22692270  if (pti->mask & TCIF_TEXT)
     
    22722273  if (pti->mask & TCIF_IMAGE)
    22732274    infoPtr->items[iItem].iImage = pti->iImage;
    2274  
     2275
    22752276  if (pti->mask & TCIF_PARAM)
    22762277    infoPtr->items[iItem].lParam = pti->lParam;
    2277  
     2278
    22782279  TAB_SetItemBounds(hwnd);
    22792280  TAB_InvalidateTabArea(hwnd, infoPtr);
    2280  
     2281
    22812282  TRACE("[%04x]: added item %d '%s'\n",
    2282         hwnd, iItem, debugstr_w(infoPtr->items[iItem].pszText));
     2283    hwnd, iItem, debugstr_w(infoPtr->items[iItem].pszText));
    22832284
    22842285  return iItem;
     
    23192320    if (iItem > 0) {
    23202321      memcpy (&infoPtr->items[0], &oldItems[0],
    2321               iItem * sizeof(TAB_ITEM));
     2322          iItem * sizeof(TAB_ITEM));
    23222323    }
    23232324
     
    23252326    if (iItem < infoPtr->uNumItem - 1) {
    23262327      memcpy (&infoPtr->items[iItem+1], &oldItems[iItem],
    2327               (infoPtr->uNumItem - iItem - 1) * sizeof(TAB_ITEM));
    2328 
    2329   }
    2330  
     2328          (infoPtr->uNumItem - iItem - 1) * sizeof(TAB_ITEM));
     2329
     2330  }
     2331
    23312332    if (iItem <= infoPtr->iSelected)
    23322333      infoPtr->iSelected++;
     
    23412342  if (pti->mask & TCIF_IMAGE)
    23422343    infoPtr->items[iItem].iImage = pti->iImage;
    2343  
     2344
    23442345  if (pti->mask & TCIF_PARAM)
    23452346    infoPtr->items[iItem].lParam = pti->lParam;
    2346  
     2347
    23472348  TAB_SetItemBounds(hwnd);
    23482349  TAB_InvalidateTabArea(hwnd, infoPtr);
    2349  
     2350
    23502351  TRACE("[%04x]: added item %d '%s'\n",
    2351         hwnd, iItem, debugstr_w(infoPtr->items[iItem].pszText));
     2352    hwnd, iItem, debugstr_w(infoPtr->items[iItem].pszText));
    23522353
    23532354  return iItem;
     
    23552356
    23562357
    2357 static LRESULT 
     2358static LRESULT
    23582359TAB_SetItemSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
    23592360{
     
    23732374}
    23742375
    2375 static LRESULT 
     2376static LRESULT
    23762377TAB_SetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    23772378{
    23782379  TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    2379   TCITEMA *tabItem; 
     2380  TCITEMA *tabItem;
    23802381  TAB_ITEM *wineItem;
    23812382  INT    iItem;
     
    23952396    wineItem->lParam = tabItem->lParam;
    23962397
    2397   if (tabItem->mask & TCIF_RTLREADING) 
     2398  if (tabItem->mask & TCIF_RTLREADING)
    23982399    FIXME("TCIF_RTLREADING\n");
    23992400
    2400   if (tabItem->mask & TCIF_STATE) 
     2401  if (tabItem->mask & TCIF_STATE)
    24012402    wineItem->dwState = tabItem->dwState;
    24022403
     
    24512452
    24522453
    2453 static LRESULT 
     2454static LRESULT
    24542455TAB_GetItemCount (HWND hwnd, WPARAM wParam, LPARAM lParam)
    24552456{
     
    24602461
    24612462
    2462 static LRESULT 
     2463static LRESULT
    24632464TAB_GetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    24642465{
     
    24762477  wineItem = &infoPtr->items[iItem];
    24772478
    2478   if (tabItem->mask & TCIF_IMAGE) 
     2479  if (tabItem->mask & TCIF_IMAGE)
    24792480    tabItem->iImage = wineItem->iImage;
    24802481
    2481   if (tabItem->mask & TCIF_PARAM) 
     2482  if (tabItem->mask & TCIF_PARAM)
    24822483    tabItem->lParam = wineItem->lParam;
    24832484
    2484   if (tabItem->mask & TCIF_RTLREADING) 
     2485  if (tabItem->mask & TCIF_RTLREADING)
    24852486    FIXME("TCIF_RTLREADING\n");
    24862487
    2487   if (tabItem->mask & TCIF_STATE) 
     2488  if (tabItem->mask & TCIF_STATE)
    24882489    tabItem->dwState = wineItem->dwState;
    24892490
    2490   if (tabItem->mask & TCIF_TEXT) 
     2491  if (tabItem->mask & TCIF_TEXT)
    24912492   Str_GetPtrWtoA (wineItem->pszText, tabItem->pszText, tabItem->cchTextMax);
    24922493
     
    24952496
    24962497
    2497 static LRESULT 
     2498static LRESULT
    24982499TAB_GetItemW (HWND hwnd, WPARAM wParam, LPARAM lParam)
    24992500{
     
    25302531
    25312532
    2532 static LRESULT 
     2533static LRESULT
    25332534TAB_DeleteItem (HWND hwnd, WPARAM wParam, LPARAM lParam)
    25342535{
     
    25402541  {
    25412542    TAB_ITEM *oldItems = infoPtr->items;
    2542    
     2543
    25432544    infoPtr->uNumItem--;
    25442545    infoPtr->items = COMCTL32_Alloc(sizeof (TAB_ITEM) * infoPtr->uNumItem);
    2545    
    2546     if (iItem > 0) 
     2546
     2547    if (iItem > 0)
    25472548      memcpy(&infoPtr->items[0], &oldItems[0], iItem * sizeof(TAB_ITEM));
    2548    
    2549     if (iItem < infoPtr->uNumItem) 
     2549
     2550    if (iItem < infoPtr->uNumItem)
    25502551      memcpy(&infoPtr->items[iItem], &oldItems[iItem + 1],
    25512552              (infoPtr->uNumItem - iItem) * sizeof(TAB_ITEM));
    2552    
     2553
    25532554    COMCTL32_Free(oldItems);
    25542555
     
    25562557    if ((iItem == infoPtr->iSelected) && (iItem > 0))
    25572558      infoPtr->iSelected--;
    2558      
     2559
    25592560    if (iItem < infoPtr->iSelected)
    25602561      infoPtr->iSelected--;
     
    25732574}
    25742575
    2575 static LRESULT 
     2576static LRESULT
    25762577TAB_DeleteAllItems (HWND hwnd, WPARAM wParam, LPARAM lParam)
    25772578{
     
    25842585    KillTimer(hwnd, TAB_HOTTRACK_TIMER);
    25852586  infoPtr->iHotTracked = -1;
    2586  
     2587
    25872588  TAB_SetItemBounds(hwnd);
    25882589  TAB_InvalidateTabArea(hwnd,infoPtr);
     
    26052606{
    26062607  TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    2607  
     2608
    26082609  TRACE("%x %lx\n",wParam, lParam);
    2609  
     2610
    26102611  infoPtr->hFont = (HFONT)wParam;
    2611  
     2612
    26122613  TAB_SetItemBounds(hwnd);
    26132614
     
    26762677    cx=LOWORD (lParam);
    26772678    cy=HIWORD (lParam);
    2678     if (GetWindowLongA(hwnd, GWL_STYLE) & CCS_NORESIZE) 
     2679    if (GetWindowLongA(hwnd, GWL_STYLE) & CCS_NORESIZE)
    26792680        uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
    26802681
     
    26952696
    26962697
    2697 static LRESULT 
     2698static LRESULT
    26982699TAB_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
    26992700{
     
    27112712
    27122713  SetWindowLongA(hwnd, 0, (DWORD)infoPtr);
    2713    
     2714
    27142715  infoPtr->uNumItem        = 0;
    27152716  infoPtr->uNumRows        = 0;
     
    27192720  infoPtr->iSelected       = -1;
    27202721  infoPtr->iHotTracked     = -1;
    2721   infoPtr->uFocus          = -1; 
     2722  infoPtr->uFocus          = -1;
    27222723  infoPtr->hwndToolTip     = 0;
    27232724  infoPtr->DoRedraw        = TRUE;
     
    27252726  infoPtr->hwndUpDown      = 0;
    27262727  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 
     2728  infoPtr->fSizeSet    = FALSE;
     2729  infoPtr->bUnicode    = IsWindowUnicode (hwnd);
     2730
     2731  TRACE("Created tab control, hwnd [%04x]\n", hwnd);
     2732
     2733  /* The tab control always has the WS_CLIPSIBLINGS style. Even
     2734     if you don't specify it in CreateWindow. This is necessary in
    27342735     order for paint to work correctly. This follows windows behaviour. */
    27352736  dwStyle = GetWindowLongA(hwnd, GWL_STYLE);
     
    27402741    infoPtr->hwndToolTip =
    27412742      CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
    2742                        CW_USEDEFAULT, CW_USEDEFAULT,
    2743                        CW_USEDEFAULT, CW_USEDEFAULT,
    2744                        hwnd, 0, 0, 0);
    2745    
     2743               CW_USEDEFAULT, CW_USEDEFAULT,
     2744               CW_USEDEFAULT, CW_USEDEFAULT,
     2745               hwnd, 0, 0, 0);
     2746
    27462747    /* Send NM_TOOLTIPSCREATED notification */
    27472748    if (infoPtr->hwndToolTip) {
    27482749      NMTOOLTIPSCREATED nmttc;
    2749      
     2750
    27502751      nmttc.hdr.hwndFrom = hwnd;
    27512752      nmttc.hdr.idFrom = GetWindowLongA(hwnd, GWL_ID);
    27522753      nmttc.hdr.code = NM_TOOLTIPSCREATED;
    27532754      nmttc.hwndToolTips = infoPtr->hwndToolTip;
    2754      
     2755
    27552756      SendMessageA (GetParent (hwnd), WM_NOTIFY,
    2756                     (WPARAM)GetWindowLongA(hwnd, GWL_ID), (LPARAM)&nmttc);
    2757     }
    2758   } 
    2759    
     2757            (WPARAM)GetWindowLongA(hwnd, GWL_ID), (LPARAM)&nmttc);
     2758    }
     2759  }
     2760
    27602761  /*
    27612762   * We need to get text information so we need a DC and we need to select
    27622763   * a font.
    27632764   */
    2764   hdc = GetDC(hwnd); 
     2765  hdc = GetDC(hwnd);
    27652766  hOldFont = SelectObject (hdc, GetStockObject (SYSTEM_FONT));
    27662767
     
    27692770
    27702771  /*
    2771    * Make sure there is enough space for the letters + growing the 
    2772    * selected item + extra space for the selected item.   
     2772   * Make sure there is enough space for the letters + growing the
     2773   * selected item + extra space for the selected item.
    27732774   */
    27742775  infoPtr->tabHeight = fontMetrics.tmHeight + 2 * VERTICAL_ITEM_PADDING +
     
    27962797    for (iItem = 0; iItem < infoPtr->uNumItem; iItem++) {
    27972798      if (infoPtr->items[iItem].pszText)
    2798         COMCTL32_Free (infoPtr->items[iItem].pszText);
     2799    COMCTL32_Free (infoPtr->items[iItem].pszText);
    27992800    }
    28002801    COMCTL32_Free (infoPtr->items);
    28012802  }
    2802  
    2803   if (infoPtr->hwndToolTip) 
     2803
     2804  if (infoPtr->hwndToolTip)
    28042805    DestroyWindow (infoPtr->hwndToolTip);
    2805  
     2806
    28062807  if (infoPtr->hwndUpDown)
    28072808    DestroyWindow(infoPtr->hwndUpDown);
     
    28272828    case TCM_GETIMAGELIST:
    28282829      return TAB_GetImageList (hwnd, wParam, lParam);
    2829      
     2830
    28302831    case TCM_SETIMAGELIST:
    28312832      return TAB_SetImageList (hwnd, wParam, lParam);
    2832      
     2833
    28332834    case TCM_GETITEMCOUNT:
    28342835      return TAB_GetItemCount (hwnd, wParam, lParam);
    2835      
     2836
    28362837    case TCM_GETITEMA:
    28372838      return TAB_GetItemA (hwnd, wParam, lParam);
    2838      
     2839
    28392840    case TCM_GETITEMW:
    28402841      return TAB_GetItemW (hwnd, wParam, lParam);
    2841      
     2842
    28422843    case TCM_SETITEMA:
    28432844      return TAB_SetItemA (hwnd, wParam, lParam);
    2844      
     2845
    28452846    case TCM_SETITEMW:
    28462847      return TAB_SetItemW (hwnd, wParam, lParam);
    2847      
     2848
    28482849    case TCM_DELETEITEM:
    28492850      return TAB_DeleteItem (hwnd, wParam, lParam);
    2850      
     2851
    28512852    case TCM_DELETEALLITEMS:
    28522853     return TAB_DeleteAllItems (hwnd, wParam, lParam);
    2853      
     2854
    28542855    case TCM_GETITEMRECT:
    28552856     return TAB_GetItemRect (hwnd, wParam, lParam);
    2856      
     2857
    28572858    case TCM_GETCURSEL:
    28582859      return TAB_GetCurSel (hwnd);
    2859      
     2860
    28602861    case TCM_HITTEST:
    28612862      return TAB_HitTest (hwnd, wParam, lParam);
    2862      
     2863
    28632864    case TCM_SETCURSEL:
    28642865      return TAB_SetCurSel (hwnd, wParam);
    2865      
     2866
    28662867    case TCM_INSERTITEMA:
    28672868      return TAB_InsertItemA (hwnd, wParam, lParam);
    2868      
     2869
    28692870    case TCM_INSERTITEMW:
    28702871      return TAB_InsertItemW (hwnd, wParam, lParam);
    2871      
     2872
    28722873    case TCM_SETITEMEXTRA:
    28732874      FIXME("Unimplemented msg TCM_SETITEMEXTRA\n");
    28742875      return 0;
    2875      
     2876
    28762877    case TCM_ADJUSTRECT:
    28772878      return TAB_AdjustRect (hwnd, (BOOL)wParam, (LPRECT)lParam);
    2878      
     2879
    28792880    case TCM_SETITEMSIZE:
    28802881      return TAB_SetItemSize (hwnd, wParam, lParam);
    2881      
     2882
    28822883    case TCM_REMOVEIMAGE:
    28832884      FIXME("Unimplemented msg TCM_REMOVEIMAGE\n");
    28842885      return 0;
    2885      
     2886
    28862887    case TCM_SETPADDING:
    28872888      FIXME("Unimplemented msg TCM_SETPADDING\n");
    28882889      return 0;
    2889      
     2890
    28902891    case TCM_GETROWCOUNT:
    28912892      return TAB_GetRowCount(hwnd);
     
    29002901      FIXME("Unimplemented msg TCM_HIGHLIGHTITEM\n");
    29012902      return 0;
    2902      
     2903
    29032904    case TCM_GETTOOLTIPS:
    29042905      return TAB_GetToolTips (hwnd, wParam, lParam);
    2905      
     2906
    29062907    case TCM_SETTOOLTIPS:
    29072908      return TAB_SetToolTips (hwnd, wParam, lParam);
    2908      
     2909
    29092910    case TCM_GETCURFOCUS:
    29102911      return TAB_GetCurFocus (hwnd);
    2911      
     2912
    29122913    case TCM_SETCURFOCUS:
    29132914      return TAB_SetCurFocus (hwnd, wParam);
    2914      
     2915
    29152916    case TCM_SETMINTABWIDTH:
    29162917      FIXME("Unimplemented msg TCM_SETMINTABWIDTH\n");
    29172918      return 0;
    2918      
     2919
    29192920    case TCM_DESELECTALL:
    29202921      FIXME("Unimplemented msg TCM_DESELECTALL\n");
    29212922      return 0;
    2922      
     2923
    29232924    case TCM_GETEXTENDEDSTYLE:
    29242925      FIXME("Unimplemented msg TCM_GETEXTENDEDSTYLE\n");
     
    29312932    case WM_GETFONT:
    29322933      return TAB_GetFont (hwnd, wParam, lParam);
    2933      
     2934
    29342935    case WM_SETFONT:
    29352936      return TAB_SetFont (hwnd, wParam, lParam);
    2936      
     2937
    29372938    case WM_CREATE:
    29382939      return TAB_Create (hwnd, wParam, lParam);
    2939      
     2940
    29402941    case WM_NCDESTROY:
    29412942      return TAB_Destroy (hwnd, wParam, lParam);
    2942      
     2943
    29432944    case WM_GETDLGCODE:
    29442945      return DLGC_WANTARROWS | DLGC_WANTCHARS;
    2945      
     2946
    29462947    case WM_LBUTTONDOWN:
    29472948      return TAB_LButtonDown (hwnd, wParam, lParam);
    2948      
     2949
    29492950    case WM_LBUTTONUP:
    29502951      return TAB_LButtonUp (hwnd, wParam, lParam);
    2951      
     2952
    29522953    case WM_RBUTTONDOWN:
    29532954      return TAB_RButtonDown (hwnd, wParam, lParam);
    2954      
     2955
    29552956    case WM_MOUSEMOVE:
    29562957      return TAB_MouseMove (hwnd, wParam, lParam);
    2957      
     2958
    29582959    case WM_ERASEBKGND:
    29592960      return TAB_EraseBackground (hwnd, (HDC)wParam);
     
    29642965    case WM_SIZE:
    29652966      return TAB_Size (hwnd, wParam, lParam);
    2966      
     2967
    29672968    case WM_SETREDRAW:
    29682969      return TAB_SetRedraw (hwnd, wParam);
     
    29752976      InvalidateRect(hwnd, NULL, TRUE);
    29762977      return 0;
    2977      
     2978
    29782979    case WM_KILLFOCUS:
    29792980    case WM_SETFOCUS:
     
    29872988    default:
    29882989      if (uMsg >= WM_USER)
    2989         WARN("unknown msg %04x wp=%08x lp=%08lx\n",
    2990              uMsg, wParam, lParam);
     2990    WARN("unknown msg %04x wp=%08x lp=%08lx\n",
     2991         uMsg, wParam, lParam);
    29912992#ifdef __WIN32OS2__
    29922993      return defComCtl32ProcA (hwnd, uMsg, wParam, lParam);
     
    30133014  wndClass.hbrBackground = (HBRUSH)NULL;
    30143015  wndClass.lpszClassName = WC_TABCONTROLA;
    3015  
     3016
    30163017  RegisterClassA (&wndClass);
    30173018}
  • trunk/src/comctl32/toolbar.c

    r6380 r6644  
     1/* $Id: toolbar.c,v 1.29 2001-09-05 12:05:03 bird Exp $ */
    12/*
    23 * Toolbar control
     
    6263    INT nRow;
    6364    RECT rect;
    64 } TBUTTON_INFO; 
     65} TBUTTON_INFO;
    6566
    6667#ifdef __WIN32OS2__
     
    131132#define TOP_BORDER         2
    132133#define BOTTOM_BORDER      2
    133 #define DDARROW_WIDTH      11 
     134#define DDARROW_WIDTH      11
    134135
    135136#define TOOLBAR_GetInfoPtr(hwnd) ((TOOLBAR_INFO *)GetWindowLongA(hwnd,0))
     
    147148    else if ((btnPtr->iString >= 0) && (btnPtr->iString < infoPtr->nNumStrings))
    148149        lpText = infoPtr->strings[btnPtr->iString];
    149    
     150
    150151    return lpText;
    151152}
    152153
    153 static BOOL 
     154static BOOL
    154155TOOLBAR_IsValidBitmapIndex(TOOLBAR_INFO *infoPtr, INT index)
    155156{
     
    195196 * Draw the text string for this button.
    196197 * note: infoPtr->himlDis *SHOULD* be non-zero when infoPtr->himlDef
    197  *      is non-zero, so we can simply check himlDef to see if we have
     198 *  is non-zero, so we can simply check himlDef to see if we have
    198199 *      an image list
    199200 */
    200201static void
    201202TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
    202                     HDC hdc, INT nState, DWORD dwStyle)
     203            HDC hdc, INT nState, DWORD dwStyle)
    203204{
    204205    RECT   rcText = btnPtr->rect;
     
    219220    if (lpText) {
    220221
    221         InflateRect (&rcText, -3, -3);
    222 
    223         if (himl && TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
    224                 if ((dwStyle & TBSTYLE_LIST) &&
    225                     ((btnPtr->fsStyle & TBSTYLE_AUTOSIZE) == 0) &&
    226                     (btnPtr->iBitmap != I_IMAGENONE)) {
    227                     rcText.left += infoPtr->nBitmapWidth;
    228                 }
    229                 else {
    230                     rcText.top += infoPtr->nBitmapHeight;
    231                 }
    232         }
    233 
    234         if (nState & (TBSTATE_PRESSED | TBSTATE_CHECKED))
    235             OffsetRect (&rcText, 1, 1);
    236 
    237         hOldFont = SelectObject (hdc, infoPtr->hFont);
    238         nOldBkMode = SetBkMode (hdc, TRANSPARENT);
    239         if (!(nState & TBSTATE_ENABLED)) {
    240             clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DHILIGHT));
    241             OffsetRect (&rcText, 1, 1);
    242             DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
    243             SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
    244             OffsetRect (&rcText, -1, -1);
    245             DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
    246         }
    247         else if (nState & TBSTATE_INDETERMINATE) {
    248             clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
    249             DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
    250         }
    251         else {
    252             clrOld = SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT));
    253             DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
    254         }
    255 
    256         SetTextColor (hdc, clrOld);
    257         SelectObject (hdc, hOldFont);
    258         if (nOldBkMode != TRANSPARENT)
    259             SetBkMode (hdc, nOldBkMode);
     222    InflateRect (&rcText, -3, -3);
     223
     224    if (himl && TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
     225        if ((dwStyle & TBSTYLE_LIST) &&
     226            ((btnPtr->fsStyle & TBSTYLE_AUTOSIZE) == 0) &&
     227            (btnPtr->iBitmap != I_IMAGENONE)) {
     228            rcText.left += infoPtr->nBitmapWidth;
     229        }
     230        else {
     231            rcText.top += infoPtr->nBitmapHeight;
     232        }
     233    }
     234
     235    if (nState & (TBSTATE_PRESSED | TBSTATE_CHECKED))
     236        OffsetRect (&rcText, 1, 1);
     237
     238    hOldFont = SelectObject (hdc, infoPtr->hFont);
     239    nOldBkMode = SetBkMode (hdc, TRANSPARENT);
     240    if (!(nState & TBSTATE_ENABLED)) {
     241        clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DHILIGHT));
     242        OffsetRect (&rcText, 1, 1);
     243        DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
     244        SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
     245        OffsetRect (&rcText, -1, -1);
     246        DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
     247    }
     248    else if (nState & TBSTATE_INDETERMINATE) {
     249        clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
     250        DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
     251    }
     252    else {
     253        clrOld = SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT));
     254        DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
     255    }
     256
     257    SetTextColor (hdc, clrOld);
     258    SelectObject (hdc, hOldFont);
     259    if (nOldBkMode != TRANSPARENT)
     260        SetBkMode (hdc, nOldBkMode);
    260261    }
    261262}
     
    275276static void
    276277TOOLBAR_DrawMasked (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
    277                     HDC hdc, INT x, INT y)
     278            HDC hdc, INT x, INT y)
    278279{
    279280    /* FIXME: this function is a hack since it uses image list
    280               internals directly */
     281          internals directly */
    281282
    282283    HIMAGELIST himl = infoPtr->himlDef;
     
    286287
    287288    if (!himl)
    288         return;
     289    return;
    289290
    290291    /* create new dc's */
     
    301302    SetTextColor (hdcImageList, RGB(0, 0, 0));
    302303    BitBlt (hdcMask, 0, 0, himl->cx, himl->cy,
    303               hdcImageList, himl->cx * btnPtr->iBitmap, 0, SRCCOPY);
     304          hdcImageList, himl->cx * btnPtr->iBitmap, 0, SRCCOPY);
    304305
    305306    /* draw the new mask */
    306307    SelectObject (hdc, GetSysColorBrush (COLOR_3DHILIGHT));
    307308    BitBlt (hdc, x+1, y+1, himl->cx, himl->cy,
    308               hdcMask, 0, 0, 0xB8074A);
     309          hdcMask, 0, 0, 0xB8074A);
    309310
    310311    SelectObject (hdc, GetSysColorBrush (COLOR_3DSHADOW));
    311312    BitBlt (hdc, x, y, himl->cx, himl->cy,
    312               hdcMask, 0, 0, 0xB8074A);
     313          hdcMask, 0, 0, 0xB8074A);
    313314
    314315    DeleteObject (hbmMask);
     
    324325    DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
    325326    BOOL hasDropDownArrow = TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) &&
    326                             (btnPtr->fsStyle & TBSTYLE_DROPDOWN);
     327                        (btnPtr->fsStyle & TBSTYLE_DROPDOWN);
    327328    RECT rc, rcArrow, rcBitmap;
    328329
    329330    if (btnPtr->fsState & TBSTATE_HIDDEN)
    330         return;
     331    return;
    331332
    332333    rc = btnPtr->rect;
     
    338339    if (hasDropDownArrow)
    339340    {
    340         if (dwStyle & TBSTYLE_FLAT)
     341    if (dwStyle & TBSTYLE_FLAT)
    341342            rc.right = max(rc.left, rc.right - DDARROW_WIDTH);
    342         else
     343    else
    343344            rc.right = max(rc.left, rc.right - DDARROW_WIDTH - 2);
    344         rcArrow.left = rc.right;
     345    rcArrow.left = rc.right;
    345346    }
    346347
     
    363364        /* when drawing the vertical bar...      */
    364365        if ((dwStyle & TBSTYLE_FLAT) /* && (btnPtr->iBitmap == 0) */)
    365             TOOLBAR_DrawFlatSeparator (&rc, hdc);
    366         return;
     366        TOOLBAR_DrawFlatSeparator (&rc, hdc);
     367    return;
    367368    }
    368369
    369370    /* disabled */
    370371    if (!(btnPtr->fsState & TBSTATE_ENABLED)) {
    371         if (!(dwStyle & TBSTYLE_FLAT))
    372         {
    373             DrawEdge (hdc, &rc, EDGE_RAISED,
    374                       BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
     372    if (!(dwStyle & TBSTYLE_FLAT))
     373    {
     374        DrawEdge (hdc, &rc, EDGE_RAISED,
     375              BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
    375376            if (hasDropDownArrow)
    376377            DrawEdge (hdc, &rcArrow, EDGE_RAISED,
    377                       BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
    378         }
    379        
     378              BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
     379    }
     380
    380381        if (hasDropDownArrow)
    381         {
    382             TOOLBAR_DrawArrow(hdc, rcArrow.left+1, rcArrow.top+1, COLOR_3DHIGHLIGHT);
    383             TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_3DSHADOW);
    384         }
    385 
    386         if (infoPtr->himlDis &&
     382    {
     383        TOOLBAR_DrawArrow(hdc, rcArrow.left+1, rcArrow.top+1, COLOR_3DHIGHLIGHT);
     384        TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_3DSHADOW);
     385    }
     386
     387    if (infoPtr->himlDis &&
    387388            TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap))
    388             ImageList_Draw (infoPtr->himlDis, btnPtr->iBitmap, hdc,
    389                         rcBitmap.left, rcBitmap.top, ILD_NORMAL);
    390         else
    391             TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top);
    392 
    393         TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
    394         return;
     389        ImageList_Draw (infoPtr->himlDis, btnPtr->iBitmap, hdc,
     390            rcBitmap.left, rcBitmap.top, ILD_NORMAL);
     391    else
     392        TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top);
     393
     394    TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
     395    return;
    395396    }
    396397
    397398    /* pressed TBSTYLE_BUTTON */
    398399    if (btnPtr->fsState & TBSTATE_PRESSED) {
    399         if (dwStyle & TBSTYLE_FLAT)
    400         {
    401             DrawEdge (hdc, &rc, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE | BF_ADJUST);
     400    if (dwStyle & TBSTYLE_FLAT)
     401    {
     402        DrawEdge (hdc, &rc, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE | BF_ADJUST);
    402403            if (hasDropDownArrow)
    403             DrawEdge (hdc, &rcArrow, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE | BF_ADJUST);
    404         }
    405         else
    406         {
    407             DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
     404        DrawEdge (hdc, &rcArrow, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE | BF_ADJUST);
     405    }
     406    else
     407    {
     408        DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
    408409            if (hasDropDownArrow)
    409             DrawEdge (hdc, &rcArrow, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
    410         }
     410        DrawEdge (hdc, &rcArrow, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
     411    }
    411412
    412413        if (hasDropDownArrow)
    413             TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_WINDOWFRAME);
     414        TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_WINDOWFRAME);
    414415
    415416        if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap))
    416             ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
    417                         rcBitmap.left + 1, rcBitmap.top + 1, ILD_NORMAL);
    418 
    419         TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
    420         return;
     417        ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
     418            rcBitmap.left + 1, rcBitmap.top + 1, ILD_NORMAL);
     419
     420    TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
     421    return;
    421422    }
    422423
    423424    /* checked TBSTYLE_CHECK */
    424425    if ((btnPtr->fsStyle & TBSTYLE_CHECK) &&
    425         (btnPtr->fsState & TBSTATE_CHECKED)) {
    426         if (dwStyle & TBSTYLE_FLAT)
    427             DrawEdge (hdc, &rc, BDR_SUNKENOUTER,
    428                         BF_RECT | BF_MIDDLE | BF_ADJUST);
    429         else
    430             DrawEdge (hdc, &rc, EDGE_SUNKEN,
    431                         BF_RECT | BF_MIDDLE | BF_ADJUST);
    432 
    433         TOOLBAR_DrawPattern (hdc, &rc);
    434        
     426    (btnPtr->fsState & TBSTATE_CHECKED)) {
     427    if (dwStyle & TBSTYLE_FLAT)
     428        DrawEdge (hdc, &rc, BDR_SUNKENOUTER,
     429            BF_RECT | BF_MIDDLE | BF_ADJUST);
     430    else
     431        DrawEdge (hdc, &rc, EDGE_SUNKEN,
     432            BF_RECT | BF_MIDDLE | BF_ADJUST);
     433
     434    TOOLBAR_DrawPattern (hdc, &rc);
     435
    435436        if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap))
    436             ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
    437                         rcBitmap.left + 1, rcBitmap.top + 1, ILD_NORMAL);
    438         TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
    439         return;
    440     }
    441 
    442     /* indeterminate */ 
     437        ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
     438            rcBitmap.left + 1, rcBitmap.top + 1, ILD_NORMAL);
     439    TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
     440    return;
     441    }
     442
     443    /* indeterminate */
    443444    if (btnPtr->fsState & TBSTATE_INDETERMINATE) {
    444         DrawEdge (hdc, &rc, EDGE_RAISED,
    445                     BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
    446 
    447         TOOLBAR_DrawPattern (hdc, &rc);
    448         TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top);
    449         TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
    450         return;
     445    DrawEdge (hdc, &rc, EDGE_RAISED,
     446            BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
     447
     448    TOOLBAR_DrawPattern (hdc, &rc);
     449    TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top);
     450    TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
     451    return;
    451452    }
    452453
     
    454455    if (dwStyle & TBSTYLE_FLAT)
    455456    {
    456         if (btnPtr->bHot)
    457         {
    458             DrawEdge (hdc, &rc, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
     457    if (btnPtr->bHot)
     458    {
     459        DrawEdge (hdc, &rc, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
    459460            if (hasDropDownArrow)
    460             DrawEdge (hdc, &rcArrow, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
    461         }
     461        DrawEdge (hdc, &rcArrow, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
     462    }
    462463        else
    463         {
     464    {
    464465            FrameRect(hdc, &rc, GetSysColorBrush(COLOR_BTNFACE));
    465466            if (hasDropDownArrow)
    466467            FrameRect(hdc, &rcArrow, GetSysColorBrush(COLOR_BTNFACE));
    467         }
     468    }
    468469
    469470        if (hasDropDownArrow)
    470             TOOLBAR_DrawArrow(hdc, rcArrow.left+1, rcArrow.top, COLOR_WINDOWFRAME);
    471 
    472         if (btnPtr->bHot && infoPtr->himlHot &&
     471        TOOLBAR_DrawArrow(hdc, rcArrow.left+1, rcArrow.top, COLOR_WINDOWFRAME);
     472
     473    if (btnPtr->bHot && infoPtr->himlHot &&
    473474            TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap))
    474             ImageList_Draw (infoPtr->himlHot, btnPtr->iBitmap, hdc,
    475                         rcBitmap.left, rcBitmap.top, ILD_NORMAL);
    476         else if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap))
    477             ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
    478                         rcBitmap.left, rcBitmap.top, ILD_NORMAL);
     475        ImageList_Draw (infoPtr->himlHot, btnPtr->iBitmap, hdc,
     476            rcBitmap.left, rcBitmap.top, ILD_NORMAL);
     477    else if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap))
     478        ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
     479            rcBitmap.left, rcBitmap.top, ILD_NORMAL);
    479480    }
    480481    else
    481482    {
    482         DrawEdge (hdc, &rc, EDGE_RAISED,
    483                 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
     483    DrawEdge (hdc, &rc, EDGE_RAISED,
     484        BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
    484485
    485486        if (hasDropDownArrow)
    486         {
    487             DrawEdge (hdc, &rcArrow, EDGE_RAISED,
    488                     BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
    489             TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_WINDOWFRAME);
    490         }
     487    {
     488        DrawEdge (hdc, &rcArrow, EDGE_RAISED,
     489            BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
     490        TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_WINDOWFRAME);
     491    }
    491492
    492493        if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap))
    493             ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
    494                         rcBitmap.left, rcBitmap.top, ILD_NORMAL);
     494        ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
     495            rcBitmap.left, rcBitmap.top, ILD_NORMAL);
    495496    }
    496497
     
    537538    if (!(btnPtr->fsState & TBSTATE_HIDDEN) &&
    538539         (btnPtr->iString > -1) &&
    539          (btnPtr->iString < infoPtr->nNumStrings)) 
     540         (btnPtr->iString < infoPtr->nNumStrings))
    540541    {
    541542        LPWSTR lpText = infoPtr->strings[btnPtr->iString];
     
    577578
    578579/***********************************************************************
    579 *               TOOLBAR_WrapToolbar
     580*       TOOLBAR_WrapToolbar
    580581*
    581 * This function walks through the buttons and seperators in the 
    582 * toolbar, and sets the TBSTATE_WRAP flag only on those items where 
    583 * wrapping should occur based on the width of the toolbar window. 
    584 * It does *not* calculate button placement itself.  That task 
    585 * takes place in TOOLBAR_CalcToolbar. If the program wants to manage 
    586 * the toolbar wrapping on it's own, it can use the TBSTYLE_WRAPPABLE 
     582* This function walks through the buttons and seperators in the
     583* toolbar, and sets the TBSTATE_WRAP flag only on those items where
     584* wrapping should occur based on the width of the toolbar window.
     585* It does *not* calculate button placement itself.  That task
     586* takes place in TOOLBAR_CalcToolbar. If the program wants to manage
     587* the toolbar wrapping on it's own, it can use the TBSTYLE_WRAPPABLE
    587588* flag, and set the TBSTATE_WRAP flags manually on the appropriate items.
    588 */ 
     589*/
    589590
    590591static void
     
    597598    BOOL bWrap, bButtonWrap;
    598599
    599     /*  When the toolbar window style is not TBSTYLE_WRAPABLE,  */
    600     /*  no layout is necessary. Applications may use this style */
    601     /*  to perform their own layout on the toolbar.             */
     600    /*  When the toolbar window style is not TBSTYLE_WRAPABLE,  */
     601    /*  no layout is necessary. Applications may use this style */
     602    /*  to perform their own layout on the toolbar.         */
    602603    if( !(dwStyle & TBSTYLE_WRAPABLE) )
    603         return;
     604    return;
    604605
    605606    btnPtr = infoPtr->buttons;
     
    616617    for (i = 0; i < infoPtr->nNumButtons; i++ )
    617618    {
    618         bWrap = FALSE;
    619         btnPtr[i].fsState &= ~TBSTATE_WRAP;
    620        
    621         if (btnPtr[i].fsState & TBSTATE_HIDDEN)
    622             continue;
    623 
    624         /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
    625         /* it is the actual width of the separator. This is used for */
    626         /* custom controls in toolbars.                              */
    627         if (btnPtr[i].fsStyle & TBSTYLE_SEP)
    628             cx = (btnPtr[i].iBitmap > 0) ? 
    629                         btnPtr[i].iBitmap : SEPARATOR_WIDTH;
    630         else
    631             cx = infoPtr->nButtonWidth;
    632 
    633         /* Two or more adjacent separators form a separator group.   */
    634         /* The first separator in a group should be wrapped to the   */
    635         /* next row if the previous wrapping is on a button.         */
    636         if( bButtonWrap &&
    637                 (btnPtr[i].fsStyle & TBSTYLE_SEP) &&
    638                 (i + 1 < infoPtr->nNumButtons ) &&
    639                 (btnPtr[i + 1].fsStyle & TBSTYLE_SEP) )
    640         {
    641             btnPtr[i].fsState |= TBSTATE_WRAP;
    642             x = infoPtr->nIndent;
    643             i++;
    644             bButtonWrap = FALSE;
    645             continue;
    646         }
    647 
    648         /* The layout makes sure the bitmap is visible, but not the button. */
    649         if ( x + cx - (infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2
    650                  > infoPtr->nWidth )
    651         {
    652             BOOL bFound = FALSE;
    653 
    654             /*  If the current button is a separator and not hidden,  */
    655             /*  go to the next until it reaches a non separator.      */
    656             /*  Wrap the last separator if it is before a button.     */
    657             while( ( (btnPtr[i].fsStyle & TBSTYLE_SEP) ||
    658                         (btnPtr[i].fsState & TBSTATE_HIDDEN) ) &&
    659                         i < infoPtr->nNumButtons )
    660             {
    661                 i++;
    662                 bFound = TRUE;
    663             }
    664    
    665             if( bFound && i < infoPtr->nNumButtons )
    666             {
    667                 i--;
    668                 btnPtr[i].fsState |= TBSTATE_WRAP;
    669                 x = infoPtr->nIndent;
    670                 bButtonWrap = FALSE;
    671                 continue;
    672             }
    673             else if ( i >= infoPtr->nNumButtons)
    674                 break;
    675 
    676             /*  If the current button is not a separator, find the last  */
    677             /*  separator and wrap it.                                  */
    678             for ( j = i - 1; j >= 0  &&  !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
    679             {
    680                 if ((btnPtr[j].fsStyle & TBSTYLE_SEP) &&
    681                         !(btnPtr[j].fsState & TBSTATE_HIDDEN))
    682                 {
    683                     bFound = TRUE;
    684                     i = j;
    685                     x = infoPtr->nIndent;
    686                     btnPtr[j].fsState |= TBSTATE_WRAP;
    687                     bButtonWrap = FALSE;
    688                     break;
    689                 }
    690             }
    691 
    692             /*  If no separator available for wrapping, wrap one of     */
    693             /*  non-hidden previous button.                             */
    694             if (!bFound)
    695             {
    696                 for ( j = i - 1;
    697                         j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
    698                 {
    699                     if (btnPtr[j].fsState & TBSTATE_HIDDEN)
    700                         continue;
    701 
    702                     bFound = TRUE;
    703                     i = j;
    704                     x = infoPtr->nIndent;
    705                     btnPtr[j].fsState |= TBSTATE_WRAP;
    706                     bButtonWrap = TRUE;
    707                     break;
    708                 }
    709             }
    710 
    711             /* If all above failed, wrap the current button. */
    712             if (!bFound) 
    713             {
    714                 btnPtr[i].fsState |= TBSTATE_WRAP;
    715                 bFound = TRUE;
    716                 x = infoPtr->nIndent;
    717                 if (btnPtr[i].fsState & TBSTYLE_SEP )
    718                     bButtonWrap = FALSE;
    719                 else
    720                     bButtonWrap = TRUE;
    721             }               
    722         }
    723         else
    724             x += cx;
     619    bWrap = FALSE;
     620    btnPtr[i].fsState &= ~TBSTATE_WRAP;
     621
     622    if (btnPtr[i].fsState & TBSTATE_HIDDEN)
     623        continue;
     624
     625    /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
     626    /* it is the actual width of the separator. This is used for */
     627    /* custom controls in toolbars.                              */
     628    if (btnPtr[i].fsStyle & TBSTYLE_SEP)
     629        cx = (btnPtr[i].iBitmap > 0) ?
     630            btnPtr[i].iBitmap : SEPARATOR_WIDTH;
     631    else
     632        cx = infoPtr->nButtonWidth;
     633
     634    /* Two or more adjacent separators form a separator group.   */
     635    /* The first separator in a group should be wrapped to the   */
     636    /* next row if the previous wrapping is on a button.         */
     637    if( bButtonWrap &&
     638        (btnPtr[i].fsStyle & TBSTYLE_SEP) &&
     639        (i + 1 < infoPtr->nNumButtons ) &&
     640        (btnPtr[i + 1].fsStyle & TBSTYLE_SEP) )
     641    {
     642        btnPtr[i].fsState |= TBSTATE_WRAP;
     643        x = infoPtr->nIndent;
     644        i++;
     645        bButtonWrap = FALSE;
     646        continue;
     647    }
     648
     649    /* The layout makes sure the bitmap is visible, but not the button. */
     650    if ( x + cx - (infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2
     651         > infoPtr->nWidth )
     652    {
     653        BOOL bFound = FALSE;
     654
     655        /*  If the current button is a separator and not hidden,  */
     656        /*  go to the next until it reaches a non separator.      */
     657        /*  Wrap the last separator if it is before a button.     */
     658        while( ( (btnPtr[i].fsStyle & TBSTYLE_SEP) ||
     659            (btnPtr[i].fsState & TBSTATE_HIDDEN) ) &&
     660            i < infoPtr->nNumButtons )
     661        {
     662        i++;
     663        bFound = TRUE;
     664        }
     665
     666        if( bFound && i < infoPtr->nNumButtons )
     667        {
     668        i--;
     669        btnPtr[i].fsState |= TBSTATE_WRAP;
     670        x = infoPtr->nIndent;
     671        bButtonWrap = FALSE;
     672        continue;
     673        }
     674        else if ( i >= infoPtr->nNumButtons)
     675        break;
     676
     677        /*  If the current button is not a separator, find the last  */
     678        /*  separator and wrap it.                  */
     679        for ( j = i - 1; j >= 0  &&  !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
     680        {
     681        if ((btnPtr[j].fsStyle & TBSTYLE_SEP) &&
     682            !(btnPtr[j].fsState & TBSTATE_HIDDEN))
     683        {
     684            bFound = TRUE;
     685            i = j;
     686            x = infoPtr->nIndent;
     687            btnPtr[j].fsState |= TBSTATE_WRAP;
     688            bButtonWrap = FALSE;
     689            break;
     690        }
     691        }
     692
     693        /*  If no separator available for wrapping, wrap one of     */
     694        /*  non-hidden previous button.                     */
     695        if (!bFound)
     696        {
     697        for ( j = i - 1;
     698            j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
     699        {
     700            if (btnPtr[j].fsState & TBSTATE_HIDDEN)
     701            continue;
     702
     703            bFound = TRUE;
     704            i = j;
     705            x = infoPtr->nIndent;
     706            btnPtr[j].fsState |= TBSTATE_WRAP;
     707            bButtonWrap = TRUE;
     708            break;
     709        }
     710        }
     711
     712        /* If all above failed, wrap the current button. */
     713        if (!bFound)
     714        {
     715        btnPtr[i].fsState |= TBSTATE_WRAP;
     716        bFound = TRUE;
     717        x = infoPtr->nIndent;
     718        if (btnPtr[i].fsState & TBSTYLE_SEP )
     719            bButtonWrap = FALSE;
     720        else
     721            bButtonWrap = TRUE;
     722        }
     723    }
     724    else
     725        x += cx;
    725726    }
    726727}
     
    728729
    729730/***********************************************************************
    730 *               TOOLBAR_CalcToolbar
     731*       TOOLBAR_CalcToolbar
    731732*
    732 * This function calculates button and separator placement. It first 
    733 * calculates the button sizes, gets the toolbar window width and then 
    734 * calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap 
     733* This function calculates button and separator placement. It first
     734* calculates the button sizes, gets the toolbar window width and then
     735* calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap
    735736* on. It assigns a new location to each item and sends this location to
    736 * the tooltip window if appropriate. Finally, it updates the rcBound 
    737 * rect and calculates the new required toolbar window height. 
    738 */ 
     737* the tooltip window if appropriate. Finally, it updates the rcBound
     738* rect and calculates the new required toolbar window height.
     739*/
    739740
    740741static void
     
    755756    if (dwStyle & TBSTYLE_LIST)
    756757    {
    757         infoPtr->nButtonHeight = max(infoPtr->nBitmapHeight, sizeString.cy) + 6;
    758         infoPtr->nButtonWidth = infoPtr->nBitmapWidth + sizeString.cx + 6;
     758    infoPtr->nButtonHeight = max(infoPtr->nBitmapHeight, sizeString.cy) + 6;
     759    infoPtr->nButtonWidth = infoPtr->nBitmapWidth + sizeString.cx + 6;
    759760    }
    760761    else {
    761762        for (i = 0; i < infoPtr->nNumButtons && !usesBitmaps; i++)
    762763        {
    763             if (TOOLBAR_IsValidBitmapIndex(infoPtr,infoPtr->buttons[i].iBitmap))
    764                 usesBitmaps = TRUE;
     764        if (TOOLBAR_IsValidBitmapIndex(infoPtr,infoPtr->buttons[i].iBitmap))
     765            usesBitmaps = TRUE;
    765766        }
    766767
     
    768769        {
    769770            if (usesBitmaps)
    770               infoPtr->nButtonHeight = sizeString.cy +
     771          infoPtr->nButtonHeight = sizeString.cy +
    771772                  infoPtr->nBitmapHeight + 6;
    772             else 
     773            else
    773774                infoPtr->nButtonHeight = sizeString.cy + 6;
    774775        }
    775776        else if (infoPtr->nButtonHeight < infoPtr->nBitmapHeight + 6)
    776             infoPtr->nButtonHeight = infoPtr->nBitmapHeight + 6;
     777        infoPtr->nButtonHeight = infoPtr->nBitmapHeight + 6;
    777778
    778779        if (sizeString.cx > infoPtr->nBitmapWidth)
    779             infoPtr->nButtonWidth = sizeString.cx + 6;
     780        infoPtr->nButtonWidth = sizeString.cx + 6;
    780781        else if (infoPtr->nButtonWidth < infoPtr->nBitmapWidth + 6)
    781             infoPtr->nButtonWidth = infoPtr->nBitmapWidth + 6;
     782        infoPtr->nButtonWidth = infoPtr->nBitmapWidth + 6;
    782783    }
    783784
     
    793794
    794795   /*
    795     * We will set the height below, and we set the width on entry 
    796     * so we do not reset them here.. 
     796    * We will set the height below, and we set the width on entry
     797    * so we do not reset them here..
    797798    */
    798799#if 0
     
    829830    for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++ )
    830831    {
    831         bWrap = FALSE;
    832         if (btnPtr->fsState & TBSTATE_HIDDEN)
    833         {
    834             SetRectEmpty (&btnPtr->rect);
    835             continue;
    836         }
    837 
    838             /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
    839             /* it is the actual width of the separator. This is used for */
    840             /* custom controls in toolbars.                              */
    841         if (btnPtr->fsStyle & TBSTYLE_SEP)
    842                 cx = (btnPtr->iBitmap > 0) ?
    843                      btnPtr->iBitmap : SEPARATOR_WIDTH;
    844         else
    845         {
    846             if (btnPtr->fsStyle & TBSTYLE_AUTOSIZE) 
     832    bWrap = FALSE;
     833    if (btnPtr->fsState & TBSTATE_HIDDEN)
     834    {
     835        SetRectEmpty (&btnPtr->rect);
     836        continue;
     837    }
     838
     839        /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
     840        /* it is the actual width of the separator. This is used for */
     841        /* custom controls in toolbars.                              */
     842    if (btnPtr->fsStyle & TBSTYLE_SEP)
     843        cx = (btnPtr->iBitmap > 0) ?
     844             btnPtr->iBitmap : SEPARATOR_WIDTH;
     845    else
     846    {
     847            if (btnPtr->fsStyle & TBSTYLE_AUTOSIZE)
    847848            {
    848849              SIZE sz;
     
    851852            }
    852853            else
    853               cx = infoPtr->nButtonWidth;
    854 
    855             if (hasDropDownArrows && (btnPtr->fsStyle & TBSTYLE_DROPDOWN))
    856               cx += DDARROW_WIDTH;
    857         }
    858         cy = infoPtr->nHeight;
    859 
    860         if (btnPtr->fsState & TBSTATE_WRAP )
    861                     bWrap = TRUE;
    862 
    863         SetRect (&btnPtr->rect, x, y, x + cx, y + cy);
    864 
    865         if (infoPtr->rcBound.left > x)
    866             infoPtr->rcBound.left = x;
    867         if (infoPtr->rcBound.right < x + cx)
    868             infoPtr->rcBound.right = x + cx;
    869         if (infoPtr->rcBound.bottom < y + cy)
    870             infoPtr->rcBound.bottom = y + cy;
    871 
    872         /* Set the toolTip only for non-hidden, non-separator button */
    873         if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & TBSTYLE_SEP ))
    874         {
    875             TTTOOLINFOA ti;
    876 
    877             ZeroMemory (&ti, sizeof(TTTOOLINFOA));
    878             ti.cbSize = sizeof(TTTOOLINFOA);
    879             ti.hwnd = hwnd;
    880             ti.uId = btnPtr->idCommand;
    881             ti.rect = btnPtr->rect;
    882             SendMessageA (infoPtr->hwndToolTip, TTM_NEWTOOLRECTA,
    883                             0, (LPARAM)&ti);
    884         }
    885 
    886         /* btnPtr->nRow is zero based. The space between the rows is    */
    887         /* also considered as a row.                                    */
    888         btnPtr->nRow = nRows + nSepRows;
    889         if( bWrap )
    890         {
    891             if ( !(btnPtr->fsStyle & TBSTYLE_SEP) )
    892                 y += cy;
    893             else
    894             {   
    895                 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
    896                 /* it is the actual width of the separator. This is used for */
    897                 /* custom controls in toolbars.                              */
    898                 y += cy + ( (btnPtr->iBitmap > 0 ) ?
    899                         btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 /3;
    900              
    901                 /* nSepRows is used to calculate the extra height follwoing  */         
    902                 /* the last row.                                             */
    903                 nSepRows++;
    904             }
    905             x = infoPtr->nIndent;
    906                 nRows++;
    907         }
    908         else
    909             x += cx;
     854          cx = infoPtr->nButtonWidth;
     855
     856        if (hasDropDownArrows && (btnPtr->fsStyle & TBSTYLE_DROPDOWN))
     857          cx += DDARROW_WIDTH;
     858    }
     859    cy = infoPtr->nHeight;
     860
     861    if (btnPtr->fsState & TBSTATE_WRAP )
     862            bWrap = TRUE;
     863
     864    SetRect (&btnPtr->rect, x, y, x + cx, y + cy);
     865
     866    if (infoPtr->rcBound.left > x)
     867        infoPtr->rcBound.left = x;
     868    if (infoPtr->rcBound.right < x + cx)
     869        infoPtr->rcBound.right = x + cx;
     870    if (infoPtr->rcBound.bottom < y + cy)
     871        infoPtr->rcBound.bottom = y + cy;
     872
     873    /* Set the toolTip only for non-hidden, non-separator button */
     874    if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & TBSTYLE_SEP ))
     875    {
     876        TTTOOLINFOA ti;
     877
     878        ZeroMemory (&ti, sizeof(TTTOOLINFOA));
     879        ti.cbSize = sizeof(TTTOOLINFOA);
     880        ti.hwnd = hwnd;
     881        ti.uId = btnPtr->idCommand;
     882        ti.rect = btnPtr->rect;
     883        SendMessageA (infoPtr->hwndToolTip, TTM_NEWTOOLRECTA,
     884                0, (LPARAM)&ti);
     885    }
     886
     887    /* btnPtr->nRow is zero based. The space between the rows is    */
     888    /* also considered as a row.                    */
     889    btnPtr->nRow = nRows + nSepRows;
     890    if( bWrap )
     891    {
     892        if ( !(btnPtr->fsStyle & TBSTYLE_SEP) )
     893            y += cy;
     894        else
     895        {
     896        /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
     897        /* it is the actual width of the separator. This is used for */
     898        /* custom controls in toolbars.                  */
     899        y += cy + ( (btnPtr->iBitmap > 0 ) ?
     900            btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 /3;
     901
     902        /* nSepRows is used to calculate the extra height follwoing  */
     903        /* the last row.                         */
     904        nSepRows++;
     905        }
     906        x = infoPtr->nIndent;
     907        nRows++;
     908    }
     909    else
     910        x += cx;
    910911    }
    911912
     
    913914    infoPtr->nRows = nRows + nSepRows + 1;
    914915
    915     /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following   */
    916     /* the last row.                                                    */
    917     infoPtr->nHeight = TOP_BORDER + (nRows + 1) * infoPtr->nButtonHeight + 
    918                         nSepRows * (SEPARATOR_WIDTH * 2 / 3) +
    919                         nSepRows * (infoPtr->nBitmapHeight + 1) +
    920                         BOTTOM_BORDER;
     916    /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following   */
     917    /* the last row.                            */
     918    infoPtr->nHeight = TOP_BORDER + (nRows + 1) * infoPtr->nButtonHeight +
     919                nSepRows * (SEPARATOR_WIDTH * 2 / 3) +
     920            nSepRows * (infoPtr->nBitmapHeight + 1) +
     921            BOTTOM_BORDER;
    921922    TRACE("toolbar height %d, button width %d\n", infoPtr->nHeight, infoPtr->nButtonWidth);
    922923}
     
    929930    TBUTTON_INFO *btnPtr;
    930931    INT i;
    931    
     932
    932933    btnPtr = infoPtr->buttons;
    933934    for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
    934         if (btnPtr->fsState & TBSTATE_HIDDEN)
    935             continue;
    936 
    937         if (btnPtr->fsStyle & TBSTYLE_SEP) {
    938             if (PtInRect (&btnPtr->rect, *lpPt)) {
    939                 TRACE(" ON SEPARATOR %d!\n", i);
    940                 return -i;
    941             }
    942         }
    943         else {
    944             if (PtInRect (&btnPtr->rect, *lpPt)) {
    945                 TRACE(" ON BUTTON %d!\n", i);
    946                 return i;
    947             }
    948         }
     935    if (btnPtr->fsState & TBSTATE_HIDDEN)
     936        continue;
     937
     938    if (btnPtr->fsStyle & TBSTYLE_SEP) {
     939        if (PtInRect (&btnPtr->rect, *lpPt)) {
     940        TRACE(" ON SEPARATOR %d!\n", i);
     941        return -i;
     942        }
     943    }
     944    else {
     945        if (PtInRect (&btnPtr->rect, *lpPt)) {
     946        TRACE(" ON BUTTON %d!\n", i);
     947        return i;
     948        }
     949    }
    949950    }
    950951
     
    962963    btnPtr = infoPtr->buttons;
    963964    for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
    964         if (btnPtr->idCommand == idCommand) {
    965             TRACE("command=%d index=%d\n", idCommand, i);
    966             return i;
    967         }
     965    if (btnPtr->idCommand == idCommand) {
     966        TRACE("command=%d index=%d\n", idCommand, i);
     967        return i;
     968    }
    968969    }
    969970    TRACE("no index found for command=%d\n", idCommand);
     
    979980
    980981    if ((nIndex < 0) || (nIndex > infoPtr->nNumButtons))
    981         return -1;
     982    return -1;
    982983
    983984    /* check index button */
    984985    btnPtr = &infoPtr->buttons[nIndex];
    985986    if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
    986         if (btnPtr->fsState & TBSTATE_CHECKED)
    987             return nIndex;
     987    if (btnPtr->fsState & TBSTATE_CHECKED)
     988        return nIndex;
    988989    }
    989990
     
    991992    nRunIndex = nIndex - 1;
    992993    while (nRunIndex >= 0) {
    993         btnPtr = &infoPtr->buttons[nRunIndex];
    994         if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
    995             if (btnPtr->fsState & TBSTATE_CHECKED)
    996                 return nRunIndex;
    997         }
    998         else
    999             break;
    1000         nRunIndex--;
     994    btnPtr = &infoPtr->buttons[nRunIndex];
     995    if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
     996        if (btnPtr->fsState & TBSTATE_CHECKED)
     997        return nRunIndex;
     998    }
     999    else
     1000        break;
     1001    nRunIndex--;
    10011002    }
    10021003
     
    10041005    nRunIndex = nIndex + 1;
    10051006    while (nRunIndex < infoPtr->nNumButtons) {
    1006         btnPtr = &infoPtr->buttons[nRunIndex]; 
    1007         if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
    1008             if (btnPtr->fsState & TBSTATE_CHECKED)
    1009                 return nRunIndex;
    1010         }
    1011         else
    1012             break;
    1013         nRunIndex++;
     1007    btnPtr = &infoPtr->buttons[nRunIndex];
     1008    if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
     1009        if (btnPtr->fsState & TBSTATE_CHECKED)
     1010        return nRunIndex;
     1011    }
     1012    else
     1013        break;
     1014    nRunIndex++;
    10141015    }
    10151016
     
    10201021static VOID
    10211022TOOLBAR_RelayEvent (HWND hwndTip, HWND hwndMsg, UINT uMsg,
    1022                     WPARAM wParam, LPARAM lParam)
     1023            WPARAM wParam, LPARAM lParam)
    10231024{
    10241025    MSG msg;
     
    10491050    switch (uMsg)
    10501051    {
    1051         case WM_INITDIALOG:
    1052             custInfo = (PCUSTDLG_INFO)lParam;
    1053             SetWindowLongA (hwnd, DWL_USER, (DWORD)custInfo);
    1054 
    1055             if (custInfo)
    1056             {
    1057                 char Buffer[256];
    1058                 int i = 0;
    1059                 int index;
    1060 
    1061                 /* send TBN_QUERYINSERT notification */
    1062                 nmtb.hdr.hwndFrom = hwnd;
    1063                 nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
    1064                 nmtb.hdr.code     = TBN_QUERYINSERT;
    1065                 nmtb.iItem = custInfo->tbInfo->nNumButtons;
    1066 
    1067                 if (!SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
    1068                                    (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb))
    1069                     return FALSE;
    1070 
    1071                 /* add items to 'toolbar buttons' list and check if removable */
    1072                 for (i = 0; i < custInfo->tbInfo->nNumButtons; i++)
    1073                 {
    1074                     btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
    1075                     memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
    1076                     btnInfo->btn.fsStyle = TBSTYLE_SEP;
    1077                     btnInfo->bVirtual = FALSE;
    1078                     LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
    1079 
    1080                     /* send TBN_QUERYDELETE notification */
    1081                     nmtb.hdr.hwndFrom = hwnd;
    1082                     nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
    1083                     nmtb.hdr.code     = TBN_QUERYDELETE;
    1084                     nmtb.iItem = i;
    1085 
    1086                     btnInfo->bRemovable = SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
    1087                                                         (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb);
    1088 
    1089                     index = (int)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, 0);
    1090                     SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
    1091                 }
    1092 
    1093                 /* insert separator button into 'available buttons' list */
    1094                 btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
    1095                 memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
    1096                 btnInfo->btn.fsStyle = TBSTYLE_SEP;
    1097                 btnInfo->bVirtual = FALSE;
    1098                 btnInfo->bRemovable = TRUE;
    1099                 LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
    1100                 index = (int)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)btnInfo);
    1101                 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
    1102 
    1103                 /* insert all buttons into dsa */
    1104                 for (i = 0;; i++)
    1105                 {
    1106                     /* send TBN_GETBUTTONINFO notification */
    1107                     nmtb.hdr.hwndFrom = hwnd;
    1108                     nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
    1109                     nmtb.hdr.code     = TBN_GETBUTTONINFOA;
    1110                     nmtb.iItem = i;
    1111                     nmtb.pszText = Buffer;
    1112                     nmtb.cchText = 256;
    1113 
    1114                     if (!SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
    1115                                        (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb))
    1116                         break;
    1117 
    1118                     TRACE("style: %x\n", nmtb.tbButton.fsStyle);               
    1119 
    1120                     /* insert button into the apropriate list */
    1121                     index = TOOLBAR_GetButtonIndex (custInfo->tbInfo, nmtb.tbButton.idCommand);
    1122                     if (index == -1)
    1123                     {
    1124                         btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
    1125                         memcpy (&btnInfo->btn, &nmtb.tbButton, sizeof(TBBUTTON));
    1126                         btnInfo->bVirtual = FALSE;
    1127                         btnInfo->bRemovable = TRUE;
    1128                         if (!(nmtb.tbButton.fsStyle & TBSTYLE_SEP))
    1129                             strcpy (btnInfo->text, nmtb.pszText);
    1130 
    1131                         index = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, 0);
    1132                         SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
    1133                     }
    1134                     else
    1135                     {
    1136                         btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
    1137                         memcpy (&btnInfo->btn, &nmtb.tbButton, sizeof(TBBUTTON));
    1138                         if (!(nmtb.tbButton.fsStyle & TBSTYLE_SEP))
    1139                             strcpy (btnInfo->text, nmtb.pszText);
    1140 
    1141                         SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
    1142                     }
    1143                 }
    1144 
    1145                 /* select first item in the 'available' list */
    1146                 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, 0, 0);
    1147 
    1148                 /* append 'virtual' separator button to the 'toolbar buttons' list */
    1149                 btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
    1150                 memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
    1151                 btnInfo->btn.fsStyle = TBSTYLE_SEP;
    1152                 btnInfo->bVirtual = TRUE;
    1153                 btnInfo->bRemovable = FALSE;
    1154                 LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
    1155                 index = (int)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)btnInfo);
    1156                 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
    1157 
    1158                 /* select last item in the 'toolbar' list */
    1159                 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index, 0);
    1160                 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETTOPINDEX, index, 0);
    1161 
    1162                 /* set focus and disable buttons */
    1163                 PostMessageA (hwnd, WM_USER, 0, 0);
    1164             }
    1165             return TRUE;
    1166 
    1167         case WM_USER:
    1168             EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
    1169             EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
    1170             EnableWindow (GetDlgItem (hwnd,IDC_REMOVE_BTN), FALSE);
    1171             SetFocus (GetDlgItem (hwnd, IDC_TOOLBARBTN_LBOX));
    1172             return TRUE;
    1173 
    1174         case WM_CLOSE:
    1175             EndDialog(hwnd, FALSE);
    1176             return TRUE;
    1177 
    1178         case WM_COMMAND:
    1179             switch (LOWORD(wParam))
    1180             {
    1181                 case IDC_TOOLBARBTN_LBOX:
    1182                     if (HIWORD(wParam) == LBN_SELCHANGE)
    1183                     {
    1184                         PCUSTOMBUTTON btnInfo;
    1185                         NMTOOLBARA nmtb;
    1186                         int count;
    1187                         int index;
    1188 
    1189                         count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
    1190                         index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
    1191 
    1192                         /* send TBN_QUERYINSERT notification */
    1193                         nmtb.hdr.hwndFrom = hwnd;
    1194                         nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
    1195                         nmtb.hdr.code     = TBN_QUERYINSERT;
    1196                         nmtb.iItem = index;
    1197 
    1198                         SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
    1199                                       (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb);
    1200 
    1201                         /* get list box item */
    1202                         btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
    1203 
    1204                         if (index == (count - 1))
    1205                         {
    1206                             /* last item (virtual separator) */
    1207                             EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
    1208                             EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
    1209                         }
    1210                         else if (index == (count - 2))
    1211                         {
    1212                             /* second last item (last non-virtual item) */
    1213                             EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
    1214                             EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
    1215                         }
    1216                         else if (index == 0)
    1217                         {
    1218                             /* first item */
    1219                             EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
    1220                             EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
    1221                         }
    1222                         else
    1223                         {
    1224                             EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
    1225                             EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
    1226                         }
    1227 
    1228                         EnableWindow (GetDlgItem (hwnd,IDC_REMOVE_BTN), btnInfo->bRemovable);
    1229                     }
    1230                     break;
    1231 
    1232                 case IDC_MOVEUP_BTN:
    1233                     {
    1234                         PCUSTOMBUTTON btnInfo;
    1235                         int index;
    1236                         int count;
    1237 
    1238                         count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
    1239                         index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
    1240                         TRACE("Move up: index %d\n", index);
    1241 
    1242                         /* send TBN_QUERYINSERT notification */
    1243                         nmtb.hdr.hwndFrom = hwnd;
    1244                         nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
    1245                         nmtb.hdr.code     = TBN_QUERYINSERT;
    1246                         nmtb.iItem = index;
    1247 
    1248                         if (SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
    1249                                           (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb))
    1250                         {
    1251                             btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
    1252 
    1253                             SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
    1254                             SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index-1, 0);
    1255                             SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index-1, (LPARAM)btnInfo);
    1256                             SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index-1 , 0);
    1257 
    1258                             if (index <= 1)
    1259                                 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
    1260                             else if (index >= (count - 3))
    1261                                 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
    1262 
    1263                             SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
    1264                             SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index-1, (LPARAM)&(btnInfo->btn));
    1265                         }
    1266                     }
    1267                     break;
    1268 
    1269                 case IDC_MOVEDN_BTN: /* move down */
    1270                     {
    1271                         PCUSTOMBUTTON btnInfo;
    1272                         int index;
    1273                         int count;
    1274 
    1275                         count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
    1276                         index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
    1277                         TRACE("Move up: index %d\n", index);
    1278 
    1279                         /* send TBN_QUERYINSERT notification */
    1280                         nmtb.hdr.hwndFrom = hwnd;
    1281                         nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
    1282                         nmtb.hdr.code     = TBN_QUERYINSERT;
    1283                         nmtb.iItem = index;
    1284 
    1285                         if (SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
    1286                                           (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb))
    1287                         {
    1288                             btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
    1289 
    1290                             /* move button down */
    1291                             SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
    1292                             SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index+1, 0);
    1293                             SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index+1, (LPARAM)btnInfo);
    1294                             SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index+1 , 0);
    1295 
    1296                             if (index == 0)
    1297                                 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
    1298                             else if (index >= (count - 3))
    1299                                 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
    1300 
    1301                             SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
    1302                             SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index+1, (LPARAM)&(btnInfo->btn));
    1303                         }
    1304                     }
    1305                     break;
    1306 
    1307                 case IDC_REMOVE_BTN: /* remove button */
    1308                     {
    1309                         PCUSTOMBUTTON btnInfo;
    1310                         int index;
    1311 
    1312                         index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
    1313                         TRACE("Remove: index %d\n", index);
    1314 
    1315                         /* send TBN_QUERYDELETE notification */
    1316                         nmtb.hdr.hwndFrom = hwnd;
    1317                         nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
    1318                         nmtb.hdr.code     = TBN_QUERYDELETE;
    1319                         nmtb.iItem = index;
    1320 
    1321                         if (SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
    1322                                           (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb))
    1323                         {
    1324                             btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
    1325                             SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
    1326                             SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index , 0);
    1327 
    1328                             SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
    1329 
    1330                             /* insert into 'available button' list */
    1331                             if (!(btnInfo->btn.fsStyle & TBSTYLE_SEP))
    1332                             {
    1333                                 index = (int)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, 0);
    1334                                 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
    1335                             }
    1336                             else
    1337                                 COMCTL32_Free (btnInfo);
    1338                         }
    1339                     }
    1340                     break;
    1341 
    1342                 case IDOK: /* Add button */
    1343                     {
    1344                         int index;
    1345                         int count;
    1346 
    1347                         count = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCOUNT, 0, 0);
    1348                         index = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCURSEL, 0, 0);
    1349                         TRACE("Add: index %d\n", index);
    1350 
    1351                         /* send TBN_QUERYINSERT notification */
    1352                         nmtb.hdr.hwndFrom = hwnd;
    1353                         nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
    1354                         nmtb.hdr.code     = TBN_QUERYINSERT;
    1355                         nmtb.iItem = index;
    1356 
    1357                         if (SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
    1358                                           (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb))
    1359                         {
    1360                             btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETITEMDATA, index, 0);
    1361 
    1362                             if (index != 0)
    1363                             {
    1364                                 /* remove from 'available buttons' list */
    1365                                 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_DELETESTRING, index, 0);
    1366                                 if (index == count-1)
    1367                                     SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, index-1 , 0);
    1368                                 else
    1369                                     SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, index , 0);
    1370                             }
    1371                             else
    1372                             {
    1373                                 PCUSTOMBUTTON btnNew;
    1374 
    1375                                 /* duplicate 'separator' button */
    1376                                 btnNew = (PCUSTOMBUTTON)COMCTL32_Alloc (sizeof(CUSTOMBUTTON));
    1377                                 memcpy (btnNew, btnInfo, sizeof(CUSTOMBUTTON));
    1378                                 btnInfo = btnNew;
    1379                             }
    1380 
    1381                             /* insert into 'toolbar button' list */
    1382                             index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
    1383                             SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index, 0);
    1384                             SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
    1385 
    1386                             SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index, (LPARAM)&(btnInfo->btn));
    1387                         }
    1388                     }
    1389                     break;
    1390 
    1391                 case IDCANCEL:
    1392                     EndDialog(hwnd, FALSE);
    1393                     break;
    1394             }
    1395             return TRUE;
    1396 
    1397         case WM_DESTROY:
    1398             {
    1399                 int count;
    1400                 int i;
    1401 
    1402                 /* delete items from 'toolbar buttons' listbox*/
    1403                 count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
    1404                 for (i = 0; i < count; i++)
    1405                 {
    1406                     btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, i, 0);
    1407                     COMCTL32_Free(btnInfo);
    1408                     SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, 0, 0);
    1409                 }
    1410                 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_RESETCONTENT, 0, 0);
    1411 
    1412 
    1413                 /* delete items from 'available buttons' listbox*/
    1414                 count = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCOUNT, 0, 0);
    1415                 for (i = 0; i < count; i++)
    1416                 {
    1417                     btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETITEMDATA, i, 0);
    1418                     COMCTL32_Free(btnInfo);
    1419                     SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, i, 0);
    1420                 }
    1421                 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_RESETCONTENT, 0, 0);
     1052    case WM_INITDIALOG:
     1053        custInfo = (PCUSTDLG_INFO)lParam;
     1054        SetWindowLongA (hwnd, DWL_USER, (DWORD)custInfo);
     1055
     1056        if (custInfo)
     1057        {
     1058        char Buffer[256];
     1059        int i = 0;
     1060        int index;
     1061
     1062        /* send TBN_QUERYINSERT notification */
     1063        nmtb.hdr.hwndFrom = hwnd;
     1064        nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
     1065        nmtb.hdr.code     = TBN_QUERYINSERT;
     1066        nmtb.iItem = custInfo->tbInfo->nNumButtons;
     1067
     1068        if (!SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
     1069                   (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb))
     1070            return FALSE;
     1071
     1072        /* add items to 'toolbar buttons' list and check if removable */
     1073        for (i = 0; i < custInfo->tbInfo->nNumButtons; i++)
     1074        {
     1075            btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
     1076            memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
     1077            btnInfo->btn.fsStyle = TBSTYLE_SEP;
     1078            btnInfo->bVirtual = FALSE;
     1079            LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
     1080
     1081            /* send TBN_QUERYDELETE notification */
     1082            nmtb.hdr.hwndFrom = hwnd;
     1083            nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
     1084            nmtb.hdr.code     = TBN_QUERYDELETE;
     1085            nmtb.iItem = i;
     1086
     1087            btnInfo->bRemovable = SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
     1088                            (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb);
     1089
     1090            index = (int)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, 0);
     1091            SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
     1092        }
     1093
     1094        /* insert separator button into 'available buttons' list */
     1095        btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
     1096        memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
     1097        btnInfo->btn.fsStyle = TBSTYLE_SEP;
     1098        btnInfo->bVirtual = FALSE;
     1099        btnInfo->bRemovable = TRUE;
     1100        LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
     1101        index = (int)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)btnInfo);
     1102        SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
     1103
     1104        /* insert all buttons into dsa */
     1105        for (i = 0;; i++)
     1106        {
     1107            /* send TBN_GETBUTTONINFO notification */
     1108            nmtb.hdr.hwndFrom = hwnd;
     1109            nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
     1110            nmtb.hdr.code     = TBN_GETBUTTONINFOA;
     1111            nmtb.iItem = i;
     1112            nmtb.pszText = Buffer;
     1113            nmtb.cchText = 256;
     1114
     1115            if (!SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
     1116                       (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb))
     1117            break;
     1118
     1119            TRACE("style: %x\n", nmtb.tbButton.fsStyle);
     1120
     1121            /* insert button into the apropriate list */
     1122            index = TOOLBAR_GetButtonIndex (custInfo->tbInfo, nmtb.tbButton.idCommand);
     1123            if (index == -1)
     1124            {
     1125            btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
     1126            memcpy (&btnInfo->btn, &nmtb.tbButton, sizeof(TBBUTTON));
     1127            btnInfo->bVirtual = FALSE;
     1128            btnInfo->bRemovable = TRUE;
     1129            if (!(nmtb.tbButton.fsStyle & TBSTYLE_SEP))
     1130                strcpy (btnInfo->text, nmtb.pszText);
     1131
     1132            index = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, 0);
     1133            SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
    14221134            }
    1423             return TRUE;
    1424 
    1425         case WM_DRAWITEM:
    1426             if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
    1427             {
    1428                 LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
    1429                 RECT rcButton;
    1430                 RECT rcText;
    1431                 HPEN hOldPen;
    1432                 HBRUSH hOldBrush;
    1433                 COLORREF oldText = 0;
    1434                 COLORREF oldBk = 0;
    1435 
    1436                 /* get item data */
    1437                 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, wParam, LB_GETITEMDATA, (WPARAM)lpdis->itemID, 0);
    1438                 if (btnInfo == NULL)
    1439                 {
    1440                     FIXME("btnInfo invalid!\n");
    1441                     return TRUE;
    1442                 }
    1443 
    1444                 /* set colors and select objects */
    1445                 oldBk = SetBkColor (lpdis->hDC, GetSysColor((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW));
    1446                 if (btnInfo->bVirtual)
    1447                    oldText = SetTextColor (lpdis->hDC, GetSysColor(COLOR_GRAYTEXT));
    1448                 else
    1449                    oldText = SetTextColor (lpdis->hDC, GetSysColor((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHTTEXT:COLOR_WINDOWTEXT));
    1450                 hOldPen = SelectObject (lpdis->hDC, GetSysColorPen ((lpdis->itemState & ODS_SELECTED)?COLOR_HIGHLIGHT:COLOR_WINDOW));
    1451                 hOldBrush = SelectObject (lpdis->hDC, GetSysColorBrush ((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW));
    1452 
    1453                 /* fill background rectangle */
    1454                 Rectangle (lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
    1455                            lpdis->rcItem.right, lpdis->rcItem.bottom);
    1456 
    1457                 /* calculate button and text rectangles */
    1458                 CopyRect (&rcButton, &lpdis->rcItem);
    1459                 InflateRect (&rcButton, -1, -1);
    1460                 CopyRect (&rcText, &rcButton);
    1461                 rcButton.right = rcButton.left + custInfo->tbInfo->nBitmapWidth + 6;
    1462                 rcText.left = rcButton.right + 2;
    1463 
    1464                 /* draw focus rectangle */
    1465                 if (lpdis->itemState & ODS_FOCUS)
    1466                     DrawFocusRect (lpdis->hDC, &lpdis->rcItem);
    1467 
    1468                 /* draw button */
    1469                 DrawEdge (lpdis->hDC, &rcButton, EDGE_RAISED, BF_RECT|BF_MIDDLE|BF_SOFT);
    1470 
    1471                 /* draw image and text */
    1472                 if ((btnInfo->btn.fsStyle & TBSTYLE_SEP) == 0)
    1473                     ImageList_Draw (custInfo->tbInfo->himlDef, btnInfo->btn.iBitmap, lpdis->hDC,
    1474                                     rcButton.left+3, rcButton.top+3, ILD_NORMAL);
    1475                 DrawTextA (lpdis->hDC,  btnInfo->text, -1, &rcText,
    1476                                DT_LEFT | DT_VCENTER | DT_SINGLELINE);
    1477 
    1478                 /* delete objects and reset colors */
    1479                 SelectObject (lpdis->hDC, hOldBrush);
    1480                 SelectObject (lpdis->hDC, hOldPen);
    1481                 SetBkColor (lpdis->hDC, oldBk);
    1482                 SetTextColor (lpdis->hDC, oldText);
    1483 
    1484                 return TRUE;
    1485             }
    1486             return FALSE;
    1487 
    1488         case WM_MEASUREITEM:
    1489             if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
    1490             {
    1491                 MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*)lParam;
    1492 
    1493                 if (custInfo && custInfo->tbInfo)
    1494                     lpmis->itemHeight = custInfo->tbInfo->nBitmapHeight + 8;
    1495                 else
    1496                     lpmis->itemHeight = 15 + 8; /* default height */
    1497 
    1498                 return TRUE;
    1499             }
    1500             return FALSE;
    1501 
    1502         default:
    1503             return FALSE;
     1135            else
     1136            {
     1137            btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
     1138            memcpy (&btnInfo->btn, &nmtb.tbButton, sizeof(TBBUTTON));
     1139            if (!(nmtb.tbButton.fsStyle & TBSTYLE_SEP))
     1140                strcpy (btnInfo->text, nmtb.pszText);
     1141
     1142            SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
     1143            }
     1144        }
     1145
     1146        /* select first item in the 'available' list */
     1147        SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, 0, 0);
     1148
     1149        /* append 'virtual' separator button to the 'toolbar buttons' list */
     1150        btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
     1151        memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
     1152        btnInfo->btn.fsStyle = TBSTYLE_SEP;
     1153        btnInfo->bVirtual = TRUE;
     1154        btnInfo->bRemovable = FALSE;
     1155        LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
     1156        index = (int)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)btnInfo);
     1157        SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
     1158
     1159        /* select last item in the 'toolbar' list */
     1160        SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index, 0);
     1161        SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETTOPINDEX, index, 0);
     1162
     1163        /* set focus and disable buttons */
     1164        PostMessageA (hwnd, WM_USER, 0, 0);
     1165        }
     1166        return TRUE;
     1167
     1168    case WM_USER:
     1169        EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
     1170        EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
     1171        EnableWindow (GetDlgItem (hwnd,IDC_REMOVE_BTN), FALSE);
     1172        SetFocus (GetDlgItem (hwnd, IDC_TOOLBARBTN_LBOX));
     1173        return TRUE;
     1174
     1175    case WM_CLOSE:
     1176        EndDialog(hwnd, FALSE);
     1177        return TRUE;
     1178
     1179    case WM_COMMAND:
     1180        switch (LOWORD(wParam))
     1181        {
     1182        case IDC_TOOLBARBTN_LBOX:
     1183            if (HIWORD(wParam) == LBN_SELCHANGE)
     1184            {
     1185            PCUSTOMBUTTON btnInfo;
     1186            NMTOOLBARA nmtb;
     1187            int count;
     1188            int index;
     1189
     1190            count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
     1191            index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
     1192
     1193            /* send TBN_QUERYINSERT notification */
     1194            nmtb.hdr.hwndFrom = hwnd;
     1195            nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
     1196            nmtb.hdr.code     = TBN_QUERYINSERT;
     1197            nmtb.iItem = index;
     1198
     1199            SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
     1200                      (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb);
     1201
     1202            /* get list box item */
     1203            btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
     1204
     1205            if (index == (count - 1))
     1206            {
     1207                /* last item (virtual separator) */
     1208                EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
     1209                EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
     1210            }
     1211            else if (index == (count - 2))
     1212            {
     1213                /* second last item (last non-virtual item) */
     1214                EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
     1215                EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
     1216            }
     1217            else if (index == 0)
     1218            {
     1219                /* first item */
     1220                EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
     1221                EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
     1222            }
     1223            else
     1224            {
     1225                EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
     1226                EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
     1227            }
     1228
     1229            EnableWindow (GetDlgItem (hwnd,IDC_REMOVE_BTN), btnInfo->bRemovable);
     1230            }
     1231            break;
     1232
     1233        case IDC_MOVEUP_BTN:
     1234            {
     1235            PCUSTOMBUTTON btnInfo;
     1236            int index;
     1237            int count;
     1238
     1239            count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
     1240            index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
     1241            TRACE("Move up: index %d\n", index);
     1242
     1243            /* send TBN_QUERYINSERT notification */
     1244            nmtb.hdr.hwndFrom = hwnd;
     1245            nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
     1246            nmtb.hdr.code     = TBN_QUERYINSERT;
     1247            nmtb.iItem = index;
     1248
     1249            if (SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
     1250                      (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb))
     1251            {
     1252                btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
     1253
     1254                SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
     1255                SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index-1, 0);
     1256                SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index-1, (LPARAM)btnInfo);
     1257                SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index-1 , 0);
     1258
     1259                if (index <= 1)
     1260                EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
     1261                else if (index >= (count - 3))
     1262                EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
     1263
     1264                SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
     1265                SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index-1, (LPARAM)&(btnInfo->btn));
     1266            }
     1267            }
     1268            break;
     1269
     1270        case IDC_MOVEDN_BTN: /* move down */
     1271            {
     1272            PCUSTOMBUTTON btnInfo;
     1273            int index;
     1274            int count;
     1275
     1276            count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
     1277            index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
     1278            TRACE("Move up: index %d\n", index);
     1279
     1280            /* send TBN_QUERYINSERT notification */
     1281            nmtb.hdr.hwndFrom = hwnd;
     1282            nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
     1283            nmtb.hdr.code     = TBN_QUERYINSERT;
     1284            nmtb.iItem = index;
     1285
     1286            if (SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
     1287                      (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb))
     1288            {
     1289                btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
     1290
     1291                /* move button down */
     1292                SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
     1293                SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index+1, 0);
     1294                SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index+1, (LPARAM)btnInfo);
     1295                SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index+1 , 0);
     1296
     1297                if (index == 0)
     1298                EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
     1299                else if (index >= (count - 3))
     1300                EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
     1301
     1302                SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
     1303                SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index+1, (LPARAM)&(btnInfo->btn));
     1304            }
     1305            }
     1306            break;
     1307
     1308        case IDC_REMOVE_BTN: /* remove button */
     1309            {
     1310            PCUSTOMBUTTON btnInfo;
     1311            int index;
     1312
     1313            index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
     1314            TRACE("Remove: index %d\n", index);
     1315
     1316            /* send TBN_QUERYDELETE notification */
     1317            nmtb.hdr.hwndFrom = hwnd;
     1318            nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
     1319            nmtb.hdr.code     = TBN_QUERYDELETE;
     1320            nmtb.iItem = index;
     1321
     1322            if (SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
     1323                      (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb))
     1324            {
     1325                btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
     1326                SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
     1327                SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index , 0);
     1328
     1329                SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
     1330
     1331                /* insert into 'available button' list */
     1332                if (!(btnInfo->btn.fsStyle & TBSTYLE_SEP))
     1333                {
     1334                index = (int)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, 0);
     1335                SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
     1336                }
     1337                else
     1338                COMCTL32_Free (btnInfo);
     1339            }
     1340            }
     1341            break;
     1342
     1343        case IDOK: /* Add button */
     1344            {
     1345            int index;
     1346            int count;
     1347
     1348            count = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCOUNT, 0, 0);
     1349            index = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCURSEL, 0, 0);
     1350            TRACE("Add: index %d\n", index);
     1351
     1352            /* send TBN_QUERYINSERT notification */
     1353            nmtb.hdr.hwndFrom = hwnd;
     1354            nmtb.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
     1355            nmtb.hdr.code     = TBN_QUERYINSERT;
     1356            nmtb.iItem = index;
     1357
     1358            if (SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY,
     1359                      (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb))
     1360            {
     1361                btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETITEMDATA, index, 0);
     1362
     1363                if (index != 0)
     1364                {
     1365                /* remove from 'available buttons' list */
     1366                SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_DELETESTRING, index, 0);
     1367                if (index == count-1)
     1368                    SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, index-1 , 0);
     1369                else
     1370                    SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, index , 0);
     1371                }
     1372                else
     1373                {
     1374                PCUSTOMBUTTON btnNew;
     1375
     1376                /* duplicate 'separator' button */
     1377                btnNew = (PCUSTOMBUTTON)COMCTL32_Alloc (sizeof(CUSTOMBUTTON));
     1378                memcpy (btnNew, btnInfo, sizeof(CUSTOMBUTTON));
     1379                btnInfo = btnNew;
     1380                }
     1381
     1382                /* insert into 'toolbar button' list */
     1383                index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
     1384                SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index, 0);
     1385                SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
     1386
     1387                SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index, (LPARAM)&(btnInfo->btn));
     1388            }
     1389            }
     1390            break;
     1391
     1392        case IDCANCEL:
     1393            EndDialog(hwnd, FALSE);
     1394            break;
     1395        }
     1396        return TRUE;
     1397
     1398    case WM_DESTROY:
     1399        {
     1400        int count;
     1401        int i;
     1402
     1403        /* delete items from 'toolbar buttons' listbox*/
     1404        count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
     1405        for (i = 0; i < count; i++)
     1406        {
     1407            btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, i, 0);
     1408            COMCTL32_Free(btnInfo);
     1409            SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, 0, 0);
     1410        }
     1411        SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_RESETCONTENT, 0, 0);
     1412
     1413
     1414        /* delete items from 'available buttons' listbox*/
     1415        count = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCOUNT, 0, 0);
     1416        for (i = 0; i < count; i++)
     1417        {
     1418            btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETITEMDATA, i, 0);
     1419            COMCTL32_Free(btnInfo);
     1420            SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, i, 0);
     1421        }
     1422        SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_RESETCONTENT, 0, 0);
     1423            }
     1424        return TRUE;
     1425
     1426    case WM_DRAWITEM:
     1427        if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
     1428        {
     1429        LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
     1430        RECT rcButton;
     1431        RECT rcText;
     1432        HPEN hOldPen;
     1433        HBRUSH hOldBrush;
     1434        COLORREF oldText = 0;
     1435        COLORREF oldBk = 0;
     1436
     1437        /* get item data */
     1438        btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, wParam, LB_GETITEMDATA, (WPARAM)lpdis->itemID, 0);
     1439        if (btnInfo == NULL)
     1440        {
     1441            FIXME("btnInfo invalid!\n");
     1442            return TRUE;
     1443        }
     1444
     1445        /* set colors and select objects */
     1446        oldBk = SetBkColor (lpdis->hDC, GetSysColor((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW));
     1447        if (btnInfo->bVirtual)
     1448           oldText = SetTextColor (lpdis->hDC, GetSysColor(COLOR_GRAYTEXT));
     1449        else
     1450           oldText = SetTextColor (lpdis->hDC, GetSysColor((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHTTEXT:COLOR_WINDOWTEXT));
     1451        hOldPen = SelectObject (lpdis->hDC, GetSysColorPen ((lpdis->itemState & ODS_SELECTED)?COLOR_HIGHLIGHT:COLOR_WINDOW));
     1452        hOldBrush = SelectObject (lpdis->hDC, GetSysColorBrush ((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW));
     1453
     1454        /* fill background rectangle */
     1455        Rectangle (lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
     1456               lpdis->rcItem.right, lpdis->rcItem.bottom);
     1457
     1458        /* calculate button and text rectangles */
     1459        CopyRect (&rcButton, &lpdis->rcItem);
     1460        InflateRect (&rcButton, -1, -1);
     1461        CopyRect (&rcText, &rcButton);
     1462        rcButton.right = rcButton.left + custInfo->tbInfo->nBitmapWidth + 6;
     1463        rcText.left = rcButton.right + 2;
     1464
     1465        /* draw focus rectangle */
     1466        if (lpdis->itemState & ODS_FOCUS)
     1467            DrawFocusRect (lpdis->hDC, &lpdis->rcItem);
     1468
     1469        /* draw button */
     1470        DrawEdge (lpdis->hDC, &rcButton, EDGE_RAISED, BF_RECT|BF_MIDDLE|BF_SOFT);
     1471
     1472        /* draw image and text */
     1473        if ((btnInfo->btn.fsStyle & TBSTYLE_SEP) == 0)
     1474            ImageList_Draw (custInfo->tbInfo->himlDef, btnInfo->btn.iBitmap, lpdis->hDC,
     1475                    rcButton.left+3, rcButton.top+3, ILD_NORMAL);
     1476        DrawTextA (lpdis->hDC,  btnInfo->text, -1, &rcText,
     1477                   DT_LEFT | DT_VCENTER | DT_SINGLELINE);
     1478
     1479        /* delete objects and reset colors */
     1480        SelectObject (lpdis->hDC, hOldBrush);
     1481        SelectObject (lpdis->hDC, hOldPen);
     1482        SetBkColor (lpdis->hDC, oldBk);
     1483        SetTextColor (lpdis->hDC, oldText);
     1484
     1485        return TRUE;
     1486        }
     1487        return FALSE;
     1488
     1489    case WM_MEASUREITEM:
     1490        if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
     1491        {
     1492        MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*)lParam;
     1493
     1494        if (custInfo && custInfo->tbInfo)
     1495            lpmis->itemHeight = custInfo->tbInfo->nBitmapHeight + 8;
     1496        else
     1497            lpmis->itemHeight = 15 + 8; /* default height */
     1498
     1499        return TRUE;
     1500        }
     1501        return FALSE;
     1502
     1503    default:
     1504        return FALSE;
    15041505    }
    15051506}
     
    15201521    TRACE("hwnd=%x wParam=%x lParam=%lx\n", hwnd, wParam, lParam);
    15211522    if (!lpAddBmp)
    1522         return -1;
     1523    return -1;
    15231524
    15241525    if (lpAddBmp->hInst == HINST_COMMCTRL)
    15251526    {
    1526         if ((lpAddBmp->nID & ~1) == IDB_STD_SMALL_COLOR)
    1527             nButtons = 15;
    1528         else if ((lpAddBmp->nID & ~1) == IDB_VIEW_SMALL_COLOR)
    1529             nButtons = 13;
    1530         else if ((lpAddBmp->nID & ~1) == IDB_HIST_SMALL_COLOR)
    1531             nButtons = 5;
    1532         else
    1533             return -1;
    1534 
    1535         TRACE ("adding %d internal bitmaps!\n", nButtons);
    1536 
    1537         /* Windows resize all the buttons to the size of a newly added standard image */
    1538         if (lpAddBmp->nID & 1)
    1539         {
    1540             /* large icons */
    1541             /* FIXME: on windows the size of the images is 25x24 but the size of the bitmap
    1542              * in rsrc is only 24x24. Fix the bitmap (how?) and then fix this 
     1527    if ((lpAddBmp->nID & ~1) == IDB_STD_SMALL_COLOR)
     1528        nButtons = 15;
     1529    else if ((lpAddBmp->nID & ~1) == IDB_VIEW_SMALL_COLOR)
     1530        nButtons = 13;
     1531    else if ((lpAddBmp->nID & ~1) == IDB_HIST_SMALL_COLOR)
     1532        nButtons = 5;
     1533    else
     1534        return -1;
     1535
     1536    TRACE ("adding %d internal bitmaps!\n", nButtons);
     1537
     1538    /* Windows resize all the buttons to the size of a newly added standard image */
     1539    if (lpAddBmp->nID & 1)
     1540    {
     1541        /* large icons */
     1542        /* FIXME: on windows the size of the images is 25x24 but the size of the bitmap
     1543             * in rsrc is only 24x24. Fix the bitmap (how?) and then fix this
    15431544             */
    1544             SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
    1545                           MAKELPARAM((WORD)24, (WORD)24));
    1546             SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
    1547                           MAKELPARAM((WORD)31, (WORD)30));
    1548         }       
    1549         else
    1550         {
    1551             /* small icons */
    1552             SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
    1553                           MAKELPARAM((WORD)16, (WORD)16));
    1554             SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
    1555                           MAKELPARAM((WORD)22, (WORD)22));
    1556         }
    1557        
    1558         TOOLBAR_CalcToolbar (hwnd);
     1545        SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
     1546              MAKELPARAM((WORD)24, (WORD)24));
     1547        SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
     1548              MAKELPARAM((WORD)31, (WORD)30));
    15591549    }
    15601550    else
    15611551    {
    1562         nButtons = (INT)wParam;
    1563         if (nButtons <= 0)
    1564             return -1;
    1565        
    1566         TRACE ("adding %d bitmaps!\n", nButtons);
    1567     }
    1568    
     1552        /* small icons */
     1553        SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
     1554              MAKELPARAM((WORD)16, (WORD)16));
     1555        SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
     1556              MAKELPARAM((WORD)22, (WORD)22));
     1557    }
     1558
     1559    TOOLBAR_CalcToolbar (hwnd);
     1560    }
     1561    else
     1562    {
     1563    nButtons = (INT)wParam;
     1564    if (nButtons <= 0)
     1565        return -1;
     1566
     1567    TRACE ("adding %d bitmaps!\n", nButtons);
     1568    }
     1569
    15691570    if (!(infoPtr->himlDef)) {
    1570         /* create new default image list */
    1571         TRACE ("creating default image list!\n");
    1572 
    1573         infoPtr->himlDef =
    1574             ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
    1575                               ILC_COLOR | ILC_MASK, nButtons, 2);
    1576         infoPtr->himlInt = infoPtr->himlDef;
     1571    /* create new default image list */
     1572    TRACE ("creating default image list!\n");
     1573
     1574    infoPtr->himlDef =
     1575        ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
     1576                  ILC_COLOR | ILC_MASK, nButtons, 2);
     1577    infoPtr->himlInt = infoPtr->himlDef;
    15771578    }
    15781579
     
    15821583    if (lpAddBmp->hInst == (HINSTANCE)0)
    15831584    {
    1584         nIndex =
    1585             ImageList_AddMasked (infoPtr->himlDef, (HBITMAP)lpAddBmp->nID,
    1586                                 CLR_DEFAULT);
     1585    nIndex =
     1586        ImageList_AddMasked (infoPtr->himlDef, (HBITMAP)lpAddBmp->nID,
     1587                CLR_DEFAULT);
    15871588    }
    15881589    else if (lpAddBmp->hInst == HINST_COMMCTRL)
    15891590    {
    1590         /* Add system bitmaps */
    1591         switch (lpAddBmp->nID)
    1592     {
    1593             case IDB_STD_SMALL_COLOR:
    1594                 hbmLoad = LoadBitmapA (COMCTL32_hModule,
    1595                                        MAKEINTRESOURCEA(IDB_STD_SMALL));
    1596                 nIndex = ImageList_AddMasked (infoPtr->himlDef,
    1597                                               hbmLoad, CLR_DEFAULT);
    1598                 DeleteObject (hbmLoad);
    1599                 break;
    1600 
    1601             case IDB_STD_LARGE_COLOR:
    1602                 hbmLoad = LoadBitmapA (COMCTL32_hModule,
    1603                                        MAKEINTRESOURCEA(IDB_STD_LARGE));
    1604                 nIndex = ImageList_AddMasked (infoPtr->himlDef,
    1605                                               hbmLoad, CLR_DEFAULT);
    1606                 DeleteObject (hbmLoad);
    1607                 break;
    1608 
    1609             case IDB_VIEW_SMALL_COLOR:
    1610                 hbmLoad = LoadBitmapA (COMCTL32_hModule,
    1611                                        MAKEINTRESOURCEA(IDB_VIEW_SMALL));
    1612                 nIndex = ImageList_AddMasked (infoPtr->himlDef,
    1613                                               hbmLoad, CLR_DEFAULT);
    1614                 DeleteObject (hbmLoad);
    1615                 break;
    1616 
    1617             case IDB_VIEW_LARGE_COLOR:
    1618                 hbmLoad = LoadBitmapA (COMCTL32_hModule,
    1619                                        MAKEINTRESOURCEA(IDB_VIEW_LARGE));
    1620                 nIndex = ImageList_AddMasked (infoPtr->himlDef,
    1621                                               hbmLoad, CLR_DEFAULT);
    1622                 DeleteObject (hbmLoad);
    1623                 break;
    1624 
    1625             case IDB_HIST_SMALL_COLOR:
    1626                 hbmLoad = LoadBitmapA (COMCTL32_hModule,
    1627                                        MAKEINTRESOURCEA(IDB_HIST_SMALL));
    1628                 nIndex = ImageList_AddMasked (infoPtr->himlDef,
    1629                                               hbmLoad, CLR_DEFAULT);
    1630                 DeleteObject (hbmLoad);
    1631                 break;
    1632 
    1633             case IDB_HIST_LARGE_COLOR:
    1634                 hbmLoad = LoadBitmapA (COMCTL32_hModule,
    1635                                        MAKEINTRESOURCEA(IDB_HIST_LARGE));
    1636                 nIndex = ImageList_AddMasked (infoPtr->himlDef,
    1637                                               hbmLoad, CLR_DEFAULT);
    1638                 DeleteObject (hbmLoad);
    1639                 break;
    1640 
    1641             default:
    1642         nIndex = ImageList_GetImageCount (infoPtr->himlDef);
    1643                 ERR ("invalid imagelist!\n");
    1644                 break;
    1645         }
     1591    /* Add system bitmaps */
     1592    switch (lpAddBmp->nID)
     1593    {
     1594        case IDB_STD_SMALL_COLOR:
     1595        hbmLoad = LoadBitmapA (COMCTL32_hModule,
     1596                       MAKEINTRESOURCEA(IDB_STD_SMALL));
     1597        nIndex = ImageList_AddMasked (infoPtr->himlDef,
     1598                          hbmLoad, CLR_DEFAULT);
     1599        DeleteObject (hbmLoad);
     1600        break;
     1601
     1602        case IDB_STD_LARGE_COLOR:
     1603        hbmLoad = LoadBitmapA (COMCTL32_hModule,
     1604                       MAKEINTRESOURCEA(IDB_STD_LARGE));
     1605        nIndex = ImageList_AddMasked (infoPtr->himlDef,
     1606                          hbmLoad, CLR_DEFAULT);
     1607        DeleteObject (hbmLoad);
     1608        break;
     1609
     1610        case IDB_VIEW_SMALL_COLOR:
     1611        hbmLoad = LoadBitmapA (COMCTL32_hModule,
     1612                       MAKEINTRESOURCEA(IDB_VIEW_SMALL));
     1613        nIndex = ImageList_AddMasked (infoPtr->himlDef,
     1614                          hbmLoad, CLR_DEFAULT);
     1615        DeleteObject (hbmLoad);
     1616        break;
     1617
     1618        case IDB_VIEW_LARGE_COLOR:
     1619        hbmLoad = LoadBitmapA (COMCTL32_hModule,
     1620                       MAKEINTRESOURCEA(IDB_VIEW_LARGE));
     1621        nIndex = ImageList_AddMasked (infoPtr->himlDef,
     1622                          hbmLoad, CLR_DEFAULT);
     1623        DeleteObject (hbmLoad);
     1624        break;
     1625
     1626        case IDB_HIST_SMALL_COLOR:
     1627        hbmLoad = LoadBitmapA (COMCTL32_hModule,
     1628                       MAKEINTRESOURCEA(IDB_HIST_SMALL));
     1629        nIndex = ImageList_AddMasked (infoPtr->himlDef,
     1630                          hbmLoad, CLR_DEFAULT);
     1631        DeleteObject (hbmLoad);
     1632        break;
     1633
     1634        case IDB_HIST_LARGE_COLOR:
     1635        hbmLoad = LoadBitmapA (COMCTL32_hModule,
     1636                       MAKEINTRESOURCEA(IDB_HIST_LARGE));
     1637        nIndex = ImageList_AddMasked (infoPtr->himlDef,
     1638                          hbmLoad, CLR_DEFAULT);
     1639        DeleteObject (hbmLoad);
     1640        break;
     1641
     1642        default:
     1643    nIndex = ImageList_GetImageCount (infoPtr->himlDef);
     1644        ERR ("invalid imagelist!\n");
     1645        break;
     1646    }
    16461647    }
    16471648    else
    16481649    {
    1649         hbmLoad = LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID);
    1650         nIndex = ImageList_AddMasked (infoPtr->himlDef, hbmLoad, CLR_DEFAULT);
    1651         DeleteObject (hbmLoad);
     1650    hbmLoad = LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID);
     1651    nIndex = ImageList_AddMasked (infoPtr->himlDef, hbmLoad, CLR_DEFAULT);
     1652    DeleteObject (hbmLoad);
    16521653    }
    16531654
     
    16591660       {
    16601661         WARN("Desired images do not match received images : Previous image number %i Previous images in list %i added %i expecting total %i, Images in list %i\n",
    1661               infoPtr->nNumBitmaps, nCount, imagecount - nCount,
    1662               infoPtr->nNumBitmaps+nButtons,imagecount);
    1663 
    1664         infoPtr->nNumBitmaps = imagecount;
     1662          infoPtr->nNumBitmaps, nCount, imagecount - nCount,
     1663          infoPtr->nNumBitmaps+nButtons,imagecount);
     1664
     1665    infoPtr->nNumBitmaps = imagecount;
    16651666       }
    16661667       else
     
    16881689
    16891690    if (infoPtr->nNumButtons == 0) {
    1690         infoPtr->buttons =
    1691             COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
     1691    infoPtr->buttons =
     1692        COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
    16921693    }
    16931694    else {
    1694         TBUTTON_INFO *oldButtons = infoPtr->buttons;
    1695         infoPtr->buttons =
    1696             COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
    1697         memcpy (&infoPtr->buttons[0], &oldButtons[0],
    1698                 nOldButtons * sizeof(TBUTTON_INFO));
     1695    TBUTTON_INFO *oldButtons = infoPtr->buttons;
     1696    infoPtr->buttons =
     1697        COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
     1698    memcpy (&infoPtr->buttons[0], &oldButtons[0],
     1699        nOldButtons * sizeof(TBUTTON_INFO));
    16991700        COMCTL32_Free (oldButtons);
    17001701    }
     
    17041705    /* insert new button data */
    17051706    for (nCount = 0; nCount < nAddButtons; nCount++) {
    1706         TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
    1707         btnPtr->iBitmap   = lpTbb[nCount].iBitmap;
    1708         btnPtr->idCommand = lpTbb[nCount].idCommand;
    1709         btnPtr->fsState   = lpTbb[nCount].fsState;
    1710         btnPtr->fsStyle   = lpTbb[nCount].fsStyle;
    1711         btnPtr->dwData    = lpTbb[nCount].dwData;
    1712         btnPtr->iString   = lpTbb[nCount].iString;
    1713         btnPtr->bHot      = FALSE;
    1714 
    1715         if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
    1716             TTTOOLINFOA ti;
    1717 
    1718             ZeroMemory (&ti, sizeof(TTTOOLINFOA));
    1719             ti.cbSize   = sizeof (TTTOOLINFOA);
    1720             ti.hwnd     = hwnd;
    1721             ti.uId      = btnPtr->idCommand;
    1722             ti.hinst    = 0;
    1723             ti.lpszText = LPSTR_TEXTCALLBACKA;
    1724 
    1725             SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
    1726                             0, (LPARAM)&ti);
    1727         }
     1707    TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
     1708    btnPtr->iBitmap   = lpTbb[nCount].iBitmap;
     1709    btnPtr->idCommand = lpTbb[nCount].idCommand;
     1710    btnPtr->fsState   = lpTbb[nCount].fsState;
     1711    btnPtr->fsStyle   = lpTbb[nCount].fsStyle;
     1712    btnPtr->dwData    = lpTbb[nCount].dwData;
     1713    btnPtr->iString   = lpTbb[nCount].iString;
     1714    btnPtr->bHot      = FALSE;
     1715
     1716    if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
     1717        TTTOOLINFOA ti;
     1718
     1719        ZeroMemory (&ti, sizeof(TTTOOLINFOA));
     1720        ti.cbSize   = sizeof (TTTOOLINFOA);
     1721        ti.hwnd     = hwnd;
     1722        ti.uId      = btnPtr->idCommand;
     1723        ti.hinst    = 0;
     1724        ti.lpszText = LPSTR_TEXTCALLBACKA;
     1725
     1726        SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
     1727                0, (LPARAM)&ti);
     1728    }
    17281729    }
    17291730
     
    17501751
    17511752    if (infoPtr->nNumButtons == 0) {
    1752         infoPtr->buttons =
    1753             COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
     1753    infoPtr->buttons =
     1754        COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
    17541755    }
    17551756    else {
    1756         TBUTTON_INFO *oldButtons = infoPtr->buttons;
    1757         infoPtr->buttons =
    1758             COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
    1759         memcpy (&infoPtr->buttons[0], &oldButtons[0],
    1760                 nOldButtons * sizeof(TBUTTON_INFO));
     1757    TBUTTON_INFO *oldButtons = infoPtr->buttons;
     1758    infoPtr->buttons =
     1759        COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
     1760    memcpy (&infoPtr->buttons[0], &oldButtons[0],
     1761        nOldButtons * sizeof(TBUTTON_INFO));
    17611762        COMCTL32_Free (oldButtons);
    17621763    }
     
    17661767    /* insert new button data */
    17671768    for (nCount = 0; nCount < nAddButtons; nCount++) {
    1768         TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
    1769         btnPtr->iBitmap   = lpTbb[nCount].iBitmap;
    1770         btnPtr->idCommand = lpTbb[nCount].idCommand;
    1771         btnPtr->fsState   = lpTbb[nCount].fsState;
    1772         btnPtr->fsStyle   = lpTbb[nCount].fsStyle;
    1773         btnPtr->dwData    = lpTbb[nCount].dwData;
    1774         btnPtr->iString   = lpTbb[nCount].iString;
    1775         btnPtr->bHot      = FALSE;
    1776 
    1777         if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
    1778             TTTOOLINFOW ti;
    1779 
    1780             ZeroMemory (&ti, sizeof(TTTOOLINFOW));
    1781             ti.cbSize   = sizeof (TTTOOLINFOW);
    1782             ti.hwnd     = hwnd;
    1783             ti.uId      = btnPtr->idCommand;
    1784             ti.hinst    = 0;
    1785             ti.lpszText = LPSTR_TEXTCALLBACKW;
    1786 
    1787             SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
    1788                             0, (LPARAM)&ti);
    1789         }
     1769    TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
     1770    btnPtr->iBitmap   = lpTbb[nCount].iBitmap;
     1771    btnPtr->idCommand = lpTbb[nCount].idCommand;
     1772    btnPtr->fsState   = lpTbb[nCount].fsState;
     1773    btnPtr->fsStyle   = lpTbb[nCount].fsStyle;
     1774    btnPtr->dwData    = lpTbb[nCount].dwData;
     1775    btnPtr->iString   = lpTbb[nCount].iString;
     1776    btnPtr->bHot      = FALSE;
     1777
     1778    if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
     1779        TTTOOLINFOW ti;
     1780
     1781        ZeroMemory (&ti, sizeof(TTTOOLINFOW));
     1782        ti.cbSize   = sizeof (TTTOOLINFOW);
     1783        ti.hwnd     = hwnd;
     1784        ti.uId      = btnPtr->idCommand;
     1785        ti.hinst    = 0;
     1786        ti.lpszText = LPSTR_TEXTCALLBACKW;
     1787
     1788        SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
     1789                0, (LPARAM)&ti);
     1790    }
    17901791    }
    17911792
     
    18051806
    18061807    if ((wParam) && (HIWORD(lParam) == 0)) {
    1807         char szString[256];
    1808         INT len, lenW;
    1809         TRACE("adding string from resource!\n");
    1810 
    1811         len = LoadStringA ((HINSTANCE)wParam, (UINT)lParam,
    1812                              szString, 256);
    1813 
    1814         TRACE("len=%d \"%s\"\n", len, szString);
    1815         nIndex = infoPtr->nNumStrings;
    1816         if (infoPtr->nNumStrings == 0) {
    1817             infoPtr->strings =
    1818                 COMCTL32_Alloc (sizeof(LPWSTR));
    1819         }
    1820         else {
    1821             LPWSTR *oldStrings = infoPtr->strings;
    1822             infoPtr->strings =
    1823                 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
    1824             memcpy (&infoPtr->strings[0], &oldStrings[0],
    1825                     sizeof(LPWSTR) * infoPtr->nNumStrings);
    1826             COMCTL32_Free (oldStrings);
    1827         }
     1808    char szString[256];
     1809    INT len, lenW;
     1810    TRACE("adding string from resource!\n");
     1811
     1812    len = LoadStringA ((HINSTANCE)wParam, (UINT)lParam,
     1813                 szString, 256);
     1814
     1815    TRACE("len=%d \"%s\"\n", len, szString);
     1816    nIndex = infoPtr->nNumStrings;
     1817    if (infoPtr->nNumStrings == 0) {
     1818        infoPtr->strings =
     1819        COMCTL32_Alloc (sizeof(LPWSTR));
     1820    }
     1821    else {
     1822        LPWSTR *oldStrings = infoPtr->strings;
     1823        infoPtr->strings =
     1824        COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
     1825        memcpy (&infoPtr->strings[0], &oldStrings[0],
     1826            sizeof(LPWSTR) * infoPtr->nNumStrings);
     1827        COMCTL32_Free (oldStrings);
     1828    }
    18281829
    18291830        lenW = MultiByteToWideChar( CP_ACP, 0, szString, -1, NULL, 0 );
     
    18311832        MultiByteToWideChar( CP_ACP, 0, szString, -1,
    18321833                             infoPtr->strings[infoPtr->nNumStrings], lenW );
    1833         infoPtr->nNumStrings++;
     1834    infoPtr->nNumStrings++;
    18341835    }
    18351836    else {
    1836         LPSTR p = (LPSTR)lParam;
    1837         INT len, lenW;
    1838 
    1839         if (p == NULL)
    1840             return -1;
    1841         TRACE("adding string(s) from array!\n");
    1842 
    1843         nIndex = infoPtr->nNumStrings;
    1844         while (*p) {
    1845             len = strlen (p);
    1846             TRACE("len=%d \"%s\"\n", len, p);
    1847 
    1848             if (infoPtr->nNumStrings == 0) {
    1849                 infoPtr->strings =
    1850                     COMCTL32_Alloc (sizeof(LPWSTR));
    1851             }
    1852             else {
    1853                 LPWSTR *oldStrings = infoPtr->strings;
    1854                 infoPtr->strings =
    1855                     COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
    1856                 memcpy (&infoPtr->strings[0], &oldStrings[0],
    1857                         sizeof(LPWSTR) * infoPtr->nNumStrings);
    1858                 COMCTL32_Free (oldStrings);
    1859             }
     1837    LPSTR p = (LPSTR)lParam;
     1838    INT len, lenW;
     1839
     1840    if (p == NULL)
     1841        return -1;
     1842    TRACE("adding string(s) from array!\n");
     1843
     1844    nIndex = infoPtr->nNumStrings;
     1845    while (*p) {
     1846        len = strlen (p);
     1847        TRACE("len=%d \"%s\"\n", len, p);
     1848
     1849        if (infoPtr->nNumStrings == 0) {
     1850        infoPtr->strings =
     1851            COMCTL32_Alloc (sizeof(LPWSTR));
     1852        }
     1853        else {
     1854        LPWSTR *oldStrings = infoPtr->strings;
     1855        infoPtr->strings =
     1856            COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
     1857        memcpy (&infoPtr->strings[0], &oldStrings[0],
     1858            sizeof(LPWSTR) * infoPtr->nNumStrings);
     1859        COMCTL32_Free (oldStrings);
     1860        }
    18601861
    18611862            lenW = MultiByteToWideChar( CP_ACP, 0, p, -1, NULL, 0 );
     
    18631864            MultiByteToWideChar( CP_ACP, 0, p, -1,
    18641865                                 infoPtr->strings[infoPtr->nNumStrings], lenW );
    1865             infoPtr->nNumStrings++;
    1866 
    1867             p += (len+1);
    1868         }
     1866        infoPtr->nNumStrings++;
     1867
     1868        p += (len+1);
     1869    }
    18691870    }
    18701871
     
    18811882
    18821883    if ((wParam) && (HIWORD(lParam) == 0)) {
    1883         WCHAR szString[MAX_RESOURCE_STRING_LENGTH];
    1884         INT len;
    1885         TRACE("adding string from resource!\n");
    1886 
    1887         len = LoadStringW ((HINSTANCE)wParam, (UINT)lParam,
    1888                              szString, MAX_RESOURCE_STRING_LENGTH);
    1889 
    1890         TRACE("len=%d %s\n", len, debugstr_w(szString));
    1891         TRACE("First char: 0x%x\n", *szString);
    1892         if (szString[0] == L'|')
    1893         {
    1894             PWSTR p = szString + 1;
    1895                
    1896             nIndex = infoPtr->nNumStrings;
    1897             while (*p != L'|') {
    1898 
    1899             if (infoPtr->nNumStrings == 0) {
    1900                 infoPtr->strings =
    1901                     COMCTL32_Alloc (sizeof(LPWSTR));
    1902             }
    1903             else {
    1904                 LPWSTR *oldStrings = infoPtr->strings;
    1905                 infoPtr->strings =
    1906                     COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
    1907                 memcpy (&infoPtr->strings[0], &oldStrings[0],
    1908                         sizeof(LPWSTR) * infoPtr->nNumStrings);
    1909                 COMCTL32_Free (oldStrings);
    1910             }
    1911 
    1912             len = COMCTL32_StrChrW (p, L'|') - p;
    1913             TRACE("len=%d %s\n", len, debugstr_w(p));
    1914             infoPtr->strings[infoPtr->nNumStrings] =
    1915                 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
    1916             lstrcpynW (infoPtr->strings[infoPtr->nNumStrings], p, len);
    1917             infoPtr->nNumStrings++;
    1918 
    1919                 p += (len+1);
    1920             }
    1921         }
    1922         else
    1923         {
     1884    WCHAR szString[MAX_RESOURCE_STRING_LENGTH];
     1885    INT len;
     1886    TRACE("adding string from resource!\n");
     1887
     1888    len = LoadStringW ((HINSTANCE)wParam, (UINT)lParam,
     1889                 szString, MAX_RESOURCE_STRING_LENGTH);
     1890
     1891    TRACE("len=%d %s\n", len, debugstr_w(szString));
     1892    TRACE("First char: 0x%x\n", *szString);
     1893    if (szString[0] == L'|')
     1894    {
     1895        PWSTR p = szString + 1;
     1896
     1897        nIndex = infoPtr->nNumStrings;
     1898        while (*p != L'|') {
     1899
     1900        if (infoPtr->nNumStrings == 0) {
     1901        infoPtr->strings =
     1902            COMCTL32_Alloc (sizeof(LPWSTR));
     1903        }
     1904        else {
     1905        LPWSTR *oldStrings = infoPtr->strings;
     1906        infoPtr->strings =
     1907            COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
     1908        memcpy (&infoPtr->strings[0], &oldStrings[0],
     1909            sizeof(LPWSTR) * infoPtr->nNumStrings);
     1910        COMCTL32_Free (oldStrings);
     1911        }
     1912
     1913        len = COMCTL32_StrChrW (p, L'|') - p;
     1914        TRACE("len=%d %s\n", len, debugstr_w(p));
     1915        infoPtr->strings[infoPtr->nNumStrings] =
     1916        COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
     1917        lstrcpynW (infoPtr->strings[infoPtr->nNumStrings], p, len);
     1918        infoPtr->nNumStrings++;
     1919
     1920        p += (len+1);
     1921        }
     1922    }
     1923    else
     1924    {
    19241925            nIndex = infoPtr->nNumStrings;
    19251926            if (infoPtr->nNumStrings == 0) {
     
    19431944    }
    19441945    else {
    1945         LPWSTR p = (LPWSTR)lParam;
    1946         INT len;
    1947 
    1948         if (p == NULL)
    1949             return -1;
    1950         TRACE("adding string(s) from array!\n");
    1951         nIndex = infoPtr->nNumStrings;
    1952         while (*p) {
    1953             len = strlenW (p);
    1954 
    1955             TRACE("len=%d %s\n", len, debugstr_w(p));
    1956             if (infoPtr->nNumStrings == 0) {
    1957                 infoPtr->strings =
    1958                     COMCTL32_Alloc (sizeof(LPWSTR));
    1959             }
    1960             else {
    1961                 LPWSTR *oldStrings = infoPtr->strings;
    1962                 infoPtr->strings =
    1963                     COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
    1964                 memcpy (&infoPtr->strings[0], &oldStrings[0],
    1965                         sizeof(LPWSTR) * infoPtr->nNumStrings);
    1966                 COMCTL32_Free (oldStrings);
    1967             }
    1968 
    1969             infoPtr->strings[infoPtr->nNumStrings] =
    1970                 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
    1971             strcpyW (infoPtr->strings[infoPtr->nNumStrings], p);
    1972             infoPtr->nNumStrings++;
    1973 
    1974             p += (len+1);
    1975         }
     1946    LPWSTR p = (LPWSTR)lParam;
     1947    INT len;
     1948
     1949    if (p == NULL)
     1950        return -1;
     1951    TRACE("adding string(s) from array!\n");
     1952    nIndex = infoPtr->nNumStrings;
     1953    while (*p) {
     1954        len = strlenW (p);
     1955
     1956        TRACE("len=%d %s\n", len, debugstr_w(p));
     1957        if (infoPtr->nNumStrings == 0) {
     1958        infoPtr->strings =
     1959            COMCTL32_Alloc (sizeof(LPWSTR));
     1960        }
     1961        else {
     1962        LPWSTR *oldStrings = infoPtr->strings;
     1963        infoPtr->strings =
     1964            COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
     1965        memcpy (&infoPtr->strings[0], &oldStrings[0],
     1966            sizeof(LPWSTR) * infoPtr->nNumStrings);
     1967        COMCTL32_Free (oldStrings);
     1968        }
     1969
     1970        infoPtr->strings[infoPtr->nNumStrings] =
     1971        COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
     1972        strcpyW (infoPtr->strings[infoPtr->nNumStrings], p);
     1973        infoPtr->nNumStrings++;
     1974
     1975        p += (len+1);
     1976    }
    19761977    }
    19771978
     
    20042005
    20052006    if (dwStyle & CCS_NORESIZE) {
    2006         uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
    2007         cx = 0;
    2008         cy = 0;
     2007    uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
     2008    cx = 0;
     2009    cy = 0;
    20092010    }
    20102011    else {
    2011         infoPtr->nWidth = parent_rect.right - parent_rect.left;
    2012         TOOLBAR_CalcToolbar (hwnd);
    2013         InvalidateRect( hwnd, NULL, TRUE );
    2014         cy = infoPtr->nHeight;
    2015         cx = infoPtr->nWidth;
    2016 
    2017         if (dwStyle & CCS_NOMOVEY) {
    2018                 GetWindowRect(hwnd, &window_rect);
    2019                 ScreenToClient(parent, (LPPOINT)&window_rect.left);
    2020                 y = window_rect.top;
    2021         }
     2012    infoPtr->nWidth = parent_rect.right - parent_rect.left;
     2013    TOOLBAR_CalcToolbar (hwnd);
     2014    InvalidateRect( hwnd, NULL, TRUE );
     2015    cy = infoPtr->nHeight;
     2016    cx = infoPtr->nWidth;
     2017
     2018    if (dwStyle & CCS_NOMOVEY) {
     2019        GetWindowRect(hwnd, &window_rect);
     2020        ScreenToClient(parent, (LPPOINT)&window_rect.left);
     2021        y = window_rect.top;
     2022    }
    20222023    }
    20232024
    20242025    if (dwStyle & CCS_NOPARENTALIGN)
    2025         uPosFlags |= SWP_NOMOVE;
     2026    uPosFlags |= SWP_NOMOVE;
    20262027
    20272028    if (!(dwStyle & CCS_NODIVIDER))
    2028         cy += GetSystemMetrics(SM_CYEDGE);
     2029    cy += GetSystemMetrics(SM_CYEDGE);
    20292030
    20302031    if (dwStyle & WS_BORDER)
     
    20612062
    20622063    if (infoPtr == NULL) {
    2063         ERR("(0x%x, 0x%x, 0x%lx)\n", hwnd, wParam, lParam);
    2064         ERR("infoPtr == NULL!\n");
    2065         return 0;
     2064    ERR("(0x%x, 0x%x, 0x%lx)\n", hwnd, wParam, lParam);
     2065    ERR("infoPtr == NULL!\n");
     2066    return 0;
    20662067    }
    20672068
     
    20812082    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    20822083    if (nIndex == -1)
    2083         return FALSE;
     2084    return FALSE;
    20842085
    20852086    btnPtr = &infoPtr->buttons[nIndex];
     
    21052106    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    21062107    if (nIndex == -1)
    2107         return FALSE;
     2108    return FALSE;
    21082109
    21092110    btnPtr = &infoPtr->buttons[nIndex];
    21102111
    21112112    if (!(btnPtr->fsStyle & TBSTYLE_CHECK))
    2112         return FALSE;
     2113    return FALSE;
    21132114
    21142115    bChecked = (btnPtr->fsState & TBSTATE_CHECKED) ? TRUE : FALSE;
    21152116
    21162117    if (LOWORD(lParam) == FALSE)
    2117         btnPtr->fsState &= ~TBSTATE_CHECKED;
     2118    btnPtr->fsState &= ~TBSTATE_CHECKED;
    21182119    else {
    2119         if (btnPtr->fsStyle & TBSTYLE_GROUP) {
    2120             nOldIndex =
    2121                 TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, nIndex);
    2122             if (nOldIndex == nIndex)
    2123                 return 0;
    2124             if (nOldIndex != -1)
    2125                 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
    2126         }
    2127         btnPtr->fsState |= TBSTATE_CHECKED;
     2120    if (btnPtr->fsStyle & TBSTYLE_GROUP) {
     2121        nOldIndex =
     2122        TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, nIndex);
     2123        if (nOldIndex == nIndex)
     2124        return 0;
     2125        if (nOldIndex != -1)
     2126        infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
     2127    }
     2128    btnPtr->fsState |= TBSTATE_CHECKED;
    21282129    }
    21292130
    21302131    if( bChecked != LOWORD(lParam) )
    21312132    {
    2132         if (nOldIndex != -1)
     2133    if (nOldIndex != -1)
    21332134        {
    21342135            InvalidateRect(hwnd, &infoPtr->buttons[nOldIndex].rect,
     
    21712172
    21722173    SendMessageA (custInfo.tbInfo->hwndNotify, WM_NOTIFY,
    2173                   (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
     2174          (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
    21742175
    21752176    if (!(hRes = FindResourceA (COMCTL32_hModule,
    21762177                                MAKEINTRESOURCEA(IDD_TBCUSTOMIZE),
    21772178                                RT_DIALOGA)))
    2178         return FALSE;
     2179    return FALSE;
    21792180
    21802181    if(!(template = (LPVOID)LoadResource (COMCTL32_hModule, hRes)))
    2181         return FALSE;
     2182    return FALSE;
    21822183
    21832184    ret = DialogBoxIndirectParamA (GetWindowLongA (hwnd, GWL_HINSTANCE),
     
    21902191    nmhdr.code = TBN_ENDADJUST;
    21912192    SendMessageA (custInfo.tbInfo->hwndNotify, WM_NOTIFY,
    2192                   (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
     2193          (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
    21932194
    21942195    return ret;
     
    22032204
    22042205    if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
    2205         return FALSE;
    2206 
    2207     if ((infoPtr->hwndToolTip) && 
    2208         !(infoPtr->buttons[nIndex].fsStyle & TBSTYLE_SEP)) {
    2209         TTTOOLINFOA ti;
    2210 
    2211         ZeroMemory (&ti, sizeof(TTTOOLINFOA));
    2212         ti.cbSize   = sizeof (TTTOOLINFOA);
    2213         ti.hwnd     = hwnd;
    2214         ti.uId      = infoPtr->buttons[nIndex].idCommand;
    2215 
    2216         SendMessageA (infoPtr->hwndToolTip, TTM_DELTOOLA, 0, (LPARAM)&ti);
     2206    return FALSE;
     2207
     2208    if ((infoPtr->hwndToolTip) &&
     2209    !(infoPtr->buttons[nIndex].fsStyle & TBSTYLE_SEP)) {
     2210    TTTOOLINFOA ti;
     2211
     2212    ZeroMemory (&ti, sizeof(TTTOOLINFOA));
     2213    ti.cbSize   = sizeof (TTTOOLINFOA);
     2214    ti.hwnd     = hwnd;
     2215    ti.uId      = infoPtr->buttons[nIndex].idCommand;
     2216
     2217    SendMessageA (infoPtr->hwndToolTip, TTM_DELTOOLA, 0, (LPARAM)&ti);
    22172218    }
    22182219
    22192220    if (infoPtr->nNumButtons == 1) {
    2220         TRACE(" simple delete!\n");
    2221         COMCTL32_Free (infoPtr->buttons);
    2222         infoPtr->buttons = NULL;
    2223         infoPtr->nNumButtons = 0;
     2221    TRACE(" simple delete!\n");
     2222    COMCTL32_Free (infoPtr->buttons);
     2223    infoPtr->buttons = NULL;
     2224    infoPtr->nNumButtons = 0;
    22242225    }
    22252226    else {
    2226         TBUTTON_INFO *oldButtons = infoPtr->buttons;
     2227    TBUTTON_INFO *oldButtons = infoPtr->buttons;
    22272228        TRACE("complex delete! [nIndex=%d]\n", nIndex);
    22282229
    2229         infoPtr->nNumButtons--;
    2230         infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
     2230    infoPtr->nNumButtons--;
     2231    infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
    22312232        if (nIndex > 0) {
    22322233            memcpy (&infoPtr->buttons[0], &oldButtons[0],
     
    22392240        }
    22402241
    2241         COMCTL32_Free (oldButtons);
     2242    COMCTL32_Free (oldButtons);
    22422243    }
    22432244
     
    22602261    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    22612262    if (nIndex == -1)
    2262         return FALSE;
     2263    return FALSE;
    22632264
    22642265    btnPtr = &infoPtr->buttons[nIndex];
     
    22682269    /* update the toolbar button state */
    22692270    if(LOWORD(lParam) == FALSE) {
    2270         btnPtr->fsState &= ~(TBSTATE_ENABLED | TBSTATE_PRESSED);
     2271    btnPtr->fsState &= ~(TBSTATE_ENABLED | TBSTATE_PRESSED);
    22712272    } else {
    2272         btnPtr->fsState |= TBSTATE_ENABLED;
     2273    btnPtr->fsState |= TBSTATE_ENABLED;
    22732274    }
    22742275
     
    23012302    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    23022303    if (nIndex == -1)
    2303         return -1;
     2304    return -1;
    23042305
    23052306    return infoPtr->buttons[nIndex].iBitmap;
     
    23232324
    23242325    if (infoPtr == NULL)
    2325         return FALSE;
     2326    return FALSE;
    23262327
    23272328    if (lpTbb == NULL)
    2328         return FALSE;
     2329    return FALSE;
    23292330
    23302331    if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
    2331         return FALSE;
     2332    return FALSE;
    23322333
    23332334    btnPtr = &infoPtr->buttons[nIndex];
     
    23522353
    23532354    if (infoPtr == NULL)
    2354         return -1;
     2355    return -1;
    23552356    if (lpTbInfo == NULL)
    2356         return -1;
     2357    return -1;
    23572358    if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOA))
    2358         return -1;
     2359    return -1;
    23592360
    23602361    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    23612362    if (nIndex == -1)
    2362         return -1;
     2363    return -1;
    23632364
    23642365    btnPtr = &infoPtr->buttons[nIndex];
    23652366
    23662367    if (lpTbInfo->dwMask & TBIF_COMMAND)
    2367         lpTbInfo->idCommand = btnPtr->idCommand;
     2368    lpTbInfo->idCommand = btnPtr->idCommand;
    23682369    if (lpTbInfo->dwMask & TBIF_IMAGE)
    2369         lpTbInfo->iImage = btnPtr->iBitmap;
     2370    lpTbInfo->iImage = btnPtr->iBitmap;
    23702371    if (lpTbInfo->dwMask & TBIF_LPARAM)
    2371         lpTbInfo->lParam = btnPtr->dwData;
     2372    lpTbInfo->lParam = btnPtr->dwData;
    23722373    if (lpTbInfo->dwMask & TBIF_SIZE)
    2373         lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
     2374    lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
    23742375    if (lpTbInfo->dwMask & TBIF_STATE)
    2375         lpTbInfo->fsState = btnPtr->fsState;
     2376    lpTbInfo->fsState = btnPtr->fsState;
    23762377    if (lpTbInfo->dwMask & TBIF_STYLE)
    2377         lpTbInfo->fsStyle = btnPtr->fsStyle;
     2378    lpTbInfo->fsStyle = btnPtr->fsStyle;
    23782379     if (lpTbInfo->dwMask & TBIF_TEXT) {
    23792380         if ((btnPtr->iString >= 0) && (btnPtr->iString < infoPtr->nNumStrings))
    2380          {     
     2381         {
    23812382             if (!WideCharToMultiByte( CP_ACP, 0, (LPWSTR)infoPtr->strings[btnPtr->iString], -1,
    23822383                                       lpTbInfo->pszText, lpTbInfo->cchText, NULL, NULL ))
     
    23982399
    23992400    if (infoPtr == NULL)
    2400         return -1;
     2401    return -1;
    24012402    if (lpTbInfo == NULL)
    2402         return -1;
     2403    return -1;
    24032404    if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOW))
    2404         return -1;
     2405    return -1;
    24052406
    24062407    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    24072408    if (nIndex == -1)
    2408         return -1;
     2409    return -1;
    24092410
    24102411    btnPtr = &infoPtr->buttons[nIndex];
    24112412
    24122413    if (lpTbInfo->dwMask & TBIF_COMMAND)
    2413         lpTbInfo->idCommand = btnPtr->idCommand;
     2414    lpTbInfo->idCommand = btnPtr->idCommand;
    24142415    if (lpTbInfo->dwMask & TBIF_IMAGE)
    2415         lpTbInfo->iImage = btnPtr->iBitmap;
     2416    lpTbInfo->iImage = btnPtr->iBitmap;
    24162417    if (lpTbInfo->dwMask & TBIF_LPARAM)
    2417         lpTbInfo->lParam = btnPtr->dwData;
     2418    lpTbInfo->lParam = btnPtr->dwData;
    24182419    if (lpTbInfo->dwMask & TBIF_SIZE)
    2419         lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
     2420    lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
    24202421    if (lpTbInfo->dwMask & TBIF_STATE)
    2421         lpTbInfo->fsState = btnPtr->fsState;
     2422    lpTbInfo->fsState = btnPtr->fsState;
    24222423    if (lpTbInfo->dwMask & TBIF_STYLE)
    2423         lpTbInfo->fsStyle = btnPtr->fsStyle;
     2424    lpTbInfo->fsStyle = btnPtr->fsStyle;
    24242425    if (lpTbInfo->dwMask & TBIF_TEXT) {
    2425         if ((btnPtr->iString >= 0) || (btnPtr->iString < infoPtr->nNumStrings))
    2426             lstrcpynW (lpTbInfo->pszText,
    2427                        (LPWSTR)infoPtr->strings[btnPtr->iString],
    2428                        lpTbInfo->cchText);
     2426    if ((btnPtr->iString >= 0) || (btnPtr->iString < infoPtr->nNumStrings))
     2427        lstrcpynW (lpTbInfo->pszText,
     2428               (LPWSTR)infoPtr->strings[btnPtr->iString],
     2429               lpTbInfo->cchText);
    24292430    }
    24302431
     
    24392440
    24402441    return MAKELONG((WORD)infoPtr->nButtonWidth,
    2441                     (WORD)infoPtr->nButtonHeight);
     2442            (WORD)infoPtr->nButtonHeight);
    24422443}
    24432444
     
    24512452    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    24522453    if (nIndex == -1)
    2453         return -1;
     2454    return -1;
    24542455
    24552456    nStringIndex = infoPtr->buttons[nIndex].iString;
     
    24582459
    24592460    if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings))
    2460         return -1;
     2461    return -1;
    24612462
    24622463    if (lParam == 0)
    2463         return -1;
     2464    return -1;
    24642465
    24652466    return WideCharToMultiByte( CP_ACP, 0, (LPWSTR)infoPtr->strings[nStringIndex], -1,
     
    24762477    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    24772478    if (nIndex == -1)
    2478         return -1;
     2479    return -1;
    24792480
    24802481    nStringIndex = infoPtr->buttons[nIndex].iString;
     
    24832484
    24842485    if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings))
    2485         return -1;
     2486    return -1;
    24862487
    24872488    if (lParam == 0)
    2488         return -1;
     2489    return -1;
    24892490
    24902491    strcpyW ((LPWSTR)lParam, (LPWSTR)infoPtr->strings[nStringIndex]);
     
    25302531
    25312532    if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))
    2532         return -1;
     2533    return -1;
    25332534
    25342535    if (infoPtr->nHotItem < 0)
    2535         return -1;
     2536    return -1;
    25362537
    25372538    return (LRESULT)infoPtr->nHotItem;
     
    25612562
    25622563    if (infoPtr == NULL)
    2563         return FALSE;
     2564    return FALSE;
    25642565    nIndex = (INT)wParam;
    25652566    btnPtr = &infoPtr->buttons[nIndex];
    25662567    if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
    2567         return FALSE;
     2568    return FALSE;
    25682569    lpRect = (LPRECT)lParam;
    25692570    if (lpRect == NULL)
    2570         return FALSE;
     2571    return FALSE;
    25712572    if (btnPtr->fsState & TBSTATE_HIDDEN)
    2572         return FALSE;
    2573    
     2573    return FALSE;
     2574
    25742575    lpRect->left   = btnPtr->rect.left;
    25752576    lpRect->right  = btnPtr->rect.right;
     
    25882589
    25892590    if (lpSize == NULL)
    2590         return FALSE;
     2591    return FALSE;
    25912592
    25922593    lpSize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left;
     
    25942595
    25952596    TRACE("maximum size %d x %d\n",
    2596            infoPtr->rcBound.right - infoPtr->rcBound.left,
    2597            infoPtr->rcBound.bottom - infoPtr->rcBound.top);
     2597       infoPtr->rcBound.right - infoPtr->rcBound.left,
     2598       infoPtr->rcBound.bottom - infoPtr->rcBound.top);
    25982599
    25992600    return TRUE;
     
    26142615
    26152616    if (infoPtr == NULL)
    2616         return FALSE;
     2617    return FALSE;
    26172618    nIndex = (INT)wParam;
    26182619    btnPtr = &infoPtr->buttons[nIndex];
    26192620    if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
    2620         return FALSE;
     2621    return FALSE;
    26212622    lpRect = (LPRECT)lParam;
    26222623    if (lpRect == NULL)
    2623         return FALSE;
    2624    
     2624    return FALSE;
     2625
    26252626    lpRect->left   = btnPtr->rect.left;
    26262627    lpRect->right  = btnPtr->rect.right;
     
    26382639
    26392640    if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_WRAPABLE)
    2640         return infoPtr->nRows;
     2641    return infoPtr->nRows;
    26412642    else
    2642         return 1;
     2643    return 1;
    26432644}
    26442645
     
    26522653    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    26532654    if (nIndex == -1)
    2654         return -1;
     2655    return -1;
    26552656
    26562657    return infoPtr->buttons[nIndex].fsState;
     
    26662667    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    26672668    if (nIndex == -1)
    2668         return -1;
     2669    return -1;
    26692670
    26702671    return infoPtr->buttons[nIndex].fsStyle;
     
    26782679
    26792680    if (infoPtr == NULL)
    2680         return 0;
     2681    return 0;
    26812682
    26822683    return infoPtr->nMaxTextRows;
     
    26902691
    26912692    if (infoPtr == NULL)
    2692         return 0;
     2693    return 0;
    26932694    return infoPtr->hwndToolTip;
    26942695}
     
    27002701    TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
    27012702
    2702     TRACE("%s hwnd=0x%x stub!\n", 
    2703            infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
     2703    TRACE("%s hwnd=0x%x stub!\n",
     2704       infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
    27042705
    27052706    return infoPtr->bUnicode;
     
    27262727    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    27272728    if (nIndex == -1)
    2728         return FALSE;
     2729    return FALSE;
    27292730
    27302731    btnPtr = &infoPtr->buttons[nIndex];
    27312732    if (LOWORD(lParam) == FALSE)
    2732         btnPtr->fsState &= ~TBSTATE_HIDDEN;
     2733    btnPtr->fsState &= ~TBSTATE_HIDDEN;
    27332734    else
    2734         btnPtr->fsState |= TBSTATE_HIDDEN;
     2735    btnPtr->fsState |= TBSTATE_HIDDEN;
    27352736
    27362737    TOOLBAR_CalcToolbar (hwnd);
     
    27582759    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    27592760    if (nIndex == -1)
    2760         return FALSE;
     2761    return FALSE;
    27612762
    27622763    btnPtr = &infoPtr->buttons[nIndex];
    27632764    if (LOWORD(lParam) == FALSE)
    2764         btnPtr->fsState &= ~TBSTATE_INDETERMINATE;
     2765    btnPtr->fsState &= ~TBSTATE_INDETERMINATE;
    27652766    else
    2766         btnPtr->fsState |= TBSTATE_INDETERMINATE;
     2767    btnPtr->fsState |= TBSTATE_INDETERMINATE;
    27672768
    27682769    InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, btnPtr));
     
    27812782
    27822783    if (lpTbb == NULL)
    2783         return FALSE;
     2784    return FALSE;
    27842785
    27852786    if (nIndex == -1) {
    27862787       /* EPP: this seems to be an undocumented call (from my IE4)
    2787         * I assume in that case that:
    2788         * - lpTbb->iString is a string pointer (not a string index in strings[] table
    2789         * - index of insertion is at the end of existing buttons
    2790         * I only see this happen with nIndex == -1, but it could have a special
    2791         * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
    2792         */
    2793        int      len;
    2794        LPSTR    ptr;
     2788    * I assume in that case that:
     2789    * - lpTbb->iString is a string pointer (not a string index in strings[] table
     2790    * - index of insertion is at the end of existing buttons
     2791    * I only see this happen with nIndex == -1, but it could have a special
     2792    * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
     2793    */
     2794       int  len;
     2795       LPSTR    ptr;
    27952796
    27962797       /* FIXME: iString == -1 is undocumented */
     
    28142815    TRACE("inserting button index=%d\n", nIndex);
    28152816    if (nIndex > infoPtr->nNumButtons) {
    2816         nIndex = infoPtr->nNumButtons;
    2817         TRACE("adjust index=%d\n", nIndex);
     2817    nIndex = infoPtr->nNumButtons;
     2818    TRACE("adjust index=%d\n", nIndex);
    28182819    }
    28192820
     
    28232824    /* pre insert copy */
    28242825    if (nIndex > 0) {
    2825         memcpy (&infoPtr->buttons[0], &oldButtons[0],
    2826                 nIndex * sizeof(TBUTTON_INFO));
     2826    memcpy (&infoPtr->buttons[0], &oldButtons[0],
     2827        nIndex * sizeof(TBUTTON_INFO));
    28272828    }
    28282829
     
    28362837
    28372838    if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
    2838         TTTOOLINFOA ti;
    2839 
    2840         ZeroMemory (&ti, sizeof(TTTOOLINFOA));
    2841         ti.cbSize   = sizeof (TTTOOLINFOA);
    2842         ti.hwnd     = hwnd;
    2843         ti.uId      = lpTbb->idCommand;
    2844         ti.hinst    = 0;
    2845         ti.lpszText = LPSTR_TEXTCALLBACKA;
    2846 
    2847         SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
    2848                         0, (LPARAM)&ti);
     2839    TTTOOLINFOA ti;
     2840
     2841    ZeroMemory (&ti, sizeof(TTTOOLINFOA));
     2842    ti.cbSize   = sizeof (TTTOOLINFOA);
     2843    ti.hwnd     = hwnd;
     2844    ti.uId      = lpTbb->idCommand;
     2845    ti.hinst    = 0;
     2846    ti.lpszText = LPSTR_TEXTCALLBACKA;
     2847
     2848    SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
     2849            0, (LPARAM)&ti);
    28492850    }
    28502851
    28512852    /* post insert copy */
    28522853    if (nIndex < infoPtr->nNumButtons - 1) {
    2853         memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
    2854                 (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
     2854    memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
     2855        (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
    28552856    }
    28562857
     
    28742875
    28752876    if (lpTbb == NULL)
    2876         return FALSE;
     2877    return FALSE;
    28772878    if (nIndex < 0)
    2878         return FALSE;
     2879    return FALSE;
    28792880
    28802881    TRACE("inserting button index=%d\n", nIndex);
    28812882    if (nIndex > infoPtr->nNumButtons) {
    2882         nIndex = infoPtr->nNumButtons;
    2883         TRACE("adjust index=%d\n", nIndex);
     2883    nIndex = infoPtr->nNumButtons;
     2884    TRACE("adjust index=%d\n", nIndex);
    28842885    }
    28852886
     
    28892890    /* pre insert copy */
    28902891    if (nIndex > 0) {
    2891         memcpy (&infoPtr->buttons[0], &oldButtons[0],
    2892                 nIndex * sizeof(TBUTTON_INFO));
     2892    memcpy (&infoPtr->buttons[0], &oldButtons[0],
     2893        nIndex * sizeof(TBUTTON_INFO));
    28932894    }
    28942895
     
    29022903
    29032904    if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
    2904         TTTOOLINFOW ti;
    2905 
    2906         ZeroMemory (&ti, sizeof(TTTOOLINFOW));
    2907         ti.cbSize   = sizeof (TTTOOLINFOW);
    2908         ti.hwnd     = hwnd;
    2909         ti.uId      = lpTbb->idCommand;
    2910         ti.hinst    = 0;
    2911         ti.lpszText = LPSTR_TEXTCALLBACKW;
    2912 
    2913         SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
    2914                         0, (LPARAM)&ti);
     2905    TTTOOLINFOW ti;
     2906
     2907    ZeroMemory (&ti, sizeof(TTTOOLINFOW));
     2908    ti.cbSize   = sizeof (TTTOOLINFOW);
     2909    ti.hwnd     = hwnd;
     2910    ti.uId      = lpTbb->idCommand;
     2911    ti.hinst    = 0;
     2912    ti.lpszText = LPSTR_TEXTCALLBACKW;
     2913
     2914    SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
     2915            0, (LPARAM)&ti);
    29152916    }
    29162917
    29172918    /* post insert copy */
    29182919    if (nIndex < infoPtr->nNumButtons - 1) {
    2919         memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
    2920                 (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
     2920    memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
     2921        (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
    29212922    }
    29222923
     
    29402941    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    29412942    if (nIndex == -1)
    2942         return FALSE;
     2943    return FALSE;
    29432944
    29442945    return (infoPtr->buttons[nIndex].fsState & TBSTATE_CHECKED);
     
    29542955    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    29552956    if (nIndex == -1)
    2956         return FALSE;
     2957    return FALSE;
    29572958
    29582959    return (infoPtr->buttons[nIndex].fsState & TBSTATE_ENABLED);
     
    29682969    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    29692970    if (nIndex == -1)
    2970         return TRUE;
     2971    return TRUE;
    29712972
    29722973    return (infoPtr->buttons[nIndex].fsState & TBSTATE_HIDDEN);
     
    29822983    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    29832984    if (nIndex == -1)
    2984         return FALSE;
     2985    return FALSE;
    29852986
    29862987    return (infoPtr->buttons[nIndex].fsState & TBSTATE_MARKED);
     
    29962997    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    29972998    if (nIndex == -1)
    2998         return FALSE;
     2999    return FALSE;
    29993000
    30003001    return (infoPtr->buttons[nIndex].fsState & TBSTATE_INDETERMINATE);
     
    30103011    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    30113012    if (nIndex == -1)
    3012         return FALSE;
     3013    return FALSE;
    30133014
    30143015    return (infoPtr->buttons[nIndex].fsState & TBSTATE_PRESSED);
     
    30313032    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    30323033    if (nIndex == -1)
    3033         return FALSE;
     3034    return FALSE;
    30343035
    30353036    btnPtr = &infoPtr->buttons[nIndex];
    30363037    if (LOWORD(lParam) == FALSE)
    3037         btnPtr->fsState &= ~TBSTATE_PRESSED;
     3038    btnPtr->fsState &= ~TBSTATE_PRESSED;
    30383039    else
    3039         btnPtr->fsState |= TBSTATE_PRESSED;
     3040    btnPtr->fsState |= TBSTATE_PRESSED;
    30403041
    30413042    InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, btnPtr));
     
    30583059
    30593060    if ((BOOL)wParam) {
    3060         /* save toolbar information */
    3061         FIXME("save to \"%s\" \"%s\"\n",
    3062                lpSave->pszSubKey, lpSave->pszValueName);
     3061    /* save toolbar information */
     3062    FIXME("save to \"%s\" \"%s\"\n",
     3063           lpSave->pszSubKey, lpSave->pszValueName);
    30633064
    30643065
    30653066    }
    30663067    else {
    3067         /* restore toolbar information */
    3068 
    3069         FIXME("restore from \"%s\" \"%s\"\n",
    3070                lpSave->pszSubKey, lpSave->pszValueName);
     3068    /* restore toolbar information */
     3069
     3070    FIXME("restore from \"%s\" \"%s\"\n",
     3071           lpSave->pszSubKey, lpSave->pszValueName);
    30713072
    30723073
     
    30863087
    30873088    if (lpSave == NULL)
    3088         return 0;
     3089    return 0;
    30893090
    30903091    if ((BOOL)wParam) {
    3091         /* save toolbar information */
    3092         FIXME("save to \"%s\" \"%s\"\n",
    3093                lpSave->pszSubKey, lpSave->pszValueName);
     3092    /* save toolbar information */
     3093    FIXME("save to \"%s\" \"%s\"\n",
     3094           lpSave->pszSubKey, lpSave->pszValueName);
    30943095
    30953096
    30963097    }
    30973098    else {
    3098         /* restore toolbar information */
    3099 
    3100         FIXME("restore from \"%s\" \"%s\"\n",
    3101                lpSave->pszSubKey, lpSave->pszValueName);
     3099    /* restore toolbar information */
     3100
     3101    FIXME("restore from \"%s\" \"%s\"\n",
     3102           lpSave->pszSubKey, lpSave->pszValueName);
    31023103
    31033104
     
    31273128
    31283129    if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
    3129         return FALSE;
     3130    return FALSE;
    31303131
    31313132    if (infoPtr->nNumButtons > 0)
     
    31573158
    31583159    if (lptbbi == NULL)
    3159         return FALSE;
     3160    return FALSE;
    31603161    if (lptbbi->cbSize < sizeof(TBBUTTONINFOA))
    3161         return FALSE;
    3162    
     3162    return FALSE;
     3163
    31633164    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    31643165    if (nIndex == -1)
    3165         return FALSE;
     3166    return FALSE;
    31663167
    31673168    btnPtr = &infoPtr->buttons[nIndex];
    31683169    if (lptbbi->dwMask & TBIF_COMMAND)
    3169         btnPtr->idCommand = lptbbi->idCommand;
     3170    btnPtr->idCommand = lptbbi->idCommand;
    31703171    if (lptbbi->dwMask & TBIF_IMAGE)
    3171         btnPtr->iBitmap = lptbbi->iImage;
     3172    btnPtr->iBitmap = lptbbi->iImage;
    31723173    if (lptbbi->dwMask & TBIF_LPARAM)
    3173         btnPtr->dwData = lptbbi->lParam;
     3174    btnPtr->dwData = lptbbi->lParam;
    31743175/*    if (lptbbi->dwMask & TBIF_SIZE) */
    3175 /*      btnPtr->cx = lptbbi->cx; */
     3176/*  btnPtr->cx = lptbbi->cx; */
    31763177    if (lptbbi->dwMask & TBIF_STATE)
    3177         btnPtr->fsState = lptbbi->fsState;
     3178    btnPtr->fsState = lptbbi->fsState;
    31783179    if (lptbbi->dwMask & TBIF_STYLE)
    3179         btnPtr->fsStyle = lptbbi->fsStyle;
     3180    btnPtr->fsStyle = lptbbi->fsStyle;
    31803181
    31813182    if (lptbbi->dwMask & TBIF_TEXT) {
    3182         if ((btnPtr->iString >= 0) ||
    3183             (btnPtr->iString < infoPtr->nNumStrings)) {
    3184            TRACE("Ooooooch\n");
     3183    if ((btnPtr->iString >= 0) ||
     3184        (btnPtr->iString < infoPtr->nNumStrings)) {
     3185       TRACE("Ooooooch\n");
    31853186#if 0
    3186             WCHAR **lpString = &infoPtr->strings[btnPtr->iString];
    3187             INT len = lstrlenA (lptbbi->pszText);
    3188             *lpString = COMCTL32_ReAlloc (lpString, sizeof(WCHAR)*(len+1));
     3187        WCHAR **lpString = &infoPtr->strings[btnPtr->iString];
     3188        INT len = lstrlenA (lptbbi->pszText);
     3189        *lpString = COMCTL32_ReAlloc (lpString, sizeof(WCHAR)*(len+1));
    31893190#endif
    31903191
    3191             /* this is the ultimate sollution */
    3192 /*          Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */
    3193         }
     3192        /* this is the ultimate sollution */
     3193/*      Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */
     3194    }
    31943195    }
    31953196
     
    32073208
    32083209    if (lptbbi == NULL)
    3209         return FALSE;
     3210    return FALSE;
    32103211    if (lptbbi->cbSize < sizeof(TBBUTTONINFOW))
    3211         return FALSE;
     3212    return FALSE;
    32123213
    32133214    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    32143215    if (nIndex == -1)
    3215         return FALSE;
     3216    return FALSE;
    32163217
    32173218    btnPtr = &infoPtr->buttons[nIndex];
    32183219    if (lptbbi->dwMask & TBIF_COMMAND)
    3219         btnPtr->idCommand = lptbbi->idCommand;
     3220    btnPtr->idCommand = lptbbi->idCommand;
    32203221    if (lptbbi->dwMask & TBIF_IMAGE)
    3221         btnPtr->iBitmap = lptbbi->iImage;
     3222    btnPtr->iBitmap = lptbbi->iImage;
    32223223    if (lptbbi->dwMask & TBIF_LPARAM)
    3223         btnPtr->dwData = lptbbi->lParam;
     3224    btnPtr->dwData = lptbbi->lParam;
    32243225/*    if (lptbbi->dwMask & TBIF_SIZE) */
    3225 /*      btnPtr->cx = lptbbi->cx; */
     3226/*  btnPtr->cx = lptbbi->cx; */
    32263227    if (lptbbi->dwMask & TBIF_STATE)
    3227         btnPtr->fsState = lptbbi->fsState;
     3228    btnPtr->fsState = lptbbi->fsState;
    32283229    if (lptbbi->dwMask & TBIF_STYLE)
    3229         btnPtr->fsStyle = lptbbi->fsStyle;
     3230    btnPtr->fsStyle = lptbbi->fsStyle;
    32303231
    32313232    if (lptbbi->dwMask & TBIF_TEXT) {
    3232         if ((btnPtr->iString >= 0) ||
    3233             (btnPtr->iString < infoPtr->nNumStrings)) {
     3233    if ((btnPtr->iString >= 0) ||
     3234        (btnPtr->iString < infoPtr->nNumStrings)) {
    32343235#if 0
    3235             WCHAR **lpString = &infoPtr->strings[btnPtr->iString];
    3236             INT len = lstrlenW (lptbbi->pszText);
    3237             *lpString = COMCTL32_ReAlloc (lpString, sizeof(WCHAR)*(len+1));
     3236        WCHAR **lpString = &infoPtr->strings[btnPtr->iString];
     3237        INT len = lstrlenW (lptbbi->pszText);
     3238        *lpString = COMCTL32_ReAlloc (lpString, sizeof(WCHAR)*(len+1));
    32383239#endif
    32393240
    3240             /* this is the ultimate solution */
    3241 /*          Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */
    3242         }
     3241        /* this is the ultimate solution */
     3242/*      Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */
     3243    }
    32433244    }
    32443245
     
    32553256    {
    32563257        ERR("invalid parameter\n");
    3257         return FALSE;
     3258    return FALSE;
    32583259    }
    32593260
    32603261    /* The documentation claims you can only change the button size before
    3261      * any button has been added. But this is wrong. 
    3262      * WINZIP32.EXE (ver 8) calls this on one of its buttons after adding 
     3262     * any button has been added. But this is wrong.
     3263     * WINZIP32.EXE (ver 8) calls this on one of its buttons after adding
    32633264     * it to the toolbar, and it checks that the return value is nonzero - mjm
    32643265     * Further testing shows that we must actually perform the change too.
     
    32763277
    32773278    if (infoPtr == NULL) {
    3278         TRACE("Toolbar not initialized yet?????\n");
    3279         return FALSE;
     3279    TRACE("Toolbar not initialized yet?????\n");
     3280    return FALSE;
    32803281    }
    32813282
    32823283    /* if setting to current values, ignore */
    32833284    if ((infoPtr->cxMin == (INT)LOWORD(lParam)) &&
    3284         (infoPtr->cxMax == (INT)HIWORD(lParam))) {
    3285         TRACE("matches current width, min=%d, max=%d, no recalc\n",
    3286               infoPtr->cxMin, infoPtr->cxMax);
    3287         return TRUE;
     3285    (infoPtr->cxMax == (INT)HIWORD(lParam))) {
     3286    TRACE("matches current width, min=%d, max=%d, no recalc\n",
     3287          infoPtr->cxMin, infoPtr->cxMax);
     3288    return TRUE;
    32883289    }
    32893290
     
    32943295    /* if both values are 0 then we are done */
    32953296    if (lParam == 0) {
    3296         TRACE("setting both min and max to 0, norecalc\n");
    3297         return TRUE;
     3297    TRACE("setting both min and max to 0, norecalc\n");
     3298    return TRUE;
    32983299    }
    32993300
     
    33013302       recalc the bounding rectangle (does DrawText w/ DT_CALCRECT
    33023303       which doesn't actually draw - GA). */
    3303     TRACE("number of buttons %d, cx=%d, cy=%d, recalcing\n", 
    3304         infoPtr->nNumButtons, infoPtr->cxMin, infoPtr->cxMax);
     3304    TRACE("number of buttons %d, cx=%d, cy=%d, recalcing\n",
     3305    infoPtr->nNumButtons, infoPtr->cxMin, infoPtr->cxMax);
    33053306
    33063307    TOOLBAR_CalcToolbar (hwnd);
     
    33193320
    33203321    if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
    3321         return FALSE;
     3322    return FALSE;
    33223323
    33233324    infoPtr->buttons[nIndex].idCommand = (INT)lParam;
     
    33253326    if (infoPtr->hwndToolTip) {
    33263327
    3327         FIXME("change tool tip!\n");
     3328    FIXME("change tool tip!\n");
    33283329
    33293330    }
     
    33483349    /* FIXME: redraw ? */
    33493350
    3350     return (LRESULT)himlTemp; 
     3351    return (LRESULT)himlTemp;
    33513352}
    33523353
     
    33603361    dwTemp = infoPtr->dwDTFlags;
    33613362    infoPtr->dwDTFlags =
    3362         (infoPtr->dwDTFlags & (DWORD)wParam) | (DWORD)lParam;
     3363    (infoPtr->dwDTFlags & (DWORD)wParam) | (DWORD)lParam;
    33633364
    33643365    return (LRESULT)dwTemp;
     
    33753376    infoPtr->dwExStyle = (DWORD)lParam;
    33763377
    3377     return (LRESULT)dwTemp; 
     3378    return (LRESULT)dwTemp;
    33783379}
    33793380
     
    33903391    /* FIXME: redraw ? */
    33913392
    3392     return (LRESULT)himlTemp; 
     3393    return (LRESULT)himlTemp;
    33933394}
    33943395
     
    34073408    {
    34083409
    3409         infoPtr->nHotItem = (INT)wParam;
     3410        infoPtr->nHotItem = (INT)wParam;
    34103411        if ((INT)wParam >=0)
    34113412        {
    34123413            btnPtr = &infoPtr->buttons[(INT)wParam];
    34133414            btnPtr->bHot = TRUE;
    3414                 InvalidateRect (hwnd, &btnPtr->rect,
     3415            InvalidateRect (hwnd, &btnPtr->rect,
    34153416                    TOOLBAR_HasText(infoPtr, btnPtr));
    34163417        }
     
    34193420            btnPtr = &infoPtr->buttons[nOldHotItem];
    34203421            btnPtr->bHot = FALSE;
    3421                 InvalidateRect (hwnd, &btnPtr->rect,
     3422            InvalidateRect (hwnd, &btnPtr->rect,
    34223423                    TOOLBAR_HasText(infoPtr, btnPtr));
    34233424        }
     
    34253426
    34263427    if (nOldHotItem < 0)
    3427         return -1;
     3428    return -1;
    34283429
    34293430    return (LRESULT)nOldHotItem;
     
    34433444    /* FIXME: redraw ? */
    34443445
    3445     return (LRESULT)himlTemp; 
     3446    return (LRESULT)himlTemp;
    34463447}
    34473448
     
    34903491
    34913492    if (infoPtr == NULL)
    3492         return FALSE;
     3493    return FALSE;
    34933494
    34943495    infoPtr->nMaxTextRows = (INT)wParam;
     
    35103511
    35113512    if (infoPtr == NULL)
    3512         return 0;
     3513    return 0;
    35133514    hwndOldNotify = infoPtr->hwndNotify;
    35143515    infoPtr->hwndNotify = (HWND)wParam;
     
    35273528
    35283529    if (LOWORD(wParam) > 1) {
    3529         FIXME("multiple rows not supported!\n");
     3530    FIXME("multiple rows not supported!\n");
    35303531    }
    35313532
     
    35433544    /* return bounding rectangle */
    35443545    if (lprc) {
    3545         lprc->left   = infoPtr->rcBound.left;
    3546         lprc->right  = infoPtr->rcBound.right;
    3547         lprc->top    = infoPtr->rcBound.top;
    3548         lprc->bottom = infoPtr->rcBound.bottom;
     3546    lprc->left   = infoPtr->rcBound.left;
     3547    lprc->right  = infoPtr->rcBound.right;
     3548    lprc->top    = infoPtr->rcBound.top;
     3549    lprc->bottom = infoPtr->rcBound.bottom;
    35493550    }
    35503551
     
    35623563    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    35633564    if (nIndex == -1)
    3564         return FALSE;
     3565    return FALSE;
    35653566
    35663567    btnPtr = &infoPtr->buttons[nIndex];
     
    35873588    nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
    35883589    if (nIndex == -1)
    3589         return FALSE;
     3590    return FALSE;
    35903591
    35913592    btnPtr = &infoPtr->buttons[nIndex];
     
    35993600
    36003601        if (infoPtr->hwndToolTip) {
    3601             FIXME("change tool tip!\n");
     3602        FIXME("change tool tip!\n");
    36023603        }
    36033604    }
     
    36133614
    36143615    if (infoPtr == NULL)
    3615         return 0;
     3616    return 0;
    36163617    infoPtr->hwndToolTip = (HWND)wParam;
    36173618    return 0;
     
    36253626    BOOL bTemp;
    36263627
    3627     TRACE("%s hwnd=0x%04x stub!\n", 
    3628            ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd);
     3628    TRACE("%s hwnd=0x%04x stub!\n",
     3629       ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd);
    36293630
    36303631    bTemp = infoPtr->bUnicode;
     
    36833684
    36843685    if (dwStyle & TBSTYLE_TOOLTIPS) {
    3685         /* Create tooltip control */
    3686         infoPtr->hwndToolTip =
    3687             CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
    3688                                CW_USEDEFAULT, CW_USEDEFAULT,
    3689                                CW_USEDEFAULT, CW_USEDEFAULT,
    3690                                hwnd, 0, 0, 0);
    3691 
    3692         /* Send NM_TOOLTIPSCREATED notification */
    3693         if (infoPtr->hwndToolTip) {
    3694             NMTOOLTIPSCREATED nmttc;
    3695 
    3696             nmttc.hdr.hwndFrom = hwnd;
    3697             nmttc.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
    3698             nmttc.hdr.code = NM_TOOLTIPSCREATED;
    3699             nmttc.hwndToolTips = infoPtr->hwndToolTip;
    3700 
    3701             SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
    3702                           (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc);
    3703         }
     3686    /* Create tooltip control */
     3687    infoPtr->hwndToolTip =
     3688        CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
     3689                   CW_USEDEFAULT, CW_USEDEFAULT,
     3690                   CW_USEDEFAULT, CW_USEDEFAULT,
     3691                   hwnd, 0, 0, 0);
     3692
     3693    /* Send NM_TOOLTIPSCREATED notification */
     3694    if (infoPtr->hwndToolTip) {
     3695        NMTOOLTIPSCREATED nmttc;
     3696
     3697        nmttc.hdr.hwndFrom = hwnd;
     3698        nmttc.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
     3699        nmttc.hdr.code = NM_TOOLTIPSCREATED;
     3700        nmttc.hwndToolTips = infoPtr->hwndToolTip;
     3701
     3702        SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
     3703              (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc);
     3704    }
    37043705    }
    37053706
     
    37173718    /* delete tooltip control */
    37183719    if (infoPtr->hwndToolTip)
    3719         DestroyWindow (infoPtr->hwndToolTip);
     3720    DestroyWindow (infoPtr->hwndToolTip);
    37203721
    37213722    /* delete button data */
    37223723    if (infoPtr->buttons)
    3723         COMCTL32_Free (infoPtr->buttons);
     3724    COMCTL32_Free (infoPtr->buttons);
    37243725
    37253726    /* delete strings */
    37263727    if (infoPtr->strings) {
    3727         INT i;
    3728         for (i = 0; i < infoPtr->nNumStrings; i++)
    3729             if (infoPtr->strings[i])
    3730                 COMCTL32_Free (infoPtr->strings[i]);
    3731 
    3732         COMCTL32_Free (infoPtr->strings);
     3728    INT i;
     3729    for (i = 0; i < infoPtr->nNumStrings; i++)
     3730        if (infoPtr->strings[i])
     3731        COMCTL32_Free (infoPtr->strings[i]);
     3732
     3733    COMCTL32_Free (infoPtr->strings);
    37333734    }
    37343735
    37353736    /* destroy internal image list */
    37363737    if (infoPtr->himlInt)
    3737         ImageList_Destroy (infoPtr->himlInt);
     3738    ImageList_Destroy (infoPtr->himlInt);
    37383739
    37393740    /* delete default font */
    37403741    if (infoPtr->hFont)
    3741         DeleteObject (infoPtr->hFont);
     3742    DeleteObject (infoPtr->hFont);
    37423743
    37433744    /* free toolbar info data */
     
    37553756
    37563757    if (infoPtr->bTransparent)
    3757         return SendMessageA (GetParent (hwnd), WM_ERASEBKGND, wParam, lParam);
     3758    return SendMessageA (GetParent (hwnd), WM_ERASEBKGND, wParam, lParam);
    37583759
    37593760    return DefWindowProcA (hwnd, WM_ERASEBKGND, wParam, lParam);
     
    37833784
    37843785    if (nHit >= 0) {
    3785         btnPtr = &infoPtr->buttons[nHit];
    3786         if (!(btnPtr->fsState & TBSTATE_ENABLED))
    3787             return 0;
    3788         SetCapture (hwnd);
    3789         infoPtr->bCaptured = TRUE;
    3790         infoPtr->nButtonDown = nHit;
    3791 
    3792         btnPtr->fsState |= TBSTATE_PRESSED;
     3786    btnPtr = &infoPtr->buttons[nHit];
     3787    if (!(btnPtr->fsState & TBSTATE_ENABLED))
     3788        return 0;
     3789    SetCapture (hwnd);
     3790    infoPtr->bCaptured = TRUE;
     3791    infoPtr->nButtonDown = nHit;
     3792
     3793    btnPtr->fsState |= TBSTATE_PRESSED;
    37933794
    37943795        InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
     
    37963797    }
    37973798    else if (GetWindowLongA (hwnd, GWL_STYLE) & CCS_ADJUSTABLE)
    3798         TOOLBAR_Customize (hwnd);
     3799    TOOLBAR_Customize (hwnd);
    37993800
    38003801    return 0;
     
    38113812
    38123813    if (infoPtr->hwndToolTip)
    3813         TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
    3814                             WM_LBUTTONDOWN, wParam, lParam);
     3814    TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
     3815                WM_LBUTTONDOWN, wParam, lParam);
    38153816
    38163817    pt.x = (INT)LOWORD(lParam);
     
    38193820
    38203821    if (nHit >= 0) {
    3821         RECT arrowRect;
    3822         btnPtr = &infoPtr->buttons[nHit];
    3823         if (!(btnPtr->fsState & TBSTATE_ENABLED))
    3824             return 0;
    3825 
    3826         infoPtr->nOldHit = nHit;
    3827 
    3828         CopyRect(&arrowRect, &btnPtr->rect);
    3829         arrowRect.left = max(btnPtr->rect.left, btnPtr->rect.right - DDARROW_WIDTH);
    3830 
    3831         /* for EX_DRAWDDARROWS style,  click must be in the drop-down arrow rect */
    3832         if ((btnPtr->fsStyle & TBSTYLE_DROPDOWN) &&
    3833              ((TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) && PtInRect(&arrowRect, pt)) ||
    3834               (!TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle))))
    3835         {
    3836             NMTOOLBARA nmtb;
    3837             /*
    3838              * this time we must force a Redraw, so the btn is
    3839              * painted down before CaptureChanged repaints it up
    3840              */
    3841             RedrawWindow(hwnd,&btnPtr->rect,0,
    3842                         RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW);
    3843 
    3844             nmtb.hdr.hwndFrom = hwnd;
    3845             nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
    3846             nmtb.hdr.code = TBN_DROPDOWN;
    3847             nmtb.iItem = btnPtr->idCommand;
    3848 
    3849             SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
    3850                           (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb);
    3851         }
    3852         else
    3853         {
    3854             SetCapture (hwnd);
    3855             infoPtr->bCaptured = TRUE;
    3856             infoPtr->nButtonDown = nHit;
    3857 
    3858             btnPtr->fsState |= TBSTATE_PRESSED;
    3859             btnPtr->bHot = FALSE;
    3860 
    3861             InvalidateRect(hwnd, &btnPtr->rect,
    3862                            TOOLBAR_HasText(infoPtr, btnPtr));
    3863         }
     3822    RECT arrowRect;
     3823    btnPtr = &infoPtr->buttons[nHit];
     3824    if (!(btnPtr->fsState & TBSTATE_ENABLED))
     3825        return 0;
     3826
     3827    infoPtr->nOldHit = nHit;
     3828
     3829    CopyRect(&arrowRect, &btnPtr->rect);
     3830    arrowRect.left = max(btnPtr->rect.left, btnPtr->rect.right - DDARROW_WIDTH);
     3831
     3832    /* for EX_DRAWDDARROWS style,  click must be in the drop-down arrow rect */
     3833    if ((btnPtr->fsStyle & TBSTYLE_DROPDOWN) &&
     3834         ((TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) && PtInRect(&arrowRect, pt)) ||
     3835          (!TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle))))
     3836    {
     3837        NMTOOLBARA nmtb;
     3838        /*
     3839         * this time we must force a Redraw, so the btn is
     3840         * painted down before CaptureChanged repaints it up
     3841         */
     3842        RedrawWindow(hwnd,&btnPtr->rect,0,
     3843            RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW);
     3844
     3845        nmtb.hdr.hwndFrom = hwnd;
     3846        nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
     3847        nmtb.hdr.code = TBN_DROPDOWN;
     3848        nmtb.iItem = btnPtr->idCommand;
     3849
     3850        SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
     3851              (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb);
     3852    }
     3853    else
     3854    {
     3855        SetCapture (hwnd);
     3856        infoPtr->bCaptured = TRUE;
     3857        infoPtr->nButtonDown = nHit;
     3858
     3859        btnPtr->fsState |= TBSTATE_PRESSED;
     3860        btnPtr->bHot = FALSE;
     3861
     3862        InvalidateRect(hwnd, &btnPtr->rect,
     3863               TOOLBAR_HasText(infoPtr, btnPtr));
     3864    }
    38643865    }
    38653866
     
    38783879
    38793880    if (infoPtr->hwndToolTip)
    3880         TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
    3881                             WM_LBUTTONUP, wParam, lParam);
     3881    TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
     3882                WM_LBUTTONUP, wParam, lParam);
    38823883
    38833884    pt.x = (INT)LOWORD(lParam);
     
    38913892
    38923893    if ((infoPtr->bCaptured) && (infoPtr->nButtonDown >= 0)) {
    3893         btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
    3894         btnPtr->fsState &= ~TBSTATE_PRESSED;
    3895 
    3896         if (nHit == infoPtr->nButtonDown) {
    3897             if (btnPtr->fsStyle & TBSTYLE_CHECK) {
    3898                 if (btnPtr->fsStyle & TBSTYLE_GROUP) {
    3899                     nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr,
    3900                         infoPtr->nButtonDown);
    3901                     if (nOldIndex == infoPtr->nButtonDown)
    3902                         bSendMessage = FALSE;
    3903                     if ((nOldIndex != infoPtr->nButtonDown) &&
    3904                         (nOldIndex != -1))
    3905                         infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
    3906                     btnPtr->fsState |= TBSTATE_CHECKED;
    3907                 }
    3908                 else {
    3909                     if (btnPtr->fsState & TBSTATE_CHECKED)
    3910                         btnPtr->fsState &= ~TBSTATE_CHECKED;
    3911                     else
    3912                         btnPtr->fsState |= TBSTATE_CHECKED;
    3913                 }
    3914             }
    3915         }
    3916         else
    3917             bSendMessage = FALSE;
    3918 
    3919         if (nOldIndex != -1)
     3894    btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
     3895    btnPtr->fsState &= ~TBSTATE_PRESSED;
     3896
     3897    if (nHit == infoPtr->nButtonDown) {
     3898        if (btnPtr->fsStyle & TBSTYLE_CHECK) {
     3899        if (btnPtr->fsStyle & TBSTYLE_GROUP) {
     3900            nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr,
     3901            infoPtr->nButtonDown);
     3902            if (nOldIndex == infoPtr->nButtonDown)
     3903            bSendMessage = FALSE;
     3904            if ((nOldIndex != infoPtr->nButtonDown) &&
     3905            (nOldIndex != -1))
     3906            infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
     3907            btnPtr->fsState |= TBSTATE_CHECKED;
     3908        }
     3909        else {
     3910            if (btnPtr->fsState & TBSTATE_CHECKED)
     3911            btnPtr->fsState &= ~TBSTATE_CHECKED;
     3912            else
     3913            btnPtr->fsState |= TBSTATE_CHECKED;
     3914        }
     3915        }
     3916    }
     3917    else
     3918        bSendMessage = FALSE;
     3919
     3920    if (nOldIndex != -1)
    39203921        {
    39213922            InvalidateRect(hwnd, &infoPtr->buttons[nOldIndex].rect,
     
    39233924        }
    39243925
    3925         /*
    3926         * now we can ReleaseCapture, which triggers CAPTURECHANGED msg,
    3927         * that resets bCaptured and btn TBSTATE_PRESSED flags,
    3928          * and obliterates nButtonDown and nOldHit (see TOOLBAR_CaptureChanged)
    3929         */
    3930         ReleaseCapture ();
    3931 
    3932         if (bSendMessage)
    3933             SendMessageA (GetParent(hwnd), WM_COMMAND,
    3934                           MAKEWPARAM(btnPtr->idCommand, 0), (LPARAM)hwnd);
     3926    /*
     3927    * now we can ReleaseCapture, which triggers CAPTURECHANGED msg,
     3928    * that resets bCaptured and btn TBSTATE_PRESSED flags,
     3929     * and obliterates nButtonDown and nOldHit (see TOOLBAR_CaptureChanged)
     3930    */
     3931    ReleaseCapture ();
     3932
     3933    if (bSendMessage)
     3934        SendMessageA (GetParent(hwnd), WM_COMMAND,
     3935              MAKEWPARAM(btnPtr->idCommand, 0), (LPARAM)hwnd);
    39353936    }
    39363937
     
    39493950    {
    39503951        btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
    3951         btnPtr->fsState &= ~TBSTATE_PRESSED;
     3952        btnPtr->fsState &= ~TBSTATE_PRESSED;
    39523953
    39533954        infoPtr->nButtonDown = -1;
     
    39753976    if((infoPtr->nOldHit == infoPtr->nHotItem) && (hotBtnPtr->fsState & TBSTATE_ENABLED))
    39763977    {
    3977         hotBtnPtr->bHot = FALSE;
     3978    hotBtnPtr->bHot = FALSE;
    39783979
    39793980        InvalidateRect (hwnd, &hotBtnPtr->rect, TOOLBAR_HasText(infoPtr,
     
    40194020    if(!(trackinfo.dwFlags & TME_LEAVE)) {
    40204021        trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */
    4021  
     4022
    40224023        /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
    40234024        /* and can properly deactivate the hot toolbar button */
     
    40264027
    40274028    if (infoPtr->hwndToolTip)
    4028         TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
    4029                             WM_MOUSEMOVE, wParam, lParam);
     4029    TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
     4030                WM_MOUSEMOVE, wParam, lParam);
    40304031
    40314032    pt.x = (INT)LOWORD(lParam);
     
    40364037    if (infoPtr->nOldHit != nHit)
    40374038    {
    4038         /* Remove the effect of an old hot button if the button was enabled and was
    4039            drawn with the hot button effect */
    4040         if(infoPtr->nOldHit >= 0 && infoPtr->nOldHit == infoPtr->nHotItem &&
    4041                 (infoPtr->buttons[infoPtr->nOldHit].fsState & TBSTATE_ENABLED))
    4042         {
    4043             oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
    4044             oldBtnPtr->bHot = FALSE;
    4045                    
    4046             InvalidateRect (hwnd, &oldBtnPtr->rect,
     4039    /* Remove the effect of an old hot button if the button was enabled and was
     4040       drawn with the hot button effect */
     4041    if(infoPtr->nOldHit >= 0 && infoPtr->nOldHit == infoPtr->nHotItem &&
     4042        (infoPtr->buttons[infoPtr->nOldHit].fsState & TBSTATE_ENABLED))
     4043    {
     4044        oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
     4045        oldBtnPtr->bHot = FALSE;
     4046
     4047        InvalidateRect (hwnd, &oldBtnPtr->rect,
    40474048                TOOLBAR_HasText(infoPtr, oldBtnPtr));
    4048         }
    4049 
    4050         /* It's not a separator or in nowhere. It's a hot button. */
    4051         if (nHit >= 0)
    4052         {
    4053             btnPtr = &infoPtr->buttons[nHit];
    4054             btnPtr->bHot = TRUE;
    4055 
    4056             infoPtr->nHotItem = nHit;
    4057 
    4058             /* only enabled buttons show hot effect */           
     4049    }
     4050
     4051    /* It's not a separator or in nowhere. It's a hot button. */
     4052    if (nHit >= 0)
     4053    {
     4054        btnPtr = &infoPtr->buttons[nHit];
     4055        btnPtr->bHot = TRUE;
     4056
     4057        infoPtr->nHotItem = nHit;
     4058
     4059            /* only enabled buttons show hot effect */
    40594060            if(infoPtr->buttons[nHit].fsState & TBSTATE_ENABLED)
    40604061            {
     
    40634064            }
    40644065
    4065         }
     4066    }
    40664067
    40674068    if (infoPtr->bCaptured) {
    4068             btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
    4069             if (infoPtr->nOldHit == infoPtr->nButtonDown) {
    4070                 btnPtr->fsState &= ~TBSTATE_PRESSED;
     4069        btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
     4070        if (infoPtr->nOldHit == infoPtr->nButtonDown) {
     4071        btnPtr->fsState &= ~TBSTATE_PRESSED;
    40714072                InvalidateRect(hwnd, &btnPtr->rect, TRUE);
    4072             }
    4073             else if (nHit == infoPtr->nButtonDown) {
    4074                 btnPtr->fsState |= TBSTATE_PRESSED;
     4073        }
     4074        else if (nHit == infoPtr->nButtonDown) {
     4075        btnPtr->fsState |= TBSTATE_PRESSED;
    40754076                InvalidateRect(hwnd, &btnPtr->rect, TRUE);
    4076             }
    4077         }
    4078         infoPtr->nOldHit = nHit;
     4077        }
     4078    }
     4079    infoPtr->nOldHit = nHit;
    40794080    }
    40804081    return 0;
     
    40864087{
    40874088/*    if (wndPtr->dwStyle & CCS_NODIVIDER) */
    4088         return DefWindowProcA (hwnd, WM_NCACTIVATE, wParam, lParam);
     4089    return DefWindowProcA (hwnd, WM_NCACTIVATE, wParam, lParam);
    40894090/*    else */
    4090 /*      return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */
     4091/*  return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */
    40914092}
    40924093
     
    40964097{
    40974098    if (!(GetWindowLongA (hwnd, GWL_STYLE) & CCS_NODIVIDER))
    4098         ((LPRECT)lParam)->top += GetSystemMetrics(SM_CYEDGE);
     4099    ((LPRECT)lParam)->top += GetSystemMetrics(SM_CYEDGE);
    40994100
    41004101    return DefWindowProcA (hwnd, WM_NCCALCSIZE, wParam, lParam);
     
    41174118    if (!GetWindowLongA (hwnd, GWL_HINSTANCE)) {
    41184119        HINSTANCE hInst = (HINSTANCE)GetWindowLongA (GetParent (hwnd), GWL_HINSTANCE);
    4119         SetWindowLongA (hwnd, GWL_HINSTANCE, (DWORD)hInst);
     4120    SetWindowLongA (hwnd, GWL_HINSTANCE, (DWORD)hInst);
    41204121    }
    41214122
     
    41324133
    41334134    if (dwStyle & WS_MINIMIZE)
    4134         return 0; /* Nothing to do */
     4135    return 0; /* Nothing to do */
    41354136
    41364137    DefWindowProcA (hwnd, WM_NCPAINT, wParam, lParam);
    41374138
    41384139    if (!(hdc = GetDCEx (hwnd, 0, DCX_USESTYLE | DCX_WINDOW)))
    4139         return 0;
     4140    return 0;
    41404141
    41414142    if (!(dwStyle & CCS_NODIVIDER))
    41424143    {
    4143         GetWindowRect (hwnd, &rcWindow);
    4144         OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
    4145         if( dwStyle & WS_BORDER )
    4146             OffsetRect (&rcWindow, 1, 1);
    4147         DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_TOP);
     4144    GetWindowRect (hwnd, &rcWindow);
     4145    OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
     4146    if( dwStyle & WS_BORDER )
     4147        OffsetRect (&rcWindow, 1, 1);
     4148    DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_TOP);
    41484149    }
    41494150
     
    41634164
    41644165    if ((infoPtr->hwndToolTip) && (lpnmh->hwndFrom == infoPtr->hwndToolTip)) {
    4165         SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,   wParam, lParam);
     4166    SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,   wParam, lParam);
    41664167
    41674168#if 0
    4168         if (lpnmh->code == TTN_GETDISPINFOA) {
    4169             LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam;
    4170 
    4171             FIXME("retrieving ASCII string\n");
    4172 
    4173         }
    4174         else if (lpnmh->code == TTN_GETDISPINFOW) {
    4175             LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam;
    4176 
    4177             FIXME("retrieving UNICODE string\n");
    4178 
    4179         }
     4169    if (lpnmh->code == TTN_GETDISPINFOA) {
     4170        LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam;
     4171
     4172        FIXME("retrieving ASCII string\n");
     4173
     4174    }
     4175    else if (lpnmh->code == TTN_GETDISPINFOW) {
     4176        LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam;
     4177
     4178        FIXME("retrieving UNICODE string\n");
     4179
     4180    }
    41804181#endif
    41814182    }
     
    41934194
    41944195    /* fill ps.rcPaint with a default rect */
    4195     memcpy(&(ps.rcPaint), &(infoPtr->rcBound), sizeof(infoPtr->rcBound)); 
     4196    memcpy(&(ps.rcPaint), &(infoPtr->rcBound), sizeof(infoPtr->rcBound));
    41964197
    41974198    hdc = wParam==0 ? BeginPaint(hwnd, &ps) : (HDC)wParam;
    41984199
    41994200    TRACE("psrect=(%d,%d)-(%d,%d)\n",
    4200           ps.rcPaint.left, ps.rcPaint.top,
    4201           ps.rcPaint.right, ps.rcPaint.bottom);
     4201      ps.rcPaint.left, ps.rcPaint.top,
     4202      ps.rcPaint.right, ps.rcPaint.bottom);
    42024203
    42034204    TOOLBAR_Refresh (hwnd, hdc, &ps);
     
    42234224    /* Resize deadlock check */
    42244225    if (infoPtr->bAutoSize) {
    4225         infoPtr->bAutoSize = FALSE;
    4226         return 0;
     4226    infoPtr->bAutoSize = FALSE;
     4227    return 0;
    42274228    }
    42284229
     
    42394240
    42404241    if (flags == SIZE_RESTORED) {
    4241         /* width and height don't apply */
    4242         parent = GetParent (hwnd);
    4243         GetClientRect(parent, &parent_rect);
    4244         x = parent_rect.left;
    4245         y = parent_rect.top;
    4246 
    4247         if (dwStyle & CCS_NORESIZE) {
    4248             uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
    4249 
    4250             /*
     4242    /* width and height don't apply */
     4243    parent = GetParent (hwnd);
     4244    GetClientRect(parent, &parent_rect);
     4245    x = parent_rect.left;
     4246    y = parent_rect.top;
     4247
     4248    if (dwStyle & CCS_NORESIZE) {
     4249        uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
     4250
     4251        /*
    42514252             * this sets the working width of the toolbar, and
    42524253             * Calc Toolbar will not adjust it, only the height
    42534254             */
    4254             infoPtr->nWidth = parent_rect.right - parent_rect.left;
    4255             cy = infoPtr->nHeight;
    4256             cx = infoPtr->nWidth;
    4257             TOOLBAR_CalcToolbar (hwnd);
    4258             infoPtr->nWidth = cx;
    4259             infoPtr->nHeight = cy;
    4260         }
    4261         else {
    4262             infoPtr->nWidth = parent_rect.right - parent_rect.left;
    4263             TOOLBAR_CalcToolbar (hwnd);
    4264             cy = infoPtr->nHeight;
    4265             cx = infoPtr->nWidth;
    4266 
    4267             if (dwStyle & CCS_NOMOVEY) {
    4268                 GetWindowRect(hwnd, &window_rect);
    4269                 ScreenToClient(parent, (LPPOINT)&window_rect.left);
    4270                 y = window_rect.top;
    4271             }
    4272         }
    4273 
    4274         if (dwStyle & CCS_NOPARENTALIGN) {
    4275             uPosFlags |= SWP_NOMOVE;
    4276             cy = infoPtr->nHeight;
    4277             cx = infoPtr->nWidth;
    4278         }
    4279 
    4280         if (!(dwStyle & CCS_NODIVIDER))
    4281             cy += GetSystemMetrics(SM_CYEDGE);
    4282 
    4283         if (dwStyle & WS_BORDER)
    4284         {
    4285             x = y = 1;
    4286             cy += GetSystemMetrics(SM_CYEDGE);
    4287             cx += GetSystemMetrics(SM_CYEDGE);
    4288         }
    4289 
    4290         SetWindowPos (hwnd, 0, parent_rect.left - x, parent_rect.top - y,
    4291                         cx, cy, uPosFlags | SWP_NOZORDER);
     4255        infoPtr->nWidth = parent_rect.right - parent_rect.left;
     4256        cy = infoPtr->nHeight;
     4257        cx = infoPtr->nWidth;
     4258        TOOLBAR_CalcToolbar (hwnd);
     4259        infoPtr->nWidth = cx;
     4260        infoPtr->nHeight = cy;
     4261    }
     4262    else {
     4263        infoPtr->nWidth = parent_rect.right - parent_rect.left;
     4264        TOOLBAR_CalcToolbar (hwnd);
     4265        cy = infoPtr->nHeight;
     4266        cx = infoPtr->nWidth;
     4267
     4268        if (dwStyle & CCS_NOMOVEY) {
     4269        GetWindowRect(hwnd, &window_rect);
     4270        ScreenToClient(parent, (LPPOINT)&window_rect.left);
     4271        y = window_rect.top;
     4272        }
     4273    }
     4274
     4275    if (dwStyle & CCS_NOPARENTALIGN) {
     4276        uPosFlags |= SWP_NOMOVE;
     4277        cy = infoPtr->nHeight;
     4278        cx = infoPtr->nWidth;
     4279    }
     4280
     4281    if (!(dwStyle & CCS_NODIVIDER))
     4282        cy += GetSystemMetrics(SM_CYEDGE);
     4283
     4284    if (dwStyle & WS_BORDER)
     4285    {
     4286        x = y = 1;
     4287        cy += GetSystemMetrics(SM_CYEDGE);
     4288        cx += GetSystemMetrics(SM_CYEDGE);
     4289    }
     4290
     4291    SetWindowPos (hwnd, 0, parent_rect.left - x, parent_rect.top - y,
     4292            cx, cy, uPosFlags | SWP_NOZORDER);
    42924293    }
    42934294    return 0;
     
    43014302
    43024303    if (nType == GWL_STYLE) {
    4303         if (lpStyle->styleNew & TBSTYLE_LIST) {
    4304             infoPtr->dwDTFlags = DT_LEFT | DT_VCENTER | DT_SINGLELINE;
    4305         }
    4306         else {
    4307             infoPtr->dwDTFlags = DT_CENTER;
    4308         }
     4304    if (lpStyle->styleNew & TBSTYLE_LIST) {
     4305        infoPtr->dwDTFlags = DT_LEFT | DT_VCENTER | DT_SINGLELINE;
     4306    }
     4307    else {
     4308        infoPtr->dwDTFlags = DT_CENTER;
     4309    }
    43094310    }
    43104311
     
    43224323{
    43234324    if (!TOOLBAR_GetInfoPtr(hwnd) && (uMsg != WM_NCCREATE))
    4324         return DefWindowProcA( hwnd, uMsg, wParam, lParam );
     4325    return DefWindowProcA( hwnd, uMsg, wParam, lParam );
    43254326
    43264327    switch (uMsg)
    43274328    {
    4328         case TB_ADDBITMAP:
    4329             return TOOLBAR_AddBitmap (hwnd, wParam, lParam);
    4330 
    4331         case TB_ADDBUTTONSA:
    4332             return TOOLBAR_AddButtonsA (hwnd, wParam, lParam);
    4333 
    4334         case TB_ADDBUTTONSW:
    4335             return TOOLBAR_AddButtonsW (hwnd, wParam, lParam);
    4336 
    4337         case TB_ADDSTRINGA:
    4338             return TOOLBAR_AddStringA (hwnd, wParam, lParam);
    4339 
    4340         case TB_ADDSTRINGW:
    4341             return TOOLBAR_AddStringW (hwnd, wParam, lParam);
    4342 
    4343         case TB_AUTOSIZE:
    4344             return TOOLBAR_AutoSize (hwnd);
    4345 
    4346         case TB_BUTTONCOUNT:
    4347             return TOOLBAR_ButtonCount (hwnd, wParam, lParam);
    4348 
    4349         case TB_BUTTONSTRUCTSIZE:
    4350             return TOOLBAR_ButtonStructSize (hwnd, wParam, lParam);
    4351 
    4352         case TB_CHANGEBITMAP:
    4353             return TOOLBAR_ChangeBitmap (hwnd, wParam, lParam);
    4354 
    4355         case TB_CHECKBUTTON:
    4356             return TOOLBAR_CheckButton (hwnd, wParam, lParam);
    4357 
    4358         case TB_COMMANDTOINDEX:
    4359             return TOOLBAR_CommandToIndex (hwnd, wParam, lParam);
    4360 
    4361         case TB_CUSTOMIZE:
    4362             return TOOLBAR_Customize (hwnd);
    4363 
    4364         case TB_DELETEBUTTON:
    4365             return TOOLBAR_DeleteButton (hwnd, wParam, lParam);
    4366 
    4367         case TB_ENABLEBUTTON:
    4368             return TOOLBAR_EnableButton (hwnd, wParam, lParam);
    4369 
    4370         case TB_GETANCHORHIGHLIGHT:
    4371             return TOOLBAR_GetAnchorHighlight (hwnd);
    4372 
    4373         case TB_GETBITMAP:
    4374             return TOOLBAR_GetBitmap (hwnd, wParam, lParam);
    4375 
    4376         case TB_GETBITMAPFLAGS:
    4377             return TOOLBAR_GetBitmapFlags (hwnd, wParam, lParam);
    4378 
    4379         case TB_GETBUTTON:
    4380             return TOOLBAR_GetButton (hwnd, wParam, lParam);
    4381 
    4382         case TB_GETBUTTONINFOA:
    4383             return TOOLBAR_GetButtonInfoA (hwnd, wParam, lParam);
    4384 
    4385         case TB_GETBUTTONINFOW:
    4386             return TOOLBAR_GetButtonInfoW (hwnd, wParam, lParam);
    4387 
    4388         case TB_GETBUTTONSIZE:
    4389             return TOOLBAR_GetButtonSize (hwnd);
    4390 
    4391         case TB_GETBUTTONTEXTA:
    4392             return TOOLBAR_GetButtonTextA (hwnd, wParam, lParam);
    4393 
    4394         case TB_GETBUTTONTEXTW:
    4395             return TOOLBAR_GetButtonTextW (hwnd, wParam, lParam);
    4396 
    4397 /*      case TB_GETCOLORSCHEME:                 */ /* 4.71 */
    4398 
    4399         case TB_GETDISABLEDIMAGELIST:
    4400             return TOOLBAR_GetDisabledImageList (hwnd, wParam, lParam);
    4401 
    4402         case TB_GETEXTENDEDSTYLE:
    4403             return TOOLBAR_GetExtendedStyle (hwnd);
    4404 
    4405         case TB_GETHOTIMAGELIST:
    4406             return TOOLBAR_GetHotImageList (hwnd, wParam, lParam);
    4407 
    4408         case TB_GETHOTITEM:
    4409             return TOOLBAR_GetHotItem (hwnd);
    4410 
    4411         case TB_GETIMAGELIST:
    4412             return TOOLBAR_GetImageList (hwnd, wParam, lParam);
    4413 
    4414 /*      case TB_GETINSERTMARK:                  */ /* 4.71 */
    4415 /*      case TB_GETINSERTMARKCOLOR:             */ /* 4.71 */
    4416 
    4417         case TB_GETITEMRECT:
    4418             return TOOLBAR_GetItemRect (hwnd, wParam, lParam);
    4419 
    4420         case TB_GETMAXSIZE:
    4421             return TOOLBAR_GetMaxSize (hwnd, wParam, lParam);
    4422 
    4423 /*      case TB_GETOBJECT:                      */ /* 4.71 */
    4424 /*      case TB_GETPADDING:                     */ /* 4.71 */
    4425 
    4426         case TB_GETRECT:
    4427             return TOOLBAR_GetRect (hwnd, wParam, lParam);
    4428 
    4429         case TB_GETROWS:
    4430             return TOOLBAR_GetRows (hwnd, wParam, lParam);
    4431 
    4432         case TB_GETSTATE:
    4433             return TOOLBAR_GetState (hwnd, wParam, lParam);
    4434 
    4435         case TB_GETSTYLE:
    4436             return TOOLBAR_GetStyle (hwnd, wParam, lParam);
    4437 
    4438         case TB_GETTEXTROWS:
    4439             return TOOLBAR_GetTextRows (hwnd, wParam, lParam);
    4440 
    4441         case TB_GETTOOLTIPS:
    4442             return TOOLBAR_GetToolTips (hwnd, wParam, lParam);
    4443 
    4444         case TB_GETUNICODEFORMAT:
    4445             return TOOLBAR_GetUnicodeFormat (hwnd, wParam, lParam);
    4446 
    4447         case CCM_GETVERSION:
    4448             return TOOLBAR_GetVersion (hwnd);
    4449 
    4450         case TB_HIDEBUTTON:
    4451             return TOOLBAR_HideButton (hwnd, wParam, lParam);
    4452 
    4453         case TB_HITTEST:
    4454             return TOOLBAR_HitTest (hwnd, wParam, lParam);
    4455 
    4456         case TB_INDETERMINATE:
    4457             return TOOLBAR_Indeterminate (hwnd, wParam, lParam);
    4458 
    4459         case TB_INSERTBUTTONA:
    4460             return TOOLBAR_InsertButtonA (hwnd, wParam, lParam);
    4461 
    4462         case TB_INSERTBUTTONW:
    4463             return TOOLBAR_InsertButtonW (hwnd, wParam, lParam);
    4464 
    4465 /*      case TB_INSERTMARKHITTEST:              */ /* 4.71 */
    4466 
    4467         case TB_ISBUTTONCHECKED:
    4468             return TOOLBAR_IsButtonChecked (hwnd, wParam, lParam);
    4469 
    4470         case TB_ISBUTTONENABLED:
    4471             return TOOLBAR_IsButtonEnabled (hwnd, wParam, lParam);
    4472 
    4473         case TB_ISBUTTONHIDDEN:
    4474             return TOOLBAR_IsButtonHidden (hwnd, wParam, lParam);
    4475 
    4476         case TB_ISBUTTONHIGHLIGHTED:
    4477             return TOOLBAR_IsButtonHighlighted (hwnd, wParam, lParam);
    4478 
    4479         case TB_ISBUTTONINDETERMINATE:
    4480             return TOOLBAR_IsButtonIndeterminate (hwnd, wParam, lParam);
    4481 
    4482         case TB_ISBUTTONPRESSED:
    4483             return TOOLBAR_IsButtonPressed (hwnd, wParam, lParam);
    4484 
    4485         case TB_LOADIMAGES:                        /* 4.70 */
    4486             FIXME("missing standard imagelists\n");
    4487             return 0;
    4488 
    4489 /*      case TB_MAPACCELERATORA:                */ /* 4.71 */
    4490 /*      case TB_MAPACCELERATORW:                */ /* 4.71 */
    4491 /*      case TB_MARKBUTTON:                     */ /* 4.71 */
    4492 /*      case TB_MOVEBUTTON:                     */ /* 4.71 */
    4493 
    4494         case TB_PRESSBUTTON:
    4495             return TOOLBAR_PressButton (hwnd, wParam, lParam);
    4496 
    4497 /*      case TB_REPLACEBITMAP: */
    4498 
    4499         case TB_SAVERESTOREA:
    4500             return TOOLBAR_SaveRestoreA (hwnd, wParam, lParam);
    4501 
    4502         case TB_SAVERESTOREW:
    4503             return TOOLBAR_SaveRestoreW (hwnd, wParam, lParam);
    4504 
    4505         case TB_SETANCHORHIGHLIGHT:
    4506             return TOOLBAR_SetAnchorHighlight (hwnd, wParam);
    4507 
    4508         case TB_SETBITMAPSIZE:
    4509             return TOOLBAR_SetBitmapSize (hwnd, wParam, lParam);
    4510 
    4511         case TB_SETBUTTONINFOA:
    4512             return TOOLBAR_SetButtonInfoA (hwnd, wParam, lParam);
    4513 
    4514         case TB_SETBUTTONINFOW:
    4515             return TOOLBAR_SetButtonInfoW (hwnd, wParam, lParam);
    4516 
    4517         case TB_SETBUTTONSIZE:
    4518             return TOOLBAR_SetButtonSize (hwnd, wParam, lParam);
    4519 
    4520         case TB_SETBUTTONWIDTH:
    4521             return TOOLBAR_SetButtonWidth (hwnd, wParam, lParam);
    4522 
    4523         case TB_SETCMDID:
    4524             return TOOLBAR_SetCmdId (hwnd, wParam, lParam);
    4525 
    4526 /*      case TB_SETCOLORSCHEME:                 */ /* 4.71 */
    4527 
    4528         case TB_SETDISABLEDIMAGELIST:
    4529             return TOOLBAR_SetDisabledImageList (hwnd, wParam, lParam);
    4530 
    4531         case TB_SETDRAWTEXTFLAGS:
    4532             return TOOLBAR_SetDrawTextFlags (hwnd, wParam, lParam);
    4533 
    4534         case TB_SETEXTENDEDSTYLE:
    4535             return TOOLBAR_SetExtendedStyle (hwnd, wParam, lParam);
    4536 
    4537         case TB_SETHOTIMAGELIST:
    4538             return TOOLBAR_SetHotImageList (hwnd, wParam, lParam);
    4539 
    4540         case TB_SETHOTITEM:
    4541             return TOOLBAR_SetHotItem (hwnd, wParam);
    4542 
    4543         case TB_SETIMAGELIST:
    4544             return TOOLBAR_SetImageList (hwnd, wParam, lParam);
    4545 
    4546         case TB_SETINDENT:
    4547             return TOOLBAR_SetIndent (hwnd, wParam, lParam);
    4548 
    4549 /*      case TB_SETINSERTMARK:                  */ /* 4.71 */
    4550 
    4551         case TB_SETINSERTMARKCOLOR:
    4552             return TOOLBAR_SetInsertMarkColor (hwnd, wParam, lParam);
    4553 
    4554         case TB_SETMAXTEXTROWS:
    4555             return TOOLBAR_SetMaxTextRows (hwnd, wParam, lParam);
    4556 
    4557 /*      case TB_SETPADDING:                     */ /* 4.71 */
    4558 
    4559         case TB_SETPARENT:
    4560             return TOOLBAR_SetParent (hwnd, wParam, lParam);
    4561 
    4562         case TB_SETROWS:
    4563             return TOOLBAR_SetRows (hwnd, wParam, lParam);
    4564 
    4565         case TB_SETSTATE:
    4566             return TOOLBAR_SetState (hwnd, wParam, lParam);
    4567 
    4568         case TB_SETSTYLE:
    4569             return TOOLBAR_SetStyle (hwnd, wParam, lParam);
    4570 
    4571         case TB_SETTOOLTIPS:
    4572             return TOOLBAR_SetToolTips (hwnd, wParam, lParam);
    4573 
    4574         case TB_SETUNICODEFORMAT:
    4575             return TOOLBAR_SetUnicodeFormat (hwnd, wParam, lParam);
    4576 
    4577         case CCM_SETVERSION:
    4578             return TOOLBAR_SetVersion (hwnd, (INT)wParam);
    4579 
    4580 
    4581 /*      case WM_CHAR: */
    4582 
    4583         case WM_CREATE:
    4584             return TOOLBAR_Create (hwnd, wParam, lParam);
    4585 
    4586         case WM_DESTROY:
    4587           return TOOLBAR_Destroy (hwnd, wParam, lParam);
    4588 
    4589         case WM_ERASEBKGND:
    4590             return TOOLBAR_EraseBackground (hwnd, wParam, lParam);
    4591 
    4592         case WM_GETFONT:
    4593                 return TOOLBAR_GetFont (hwnd, wParam, lParam);
    4594 
    4595 /*      case WM_KEYDOWN: */
    4596 /*      case WM_KILLFOCUS: */
    4597 
    4598         case WM_LBUTTONDBLCLK:
    4599             return TOOLBAR_LButtonDblClk (hwnd, wParam, lParam);
    4600 
    4601         case WM_LBUTTONDOWN:
    4602             return TOOLBAR_LButtonDown (hwnd, wParam, lParam);
    4603 
    4604         case WM_LBUTTONUP:
    4605             return TOOLBAR_LButtonUp (hwnd, wParam, lParam);
    4606 
    4607         case WM_MOUSEMOVE:
    4608             return TOOLBAR_MouseMove (hwnd, wParam, lParam);
    4609 
    4610         case WM_MOUSELEAVE:
    4611             return TOOLBAR_MouseLeave (hwnd, wParam, lParam);   
    4612 
    4613         case WM_CAPTURECHANGED:
    4614             return TOOLBAR_CaptureChanged(hwnd);       
    4615 
    4616         case WM_NCACTIVATE:
    4617             return TOOLBAR_NCActivate (hwnd, wParam, lParam);
    4618 
    4619         case WM_NCCALCSIZE:
    4620             return TOOLBAR_NCCalcSize (hwnd, wParam, lParam);
    4621 
    4622         case WM_NCCREATE:
    4623             return TOOLBAR_NCCreate (hwnd, wParam, lParam);
    4624 
    4625         case WM_NCPAINT:
    4626             return TOOLBAR_NCPaint (hwnd, wParam, lParam);
    4627 
    4628         case WM_NOTIFY:
    4629             return TOOLBAR_Notify (hwnd, wParam, lParam);
    4630 
    4631 /*      case WM_NOTIFYFORMAT: */
    4632 
    4633         case WM_PAINT:
    4634             return TOOLBAR_Paint (hwnd, wParam);
    4635 
    4636         case WM_SIZE:
    4637             return TOOLBAR_Size (hwnd, wParam, lParam);
    4638 
    4639         case WM_STYLECHANGED:
    4640             return TOOLBAR_StyleChanged (hwnd, (INT)wParam, (LPSTYLESTRUCT)lParam);
    4641 
    4642 /*      case WM_SYSCOLORCHANGE: */
    4643 
    4644 /*      case WM_WININICHANGE: */
    4645 
    4646         case WM_CHARTOITEM:
    4647         case WM_COMMAND:
    4648         case WM_DRAWITEM:
    4649         case WM_MEASUREITEM:
    4650         case WM_VKEYTOITEM:
    4651             return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
    4652 
    4653         default:
    4654             if (uMsg >= WM_USER)
    4655                 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
    4656                      uMsg, wParam, lParam);
    4657             return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     4329    case TB_ADDBITMAP:
     4330        return TOOLBAR_AddBitmap (hwnd, wParam, lParam);
     4331
     4332    case TB_ADDBUTTONSA:
     4333        return TOOLBAR_AddButtonsA (hwnd, wParam, lParam);
     4334
     4335    case TB_ADDBUTTONSW:
     4336        return TOOLBAR_AddButtonsW (hwnd, wParam, lParam);
     4337
     4338    case TB_ADDSTRINGA:
     4339        return TOOLBAR_AddStringA (hwnd, wParam, lParam);
     4340
     4341    case TB_ADDSTRINGW:
     4342        return TOOLBAR_AddStringW (hwnd, wParam, lParam);
     4343
     4344    case TB_AUTOSIZE:
     4345        return TOOLBAR_AutoSize (hwnd);
     4346
     4347    case TB_BUTTONCOUNT:
     4348        return TOOLBAR_ButtonCount (hwnd, wParam, lParam);
     4349
     4350    case TB_BUTTONSTRUCTSIZE:
     4351        return TOOLBAR_ButtonStructSize (hwnd, wParam, lParam);
     4352
     4353    case TB_CHANGEBITMAP:
     4354        return TOOLBAR_ChangeBitmap (hwnd, wParam, lParam);
     4355
     4356    case TB_CHECKBUTTON:
     4357        return TOOLBAR_CheckButton (hwnd, wParam, lParam);
     4358
     4359    case TB_COMMANDTOINDEX:
     4360        return TOOLBAR_CommandToIndex (hwnd, wParam, lParam);
     4361
     4362    case TB_CUSTOMIZE:
     4363        return TOOLBAR_Customize (hwnd);
     4364
     4365    case TB_DELETEBUTTON:
     4366        return TOOLBAR_DeleteButton (hwnd, wParam, lParam);
     4367
     4368    case TB_ENABLEBUTTON:
     4369        return TOOLBAR_EnableButton (hwnd, wParam, lParam);
     4370
     4371    case TB_GETANCHORHIGHLIGHT:
     4372        return TOOLBAR_GetAnchorHighlight (hwnd);
     4373
     4374    case TB_GETBITMAP:
     4375        return TOOLBAR_GetBitmap (hwnd, wParam, lParam);
     4376
     4377    case TB_GETBITMAPFLAGS:
     4378        return TOOLBAR_GetBitmapFlags (hwnd, wParam, lParam);
     4379
     4380    case TB_GETBUTTON:
     4381        return TOOLBAR_GetButton (hwnd, wParam, lParam);
     4382
     4383    case TB_GETBUTTONINFOA:
     4384        return TOOLBAR_GetButtonInfoA (hwnd, wParam, lParam);
     4385
     4386    case TB_GETBUTTONINFOW:
     4387        return TOOLBAR_GetButtonInfoW (hwnd, wParam, lParam);
     4388
     4389    case TB_GETBUTTONSIZE:
     4390        return TOOLBAR_GetButtonSize (hwnd);
     4391
     4392    case TB_GETBUTTONTEXTA:
     4393        return TOOLBAR_GetButtonTextA (hwnd, wParam, lParam);
     4394
     4395    case TB_GETBUTTONTEXTW:
     4396        return TOOLBAR_GetButtonTextW (hwnd, wParam, lParam);
     4397
     4398/*  case TB_GETCOLORSCHEME:         */ /* 4.71 */
     4399
     4400    case TB_GETDISABLEDIMAGELIST:
     4401        return TOOLBAR_GetDisabledImageList (hwnd, wParam, lParam);
     4402
     4403    case TB_GETEXTENDEDSTYLE:
     4404        return TOOLBAR_GetExtendedStyle (hwnd);
     4405
     4406    case TB_GETHOTIMAGELIST:
     4407        return TOOLBAR_GetHotImageList (hwnd, wParam, lParam);
     4408
     4409    case TB_GETHOTITEM:
     4410        return TOOLBAR_GetHotItem (hwnd);
     4411
     4412    case TB_GETIMAGELIST:
     4413        return TOOLBAR_GetImageList (hwnd, wParam, lParam);
     4414
     4415/*  case TB_GETINSERTMARK:          */ /* 4.71 */
     4416/*  case TB_GETINSERTMARKCOLOR:     */ /* 4.71 */
     4417
     4418    case TB_GETITEMRECT:
     4419        return TOOLBAR_GetItemRect (hwnd, wParam, lParam);
     4420
     4421    case TB_GETMAXSIZE:
     4422        return TOOLBAR_GetMaxSize (hwnd, wParam, lParam);
     4423
     4424/*  case TB_GETOBJECT:          */ /* 4.71 */
     4425/*  case TB_GETPADDING:         */ /* 4.71 */
     4426
     4427    case TB_GETRECT:
     4428        return TOOLBAR_GetRect (hwnd, wParam, lParam);
     4429
     4430    case TB_GETROWS:
     4431        return TOOLBAR_GetRows (hwnd, wParam, lParam);
     4432
     4433    case TB_GETSTATE:
     4434        return TOOLBAR_GetState (hwnd, wParam, lParam);
     4435
     4436    case TB_GETSTYLE:
     4437        return TOOLBAR_GetStyle (hwnd, wParam, lParam);
     4438
     4439    case TB_GETTEXTROWS:
     4440        return TOOLBAR_GetTextRows (hwnd, wParam, lParam);
     4441
     4442    case TB_GETTOOLTIPS:
     4443        return TOOLBAR_GetToolTips (hwnd, wParam, lParam);
     4444
     4445    case TB_GETUNICODEFORMAT:
     4446        return TOOLBAR_GetUnicodeFormat (hwnd, wParam, lParam);
     4447
     4448    case CCM_GETVERSION:
     4449        return TOOLBAR_GetVersion (hwnd);
     4450
     4451    case TB_HIDEBUTTON:
     4452        return TOOLBAR_HideButton (hwnd, wParam, lParam);
     4453
     4454    case TB_HITTEST:
     4455        return TOOLBAR_HitTest (hwnd, wParam, lParam);
     4456
     4457    case TB_INDETERMINATE:
     4458        return TOOLBAR_Indeterminate (hwnd, wParam, lParam);
     4459
     4460    case TB_INSERTBUTTONA:
     4461        return TOOLBAR_InsertButtonA (hwnd, wParam, lParam);
     4462
     4463    case TB_INSERTBUTTONW:
     4464        return TOOLBAR_InsertButtonW (hwnd, wParam, lParam);
     4465
     4466/*  case TB_INSERTMARKHITTEST:      */ /* 4.71 */
     4467
     4468    case TB_ISBUTTONCHECKED:
     4469        return TOOLBAR_IsButtonChecked (hwnd, wParam, lParam);
     4470
     4471    case TB_ISBUTTONENABLED:
     4472        return TOOLBAR_IsButtonEnabled (hwnd, wParam, lParam);
     4473
     4474    case TB_ISBUTTONHIDDEN:
     4475        return TOOLBAR_IsButtonHidden (hwnd, wParam, lParam);
     4476
     4477    case TB_ISBUTTONHIGHLIGHTED:
     4478        return TOOLBAR_IsButtonHighlighted (hwnd, wParam, lParam);
     4479
     4480    case TB_ISBUTTONINDETERMINATE:
     4481        return TOOLBAR_IsButtonIndeterminate (hwnd, wParam, lParam);
     4482
     4483    case TB_ISBUTTONPRESSED:
     4484        return TOOLBAR_IsButtonPressed (hwnd, wParam, lParam);
     4485
     4486    case TB_LOADIMAGES:            /* 4.70 */
     4487        FIXME("missing standard imagelists\n");
     4488        return 0;
     4489
     4490/*  case TB_MAPACCELERATORA:        */ /* 4.71 */
     4491/*  case TB_MAPACCELERATORW:        */ /* 4.71 */
     4492/*  case TB_MARKBUTTON:         */ /* 4.71 */
     4493/*  case TB_MOVEBUTTON:         */ /* 4.71 */
     4494
     4495    case TB_PRESSBUTTON:
     4496        return TOOLBAR_PressButton (hwnd, wParam, lParam);
     4497
     4498/*  case TB_REPLACEBITMAP: */
     4499
     4500    case TB_SAVERESTOREA:
     4501        return TOOLBAR_SaveRestoreA (hwnd, wParam, lParam);
     4502
     4503    case TB_SAVERESTOREW:
     4504        return TOOLBAR_SaveRestoreW (hwnd, wParam, lParam);
     4505
     4506    case TB_SETANCHORHIGHLIGHT:
     4507        return TOOLBAR_SetAnchorHighlight (hwnd, wParam);
     4508
     4509    case TB_SETBITMAPSIZE:
     4510        return TOOLBAR_SetBitmapSize (hwnd, wParam, lParam);
     4511
     4512    case TB_SETBUTTONINFOA:
     4513        return TOOLBAR_SetButtonInfoA (hwnd, wParam, lParam);
     4514
     4515    case TB_SETBUTTONINFOW:
     4516        return TOOLBAR_SetButtonInfoW (hwnd, wParam, lParam);
     4517
     4518    case TB_SETBUTTONSIZE:
     4519        return TOOLBAR_SetButtonSize (hwnd, wParam, lParam);
     4520
     4521    case TB_SETBUTTONWIDTH:
     4522        return TOOLBAR_SetButtonWidth (hwnd, wParam, lParam);
     4523
     4524    case TB_SETCMDID:
     4525        return TOOLBAR_SetCmdId (hwnd, wParam, lParam);
     4526
     4527/*  case TB_SETCOLORSCHEME:         */ /* 4.71 */
     4528
     4529    case TB_SETDISABLEDIMAGELIST:
     4530        return TOOLBAR_SetDisabledImageList (hwnd, wParam, lParam);
     4531
     4532    case TB_SETDRAWTEXTFLAGS:
     4533        return TOOLBAR_SetDrawTextFlags (hwnd, wParam, lParam);
     4534
     4535    case TB_SETEXTENDEDSTYLE:
     4536        return TOOLBAR_SetExtendedStyle (hwnd, wParam, lParam);
     4537
     4538    case TB_SETHOTIMAGELIST:
     4539        return TOOLBAR_SetHotImageList (hwnd, wParam, lParam);
     4540
     4541    case TB_SETHOTITEM:
     4542        return TOOLBAR_SetHotItem (hwnd, wParam);
     4543
     4544    case TB_SETIMAGELIST:
     4545        return TOOLBAR_SetImageList (hwnd, wParam, lParam);
     4546
     4547    case TB_SETINDENT:
     4548        return TOOLBAR_SetIndent (hwnd, wParam, lParam);
     4549
     4550/*  case TB_SETINSERTMARK:          */ /* 4.71 */
     4551
     4552    case TB_SETINSERTMARKCOLOR:
     4553        return TOOLBAR_SetInsertMarkColor (hwnd, wParam, lParam);
     4554
     4555    case TB_SETMAXTEXTROWS:
     4556        return TOOLBAR_SetMaxTextRows (hwnd, wParam, lParam);
     4557
     4558/*  case TB_SETPADDING:         */ /* 4.71 */
     4559
     4560    case TB_SETPARENT:
     4561        return TOOLBAR_SetParent (hwnd, wParam, lParam);
     4562
     4563    case TB_SETROWS:
     4564        return TOOLBAR_SetRows (hwnd, wParam, lParam);
     4565
     4566    case TB_SETSTATE:
     4567        return TOOLBAR_SetState (hwnd, wParam, lParam);
     4568
     4569    case TB_SETSTYLE:
     4570        return TOOLBAR_SetStyle (hwnd, wParam, lParam);
     4571
     4572    case TB_SETTOOLTIPS:
     4573        return TOOLBAR_SetToolTips (hwnd, wParam, lParam);
     4574
     4575    case TB_SETUNICODEFORMAT:
     4576        return TOOLBAR_SetUnicodeFormat (hwnd, wParam, lParam);
     4577
     4578    case CCM_SETVERSION:
     4579        return TOOLBAR_SetVersion (hwnd, (INT)wParam);
     4580
     4581
     4582/*  case WM_CHAR: */
     4583
     4584    case WM_CREATE:
     4585        return TOOLBAR_Create (hwnd, wParam, lParam);
     4586
     4587    case WM_DESTROY:
     4588      return TOOLBAR_Destroy (hwnd, wParam, lParam);
     4589
     4590    case WM_ERASEBKGND:
     4591        return TOOLBAR_EraseBackground (hwnd, wParam, lParam);
     4592
     4593    case WM_GETFONT:
     4594        return TOOLBAR_GetFont (hwnd, wParam, lParam);
     4595
     4596/*  case WM_KEYDOWN: */
     4597/*  case WM_KILLFOCUS: */
     4598
     4599    case WM_LBUTTONDBLCLK:
     4600        return TOOLBAR_LButtonDblClk (hwnd, wParam, lParam);
     4601
     4602    case WM_LBUTTONDOWN:
     4603        return TOOLBAR_LButtonDown (hwnd, wParam, lParam);
     4604
     4605    case WM_LBUTTONUP:
     4606        return TOOLBAR_LButtonUp (hwnd, wParam, lParam);
     4607
     4608    case WM_MOUSEMOVE:
     4609        return TOOLBAR_MouseMove (hwnd, wParam, lParam);
     4610
     4611    case WM_MOUSELEAVE:
     4612        return TOOLBAR_MouseLeave (hwnd, wParam, lParam);
     4613
     4614    case WM_CAPTURECHANGED:
     4615        return TOOLBAR_CaptureChanged(hwnd);
     4616
     4617    case WM_NCACTIVATE:
     4618        return TOOLBAR_NCActivate (hwnd, wParam, lParam);
     4619
     4620    case WM_NCCALCSIZE:
     4621        return TOOLBAR_NCCalcSize (hwnd, wParam, lParam);
     4622
     4623    case WM_NCCREATE:
     4624        return TOOLBAR_NCCreate (hwnd, wParam, lParam);
     4625
     4626    case WM_NCPAINT:
     4627        return TOOLBAR_NCPaint (hwnd, wParam, lParam);
     4628
     4629    case WM_NOTIFY:
     4630        return TOOLBAR_Notify (hwnd, wParam, lParam);
     4631
     4632/*  case WM_NOTIFYFORMAT: */
     4633
     4634    case WM_PAINT:
     4635        return TOOLBAR_Paint (hwnd, wParam);
     4636
     4637    case WM_SIZE:
     4638        return TOOLBAR_Size (hwnd, wParam, lParam);
     4639
     4640    case WM_STYLECHANGED:
     4641        return TOOLBAR_StyleChanged (hwnd, (INT)wParam, (LPSTYLESTRUCT)lParam);
     4642
     4643/*  case WM_SYSCOLORCHANGE: */
     4644
     4645/*  case WM_WININICHANGE: */
     4646
     4647    case WM_CHARTOITEM:
     4648    case WM_COMMAND:
     4649    case WM_DRAWITEM:
     4650    case WM_MEASUREITEM:
     4651    case WM_VKEYTOITEM:
     4652        return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
     4653
     4654    default:
     4655        if (uMsg >= WM_USER)
     4656        ERR("unknown msg %04x wp=%08x lp=%08lx\n",
     4657             uMsg, wParam, lParam);
     4658        return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    46584659    }
    46594660    return 0;
     
    46744675    wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
    46754676    wndClass.lpszClassName = TOOLBARCLASSNAMEA;
    4676  
     4677
    46774678    RegisterClassA (&wndClass);
    46784679}
Note: See TracChangeset for help on using the changeset viewer.