- Timestamp:
- Sep 5, 2001, 2:05:03 PM (24 years ago)
- 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 * 2 3 * Copyright 1999 Marcus Meissner 3 4 * Copyright 2001 Hidenori TAKESHIMA <hidenori@a2.ctktv.ne.jp> … … 22 23 23 24 /*********************************************************************** 24 * 25 * 25 * AVIFileInit (AVIFILE.100) 26 * AVIFileInit (AVIFIL32.@) 26 27 */ 27 28 void WINAPI AVIFileInit(void) 28 29 { 29 30 31 32 33 34 35 36 37 38 } 39 40 /*********************************************************************** 41 * 42 * 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.@) 43 44 */ 44 45 void WINAPI AVIFileExit(void) 45 46 { 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 } 63 64 /*********************************************************************** 65 * 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.@) 66 67 */ 67 68 ULONG WINAPI AVIFileAddRef(PAVIFILE pfile) 68 69 { 69 70 } 71 72 /*********************************************************************** 73 * 74 * 70 return IAVIFile_AddRef( pfile ); 71 } 72 73 /*********************************************************************** 74 * AVIFileRelease (AVIFILE.141) 75 * AVIFileRelease (AVIFIL32.@) 75 76 */ 76 77 ULONG WINAPI AVIFileRelease(PAVIFILE pfile) 77 78 { 78 79 } 80 81 /*********************************************************************** 82 * 83 * 79 return IAVIFile_Release( pfile ); 80 } 81 82 /*********************************************************************** 83 * AVIFileOpen (AVIFILE.102) 84 * AVIFileOpenA (AVIFIL32.@) 84 85 */ 85 86 HRESULT WINAPI AVIFileOpenA( 86 87 { 88 WCHAR*pwsz;89 HRESULThr;90 91 92 93 94 95 96 97 98 } 99 100 /*********************************************************************** 101 * 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.@) 102 103 */ 103 104 HRESULT WINAPI AVIFileOpenW( 104 105 { 106 HRESULThr;107 IClassFactory*pcf;108 CLSIDclsRIFF;109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 } 151 152 /*********************************************************************** 153 * 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.@) 154 155 */ 155 156 HRESULT WINAPI AVIFileInfoW(PAVIFILE pfile,AVIFILEINFOW* pfi,LONG lSize) 156 157 { 157 158 } 159 160 /*********************************************************************** 161 * 162 * 158 return IAVIFile_Info( pfile, pfi, lSize ); 159 } 160 161 /*********************************************************************** 162 * AVIFileInfo (AVIFIL32.@) 163 * AVIFileInfoA (AVIFIL32.@) 163 164 */ 164 165 HRESULT WINAPI AVIFileInfoA(PAVIFILE pfile,AVIFILEINFOA* pfi,LONG lSize) 165 166 { 166 AVIFILEINFOWfiw;167 HRESULThr;168 169 170 171 172 173 174 175 176 177 178 179 180 } 181 182 /*********************************************************************** 183 * 184 * 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.@) 185 186 */ 186 187 HRESULT WINAPI AVIFileGetStream(PAVIFILE pfile,PAVISTREAM* pas,DWORD fccType,LONG lParam) 187 188 { 188 189 } 190 191 /*********************************************************************** 192 * 189 return IAVIFile_GetStream(pfile,pas,fccType,lParam); 190 } 191 192 /*********************************************************************** 193 * AVIFileCreateStreamW (AVIFIL32.@) 193 194 */ 194 195 HRESULT WINAPI AVIFileCreateStreamW(PAVIFILE pfile,PAVISTREAM* ppas,AVISTREAMINFOW* pasi) 195 196 { 196 197 } 198 199 /*********************************************************************** 200 * 197 return IAVIFile_CreateStream(pfile,ppas,pasi); 198 } 199 200 /*********************************************************************** 201 * AVIFileCreateStreamA (AVIFIL32.@) 201 202 */ 202 203 HRESULT WINAPI AVIFileCreateStreamA(PAVIFILE pfile,PAVISTREAM* ppas,AVISTREAMINFOA* pasi) 203 204 { 204 AVISTREAMINFOWsiw;205 HRESULThr;206 207 208 209 210 211 212 213 214 215 } 216 217 /*********************************************************************** 218 * 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.@) 219 220 */ 220 221 HRESULT WINAPI AVIFileWriteData( 221 222 { 223 224 } 225 226 /*********************************************************************** 227 * 222 PAVIFILE pfile,DWORD dwChunkId,LPVOID lpvData,LONG cbData ) 223 { 224 return IAVIFile_WriteData( pfile,dwChunkId,lpvData,cbData ); 225 } 226 227 /*********************************************************************** 228 * AVIFileReadData (AVIFIL32.@) 228 229 */ 229 230 HRESULT WINAPI AVIFileReadData( 230 231 { 232 233 } 234 235 /*********************************************************************** 236 * 231 PAVIFILE pfile,DWORD dwChunkId,LPVOID lpvData,LPLONG pcbData ) 232 { 233 return IAVIFile_ReadData( pfile,dwChunkId,lpvData,pcbData ); 234 } 235 236 /*********************************************************************** 237 * AVIFileEndRecord (AVIFIL32.@) 237 238 */ 238 239 HRESULT WINAPI AVIFileEndRecord( PAVIFILE pfile ) 239 240 { 240 241 } 242 243 /*********************************************************************** 244 * 241 return IAVIFile_EndRecord( pfile ); 242 } 243 244 /*********************************************************************** 245 * AVIStreamAddRef (AVIFIL32.@) 245 246 */ 246 247 ULONG WINAPI AVIStreamAddRef(PAVISTREAM pas) 247 248 { 248 249 } 250 251 /*********************************************************************** 252 * 249 return IAVIStream_Release(pas); 250 } 251 252 /*********************************************************************** 253 * AVIStreamRelease (AVIFIL32.@) 253 254 */ 254 255 ULONG WINAPI AVIStreamRelease(PAVISTREAM pas) 255 256 { 256 257 } 258 259 /*********************************************************************** 260 * 257 return IAVIStream_Release(pas); 258 } 259 260 /*********************************************************************** 261 * AVIStreamInfoW (AVIFIL32.@) 261 262 */ 262 263 HRESULT WINAPI AVIStreamInfoW(PAVISTREAM pas,AVISTREAMINFOW* psi,LONG lSize) 263 264 { 264 265 } 266 267 /*********************************************************************** 268 * 269 * 265 return IAVIStream_Info(pas,psi,lSize); 266 } 267 268 /*********************************************************************** 269 * AVIStreamInfo (AVIFIL32.@) 270 * AVIStreamInfoA (AVIFIL32.@) 270 271 */ 271 272 HRESULT WINAPI AVIStreamInfoA(PAVISTREAM pas,AVISTREAMINFOA* psi,LONG lSize) 272 273 { 273 AVISTREAMINFOWsiw;274 HRESULThr;275 276 277 278 279 280 281 282 283 284 285 286 } 287 288 /*********************************************************************** 289 * 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.@) 290 291 */ 291 292 LONG WINAPI AVIStreamFindSample(PAVISTREAM pas,LONG lPos,LONG lFlags) 292 293 { 293 294 } 295 296 /*********************************************************************** 297 * 294 return IAVIStream_FindSample(pas,lPos,lFlags); 295 } 296 297 /*********************************************************************** 298 * AVIStreamReadFormat (AVIFIL32.@) 298 299 */ 299 300 HRESULT WINAPI AVIStreamReadFormat(PAVISTREAM pas,LONG pos,LPVOID format,LONG *formatsize) { 300 301 } 302 303 /*********************************************************************** 304 * 301 return IAVIStream_ReadFormat(pas,pos,format,formatsize); 302 } 303 304 /*********************************************************************** 305 * AVIStreamSetFormat (AVIFIL32.@) 305 306 */ 306 307 HRESULT WINAPI AVIStreamSetFormat(PAVISTREAM pas,LONG pos,LPVOID format,LONG formatsize) { 307 308 } 309 310 /*********************************************************************** 311 * 308 return IAVIStream_SetFormat(pas,pos,format,formatsize); 309 } 310 311 /*********************************************************************** 312 * AVIStreamReadData (AVIFIL32.@) 312 313 */ 313 314 HRESULT WINAPI AVIStreamReadData(PAVISTREAM pas,DWORD fcc,LPVOID lp,LONG *lpread) { 314 315 } 316 317 /*********************************************************************** 318 * 315 return IAVIStream_ReadData(pas,fcc,lp,lpread); 316 } 317 318 /*********************************************************************** 319 * AVIStreamWriteData (AVIFIL32.@) 319 320 */ 320 321 HRESULT WINAPI AVIStreamWriteData(PAVISTREAM pas,DWORD fcc,LPVOID lp,LONG size) { 321 322 } 323 324 /*********************************************************************** 325 * 322 return IAVIStream_WriteData(pas,fcc,lp,size); 323 } 324 325 /*********************************************************************** 326 * AVIStreamRead (AVIFIL32.@) 326 327 */ 327 328 HRESULT WINAPI AVIStreamRead(PAVISTREAM pas,LONG start,LONG samples,LPVOID buffer,LONG buffersize,LONG *bytesread,LONG *samplesread) 328 329 { 329 330 } 331 332 /*********************************************************************** 333 * 330 return IAVIStream_Read(pas,start,samples,buffer,buffersize,bytesread,samplesread); 331 } 332 333 /*********************************************************************** 334 * AVIStreamWrite (AVIFIL32.@) 334 335 */ 335 336 HRESULT WINAPI AVIStreamWrite(PAVISTREAM pas,LONG start,LONG samples,LPVOID buffer,LONG buffersize,DWORD flags,LONG *sampwritten,LONG *byteswritten) { 336 337 } 338 339 340 /*********************************************************************** 341 * 337 return IAVIStream_Write(pas,start,samples,buffer,buffersize,flags,sampwritten,byteswritten); 338 } 339 340 341 /*********************************************************************** 342 * AVIStreamStart (AVIFIL32.@) 342 343 */ 343 344 LONG WINAPI AVIStreamStart(PAVISTREAM pas) 344 345 { 345 AVISTREAMINFOWsi;346 HRESULThr;347 348 349 350 351 352 } 353 354 /*********************************************************************** 355 * 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.@) 356 357 */ 357 358 LONG WINAPI AVIStreamLength(PAVISTREAM pas) 358 359 { 359 AVISTREAMINFOWsi;360 HRESULThr;361 362 363 364 365 366 } 367 368 /*********************************************************************** 369 * 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.@) 370 371 */ 371 372 LONG WINAPI AVIStreamTimeToSample(PAVISTREAM pas,LONG lTime) 372 373 { 373 AVISTREAMINFOWsi;374 HRESULThr;375 376 377 378 379 380 381 382 383 } 384 385 /*********************************************************************** 386 * 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.@) 387 388 */ 388 389 LONG WINAPI AVIStreamSampleToTime(PAVISTREAM pas,LONG lSample) 389 390 { 390 AVISTREAMINFOWsi;391 HRESULThr;392 393 394 395 396 397 398 399 400 } 401 402 /*********************************************************************** 403 * 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.@) 404 405 */ 405 406 HRESULT WINAPI AVIStreamBeginStreaming(PAVISTREAM pas,LONG lStart,LONG lEnd,LONG lRate) 406 407 { 407 408 409 } 410 411 /*********************************************************************** 412 * 408 FIXME("(%p)->(%ld,%ld,%ld),stub!\n",pas,lStart,lEnd,lRate); 409 return E_FAIL; 410 } 411 412 /*********************************************************************** 413 * AVIStreamEndStreaming (AVIFIL32.@) 413 414 */ 414 415 HRESULT WINAPI AVIStreamEndStreaming(PAVISTREAM pas) 415 416 { 416 417 418 } 419 420 /*********************************************************************** 421 * 417 FIXME("(%p)->(),stub!\n",pas); 418 return E_FAIL; 419 } 420 421 /*********************************************************************** 422 * AVIStreamGetFrameOpen (AVIFIL32.@) 422 423 */ 423 424 PGETFRAME WINAPI AVIStreamGetFrameOpen(PAVISTREAM pas,LPBITMAPINFOHEADER pbi) 424 425 { 425 IGetFrame*pgf;426 HRESULThr;427 AVISTREAMINFOWsi;428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 } 447 448 /*********************************************************************** 449 * 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.@) 450 451 */ 451 452 LPVOID WINAPI AVIStreamGetFrame(PGETFRAME pgf, LONG lPos) 452 453 { 453 454 } 455 456 /*********************************************************************** 457 * 454 return IGetFrame_GetFrame(pgf,lPos); 455 } 456 457 /*********************************************************************** 458 * AVIStreamGetFrameClose (AVIFIL32.@) 458 459 */ 459 460 HRESULT WINAPI AVIStreamGetFrameClose(PGETFRAME pgf) 460 461 { 461 462 } 463 464 /*********************************************************************** 465 * 462 return IGetFrame_End(pgf); 463 } 464 465 /*********************************************************************** 466 * AVIStreamOpenFromFileA (AVIFIL32.@) 466 467 */ 467 468 HRESULT WINAPI AVIStreamOpenFromFileA(PAVISTREAM* ppas, LPCSTR szFile, DWORD fccType, LONG lParam, UINT uMode, CLSID* lpHandler) 468 469 { 469 WCHAR*pwsz;470 HRESULThr;471 472 473 474 475 476 477 478 } 479 480 /*********************************************************************** 481 * 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.@) 482 483 */ 483 484 HRESULT WINAPI AVIStreamOpenFromFileW(PAVISTREAM* ppas, LPCWSTR szFile, DWORD fccType, LONG lParam, UINT uMode, CLSID* lpHandler) 484 485 { 485 HRESULThr;486 PAVIFILEpaf;487 AVIFILEINFOWfi;488 489 490 491 492 493 494 495 496 497 498 499 500 } 501 502 /*********************************************************************** 503 * 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.@) 504 505 */ 505 506 HRESULT WINAPI AVIStreamCreate(PAVISTREAM* ppas, LONG lParam1, LONG lParam2, CLSID* lpHandler) 506 507 { 507 HRESULThr;508 IClassFactory*pcf;509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 } 543 544 /*********************************************************************** 545 * 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.@) 546 547 */ 547 548 HRESULT WINAPI AVIMakeCompressedStream(PAVISTREAM *ppsCompressed,PAVISTREAM ppsSource,AVICOMPRESSOPTIONS *aco,CLSID *pclsidHandler) 548 549 { 549 550 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 * 2 3 * Copyright 2001 Hidenori TAKESHIMA <hidenori@a2.ctktv.ne.jp> 3 4 */ … … 27 28 static ICOM_VTABLE(IClassFactory) iclassfact = 28 29 { 29 30 31 32 33 34 30 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE 31 IClassFactory_fnQueryInterface, 32 IClassFactory_fnAddRef, 33 IClassFactory_fnRelease, 34 IClassFactory_fnCreateInstance, 35 IClassFactory_fnLockServer 35 36 }; 36 37 37 38 typedef struct 38 39 { 39 40 41 DWORDref;40 /* IUnknown fields */ 41 ICOM_VFIELD(IClassFactory); 42 DWORD ref; 42 43 } IClassFactoryImpl; 43 44 … … 49 50 IClassFactory_fnQueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) 50 51 { 51 52 ICOM_THIS(IClassFactoryImpl,iface); 52 53 53 54 55 56 57 58 59 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 } 61 62 62 63 return E_NOINTERFACE; 63 64 } 64 65 65 66 static ULONG WINAPI IClassFactory_fnAddRef(LPCLASSFACTORY iface) 66 67 { 67 68 ICOM_THIS(IClassFactoryImpl,iface); 68 69 69 70 71 70 TRACE("(%p)->()\n",This); 71 if ( (This->ref) == 0 ) 72 AVIFILE_data.dwClassObjRef ++; 72 73 73 74 return ++(This->ref); 74 75 } 75 76 76 77 static ULONG WINAPI IClassFactory_fnRelease(LPCLASSFACTORY iface) 77 78 { 78 79 ICOM_THIS(IClassFactoryImpl,iface); 79 80 80 81 82 81 TRACE("(%p)->()\n",This); 82 if ( (--(This->ref)) > 0 ) 83 return This->ref; 83 84 84 85 85 AVIFILE_data.dwClassObjRef --; 86 return 0; 86 87 } 87 88 … … 90 91 /*ICOM_THIS(IClassFactoryImpl,iface);*/ 91 92 92 93 94 93 *ppobj = NULL; 94 if ( pOuter != NULL ) 95 return E_FAIL; 95 96 96 97 98 99 97 if ( IsEqualGUID( &IID_IAVIFile, riid ) ) 98 return AVIFILE_CreateIAVIFile(ppobj); 99 if ( IsEqualGUID( &IID_IAVIStream, riid ) ) 100 return AVIFILE_CreateIAVIStream(ppobj); 100 101 101 102 return E_NOINTERFACE; 102 103 } 103 104 104 105 static HRESULT WINAPI IClassFactory_fnLockServer(LPCLASSFACTORY iface,BOOL dolock) 105 106 { 106 107 HRESULThr;107 ICOM_THIS(IClassFactoryImpl,iface); 108 HRESULT hr; 108 109 109 110 111 112 113 110 FIXME("(%p)->(%d),stub!\n",This,dolock); 111 if (dolock) 112 hr = IClassFactory_AddRef(iface); 113 else 114 hr = IClassFactory_Release(iface); 114 115 115 116 return hr; 116 117 } 117 118 118 119 119 120 /*********************************************************************** 120 * 121 * DllGetClassObject (AVIFIL32.@) 121 122 */ 122 123 HRESULT WINAPI AVIFILE_DllGetClassObject(const CLSID* pclsid,const IID* piid,void** ppv) 123 124 { 124 125 126 127 128 129 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 } 131 132 132 133 return CLASS_E_CLASSNOTAVAILABLE; 133 134 } 134 135 135 136 /***************************************************************************** 136 * 137 * DllCanUnloadNow (AVIFIL32.@) 137 138 */ 138 139 DWORD WINAPI AVIFILE_DllCanUnloadNow(void) 139 140 { 140 141 return ( AVIFILE_data.dwClassObjRef == 0 ) ? S_OK : S_FALSE; 141 142 } 142 143 -
trunk/src/comctl32/animate.c
r5630 r6644 1 1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */ 2 /* $Id: animate.c,v 1.14 2001-09-05 12:04:56 bird Exp $ */ 2 3 /* 3 4 * Animation control 4 5 * 5 6 * Copyright 1998, 1999 Eric Kohl 6 * 7 * 1999 Eric Pouech 7 8 * 8 9 * NOTES … … 33 34 #endif 34 35 /* reference to input stream (file or resource) */ 35 HGLOBAL 36 HMMIO hMMio;/* handle to mmio stream */37 HWND 36 HGLOBAL hRes; 37 HMMIO hMMio; /* handle to mmio stream */ 38 HWND hWnd; 38 39 /* information on the loaded AVI file */ 39 MainAVIHeader 40 AVIStreamHeader 41 LPBITMAPINFOHEADER 42 LPDWORD 40 MainAVIHeader mah; 41 AVIStreamHeader ash; 42 LPBITMAPINFOHEADER inbih; 43 LPDWORD lpIndex; 43 44 /* data for the decompressor */ 44 HIC 45 LPBITMAPINFOHEADER 46 LPVOID 47 LPVOID 45 HIC hic; 46 LPBITMAPINFOHEADER outbih; 47 LPVOID indata; 48 LPVOID outdata; 48 49 /* data for the background mechanism */ 49 CRITICAL_SECTION 50 HANDLE 51 UINT 50 CRITICAL_SECTION cs; 51 HANDLE hThread; 52 UINT uTimer; 52 53 /* data for playing the file */ 53 int 54 int 55 int 56 int 54 int nFromFrame; 55 int nToFrame; 56 int nLoop; 57 int currFrame; 57 58 /* tranparency info*/ 58 COLORREF transparentColor;59 HBRUSH 60 HBITMAP 59 COLORREF transparentColor; 60 HBRUSH hbrushBG; 61 HBITMAP hbmPrevFrame; 61 62 } ANIMATE_INFO; 62 63 63 64 #define ANIMATE_GetInfoPtr(hWnd) ((ANIMATE_INFO *)GetWindowLongA(hWnd, 0)) 64 #define ANIMATE_COLOR_NONE 65 #define ANIMATE_COLOR_NONE 0xffffffff 65 66 66 67 static void ANIMATE_Notify(ANIMATE_INFO* infoPtr, UINT notif) 67 68 { 68 SendMessageA(GetParent(infoPtr->hWnd), WM_COMMAND, 69 MAKEWPARAM(GetDlgCtrlID(infoPtr->hWnd), notif), 70 69 SendMessageA(GetParent(infoPtr->hWnd), WM_COMMAND, 70 MAKEWPARAM(GetDlgCtrlID(infoPtr->hWnd), notif), 71 (LPARAM)infoPtr->hWnd); 71 72 } 72 73 … … 77 78 #endif 78 79 { 79 HRSRC 80 MMIOINFO 81 LPVOID 82 80 HRSRC hrsrc; 81 MMIOINFO mminfo; 82 LPVOID lpAvi; 83 83 84 #ifdef __WIN32OS2__ 84 85 if (unicode) … … 90 91 #endif 91 92 if (!hrsrc) 92 93 93 return FALSE; 94 94 95 infoPtr->hRes = LoadResource(hInst, hrsrc); 95 96 if (!infoPtr->hRes) 96 97 97 return FALSE; 98 98 99 lpAvi = LockResource(infoPtr->hRes); 99 100 if (!lpAvi) 100 101 101 return FALSE; 102 102 103 memset(&mminfo, 0, sizeof(mminfo)); 103 104 mminfo.fccIOProc = FOURCC_MEM; … … 106 107 infoPtr->hMMio = mmioOpenA(NULL, &mminfo, MMIO_READ); 107 108 if (!infoPtr->hMMio) { 108 109 109 GlobalFree((HGLOBAL)lpAvi); 110 return FALSE; 110 111 } 111 112 … … 127 128 #else 128 129 infoPtr->hMMio = mmioOpenA((LPSTR)lpName, NULL, 129 130 MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE); 130 131 #endif 131 132 if (!infoPtr->hMMio) 132 133 133 return FALSE; 134 134 135 return TRUE; 135 136 } … … 141 142 142 143 /* should stop playing */ 143 if (infoPtr->hThread) 144 if (infoPtr->hThread) 144 145 { 145 146 if (!TerminateThread(infoPtr->hThread,0)) 146 147 WARN("could not destroy animation thread!\n"); 147 148 infoPtr->hThread = 0; 148 149 } 149 150 if (infoPtr->uTimer) { 150 151 151 KillTimer(infoPtr->hWnd, infoPtr->uTimer); 152 infoPtr->uTimer = 0; 152 153 } 153 154 … … 163 164 { 164 165 if (infoPtr->hMMio) { 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 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 } 187 188 if( infoPtr->indata ) 188 189 { 189 190 HeapFree(GetProcessHeap(), 0, infoPtr->indata); 190 191 infoPtr->indata = NULL; 191 192 } 192 193 if( infoPtr->outdata ) 193 194 { 194 195 HeapFree(GetProcessHeap(), 0, infoPtr->outdata); 195 196 infoPtr->outdata = NULL; 196 197 } 197 198 if( infoPtr->hbmPrevFrame ) 198 199 { 199 200 DeleteObject(infoPtr->hbmPrevFrame); 200 201 infoPtr->hbmPrevFrame = 0; 201 202 } 202 203 204 205 206 207 208 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; 211 212 } 212 213 213 214 static void ANIMATE_TransparentBlt(ANIMATE_INFO* infoPtr, HDC hdcDest, HDC hdcSource) 214 { 215 { 215 216 HDC hdcMask; 216 217 HBITMAP hbmMask; 217 HBITMAP hbmOld; 218 218 HBITMAP hbmOld; 219 219 220 /* create a transparency mask */ 220 221 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); 223 224 224 225 SetBkColor(hdcSource,infoPtr->transparentColor); 225 226 BitBlt(hdcMask,0,0,infoPtr->inbih->biWidth, infoPtr->inbih->biHeight,hdcSource,0,0,SRCCOPY); 226 227 227 228 /* 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)); 230 231 BitBlt(hdcSource, 0, 0, infoPtr->inbih->biWidth, infoPtr->inbih->biHeight, hdcMask, 0, 0, SRCAND); 231 232 232 233 /* 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)); 235 236 BitBlt(hdcDest, 0, 0, infoPtr->inbih->biWidth, infoPtr->inbih->biHeight, hdcMask, 0, 0, SRCAND); 236 237 … … 258 259 259 260 if (!hDC || !infoPtr->inbih) 260 261 return TRUE; 261 262 262 263 if (infoPtr->hic ) … … 266 267 267 268 nWidth = infoPtr->outbih->biWidth; 268 nHeight = infoPtr->outbih->biHeight; 269 nHeight = infoPtr->outbih->biHeight; 269 270 } else 270 { 271 { 271 272 pBitmapData = infoPtr->indata; 272 273 pBitmapInfo = (LPBITMAPINFO)infoPtr->inbih; 273 274 274 275 nWidth = infoPtr->inbih->biWidth; 275 nHeight = infoPtr->inbih->biHeight; 276 } 276 nHeight = infoPtr->inbih->biHeight; 277 } 277 278 278 279 if(!infoPtr->hbmPrevFrame) … … 281 282 } 282 283 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 285 286 hdcMem = CreateCompatibleDC(hDC); 286 287 hbmOld = SelectObject(hdcMem, infoPtr->hbmPrevFrame); 287 288 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, 290 291 * 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 292 293 */ 293 294 if(infoPtr->transparentColor == ANIMATE_COLOR_NONE) 294 295 { 295 296 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 { 300 301 HDC hdcFinal = CreateCompatibleDC(hDC); 301 302 HBITMAP hbmFinal = CreateCompatibleBitmap(hDC,nWidth, nHeight); 302 303 HBITMAP hbmOld2 = SelectObject(hdcFinal, hbmFinal); 303 304 RECT rect; 304 305 305 306 rect.left = 0; 306 307 rect.top = 0; 307 308 rect.right = nWidth; 308 309 rect.bottom = nHeight; 309 310 310 311 if(!infoPtr->hbrushBG) 311 312 infoPtr->hbrushBG = GetCurrentObject(hDC, OBJ_BRUSH); … … 320 321 infoPtr->hbmPrevFrame = hbmFinal; 321 322 } 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; 326 327 327 328 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); 332 333 333 334 SelectObject(hdcMem, hbmOld); … … 338 339 static LRESULT ANIMATE_DrawFrame(ANIMATE_INFO* infoPtr) 339 340 { 340 HDC 341 HDC hDC; 341 342 342 343 TRACE("Drawing frame %d (loop %d)\n", infoPtr->currFrame, infoPtr->nLoop); … … 346 347 mmioSeek(infoPtr->hMMio, infoPtr->lpIndex[infoPtr->currFrame], SEEK_SET); 347 348 mmioRead(infoPtr->hMMio, infoPtr->indata, infoPtr->ash.dwSuggestedBufferSize); 348 349 349 350 if (infoPtr->hic && 350 ICDecompress(infoPtr->hic, 0, infoPtr->inbih, infoPtr->indata, 351 352 353 354 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; 355 356 } 356 357 357 358 if ((hDC = GetDC(infoPtr->hWnd)) != 0) { 358 359 359 ANIMATE_PaintFrame(infoPtr, hDC); 360 ReleaseDC(infoPtr->hWnd, hDC); 360 361 } 361 362 362 363 if (infoPtr->currFrame++ >= infoPtr->nToFrame) { 363 364 365 366 367 368 364 infoPtr->currFrame = infoPtr->nFromFrame; 365 if (infoPtr->nLoop != -1) { 366 if (--infoPtr->nLoop == 0) { 367 ANIMATE_DoStop(infoPtr); 368 } 369 } 369 370 } 370 371 LeaveCriticalSection(&infoPtr->cs); … … 375 376 static DWORD CALLBACK ANIMATE_AnimationThread(LPVOID ptr_) 376 377 { 377 ANIMATE_INFO* 378 ANIMATE_INFO* infoPtr = (ANIMATE_INFO*)ptr_; 378 379 HDC hDC; 379 380 380 381 if(!infoPtr) 381 382 { … … 385 386 386 387 while(1) 387 { 388 if(GetWindowLongA(infoPtr->hWnd, GWL_STYLE) & ACS_TRANSPARENT) 388 { 389 if(GetWindowLongA(infoPtr->hWnd, GWL_STYLE) & ACS_TRANSPARENT) 389 390 { 390 391 hDC = GetDC(infoPtr->hWnd); 391 392 392 /* sometimes the animation window will be destroyed in between 393 * by the main program, so a ReleaseDC() error msg is possible */ 393 394 infoPtr->hbrushBG = SendMessageA(GetParent(infoPtr->hWnd),WM_CTLCOLORSTATIC,hDC, infoPtr->hWnd); 394 395 ReleaseDC(infoPtr->hWnd,hDC); 395 396 } 396 397 397 398 EnterCriticalSection(&infoPtr->cs); 398 399 ANIMATE_DrawFrame(infoPtr); 399 400 LeaveCriticalSection(&infoPtr->cs); 400 401 401 402 /* time is in microseconds, we should convert it to milliseconds */ 402 403 Sleep((infoPtr->mah.dwMicroSecPerFrame+500)/1000); … … 411 412 /* nothing opened */ 412 413 if (!infoPtr->hMMio) 413 414 return FALSE; 414 415 415 416 if (infoPtr->hThread || infoPtr->uTimer) { 416 417 417 FIXME("Already playing ? what should I do ??\n"); 418 ANIMATE_DoStop(infoPtr); 418 419 } 419 420 … … 423 424 424 425 if (infoPtr->nToFrame == 0xFFFF) 425 426 427 TRACE("(repeat=%d from=%d to=%d);\n", 428 426 infoPtr->nToFrame = infoPtr->mah.dwTotalFrames - 1; 427 428 TRACE("(repeat=%d from=%d to=%d);\n", 429 infoPtr->nLoop, infoPtr->nFromFrame, infoPtr->nToFrame); 429 430 430 431 if (infoPtr->nFromFrame >= infoPtr->nToFrame || 431 432 432 infoPtr->nToFrame >= infoPtr->mah.dwTotalFrames) 433 return FALSE; 433 434 434 435 infoPtr->currFrame = infoPtr->nFromFrame; 435 436 436 437 if (GetWindowLongA(hWnd, GWL_STYLE) & ACS_TIMER) { 437 438 439 438 TRACE("Using a timer\n"); 439 /* create a timer to display AVI */ 440 infoPtr->uTimer = SetTimer(hWnd, 1, infoPtr->mah.dwMicroSecPerFrame / 1000, NULL); 440 441 } else { 441 442 DWORD threadID; 442 443 443 444 TRACE("Using an animation thread\n"); 444 445 infoPtr->hThread = CreateThread(0,0,ANIMATE_AnimationThread,(LPVOID)infoPtr,0,0 &threadID); 445 446 if(!infoPtr->hThread) … … 448 449 return FALSE; 449 450 } 450 451 } 452 451 452 } 453 453 454 ANIMATE_Notify(infoPtr, ACN_START); 454 455 … … 459 460 static BOOL ANIMATE_GetAviInfo(ANIMATE_INFO *infoPtr) 460 461 { 461 MMCKINFO 462 MMCKINFO 463 MMCKINFO 464 MMCKINFO 465 DWORD 466 DWORD 462 MMCKINFO ckMainRIFF; 463 MMCKINFO mmckHead; 464 MMCKINFO mmckList; 465 MMCKINFO mmckInfo; 466 DWORD numFrame; 467 DWORD insize; 467 468 468 469 if (mmioDescend(infoPtr->hMMio, &ckMainRIFF, NULL, 0) != 0) { 469 470 470 WARN("Can't find 'RIFF' chunk\n"); 471 return FALSE; 471 472 } 472 473 473 474 if ((ckMainRIFF.ckid != FOURCC_RIFF) || 474 475 476 475 (ckMainRIFF.fccType != mmioFOURCC('A', 'V', 'I', ' '))) { 476 WARN("Can't find 'AVI ' chunk\n"); 477 return FALSE; 477 478 } 478 479 479 480 mmckHead.fccType = mmioFOURCC('h', 'd', 'r', 'l'); 480 481 if (mmioDescend(infoPtr->hMMio, &mmckHead, &ckMainRIFF, MMIO_FINDLIST) != 0) { 481 482 482 WARN("Can't find 'hdrl' list\n"); 483 return FALSE; 483 484 } 484 485 485 486 mmckInfo.ckid = mmioFOURCC('a', 'v', 'i', 'h'); 486 487 if (mmioDescend(infoPtr->hMMio, &mmckInfo, &mmckHead, MMIO_FINDCHUNK) != 0) { 487 488 488 WARN("Can't find 'avih' chunk\n"); 489 return FALSE; 489 490 } 490 491 491 492 mmioRead(infoPtr->hMMio, (LPSTR)&infoPtr->mah, sizeof(infoPtr->mah)); 492 493 493 TRACE("mah.dwMicroSecPerFrame=%ld\n", 494 TRACE("mah.dwMaxBytesPerSec=%ld\n", 495 TRACE("mah.dwPaddingGranularity=%ld\n", 496 TRACE("mah.dwFlags=%ld\n", 497 TRACE("mah.dwTotalFrames=%ld\n", 498 TRACE("mah.dwInitialFrames=%ld\n", 499 TRACE("mah.dwStreams=%ld\n", 500 TRACE("mah.dwSuggestedBufferSize=%ld\n", 501 TRACE("mah.dwWidth=%ld\n", 502 TRACE("mah.dwHeight=%ld\n", 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); 503 504 504 505 mmioAscend(infoPtr->hMMio, &mmckInfo, 0); … … 506 507 mmckList.fccType = mmioFOURCC('s', 't', 'r', 'l'); 507 508 if (mmioDescend(infoPtr->hMMio, &mmckList, &mmckHead, MMIO_FINDLIST) != 0) { 508 509 509 WARN("Can't find 'strl' list\n"); 510 return FALSE; 510 511 } 511 512 512 513 mmckInfo.ckid = mmioFOURCC('s', 't', 'r', 'h'); 513 514 if (mmioDescend(infoPtr->hMMio, &mmckInfo, &mmckList, MMIO_FINDCHUNK) != 0) { 514 515 515 WARN("Can't find 'strh' chunk\n"); 516 return FALSE; 516 517 } 517 518 518 519 mmioRead(infoPtr->hMMio, (LPSTR)&infoPtr->ash, sizeof(infoPtr->ash)); 519 520 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 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 528 TRACE("ash.dwFlags=%ld\n", 529 TRACE("ash.wPriority=%d\n", 530 TRACE("ash.wLanguage=%d\n", 531 TRACE("ash.dwInitialFrames=%ld\n", 532 TRACE("ash.dwScale=%ld\n", 533 TRACE("ash.dwRate=%ld\n", 534 TRACE("ash.dwStart=%ld\n", 535 TRACE("ash.dwLength=%ld\n", 536 TRACE("ash.dwSuggestedBufferSize=%ld\n", 537 TRACE("ash.dwQuality=%ld\n", 538 TRACE("ash.dwSampleSize=%ld\n", 539 TRACE("ash.rcFrame=(%d,%d,%d,%d)\n", infoPtr->ash.rcFrame.top, infoPtr->ash.rcFrame.left,540 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); 541 542 542 543 mmioAscend(infoPtr->hMMio, &mmckInfo, 0); … … 544 545 mmckInfo.ckid = mmioFOURCC('s', 't', 'r', 'f'); 545 546 if (mmioDescend(infoPtr->hMMio, &mmckInfo, &mmckList, MMIO_FINDCHUNK) != 0) { 546 547 547 WARN("Can't find 'strh' chunk\n"); 548 return FALSE; 548 549 } 549 550 550 551 infoPtr->inbih = HeapAlloc(GetProcessHeap(), 0, mmckInfo.cksize); 551 552 if (!infoPtr->inbih) { 552 553 553 WARN("Can't alloc input BIH\n"); 554 return FALSE; 554 555 } 555 556 556 557 mmioRead(infoPtr->hMMio, (LPSTR)infoPtr->inbih, mmckInfo.cksize); 557 558 558 TRACE("bih.biSize=%ld\n", 559 TRACE("bih.biWidth=%ld\n", 560 TRACE("bih.biHeight=%ld\n", 561 TRACE("bih.biPlanes=%d\n", 562 TRACE("bih.biBitCount=%d\n", 563 TRACE("bih.biCompression=%ld\n", 564 TRACE("bih.biSizeImage=%ld\n", 565 TRACE("bih.biXPelsPerMeter=%ld\n", 566 TRACE("bih.biYPelsPerMeter=%ld\n", 567 TRACE("bih.biClrUsed=%ld\n", 568 TRACE("bih.biClrImportant=%ld\n", 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); 569 570 570 571 mmioAscend(infoPtr->hMMio, &mmckInfo, 0); 571 572 572 573 mmioAscend(infoPtr->hMMio, &mmckList, 0); 573 574 574 575 #if 0 575 576 /* 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 577 578 */ 578 579 mmckList.fccType = mmioFOURCC('s', 't', 'r', 'l'); 579 580 if (mmioDescend(infoPtr->hMMio, &mmckList, &mmckHead, MMIO_FINDLIST) == 0) { 580 581 581 WARN("There should be a single 'strl' list\n"); 582 return FALSE; 582 583 } 583 584 #endif … … 589 590 mmckList.fccType = mmioFOURCC('m', 'o', 'v', 'i'); 590 591 if (mmioDescend(infoPtr->hMMio, &mmckList, &ckMainRIFF, MMIO_FINDLIST) != 0) { 591 592 592 WARN("Can't find 'movi' list\n"); 593 return FALSE; 593 594 } 594 595 595 596 /* FIXME: should handle the 'rec ' LIST when present */ 596 597 597 infoPtr->lpIndex = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 598 598 infoPtr->lpIndex = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 599 infoPtr->mah.dwTotalFrames * sizeof(DWORD)); 599 600 if (!infoPtr->lpIndex) { 600 601 601 WARN("Can't alloc index array\n"); 602 return FALSE; 602 603 } 603 604 604 605 numFrame = insize = 0; 605 while (mmioDescend(infoPtr->hMMio, &mmckInfo, &mmckList, 0) == 0 && 606 607 608 609 610 611 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); 612 613 } 613 614 if (numFrame != infoPtr->mah.dwTotalFrames) { 614 615 615 WARN("Found %ld frames (/%ld)\n", numFrame, infoPtr->mah.dwTotalFrames); 616 return FALSE; 616 617 } 617 618 if (insize > infoPtr->ash.dwSuggestedBufferSize) { 618 619 619 WARN("insize=%ld suggestedSize=%ld\n", insize, infoPtr->ash.dwSuggestedBufferSize); 620 infoPtr->ash.dwSuggestedBufferSize = insize; 620 621 } 621 622 622 623 infoPtr->indata = HeapAlloc(GetProcessHeap(), 0, infoPtr->ash.dwSuggestedBufferSize); 623 624 if (!infoPtr->indata) { 624 625 625 WARN("Can't alloc input buffer\n"); 626 return FALSE; 626 627 } 627 628 … … 632 633 static BOOL ANIMATE_GetAviCodec(ANIMATE_INFO *infoPtr) 633 634 { 634 DWORD 635 DWORD outSize; 635 636 636 637 /* check uncompressed AVI */ … … 638 639 (infoPtr->ash.fccHandler == mmioFOURCC('R', 'L', 'E', ' '))) 639 640 { 640 infoPtr->hic = 0; 641 641 infoPtr->hic = 0; 642 return TRUE; 642 643 } 643 644 … … 645 646 infoPtr->hic = ICOpen(ICTYPE_VIDEO, infoPtr->ash.fccHandler, ICMODE_DECOMPRESS); 646 647 if (!infoPtr->hic) { 647 648 649 } 650 651 outSize = ICSendMessage(infoPtr->hic, ICM_DECOMPRESS_GET_FORMAT, 652 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); 653 654 654 655 infoPtr->outbih = HeapAlloc(GetProcessHeap(), 0, outSize); 655 656 if (!infoPtr->outbih) { 656 657 658 } 659 660 if (ICSendMessage(infoPtr->hic, ICM_DECOMPRESS_GET_FORMAT, 661 662 663 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; 664 665 } 665 666 666 667 infoPtr->outdata = HeapAlloc(GetProcessHeap(), 0, infoPtr->outbih->biSizeImage); 667 668 if (!infoPtr->outdata) { 668 669 670 } 671 672 if (ICSendMessage(infoPtr->hic, ICM_DECOMPRESS_BEGIN, 673 674 675 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; 676 677 } 677 678 … … 691 692 692 693 if (!lParam) { 693 694 695 } 696 694 TRACE("Closing avi!\n"); 695 return TRUE; 696 } 697 697 698 if (!hInstance) 698 699 hInstance = GetWindowLongA(hWnd, GWL_HINSTANCE); … … 719 720 #else 720 721 if (HIWORD(lParam)) { 721 722 723 724 725 726 727 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 } 730 731 } else { 731 732 733 734 735 736 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 } 738 739 } 739 740 #endif 740 741 if (!ANIMATE_GetAviInfo(infoPtr)) { 741 742 743 742 WARN("Can't get AVI information\n"); 743 ANIMATE_Free(infoPtr); 744 return FALSE; 744 745 } 745 746 746 747 if (!ANIMATE_GetAviCodec(infoPtr)) { 747 748 749 748 WARN("Can't get AVI Codec\n"); 749 ANIMATE_Free(infoPtr); 750 return FALSE; 750 751 } 751 752 752 753 if (!GetWindowLongA(hWnd, GWL_STYLE) & ACS_CENTER) { 753 754 754 SetWindowPos(hWnd, 0, 0, 0, infoPtr->mah.dwWidth, infoPtr->mah.dwHeight, 755 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER); 755 756 } 756 757 757 758 if (GetWindowLongA(hWnd, GWL_STYLE) & ACS_AUTOPLAY) { 758 759 return ANIMATE_Play(hWnd, -1, (LPARAM)MAKELONG(0, infoPtr->mah.dwTotalFrames-1)); 759 760 } 760 761 … … 771 772 /* nothing opened */ 772 773 if (!infoPtr->hMMio) 773 774 return FALSE; 774 775 775 776 ANIMATE_DoStop(infoPtr); … … 780 781 static LRESULT ANIMATE_Create(HWND hWnd, WPARAM wParam, LPARAM lParam) 781 782 { 782 ANIMATE_INFO* 783 ANIMATE_INFO* infoPtr; 783 784 784 785 /* allocate memory for info structure */ … … 789 790 #endif 790 791 if (!infoPtr) { 791 792 792 ERR("could not allocate info memory!\n"); 793 return 0; 793 794 } 794 795 … … 802 803 803 804 InitializeCriticalSection(&infoPtr->cs); 804 805 805 806 return 0; 806 807 } … … 826 827 { 827 828 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); 833 834 } 834 835 … … 842 843 { 843 844 if (GetWindowLongA(hWnd, GWL_STYLE) & ACS_CENTER) { 844 845 InvalidateRect(hWnd, NULL, TRUE); 845 846 } 846 847 return TRUE; … … 851 852 TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n", hWnd, uMsg, wParam, lParam); 852 853 if (!ANIMATE_GetInfoPtr(hWnd) && (uMsg != WM_NCCREATE)) 853 854 return DefWindowProcA(hWnd, uMsg, wParam, lParam); 854 855 switch (uMsg) 855 856 { … … 862 863 #else 863 864 case ACM_OPENA: 864 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 870 871 case ACM_PLAY: 871 872 872 return ANIMATE_Play(hWnd, wParam, lParam); 873 873 874 case ACM_STOP: 874 875 875 return ANIMATE_Stop(hWnd, wParam, lParam); 876 876 877 case WM_NCCREATE: 877 878 879 878 ANIMATE_Create(hWnd, wParam, lParam); 879 return DefWindowProcA(hWnd, uMsg, wParam, lParam); 880 880 881 case WM_NCHITTEST: 881 882 return HTTRANSPARENT; 882 883 883 884 case WM_DESTROY: 884 885 886 885 ANIMATE_Destroy(hWnd, wParam, lParam); 886 return DefWindowProcA(hWnd, uMsg, wParam, lParam); 887 887 888 case WM_ERASEBKGND: 888 889 890 891 /* 889 ANIMATE_EraseBackground(hWnd, wParam, lParam); 890 break; 891 892 /* case WM_STYLECHANGED: FIXME shall we do something ?? */ 892 893 893 894 case WM_TIMER: 894 895 if (GetWindowLongA(hWnd, GWL_STYLE) & ACS_TRANSPARENT) 895 896 { 896 897 ANIMATE_INFO* infoPtr = ANIMATE_GetInfoPtr(hWnd); 897 898 infoPtr->hbrushBG = SendMessageA(GetParent(hWnd),WM_CTLCOLORSTATIC,(HDC)wParam, hWnd); 898 899 } 899 900 900 return ANIMATE_DrawFrame(ANIMATE_GetInfoPtr(hWnd)); 901 901 902 case WM_CLOSE: 902 903 903 ANIMATE_Free(ANIMATE_GetInfoPtr(hWnd)); 904 return TRUE; 904 905 905 906 case WM_PAINT: 906 907 { 907 908 ANIMATE_INFO* infoPtr = ANIMATE_GetInfoPtr(hWnd); 908 909 909 910 /* the animation isn't playing, don't paint */ 910 911 912 913 911 if(!infoPtr->uTimer && !infoPtr->hThread) 912 /* default paint handling */ 913 return DefWindowProcA(hWnd, uMsg, wParam, lParam); 914 914 915 if (GetWindowLongA(hWnd, GWL_STYLE) & ACS_TRANSPARENT) 915 916 infoPtr->hbrushBG = SendMessageA(GetParent(hWnd), WM_CTLCOLORSTATIC, 916 917 917 (HDC)wParam, hWnd); 918 918 919 if (wParam) 919 920 { … … 924 925 else 925 926 { 926 927 927 PAINTSTRUCT ps; 928 HDC hDC = BeginPaint(hWnd, &ps); 928 929 929 930 EnterCriticalSection(&infoPtr->cs); 930 931 ANIMATE_PaintFrame(infoPtr, hDC); 931 932 LeaveCriticalSection(&infoPtr->cs); 932 933 934 935 } 936 933 934 EndPaint(hWnd, &ps); 935 } 936 } 937 break; 937 938 938 939 case WM_SIZE: 939 940 940 ANIMATE_Size(hWnd, wParam, lParam); 941 return DefWindowProcA(hWnd, uMsg, wParam, lParam); 941 942 942 943 default: 943 944 945 944 if (uMsg >= WM_USER) 945 ERR("unknown msg %04x wp=%08x lp=%08lx\n", uMsg, wParam, lParam); 946 946 947 #ifdef __WIN32OS2__ 947 948 return defComCtl32ProcA (hWnd, uMsg, wParam, lParam); 948 949 #else 949 950 return DefWindowProcA(hWnd, uMsg, wParam, lParam); 950 951 #endif 951 952 } … … 966 967 wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1); 967 968 wndClass.lpszClassName = ANIMATE_CLASSA; 968 969 969 970 RegisterClassA(&wndClass); 970 971 } -
trunk/src/comctl32/comboex.c
r6380 r6644 1 /* $Id: comboex.c,v 1.12 2001-09-05 12:04:56 bird Exp $ */ 1 2 /* 2 3 * TODO <------------- … … 4 5 * result in a FIXME: 5 6 * CBES_EX_NOEDITIMAGEINDENT 6 * 7 * 8 * 7 * CBES_EX_PATHWORDBREAKPROC 8 * CBES_EX_NOSIZELIMIT 9 * CBES_EX_CASESENSITIVE 9 10 * 2. None of the following callback items are implemented. Therefor 10 11 * no CBEN_GETDISPINFO notifies are issued. Use in either CBEM_INSERTITEM … … 37 38 * generate message sequence similar to native DLL. 38 39 * 2. Handle case where CBEM_SETITEM is called to display data in EDIT 39 * Control. 40 * Control. 40 41 * 3. Add override for WNDPROC for the EDIT control (reqed for VK_RETURN). 41 42 * 4. Dump input data for things using COMBOBOXEXITEM{A|W}. … … 55 56 * 3. Lock image selected status to focus state of edit control if 56 57 * 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 58 59 * focus for 3 above. 59 60 * 5. The LBN_SELCHANGE is just for documentation purposes. … … 70 71 * 71 72 * 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 73 74 * WM_NOTIFY correctly based on results. 74 75 * 2. Fix memory leaks of text strings in COMBOEX_WM_DELETEITEM. 75 76 * 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. 77 78 * 4. Fix some issues with COMBOEX_DrawItem. 78 79 * … … 150 151 /* 151 152 * 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 154 155 * particular WM_DRAWITEM message is for listbox only items. Any messasges 155 156 * without this flag is then for the Edit control field. 156 157 * 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 158 159 * only version 4.0 applications will have ODS_COMBOBOXEDIT set. 159 160 */ … … 189 190 if (TRACE_ON(comboex)){ 190 191 TRACE("item %p - mask=%08x, pszText=%p, cchTM=%d, iImage=%d\n", 191 192 192 item, item->mask, item->pszText, item->cchTextMax, 193 item->iImage); 193 194 TRACE("item %p - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n", 194 195 item, item->iSelectedImage, item->iOverlay, item->iIndent, item->lParam); 195 196 if ((item->mask & CBEIF_TEXT) && item->pszText) 196 197 197 TRACE("item %p - pszText=%s\n", 198 item, debugstr_w((const WCHAR *)item->pszText)); 198 199 } 199 200 } … … 205 206 if (TRACE_ON(comboex)){ 206 207 TRACE("input - mask=%08x, iItem=%d, pszText=%p, cchTM=%d, iImage=%d\n", 207 208 208 input->mask, input->iItem, input->pszText, input->cchTextMax, 209 input->iImage); 209 210 if ((input->mask & CBEIF_TEXT) && input->pszText) { 210 211 TRACE("input - pszText=<%s>\n", 212 213 else 214 TRACE("input - pszText=<%s>\n", 215 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)); 216 217 } 217 218 TRACE("input - iSelectedImage=%d, iOverlay=%d, iIndent=%d, lParam=%08lx\n", 218 219 input->iSelectedImage, input->iOverlay, input->iIndent, input->lParam); 219 220 } 220 221 } … … 226 227 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 227 228 228 if (infoPtr->hwndCombo) 229 229 if (infoPtr->hwndCombo) 230 return SendMessageA (infoPtr->hwndCombo, uMsg, wParam, lParam); 230 231 231 232 return 0; … … 241 242 hdr->code = code; 242 243 if (infoPtr->NtfUnicode) 243 244 244 return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0, 245 (LPARAM)hdr); 245 246 else 246 247 247 return SendMessageA (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0, 248 (LPARAM)hdr); 248 249 } 249 250 … … 259 260 hdr->hdr.code = code; 260 261 if (infoPtr->NtfUnicode) 261 262 262 return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0, 263 (LPARAM)hdr); 263 264 else { 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 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; 287 288 } 288 289 } … … 299 300 hdr->hdr.code = (infoPtr->NtfUnicode) ? CBEN_ENDEDITW : CBEN_ENDEDITA; 300 301 if (infoPtr->NtfUnicode) 301 302 302 return SendMessageW (GetParent(infoPtr->hwndSelf), WM_NOTIFY, 0, 303 (LPARAM)hdr); 303 304 else { 304 305 306 307 308 309 310 311 312 313 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); 314 315 } 315 316 } … … 340 341 } 341 342 if (cit->mask & CBEIF_IMAGE) 342 343 cit->iImage = item->iImage; 343 344 if (cit->mask & CBEIF_SELECTEDIMAGE) 344 345 cit->iSelectedImage = item->iSelectedImage; 345 346 if (cit->mask & CBEIF_OVERLAY) 346 347 cit->iOverlay = item->iOverlay; 347 348 if (cit->mask & CBEIF_INDENT) 348 349 cit->iIndent = item->iIndent; 349 350 if (cit->mask & CBEIF_LPARAM) 350 351 cit->lParam = item->lParam; 351 352 352 353 } … … 364 365 iinfo.rcImage.left = iinfo.rcImage.right = 0; 365 366 if (infoPtr->himl) { 366 367 367 ImageList_GetImageInfo(infoPtr->himl, 0, &iinfo); 368 xoff = iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP; 368 369 } 369 370 GetClientRect (infoPtr->hwndCombo, &rect); … … 380 381 381 382 TRACE("Combo client (%d,%d)-(%d,%d), setting Edit to (%d,%d)-(%d,%d)\n", 382 383 383 rect.left, rect.top, rect.right, rect.bottom, 384 x, y, x + w, y + h); 384 385 SetWindowPos(infoPtr->hwndEdit, HWND_TOP, 385 386 387 386 x, y, 387 w, h, 388 SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER); 388 389 } 389 390 … … 399 400 cy = mysize.cy + CBE_EXTRA; 400 401 if (infoPtr->himl) { 401 402 403 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); 404 405 } 405 406 SendMessageW (hwnd, CB_SETITEMHEIGHT, (WPARAM) -1, (LPARAM) cy); 406 407 if (infoPtr->hwndCombo) 407 408 SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT, 408 409 (WPARAM) 0, (LPARAM) cy); 409 410 } 410 411 … … 419 420 /* EM_SETSEL32 (0,-1) */ 420 421 if (item->mask & CBEIF_TEXT) { 421 422 423 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 428 429 static CBE_ITEMDATA * 429 430 COMBOEX_FindItem(COMBOEX_INFO *infoPtr, INT index) … … 433 434 434 435 if ((index > infoPtr->nb_items) || (index < -1)) 435 436 return 0; 436 437 if (index == -1) 437 438 return infoPtr->edit; 438 439 item = infoPtr->items; 439 440 i = infoPtr->nb_items - 1; … … 441 442 /* find the item in the list */ 442 443 while (item && (i > index)) { 443 444 444 item = (CBE_ITEMDATA *)item->next; 445 i--; 445 446 } 446 447 if (!item || (i != index)) { 447 448 448 FIXME("COMBOBOXEX item structures broken. Please report!\n"); 449 return 0; 449 450 } 450 451 return item; … … 456 457 { 457 458 if (item->pszText == LPSTR_TEXTCALLBACKW) 458 459 FIXME("Callback not implemented yet for pszText\n"); 459 460 if (item->iImage == I_IMAGECALLBACK) 460 461 FIXME("Callback not implemented yet for iImage\n"); 461 462 if (item->iSelectedImage == I_IMAGECALLBACK) 462 463 FIXME("Callback not implemented yet for iSelectedImage\n"); 463 464 if (item->iOverlay == I_IMAGECALLBACK) 464 465 FIXME("Callback not implemented yet for iOverlay\n"); 465 466 if (item->iIndent == I_INDENTCALLBACK) 466 467 FIXME("Callback not implemented yet for iIndent\n"); 467 468 } 468 469 … … 482 483 /* if item number requested does not exist then return failure */ 483 484 if ((index > infoPtr->nb_items) || (index < 0)) { 484 485 485 ERR("attempt to delete item that does not exist\n"); 486 return CB_ERR; 486 487 } 487 488 488 489 if (!(item = COMBOEX_FindItem(infoPtr, index))) { 489 490 490 ERR("attempt to delete item that was not found!\n"); 491 return CB_ERR; 491 492 } 492 493 … … 515 516 516 517 if ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN) 517 518 return 0; 518 519 519 520 TRACE("-- 0x%x\n", infoPtr->hwndEdit); … … 560 561 /* if item number requested does not exist then return failure */ 561 562 if ((index > infoPtr->nb_items) || (index < -1)) { 562 563 563 ERR("attempt to get item that does not exist\n"); 564 return 0; 564 565 } 565 566 566 567 /* if the item is the edit control and there is no edit control, skip */ 567 if ((index == -1) && 568 if ((index == -1) && 568 569 ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN)) 569 570 return 0; 570 571 571 572 if (!(item = COMBOEX_FindItem(infoPtr, index))) { 572 573 573 ERR("attempt to get item that was not found!\n"); 574 return 0; 574 575 } 575 576 … … 594 595 595 596 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 597 if (len > 0) 598 WideCharToMultiByte (CP_ACP, 0, tmpcit.pszText, -1, 599 cit->pszText, cit->cchTextMax, NULL, NULL); 599 600 600 601 cit->iImage = tmpcit.iImage; … … 613 614 COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwnd); 614 615 615 TRACE("%s hwnd=0x%x\n", 616 616 TRACE("%s hwnd=0x%x\n", 617 infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd); 617 618 618 619 return infoPtr->bUnicode; … … 626 627 627 628 if ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN) 628 629 if ((infoPtr->flags & (WCBE_ACTEDIT | WCBE_EDITCHG)) == 630 631 629 return FALSE; 630 if ((infoPtr->flags & (WCBE_ACTEDIT | WCBE_EDITCHG)) == 631 (WCBE_ACTEDIT | WCBE_EDITCHG)) 632 return TRUE; 632 633 return FALSE; 633 634 } … … 661 662 /* fast path for iItem = -1 */ 662 663 item->next = infoPtr->items; 663 664 infoPtr->items = item; 664 665 } 665 666 else { 666 667 INT i = infoPtr->nb_items-1; 667 668 669 670 671 672 673 674 675 676 677 678 679 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; 680 681 } 681 682 … … 684 685 if (item->mask & CBEIF_TEXT) { 685 686 LPWSTR str; 686 687 INT len; 687 688 688 689 str = cit->pszText; 689 690 if (!str) str = (LPWSTR) L""; 690 691 692 693 694 695 696 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; 697 698 item->cchTextMax = cit->cchTextMax; 698 699 } … … 713 714 COMBOEX_DumpItem (item); 714 715 715 SendMessageW (infoPtr->hwndCombo, CB_INSERTSTRING, 716 716 SendMessageW (infoPtr->hwndCombo, CB_INSERTSTRING, 717 (WPARAM)cit->iItem, (LPARAM)item); 717 718 718 719 COMBOEX_CopyItem (infoPtr, item, &nmcit.ceItem); … … 727 728 COMBOEX_InsertItemA (HWND hwnd, WPARAM wParam, LPARAM lParam) 728 729 { 729 COMBOBOXEXITEMA 730 COMBOBOXEXITEMW 731 LRESULT 730 COMBOBOXEXITEMA *cit = (COMBOBOXEXITEMA *) lParam; 731 COMBOBOXEXITEMW citW; 732 LRESULT ret; 732 733 733 734 memcpy(&citW,cit,sizeof(COMBOBOXEXITEMA)); 734 735 if (cit->mask & CBEIF_TEXT) { 735 736 LPSTR str; 736 737 INT len; 737 738 738 739 str = cit->pszText; 739 740 if (!str) str=""; 740 741 742 743 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 } 745 746 } 746 747 ret = COMBOEX_InsertItemW(hwnd,wParam,(LPARAM)&citW);; 747 748 748 749 if (cit->mask & CBEIF_TEXT) 749 750 COMCTL32_Free(citW.pszText); 750 751 return ret; 751 752 } … … 763 764 764 765 if (lParam & (CBES_EX_NOEDITIMAGEINDENT | 765 766 767 768 766 CBES_EX_PATHWORDBREAKPROC | 767 CBES_EX_NOSIZELIMIT | 768 CBES_EX_CASESENSITIVE)) 769 FIXME("Extended style not implemented %08lx\n", lParam); 769 770 770 771 if ((DWORD)wParam) { 771 772 infoPtr->dwExtStyle = (infoPtr->dwExtStyle & ~(DWORD)wParam) | (DWORD)lParam; 772 773 } 773 774 else 774 775 infoPtr->dwExtStyle = (DWORD)lParam; 775 776 776 777 /* … … 778 779 */ 779 780 if ((infoPtr->dwExtStyle & CBES_EX_NOEDITIMAGE) ^ 780 781 782 783 784 785 786 787 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); 788 789 } 789 790 … … 826 827 /* if item number requested does not exist then return failure */ 827 828 if ((index > infoPtr->nb_items) || (index < -1)) { 828 829 829 ERR("attempt to set item that does not exist yet!\n"); 830 return 0; 830 831 } 831 832 832 833 /* if the item is the edit control and there is no edit control, skip */ 833 if ((index == -1) && 834 if ((index == -1) && 834 835 ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN)) 835 836 return 0; 836 837 837 838 if (!(item = COMBOEX_FindItem(infoPtr, index))) { 838 839 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 */ 843 844 item->mask |= cit->mask; 844 845 if (cit->mask & CBEIF_TEXT) { 845 846 LPWSTR str; 846 847 847 INT len; 848 WCHAR emptystr[1] = {0}; 848 849 849 850 str = cit->pszText; 850 851 if (!str) str=emptystr; 851 852 853 854 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 } 856 857 item->cchTextMax = cit->cchTextMax; 857 858 } … … 873 874 /* if original request was to update edit control, do some fast foot work */ 874 875 if (cit->iItem == -1) { 875 876 876 COMBOEX_SetEditText (infoPtr, item); 877 RedrawWindow (infoPtr->hwndCombo, 0, 0, RDW_ERASE | RDW_INVALIDATE); 877 878 } 878 879 return TRUE; … … 882 883 COMBOEX_SetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam) 883 884 { 884 COMBOBOXEXITEMA 885 COMBOBOXEXITEMW 886 LRESULT 885 COMBOBOXEXITEMA *cit = (COMBOBOXEXITEMA *) lParam; 886 COMBOBOXEXITEMW citW; 887 LRESULT ret; 887 888 888 889 memcpy(&citW,cit,sizeof(COMBOBOXEXITEMA)); 889 890 if (cit->mask & CBEIF_TEXT) { 890 891 LPSTR str; 891 892 INT len; 892 893 893 894 str = cit->pszText; 894 895 if (!str) str=""; 895 896 897 898 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 } 900 901 } 901 902 ret = COMBOEX_SetItemW(hwnd,wParam,(LPARAM)&citW);; 902 903 903 904 if (cit->mask & CBEIF_TEXT) 904 905 COMCTL32_Free(citW.pszText); 905 906 return ret; 906 907 } … … 913 914 BOOL bTemp = infoPtr->bUnicode; 914 915 915 TRACE("to %s hwnd=0x%04x, was %s\n", 916 917 916 TRACE("to %s hwnd=0x%04x, was %s\n", 917 ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd, 918 (bTemp) ? "TRUE" : "FALSE"); 918 919 919 920 infoPtr->bUnicode = (BOOL)wParam; … … 937 938 i = MultiByteToWideChar (CP_ACP, 0, (LPSTR)lParam, -1, NULL, 0); 938 939 if (i > 0) { 939 940 940 desired = (LPWSTR)COMCTL32_Alloc ((i + 1)*sizeof(WCHAR)); 941 MultiByteToWideChar (CP_ACP, 0, (LPSTR)lParam, -1, desired, i); 941 942 } 942 943 … … 945 946 /* now search from after starting loc and wrapping back to start */ 946 947 for(i=start+1; i<count; i++) { 947 item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo, 948 949 TRACE("desired=%s, item=%s\n", 950 951 952 953 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 } 955 956 } 956 957 for(i=0; i<=start; i++) { 957 item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo, 958 959 TRACE("desired=%s, item=%s\n", 960 961 962 963 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 } 965 966 } 966 967 COMCTL32_Free(desired); … … 977 978 LRESULT lret = 0; 978 979 979 item1 = (CBE_ITEMDATA *)COMBOEX_Forward (hwnd, CB_GETITEMDATA, 980 980 item1 = (CBE_ITEMDATA *)COMBOEX_Forward (hwnd, CB_GETITEMDATA, 981 wParam, lParam); 981 982 if ((item1 != NULL) && ((LRESULT)item1 != CB_ERR)) { 982 983 984 985 986 987 988 989 990 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; 991 992 } 992 993 lret = (LRESULT)item1; … … 1005 1006 1006 1007 if (!(item = COMBOEX_FindItem(infoPtr, index))) { 1007 1008 1008 /* FIXME: need to clear selection */ 1009 return CB_ERR; 1009 1010 } 1010 1011 1011 1012 TRACE("selecting item %d text=%s\n", index, (item->pszText) ? 1012 1013 debugstr_w(item->pszText) : "<null>"); 1013 1014 infoPtr->selected = index; 1014 1015 … … 1026 1027 CBE_ITEMDATA *item1, *item2; 1027 1028 1028 item1 = (CBE_ITEMDATA *)COMBOEX_Forward (hwnd, CB_GETITEMDATA, 1029 1029 item1 = (CBE_ITEMDATA *)COMBOEX_Forward (hwnd, CB_GETITEMDATA, 1030 wParam, lParam); 1030 1031 if ((item1 != NULL) && ((LRESULT)item1 != CB_ERR)) { 1031 1032 1033 1034 1035 1036 1037 1038 1039 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; 1040 1041 } 1041 1042 TRACE("non-valid result from combo 0x%08lx\n", (DWORD)item1); … … 1054 1055 /* First, lets forward the message to the normal combo control 1055 1056 just like Windows. */ 1056 if (infoPtr->hwndCombo) 1057 if (infoPtr->hwndCombo) 1057 1058 SendMessageW (infoPtr->hwndCombo, CB_SETITEMHEIGHT, wParam, lParam); 1058 1059 … … 1060 1061 GetWindowRect (hwnd, &cbx_wrect); 1061 1062 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 */ 1063 1064 height = cb_wrect.bottom-cb_wrect.top 1064 1065 + cbx_wrect.bottom-cbx_wrect.top 1065 1066 - (cbx_crect.bottom-cbx_crect.top); 1066 1067 TRACE("EX window=(%d,%d)-(%d,%d), client=(%d,%d)-(%d,%d)\n", 1067 1068 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); 1069 1070 TRACE("CB window=(%d,%d)-(%d,%d), EX setting=(0,0)-(%d,%d)\n", 1070 1071 1071 cb_wrect.left, cb_wrect.top, cb_wrect.right, cb_wrect.bottom, 1072 cbx_wrect.right-cbx_wrect.left, height); 1072 1073 SetWindowPos (hwnd, HWND_TOP, 0, 0, 1073 1074 1075 1074 cbx_wrect.right-cbx_wrect.left, 1075 height, 1076 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE); 1076 1077 1077 1078 return ret; … … 1101 1102 #endif 1102 1103 if (infoPtr == NULL) { 1103 1104 1104 ERR("could not allocate info memory!\n"); 1105 return 0; 1105 1106 } 1106 1107 … … 1115 1116 1116 1117 i = SendMessageA(GetParent (hwnd), 1117 1118 WM_NOTIFYFORMAT, hwnd, NF_QUERY); 1118 1119 if ((i < NFR_ANSI) || (i > NFR_UNICODE)) { 1119 1120 1121 1120 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", 1121 i); 1122 i = NFR_ANSI; 1122 1123 } 1123 1124 infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0; … … 1127 1128 /* create combo box */ 1128 1129 dwComboStyle = GetWindowLongA (hwnd, GWL_STYLE) & 1129 1130 (CBS_SIMPLE|CBS_DROPDOWN|CBS_DROPDOWNLIST|WS_CHILD); 1130 1131 1131 1132 GetWindowRect(hwnd, &wnrc1); 1132 1133 GetClientRect(hwnd, &clrc1); 1133 1134 TRACE("EX window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d)\n", 1134 1135 1135 wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom, 1136 clrc1.left, clrc1.top, clrc1.right, clrc1.bottom); 1136 1137 TRACE("combo style=%08lx, adding style=%08lx\n", dwComboStyle, 1137 1138 WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VSCROLL | 1138 1139 CBS_NOINTEGRALHEIGHT | CBS_DROPDOWNLIST | 1139 1140 WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED); 1140 1141 1141 1142 /* Native version of ComboEx creates the ComboBox with DROPDOWNLIST */ … … 1147 1148 1148 1149 infoPtr->hwndCombo = CreateWindowA ("ComboBox", "", 1149 1150 /* following line added to match native */ 1150 1151 WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VSCROLL | 1151 CBS_NOINTEGRALHEIGHT | CBS_DROPDOWNLIST | 1152 1153 1154 1155 1156 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 /* 1159 1160 * native does the following at this point according to trace: 1160 1161 * GetWindowThreadProcessId(hwndCombo,0) … … 1165 1166 1166 1167 /* 1167 * Setup a property to hold the pointer to the COMBOBOXEX 1168 * Setup a property to hold the pointer to the COMBOBOXEX 1168 1169 * data structure. 1169 1170 */ 1170 1171 test = GetPropA(infoPtr->hwndCombo, (LPCSTR)(LONG)ComboExInfo); 1171 1172 if (!test || ((COMBOEX_INFO *)test != infoPtr)) { 1172 1173 } 1174 infoPtr->prevComboWndProc = (WNDPROC)SetWindowLongA(infoPtr->hwndCombo, 1175 1173 SetPropA(infoPtr->hwndCombo, "CC32SubclassInfo", (LONG)infoPtr); 1174 } 1175 infoPtr->prevComboWndProc = (WNDPROC)SetWindowLongA(infoPtr->hwndCombo, 1176 GWL_WNDPROC, (LONG)COMBOEX_ComboWndProc); 1176 1177 infoPtr->font = SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0); 1177 1178 … … 1182 1183 */ 1183 1184 if ((cs->style & CBS_DROPDOWNLIST) == CBS_DROPDOWN) { 1184 1185 1186 1187 infoPtr->hwndCombo, 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 * Setup a property to hold the pointer to the COMBOBOXEX 1201 1202 1203 1204 1205 1206 1207 infoPtr->prevEditWndProc = (WNDPROC)SetWindowLongA(infoPtr->hwndEdit, 1208 1209 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); 1210 1211 } 1211 1212 else { 1212 1213 1213 infoPtr->hwndEdit = 0; 1214 infoPtr->font = 0; 1214 1215 } 1215 1216 … … 1219 1220 */ 1220 1221 if (!infoPtr->font) { 1221 SystemParametersInfoA (SPI_GETICONTITLELOGFONT, sizeof(mylogfont), 1222 1223 1222 SystemParametersInfoA (SPI_GETICONTITLELOGFONT, sizeof(mylogfont), 1223 &mylogfont, 0); 1224 infoPtr->font = CreateFontIndirectA (&mylogfont); 1224 1225 } 1225 1226 SendMessageW (infoPtr->hwndCombo, WM_SETFONT, (WPARAM)infoPtr->font, 0); 1226 1227 if (infoPtr->hwndEdit) { 1227 1228 1228 SendMessageW (infoPtr->hwndEdit, WM_SETFONT, (WPARAM)infoPtr->font, 0); 1229 SendMessageW (infoPtr->hwndEdit, EM_SETMARGINS, (WPARAM)EC_USEFONTINFO, 0); 1229 1230 } 1230 1231 … … 1237 1238 GetWindowRect(infoPtr->hwndCombo, &cmbwrc); 1238 1239 TRACE("EX window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d) CB wnd=(%d,%d)-(%d,%d)\n", 1239 1240 1241 1242 SetWindowPos(infoPtr->hwndCombo, HWND_TOP, 1243 1244 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); 1245 1246 1246 1247 GetWindowRect(infoPtr->hwndCombo, &cmbwrc); 1247 1248 TRACE("CB window=(%d,%d)-(%d,%d)\n", 1248 1249 SetWindowPos(hwnd, HWND_TOP, 1250 1251 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); 1252 1253 1253 1254 COMBOEX_AdjustEditPos (infoPtr); 1254 1255 1255 1256 /* 1256 * Create an item structure to represent the data in the 1257 * Create an item structure to represent the data in the 1257 1258 * EDIT control. 1258 1259 */ … … 1284 1285 { 1285 1286 case CBN_DROPDOWN: 1286 SendMessageW (GetParent (hwnd), WM_COMMAND, wParam, 1287 1288 1289 * from native trace of first dropdown after typing in URL in IE4 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 * the rest is supposition 1300 1301 1302 1303 1304 1305 1306 1307 item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo, 1308 CB_GETITEMDATA, 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 item = (CBE_ITEMDATA *)SendMessageW (infoPtr->hwndCombo, 1323 CB_GETITEMDATA, 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 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; 1359 1360 1360 1361 case CBN_SELCHANGE: 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 return SendMessageW (GetParent (hwnd), WM_COMMAND, wParam, 1382 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); 1383 1384 1384 1385 case CBN_SELENDOK: 1385 /* 1386 1387 1388 1389 return SendMessageW (GetParent (hwnd), WM_COMMAND, wParam, 1390 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); 1391 1392 1392 1393 case CBN_KILLFOCUS: 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 SendMessageW (GetParent (hwnd), WM_COMMAND, wParam, 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 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; 1423 1424 1424 1425 case CBN_CLOSEUP: 1425 1426 default: 1426 /* 1427 1428 1429 1430 1431 1432 lret = SendMessageW (GetParent (hwnd), WM_COMMAND, wParam, 1433 1434 1435 1436 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; 1437 1438 } 1438 1439 return 0; … … 1450 1451 1451 1452 TRACE("CtlType=%08x, CtlID=%08x, itemID=%08x, hwnd=%x, data=%08lx\n", 1452 1453 dis->CtlType, dis->CtlID, dis->itemID, dis->hwndItem, dis->itemData); 1453 1454 1454 1455 if ((dis->itemID >= infoPtr->nb_items) || (dis->itemID < 0)) return FALSE; … … 1458 1459 1459 1460 if (i == dis->itemID) { 1460 1461 infoPtr->items = infoPtr->items->next; 1461 1462 } 1462 1463 else { 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 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; 1477 1478 } 1478 1479 infoPtr->nb_items--; … … 1482 1483 1483 1484 if (olditem->pszText) 1484 1485 COMCTL32_Free(olditem->pszText); 1485 1486 COMCTL32_Free(olditem); 1486 1487 … … 1510 1511 /* dump the DRAWITEMSTRUCT if tracing "comboex" but not "message" */ 1511 1512 if (!TRACE_ON(message)) { 1512 TRACE("DRAWITEMSTRUCT: CtlType=0x%08x CtlID=0x%08x\n", 1513 1514 TRACE("itemID=0x%08x itemAction=0x%08x itemState=0x%08x\n", 1515 1516 1517 dis->hwndItem, dis->hDC, dis->rcItem.left, 1518 dis->rcItem.top, dis->rcItem.right, dis->rcItem.bottom, 1519 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); 1520 1521 } 1521 1522 … … 1532 1533 /* though the list box or combo box has the focus. */ 1533 1534 if (dis->itemID == 0xffffffff) { 1534 1535 ( (dis->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)) && (dis->itemState & ODS_FOCUS) ) ) { 1536 1537 1538 1539 1540 1541 else if ((dis->CtlType == ODT_COMBOBOX) && 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 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 } 1566 1567 } 1567 1568 1568 1569 /* If draw item is -1 (edit control) setup the item pointer */ 1569 1570 if (dis->itemID == 0xffffffff) { 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 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 } 1595 1596 } 1596 1597 1597 1598 /* if the item pointer is not set, then get the data and locate it */ 1598 1599 if (!item) { 1599 1600 1601 1602 1603 1604 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 } 1606 1607 } 1607 1608 … … 1612 1613 xbase += (item->iIndent * CBE_INDENT); 1613 1614 if (item->mask & CBEIF_IMAGE) { 1614 1615 1615 ImageList_GetImageInfo(infoPtr->himl, item->iImage, &iinfo); 1616 xioff = (iinfo.rcImage.right - iinfo.rcImage.left + CBE_SEP); 1616 1617 } 1617 1618 … … 1619 1620 case ODA_FOCUS: 1620 1621 if (dis->itemState & ODS_SELECTED /*1*/) { 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 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 } 1647 1648 break; 1648 1649 case ODA_SELECT: 1649 1650 case ODA_DRAWENTIRE: 1650 1651 drawimage = -1; 1651 1652 1653 if (item->mask & CBEIF_IMAGE) 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 /* if we have an edit control, the slave the 1667 * selection state to the Edit focus state 1668 1669 1670 1671 1672 1673 1674 1675 1676 /* if we don't have an edit control, use 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 ImageList_Draw (infoPtr->himl, drawimage, dis->hDC, 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 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; 1729 1730 default: 1730 FIXME("unknown action hwnd=%08x, wparam=%08x, lparam=%08lx, action=%d\n", 1731 1731 FIXME("unknown action hwnd=%08x, wparam=%08x, lparam=%08lx, action=%d\n", 1732 hwnd, wParam, lParam, dis->itemAction); 1732 1733 } 1733 1734 … … 1742 1743 1743 1744 if (infoPtr->hwndCombo) 1744 1745 DestroyWindow (infoPtr->hwndCombo); 1745 1746 1746 1747 if (infoPtr->edit) { 1747 1748 1748 COMCTL32_Free (infoPtr->edit); 1749 infoPtr->edit = 0; 1749 1750 } 1750 1751 … … 1752 1753 CBE_ITEMDATA *this, *next; 1753 1754 1754 1755 1756 1757 1758 1759 1760 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 } 1762 1763 } 1763 1764 … … 1785 1786 1786 1787 TRACE("adjusted height hwnd=%08x, height=%d\n", 1787 1788 hwnd, mis->itemHeight); 1788 1789 1789 1790 return 0; … … 1800 1801 newstyle = oldstyle & ~(WS_VSCROLL | WS_HSCROLL); 1801 1802 if (newstyle != oldstyle) { 1802 1803 1804 1803 TRACE("req style %08lx, reseting style %08lx\n", 1804 oldstyle, newstyle); 1805 SetWindowLongA (hwnd, GWL_STYLE, newstyle); 1805 1806 } 1806 1807 return 1; … … 1815 1816 1816 1817 if (lParam == NF_REQUERY) { 1817 1818 1819 1820 1821 1822 1823 1824 1825 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; 1826 1827 } 1827 1828 return (LRESULT)((infoPtr->bUnicode) ? NFR_UNICODE : NFR_ANSI); … … 1837 1838 GetWindowRect (hwnd, &rect); 1838 1839 TRACE("my rect (%d,%d)-(%d,%d)\n", 1839 1840 rect.left, rect.top, rect.right, rect.bottom); 1840 1841 1841 1842 MoveWindow (infoPtr->hwndCombo, 0, 0, rect.right -rect.left, 1842 1843 rect.bottom - rect.top, TRUE); 1843 1844 1844 1845 COMBOEX_AdjustEditPos (infoPtr); … … 1862 1863 /* width is winpos value + border width of comboex */ 1863 1864 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); 1866 1867 1867 1868 TRACE("winpos=(%d,%d %dx%d) flags=0x%08x\n", 1868 1869 wp->x, wp->y, wp->cx, wp->cy, wp->flags); 1869 1870 TRACE("EX window=(%d,%d)-(%d,%d), client=(%d,%d)-(%d,%d)\n", 1870 1871 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); 1872 1873 TRACE("CB window=(%d,%d)-(%d,%d), EX setting=(0,0)-(%d,%d)\n", 1873 1874 1874 cb_wrect.left, cb_wrect.top, cb_wrect.right, cb_wrect.bottom, 1875 width, cb_wrect.bottom-cb_wrect.top); 1875 1876 1876 1877 if (width) SetWindowPos (infoPtr->hwndCombo, HWND_TOP, 0, 0, 1877 1878 1879 1878 width, 1879 cb_wrect.bottom-cb_wrect.top, 1880 SWP_NOACTIVATE); 1880 1881 1881 1882 GetWindowRect (infoPtr->hwndCombo, &cb_wrect); … … 1883 1884 /* height is combo window height plus border width of comboex */ 1884 1885 height = (cb_wrect.bottom-cb_wrect.top) 1885 1886 + (cbx_wrect.bottom-cbx_wrect.top) 1886 1887 - (cbx_crect.bottom-cbx_crect.top); 1887 1888 if (wp->cy < height) wp->cy = height; 1888 1889 if (infoPtr->hwndEdit) { 1889 1890 1890 COMBOEX_AdjustEditPos (infoPtr); 1891 InvalidateRect (infoPtr->hwndCombo, 0, TRUE); 1891 1892 } 1892 1893 … … 1906 1907 LRESULT lret; 1907 1908 1908 TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx, info_ptr=%p\n", 1909 1909 TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx, info_ptr=%p\n", 1910 hwnd, uMsg, wParam, lParam, infoPtr); 1910 1911 1911 1912 if (!infoPtr) return 0; … … 1915 1916 1916 1917 case WM_CHAR: 1917 1918 1919 1920 return CallWindowProcA (infoPtr->prevEditWndProc, 1921 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); 1922 1923 1923 1924 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 */ 1927 1928 hDC = (HDC) wParam; 1928 1929 1929 nbkc = GetSysColor (COLOR_WINDOW); 1930 obkc = SetBkColor (hDC, nbkc); 1930 1931 GetClientRect (hwnd, &rect); 1931 1932 1933 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); 1934 1935 SetBkColor (hDC, obkc); 1935 return CallWindowProcA (infoPtr->prevEditWndProc, 1936 1936 return CallWindowProcA (infoPtr->prevEditWndProc, 1937 hwnd, uMsg, wParam, lParam); 1937 1938 1938 1939 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; 2057 2029 } 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 } 2058 2059 2059 2060 case WM_SETFOCUS: 2060 2061 lret = CallWindowProcA (infoPtr->prevEditWndProc, 2062 2063 2064 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; 2065 2066 2066 2067 case WM_KILLFOCUS: 2067 /* 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 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 */ 2083 2084 2084 2085 default: 2085 return CallWindowProcA (infoPtr->prevEditWndProc, 2086 2086 return CallWindowProcA (infoPtr->prevEditWndProc, 2087 hwnd, uMsg, wParam, lParam); 2087 2088 } 2088 2089 return 0; … … 2102 2103 WCHAR edit_text[260]; 2103 2104 2104 TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx, info_ptr=%p\n", 2105 2105 TRACE("hwnd=%x msg=%x wparam=%x lParam=%lx, info_ptr=%p\n", 2106 hwnd, uMsg, wParam, lParam, infoPtr); 2106 2107 2107 2108 if (!infoPtr) return 0; … … 2111 2112 2112 2113 case CB_FINDSTRINGEXACT: 2113 2114 return COMBOEX_FindStringExact (infoPtr, wParam, lParam); 2114 2115 2115 2116 case WM_DRAWITEM: 2116 2117 2118 2119 2120 2121 2122 return CallWindowProcA (infoPtr->prevComboWndProc, 2123 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); 2124 2125 2125 2126 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 */ 2129 2130 hDC = (HDC) wParam; 2130 2131 2131 nbkc = GetSysColor (COLOR_WINDOW); 2132 obkc = SetBkColor (hDC, nbkc); 2132 2133 GetClientRect (hwnd, &rect); 2133 2134 2135 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); 2136 2137 SetBkColor (hDC, obkc); 2137 return CallWindowProcA (infoPtr->prevComboWndProc, 2138 2138 return CallWindowProcA (infoPtr->prevComboWndProc, 2139 hwnd, uMsg, wParam, lParam); 2139 2140 2140 2141 case WM_SETCURSOR: 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 return CallWindowProcA (infoPtr->prevComboWndProc, 2153 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); 2154 2155 2155 2156 case WM_COMMAND: 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 (WPARAM)focusedhwnd, 0); 2197 2198 2199 2200 /* 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 /* 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 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 */ 2306 2307 default: 2307 return CallWindowProcA (infoPtr->prevComboWndProc, 2308 2308 return CallWindowProcA (infoPtr->prevComboWndProc, 2309 hwnd, uMsg, wParam, lParam); 2309 2310 } 2310 2311 return 0; … … 2320 2321 2321 2322 if (!COMBOEX_GetInfoPtr (hwnd)) { 2322 2323 2324 2325 2323 if (uMsg == WM_CREATE) 2324 return COMBOEX_Create (hwnd, wParam, lParam); 2325 if (uMsg == WM_NCCREATE) 2326 COMBOEX_NCCreate (hwnd, wParam, lParam); 2326 2327 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 2327 2328 } … … 2330 2331 { 2331 2332 case CBEM_DELETEITEM: /* maps to CB_DELETESTRING */ 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 case CBEM_SETEXSTYLE:/* FIXME: obsoleted, should be the same as: */2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 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); 2379 2380 2380 2381 2381 2382 /* Combo messages we are not sure if we need to process or just forward */ 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 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); 2395 2396 2396 2397 /* Combo messages OK to just forward to the regular COMBO */ 2397 case CB_GETCOUNT: 2398 2399 2398 case CB_GETCOUNT: 2399 case CB_GETCURSEL: 2400 case CB_GETDROPPEDSTATE: 2400 2401 case CB_SETDROPPEDWIDTH: 2401 2402 case CB_SETEXTENDEDUI: 2402 2403 case CB_SHOWDROPDOWN: 2403 2404 return COMBOEX_Forward (hwnd, uMsg, wParam, lParam); 2404 2405 2405 2406 /* Combo messages we need to process specially */ 2406 2407 case CB_FINDSTRINGEXACT: 2407 return COMBOEX_FindStringExact (COMBOEX_GetInfoPtr (hwnd), 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 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); 2421 2422 2422 2423 2423 2424 2424 2425 /* Window messages passed to parent */ 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 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); 2435 2436 2436 2437 2437 2438 /* Window messages we need to process */ 2438 2439 case WM_DELETEITEM: 2439 2440 return COMBOEX_WM_DeleteItem (hwnd, wParam, lParam); 2440 2441 2441 2442 case WM_DRAWITEM: 2442 2443 return COMBOEX_DrawItem (hwnd, wParam, lParam); 2443 2444 2444 2445 2445 case WM_DESTROY: 2446 return COMBOEX_Destroy (hwnd, wParam, lParam); 2446 2447 2447 2448 case WM_MEASUREITEM: … … 2449 2450 2450 2451 case WM_NOTIFYFORMAT: 2451 2452 2453 2454 2452 return COMBOEX_NotifyFormat (hwnd, wParam, lParam); 2453 2454 case WM_SIZE: 2455 return COMBOEX_Size (hwnd, wParam, lParam); 2455 2456 2456 2457 case WM_WINDOWPOSCHANGING: 2457 2458 2459 2460 2461 2462 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); 2463 2464 #ifdef __WIN32OS2__ 2464 2465 return defComCtl32ProcA (hwnd, uMsg, wParam, lParam); 2465 2466 #else 2466 2467 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 2467 2468 #endif 2468 2469 } … … 2484 2485 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); 2485 2486 wndClass.lpszClassName = WC_COMBOBOXEXA; 2486 2487 2487 2488 RegisterClassA (&wndClass); 2488 2489 -
trunk/src/comctl32/comctl32.c
r5416 r6644 1 /* 1 /* $Id: comctl32.c,v 1.18 2001-09-05 12:04:56 bird Exp $ */ 2 /* 2 3 * Common controls functions 3 4 * … … 99 100 100 101 switch (fdwReason) { 101 102 case DLL_PROCESS_ATTACH: 102 103 COMCTL32_hModule = (HMODULE)hinstDLL; 103 104 … … 130 131 break; 131 132 132 133 case DLL_PROCESS_DETACH: 133 134 /* unregister all common control classes */ 134 135 ANIMATE_Unregister (); … … 204 205 VOID WINAPI 205 206 MenuHelp (UINT uMsg, WPARAM wParam, LPARAM lParam, HMENU hMainMenu, 206 207 HINSTANCE hInst, HWND hwndStatus, LPUINT lpwIDs) 207 208 { 208 209 UINT uMenuID = 0; 209 210 210 211 if (!IsWindow (hwndStatus)) 211 212 return; 212 213 213 214 switch (uMsg) { 214 215 216 215 case WM_MENUSELECT: 216 TRACE("WM_MENUSELECT wParam=0x%X lParam=0x%lX\n", 217 wParam, lParam); 217 218 218 219 if ((HIWORD(wParam) == 0xFFFF) && (lParam == 0)) { 219 220 /* menu was closed */ 220 221 TRACE("menu was closed!\n"); 221 222 SendMessageA (hwndStatus, SB_SIMPLE, FALSE, 0); 222 223 } 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 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; 243 244 244 245 case WM_COMMAND : 245 246 247 248 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 249 250 * any FIXME for WM_COMMAND 250 251 */ 251 252 253 254 255 256 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] 263 264 * 264 265 * Shows or hides controls and updates the corresponding menu item. … … 297 298 298 299 if (lpInfo == NULL) 299 300 return FALSE; 300 301 301 302 if (!(lpInfo[0]) || !(lpInfo[1])) 302 303 return FALSE; 303 304 304 305 /* search for control */ 305 306 lpMenuId = &lpInfo[2]; 306 307 while (*lpMenuId != uFlags) 307 308 lpMenuId += 2; 308 309 309 310 if (GetMenuState (lpInfo[1], uFlags, MF_BYCOMMAND) & MFS_CHECKED) { 310 311 312 313 314 315 316 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); 317 318 } 318 319 else { 319 320 321 322 323 324 325 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); 326 327 } 327 328 … … 357 358 358 359 TRACE("(0x%08lx 0x%08lx 0x%08lx)\n", 359 360 (DWORD)hwnd, (DWORD)lpRect, (DWORD)lpInfo); 360 361 361 362 GetClientRect (hwnd, lpRect); … … 363 364 364 365 do { 365 366 367 368 369 370 371 372 373 374 375 376 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++; 377 378 } while (*lpRun); 378 379 } … … 416 417 r.left += 3; 417 418 DrawTextA (hdc, text, lstrlenA(text), 418 &r, DT_LEFT|DT_VCENTER|DT_SINGLELINE); 419 &r, DT_LEFT|DT_VCENTER|DT_SINGLELINE); 419 420 if (oldbkmode != TRANSPARENT) 420 421 SetBkMode(hdc, oldbkmode); 421 422 } 422 423 } … … 466 467 CreateStatusWindowA (INT style, LPCSTR text, HWND parent, UINT wid) 467 468 { 468 return CreateWindowA(STATUSCLASSNAMEA, text, style, 469 470 CW_USEDEFAULT, CW_USEDEFAULT, 471 469 return CreateWindowA(STATUSCLASSNAMEA, text, style, 470 CW_USEDEFAULT, CW_USEDEFAULT, 471 CW_USEDEFAULT, CW_USEDEFAULT, 472 parent, wid, 0, 0); 472 473 } 473 474 … … 491 492 { 492 493 return CreateWindowW(STATUSCLASSNAMEW, text, style, 493 494 495 494 CW_USEDEFAULT, CW_USEDEFAULT, 495 CW_USEDEFAULT, CW_USEDEFAULT, 496 parent, wid, 0, 0); 496 497 } 497 498 … … 521 522 HWND WINAPI 522 523 CreateUpDownControl (DWORD style, INT x, INT y, INT cx, INT cy, 523 524 524 HWND parent, INT id, HINSTANCE inst, 525 HWND buddy, INT maxVal, INT minVal, INT curVal) 525 526 { 526 527 HWND hUD = 527 528 528 CreateWindowA (UPDOWN_CLASSA, 0, style, x, y, cx, cy, 529 parent, id, inst, 0); 529 530 if (hUD) { 530 531 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)); 533 534 } 534 535 … … 584 585 585 586 if (!lpInitCtrls) 586 587 return FALSE; 587 588 if (lpInitCtrls->dwSize != sizeof(INITCOMMONCONTROLSEX)) 588 589 return FALSE; 589 590 590 591 TRACE("(0x%08lx)\n", lpInitCtrls->dwICC); 591 592 592 593 for (cCount = 0; cCount < 32; cCount++) { 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 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 } 639 640 } 640 641 … … 681 682 hwndTB = 682 683 CreateWindowExA (0, TOOLBARCLASSNAMEA, "", style|WS_CHILD, 0, 0, 0, 0, 683 684 hwnd, (HMENU)wID, 0, NULL); 684 685 if(hwndTB) { 685 686 TBADDBITMAP tbab; 686 687 687 688 SendMessageA (hwndTB, TB_BUTTONSTRUCTSIZE, 688 689 (WPARAM)uStructSize, 0); 689 690 690 691 /* set bitmap and button size */ … … 705 706 706 707 707 708 709 710 711 712 713 714 715 716 717 718 719 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); 720 721 } 721 722 … … 741 742 HBITMAP WINAPI 742 743 CreateMappedBitmap (HINSTANCE hInstance, INT idBitmap, UINT wFlags, 743 744 LPCOLORMAP lpColorMap, INT iNumMaps) 744 745 { 745 746 HGLOBAL hglb; … … 754 755 COLORREF cRef; 755 756 COLORMAP internalColorMap[4] = 756 757 {{0x000000, 0}, {0x808080, 0}, {0xC0C0C0, 0}, {0xFFFFFF, 0}}; 757 758 758 759 /* initialize pointer to colortable and default color table */ 759 760 if (lpColorMap) { 760 761 761 iMaps = iNumMaps; 762 sysColorMap = lpColorMap; 762 763 } 763 764 else { 764 765 766 767 768 769 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; 770 771 } 771 772 772 773 hRsrc = FindResourceA (hInstance, (LPSTR)idBitmap, RT_BITMAPA); 773 774 if (hRsrc == 0) 774 775 return 0; 775 776 hglb = LoadResource (hInstance, hRsrc); 776 777 if (hglb == 0) 777 778 return 0; 778 779 lpBitmap = (LPBITMAPINFOHEADER)LockResource (hglb); 779 780 if (lpBitmap == NULL) 780 781 return 0; 781 782 782 783 nColorTableSize = (1 << lpBitmap->biBitCount); … … 784 785 lpBitmapInfo = (LPBITMAPINFOHEADER)GlobalAlloc (GMEM_FIXED, nSize); 785 786 if (lpBitmapInfo == NULL) 786 787 return 0; 787 788 RtlMoveMemory (lpBitmapInfo, lpBitmap, nSize); 788 789 … … 790 791 791 792 for (iColor = 0; iColor < nColorTableSize; iColor++) { 792 793 for (i = 0; i < iMaps; i++) { 793 794 cRef = RGB(pColorTable[iColor].rgbRed, 794 795 pColorTable[iColor].rgbGreen, 795 796 pColorTable[iColor].rgbBlue); 796 797 if ( cRef == sysColorMap[i].from) { 797 798 #if 0 798 799 800 801 802 799 if (wFlags & CBS_MASKED) { 800 if (sysColorMap[i].to != COLOR_BTNTEXT) 801 pColorTable[iColor] = RGB(255, 255, 255); 802 } 803 else 803 804 #endif 804 805 pColorTable[iColor].rgbBlue = GetBValue(sysColorMap[i].to); 805 806 pColorTable[iColor].rgbGreen = GetGValue(sysColorMap[i].to); 806 807 pColorTable[iColor].rgbRed = GetRValue(sysColorMap[i].to); 807 808 809 808 break; 809 } 810 } 810 811 } 811 812 nWidth = (INT)lpBitmapInfo->biWidth; … … 814 815 hbm = CreateCompatibleBitmap (hdcScreen, nWidth, nHeight); 815 816 if (hbm) { 816 817 818 819 820 821 822 823 824 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); 825 826 } 826 827 ReleaseDC ((HWND)0, hdcScreen); … … 855 856 HWND WINAPI 856 857 CreateToolbar (HWND hwnd, DWORD style, UINT wID, INT nBitmaps, 857 858 858 HINSTANCE hBMInst, UINT wBMID, 859 LPCOLDTBBUTTON lpButtons,INT iNumButtons) 859 860 { 860 861 return CreateToolbarEx (hwnd, style | CCS_NODIVIDER, wID, nBitmaps, 861 862 862 hBMInst, wBMID, (LPCTBBUTTON)lpButtons, 863 iNumButtons, 0, 0, 0, 0, sizeof (OLDTBBUTTON)); 863 864 } 864 865 … … 885 886 if (pdvi->cbSize != sizeof(DLLVERSIONINFO)) { 886 887 WARN("wrong DLLVERSIONINFO size from app"); 887 888 return E_INVALIDARG; 888 889 } 889 890 … … 894 895 895 896 TRACE("%lu.%lu.%lu.%lu\n", 896 897 897 pdvi->dwMajorVersion, pdvi->dwMinorVersion, 898 pdvi->dwBuildNumber, pdvi->dwPlatformID); 898 899 899 900 return S_OK; … … 901 902 902 903 /*********************************************************************** 903 * 904 * DllInstall (COMCTL32.@) 904 905 */ 905 906 HRESULT WINAPI COMCTL32_DllInstall(BOOL bInstall, LPCWSTR cmdline) 906 907 { 907 FIXME("(%s, %s): stub\n", bInstall?"TRUE":"FALSE", 908 908 FIXME("(%s, %s): stub\n", bInstall?"TRUE":"FALSE", 909 debugstr_w(cmdline)); 909 910 910 911 return S_OK; … … 916 917 POINT pos; /* center of hover rectangle */ 917 918 INT iHoverTime; /* elapsed time the cursor has been inside of the hover rect */ 918 } _TRACKINGLIST; 919 } _TRACKINGLIST; 919 920 920 921 static _TRACKINGLIST TrackingList[10]; … … 955 956 if(TrackingList[i].tme.dwFlags & TME_HOVER) { 956 957 /* add the timer interval to the hovering time */ 957 TrackingList[i].iHoverTime+=iTimerInterval; 958 958 TrackingList[i].iHoverTime+=iTimerInterval; 959 959 960 /* has the cursor moved outside the rectangle centered around pos? */ 960 961 if((abs(pos.x - TrackingList[i].pos.x) > (hoverwidth / 2.0)) … … 985 986 } 986 987 } 987 988 988 989 /* stop the timer if the tracking list is empty */ 989 990 if(iTrackMax == 0) { … … 1036 1037 1037 1038 flags = ptme->dwFlags; 1038 1039 1039 1040 /* if HOVER_DEFAULT was specified replace this with the systems current value */ 1040 1041 if(ptme->dwHoverTime == HOVER_DEFAULT) … … 1042 1043 1043 1044 GetCursorPos(&pos); 1044 hwnd = WindowFromPoint(pos); 1045 hwnd = WindowFromPoint(pos); 1045 1046 1046 1047 if ( flags & TME_CANCEL ) { … … 1048 1049 cancel = 1; 1049 1050 } 1050 1051 1051 1052 if ( flags & TME_HOVER ) { 1052 1053 flags &= ~ TME_HOVER; 1053 1054 hover = 1; 1054 1055 } 1055 1056 1056 1057 if ( flags & TME_LEAVE ) { 1057 1058 flags &= ~ TME_LEAVE; … … 1075 1076 else 1076 1077 ptme->dwFlags = 0; 1077 1078 1078 1079 return TRUE; /* return here, TME_QUERY is retrieving information */ 1079 1080 } … … 1098 1099 { 1099 1100 TrackingList[i] = TrackingList[--iTrackMax]; 1100 1101 1101 1102 if(iTrackMax == 0) { 1102 1103 KillTimer(0, timer); … … 1119 1120 TrackingList[i].tme.dwHoverTime = ptme->dwHoverTime; 1120 1121 } 1121 1122 1122 1123 if(leave) 1123 1124 TrackingList[i].tme.dwFlags |= TME_LEAVE; 1124 1125 1125 1126 /* reset iHoverTime as per winapi specs */ 1126 TrackingList[i].iHoverTime = 0; 1127 1127 TrackingList[i].iHoverTime = 0; 1128 1128 1129 return TRUE; 1129 1130 } 1130 } 1131 } 1131 1132 1132 1133 /* if the tracking list is full return FALSE */ … … 1198 1199 1199 1200 hwndToolTip = CreateWindowExA(0, TOOLTIPS_CLASSA, NULL, 0, 1200 1201 1202 1201 CW_USEDEFAULT, CW_USEDEFAULT, 1202 CW_USEDEFAULT, CW_USEDEFAULT, hwndOwner, 1203 0, 0, 0); 1203 1204 1204 1205 /* Send NM_TOOLTIPSCREATED notification */ 1205 1206 if (hwndToolTip) 1206 1207 { 1207 1208 NMTOOLTIPSCREATED nmttc; 1208 1209 /* true owner can be different if hwndOwner is a child window */ 1209 1210 HWND hwndTrueOwner = GetWindow(hwndToolTip, GW_OWNER); 1210 1211 nmttc.hdr.hwndFrom = hwndTrueOwner; 1211 1212 nmttc.hdr.idFrom = GetWindowLongA(hwndTrueOwner, GWL_ID); 1212 1213 1213 nmttc.hdr.code = NM_TOOLTIPSCREATED; 1214 nmttc.hwndToolTips = hwndToolTip; 1214 1215 1215 1216 SendMessageA(GetParent(hwndTrueOwner), WM_NOTIFY, 1216 1217 (WPARAM)GetWindowLongA(hwndTrueOwner, GWL_ID), 1217 1218 (LPARAM)&nmttc); 1218 1219 } 1219 1220 -
trunk/src/comctl32/comctl32undoc.c
r6380 r6644 1 /* $Id: comctl32undoc.c,v 1.22 2001-09-05 12:04:57 bird Exp $ */ 1 2 /* 2 3 * Undocumented functions from COMCTL32.DLL … … 98 99 99 100 FIXME ("phDpa=%p loadProc=%p pStream=%p lParam=%lx\n", 100 101 phDpa, loadProc, pStream, lParam); 101 102 102 103 if (!phDpa || !loadProc || !pStream) 103 104 return E_INVALIDARG; 104 105 105 106 *phDpa = (HDPA)NULL; … … 110 111 errCode = IStream_Seek (pStream, position, STREAM_SEEK_CUR, &newPosition); 111 112 if (errCode != S_OK) 112 113 return errCode; 113 114 114 115 errCode = IStream_Read (pStream, &streamData, sizeof(STREAMDATA), &ulRead); 115 116 if (errCode != S_OK) 116 117 return errCode; 117 118 118 119 FIXME ("dwSize=%lu dwData2=%lu dwItems=%lu\n", 119 120 streamData.dwSize, streamData.dwData2, streamData.dwItems); 120 121 121 122 if (lParam < sizeof(STREAMDATA) || 122 123 124 123 streamData.dwSize < sizeof(STREAMDATA) || 124 streamData.dwData2 < 1) { 125 errCode = E_FAIL; 125 126 } 126 127 … … 128 129 hDpa = DPA_Create (streamData.dwItems); 129 130 if (!hDpa) 130 131 return E_OUTOFMEMORY; 131 132 132 133 if (!DPA_Grow (hDpa, streamData.dwItems)) 133 134 return E_OUTOFMEMORY; 134 135 135 136 /* load data from the stream into the dpa */ … … 137 138 for (loadData.nCount = 0; loadData.nCount < streamData.dwItems; loadData.nCount++) { 138 139 errCode = (loadProc)(&loadData, pStream, lParam); 139 140 141 142 143 144 145 140 if (errCode != S_OK) { 141 errCode = S_FALSE; 142 break; 143 } 144 145 *ptr = loadData.ptr; 146 ptr++; 146 147 } 147 148 … … 177 178 178 179 FIXME ("hDpa=%p loadProc=%p pStream=%p lParam=%lx\n", 179 180 hDpa, loadProc, pStream, lParam); 180 181 181 182 return E_FAIL; … … 200 201 BOOL WINAPI 201 202 DPA_Merge (const HDPA hdpa1, const HDPA hdpa2, DWORD dwFlags, 202 203 PFNDPACOMPARE pfnCompare, PFNDPAMERGE pfnMerge, LPARAM lParam) 203 204 { 204 205 INT nCount; … … 208 209 209 210 TRACE("%p %p %08lx %p %p %08lx)\n", 210 211 hdpa1, hdpa2, dwFlags, pfnCompare, pfnMerge, lParam); 211 212 212 213 if (IsBadWritePtr (hdpa1, sizeof(DPA))) 213 214 return FALSE; 214 215 215 216 if (IsBadWritePtr (hdpa2, sizeof(DPA))) 216 217 return FALSE; 217 218 218 219 if (IsBadCodePtr ((FARPROC)pfnCompare)) 219 220 return FALSE; 220 221 221 222 if (IsBadCodePtr ((FARPROC)pfnMerge)) 222 223 return FALSE; 223 224 224 225 if (dwFlags & DPAM_SORT) { 225 226 227 228 229 230 231 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"); 232 233 } 233 234 234 235 if (hdpa2->nItemCount < 1) 235 236 return TRUE; 236 237 237 238 TRACE("hdpa1->nItemCount=%d hdpa2->nItemCount=%d\n", 238 239 hdpa1->nItemCount, hdpa2->nItemCount); 239 240 240 241 … … 250 251 { 251 252 if (nIndex < 0) break; 252 253 TRACE("compare result=%d, dpa1.cnt=%d, dpa2.cnt=%d\n", 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 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 } 297 298 298 299 } … … 358 359 359 360 if (lpSrc) 360 361 lpDest = HeapReAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, lpSrc, dwSize); 361 362 else 362 363 lpDest = HeapAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, dwSize); 363 364 364 365 TRACE("-- ret=%p\n", lpDest); … … 458 459 HANDLE WINAPI 459 460 CreateMRUListLazyA (LPCREATEMRULIST lpcml, DWORD dwParam2, 460 461 DWORD dwParam3, DWORD dwParam4); 461 462 462 463 … … 490 491 #if 0 491 492 if (!(hmru->dwParam1 & 1001)) { 492 493 494 493 RegSetValueExA (hmru->hKeyMRU, "MRUList", 0, REG_SZ, 494 hmru->lpszMRUString, 495 strlen (hmru->lpszMRUString)); 495 496 } 496 497 … … 506 507 /************************************************************************** 507 508 * AddMRUData [COMCTL32.167] 508 * 509 * 509 510 * Add item to MRU binary list. If item already exists in list then it is 510 511 * simply moved up to the top of the list and not added again. If list is … … 530 531 /************************************************************************** 531 532 * AddMRUStringA [COMCTL32.153] 532 * 533 * 533 534 * Add item to MRU string list. If item already exists in list them it is 534 535 * simply moved up to the top of the list and not added again. If list is … … 572 573 /************************************************************************** 573 574 * FindMRUData [COMCTL32.169] 574 * 575 * 575 576 * Searches binary list for item that matches lpData of length cbData. 576 577 * Returns position in list order 0 -> MRU and if lpRegNum != NULL then value … … 590 591 { 591 592 FIXME("(%08x, %p, %ld, %p) empty stub!\n", 592 593 hList, lpData, cbData, lpRegNum); 593 594 594 595 return 0; … … 597 598 /************************************************************************** 598 599 * FindMRUStringA [COMCTL32.155] 599 * 600 * 600 601 * Searches string list for item that matches lpszString. 601 602 * Returns position in list order 0 -> MRU and if lpRegNum != NULL then value … … 614 615 { 615 616 FIXME("(%08x, %s, %p) empty stub!\n", hList, debugstr_a(lpszString), 616 617 lpRegNum); 617 618 618 619 return 0; … … 640 641 641 642 if (lpcml == NULL) 642 643 return 0; 643 644 644 645 if (lpcml->cbSize < sizeof(CREATEMRULIST)) 645 646 return 0; 646 647 647 648 FIXME("(%lu %lu %lx %lx \"%s\" %p)\n", 648 649 649 lpcml->cbSize, lpcml->nMaxItems, lpcml->dwFlags, 650 (DWORD)lpcml->hKey, lpcml->lpszSubKey, lpcml->lpfnCompare); 650 651 651 652 /* dummy pointer creation */ … … 659 660 /************************************************************************** 660 661 * EnumMRUListA [COMCTL32.154] 661 * 662 * 662 663 * Enumerate item in a list 663 664 * … … 673 674 * of list returns -1. 674 675 * If lpBuffer == NULL or nItemPos is -ve return value is no. of items in 675 * the list. 676 * the list. 676 677 */ 677 678 INT WINAPI EnumMRUListA(HANDLE hList, INT nItemPos, LPVOID lpBuffer, … … 679 680 { 680 681 FIXME("(%08x, %d, %p, %ld): stub\n", hList, nItemPos, lpBuffer, 681 682 nBufferSize); 682 683 return 0; 683 684 } … … 702 703 703 704 if (!lpDest && lpSrc) 704 705 return strlen (lpSrc); 705 706 706 707 if (nMaxLen == 0) 707 708 return 0; 708 709 709 710 if (lpSrc == NULL) { 710 711 711 lpDest[0] = '\0'; 712 return 0; 712 713 } 713 714 714 715 len = strlen (lpSrc); 715 716 if (len >= nMaxLen) 716 717 len = nMaxLen - 1; 717 718 718 719 RtlMoveMemory (lpDest, lpSrc, len); … … 737 738 { 738 739 TRACE("(%p %p)\n", lppDest, lpSrc); 739 740 740 741 if (lpSrc) { 741 742 743 744 745 742 LPSTR ptr = COMCTL32_ReAlloc (*lppDest, strlen (lpSrc) + 1); 743 if (!ptr) 744 return FALSE; 745 strcpy (ptr, lpSrc); 746 *lppDest = ptr; 746 747 } 747 748 else { 748 749 750 751 749 if (*lppDest) { 750 COMCTL32_Free (*lppDest); 751 *lppDest = NULL; 752 } 752 753 } 753 754 … … 775 776 776 777 if (!lpDest && lpSrc) 777 778 return strlenW (lpSrc); 778 779 779 780 if (nMaxLen == 0) 780 781 return 0; 781 782 782 783 if (lpSrc == NULL) { 783 784 784 lpDest[0] = L'\0'; 785 return 0; 785 786 } 786 787 787 788 len = strlenW (lpSrc); 788 789 if (len >= nMaxLen) 789 790 len = nMaxLen - 1; 790 791 791 792 RtlMoveMemory (lpDest, lpSrc, len*sizeof(WCHAR)); … … 810 811 { 811 812 TRACE("(%p %p)\n", lppDest, lpSrc); 812 813 813 814 if (lpSrc) { 814 815 816 817 818 819 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; 820 821 } 821 822 else { 822 823 824 825 823 if (*lppDest) { 824 COMCTL32_Free (*lppDest); 825 *lppDest = NULL; 826 } 826 827 } 827 828 … … 852 853 853 854 if (!lpDest && lpSrc) 854 855 return WideCharToMultiByte(CP_ACP, 0, lpSrc, -1, 0, 0, NULL, NULL); 855 856 856 857 if (nMaxLen == 0) 857 858 return 0; 858 859 859 860 if (lpSrc == NULL) { 860 861 861 lpDest[0] = '\0'; 862 return 0; 862 863 } 863 864 864 865 len = WideCharToMultiByte(CP_ACP, 0, lpSrc, -1, 0, 0, NULL, NULL); 865 866 if (len >= nMaxLen) 866 867 len = nMaxLen - 1; 867 868 868 869 WideCharToMultiByte(CP_ACP, 0, lpSrc, -1, lpDest, len, NULL, NULL); … … 897 898 898 899 if (lpSrc) { 899 900 901 902 903 904 905 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; 906 907 } 907 908 else { 908 909 910 911 909 if (*lppDest) { 910 COMCTL32_Free (*lppDest); 911 *lppDest = NULL; 912 } 912 913 } 913 914 … … 944 945 if (hdsa) 945 946 { 946 947 hdsa->nItemCount = 0; 947 948 hdsa->pData = NULL; 948 949 950 949 hdsa->nMaxCount = 0; 950 hdsa->nItemSize = nSize; 951 hdsa->nGrow = max(1, nGrow); 951 952 } 952 953 … … 972 973 973 974 if (!hdsa) 974 975 return FALSE; 975 976 976 977 if (hdsa->pData && (!COMCTL32_Free (hdsa->pData))) 977 978 return FALSE; 978 979 979 980 return COMCTL32_Free (hdsa); … … 982 983 983 984 /************************************************************************** 984 * DSA_GetItem [COMCTL32.322] 985 * DSA_GetItem [COMCTL32.322] 985 986 * 986 987 * PARAMS … … 1000 1001 1001 1002 TRACE("(%p %d %p)\n", hdsa, nIndex, pDest); 1002 1003 1003 1004 if (!hdsa) 1004 1005 return FALSE; 1005 1006 if ((nIndex < 0) || (nIndex >= hdsa->nItemCount)) 1006 1007 return FALSE; 1007 1008 1008 1009 pSrc = (char *) hdsa->pData + (hdsa->nItemSize * nIndex); … … 1014 1015 1015 1016 /************************************************************************** 1016 * DSA_GetItemPtr [COMCTL32.323] 1017 * DSA_GetItemPtr [COMCTL32.323] 1017 1018 * 1018 1019 * Retrieves a pointer to the specified item. … … 1035 1036 1036 1037 if (!hdsa) 1037 1038 return NULL; 1038 1039 if ((nIndex < 0) || (nIndex >= hdsa->nItemCount)) 1039 1040 return NULL; 1040 1041 1041 1042 pSrc = (char *) hdsa->pData + (hdsa->nItemSize * nIndex); 1042 1043 1043 1044 TRACE("-- ret=%p\n", pSrc); 1044 1045 … … 1048 1049 1049 1050 /************************************************************************** 1050 * DSA_SetItem [COMCTL32.325] 1051 * DSA_SetItem [COMCTL32.325] 1051 1052 * 1052 1053 * Sets the contents of an item in the array. … … 1067 1068 INT nSize, nNewItems; 1068 1069 LPVOID pDest, lpTemp; 1069 1070 1070 1071 TRACE("(%p %d %p)\n", hdsa, nIndex, pSrc); 1071 1072 1072 1073 if ((!hdsa) || nIndex < 0) 1073 1074 1074 return FALSE; 1075 1075 1076 if (hdsa->nItemCount <= nIndex) { 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 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 } 1095 1096 } 1096 1097 … … 1098 1099 pDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex); 1099 1100 TRACE("-- move dest=%p src=%p size=%d\n", 1100 1101 pDest, pSrc, hdsa->nItemSize); 1101 1102 memmove (pDest, pSrc, hdsa->nItemSize); 1102 1103 … … 1106 1107 1107 1108 /************************************************************************** 1108 * DSA_InsertItem [COMCTL32.324] 1109 * DSA_InsertItem [COMCTL32.324] 1109 1110 * 1110 1111 * PARAMS … … 1124 1125 LPVOID lpTemp, lpDest; 1125 1126 LPDWORD p; 1126 1127 1127 1128 TRACE("(%p %d %p)\n", hdsa, nIndex, pSrc); 1128 1129 1129 1130 if ((!hdsa) || nIndex < 0) 1130 1131 return -1; 1131 1132 1132 1133 for (i = 0; i < hdsa->nItemSize; i += 4) { 1133 1134 1135 1136 1137 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 1140 1141 /* when nIndex >= nItemCount then append */ 1141 1142 if (nIndex >= hdsa->nItemCount) 1142 1143 nIndex = hdsa->nItemCount; 1143 1144 1144 1145 /* do we need to resize ? */ 1145 1146 if (hdsa->nItemCount >= hdsa->nMaxCount) { 1146 1147 1148 1149 1150 1151 1152 1153 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; 1155 1156 } 1156 1157 1157 1158 /* do we need to move elements ? */ 1158 1159 if (nIndex < hdsa->nItemCount) { 1159 1160 1161 1162 1163 1164 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); 1165 1166 } 1166 1167 … … 1169 1170 lpDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex); 1170 1171 TRACE("-- move dest=%p src=%p size=%d\n", 1171 1172 lpDest, pSrc, hdsa->nItemSize); 1172 1173 memmove (lpDest, pSrc, hdsa->nItemSize); 1173 1174 … … 1177 1178 1178 1179 /************************************************************************** 1179 * DSA_DeleteItem [COMCTL32.326] 1180 * DSA_DeleteItem [COMCTL32.326] 1180 1181 * 1181 1182 * PARAMS … … 1193 1194 LPVOID lpDest,lpSrc; 1194 1195 INT nSize; 1195 1196 1196 1197 TRACE("(%p %d)\n", hdsa, nIndex); 1197 1198 1198 1199 if (!hdsa) 1199 1200 return -1; 1200 1201 if (nIndex < 0 || nIndex >= hdsa->nItemCount) 1201 1202 return -1; 1202 1203 1203 1204 /* do we need to move ? */ 1204 1205 if (nIndex < hdsa->nItemCount - 1) { 1205 1206 1207 1208 1209 1210 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 1213 1214 hdsa->nItemCount--; 1214 1215 1215 1216 /* free memory ? */ 1216 1217 if ((hdsa->nMaxCount - hdsa->nItemCount) >= hdsa->nGrow) { 1217 1218 1219 1220 1221 1222 1223 1224 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; 1225 1226 } 1226 1227 … … 1247 1248 TRACE("(%p)\n", hdsa); 1248 1249 1249 if (!hdsa) 1250 1250 if (!hdsa) 1251 return FALSE; 1251 1252 if (hdsa->pData && (!COMCTL32_Free (hdsa->pData))) 1252 1253 return FALSE; 1253 1254 1254 1255 hdsa->nItemCount = 0; … … 1285 1286 hdpa = (HDPA)COMCTL32_Alloc (sizeof(DPA)); 1286 1287 if (hdpa) { 1287 1288 1289 1290 1291 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)); 1292 1293 } 1293 1294 … … 1315 1316 1316 1317 if (!hdpa) 1317 1318 return FALSE; 1318 1319 1319 1320 if (hdpa->ptrs && (!HeapFree (hdpa->hHeap, 0, hdpa->ptrs))) 1320 1321 return FALSE; 1321 1322 1322 1323 return HeapFree (hdpa->hHeap, 0, hdpa); … … 1344 1345 1345 1346 if (!hdpa) 1346 1347 return FALSE; 1347 1348 1348 1349 hdpa->nGrow = max(8, nGrow); … … 1379 1380 1380 1381 if (!hdpa) 1381 1382 return NULL; 1382 1383 1383 1384 TRACE("(%p %p)\n", hdpa, hdpaNew); 1384 1385 1385 1386 if (!hdpaNew) { 1386 1387 1388 1389 1390 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; 1391 1392 } 1392 1393 else 1393 1394 hdpaTemp = hdpaNew; 1394 1395 1395 1396 if (hdpaTemp->ptrs) { 1396 1397 1398 1399 1400 1397 /* remove old pointer array */ 1398 HeapFree (hdpaTemp->hHeap, 0, hdpaTemp->ptrs); 1399 hdpaTemp->ptrs = NULL; 1400 hdpaTemp->nItemCount = 0; 1401 hdpaTemp->nMaxCount = 0; 1401 1402 } 1402 1403 1403 1404 /* create a new pointer array */ 1404 1405 nNewItems = hdpaTemp->nGrow * 1405 1406 ((INT)((hdpa->nItemCount - 1) / hdpaTemp->nGrow) + 1); 1406 1407 nSize = nNewItems * sizeof(LPVOID); 1407 1408 hdpaTemp->ptrs = 1408 1409 (LPVOID*)HeapAlloc (hdpaTemp->hHeap, HEAP_ZERO_MEMORY, nSize); 1409 1410 hdpaTemp->nMaxCount = nNewItems; 1410 1411 … … 1412 1413 hdpaTemp->nItemCount = hdpa->nItemCount; 1413 1414 memmove (hdpaTemp->ptrs, hdpa->ptrs, 1414 1415 hdpaTemp->nItemCount * sizeof(LPVOID)); 1415 1416 1416 1417 return hdpaTemp; … … 1438 1439 1439 1440 if (!hdpa) 1440 1441 return NULL; 1441 1442 if (!hdpa->ptrs) { 1442 1443 1443 WARN("no pointer array.\n"); 1444 return NULL; 1444 1445 } 1445 1446 if ((i < 0) || (i >= hdpa->nItemCount)) { 1446 1447 1447 WARN("not enough pointers in array (%d vs %d).\n",i,hdpa->nItemCount); 1448 return NULL; 1448 1449 } 1449 1450 … … 1474 1475 1475 1476 if (!hdpa->ptrs) 1476 1477 return -1; 1477 1478 1478 1479 for (i = 0; i < hdpa->nItemCount; i++) { 1479 1480 1480 if (hdpa->ptrs[i] == p) 1481 return i; 1481 1482 } 1482 1483 … … 1509 1510 1510 1511 if ((!hdpa) || (i < 0)) 1511 1512 return -1; 1512 1513 1513 1514 if (!hdpa->ptrs) { 1514 1515 1516 1517 1518 1519 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; 1520 1521 nIndex = 0; 1521 1522 } 1522 1523 else { 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 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 } 1550 1551 } 1551 1552 … … 1577 1578 { 1578 1579 LPVOID *lpTemp; 1579 1580 1580 1581 TRACE("(%p %d %p)\n", hdpa, i, p); 1581 1582 1582 1583 if ((!hdpa) || i < 0) 1583 1584 1584 return FALSE; 1585 1585 1586 if (hdpa->nItemCount <= i) { 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 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 } 1605 1606 } 1606 1607 … … 1631 1632 LPVOID *lpDest, *lpSrc, lpTemp = NULL; 1632 1633 INT nSize; 1633 1634 1634 1635 TRACE("(%p %d)\n", hdpa, i); 1635 1636 1636 1637 if ((!hdpa) || i < 0 || i >= hdpa->nItemCount) 1637 1638 return NULL; 1638 1639 1639 1640 lpTemp = hdpa->ptrs[i]; … … 1641 1642 /* do we need to move ?*/ 1642 1643 if (i < hdpa->nItemCount - 1) { 1643 1644 1645 1646 1647 1648 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 1651 1652 hdpa->nItemCount --; 1652 1653 1653 1654 /* free memory ?*/ 1654 1655 if ((hdpa->nMaxCount - hdpa->nItemCount) >= hdpa->nGrow) { 1655 1656 1657 1658 1659 1660 1661 1662 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; 1664 1665 } 1665 1666 … … 1686 1687 TRACE("(%p)\n", hdpa); 1687 1688 1688 if (!hdpa) 1689 1689 if (!hdpa) 1690 return FALSE; 1690 1691 1691 1692 if (hdpa->ptrs && (!HeapFree (hdpa->hHeap, 0, hdpa->ptrs))) 1692 1693 return FALSE; 1693 1694 1694 1695 hdpa->nItemCount = 0; 1695 1696 hdpa->nMaxCount = hdpa->nGrow * 2; 1696 1697 hdpa->ptrs = (LPVOID*)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY, 1697 1698 hdpa->nMaxCount * sizeof(LPVOID)); 1698 1699 1699 1700 return TRUE; … … 1719 1720 static VOID 1720 1721 DPA_QuickSort (LPVOID *lpPtrs, INT l, INT r, 1721 1722 PFNDPACOMPARE pfnCompare, LPARAM lParam) 1722 1723 { 1723 1724 INT m; … … 1725 1726 1726 1727 TRACE("l=%i r=%i\n", l, r); 1727 1728 1728 1729 if (l==r) /* one element is always sorted */ 1729 1730 return; 1730 1731 if (r<l) /* oops, got it in the wrong order */ 1731 1732 { 1732 1733 DPA_QuickSort(lpPtrs, r, l, pfnCompare, lParam); 1733 1734 return; 1734 1735 } 1735 1736 m = (l+r)/2; /* divide by two */ 1736 1737 DPA_QuickSort(lpPtrs, l, m, pfnCompare, lParam); … … 1738 1739 1739 1740 /* join the two sides */ 1740 while( (l<=m) && (m<r) ) 1741 while( (l<=m) && (m<r) ) 1741 1742 { 1742 1743 if(pfnCompare(lpPtrs[l],lpPtrs[m+1],lParam)>0) … … 1772 1773 { 1773 1774 if (!hdpa || !pfnCompare) 1774 1775 return FALSE; 1775 1776 1776 1777 TRACE("(%p %p 0x%lx)\n", hdpa, pfnCompare, lParam); 1777 1778 1778 1779 if ((hdpa->nItemCount > 1) && (hdpa->ptrs)) 1779 1780 1780 DPA_QuickSort (hdpa->ptrs, 0, hdpa->nItemCount - 1, 1781 pfnCompare, lParam); 1781 1782 1782 1783 return TRUE; … … 1809 1810 INT WINAPI 1810 1811 DPA_Search (const HDPA hdpa, LPVOID pFind, INT nStart, 1811 1812 PFNDPACOMPARE pfnCompare, LPARAM lParam, UINT uOptions) 1812 1813 { 1813 1814 if (!hdpa || !pfnCompare || !pFind) 1814 1815 return -1; 1815 1816 1816 1817 TRACE("(%p %p %d %p 0x%08lx 0x%08x)\n", 1817 1818 hdpa, pFind, nStart, pfnCompare, lParam, uOptions); 1818 1819 1819 1820 if (uOptions & DPAS_SORTED) { 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 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 } 1851 1852 } 1852 1853 else { 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 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 } 1867 1868 } 1868 1869 … … 1894 1895 1895 1896 if (hHeap) 1896 1897 hdpa = (HDPA)HeapAlloc (hHeap, HEAP_ZERO_MEMORY, sizeof(DPA)); 1897 1898 else 1898 1899 hdpa = (HDPA)COMCTL32_Alloc (sizeof(DPA)); 1899 1900 1900 1901 if (hdpa) { 1901 1902 1903 1904 1905 1906 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)); 1907 1908 } 1908 1909 … … 1940 1941 1941 1942 TRACE("(0x%04x 0x%04x %d %p 0x%08lx)\n", 1942 1943 1943 lpNotify->hwndFrom, lpNotify->hwndTo, uCode, lpHdr, 1944 lpNotify->dwParam5); 1944 1945 1945 1946 if (!lpNotify->hwndTo) 1946 1947 return 0; 1947 1948 1948 1949 if (lpNotify->hwndFrom == -1) { 1949 1950 1950 lpNmh = lpHdr; 1951 idFrom = lpHdr->idFrom; 1951 1952 } 1952 1953 else { 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 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; 1967 1968 } 1968 1969 … … 1987 1988 LRESULT WINAPI 1988 1989 COMCTL32_SendNotify (HWND hwndFrom, HWND hwndTo, 1989 1990 UINT uCode, LPNMHDR lpHdr) 1990 1991 { 1991 1992 NOTIFYDATA notify; 1992 1993 1993 1994 TRACE("(0x%04x 0x%04x %d %p)\n", 1994 1995 hwndFrom, hwndTo, uCode, lpHdr); 1995 1996 1996 1997 notify.hwndFrom = hwndFrom; … … 2020 2021 LRESULT WINAPI 2021 2022 COMCTL32_SendNotifyEx (HWND hwndTo, HWND hwndFrom, UINT uCode, 2022 2023 LPNMHDR lpHdr, DWORD dwParam5) 2023 2024 { 2024 2025 NOTIFYDATA notify; … … 2026 2027 2027 2028 TRACE("(0x%04x 0x%04x %d %p 0x%08lx)\n", 2028 2029 hwndFrom, hwndTo, uCode, lpHdr, dwParam5); 2029 2030 2030 2031 hwndNotify = hwndTo; 2031 2032 if (!hwndTo) { 2032 2033 2034 2035 2036 2033 if (IsWindow (hwndFrom)) { 2034 hwndNotify = GetParent (hwndFrom); 2035 if (!hwndNotify) 2036 return 0; 2037 } 2037 2038 } 2038 2039 … … 2069 2070 2070 2071 if (*lpStr2 == 0) 2071 2072 return ((LPSTR)lpStr1); 2072 2073 len1 = 0; 2073 2074 while (lpStr1[len1] != 0) ++len1; … … 2075 2076 while (lpStr2[len2] != 0) ++len2; 2076 2077 if (len2 == 0) 2077 2078 return ((LPSTR)(lpStr1 + len1)); 2078 2079 first = tolower (*lpStr2); 2079 2080 while (len1 >= len2) { 2080 2081 2082 2083 2084 2085 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); 2086 2087 } 2087 2088 ++lpStr1; --len1; 2088 2089 } 2089 2090 return (NULL); … … 2116 2117 * 2117 2118 * Enumerates all items in a dynamic pointer array. 2118 *2119 * PARAMS2120 * hdpa [I] handle to the dynamic pointer array2121 * enumProc [I]2122 * lParam [I]2123 *2124 * RETURNS2125 * none2126 */2127 2128 VOID WINAPI2129 DPA_EnumCallback (const HDPA hdpa, DPAENUMPROC enumProc, LPARAM lParam)2130 {2131 INT i;2132 2133 TRACE("(%p %p %08lx)\n", hdpa, enumProc, lParam);2134 2135 if (!hdpa)2136 return;2137 if (hdpa->nItemCount <= 0)2138 return;2139 2140 for (i = 0; i < hdpa->nItemCount; i++) {2141 if ((enumProc)(hdpa->ptrs[i], lParam) == 0)2142 return;2143 }2144 2145 return;2146 }2147 2148 2149 /**************************************************************************2150 * DPA_DestroyCallback [COMCTL32.386]2151 *2152 * Enumerates all items in a dynamic pointer array and destroys it.2153 2119 * 2154 2120 * PARAMS … … 2158 2124 * 2159 2125 * RETURNS 2126 * none 2127 */ 2128 2129 VOID WINAPI 2130 DPA_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 2160 2161 * Success: TRUE 2161 2162 * Failure: FALSE … … 2195 2196 2196 2197 if (!hdsa) 2197 2198 return; 2198 2199 if (hdsa->nItemCount <= 0) 2199 2200 return; 2200 2201 2201 2202 for (i = 0; i < hdsa->nItemCount; i++) { 2202 2203 2204 2203 LPVOID lpItem = DSA_GetItemPtr (hdsa, i); 2204 if ((enumProc)(lpItem, lParam) == 0) 2205 return; 2205 2206 } 2206 2207 … … 2301 2302 if (dbcs && lpStart[1] != HIBYTE(wMatch)) continue; 2302 2303 lpGotIt = lpStart; 2303 } 2304 } 2304 2305 return (LPSTR)lpGotIt; 2305 2306 } … … 2355 2356 if( strchrW(lpSet, *(WORD*)lpLoop)) 2356 2357 return (INT)(lpLoop-lpStr); 2357 2358 2358 2359 return (INT)(lpLoop-lpStr); 2359 2360 } … … 2399 2400 2400 2401 if (IsWindow (hwnd) == FALSE) 2401 2402 return FALSE; 2402 2403 2403 2404 if (b == 0) 2404 2405 return FALSE; 2405 2406 2406 2407 -
trunk/src/comctl32/datetime.c
r6470 r6644 1 /* $Id: datetime.c,v 1.18 2001-09-05 12:04:57 bird Exp $ */ 1 2 /* 2 3 * Date and time picker control … … 34 35 COMCTL32_HEADER header; 35 36 #endif 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 int *buflen; 54 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]; 55 56 POINT monthcal_pos; 56 57 } DATETIME_INFO, *LPDATETIME_INFO; … … 61 62 /* this list of defines is closely related to `allowedformatchars' defined 62 63 * in datetime.c; the high nibble indicates the `base type' of the format 63 * specifier. 64 * specifier. 64 65 * Do not change without first reading DATETIME_UseFormat. 65 * 66 * 66 67 */ 67 68 68 #define DT_END_FORMAT 0 69 #define ONEDIGITDAY 70 #define TWODIGITDAY 71 #define THREECHARDAY 69 #define DT_END_FORMAT 0 70 #define ONEDIGITDAY 0x01 71 #define TWODIGITDAY 0x02 72 #define THREECHARDAY 0x03 72 73 #define FULLDAY 0x04 73 74 #define ONEDIGIT12HOUR 0x11 … … 94 95 #define FORMATCALLBACK 0x81 /* -> maximum of 0x80 callbacks possible */ 95 96 #define FORMATCALLMASK 0x80 96 #define DT_STRING 97 #define DT_STRING 0x0100 97 98 98 99 #define DTHT_DATEFIELD 0xff /* for hit-testing */ 99 100 100 101 #define DTHT_NONE 0 101 #define DTHT_CHECKBOX 0x200 102 #define DTHT_CHECKBOX 0x200 /* these should end at '00' , to make */ 102 103 #define DTHT_MCPOPUP 0x300 /* & DTHT_DATEFIELD 0 when DATETIME_KeyDown */ 103 104 #define DTHT_GOTFOCUS 0x400 /* tests for date-fields */ … … 126 127 if (!lParam) return GDT_NONE; 127 128 128 if ((dwStyle & DTS_SHOWNONE) && 129 if ((dwStyle & DTS_SHOWNONE) && 129 130 (SendMessageA (infoPtr->hwndCheckbut, BM_GETCHECK, 0, 0))) 130 131 return GDT_NONE; … … 145 146 if (!lParam) return 0; 146 147 147 if (lParam==GDT_VALID) 148 148 if (lParam==GDT_VALID) 149 MONTHCAL_CopyTime (lprgSysTimeArray, &infoPtr->date); 149 150 if (lParam==GDT_NONE) { 150 151 infoPtr->dateValid=FALSE; 151 152 SendMessageA (infoPtr->hwndCheckbut, BM_SETCHECK, 0, 0); 152 153 } 153 154 return 1; 154 155 } … … 228 229 229 230 230 /* 231 Split up a formattxt in actions. 231 /* 232 Split up a formattxt in actions. 232 233 See ms documentation for the meaning of the letter codes/'specifiers'. 233 234 234 Notes: 235 Notes: 235 236 *'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; 237 238 start of the string is encoded in lower bits of DT_STRING. 238 239 Therefore, 'string' ends finally up as '<show seconds>tring'. … … 241 242 242 243 243 static void 244 static void 244 245 DATETIME_UseFormat (DATETIME_INFO *infoPtr, const char *formattxt) 245 246 { … … 256 257 257 258 for (i=0; i<strlen (formattxt); i++) { 258 259 260 if (allowedformatchars[j]==formattxt[i]) {261 262 263 264 265 266 267 if (infoPtr->fieldspec[*nrFields]>>4!=j) { 268 (*nrFields)++; 269 270 271 272 273 (*nrFields)++; 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 } else 289 290 291 292 293 } 294 295 296 297 298 299 300 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 } 302 303 303 304 } /* for i */ … … 309 310 310 311 311 static LRESULT 312 static LRESULT 312 313 DATETIME_SetFormat (HWND hwnd, WPARAM wParam, LPARAM lParam) 313 314 { … … 318 319 TRACE("%04x %08lx\n",wParam,lParam); 319 320 if (!lParam) { 320 321 322 if (dwStyle & DTS_LONGDATEFORMAT) 323 324 else if (dwStyle & DTS_TIMEFORMAT) 325 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; 326 327 else /* DTS_SHORTDATEFORMAT */ 327 328 329 330 } 328 format_item=LOCALE_SSHORTDATE; 329 GetLocaleInfoA( GetSystemDefaultLCID(), format_item,format_buf,sizeof(format_buf)); 330 DATETIME_UseFormat (infoPtr, format_buf); 331 } 331 332 else 332 333 DATETIME_UseFormat (infoPtr, (char *) lParam); 333 334 334 335 return infoPtr->nrFields; … … 336 337 337 338 338 static LRESULT 339 static LRESULT 339 340 DATETIME_SetFormatW (HWND hwnd, WPARAM wParam, LPARAM lParam) 340 341 … … 342 343 TRACE("%04x %08lx\n",wParam,lParam); 343 344 if (lParam) { 344 345 345 LPSTR buf; 346 int retval; 346 347 int len = WideCharToMultiByte( CP_ACP, 0, (LPWSTR)lParam, -1, NULL, 0, NULL, NULL ); 347 348 348 349 buf = (LPSTR) COMCTL32_Alloc (len); 349 350 WideCharToMultiByte( CP_ACP, 0, (LPWSTR)lParam, -1, buf, len, NULL, NULL ); 350 351 352 353 } 351 retval=DATETIME_SetFormat (hwnd, 0, (LPARAM) buf); 352 COMCTL32_Free (buf); 353 return retval; 354 } 354 355 else 355 356 357 } 358 359 360 static void 356 return DATETIME_SetFormat (hwnd, 0, 0); 357 358 } 359 360 361 static void 361 362 DATETIME_ReturnTxt (DATETIME_INFO *infoPtr, int count, char *result) 362 363 { … … 368 369 TRACE ("%d,%d\n", infoPtr->nrFields, count); 369 370 if ((count>infoPtr->nrFields) || (count<0)) { 370 371 371 WARN ("buffer overrun, have %d want %d\n", infoPtr->nrFields, count); 372 return; 372 373 } 373 374 374 375 if (!infoPtr->fieldspec) return; 375 376 376 377 spec=infoPtr->fieldspec[count]; 377 378 if (spec & DT_STRING) { 378 379 380 381 382 383 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; 384 385 } 385 386 386 387 387 388 switch (spec) { 388 case DT_END_FORMAT: 389 390 391 case ONEDIGITDAY: 392 393 394 case TWODIGITDAY: 395 396 397 case THREECHARDAY: 398 399 400 401 402 403 404 405 406 407 case ONEDIGIT12HOUR: 408 if (date.wHour>12) 409 410 else 411 412 413 case TWODIGIT12HOUR: 414 if (date.wHour>12) 415 416 else 417 418 419 case ONEDIGIT24HOUR: 420 421 422 case TWODIGIT24HOUR: 423 424 425 case ONEDIGITSECOND: 426 427 428 case TWODIGITSECOND: 429 430 431 case ONEDIGITMINUTE: 432 433 434 case TWODIGITMINUTE: 435 436 437 case ONEDIGITMONTH: 438 439 440 case TWODIGITMONTH: 441 442 443 case THREECHARMONTH: 444 445 446 447 448 case FULLMONTH: 449 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, 450 451 #ifdef __WIN32OS2__ 451 452 452 buffer,sizeof(buffer)); 453 strcpy (result,buffer); 453 454 #else 454 455 result,sizeof(result)); 455 456 #endif 456 457 case ONELETTERAMPM: 458 if (date.wHour<12) 459 460 else 461 462 463 case TWOLETTERAMPM: 464 if (date.wHour<12) 465 466 else 467 468 469 case FORMATCALLBACK: 470 471 472 473 case ONEDIGITYEAR: 474 475 476 case TWODIGITYEAR: 477 478 479 case FULLYEAR: 480 481 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; 482 483 } 483 484 485 } 486 487 488 static void 484 485 TRACE ("arg%d=%x->[%s]\n",count,infoPtr->fieldspec[count],result); 486 } 487 488 489 static void 489 490 DATETIME_IncreaseField (DATETIME_INFO *infoPtr, int number) 490 491 { … … 497 498 spec=infoPtr->fieldspec[number]; 498 499 if ((spec & DTHT_DATEFIELD)==0) return; 499 500 500 501 switch (spec) { 501 case ONEDIGITDAY: 502 case TWODIGITDAY: 503 case THREECHARDAY: 504 505 506 507 date->wDay=1; 508 509 case ONEDIGIT12HOUR: 510 case TWODIGIT12HOUR: 511 case ONEDIGIT24HOUR: 512 case TWODIGIT24HOUR: 513 514 515 516 case ONEDIGITSECOND: 517 case TWODIGITSECOND: 518 519 520 521 case ONEDIGITMINUTE: 522 case TWODIGITMINUTE: 523 524 525 526 case ONEDIGITMONTH: 527 case TWODIGITMONTH: 528 case THREECHARMONTH: 529 case FULLMONTH: 530 531 532 if (date->wDay>MONTHCAL_MonthLength(date->wMonth,date->wYear)) 533 534 535 case ONELETTERAMPM: 536 case TWOLETTERAMPM: 537 538 539 540 case FORMATCALLBACK: 541 542 543 case ONEDIGITYEAR: 544 case TWODIGITYEAR: 545 case FULLYEAR: 546 547 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 554 static void 554 555 DATETIME_DecreaseField (DATETIME_INFO *infoPtr, int number) 555 556 { … … 562 563 spec = infoPtr->fieldspec[number]; 563 564 if ((spec & DTHT_DATEFIELD)==0) return; 564 565 565 566 TRACE ("%x\n",spec); 566 567 567 568 switch (spec) { 568 case ONEDIGITDAY: 569 case TWODIGITDAY: 570 case THREECHARDAY: 571 572 573 if (date->wDay<1) 574 575 576 case ONEDIGIT12HOUR: 577 case TWODIGIT12HOUR: 578 case ONEDIGIT24HOUR: 579 case TWODIGIT24HOUR: 580 if (date->wHour) 581 582 583 584 585 case ONEDIGITSECOND: 586 case TWODIGITSECOND: 587 if (date->wHour) 588 589 590 591 592 case ONEDIGITMINUTE: 593 case TWODIGITMINUTE: 594 if (date->wMinute) 595 596 597 598 599 case ONEDIGITMONTH: 600 case TWODIGITMONTH: 601 case THREECHARMONTH: 602 case FULLMONTH: 603 if (date->wMonth>1) 604 605 606 607 if (date->wDay>MONTHCAL_MonthLength(date->wMonth,date->wYear)) 608 609 610 case ONELETTERAMPM: 611 case TWOLETTERAMPM: 612 if (date->wHour<12) 613 614 615 616 617 case FORMATCALLBACK: 618 619 620 case ONEDIGITYEAR: 621 case TWODIGITYEAR: 622 case FULLYEAR: 623 624 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 631 static void 631 632 DATETIME_ResetFieldDown (DATETIME_INFO *infoPtr, int number) 632 633 { … … 639 640 spec = infoPtr->fieldspec[number]; 640 641 if ((spec & DTHT_DATEFIELD)==0) return; 641 642 642 643 643 644 switch (spec) { 644 case ONEDIGITDAY: 645 case TWODIGITDAY: 646 case THREECHARDAY: 647 648 649 650 case ONEDIGIT12HOUR: 651 case TWODIGIT12HOUR: 652 case ONEDIGIT24HOUR: 653 case TWODIGIT24HOUR: 654 case ONELETTERAMPM: 655 case TWOLETTERAMPM: 656 657 658 case ONEDIGITSECOND: 659 case TWODIGITSECOND: 660 661 662 case ONEDIGITMINUTE: 663 case TWODIGITMINUTE: 664 665 666 case ONEDIGITMONTH: 667 case TWODIGITMONTH: 668 case THREECHARMONTH: 669 case FULLMONTH: 670 671 case FORMATCALLBACK: 672 673 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: 676 677 /* FYI: On 9/14/1752 the calender changed and England and the American */ 677 678 /* colonies changed to the Gregorian calender. This change involved */ 678 679 /* having September 14th following September 2nd. So no date algorithms */ 679 680 /* work before that date. */ 680 case FULLYEAR: 681 682 683 684 date->wDay = 14;/* overactive ms-programmers..*/685 686 687 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 694 static void 694 695 DATETIME_ResetFieldUp (DATETIME_INFO *infoPtr, int number) 695 696 { … … 702 703 spec=infoPtr->fieldspec[number]; 703 704 if ((spec & DTHT_DATEFIELD)==0) return; 704 705 705 706 switch (spec) { 706 case ONEDIGITDAY: 707 case TWODIGITDAY: 708 case THREECHARDAY: 709 710 711 712 case ONEDIGIT12HOUR: 713 case TWODIGIT12HOUR: 714 case ONEDIGIT24HOUR: 715 case TWODIGIT24HOUR: 716 case ONELETTERAMPM: 717 case TWOLETTERAMPM: 718 719 720 case ONEDIGITSECOND: 721 case TWODIGITSECOND: 722 723 724 case ONEDIGITMINUTE: 725 case TWODIGITMINUTE: 726 727 728 case ONEDIGITMONTH: 729 case TWODIGITMONTH: 730 case THREECHARMONTH: 731 case FULLMONTH: 732 733 case FORMATCALLBACK: 734 735 736 case ONEDIGITYEAR: 737 case TWODIGITYEAR: 738 case FULLYEAR: 739 740 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 } 742 743 743 744 } … … 758 759 SIZE size; 759 760 COLORREF oldBk, oldTextColor; 760 761 761 762 /* draw control edge */ 762 763 TRACE("\n"); … … 764 765 FillRect(hdc, rcClient, hbr); 765 766 DrawEdge(hdc, rcClient, EDGE_SUNKEN, BF_RECT); 766 DeleteObject(hbr); 767 767 DeleteObject(hbr); 768 768 769 if (infoPtr->dateValid) { 769 770 char txt[80]; … … 798 799 DT_RIGHT | DT_VCENTER | DT_SINGLELINE ); 799 800 SetBkColor (hdc, oldBk); 800 801 SetTextColor (hdc, oldTextColor); 801 802 } 802 803 else … … 832 833 if (PtInRect (&infoPtr->fieldRect[i], pt)) { 833 834 retval = i; 834 TRACE("Hit in date text in field %d\n", i); 835 TRACE("Hit in date text in field %d\n", i); 835 836 break; 836 837 } … … 845 846 DATETIME_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam) 846 847 { 847 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 848 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 848 849 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); 849 850 int old, new; … … 874 875 infoPtr->monthcal_pos.x = infoPtr->rcClient.right - ((infoPtr->calbutton.right - 875 876 infoPtr->calbutton.left) + 145); 876 else 877 else 877 878 infoPtr->monthcal_pos.x = 8; 878 879 … … 888 889 889 890 TRACE ("dt:%x mc:%x mc parent:%x, desktop:%x, mcpp:%x\n", 890 hwnd,infoPtr->hMonthCal, 891 hwnd,infoPtr->hMonthCal, 891 892 GetParent (infoPtr->hMonthCal), 892 893 GetDesktopWindow (), … … 904 905 DATETIME_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam) 905 906 { 906 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 907 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 907 908 908 909 TRACE("\n"); 909 910 910 911 if(infoPtr->bCalDepressed == TRUE) { 911 912 infoPtr->bCalDepressed = FALSE; … … 934 935 DATETIME_ParentNotify (HWND hwnd, WPARAM wParam, LPARAM lParam) 935 936 { 936 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 937 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 937 938 LPNMHDR lpnmh = (LPNMHDR) lParam; 938 939 … … 954 955 955 956 { 956 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 957 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 957 958 LPNMHDR lpnmh = (LPNMHDR) lParam; 958 959 … … 964 965 965 966 966 static LRESULT 967 static LRESULT 967 968 DATETIME_KeyDown (HWND hwnd, WPARAM wParam, LPARAM lParam) 968 969 { … … 978 979 979 980 if (infoPtr->select & FORMATCALLMASK) { 980 981 FIXME ("Callbacks not implemented yet\n"); 981 982 } 982 983 983 984 switch (wParam) { 984 985 case VK_UP:986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 case VK_LEFT: 1003 1004 1005 1006 1007 } else 1008 1009 1010 1011 1012 case VK_RIGHT: 1013 1014 1015 1016 1017 1018 1019 1020 1021 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 } 1023 1024 1024 1025 InvalidateRect(hwnd, NULL, FALSE); … … 1031 1032 DATETIME_KillFocus (HWND hwnd, WPARAM wParam, LPARAM lParam) 1032 1033 { 1033 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 1034 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 1034 1035 1035 1036 TRACE ("\n"); 1036 1037 1037 1038 if (infoPtr->haveFocus) { 1038 1039 1039 DATETIME_SendSimpleNotify (hwnd, NM_KILLFOCUS); 1040 infoPtr->haveFocus = 0; 1040 1041 } 1041 1042 … … 1049 1050 DATETIME_SetFocus (HWND hwnd, WPARAM wParam, LPARAM lParam) 1050 1051 { 1051 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 1052 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 1052 1053 1053 1054 TRACE ("\n"); 1054 1055 1055 1056 if (infoPtr->haveFocus==0) { 1056 DATETIME_SendSimpleNotify (hwnd, NM_SETFOCUS); 1057 1057 DATETIME_SendSimpleNotify (hwnd, NM_SETFOCUS); 1058 infoPtr->haveFocus = DTHT_GOTFOCUS; 1058 1059 } 1059 1060 … … 1068 1069 1069 1070 { 1070 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 1071 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 1071 1072 NMDATETIMECHANGE dtdtc; 1072 1073 … … 1136 1137 infoPtr->monthcal_pos.x = infoPtr->rcClient.right - ((infoPtr->calbutton.right - 1137 1138 infoPtr->calbutton.left) + 145); 1138 else 1139 else 1139 1140 infoPtr->monthcal_pos.x = 8; 1140 1141 … … 1172 1173 1173 1174 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, 1176 1177 2,2,13,13, 1177 hwnd, 1178 hwnd, 1178 1179 0, GetWindowLongA (hwnd, GWL_HINSTANCE), 0); 1179 1180 SendMessageA (infoPtr->hwndCheckbut, BM_SETCHECK, 1, 0); … … 1196 1197 1197 1198 /* create the monthcal control */ 1198 infoPtr->hMonthCal = CreateWindowExA (0,"SysMonthCal32", 0, 1199 1200 1201 GetParent(hwnd), 1202 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); 1203 1204 1204 1205 /* initialize info structure */ … … 1214 1215 { 1215 1216 DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); 1216 1217 1217 1218 TRACE("\n"); 1218 1219 COMCTL32_Free (infoPtr); … … 1227 1228 1228 1229 if (!DATETIME_GetInfoPtr(hwnd) && (uMsg != WM_CREATE)) 1229 1230 1230 return DefWindowProcA( hwnd, uMsg, wParam, lParam ); 1231 1231 1232 switch (uMsg) 1232 1233 { … … 1236 1237 1237 1238 case DTM_SETSYSTEMTIME: 1238 1239 return DATETIME_SetSystemTime (hwnd, wParam, lParam); 1239 1240 1240 1241 case DTM_GETRANGE: … … 1266 1267 1267 1268 case WM_PARENTNOTIFY: 1268 1269 return DATETIME_ParentNotify (hwnd, wParam, lParam); 1269 1270 1270 1271 case WM_NOTIFY: 1271 1272 return DATETIME_Notify (hwnd, wParam, lParam); 1272 1273 1273 1274 case WM_GETDLGCODE: … … 1296 1297 1297 1298 case WM_CREATE: 1298 1299 return DATETIME_Create (hwnd, wParam, lParam); 1299 1300 1300 1301 case WM_DESTROY: 1301 1302 return DATETIME_Destroy (hwnd, wParam, lParam); 1302 1303 1303 1304 default: 1304 1305 1306 1305 if (uMsg >= WM_USER) 1306 ERR("unknown msg %04x wp=%08x lp=%08lx\n", 1307 uMsg, wParam, lParam); 1307 1308 #ifdef __WIN32OS2__ 1308 1309 return defComCtl32ProcA (hwnd, uMsg, wParam, lParam); 1309 1310 #else 1310 1311 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 1311 1312 #endif 1312 1313 } … … 1329 1330 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); 1330 1331 wndClass.lpszClassName = DATETIMEPICK_CLASSA; 1331 1332 1332 1333 RegisterClassA (&wndClass); 1333 1334 } -
trunk/src/comctl32/flatsb.c
r5416 r6644 1 /* $Id: flatsb.c,v 1.10 2001-09-05 12:04:58 bird Exp $ */ 1 2 /* 2 3 * Flat Scrollbar control … … 39 40 40 41 /*********************************************************************** 41 * 42 * 43 * 42 * InitializeFlatSB 43 * 44 * returns nonzero if successful, zero otherwise 44 45 * 45 46 */ … … 52 53 53 54 /*********************************************************************** 54 * 55 * 56 * 57 * E_FAILif one of the scroll bars is currently in use58 * S_FALSEif InitializeFlatSB was never called on this hwnd59 * S_OKotherwise55 * 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 60 61 * 61 62 */ … … 68 69 69 70 /*********************************************************************** 70 * 71 * 72 * 73 * 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 */ 78 BOOL WINAPI 78 79 FlatSB_GetScrollProp(HWND hwnd, INT propIndex, LPINT prop) 79 80 { … … 84 85 85 86 /*********************************************************************** 86 * 87 */ 88 BOOL WINAPI 87 * FlatSB_SetScrollProp 88 */ 89 BOOL WINAPI 89 90 FlatSB_SetScrollProp(HWND hwnd, UINT index, INT newValue, BOOL flag) 90 91 { … … 95 96 96 97 /*********************************************************************** 97 * 98 * 99 * 100 * 101 * 102 * 103 * 104 * the flat scroll bar functions, flat scroll bars will show up and105 * 106 * 107 * 108 * 109 * 110 */ 111 112 /*********************************************************************** 113 * 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 */ 116 BOOL WINAPI 116 117 FlatSB_EnableScrollBar(HWND hwnd, int nBar, UINT flags) 117 118 { … … 120 121 121 122 /*********************************************************************** 122 * 123 */ 124 BOOL WINAPI 123 * FlatSB_ShowScrollBar 124 */ 125 BOOL WINAPI 125 126 FlatSB_ShowScrollBar(HWND hwnd, int nBar, BOOL fShow) 126 127 { … … 129 130 130 131 /*********************************************************************** 131 * 132 */ 133 BOOL WINAPI 132 * FlatSB_GetScrollRange 133 */ 134 BOOL WINAPI 134 135 FlatSB_GetScrollRange(HWND hwnd, int nBar, LPINT min, LPINT max) 135 136 { … … 138 139 139 140 /*********************************************************************** 140 * 141 */ 142 BOOL WINAPI 141 * FlatSB_GetScrollInfo 142 */ 143 BOOL WINAPI 143 144 FlatSB_GetScrollInfo(HWND hwnd, int nBar, LPSCROLLINFO info) 144 145 { … … 147 148 148 149 /*********************************************************************** 149 * 150 */ 151 INT WINAPI 150 * FlatSB_GetScrollPos 151 */ 152 INT WINAPI 152 153 FlatSB_GetScrollPos(HWND hwnd, int nBar) 153 154 { … … 156 157 157 158 /*********************************************************************** 158 * 159 */ 160 INT WINAPI 159 * FlatSB_SetScrollPos 160 */ 161 INT WINAPI 161 162 FlatSB_SetScrollPos(HWND hwnd, int nBar, INT pos, BOOL bRedraw) 162 163 { … … 165 166 166 167 /*********************************************************************** 167 * 168 */ 169 INT WINAPI 168 * FlatSB_SetScrollInfo 169 */ 170 INT WINAPI 170 171 FlatSB_SetScrollInfo(HWND hwnd, int nBar, LPSCROLLINFO info, BOOL bRedraw) 171 172 { … … 174 175 175 176 /*********************************************************************** 176 * 177 */ 178 INT WINAPI 177 * FlatSB_SetScrollRange 178 */ 179 INT WINAPI 179 180 FlatSB_SetScrollRange(HWND hwnd, int nBar, INT min, INT max, BOOL bRedraw) 180 181 { … … 212 213 switch (uMsg) 213 214 { 214 215 216 217 218 219 220 221 222 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", 223 224 uMsg, wParam, lParam); 224 225 #ifdef __WIN32OS2__ 225 226 return defComCtl32ProcA (hwnd, uMsg, wParam, lParam); 226 227 #else 227 228 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 228 229 #endif 229 230 } … … 245 246 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); 246 247 wndClass.lpszClassName = FLATSB_CLASSA; 247 248 248 249 RegisterClassA (&wndClass); 249 250 } -
trunk/src/comctl32/imagelist.c
r6380 r6644 1 /* $Id: imagelist.c,v 1.15 2001-09-05 12:04:58 bird Exp $ */ 1 2 /* 2 3 * ImageList implementation … … 20 21 * - ImageList_Draw, ImageList_DrawEx and ImageList_GetIcon use 21 22 * 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 23 24 * limited in functionality too. 24 25 */ … … 69 70 70 71 /************************************************************************* 71 * IMAGELIST_InternalExpandBitmaps [Internal] 72 * IMAGELIST_InternalExpandBitmaps [Internal] 72 73 * 73 74 * Expands the bitmaps of an image list by the given number of images. … … 92 93 if ((himl->cCurImage + nImageCount < himl->cMaxImage) 93 94 && (himl->cy >= cy)) 94 95 return; 95 96 96 97 if (cy == 0) cy = himl->cy; … … 116 117 117 118 if (himl->hbmMask) { 118 hbmNewBitmap = 119 hbmNewBitmap = 119 120 CreateBitmap (nNewWidth, cy, 1, 1, NULL); 120 121 … … 138 139 139 140 /************************************************************************* 140 * IMAGELIST_InternalDraw [Internal] 141 * IMAGELIST_InternalDraw [Internal] 141 142 * 142 143 * Draws the image in the ImageList (without the mask) … … 151 152 * 152 153 * NOTES 153 * This function is used by ImageList_DrawIndirect, when it is 154 * This function is used by ImageList_DrawIndirect, when it is 154 155 * required to draw only the Image (without the mask) to the screen. 155 156 * … … 164 165 hImageDC = CreateCompatibleDC(0); 165 166 hOldBitmap = SelectObject(hImageDC, pimldp->himl->hbmImage); 166 BitBlt(pimldp->hdcDst, 167 BitBlt(pimldp->hdcDst, 167 168 pimldp->x, pimldp->y, cx, cy, 168 hImageDC, 169 pimldp->himl->cx * pimldp->i, 0, 169 hImageDC, 170 pimldp->himl->cx * pimldp->i, 0, 170 171 SRCCOPY); 171 172 … … 176 177 177 178 /************************************************************************* 178 * IMAGELIST_InternalDrawMask [Internal] 179 * IMAGELIST_InternalDrawMask [Internal] 179 180 * 180 181 * Draws the image in the ImageList with the mask … … 189 190 * 190 191 * NOTES 191 * This function is used by ImageList_DrawIndirect, when it is 192 * This function is used by ImageList_DrawIndirect, when it is 192 193 * required to draw the Image with the mask to the screen. 193 194 * … … 205 206 UINT fStyle = pimldp->fStyle & (~ILD_OVERLAYMASK); 206 207 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 209 210 * not on the screen. 210 211 */ … … 221 222 hOffScreenDC = CreateCompatibleDC( pimldp->hdcDst ); 222 223 223 if ( hOffScreenDC ) 224 if ( hOffScreenDC ) 224 225 { 225 226 hOffScreenBmp = CreateCompatibleBitmap( pimldp->hdcDst, cx, cy ); 226 227 227 if ( hOffScreenBmp ) 228 if ( hOffScreenBmp ) 228 229 SelectObject( hOffScreenDC, hOffScreenBmp ); 229 230 else … … 235 236 hOldBitmapImage = SelectObject(hImageDC, himlLocal->hbmImage); 236 237 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. 240 241 * We will use the copy, and this dc for all the various 241 242 * blitting, and then do one final blit to the screen dc. 242 243 * This should clean up most of the flickering. 243 244 */ 244 BitBlt( hOffScreenDC, 0, 0, cx, cy, pimldp->hdcDst, pimldp->x, 245 BitBlt( hOffScreenDC, 0, 0, cx, cy, pimldp->hdcDst, pimldp->x, 245 246 pimldp->y, SRCCOPY); 246 247 247 /* 248 /* 248 249 * Draw the Background for the appropriate Styles 249 250 */ 250 if( bUseCustomBackground && (fStyle == ILD_NORMAL || fStyle & ILD_IMAGE 251 if( bUseCustomBackground && (fStyle == ILD_NORMAL || fStyle & ILD_IMAGE 251 252 || bBlendFlag) ) 252 253 { 253 254 254 255 hBrush = CreateSolidBrush (himlLocal->clrBk); 255 256 hOldBrush = SelectObject (pimldp->hdcDst, hBrush); 256 257 257 258 PatBlt( hOffScreenDC, pimldp->x, pimldp->y, cx, cy, PATCOPY ); 258 259 … … 260 261 } 261 262 262 /* 263 /* 263 264 * Draw Image Transparently over the current background 264 265 */ 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 { /* 268 269 * 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. 271 272 */ 272 273 oldBkColor = SetBkColor( hOffScreenDC, RGB( 0xff, 0xff, 0xff ) ); 273 274 oldBkColor = SetBkColor( hOffScreenDC, RGB( 0xff, 0xff, 0xff ) ); 274 275 oldFgColor = SetTextColor( hOffScreenDC, RGB( 0, 0, 0 ) ); 275 276 … … 279 280 BitBlt( hOffScreenDC, 0, 0, cx, cy, hImageDC,himlLocal->cx * pimldp->i, 280 281 0, SRCPAINT ); 281 282 } 283 282 283 } 284 284 285 /* 285 286 * Draw the image when no Background is specified … … 287 288 else if((fStyle & ILD_IMAGE) && !bUseCustomBackground) 288 289 { 289 BitBlt( hOffScreenDC, 0, 0, cx, cy, hImageDC, 290 BitBlt( hOffScreenDC, 0, 0, cx, cy, hImageDC, 290 291 himlLocal->cx * pimldp->i, 0, SRCCOPY); 291 292 } 292 /* 293 /* 293 294 * Draw the mask with or without a background 294 295 */ … … 298 299 0, bUseCustomBackground ? SRCCOPY : SRCAND); 299 300 } 300 301 301 302 /* 302 303 * Blit the bitmap to the screen now. … … 305 306 hOffScreenDC, 0, 0, SRCCOPY); 306 307 307 308 308 309 SelectObject(hImageDC, hOldBitmapImage); 309 310 SelectObject(hMaskDC, hOldBitmapMask); 310 311 311 312 cleanup: 312 313 313 314 DeleteDC(hImageDC); 314 315 DeleteDC(hMaskDC); 315 316 316 317 DeleteDC( hOffScreenDC ); 317 318 DeleteObject( hOffScreenBmp ); 318 319 319 320 return; 320 321 } 321 322 322 323 /************************************************************************* 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 326 327 * 327 328 * PARAMS … … 334 335 * 335 336 * 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 * 339 340 */ 340 341 static VOID … … 375 376 376 377 BitBlt(hBlendMaskDC, 377 0,0, cx, cy, 378 0,0, cx, cy, 378 379 hMaskDC, 379 380 himlLocal->cx * pimldp->i,0, … … 381 382 382 383 BitBlt(hBlendMaskDC, 383 0,0, cx, cy, 384 0,0, cx, cy, 384 385 hBlendMaskDC, 385 0,0, 386 0,0, 386 387 NOTSRCCOPY); 387 388 … … 397 398 hOldBrush = (HBRUSH) SelectObject (pimldp->hdcDst, hBlendColorBrush); 398 399 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, 403 404 0xB8074A); /* PSDPxax */ 404 405 … … 413 414 414 415 /************************************************************************* 415 * IMAGELIST_InternalDrawOverlay [Internal] 416 * 417 * Draws the overlay image 416 * IMAGELIST_InternalDrawOverlay [Internal] 417 * 418 * Draws the overlay image 418 419 * 419 420 * PARAMS … … 426 427 * 427 428 * NOTES 428 * This functions is used by ImageList_DrawIndirect, when it is 429 * This functions is used by ImageList_DrawIndirect, when it is 429 430 * required to draw the overlay 430 431 * 431 * 432 */ 433 static VOID 432 * 433 */ 434 static VOID 434 435 IMAGELIST_InternalDrawOverlay(IMAGELISTDRAWPARAMS *pimldp, INT cx, INT cy) 435 436 { … … 447 448 if (pimldp->himl->hbmMask) 448 449 { 449 hOldBitmap = (HBITMAP) SelectObject (hImageDC, 450 hOldBitmap = (HBITMAP) SelectObject (hImageDC, 450 451 pimldp->himl->hbmMask); 451 452 452 BitBlt (pimldp->hdcDst, 453 BitBlt (pimldp->hdcDst, 453 454 pimldp->x, pimldp->y, cx, cy, 454 455 hImageDC, pimldp->himl->cx * nOvlIdx, 0, … … 457 458 SelectObject(hImageDC, hOldBitmap); 458 459 } 459 hOldBitmap = (HBITMAP) SelectObject (hImageDC, 460 hOldBitmap = (HBITMAP) SelectObject (hImageDC, 460 461 pimldp->himl->hbmImage); 461 462 462 BitBlt (pimldp->hdcDst, 463 pimldp->x, pimldp->y, cx, cy, 463 BitBlt (pimldp->hdcDst, 464 pimldp->x, pimldp->y, cx, cy, 464 465 hImageDC, 465 466 pimldp->himl->cx * nOvlIdx, 0, … … 492 493 493 494 INT WINAPI 494 ImageList_Add (HIMAGELIST himl, 495 ImageList_Add (HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask) 495 496 { 496 497 HDC hdcImage, hdcBitmap; … … 531 532 hOldBitmapTemp = (HBITMAP) SelectObject(hdcTemp, hbmMask); 532 533 533 BitBlt (hdcMask, 534 BitBlt (hdcMask, 534 535 nStartX, 0, bmp.bmWidth, bmp.bmHeight, 535 hdcTemp, 536 0, 0, 536 hdcTemp, 537 0, 0, 537 538 SRCCOPY); 538 539 … … 542 543 /* Remove the background from the image 543 544 */ 544 BitBlt (hdcImage, 545 BitBlt (hdcImage, 545 546 nStartX, 0, bmp.bmWidth, bmp.bmHeight, 546 hdcMask, 547 nStartX, 0, 547 hdcMask, 548 nStartX, 0, 548 549 0x220326); /* NOTSRCAND */ 549 550 … … 586 587 587 588 /************************************************************************* 588 * ImageList_AddMasked [COMCTL32.42] 589 * ImageList_AddMasked [COMCTL32.42] 589 590 * 590 591 * Adds an image or images to an image list and creates a mask from the … … 651 652 GetPixel (hdcBitmap, 0, 0); 652 653 SetBkColor (hdcBitmap, bkColor); 653 BitBlt (hdcMask, 654 BitBlt (hdcMask, 654 655 nMaskXOffset, 0, bmp.bmWidth, bmp.bmHeight, 655 hdcBitmap, 0, 0, 656 hdcBitmap, 0, 0, 656 657 SRCCOPY); 657 658 … … 668 669 This is here in case some apps rely on this bug 669 670 */ 670 BitBlt(hdcBitmap, 671 BitBlt(hdcBitmap, 671 672 0, 0, bmp.bmWidth, bmp.bmHeight, 672 hdcMask, 673 nMaskXOffset, 0, 673 hdcMask, 674 nMaskXOffset, 0, 674 675 0x220326); /* NOTSRCAND */ 675 676 /* Copy result to the imagelist 676 677 */ 677 BitBlt (hdcImage, 678 BitBlt (hdcImage, 678 679 nIndex * himl->cx, 0, bmp.bmWidth, bmp.bmHeight, 679 hdcBitmap, 680 0, 0, 680 hdcBitmap, 681 0, 0, 681 682 SRCCOPY); 682 683 /* Clean up … … 698 699 699 700 /************************************************************************* 700 * ImageList_BeginDrag [COMCTL32.43] 701 * ImageList_BeginDrag [COMCTL32.43] 701 702 * 702 703 * Creates a temporary image list that contains one image. It will be used … … 716 717 BOOL WINAPI 717 718 ImageList_BeginDrag (HIMAGELIST himlTrack, INT iTrack, 718 719 INT dxHotspot, INT dyHotspot) 719 720 { 720 721 HDC hdcSrc, hdcDst; … … 723 724 724 725 if (himlTrack == NULL) 725 726 return FALSE; 726 727 727 728 if (himlInternalDrag) … … 729 730 730 731 himlInternalDrag = 731 732 732 ImageList_Create (himlTrack->cx, himlTrack->cy, 733 himlTrack->flags, 1, 1); 733 734 if (himlInternalDrag == NULL) { 734 735 ERR("Error creating drag image list!\n"); … … 764 765 765 766 /************************************************************************* 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 769 770 * destination image list. Images can be copied or swapped. 770 771 * … … 787 788 788 789 BOOL WINAPI 789 ImageList_Copy (HIMAGELIST himlDst, INT iDst, 790 791 { 792 HDC hdcSrc, hdcDst; 790 ImageList_Copy (HIMAGELIST himlDst, INT iDst, HIMAGELIST himlSrc, 791 INT iSrc, INT uFlags) 792 { 793 HDC hdcSrc, hdcDst; 793 794 794 795 TRACE("iDst=%d iSrc=%d\n", iDst, iSrc); 795 796 796 797 if ((himlSrc == NULL) || (himlDst == NULL)) 797 798 return FALSE; 798 799 if ((iDst < 0) || (iDst >= himlDst->cCurImage)) 799 800 return FALSE; 800 801 if ((iSrc < 0) || (iSrc >= himlSrc->cCurImage)) 801 802 return FALSE; 802 803 803 804 hdcSrc = CreateCompatibleDC (0); … … 815 816 himlSrc->uBitsPixel, NULL); 816 817 hbmTempMask = CreateBitmap (himlSrc->cx, himlSrc->cy, 1, 817 818 1, NULL); 818 819 819 820 /* copy (and stretch) destination to temporary bitmaps.(save) */ … … 908 909 HIMAGELIST WINAPI 909 910 ImageList_Create (INT cx, INT cy, UINT flags, 910 911 INT cInitial, INT cGrow) 911 912 { 912 913 HIMAGELIST himl; … … 914 915 INT nCount; 915 916 HBITMAP hbmTemp; 916 static WORD aBitBlend25[] = 917 static WORD aBitBlend25[] = 917 918 {0xAA, 0x00, 0x55, 0x00, 0xAA, 0x00, 0x55, 0x00}; 918 919 … … 948 949 if (himl->cMaxImage > 0) { 949 950 himl->hbmImage = 950 951 CreateBitmap (himl->cx * himl->cMaxImage, himl->cy, 951 952 1, himl->uBitsPixel, NULL); 952 953 954 955 953 if (himl->hbmImage == 0) { 954 ERR("Error creating image bitmap!\n"); 955 return NULL; 956 } 956 957 } 957 958 else 958 959 himl->hbmImage = 0; 959 960 960 961 if ( (himl->cMaxImage > 0) && (himl->flags & ILC_MASK)) { 961 962 himl->hbmMask = CreateBitmap (himl->cx * himl->cMaxImage, himl->cy, 962 963 1, 1, NULL); 963 964 if (himl->hbmMask == 0) { 964 965 ERR("Error creating mask bitmap!\n"); … … 986 987 987 988 /************************************************************************* 988 * ImageList_Destroy [COMCTL32.46] 989 * ImageList_Destroy [COMCTL32.46] 989 990 * 990 991 * Destroys an image list. … … 1000 1001 BOOL WINAPI 1001 1002 ImageList_Destroy (HIMAGELIST himl) 1002 { 1003 { 1003 1004 if (!himl) 1004 1005 return FALSE; 1005 1006 1006 1007 /* delete image bitmaps */ … … 1015 1016 if (himl->hbrBlend50) 1016 1017 DeleteObject (himl->hbrBlend50); 1017 1018 1018 1019 COMCTL32_Free (himl); 1019 1020 … … 1023 1024 1024 1025 /************************************************************************* 1025 * ImageList_DragEnter [COMCTL32.47] 1026 * ImageList_DragEnter [COMCTL32.47] 1026 1027 * 1027 1028 * Locks window update and displays the drag image at the given position. … … 1045 1046 { 1046 1047 if (himlInternalDrag == NULL) 1047 1048 return FALSE; 1048 1049 1049 1050 if (hwndLock) 1050 1051 hwndInternalDrag = hwndLock; 1051 1052 else 1052 1053 hwndInternalDrag = GetDesktopWindow (); 1053 1054 1054 1055 xInternalPos = x; … … 1057 1058 hdcBackBuffer = CreateCompatibleDC (0); 1058 1059 hbmBackBuffer = CreateCompatibleBitmap (hdcBackBuffer, 1059 1060 himlInternalDrag->cx, himlInternalDrag->cy); 1060 1061 1061 1062 ImageList_DragShowNolock (TRUE); … … 1066 1067 1067 1068 /************************************************************************* 1068 * ImageList_DragLeave [COMCTL32.48] 1069 * ImageList_DragLeave [COMCTL32.48] 1069 1070 * 1070 1071 * Unlocks window update and hides the drag image. … … 1082 1083 { 1083 1084 if (hwndLock) 1084 1085 hwndInternalDrag = hwndLock; 1085 1086 else 1086 1087 hwndInternalDrag = GetDesktopWindow (); 1087 1088 1088 1089 ImageList_DragShowNolock (FALSE); … … 1096 1097 1097 1098 /************************************************************************* 1098 * ImageList_DragMove [COMCTL32.49] 1099 * ImageList_DragMove [COMCTL32.49] 1099 1100 * 1100 1101 * Moves the drag image. … … 1128 1129 1129 1130 /************************************************************************* 1130 * ImageList_DragShowNolock [COMCTL32.50] 1131 * ImageList_DragShowNolock [COMCTL32.50] 1131 1132 * 1132 1133 * Shows or hides the drag image. … … 1152 1153 1153 1154 hdcDrag = GetDCEx (hwndInternalDrag, 0, 1154 1155 DCX_WINDOW | DCX_CACHE | DCX_LOCKWINDOWUPDATE); 1155 1156 1156 1157 if (bShow) { 1157 1158 1159 1160 1161 1158 /* show drag image */ 1159 1160 /* save background */ 1161 1162 /* draw drag image */ 1162 1163 1163 1164 } 1164 1165 else { 1165 1166 1167 1166 /* hide drag image */ 1167 1168 /* restore background */ 1168 1169 1169 1170 } … … 1199 1200 BOOL WINAPI 1200 1201 ImageList_Draw (HIMAGELIST himl, INT i, HDC hdc, 1201 1202 INT x, INT y, UINT fStyle) 1202 1203 { 1203 1204 IMAGELISTDRAWPARAMS imldp; … … 1252 1253 BOOL WINAPI 1253 1254 ImageList_DrawEx (HIMAGELIST himl, INT i, HDC hdc, INT x, INT y, 1254 1255 1255 INT dx, INT dy, COLORREF rgbBk, COLORREF rgbFg, 1256 UINT fStyle) 1256 1257 { 1257 1258 IMAGELISTDRAWPARAMS imldp; … … 1277 1278 1278 1279 /************************************************************************* 1279 * ImageList_DrawIndirect [COMCTL32.53] 1280 * ImageList_DrawIndirect [COMCTL32.53] 1280 1281 * 1281 1282 * Draws an image using ... … … 1292 1293 ImageList_DrawIndirect (IMAGELISTDRAWPARAMS *pimldp) 1293 1294 { 1294 INT cx, cy; 1295 /* 1295 INT cx, cy; 1296 /* 1296 1297 Do some Error Checking 1297 1298 */ … … 1303 1304 return FALSE; 1304 1305 if ((pimldp->i < 0) || (pimldp->i >= pimldp->himl->cCurImage)) { 1305 1306 ERR("%d not within range (max %d)\n",pimldp->i,pimldp->himl->cCurImage-1); 1306 1307 return FALSE; 1307 1308 } … … 1322 1323 IMAGELIST_InternalDraw(pimldp, cx, cy); 1323 1324 } 1324 /* 1325 /* 1325 1326 Apply the blend if needed to the Image 1326 1327 */ … … 1387 1388 DeleteDC (hdcSrc); 1388 1389 1389 1390 1390 himlDst->cCurImage = himlSrc->cCurImage; 1391 himlDst->cMaxImage = himlSrc->cMaxImage; 1391 1392 } 1392 1393 return himlDst; … … 1447 1448 { 1448 1449 if (himl == NULL) 1449 1450 return CLR_NONE; 1450 1451 1451 1452 return himl->clrBk; … … 1483 1484 1484 1485 /************************************************************************* 1485 * ImageList_GetIcon [COMCTL32.59] 1486 * ImageList_GetIcon [COMCTL32.59] 1486 1487 * 1487 1488 * Creates an icon from a masked image of an image list. … … 1506 1507 1507 1508 if ((himl == NULL) || (i < 0) || (i >= himl->cCurImage)) { 1508 1509 1509 FIXME("(%p,%d,%x), params out of range!\n",himl,i,fStyle); 1510 return 0; 1510 1511 } 1511 1512 … … 1519 1520 hOldDstBitmap = (HBITMAP)SelectObject (hdcDst, ii.hbmMask); 1520 1521 if (himl->hbmMask) { 1521 1522 1523 1522 SelectObject (hdcSrc, himl->hbmMask); 1523 BitBlt (hdcDst, 0, 0, himl->cx, himl->cy, 1524 hdcSrc, i * himl->cx, 0, SRCCOPY); 1524 1525 } 1525 1526 else 1526 1527 PatBlt (hdcDst, 0, 0, himl->cx, himl->cy, BLACKNESS); 1527 1528 1528 1529 /* draw image*/ … … 1531 1532 SelectObject (hdcDst, ii.hbmColor); 1532 1533 BitBlt (hdcDst, 0, 0, himl->cx, himl->cy, 1533 1534 hdcSrc, i * himl->cx, 0, SRCCOPY); 1534 1535 1535 1536 /* 1536 1537 * CreateIconIndirect requires us to deselect the bitmaps from 1537 * the DCs before calling 1538 * the DCs before calling 1538 1539 */ 1539 1540 SelectObject(hdcSrc, hOldSrcBitmap); 1540 1541 SelectObject(hdcDst, hOldDstBitmap); 1541 1542 1542 hIcon = CreateIconIndirect (&ii); 1543 hIcon = CreateIconIndirect (&ii); 1543 1544 1544 1545 DeleteDC (hdcSrc); … … 1573 1574 { 1574 1575 if (himl == NULL) 1575 1576 return FALSE; 1576 1577 if ((himl->cx <= 0) || (himl->cy <= 0)) 1577 1578 return FALSE; 1578 1579 1579 1580 if (cx) 1580 1581 *cx = himl->cx; 1581 1582 if (cy) 1582 1583 *cy = himl->cy; 1583 1584 1584 1585 return TRUE; … … 1603 1604 { 1604 1605 if (himl == NULL) 1605 1606 return 0; 1606 1607 1607 1608 return himl->cCurImage; … … 1628 1629 { 1629 1630 if ((himl == NULL) || (pImageInfo == NULL)) 1630 1631 return FALSE; 1631 1632 if ((i < 0) || (i >= himl->cCurImage)) 1632 1633 return FALSE; 1633 1634 1634 1635 pImageInfo->hbmImage = himl->hbmImage; 1635 1636 pImageInfo->hbmMask = himl->hbmMask; 1636 1637 1637 1638 pImageInfo->rcImage.top = 0; 1638 1639 pImageInfo->rcImage.bottom = himl->cy; 1639 1640 pImageInfo->rcImage.left = i * himl->cx; 1640 1641 pImageInfo->rcImage.right = (i+1) * himl->cx; 1641 1642 1642 1643 return TRUE; 1643 1644 } … … 1645 1646 1646 1647 /************************************************************************* 1647 * ImageList_GetImageRect [COMCTL32.63] 1648 * ImageList_GetImageRect [COMCTL32.63] 1648 1649 * 1649 1650 * Retrieves the rectangle of the specified image in an image list. … … 1666 1667 { 1667 1668 if ((himl == NULL) || (lpRect == NULL)) 1668 1669 return FALSE; 1669 1670 if ((i < 0) || (i >= himl->cCurImage)) 1670 1671 return FALSE; 1671 1672 1672 1673 lpRect->left = i * himl->cx; … … 1704 1705 HIMAGELIST WINAPI 1705 1706 ImageList_LoadImageA (HINSTANCE hi, LPCSTR lpbmp, INT cx, INT cGrow, 1706 1707 COLORREF clrMask, UINT uType, UINT uFlags) 1707 1708 { 1708 1709 HIMAGELIST himl = NULL; … … 1744 1745 GetIconInfo (handle, &ii); 1745 1746 GetObjectA (ii.hbmColor, sizeof(BITMAP), (LPVOID)&bmp); 1746 himl = ImageList_Create (bmp.bmWidth, bmp.bmHeight, 1747 himl = ImageList_Create (bmp.bmWidth, bmp.bmHeight, 1747 1748 ILC_MASK | ILC_COLOR, 1, cGrow); 1748 1749 ImageList_Add (himl, ii.hbmColor, ii.hbmMask); … … 1752 1753 1753 1754 DeleteObject (handle); 1754 1755 1755 1756 return himl; 1756 1757 } … … 1781 1782 HIMAGELIST WINAPI 1782 1783 ImageList_LoadImageW (HINSTANCE hi, LPCWSTR lpbmp, INT cx, INT cGrow, 1783 COLORREF clrMask, UINT uType,UINT uFlags)1784 COLORREF clrMask, UINT uType, UINT uFlags) 1784 1785 { 1785 1786 HIMAGELIST himl = NULL; … … 1808 1809 GetIconInfo (handle, &ii); 1809 1810 GetObjectA (ii.hbmMask, sizeof(BITMAP), (LPVOID)&bmp); 1810 himl = ImageList_Create (bmp.bmWidth, bmp.bmHeight, 1811 himl = ImageList_Create (bmp.bmWidth, bmp.bmHeight, 1811 1812 ILC_MASK | ILC_COLOR, 1, cGrow); 1812 1813 ImageList_Add (himl, ii.hbmColor, ii.hbmMask); … … 1816 1817 1817 1818 DeleteObject (handle); 1818 1819 1819 1820 return himl; 1820 1821 } … … 1822 1823 1823 1824 /************************************************************************* 1824 * ImageList_Merge [COMCTL32.67] 1825 * ImageList_Merge [COMCTL32.67] 1825 1826 * 1826 1827 * Creates a new image list that contains a merged image from the specified … … 1842 1843 HIMAGELIST WINAPI 1843 1844 ImageList_Merge (HIMAGELIST himl1, INT i1, HIMAGELIST himl2, INT i2, 1844 1845 INT dx, INT dy) 1845 1846 { 1846 1847 HIMAGELIST himlDst = NULL; … … 1851 1852 1852 1853 if ((himl1 == NULL) || (himl2 == NULL)) 1853 1854 return NULL; 1854 1855 1855 1856 /* check indices */ … … 1903 1904 nX1 = i1 * himl1->cx; 1904 1905 nX2 = i2 * himl2->cx; 1905 1906 1906 1907 /* copy image */ 1907 1908 SelectObject (hdcSrcImage, himl1->hbmImage); 1908 1909 SelectObject (hdcDstImage, himlDst->hbmImage); 1909 BitBlt (hdcDstImage, 0, 0, cxDst, cyDst, 1910 BitBlt (hdcDstImage, 0, 0, cxDst, cyDst, 1910 1911 hdcSrcImage, 0, 0, BLACKNESS); 1911 BitBlt (hdcDstImage, xOff1, yOff1, himl1->cx, himl1->cy, 1912 BitBlt (hdcDstImage, xOff1, yOff1, himl1->cx, himl1->cy, 1912 1913 hdcSrcImage, nX1, 0, SRCCOPY); 1913 1914 1914 1915 SelectObject (hdcSrcImage, himl2->hbmMask); 1915 BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 1916 BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 1916 1917 hdcSrcImage, nX2, 0, SRCAND); 1917 1918 1918 1919 SelectObject (hdcSrcImage, himl2->hbmImage); 1919 BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 1920 BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 1920 1921 hdcSrcImage, nX2, 0, SRCPAINT); 1921 1922 … … 1923 1924 SelectObject (hdcSrcImage, himl1->hbmMask); 1924 1925 SelectObject (hdcDstImage, himlDst->hbmMask); 1925 BitBlt (hdcDstImage, 0, 0, cxDst, cyDst, 1926 BitBlt (hdcDstImage, 0, 0, cxDst, cyDst, 1926 1927 hdcSrcImage, 0, 0, WHITENESS); 1927 BitBlt (hdcDstImage, xOff1, yOff1, himl1->cx, himl1->cy, 1928 BitBlt (hdcDstImage, xOff1, yOff1, himl1->cx, himl1->cy, 1928 1929 hdcSrcImage, nX1, 0, SRCCOPY); 1929 1930 1930 1931 SelectObject (hdcSrcImage, himl2->hbmMask); 1931 BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 1932 BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 1932 1933 hdcSrcImage, nX2, 0, SRCAND); 1933 1934 … … 1935 1936 DeleteDC (hdcDstImage); 1936 1937 } 1937 1938 1938 1939 return himlDst; 1939 1940 } … … 1945 1946 int bitspixel = GetDeviceCaps(hdc,BITSPIXEL)*GetDeviceCaps(hdc,PLANES); 1946 1947 if (bitspixel>8) 1947 1948 return TRUE; 1948 1949 if (bitspixel<=4) 1949 1950 return FALSE; 1950 1951 return GetDeviceCaps(hdc,CAPS1) & C1_DIBENGINE; 1951 1952 } … … 1954 1955 /* helper for ImageList_Read, see comments below */ 1955 1956 static HBITMAP _read_bitmap(LPSTREAM pstm,int ilcFlag,int cx,int cy) { 1956 HDC 1957 BITMAPFILEHEADER 1958 BITMAPINFOHEADER 1959 int 1960 LPBITMAPINFOHEADER 1961 int 1962 HBITMAP 1963 LPBYTE 1964 int 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 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)) 1970 1971 ) 1971 1972 return 0; 1972 1973 1973 1974 bitsperpixel = bmih.biPlanes * bmih.biBitCount; 1974 1975 if (bitsperpixel<=8) 1975 1976 palspace = (1<<bitsperpixel)*sizeof(RGBQUAD); 1976 1977 else 1977 1978 palspace = 0; 1978 1979 width = bmih.biWidth; 1979 1980 height = bmih.biHeight; 1980 1981 bmihc = (LPBITMAPINFOHEADER)LocalAlloc(LMEM_ZEROINIT,sizeof(bmih)+palspace); 1981 1982 memcpy(bmihc,&bmih,sizeof(bmih)); 1982 longsperline 1983 bmihc->biSizeImage 1983 longsperline = ((width*bitsperpixel+31)&~0x1f)>>5; 1984 bmihc->biSizeImage = (longsperline*height)<<2; 1984 1985 1985 1986 /* read the palette right after the end of the bitmapinfoheader */ 1986 1987 if (palspace) 1987 1988 1988 if (!SUCCEEDED(IStream_Read ( pstm, bmihc+1, palspace, NULL))) 1989 goto ret1; 1989 1990 1990 1991 xdc = GetDC(0); 1991 1992 #if 0 /* Magic for NxM -> 1x(N*M) not implemented for DIB Sections */ 1992 1993 if ((bitsperpixel>1) && 1993 1994 ((ilcFlag!=ILC_COLORDDB) && (!ilcFlag || may_use_dibsection(xdc))) 1994 1995 ) { 1995 1996 1997 1998 1999 2000 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; 2001 2002 } else 2002 2003 #endif 2003 2004 { 2004 2005 2006 nwidth= width*(height/cy);2007 nheight= cy;2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 bytesperline= longsperline*4;2023 nbytesperline= (height/cy)*bytesperline;2024 2025 2026 2027 2028 2029 2030 2031 bmihc->biWidth= nwidth;2032 bmihc->biHeight= nheight;2033 2034 2035 2036 2037 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; 2038 2039 } 2039 2040 ret1: 2040 if (xdc) 2041 if (bmihc) 2041 if (xdc) ReleaseDC(0,xdc); 2042 if (bmihc) LocalFree((HLOCAL)bmihc); 2042 2043 if (!result) { 2043 2044 2045 2046 2044 if (hbitmap) { 2045 DeleteObject(hbitmap); 2046 hbitmap = 0; 2047 } 2047 2048 } 2048 2049 return hbitmap; … … 2062 2063 * 2063 2064 * The format is like this: 2064 * ILHEADilheadstruct;2065 * ILHEAD ilheadstruct; 2065 2066 * 2066 2067 * for the color image part: 2067 * BITMAPFILEHEADER bmfh;2068 * BITMAPINFOHEADERbmih;2068 * BITMAPFILEHEADER bmfh; 2069 * BITMAPINFOHEADER bmih; 2069 2070 * only if it has a palette: 2070 * RGBQUAD rgbs[nr_of_paletted_colors];2071 * 2072 * BYTEcolorbits[imagesize];2071 * RGBQUAD rgbs[nr_of_paletted_colors]; 2072 * 2073 * BYTE colorbits[imagesize]; 2073 2074 * 2074 2075 * the following only if the ILC_MASK bit is set in ILHEAD.ilFlags: 2075 * BITMAPFILEHEADERbmfh_mask;2076 * BITMAPINFOHEADERbmih_mask;2076 * BITMAPFILEHEADER bmfh_mask; 2077 * BITMAPINFOHEADER bmih_mask; 2077 2078 * only if it has a palette (it usually does not): 2078 * RGBQUAD rgbs[nr_of_paletted_colors];2079 * 2080 * BYTEmaskbits[imagesize];2079 * RGBQUAD rgbs[nr_of_paletted_colors]; 2080 * 2081 * BYTE maskbits[imagesize]; 2081 2082 * 2082 2083 * CAVEAT: Those images are within a NxM bitmap, not the 1xN we expect. … … 2085 2086 HIMAGELIST WINAPI ImageList_Read (LPSTREAM pstm) 2086 2087 { 2087 ILHEAD 2088 HIMAGELIST 2089 HBITMAP 2090 int 2088 ILHEAD ilHead; 2089 HIMAGELIST himl; 2090 HBITMAP hbmColor=0,hbmMask=0; 2091 int i; 2091 2092 2092 2093 if (!SUCCEEDED(IStream_Read (pstm, &ilHead, sizeof(ILHEAD), NULL))) 2093 2094 return NULL; 2094 2095 if (ilHead.usMagic != (('L' << 8) | 'I')) 2095 2096 return NULL; 2096 2097 if (ilHead.usVersion != 0x101) /* probably version? */ 2097 2098 return NULL; 2098 2099 2099 2100 #if 0 2100 FIXME(" 2101 FIXME(" 2102 FIXME(" 2103 FIXME(" 2104 FIXME(" 2105 FIXME(" 2106 FIXME(" 2107 FIXME(" 2108 FIXME(" 2109 FIXME(" 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]); 2110 2111 #endif 2111 2112 2112 2113 hbmColor = _read_bitmap(pstm,ilHead.flags & ~ILC_MASK,ilHead.cx,ilHead.cy); 2113 2114 if (!hbmColor) 2114 2115 return NULL; 2115 2116 if (ilHead.flags & ILC_MASK) { 2116 2117 2118 2119 2120 2117 hbmMask = _read_bitmap(pstm,0,ilHead.cx,ilHead.cy); 2118 if (!hbmMask) { 2119 DeleteObject(hbmColor); 2120 return NULL; 2121 } 2121 2122 } 2122 2123 2123 2124 himl = ImageList_Create ( 2124 2125 2126 2127 1,/* initial */2128 2125 ilHead.cx, 2126 ilHead.cy, 2127 ilHead.flags, 2128 1, /* initial */ 2129 ilHead.cGrow 2129 2130 ); 2130 2131 if (!himl) { 2131 2132 2133 2132 DeleteObject(hbmColor); 2133 DeleteObject(hbmMask); 2134 return NULL; 2134 2135 } 2135 2136 himl->hbmImage = hbmColor; … … 2140 2141 ImageList_SetBkColor(himl,ilHead.bkcolor); 2141 2142 for (i=0;i<4;i++) 2142 2143 ImageList_SetOverlayImage(himl,ilHead.ovls[i],i+1); 2143 2144 return himl; 2144 2145 } … … 2168 2169 return FALSE; 2169 2170 } 2170 2171 2171 2172 if ((i < -1) || (i >= himl->cCurImage)) { 2172 2173 ERR("index out of range! %d\n", i); … … 2211 2212 TRACE(" - Max. number of images: %d / %d (Old/New)\n", 2212 2213 himl->cMaxImage, himl->cCurImage + himl->cGrow - 1); 2213 2214 2214 2215 hbmNewImage = 2215 2216 CreateBitmap (cxNew, himl->cy, 1, himl->uBitsPixel, NULL); … … 2226 2227 if (i > 0) { 2227 2228 TRACE("Pre image copy: Copy %d images\n", i); 2228 2229 2229 2230 SelectObject (hdcSrc, himl->hbmImage); 2230 2231 SelectObject (hdcDst, hbmNewImage); … … 2277 2278 2278 2279 /************************************************************************* 2279 * ImageList_Replace [COMCTL32.70] 2280 * ImageList_Replace [COMCTL32.70] 2280 2281 * 2281 2282 * Replaces an image in an image list with a new image. … … 2294 2295 BOOL WINAPI 2295 2296 ImageList_Replace (HIMAGELIST himl, INT i, HBITMAP hbmImage, 2296 2297 HBITMAP hbmMask) 2297 2298 { 2298 2299 HDC hdcImageList, hdcImage; … … 2303 2304 return FALSE; 2304 2305 } 2305 2306 2306 2307 if ((i >= himl->cMaxImage) || (i < 0)) { 2307 2308 ERR("Invalid image index!\n"); … … 2333 2334 */ 2334 2335 SelectObject (hdcImageList, himl->hbmImage); 2335 StretchBlt (hdcImageList, 2336 StretchBlt (hdcImageList, 2336 2337 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, 2339 2340 0x220326); /* NOTSRCAND */ 2340 2341 } … … 2375 2376 2376 2377 if (himl == NULL) 2377 2378 return -1; 2378 2379 if ((i >= himl->cMaxImage) || (i < -1)) 2379 2380 return -1; 2380 2381 2381 2382 hBestFitIcon = CopyImage( 2382 hIcon, IMAGE_ICON, 2383 himl->cx, himl->cy, 2383 hIcon, IMAGE_ICON, 2384 himl->cx, himl->cy, 2384 2385 LR_COPYFROMRESOURCE); 2385 2386 2386 2387 GetIconInfo (hBestFitIcon, &ii); 2387 2388 if (ii.hbmMask == 0) 2388 2389 ERR("no mask!\n"); 2389 2390 if (ii.hbmColor == 0) 2390 2391 ERR("no color!\n"); 2391 2392 GetObjectA (ii.hbmMask, sizeof(BITMAP), (LPVOID)&bmp); 2392 2393 … … 2404 2405 TRACE("hdcImageList=0x%x!\n", hdcImageList); 2405 2406 if (hdcImageList == 0) 2406 2407 ERR("invalid hdcImageList!\n"); 2407 2408 2408 2409 hdcImage = CreateCompatibleDC (0); 2409 2410 TRACE("hdcImage=0x%x!\n", hdcImage); 2410 2411 if (hdcImage == 0) 2411 2412 ERR("invalid hdcImage!\n"); 2412 2413 2413 2414 hbmOldDst = SelectObject (hdcImageList, himl->hbmImage); … … 2429 2430 2430 2431 if(hBestFitIcon) 2431 2432 DestroyIcon(hBestFitIcon); 2432 2433 if (hdcImageList) 2433 2434 DeleteDC (hdcImageList); 2434 2435 if (hdcImage) 2435 2436 DeleteDC (hdcImage); 2436 2437 if (ii.hbmColor) 2437 2438 DeleteObject (ii.hbmColor); 2438 2439 if (ii.hbmMask) 2439 2440 DeleteObject (ii.hbmMask); 2440 2441 2441 2442 return nIndex; … … 2444 2445 2445 2446 /************************************************************************* 2446 * ImageList_SetBkColor [COMCTL32.76] 2447 * ImageList_SetBkColor [COMCTL32.76] 2447 2448 * 2448 2449 * Sets the background color of an image list. … … 2463 2464 2464 2465 if (himl == NULL) 2465 2466 return CLR_NONE; 2466 2467 2467 2468 clrOldBk = himl->clrBk; … … 2492 2493 BOOL WINAPI 2493 2494 ImageList_SetDragCursorImage (HIMAGELIST himlDrag, INT iDrag, 2494 2495 INT dxHotspot, INT dyHotspot) 2495 2496 { 2496 2497 HIMAGELIST himlTemp; … … 2499 2500 2500 2501 if (himlInternalDrag == NULL) 2501 2502 return FALSE; 2502 2503 2503 2504 TRACE(" dxH=%d dyH=%d nX=%d nY=%d\n", 2504 2505 dxHotspot, dyHotspot, nInternalDragHotspotX, nInternalDragHotspotY); 2505 2506 2506 2507 himlTemp = ImageList_Merge (himlInternalDrag, 0, himlDrag, iDrag, 2507 2508 dxHotspot, dyHotspot); 2508 2509 2509 2510 ImageList_Destroy (himlInternalDrag); … … 2518 2519 2519 2520 /************************************************************************* 2520 * ImageList_SetFilter [COMCTL32.78] 2521 * ImageList_SetFilter [COMCTL32.78] 2521 2522 * 2522 2523 * Sets a filter (or does something completely different)!!??? … … 2540 2541 { 2541 2542 FIXME("(%p 0x%x 0x%lx):empty stub!\n", 2542 2543 himl, i, dwFilter); 2543 2544 2544 2545 return FALSE; … … 2567 2568 2568 2569 if (!himl) 2569 2570 return FALSE; 2570 2571 2571 2572 /* remove all images */ … … 2617 2618 2618 2619 if (!himl) 2619 2620 return FALSE; 2620 2621 if (himl->cCurImage >= iImageCount) 2621 2622 return FALSE; 2622 2623 if (himl->cMaxImage > iImageCount) 2623 2624 return TRUE; 2624 2625 2625 2626 nNewCount = iImageCount + himl->cGrow; … … 2636 2637 SelectObject (hdcBitmap, hbmNewBitmap); 2637 2638 2638 2639 /* copy images */ 2639 2640 BitBlt (hdcBitmap, 0, 0, nCopyCount * himl->cx, himl->cy, 2640 2641 hdcImageList, 0, 0, SRCCOPY); 2641 2642 #if 0 2642 2643 2644 2645 PatBlt (hdcBitmap, nCopyCount * himl->cx, 0, 2646 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); 2647 2648 #endif 2648 2649 2649 DeleteObject (himl->hbmImage); 2650 himl->hbmImage = hbmNewBitmap; 2650 2651 } 2651 2652 else 2652 2653 ERR("Could not create new image bitmap !\n"); 2653 2654 2654 2655 if (himl->hbmMask) … … 2661 2662 SelectObject (hdcBitmap, hbmNewBitmap); 2662 2663 2663 2664 /* copy images */ 2664 2665 BitBlt (hdcBitmap, 0, 0, nCopyCount * himl->cx, himl->cy, 2665 2666 hdcImageList, 0, 0, SRCCOPY); 2666 2667 #if 0 2667 2668 2669 2670 PatBlt (hdcBitmap, nCopyCount * himl->cx, 0, 2671 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); 2672 2673 #endif 2673 2674 DeleteObject (himl->hbmMask); … … 2709 2710 { 2710 2711 if (!himl) 2711 2712 return FALSE; 2712 2713 if ((iOverlay < 1) || (iOverlay > MAX_OVERLAYIMAGE)) 2713 2714 return FALSE; 2714 2715 if ((iImage!=-1) && ((iImage < 0) || (iImage > himl->cCurImage))) 2715 2716 return FALSE; 2716 2717 himl->nOvlIdx[iOverlay - 1] = iImage; 2717 2718 return TRUE; … … 2744 2745 { 2745 2746 if (!himl) 2746 2747 return FALSE; 2747 2748 2748 2749 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 $ */ 1 2 /* 2 3 * COMCTL32 DLL entry point … … 26 27 #define INCL_DOSMODULEMGR 27 28 #define INCL_DOSPROCESS 28 #include <os2wrap.h> 29 #include <os2wrap.h> //Odin32 OS/2 api wrappers 29 30 #include <stdlib.h> 30 31 #include <stdio.h> … … 59 60 { 60 61 BOOL ret = COMCTL32_LibMain(hinstDLL, fdwReason, fImpLoad); 61 62 return ret; 62 63 } 63 64 } … … 85 86 switch (ulFlag) { 86 87 case 0 : 87 88 dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&comctl32_PEResTab, 88 89 COMCTL32_MAJORIMAGE_VERSION, COMCTL32_MINORIMAGE_VERSION, 89 90 IMAGE_SUBSYSTEM_WINDOWS_GUI); 90 if(dllHandle == 0) 91 91 if(dllHandle == 0) 92 return 0UL; 92 93 93 94 break; 94 95 case 1 : 95 96 if(dllHandle) { 96 97 UnregisterLxDll(dllHandle); 97 98 } 98 99 break; -
trunk/src/comctl32/initterm.cpp
r6375 r6644 1 /* $Id: initterm.cpp,v 1.16 2001-09-05 12:04:59 bird Exp $ */ 1 2 /* 2 3 * COMCTL32 DLL entry point … … 26 27 #define INCL_DOSMODULEMGR 27 28 #define INCL_DOSPROCESS 28 #include <os2wrap.h> 29 #include <os2wrap.h> //Odin32 OS/2 api wrappers 29 30 #include <stdlib.h> 30 31 #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 $ */ 1 2 /* 2 3 * Listview control -
trunk/src/comctl32/monthcal.c
r5416 r6644 1 /* $Id: monthcal.c,v 1.12 2001-09-05 12:05:00 bird Exp $ */ 1 2 /* Month calendar control 2 3 * 3 4 * 4 5 * Copyright 1998, 1999 Eric Kohl (ekohl@abo.rhein-zeitung.de) 5 6 * Copyright 1999 Alex Priem (alexp@sci.kun.nl) 6 7 * Copyright 1999 Chris Morgan <cmorgan@wpi.edu> and 7 * 8 * James Abbatiello <abbeyj@wpi.edu> 8 9 * Copyright 2000 Uwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de> 9 10 * … … 13 14 * 14 15 * FIXME: handle resources better (doesn't work now); also take care 15 of internationalization.16 * of internationalization. 16 17 * FIXME: keyboard handling. 17 18 */ … … 43 44 DEFAULT_DEBUG_CHANNEL(monthcal); 44 45 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 */ 47 48 #define MC_PREVPRESSED 4 /* Prev month button pressed */ 48 49 #define MC_NEXTPRESSED 8 /* Next month button pressed */ 49 #define MC_NEXTMONTHDELAY 350 50 51 52 #define MC_NEXTMONTHTIMER 1 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 54 55 55 56 typedef struct … … 58 59 COMCTL32_HEADER header; 59 60 #endif 60 COLORREF 61 COLORREF 62 COLORREF 63 COLORREF 64 COLORREF 65 COLORREF 66 HFONT 67 HFONT 68 int 69 int 70 int 71 int 72 int 73 int 74 int 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 */ 76 77 /* 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 78 int visible; /* # of months visible */ 79 int firstDay; /* Start month calendar with firstDay's day */ 80 int monthRange; 80 81 MONTHDAYSTATE *monthdayState; 81 SYSTEMTIME 82 DWORD 83 DWORD 84 int status;/* See MC_SEL flags */85 int curSelDay;/* current selected day */86 int firstSelDay;/* first selected day */87 int 88 SYSTEMTIME 89 SYSTEMTIME 90 DWORD 91 SYSTEMTIME 92 SYSTEMTIME 93 94 RECT rcClient; 95 RECT rcDraw; 96 RECT title; 97 RECT titlebtnnext; 98 RECT titlebtnprev; /* the `prev month' button in the header */ 99 RECT titlemonth; 100 RECT titleyear; 101 RECT wdays; 102 RECT days; 103 RECT weeknums; 104 RECT todayrect; 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 */ 105 106 HWND hWndYearEdit; /* Window Handle of edit box to handle years */ 106 107 HWND hWndYearUpDown;/* Window Handle of updown box to handle years */ … … 141 142 142 143 /* make sure that time is valid */ 143 static int MONTHCAL_ValidateTime(SYSTEMTIME time) 144 static int MONTHCAL_ValidateTime(SYSTEMTIME time) 144 145 { 145 146 if(time.wMonth > 12) return FALSE; 146 147 if(time.wDayOfWeek > 6) return FALSE; 147 148 if(time.wDay > MONTHCAL_MonthLength(time.wMonth, time.wYear)) 148 149 return FALSE; 149 150 if(time.wHour > 23) return FALSE; 150 151 if(time.wMinute > 59) return FALSE; … … 156 157 157 158 158 void MONTHCAL_CopyTime(const SYSTEMTIME *from, SYSTEMTIME *to) 159 void MONTHCAL_CopyTime(const SYSTEMTIME *from, SYSTEMTIME *to) 159 160 { 160 161 to->wYear = from->wYear; … … 169 170 170 171 171 /* Note:Depending on DST, this may be offset by a day. 172 /* Note:Depending on DST, this may be offset by a day. 172 173 Need to find out if we're on a DST place & adjust the clock accordingly. 173 174 Above function assumes we have a valid data. … … 182 183 year-=(month < 3); 183 184 184 return((year + year/4 - year/100 + year/400 + 185 return((year + year/4 - year/100 + year/400 + 185 186 DayOfWeekTable[month-1] + day - 1 ) % 7); 186 187 } … … 189 190 and day in the calendar. day== 0 mean the last day of tha last month 190 191 */ 191 static int MONTHCAL_CalcDayFromPos(MONTHCAL_INFO *infoPtr, int x, int y, 192 int *daypos,int *weekpos) 192 static int MONTHCAL_CalcDayFromPos(MONTHCAL_INFO *infoPtr, int x, int y, 193 int *daypos,int *weekpos) 193 194 { 194 195 int retval, firstDay; … … 202 203 *daypos = (x - infoPtr->days.left ) / infoPtr->width_increment; 203 204 *weekpos = (y - infoPtr->days.top ) / infoPtr->height_increment; 204 205 205 206 firstDay = (MONTHCAL_CalculateDayOfWeek(1, infoPtr->currentMonth, infoPtr->currentYear)+6 - infoPtr->firstDay)%7; 206 207 retval = *daypos + (7 * *weekpos) - firstDay; … … 211 212 /* sets x and y to be the position of the day */ 212 213 /* x == day, y == week where(0,0) == firstDay, 1st week */ 213 static void MONTHCAL_CalcDayXY(MONTHCAL_INFO *infoPtr, int day, int month, 214 static void MONTHCAL_CalcDayXY(MONTHCAL_INFO *infoPtr, int day, int month, 214 215 int *x, int *y) 215 216 { … … 227 228 if(prevMonth==0) 228 229 prevMonth = 12; 229 230 230 231 *x = (MONTHCAL_MonthLength(prevMonth, infoPtr->currentYear) - firstDay) % 7; 231 232 *y = 0; … … 240 241 241 242 /* x: column(day), y: row(week) */ 242 static void MONTHCAL_CalcDayRect(MONTHCAL_INFO *infoPtr, RECT *r, int x, int y) 243 static void MONTHCAL_CalcDayRect(MONTHCAL_INFO *infoPtr, RECT *r, int x, int y) 243 244 { 244 245 r->left = infoPtr->days.left + x * infoPtr->width_increment; … … 252 253 /* day is the day value of the month(1 == 1st), month is the month */ 253 254 /* value(january == 1, december == 12) */ 254 static inline void MONTHCAL_CalcPosFromDay(MONTHCAL_INFO *infoPtr, 255 static inline void MONTHCAL_CalcPosFromDay(MONTHCAL_INFO *infoPtr, 255 256 int day, int month, RECT *r) 256 257 { … … 278 279 x = day_rect.left; 279 280 y = day_rect.top; 280 281 281 282 points[0].x = x; 282 283 points[0].y = y - 1; … … 287 288 points[3].x = x + infoPtr->width_increment; 288 289 points[3].y = y + 0.5 * infoPtr->height_increment; 289 290 290 291 points[4].x = x + infoPtr->width_increment; 291 292 points[4].y = y + 0.9 * infoPtr->height_increment; … … 294 295 points[6].x = x + 0.5 * infoPtr->width_increment; 295 296 points[6].y = y + 0.9 * infoPtr->height_increment; /* bring the bottom up just 296 297 297 a hair to fit inside the day rectangle */ 298 298 299 points[7].x = x + 0.2 * infoPtr->width_increment; 299 300 points[7].y = y + 0.8 * infoPtr->height_increment; … … 309 310 points[12].x = x + 0.4 * infoPtr->width_increment; 310 311 points[12].y = y + 0.2 * infoPtr->height_increment; 311 312 312 313 PolyBezier(hdc, points, 13); 313 314 DeleteObject(hRedPen); … … 329 330 sprintf(buf, "%d", day); 330 331 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. 332 333 * 1<day<31, so evertyhing's OK. 333 334 */ … … 349 350 350 351 /* FIXME: this may need to be changed now b/c of the other 351 352 drawing changes 11/3/99 CMM */ 352 353 r2.left = r.left - 0.25 * infoPtr->textWidth; 353 354 r2.top = r.top; … … 390 391 391 392 /* CHECKME: For `todays date', do we need to check the locale?*/ 392 static void MONTHCAL_Refresh(HWND hwnd, HDC hdc, PAINTSTRUCT* ps) 393 static void MONTHCAL_Refresh(HWND hwnd, HDC hdc, PAINTSTRUCT* ps) 393 394 { 394 395 MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd); … … 425 426 hbr = CreateSolidBrush (infoPtr->bk); 426 427 FillRect(hdc, rcClient, hbr); 427 DeleteObject(hbr); 428 DeleteObject(hbr); 428 429 429 430 /* draw header */ … … 434 435 DeleteObject(hbr); 435 436 } 436 437 437 438 /* if the previous button is pressed draw it depressed */ 438 439 if(IntersectRect(&rcTemp, &(ps->rcPaint), prev)) 439 { 440 { 440 441 if((infoPtr->status & MC_PREVPRESSED)) 441 442 DrawFrameControl(hdc, prev, DFC_SCROLL, 442 443 DFCS_SCROLLLEFT | DFCS_PUSHED | 443 444 (dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0)); 444 445 else /* if the previous button is pressed draw it depressed */ 445 446 DrawFrameControl(hdc, prev, DFC_SCROLL, 446 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 */ 450 451 if(IntersectRect(&rcTemp, &(ps->rcPaint), next)) 451 452 { 452 453 if((infoPtr->status & MC_NEXTPRESSED)) 453 454 DrawFrameControl(hdc, next, DFC_SCROLL, 454 455 DFCS_SCROLLRIGHT | DFCS_PUSHED | 455 456 (dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0)); 456 457 else /* if the next button is pressed draw it depressed */ … … 466 467 titlemonth->left = title->left; 467 468 titlemonth->right = title->right; 468 469 469 470 GetLocaleInfoA( LOCALE_USER_DEFAULT,LOCALE_SMONTHNAME1+infoPtr->currentMonth -1, 470 471 buf1,sizeof(buf1)); 471 472 sprintf(buf, "%s %ld", buf1, infoPtr->currentYear); 472 473 473 474 if(IntersectRect(&rcTemp, &(ps->rcPaint), titlemonth)) 474 475 { 475 DrawTextA(hdc, buf, strlen(buf), titlemonth, 476 DrawTextA(hdc, buf, strlen(buf), titlemonth, 476 477 DT_CENTER | DT_VCENTER | DT_SINGLELINE); 477 478 } … … 481 482 /* titlemonth left/right contained rect for whole titletxt('June 1999') 482 483 * 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) 484 485 */ 485 486 GetTextExtentPoint32A(hdc, buf, strlen(buf), &size); … … 489 490 titlemonth->right = titlemonth->left + size.cx; 490 491 titleyear->left = titlemonth->right; 491 492 492 493 /* draw month area */ 493 494 rcTemp.top=infoPtr->wdays.top; … … 501 502 DeleteObject(hbr); 502 503 } 503 504 504 505 /* draw line under day abbreviatons */ 505 506 506 507 MoveToEx(hdc, infoPtr->days.left + 3, title->bottom + textHeight + 1, NULL); 507 508 508 509 LineTo(hdc, rcDraw->right - 3, title->bottom + textHeight + 1); 509 510 510 511 prevMonth = infoPtr->currentMonth - 1; 511 512 if(prevMonth == 0) /* if currentMonth is january(1) prevMonth is */ … … 529 530 for(j=0; j<7; j++) { 530 531 GetLocaleInfoA( LOCALE_USER_DEFAULT,LOCALE_SABBREVDAYNAME1 + (i +j)%7, 531 532 buf,sizeof(buf)); 532 533 DrawTextA(hdc, buf, strlen(buf), days, 533 534 DT_CENTER | DT_VCENTER | DT_SINGLELINE ); … … 537 538 538 539 /* draw day numbers; first, the previous month */ 539 540 540 541 firstDay = MONTHCAL_CalculateDayOfWeek(1, infoPtr->currentMonth, infoPtr->currentYear); 541 542 day = MONTHCAL_MonthLength(prevMonth, infoPtr->currentYear) + 542 543 day = MONTHCAL_MonthLength(prevMonth, infoPtr->currentYear) + 543 544 (infoPtr->firstDay + 7 - firstDay)%7 + 1; 544 545 if (day > MONTHCAL_MonthLength(prevMonth, infoPtr->currentYear)) … … 553 554 if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay)) 554 555 { 555 MONTHCAL_DrawDay(hdc, infoPtr, day, prevMonth, i, 0, 556 MONTHCAL_DrawDay(hdc, infoPtr, day, prevMonth, i, 0, 556 557 infoPtr->monthdayState[m] & mask); 557 558 } … … 577 578 { 578 579 579 MONTHCAL_DrawDay(hdc, infoPtr, day, infoPtr->currentMonth, i, 0, 580 580 MONTHCAL_DrawDay(hdc, infoPtr, day, infoPtr->currentMonth, i, 0, 581 infoPtr->monthdayState[m] & mask); 581 582 582 583 if((infoPtr->currentMonth==infoPtr->todaysDate.wMonth) && 583 584 (day==infoPtr->todaysDate.wDay) && 584 585 (infoPtr->currentYear == infoPtr->todaysDate.wYear)) { 585 586 if(!(dwStyle & MCS_NOTODAYCIRCLE)) 586 587 MONTHCAL_CircleDay(hdc, infoPtr, day, infoPtr->currentMonth); 587 588 } 588 589 } … … 595 596 j = 1; /* move to the 2nd week of the current month */ 596 597 i = 0; /* move back to sunday */ 597 while(day <= MONTHCAL_MonthLength(infoPtr->currentMonth, infoPtr->currentYear)) { 598 while(day <= MONTHCAL_MonthLength(infoPtr->currentMonth, infoPtr->currentYear)) { 598 599 MONTHCAL_CalcDayRect(infoPtr, &rcDay, i, j); 599 600 if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay)) … … 604 605 if((infoPtr->currentMonth==infoPtr->todaysDate.wMonth) && 605 606 (day==infoPtr->todaysDate.wDay) && 606 (infoPtr->currentYear == infoPtr->todaysDate.wYear)) 607 if(!(dwStyle & MCS_NOTODAYCIRCLE)) 608 607 (infoPtr->currentYear == infoPtr->todaysDate.wYear)) 608 if(!(dwStyle & MCS_NOTODAYCIRCLE)) 609 MONTHCAL_CircleDay(hdc, infoPtr, day, infoPtr->currentMonth); 609 610 } 610 611 mask<<=1; … … 627 628 MONTHCAL_CalcDayRect(infoPtr, &rcDay, i, j); 628 629 if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay)) 629 { 630 { 630 631 MONTHCAL_DrawDay(hdc, infoPtr, day, infoPtr->currentMonth + 1, i, j, 631 632 infoPtr->monthdayState[m] & mask); 632 633 } 633 634 634 635 mask<<=1; 635 636 day++; 636 i++; 637 i++; 637 638 if(i==7) { /* past saturday, go to next week's sunday */ 638 639 i = 0; … … 650 651 if(!(dwStyle & MCS_NOTODAYCIRCLE)) { 651 652 /*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 653 MONTHCAL_CircleDay(hdc, infoPtr, 654 day+MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear), 655 infoPtr->currentMonth); 655 656 offset+=textWidth; 656 657 } 657 658 if (!LoadStringA(COMCTL32_hModule,IDM_TODAY,buf1,sizeof(buf1))) 658 659 { 659 660 660 WARN("Can't load resource\n"); 661 strcpy(buf1,"Today:"); 661 662 } 662 663 MONTHCAL_CalcDayRect(infoPtr, &rtoday, 1, 6); … … 674 675 } 675 676 676 /*eventually draw week numbers*/ 677 /*eventually draw week numbers*/ 677 678 if(dwStyle & MCS_WEEKNUMBERS) { 678 679 /* display weeknumbers*/ … … 682 683 LOCALE_IFIRSTWEEKOFYEAR == 0 (e.g US?): 683 684 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): 685 686 First week of year must contain 4 days of the new year 686 687 LOCALE_IFIRSTWEEKOFYEAR == 1 (what contries?) … … 688 689 */ 689 690 GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_IFIRSTWEEKOFYEAR, 690 691 buf, sizeof(buf)); 691 692 sscanf(buf, "%d", &weeknum); 692 693 switch (weeknum) 693 694 { 694 695 case 1: mindays = 6; 695 696 break; 696 697 case 2: mindays = 3; 697 698 break; 698 699 case 0: 699 700 default: 700 701 mindays = 0; 701 702 } 702 703 if (infoPtr->currentMonth < 2) 703 704 { 704 705 706 if ((infoPtr->firstDay +7 - weeknum1)%7 > mindays) 707 708 709 710 711 for(i=0; i<11; i++) 712 713 714 715 716 717 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 } 719 720 } 720 721 else 721 722 { 722 723 for(i=0; i<prevMonth-1; i++) 724 725 726 727 728 729 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++; 730 731 } 731 732 days->left = infoPtr->weeknums.left; … … 735 736 for(i=0; i<6; i++) { 736 737 if((i==0)&&(weeknum>50)) 737 738 739 740 738 { 739 sprintf(buf, "%d", weeknum); 740 weeknum=0; 741 } 741 742 else if((i==5)&&(weeknum>47)) 742 743 744 743 { 744 sprintf(buf, "%d", 1); 745 } 745 746 else 746 747 sprintf(buf, "%d", weeknum + i); 747 748 DrawTextA(hdc, buf, -1, days, DT_CENTER | DT_VCENTER | DT_SINGLELINE ); 748 749 days->top+=infoPtr->height_increment; 749 750 days->bottom+=infoPtr->height_increment; 750 751 } 751 752 752 753 MoveToEx(hdc, infoPtr->weeknums.right, infoPtr->weeknums.top + 3 , NULL); 753 754 LineTo(hdc, infoPtr->weeknums.right, infoPtr->weeknums.bottom ); 754 755 755 756 } 756 757 /* currentFont was font at entering Refresh */ 757 758 758 759 SetBkColor(hdc, oldBkColor); 759 SelectObject(hdc, currentFont); 760 SelectObject(hdc, currentFont); 760 761 SetTextColor(hdc, oldTextColor); 761 762 } 762 763 763 764 764 static LRESULT 765 static LRESULT 765 766 MONTHCAL_GetMinReqRect(HWND hwnd, WPARAM wParam, LPARAM lParam) 766 767 { … … 768 769 LPRECT lpRect = (LPRECT) lParam; 769 770 TRACE("%x %lx\n", wParam, lParam); 770 771 771 772 /* validate parameters */ 772 773 … … 781 782 782 783 783 static LRESULT 784 static LRESULT 784 785 MONTHCAL_GetColor(HWND hwnd, WPARAM wParam, LPARAM lParam) 785 786 { … … 807 808 808 809 809 static LRESULT 810 static LRESULT 810 811 MONTHCAL_SetColor(HWND hwnd, WPARAM wParam, LPARAM lParam) 811 812 { … … 847 848 848 849 849 static LRESULT 850 static LRESULT 850 851 MONTHCAL_GetMonthDelta(HWND hwnd, WPARAM wParam, LPARAM lParam) 851 852 { … … 853 854 854 855 TRACE("%x %lx\n", wParam, lParam); 855 856 856 857 if(infoPtr->delta) 857 858 return infoPtr->delta; … … 861 862 862 863 863 static LRESULT 864 static LRESULT 864 865 MONTHCAL_SetMonthDelta(HWND hwnd, WPARAM wParam, LPARAM lParam) 865 866 { … … 868 869 869 870 TRACE("%x %lx\n", wParam, lParam); 870 871 871 872 infoPtr->delta = (int)wParam; 872 873 return prev; … … 874 875 875 876 876 static LRESULT 877 static LRESULT 877 878 MONTHCAL_GetFirstDayOfWeek(HWND hwnd, WPARAM wParam, LPARAM lParam) 878 879 { 879 880 MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd); 880 881 881 882 return infoPtr->firstDay; 882 883 } … … 887 888 /* FIXME: this needs to be implemented properly in MONTHCAL_Refresh() */ 888 889 /* FIXME: we need more error checking here */ 889 static LRESULT 890 static LRESULT 890 891 MONTHCAL_SetFirstDayOfWeek(HWND hwnd, WPARAM wParam, LPARAM lParam) 891 892 { … … 903 904 { 904 905 GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_IFIRSTDAYOFWEEK, 905 906 buf, sizeof(buf)); 906 907 TRACE("%s %d\n", buf, strlen(buf)); 907 908 if(sscanf(buf, "%d", &day) == 1) 908 909 infoPtr->firstDay = day; 909 910 else 910 911 infoPtr->firstDay = 0; 911 912 } 912 913 return prev; … … 916 917 /* FIXME: fill this in */ 917 918 static LRESULT 918 MONTHCAL_GetMonthRange(HWND hwnd, WPARAM wParam, LPARAM lParam) 919 MONTHCAL_GetMonthRange(HWND hwnd, WPARAM wParam, LPARAM lParam) 919 920 { 920 921 MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd); … … 937 938 938 939 /* FIXME: are validated times taken from current date/time or simply 939 * copied? 940 * copied? 940 941 * FIXME: check whether MCM_GETMONTHRANGE shows correct result after 941 942 * adjusting range with MCM_SETRANGE … … 950 951 951 952 TRACE("%x %lx\n", wParam, lParam); 952 953 953 954 if(wParam & GDTR_MAX) { 954 955 if(MONTHCAL_ValidateTime(lprgSysTimeArray[1])){ … … 973 974 infoPtr->monthRange = infoPtr->maxDate.wMonth - infoPtr->minDate.wMonth; 974 975 975 if(infoPtr->monthRange!=prev) { 976 COMCTL32_ReAlloc(infoPtr->monthdayState, 977 976 if(infoPtr->monthRange!=prev) { 977 COMCTL32_ReAlloc(infoPtr->monthdayState, 978 infoPtr->monthRange * sizeof(MONTHDAYSTATE)); 978 979 } 979 980 … … 983 984 984 985 /* 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 986 987 * SetRange. Is this the right behavior? 987 988 */ … … 1015 1016 if(iMonths!=infoPtr->monthRange) return 0; 1016 1017 1017 for(i=0; i<iMonths; i++) 1018 for(i=0; i<iMonths; i++) 1018 1019 infoPtr->monthdayState[i] = dayStates[i]; 1019 1020 return 1; 1020 1021 } 1021 1022 1022 static LRESULT 1023 static LRESULT 1023 1024 MONTHCAL_GetCurSel(HWND hwnd, WPARAM wParam, LPARAM lParam) 1024 1025 { … … 1036 1037 /* FIXME: if the specified date is not visible, make it visible */ 1037 1038 /* FIXME: redraw? */ 1038 static LRESULT 1039 static LRESULT 1039 1040 MONTHCAL_SetCurSel(HWND hwnd, WPARAM wParam, LPARAM lParam) 1040 1041 { … … 1057 1058 1058 1059 1059 static LRESULT 1060 static LRESULT 1060 1061 MONTHCAL_GetMaxSelCount(HWND hwnd, WPARAM wParam, LPARAM lParam) 1061 1062 { … … 1067 1068 1068 1069 1069 static LRESULT 1070 static LRESULT 1070 1071 MONTHCAL_SetMaxSelCount(HWND hwnd, WPARAM wParam, LPARAM lParam) 1071 1072 { … … 1081 1082 1082 1083 1083 static LRESULT 1084 static LRESULT 1084 1085 MONTHCAL_GetSelRange(HWND hwnd, WPARAM wParam, LPARAM lParam) 1085 1086 { … … 1100 1101 return TRUE; 1101 1102 } 1102 1103 1103 1104 return FALSE; 1104 1105 } 1105 1106 1106 1107 1107 static LRESULT 1108 static LRESULT 1108 1109 MONTHCAL_SetSelRange(HWND hwnd, WPARAM wParam, LPARAM lParam) 1109 1110 { … … 1124 1125 return TRUE; 1125 1126 } 1126 1127 1127 1128 return FALSE; 1128 1129 } 1129 1130 1130 1131 1131 static LRESULT 1132 static LRESULT 1132 1133 MONTHCAL_GetToday(HWND hwnd, WPARAM wParam, LPARAM lParam) 1133 1134 { … … 1145 1146 1146 1147 1147 static LRESULT 1148 static LRESULT 1148 1149 MONTHCAL_SetToday(HWND hwnd, WPARAM wParam, LPARAM lParam) 1149 1150 { … … 1170 1171 DWORD retval; 1171 1172 int day,wday,wnum; 1172 1173 1173 1174 1174 1175 x = lpht->pt.x; 1175 1176 y = lpht->pt.y; 1176 1177 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 1182 1183 1184 1185 1186 1187 1188 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); 1189 1190 */ 1190 1191 1191 1192 /* are we in the header? */ 1192 1193 1193 1194 if(PtInRect(&infoPtr->title, lpht->pt)) { 1194 1195 if(PtInRect(&infoPtr->titlebtnprev, lpht->pt)) { … … 1208 1209 goto done; 1209 1210 } 1210 1211 1211 1212 retval = MCHT_TITLE; 1212 1213 goto done; 1213 1214 } 1214 1215 1215 1216 day = MONTHCAL_CalcDayFromPos(infoPtr,x,y,&wday,&wnum); 1216 1217 if(PtInRect(&infoPtr->wdays, lpht->pt)) { … … 1218 1219 lpht->st.wYear = infoPtr->currentYear; 1219 1220 lpht->st.wMonth = (day < 1)? infoPtr->currentMonth -1 : infoPtr->currentMonth; 1220 lpht->st.wDay = (day < 1)? 1221 lpht->st.wDay = (day < 1)? 1221 1222 MONTHCAL_MonthLength(infoPtr->currentMonth-1,infoPtr->currentYear) -day : day; 1222 1223 goto done; 1223 1224 } 1224 if(PtInRect(&infoPtr->weeknums, lpht->pt)) { 1225 retval = MCHT_CALENDARWEEKNUM; 1225 if(PtInRect(&infoPtr->weeknums, lpht->pt)) { 1226 retval = MCHT_CALENDARWEEKNUM; 1226 1227 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)) ? 1229 1230 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)) ? 1233 1234 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)) 1237 1238 { 1238 1239 lpht->st.wYear = infoPtr->currentYear; 1239 if ( day < 1) 1240 1241 1242 1243 1244 1245 1246 1247 1248 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 } 1250 1251 else if (day > MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear)) 1251 1252 1253 1254 1255 1256 1257 1258 1259 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 } 1261 1262 else { 1262 1263 1264 1263 retval = MCHT_CALENDARDATE; 1264 lpht->st.wMonth = infoPtr->currentMonth; 1265 lpht->st.wDay = day; 1265 1266 } 1266 1267 goto done; 1267 1268 } 1268 1269 if(PtInRect(&infoPtr->todayrect, lpht->pt)) { 1269 retval = MCHT_TODAYLINK; 1270 retval = MCHT_TODAYLINK; 1270 1271 goto done; 1271 1272 } 1272 1273 1273 1274 1274 1275 /* Hit nothing special? What's left must be background :-) */ 1275 1276 retval = MCHT_CALENDARBK; 1277 done: 1276 1277 retval = MCHT_CALENDARBK; 1278 done: 1278 1279 lpht->uHit = retval; 1279 1280 return retval; … … 1300 1301 nmds.nmhdr.idFrom = GetWindowLongA(hwnd, GWL_ID); 1301 1302 nmds.nmhdr.code = MCN_GETDAYSTATE; 1302 nmds.cDayState 1303 nmds.prgDayState 1303 nmds.cDayState = infoPtr->monthRange; 1304 nmds.prgDayState = COMCTL32_Alloc(infoPtr->monthRange * sizeof(MONTHDAYSTATE)); 1304 1305 1305 1306 SendMessageA(GetParent(hwnd), WM_NOTIFY, … … 1330 1331 nmds.nmhdr.idFrom = GetWindowLongA(hwnd, GWL_ID); 1331 1332 nmds.nmhdr.code = MCN_GETDAYSTATE; 1332 nmds.cDayState 1333 nmds.prgDayState = COMCTL32_Alloc1333 nmds.cDayState = infoPtr->monthRange; 1334 nmds.prgDayState = COMCTL32_Alloc 1334 1335 (infoPtr->monthRange * sizeof(MONTHDAYSTATE)); 1335 1336 … … 1348 1349 POINT menupoint; 1349 1350 char buf[32]; 1350 1351 1351 1352 hMenu = CreatePopupMenu(); 1352 1353 if (!LoadStringA(COMCTL32_hModule,IDM_GOTODAY,buf,sizeof(buf))) … … 1360 1361 ClientToScreen(hwnd, &menupoint); 1361 1362 if( TrackPopupMenu(hMenu,TPM_RIGHTBUTTON| TPM_NONOTIFY|TPM_RETURNCMD, 1362 1363 menupoint.x,menupoint.y,0,hwnd,NULL)) 1363 1364 { 1364 1365 infoPtr->currentMonth=infoPtr->todaysDate.wMonth; 1365 1366 infoPtr->currentYear=infoPtr->todaysDate.wYear; 1366 1367 InvalidateRect(hwnd, NULL, FALSE); 1367 } 1368 } 1368 1369 return 0; 1369 1370 } … … 1381 1382 POINT menupoint; 1382 1383 TRACE("%x %lx\n", wParam, lParam); 1383 1384 1384 1385 if (infoPtr->hWndYearUpDown) 1385 1386 { 1386 1387 infoPtr->currentYear=SendMessageA( infoPtr->hWndYearUpDown, UDM_SETPOS, (WPARAM) 0,(LPARAM)0); 1387 1388 if(!DestroyWindow(infoPtr->hWndYearUpDown)) 1388 1389 1390 1389 { 1390 FIXME("Can't destroy Updown Control\n"); 1391 } 1391 1392 else 1392 1393 infoPtr->hWndYearUpDown=0; 1393 1394 if(!DestroyWindow(infoPtr->hWndYearEdit)) 1394 1395 1396 1395 { 1396 FIXME("Can't destroy Updown Control\n"); 1397 } 1397 1398 else 1398 1399 infoPtr->hWndYearEdit=0; 1399 1400 InvalidateRect(hwnd, NULL, FALSE); 1400 1401 } 1401 1402 1402 1403 ht.pt.x = (INT)LOWORD(lParam); 1403 1404 ht.pt.y = (INT)HIWORD(lParam); … … 1414 1415 return TRUE; 1415 1416 } 1416 if(hit == MCHT_TITLEBTNPREV){ 1417 if(hit == MCHT_TITLEBTNPREV){ 1417 1418 MONTHCAL_GoToPrevMonth(hwnd, infoPtr); 1418 1419 infoPtr->status = MC_PREVPRESSED; … … 1424 1425 if(hit == MCHT_TITLEMONTH) { 1425 1426 hMenu = CreatePopupMenu(); 1426 1427 1427 1428 for (i=0; i<12;i++) 1428 1429 { 1429 1430 1431 1430 GetLocaleInfoA( LOCALE_USER_DEFAULT,LOCALE_SMONTHNAME1+i, 1431 buf,sizeof(buf)); 1432 AppendMenuA(hMenu, MF_STRING|MF_ENABLED,i+1, buf); 1432 1433 } 1433 1434 menupoint.x=infoPtr->titlemonth.right; … … 1435 1436 ClientToScreen(hwnd, &menupoint); 1436 1437 i= TrackPopupMenu(hMenu,TPM_LEFTALIGN | TPM_NONOTIFY | TPM_RIGHTBUTTON | TPM_RETURNCMD, 1437 1438 menupoint.x,menupoint.y,0,hwnd,NULL); 1438 1439 if ((i>0) && (i<13)) 1439 1440 { 1440 1441 1441 infoPtr->currentMonth=i; 1442 InvalidateRect(hwnd, NULL, FALSE); 1442 1443 } 1443 1444 } 1444 1445 if(hit == MCHT_TITLEYEAR) { 1445 1446 infoPtr->hWndYearEdit=CreateWindowExA(0, 1446 1447 1448 1449 1450 1451 1452 1453 (HMENU)NULL, 1454 (HINSTANCE)NULL, 1455 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); 1456 1457 infoPtr->hWndYearUpDown=CreateWindowExA(0, 1457 1458 1459 1460 1461 1462 1463 1464 (HMENU)NULL, 1465 (HINSTANCE)NULL, 1466 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); 1467 1468 SendMessageA( infoPtr->hWndYearUpDown, UDM_SETRANGE, (WPARAM) 0, MAKELONG (9999, 1753)); 1468 1469 SendMessageA( infoPtr->hWndYearUpDown, UDM_SETBUDDY, (WPARAM) infoPtr->hWndYearEdit, (LPARAM)0 ); 1469 1470 SendMessageA( infoPtr->hWndYearUpDown, UDM_SETPOS, (WPARAM) 0,(LPARAM)infoPtr->currentYear ); 1470 1471 return TRUE; 1471 1472 1472 1473 } 1473 1474 if(hit == MCHT_TODAYLINK) { … … 1487 1488 MONTHCAL_CopyTime(&nmsc.stSelStart, &infoPtr->minSel); 1488 1489 MONTHCAL_CopyTime(&nmsc.stSelEnd, &infoPtr->maxSel); 1489 1490 1490 1491 SendMessageA(GetParent(hwnd), WM_NOTIFY, 1491 1492 (WPARAM)nmsc.nmhdr.idFrom,(LPARAM)&nmsc); … … 1493 1494 MONTHCAL_CopyTime(&ht.st, &selArray[0]); 1494 1495 MONTHCAL_CopyTime(&ht.st, &selArray[1]); 1495 MONTHCAL_SetSelRange(hwnd,0,(LPARAM) &selArray); 1496 MONTHCAL_SetSelRange(hwnd,0,(LPARAM) &selArray); 1496 1497 1497 1498 /* redraw both old and new days if the selected day changed */ … … 1546 1547 return TRUE; 1547 1548 } 1548 if(hit == MCHT_CALENDARDATEPREV){ 1549 if(hit == MCHT_CALENDARDATEPREV){ 1549 1550 MONTHCAL_GoToPrevMonth(hwnd, infoPtr); 1550 1551 InvalidateRect(hwnd, NULL, FALSE); … … 1564 1565 MONTHCAL_CopyTime(&nmsc.stSelStart, &infoPtr->minSel); 1565 1566 MONTHCAL_CopyTime(&nmsc.stSelEnd, &infoPtr->maxSel); 1566 1567 1567 1568 SendMessageA(GetParent(hwnd), WM_NOTIFY, 1568 1569 (WPARAM)nmsc.nmhdr.idFrom, (LPARAM)&nmsc); 1569 1570 1570 1571 /* redraw if necessary */ 1571 1572 if(redraw) 1572 1573 InvalidateRect(hwnd, NULL, FALSE); 1573 1574 1574 1575 return 0; 1575 1576 } … … 1586 1587 1587 1588 switch(wParam) { 1588 case MC_NEXTMONTHTIMER: 1589 case MC_NEXTMONTHTIMER: 1589 1590 redraw = TRUE; 1590 1591 MONTHCAL_GoToNextMonth(hwnd, infoPtr); … … 1618 1619 ht.pt.x = LOWORD(lParam); 1619 1620 ht.pt.y = HIWORD(lParam); 1620 1621 1621 1622 hit = MONTHCAL_HitTest(hwnd, (LPARAM)&ht); 1622 1623 1623 1624 /* not on the calendar date numbers? bail out */ 1624 1625 TRACE("hit:%x\n",hit); … … 1638 1639 if(infoPtr->firstSelDay==selArray[0].wDay) i=1; 1639 1640 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) { 1641 1642 /* 1st time we get here: selArray[0]=selArray[1]) */ 1642 1643 /* if we're still at the first selected date, return */ … … 1644 1645 if(selday<infoPtr->firstSelDay) i = 0; 1645 1646 } 1646 1647 1647 1648 if(abs(infoPtr->firstSelDay - selday) >= infoPtr->maxSelCount) { 1648 1649 if(selday>infoPtr->firstSelDay) … … 1651 1652 selday = infoPtr->firstSelDay - infoPtr->maxSelCount; 1652 1653 } 1653 1654 1654 1655 if(selArray[i].wDay!=selday) { 1655 1656 TRACE("newRange:%d %d %d %d\n", infoPtr->firstSelDay, selArray[0].wDay, selArray[1].wDay, i); 1656 1657 1657 1658 selArray[i].wDay = selday; 1658 1659 … … 1712 1713 { 1713 1714 TRACE("\n"); 1714 1715 1715 1716 InvalidateRect(hwnd, NULL, FALSE); 1716 1717 … … 1769 1770 1770 1771 /* 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 1773 1774 */ 1774 1775 if(dwStyle & MCS_WEEKNUMBERS) … … 1776 1777 else 1777 1778 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; 1780 1781 infoPtr->left_offset = (infoPtr->rcDraw.right - infoPtr->rcDraw.left) - (infoPtr->width_increment * xdiv); 1781 1782 infoPtr->top_offset = (infoPtr->rcDraw.bottom - infoPtr->rcDraw.top) - (infoPtr->height_increment * 10.0); … … 1790 1791 rcDraw->bottom = rcDraw->top + 9 * infoPtr->textHeight + 5; 1791 1792 }*/ 1792 1793 1793 1794 /* calculate title area */ 1794 1795 title->top = rcClient->top; … … 1805 1806 next->right = title->right - 6; 1806 1807 next->left = next->right - (title->bottom - title->top); 1807 1808 1808 1809 /* titlemonth->left and right change based upon the current month */ 1809 1810 /* and are recalculated in refresh as the current month may change */ … … 1811 1812 titlemonth->top = titleyear->top = title->top + (infoPtr->height_increment)/2; 1812 1813 titlemonth->bottom = titleyear->bottom = title->bottom - (infoPtr->height_increment)/2; 1813 1814 1814 1815 /* setup the dimensions of the rectangle we draw the names of the */ 1815 1816 /* days of the week in */ 1816 1817 weeknumrect->left =infoPtr->left_offset; 1817 if(dwStyle & MCS_WEEKNUMBERS) 1818 if(dwStyle & MCS_WEEKNUMBERS) 1818 1819 weeknumrect->right=prev->right; 1819 1820 else … … 1823 1824 wdays->top = title->bottom ; 1824 1825 wdays->bottom = wdays->top + infoPtr->height_increment; 1825 1826 1826 1827 days->top = weeknumrect->top = wdays->bottom ; 1827 1828 days->bottom = weeknumrect->bottom = days->top + 6 * infoPtr->height_increment; 1828 1829 1829 1830 todayrect->left = rcClient->left; 1830 1831 todayrect->right = rcClient->right; … … 1832 1833 todayrect->bottom = days->bottom + infoPtr->height_increment; 1833 1834 1834 /* uncomment for excessive debugging 1835 /* uncomment for excessive debugging 1835 1836 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 1837 1838 1839 1840 1841 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); 1842 1843 */ 1843 1844 1844 1845 /* restore the originally selected font */ 1845 SelectObject(hdc, currentFont); 1846 SelectObject(hdc, currentFont); 1846 1847 1847 1848 ReleaseDC(hwnd, hdc); … … 1865 1866 { 1866 1867 MONTHCAL_INFO *infoPtr; 1867 LOGFONTA 1868 LOGFONTA logFont; 1868 1869 1869 1870 /* allocate memory for info structure */ … … 1900 1901 infoPtr->maxSelCount = 7; 1901 1902 infoPtr->monthRange = 3; 1902 infoPtr->monthdayState = COMCTL32_Alloc 1903 infoPtr->monthdayState = COMCTL32_Alloc 1903 1904 (infoPtr->monthRange * sizeof(MONTHDAYSTATE)); 1904 1905 infoPtr->titlebk = GetSysColor(COLOR_ACTIVECAPTION); … … 1907 1908 infoPtr->trailingtxt = GetSysColor(COLOR_GRAYTEXT); 1908 1909 infoPtr->bk = GetSysColor(COLOR_WINDOW); 1909 infoPtr->txt 1910 infoPtr->txt = GetSysColor(COLOR_WINDOWTEXT); 1910 1911 1911 1912 /* call MONTHCAL_UpdateSize to set all of the dimensions */ … … 2062 2063 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); 2063 2064 wndClass.lpszClassName = MONTHCAL_CLASSA; 2064 2065 2065 2066 RegisterClassA(&wndClass); 2066 2067 } -
trunk/src/comctl32/pager.c
r6380 r6644 1 /* $Id: pager.c,v 1.9 2001-09-05 12:05:01 bird Exp $ */ 1 2 /* 2 3 * Pager control … … 39 40 INT nPos; /* scroll position */ 40 41 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 */ 42 43 BOOL bForward; /* forward WM_MOUSEMOVE msgs to the contained wnd */ 43 44 INT TLbtnState; /* state of top or left btn */ … … 57 58 #define REPEAT_DELAY 50 58 59 59 /* the horizontal arrows are: 60 /* the horizontal arrows are: 60 61 * 61 62 * 01234 01234 … … 66 67 * 5 ** ** 67 68 * 6 * * 68 * 7 69 * 7 69 70 * 70 71 */ … … 74 75 INT x, y, w, h; 75 76 HPEN hOldPen; 76 77 77 78 w = r.right - r.left + 1; 78 79 h = r.bottom - r.top + 1; … … 107 108 } 108 109 109 /* the vertical arrows are: 110 /* the vertical arrows are: 110 111 * 111 112 * 01234567 01234567 112 * 1****** ** 113 * 1****** ** 113 114 * 2 **** **** 114 115 * 3 ** ****** … … 121 122 INT x, y, w, h; 122 123 HPEN hOldPen; 123 124 124 125 w = r.right - r.left + 1; 125 126 h = r.bottom - r.top + 1; … … 165 166 166 167 if ((rc.right - rc.left <= 0) || (rc.bottom - rc.top <= 0)) 167 return; 168 return; 168 169 169 170 hBrush = CreateSolidBrush(clrBk); … … 172 173 FillRect(hdc, &rc, hBrush); 173 174 174 if (btnState == PGF_HOT) 175 if (btnState == PGF_HOT) 175 176 { 176 177 DrawEdge( hdc, &rc, BDR_RAISEDINNER, BF_RECT); … … 180 181 PAGER_DrawVertArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft); 181 182 } 182 else if (btnState == PGF_NORMAL) 183 else if (btnState == PGF_NORMAL) 183 184 { 184 185 DrawEdge (hdc, &rc, BDR_OUTER, BF_FLAT); … … 188 189 PAGER_DrawVertArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft); 189 190 } 190 else if (btnState == PGF_DEPRESSED) 191 else if (btnState == PGF_DEPRESSED) 191 192 { 192 193 DrawEdge( hdc, &rc, BDR_SUNKENOUTER, BF_RECT); … … 196 197 PAGER_DrawVertArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft); 197 198 } 198 else if (btnState == PGF_GRAYED) 199 else if (btnState == PGF_GRAYED) 199 200 { 200 201 DrawEdge (hdc, &rc, BDR_OUTER, BF_FLAT); … … 233 234 PAGER_GetButtonState (HWND hwnd, WPARAM wParam, LPARAM lParam) 234 235 { 235 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 236 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 236 237 LRESULT btnState = PGF_INVISIBLE; 237 238 INT btn = (INT)lParam; … … 250 251 PAGER_GetPos(HWND hwnd) 251 252 { 252 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 253 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 253 254 TRACE("[%04x] returns %d\n", hwnd, infoPtr->nPos); 254 255 return (LRESULT)infoPtr->nPos; … … 258 259 PAGER_GetButtonSize(HWND hwnd) 259 260 { 260 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 261 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 261 262 TRACE("[%04x] returns %d\n", hwnd, infoPtr->nButtonSize); 262 263 return (LRESULT)infoPtr->nButtonSize; … … 266 267 PAGER_GetBorder(HWND hwnd) 267 268 { 268 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 269 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 269 270 TRACE("[%04x] returns %d\n", hwnd, infoPtr->nBorder); 270 271 return (LRESULT)infoPtr->nBorder; … … 274 275 PAGER_GetBkColor(HWND hwnd) 275 276 { 276 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 277 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 277 278 TRACE("[%04x] returns %06lx\n", hwnd, infoPtr->clrBk); 278 279 return (LRESULT)infoPtr->clrBk; 279 280 } 280 281 281 static void 282 PAGER_CalcSize (HWND hwnd, INT* size, BOOL getWidth) 282 static void 283 PAGER_CalcSize (HWND hwnd, INT* size, BOOL getWidth) 283 284 { 284 285 NMPGCALCSIZE nmpgcs; … … 333 334 infoPtr->nHeight = wndSize; 334 335 335 TRACE("[%04x] SWP %dx%d at (%d,%d)\n", hwnd, 336 TRACE("[%04x] SWP %dx%d at (%d,%d)\n", hwnd, 336 337 infoPtr->nWidth, infoPtr->nHeight, 337 338 0, -nPos); … … 379 380 } 380 381 381 static void 382 static void 382 383 PAGER_GrayAndRestoreBtns(PAGER_INFO* infoPtr, INT scrollRange, 383 384 BOOL* needsResize, BOOL* needsRepaint) … … 416 417 417 418 418 static void 419 static void 419 420 PAGER_NormalizeBtns(PAGER_INFO* infoPtr, BOOL* needsRepaint) 420 421 { … … 432 433 } 433 434 434 static void 435 static void 435 436 PAGER_HideGrayBtns(PAGER_INFO* infoPtr, BOOL* needsResize) 436 437 { … … 464 465 465 466 if (resizeClient) /* initiate NCCalcSize to resize client wnd */ 466 SetWindowPos(hwnd, 0,0,0,0,0, 467 SetWindowPos(hwnd, 0,0,0,0,0, 467 468 SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | 468 469 SWP_NOZORDER | SWP_NOACTIVATE); 469 470 470 471 if (repaintBtns) 471 SendMessageA(hwnd, WM_NCPAINT, 0, 0); 472 } 473 474 static LRESULT 472 SendMessageA(hwnd, WM_NCPAINT, 0, 0); 473 } 474 475 static LRESULT 475 476 PAGER_SetPos(HWND hwnd, INT newPos, BOOL fromBtnPress) 476 477 { … … 518 519 } 519 520 520 static void 521 static void 521 522 PAGER_SetFixedWidth(HWND hwnd, PAGER_INFO* infoPtr) 522 523 { … … 544 545 545 546 /* 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, 547 548 SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER); 548 549 549 550 550 551 TRACE("[%04x] infoPtr->nWidth set to %d\n", 551 552 } 553 554 static void 552 hwnd, infoPtr->nWidth); 553 } 554 555 static void 555 556 PAGER_SetFixedHeight(HWND hwnd, PAGER_INFO* infoPtr) 556 557 { … … 578 579 579 580 /* 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, 581 582 SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER); 582 583 583 584 TRACE("[%04x] infoPtr->nHeight set to %d\n", 584 585 hwnd, infoPtr->nHeight); 585 586 } 586 587 … … 601 602 PAGER_SetPos(hwnd, 0, FALSE); 602 603 } 603 else 604 else 604 605 { 605 606 PAGER_UpdateBtns(hwnd, infoPtr, scrollRange, TRUE); … … 700 701 nmpgScroll.hdr.code = PGN_SCROLL; 701 702 702 GetWindowRect(hwnd, &rcWnd); 703 GetClientRect(hwnd, &nmpgScroll.rcParent); 703 GetWindowRect(hwnd, &rcWnd); 704 GetClientRect(hwnd, &nmpgScroll.rcParent); 704 705 nmpgScroll.iXpos = nmpgScroll.iYpos = 0; 705 706 nmpgScroll.iDir = dir; … … 716 717 } 717 718 nmpgScroll.iScroll -= 2*infoPtr->nButtonSize; 718 719 719 720 SendMessageA (hwnd, WM_NOTIFY, 720 721 (WPARAM)nmpgScroll.hdr.idFrom, (LPARAM)&nmpgScroll); 721 722 722 723 TRACE("[%04x] PGN_SCROLL returns iScroll=%d\n", hwnd, nmpgScroll.iScroll); 723 724 … … 769 770 FIXME("[%04x] Drag and Drop style is not implemented yet.\n", hwnd); 770 771 /* 771 772 773 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 */ 775 776 if (!(dwStyle & PGS_HORZ) && !(dwStyle & PGS_VERT)) 776 777 { … … 800 801 /* 801 802 * 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. 803 804 * On exit, the struct should contain the screen 804 805 * coordinates of the corresponding window's client area. 805 806 */ 806 807 807 808 if (PAGER_IsHorizontal(hwnd)) 808 809 { 809 810 if (infoPtr->TLbtnState) /* != PGF_INVISIBLE */ 810 811 lpRect->left += infoPtr->nButtonSize; 811 if (infoPtr->BRbtnState) 812 if (infoPtr->BRbtnState) 812 813 lpRect->right -= infoPtr->nButtonSize; 813 814 } … … 863 864 bHorizontal, TRUE, infoPtr->TLbtnState); 864 865 PAGER_DrawButton(hdc, infoPtr->clrBk, rcBottomRight, 865 bHorizontal, FALSE, infoPtr->BRbtnState); 866 bHorizontal, FALSE, infoPtr->BRbtnState); 866 867 867 868 ReleaseDC( hwnd, hdc ); … … 869 870 } 870 871 871 static INT 872 static INT 872 873 PAGER_HitTest (HWND hwnd, LPPOINT pt) 873 874 { … … 976 977 if(!(trackinfo.dwFlags & TME_LEAVE)) { 977 978 trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */ 978 979 979 980 /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */ 980 981 /* and can properly deactivate the hot button */ … … 982 983 } 983 984 984 SendMessageA(hwnd, WM_NCPAINT, 0, 0); 985 SendMessageA(hwnd, WM_NCPAINT, 0, 0); 985 986 } 986 987 … … 1025 1026 1026 1027 TRACE("[%04x]\n", hwnd); 1027 1028 1028 1029 hit = PAGER_HitTest(hwnd, &pt); 1029 1030 … … 1033 1034 repaintBtns = infoPtr->TLbtnState != PGF_DEPRESSED; 1034 1035 infoPtr->TLbtnState = PGF_DEPRESSED; 1035 SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0); 1036 SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0); 1036 1037 } 1037 1038 else if (hit == HTRIGHT || hit == HTBOTTOM) … … 1039 1040 repaintBtns = infoPtr->BRbtnState != PGF_DEPRESSED; 1040 1041 infoPtr->BRbtnState = PGF_DEPRESSED; 1041 SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0); 1042 SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0); 1042 1043 } 1043 1044 1044 1045 if (repaintBtns) 1045 SendMessageA(hwnd, WM_NCPAINT, 0, 0); 1046 SendMessageA(hwnd, WM_NCPAINT, 0, 0); 1046 1047 1047 1048 switch(hit) … … 1130 1131 1131 1132 if (!infoPtr && (uMsg != WM_CREATE)) 1132 1133 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 1133 1134 1134 1135 switch (uMsg) … … 1156 1157 case PGM_RECALCSIZE: 1157 1158 return PAGER_RecalcSize(hwnd); 1158 1159 1159 1160 case PGM_SETBKCOLOR: 1160 1161 return PAGER_SetBkColor (hwnd, wParam, lParam); … … 1204 1205 if (infoPtr->bForward && infoPtr->hwndChild) 1205 1206 PostMessageA(infoPtr->hwndChild, WM_MOUSEMOVE, wParam, lParam); 1206 return TRUE; 1207 return TRUE; 1207 1208 1208 1209 case WM_MOUSELEAVE: 1209 return PAGER_MouseLeave (hwnd, wParam, lParam); 1210 return PAGER_MouseLeave (hwnd, wParam, lParam); 1210 1211 1211 1212 case WM_LBUTTONDOWN: … … 1219 1220 /* 1220 1221 case WM_PAINT: 1221 return PAGER_Paint (hwnd, wParam); 1222 return PAGER_Paint (hwnd, wParam); 1222 1223 */ 1223 1224 case WM_TIMER: … … 1233 1234 { 1234 1235 PAGER_Scroll(hwnd, infoPtr->direction); 1235 SetTimer(hwnd, TIMERID2, REPEAT_DELAY, 0); 1236 SetTimer(hwnd, TIMERID2, REPEAT_DELAY, 0); 1236 1237 } 1237 1238 break; … … 1266 1267 wndClass.hbrBackground = 0; 1267 1268 wndClass.lpszClassName = WC_PAGESCROLLERA; 1268 1269 1269 1270 RegisterClassA (&wndClass); 1270 1271 } -
trunk/src/comctl32/rebar.c
r6380 r6644 1 /* $Id: rebar.c,v 1.16 2001-09-05 12:05:01 bird Exp $ */ 1 2 /* 2 3 * … … 21 22 * - vertical placement 22 23 * - ComboBox and ComboBoxEx placement 23 * - center image 24 * - center image 24 25 * - Layout code. 25 26 * - Display code. … … 30 31 * rev 2,3,4 31 32 * - Implement initial version of row grouping, row separators, 32 * text and background colors. Support additional messages. 33 * text and background colors. Support additional messages. 33 34 * Support RBBS_BREAK. Implement ERASEBKGND and improve painting. 34 35 * rev 5 35 36 * - 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 37 38 * RBS_BANDBORDERS. 38 39 * rev 6 … … 62 63 * 12. Correct drawing of rebar borders and handling of RBS_BORDERS. 63 64 * rev 7d 64 * 13. Support WM_NOTIFYFORMAT (both incoming and outgoing) and do 65 * 13. Support WM_NOTIFYFORMAT (both incoming and outgoing) and do 65 66 * WM_NOTIFY correctly based on results. 66 67 * 14. Implement WM_SETREDRAW. 67 68 * 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, 69 70 * image, and text for each band is drawn by the WM_PAINT process. Change 70 71 * this code to match. … … 95 96 * 2. Following still not handled: RBBS_FIXEDBMP, RBBS_CHILDEDGE, 96 97 * RBBS_USECHEVRON 97 * 3. Following are only partially handled: 98 * 3. Following are only partially handled: 98 99 * RBS_AUTOSIZE, RBBS_VARIABLEHEIGHT 99 100 * 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 101 102 * in here). Should be fixed!! 102 103 * 6. The following messages are not implemented: … … 211 212 BOOL NtfUnicode; /* TRUE if parent wants notify in W format */ 212 213 BOOL DoRedraw; /* TRUE to acutally draw bands */ 213 UINT fStatus; /* Status flags (see below) */ 214 UINT fStatus; /* Status flags (see below) */ 214 215 HCURSOR hcurArrow; /* handle to the arrow cursor */ 215 216 HCURSOR hcurHorz; /* handle to the EW cursor */ … … 263 264 264 265 /* This is the increment that is used over the band height */ 265 /* Determined by experiment. */ 266 /* Determined by experiment. */ 266 267 #define REBARSPACE 4 267 268 … … 274 275 #define rcBrb(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.bottom : b->rcBand.right) 275 276 #define rcBw(b) ((infoPtr->dwStyle & CCS_VERT) ? (b->rcBand.bottom - b->rcBand.top) : \ 276 277 (b->rcBand.right - b->rcBand.left)) 277 278 #define ircBlt(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.left : b->rcBand.top) 278 279 #define ircBrb(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.right : b->rcBand.bottom) 279 280 #define ircBw(b) ((infoPtr->dwStyle & CCS_VERT) ? (b->rcBand.right - b->rcBand.left) : \ 280 281 (b->rcBand.bottom - b->rcBand.top)) 281 282 282 283 /* The following define determines if a given band is hidden */ … … 338 339 *line = 0; 339 340 while (band_stylename[i]) { 340 341 342 343 344 341 if (style & (1<<i)) { 342 if (*line != 0) strcat(line, " | "); 343 strcat(line, band_stylename[i]); 344 } 345 i++; 345 346 } 346 347 return line; … … 355 356 *line = 0; 356 357 while (band_maskname[i]) { 357 358 359 360 361 358 if (mask & (1<<i)) { 359 if (*line != 0) strcat(line, " | "); 360 strcat(line, band_maskname[i]); 361 } 362 i++; 362 363 } 363 364 return line; … … 370 371 if( !TRACE_ON(rebar) ) return; 371 372 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); 373 374 TRACE("band info: mask=0x%08x (%s)\n", pB->fMask, REBAR_FmtMask(pB->fMask)); 374 375 if (pB->fMask & RBBIM_STYLE) 375 376 TRACE("band info: style=0x%08x (%s)\n", pB->fStyle, REBAR_FmtStyle(pB->fStyle)); 376 377 if (pB->fMask & (RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_HEADERSIZE | RBBIM_LPARAM )) { 377 378 379 380 381 382 383 384 385 386 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"); 387 388 } 388 389 if (pB->fMask & RBBIM_CHILDSIZE) 389 390 pB->cxMinChild, 391 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); 392 393 } 393 394 … … 400 401 if(! TRACE_ON(rebar) ) return; 401 402 402 TRACE("hwnd=%04x: color=%08lx/%08lx, bands=%u, rows=%u, cSize=%ld,%ld\n", 403 404 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); 405 406 TRACE("hwnd=%04x: flags=%08x, dragStart=%d,%d, dragNow=%d,%d, ihitBand=%d\n", 406 407 408 407 iP->hwndSelf, iP->fStatus, iP->dragStart.x, iP->dragStart.y, 408 iP->dragNow.x, iP->dragNow.y, 409 iP->ihitBand); 409 410 TRACE("hwnd=%04x: style=%08lx, I'm Unicode=%s, notify in Unicode=%s, redraw=%s\n", 410 411 411 iP->hwndSelf, iP->dwStyle, (iP->bUnicode)?"TRUE":"FALSE", 412 (iP->NtfUnicode)?"TRUE":"FALSE", (iP->DoRedraw)?"TRUE":"FALSE"); 412 413 for (i = 0; i < iP->uNumBands; i++) { 413 414 415 416 417 418 TRACE("band # %u: style=0x%08x (%s)\n", 419 420 TRACE("band # %u: uMinH=%u xHeader=%u", 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 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); 445 446 } 446 447 … … 456 457 if (!parent) { 457 458 parent = GetParent (infoPtr->hwndSelf); 458 459 459 owner = GetWindow (infoPtr->hwndSelf, GW_OWNER); 460 if (owner) parent = owner; 460 461 } 461 462 return parent; … … 474 475 475 476 TRACE("window %04x, code=%08x, %s\n", parent, code, 476 477 (infoPtr->NtfUnicode) ? "via Unicode" : "via ANSI"); 477 478 478 479 if (infoPtr->NtfUnicode) 479 480 480 return SendMessageW (parent, WM_NOTIFY, (WPARAM) nmhdr->idFrom, 481 (LPARAM)nmhdr); 481 482 else 482 483 483 return SendMessageA (parent, WM_NOTIFY, (WPARAM) nmhdr->idFrom, 484 (LPARAM)nmhdr); 484 485 } 485 486 … … 492 493 notify_rebar.dwMask = 0; 493 494 if (uBand!=-1) { 494 495 496 497 498 499 500 501 502 503 504 505 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 } 507 508 } 508 509 notify_rebar.uBand = uBand; … … 521 522 /* draw caption image */ 522 523 if (lpBand->fDraw & DRAW_IMAGE) { 523 524 525 526 527 528 529 530 531 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); 532 533 } 533 534 534 535 /* draw caption text */ 535 536 if (lpBand->fDraw & DRAW_TEXT) { 536 537 538 539 540 541 542 543 544 545 546 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); 547 548 } 548 549 } … … 559 560 oldrow = infoPtr->bands[0].iRow; 560 561 for (i = 0; i < infoPtr->uNumBands; i++) { 561 562 563 if (HIDDENBAND(lpBand)) continue; 564 565 566 562 lpBand = &infoPtr->bands[i]; 563 564 if (HIDDENBAND(lpBand)) continue; 565 566 /* now draw the band */ 567 REBAR_DrawBand (hdc, infoPtr, lpBand); 567 568 568 569 } … … 572 573 static void 573 574 REBAR_FixVert (REBAR_INFO *infoPtr, UINT rowstart, UINT rowend, 574 575 /* Function: */ 575 INT mcy) 576 /* Function: */ 576 577 /* Cycle through bands in row and fix height of each band. */ 577 578 /* Also determine whether each band has changed. */ … … 585 586 for (i = (INT)rowstart; i<=(INT)rowend; i++) { 586 587 lpBand = &infoPtr->bands[i]; 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 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); 618 619 } 619 620 } … … 622 623 static void 623 624 REBAR_AdjustBands (REBAR_INFO *infoPtr, UINT rowstart, UINT rowend, 624 625 INT maxx, INT mcy) 625 626 /* Function: This routine distributes the extra space in a row. */ 626 627 /* See algorithm below. */ … … 634 635 635 636 TRACE("start=%u, end=%u, max x=%d, max y=%d\n", 636 637 rowstart, rowend, maxx, mcy); 637 638 638 639 /* ******************* Phase 1 ************************ */ … … 642 643 /* or band's ->ccx reached. */ 643 644 /* If any band modified, add any space left to last band */ 644 /* adjusted. */ 645 /* adjusted. */ 645 646 /* */ 646 647 /* ****************************************************** */ … … 650 651 last_adjusted = 0; 651 652 for (i=(INT)rowstart; i<=(INT)rowend; i++) { 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 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); 694 695 } 695 696 if ((x >= maxx) || last_adjusted) { 696 697 ERR("Phase 1 failed, x=%d, maxx=%d, start=%u, end=%u\n", 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 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; 727 728 } 728 729 … … 736 737 x = 0; 737 738 for (i=(INT)rowstart; i<=(INT)rowend; i++) { 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 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); 764 765 } 765 766 if (x >= maxx) { 766 767 ERR("Phase 2 failed, x=%d, maxx=%d, start=%u, end=%u\n", 768 769 770 771 772 773 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; 774 775 } 775 776 … … 781 782 lpBand = &infoPtr->bands[rowstart]; 782 783 ERR("Serious problem adjusting row %d, start band %d, end band %d\n", 783 784 lpBand->iRow, rowstart, rowend); 784 785 REBAR_DumpBand (infoPtr); 785 786 return; … … 805 806 if (HIDDENBAND(lpBand)) { 806 807 SetRect (&lpBand->rcChild, 807 808 809 808 lpBand->rcBand.right, lpBand->rcBand.top, 809 lpBand->rcBand.right, lpBand->rcBand.bottom); 810 continue; 810 811 } 811 812 … … 814 815 /* set initial gripper rectangle */ 815 816 SetRect (&lpBand->rcGripper, lpBand->rcBand.left, lpBand->rcBand.top, 816 817 lpBand->rcBand.left, lpBand->rcBand.bottom); 817 818 818 819 /* calculate gripper rectangle */ 819 820 if ( lpBand->fStatus & HAS_GRIPPER) { 820 821 822 823 824 825 826 827 828 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); 829 830 } 830 831 else { /* no gripper will be drawn */ 831 832 833 834 835 SetRect (&lpBand->rcCapImage, 836 837 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); 838 839 } 839 840 840 841 /* image is visible */ 841 842 if (lpBand->fStatus & HAS_IMAGE) { 842 843 844 845 846 847 848 849 850 /* update band height 851 852 853 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 } */ 855 856 } 856 857 else { 857 858 859 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); 860 861 } 861 862 862 863 /* text is visible */ 863 864 if (lpBand->fStatus & HAS_TEXT) { 864 865 lpBand->rcCapText.right = max(lpBand->rcCapText.left, 866 865 lpBand->fDraw |= DRAW_TEXT; 866 lpBand->rcCapText.right = max(lpBand->rcCapText.left, 867 lpBand->rcCapText.right-REBAR_POST_TEXT); 867 868 } 868 869 869 870 /* set initial child window rectangle if there is a child */ 870 871 if (lpBand->fMask & RBBIM_CHILD) { 871 872 873 874 875 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); 876 877 } 877 878 else { 878 879 SetRect (&lpBand->rcChild, 879 880 880 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.top, 881 lpBand->rcBand.right, lpBand->rcBand.bottom); 881 882 } 882 883 883 884 /* flag if notify required and invalidate rectangle */ 884 if (notify && 885 886 887 888 889 890 891 892 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); 893 894 } 894 895 if (lpBand->fDraw & NTF_INVALIDATE) { 895 896 lpBand->rcBand.left, 897 898 lpBand->rcBand.right + ((lpBand->fDraw & DRAW_RIGHTSEP) ? SEP_WIDTH_SIZE : 0), 899 900 901 902 903 904 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); 905 906 } 906 907 … … 925 926 926 927 for(i=rstart; i<rend; i++){ 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 SetRect (&lpBand->rcCapImage, 973 974 975 976 977 978 979 980 981 982 983 984 985 SetRect (&lpBand->rcCapText, 986 987 988 989 990 991 992 993 994 995 996 SetRect (&lpBand->rcCapText, 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 if (notify && 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 lpBand->rcBand.left, 1036 1037 lpBand->rcBand.right + ((lpBand->fDraw & DRAW_BOTTOMSEP) ? SEP_WIDTH_SIZE : 0), 1038 1039 1040 1041 1042 1043 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 } 1045 1046 1046 1047 } … … 1063 1064 1064 1065 TRACE( " old [%ld x %ld], new [%ld x %ld], client [%d x %d]\n", 1065 1066 1067 1066 infoPtr->oldSize.cx, infoPtr->oldSize.cy, 1067 infoPtr->calcSize.cx, infoPtr->calcSize.cy, 1068 rc.right, rc.bottom); 1068 1069 1069 1070 /* If we need to shrink client, then skip size test */ 1070 1071 if ((infoPtr->calcSize.cy >= rc.bottom) && 1071 1072 1073 1074 1075 1076 1077 1078 1079 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 } 1081 1082 } 1082 1083 … … 1094 1095 #if 0 1095 1096 if (GetWindowLongA (infoPtr->hwndSelf, GWL_STYLE) & WS_BORDER) { 1096 1097 InflateRect (&rc, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE)); 1097 1098 } 1098 1099 #endif 1099 1100 1100 1101 TRACE("setting to (0,0)-(%d,%d)\n", 1101 1102 rc.right - rc.left, rc.bottom - rc.top); 1102 1103 SetWindowPos (infoPtr->hwndSelf, 0, 0, 0, 1103 1104 1104 rc.right - rc.left, rc.bottom - rc.top, 1105 SWP_NOMOVE | SWP_NOZORDER | SWP_SHOWWINDOW); 1105 1106 } 1106 1107 … … 1120 1121 1121 1122 for (i = start; i < endplus; i++) { 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 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 } 1190 1191 } 1191 1192 if (!EndDeferWindowPos(deferpos)) … … 1212 1213 1213 1214 if (!(infoPtr->fStatus & BAND_NEEDS_LAYOUT)) { 1214 1215 1216 1215 TRACE("no layout done. No band changed.\n"); 1216 REBAR_DumpBand (infoPtr); 1217 return; 1217 1218 } 1218 1219 infoPtr->fStatus &= ~BAND_NEEDS_LAYOUT; … … 1221 1222 GetClientRect (infoPtr->hwndSelf, &rcClient); 1222 1223 TRACE("Client is (%d,%d)-(%d,%d)\n", 1223 1224 rcClient.left, rcClient.top, rcClient.right, rcClient.bottom); 1224 1225 1225 1226 if (lpRect) { 1226 1227 1228 1227 rcAdj = *lpRect; 1228 TRACE("adjustment rect is (%d,%d)-(%d,%d)\n", 1229 rcAdj.left, rcAdj.top, rcAdj.right, rcAdj.bottom); 1229 1230 } 1230 1231 else { … … 1243 1244 1244 1245 if (!infoPtr->DoRedraw && (clientcx == 0) && (clientcy == 0)) { 1245 1246 1247 1246 ERR("no redraw and client is zero, skip layout\n"); 1247 infoPtr->fStatus |= BAND_NEEDS_LAYOUT; 1248 return; 1248 1249 } 1249 1250 1250 1251 /* save height of original control */ 1251 if (infoPtr->dwStyle & CCS_VERT) 1252 if (infoPtr->dwStyle & CCS_VERT) 1252 1253 origheight = infoPtr->calcSize.cx; 1253 1254 else … … 1258 1259 1259 1260 TRACE("band loop constants, clientcx=%d, clientcy=%d\n", 1260 1261 clientcx, clientcy); 1261 1262 x = 0; 1262 1263 y = 0; … … 1268 1269 1269 1270 for (i = 0; i < infoPtr->uNumBands; i++) { 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 cxsep = ( ((infoPtr->dwStyle & CCS_VERT) ? y : x)==0) ? 0 : SEP_WIDTH; 1280 1281 1282 cx = lpBand->cxHeader; 1283 1284 1285 1286 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); 1287 1288 else 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 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; 1373 1374 1374 1375 } /* for (i = 0; i < infoPtr->uNumBands... */ … … 1380 1381 1381 1382 for (j = rowstart; j < infoPtr->uNumBands; j++) { 1382 1383 1384 1385 1386 1387 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 } 1389 1390 } 1390 1391 … … 1399 1400 mmcy = 0; 1400 1401 if (!(infoPtr->dwStyle & RBS_VARHEIGHT)) { 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 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; 1436 1437 } 1437 1438 … … 1445 1446 if (lpRect) { 1446 1447 INT i, j, prev_rh, new_rh, adj_rh, prev_idx, current_idx; 1447 1448 REBAR_BAND *prev, *current, *walk; 1448 1449 1449 1450 /* FIXME: problem # 2 */ 1450 if (((infoPtr->dwStyle & CCS_VERT) ? 1451 if (((infoPtr->dwStyle & CCS_VERT) ? 1451 1452 #if PROBLEM2 1452 1453 (x < adjcx) : (y < adjcy) 1453 1454 #else 1454 1455 (adjcx - x > 4) : (adjcy - y > 4) 1455 1456 #endif 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 if ((infoPtr->dwStyle & CCS_VERT) ? (x >= adjcx) : (y >= adjcy)) 1533 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 } 1537 1538 } 1538 1539 … … 1545 1546 /* clientcy/clientcx height/width of client area */ 1546 1547 1547 /* **** FIXME FIXME FIXME 1548 /* **** FIXME FIXME FIXME 1548 1549 * this does not take into account that more than one band 1549 1550 * is in a row!!!!!!!!! … … 1551 1552 1552 1553 if (((infoPtr->dwStyle & CCS_VERT) ? clientcx > x : clientcy > y) && 1553 1554 1555 1556 1557 1558 1559 1560 1561 if (((INT)lpBand->cyMaxChild < 1) || 1562 1563 1564 1565 1566 1567 1568 1569 j = ((diff / lpBand->cyIntegral) * lpBand->cyIntegral) + 1570 1571 if (j > lpBand->cyMaxChild + REBARSPACE) 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 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; 1592 1593 } 1593 1594 … … 1598 1599 1599 1600 if (infoPtr->uNumBands) { 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 if (lpBand->iRow < infoPtr->uNumRows) 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 infoPtr->uNumBands, infoPtr->uNumRows, 1643 1644 1645 1646 1647 1648 1649 (infoPtr->dwStyle & CCS_VERT) ? 1650 1651 1652 1653 1654 1655 1656 if (mcy < ircBw(lpBand)) 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 REBAR_CalcHorzBand (infoPtr, 0, infoPtr->uNumBands, 1674 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 } 1676 1677 } 1677 1678 … … 1681 1682 infoPtr->oldSize = infoPtr->calcSize; 1682 1683 if (infoPtr->dwStyle & CCS_VERT) { 1683 1684 1685 1686 1687 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; 1688 1689 } 1689 1690 else { 1690 1691 1692 1693 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; 1695 1696 } 1696 1697 … … 1749 1750 /* calculate gripper rectangle */ 1750 1751 if ( (!(lpBand->fStyle & RBBS_NOGRIPPER)) && 1751 ( (lpBand->fStyle & RBBS_GRIPPERALWAYS) || 1752 1752 ( (lpBand->fStyle & RBBS_GRIPPERALWAYS) || 1753 ( !(lpBand->fStyle & RBBS_FIXEDSIZE) && (infoPtr->uNumBands > 1))) 1753 1754 ) { 1754 1755 lpBand->fStatus |= HAS_GRIPPER; 1755 1756 if (infoPtr->dwStyle & CCS_VERT) 1756 1757 if (infoPtr->dwStyle & RBS_VERTICALGRIPPER) 1757 1758 header += (GRIPPER_HEIGHT + REBAR_PRE_GRIPPER); 1758 1759 else 1759 1760 header += (GRIPPER_WIDTH + REBAR_PRE_GRIPPER); 1760 1761 else 1761 1762 header += (REBAR_PRE_GRIPPER + GRIPPER_WIDTH); … … 1766 1767 /* image is visible */ 1767 1768 if ((lpBand->fMask & RBBIM_IMAGE) && (infoPtr->himl)) { 1768 1769 lpBand->fStatus |= HAS_IMAGE; 1769 1770 if (infoPtr->dwStyle & CCS_VERT) { 1770 1771 1772 1773 1774 1775 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 } 1777 1778 } 1778 1779 1779 1780 /* text is visible */ 1780 1781 if ((lpBand->fMask & RBBIM_TEXT) && (lpBand->lpText)) { 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 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); 1793 1794 } 1794 1795 1795 1796 /* if no gripper but either image or text, then leave space */ 1796 1797 if ((lpBand->fStatus & (HAS_IMAGE | HAS_TEXT)) && 1797 1798 1798 !(lpBand->fStatus & HAS_GRIPPER)) { 1799 header += REBAR_ALWAYS_SPACE; 1799 1800 } 1800 1801 … … 1810 1811 lpBand->ccy = lpBand->lcy; 1811 1812 if (lpBand->fMask & RBBIM_CHILDSIZE) { 1812 1813 1814 1813 if (!(lpBand->fStyle & RBBS_FIXEDSIZE)) { 1814 lpBand->offChild.cx = 4; 1815 lpBand->offChild.cy = 2; 1815 1816 } 1816 1817 lpBand->lcx = lpBand->cxMinChild; 1817 1818 1818 1819 /* Set the .cy values for CHILDSIZE case */ 1819 1820 lpBand->lcy = max(lpBand->lcy, lpBand->cyMinChild); 1820 1821 lpBand->ccy = lpBand->lcy; 1821 1822 lpBand->hcy = lpBand->lcy; 1822 1823 if (lpBand->cyMaxChild != 0xffffffff) { 1823 1824 } 1825 1826 1824 lpBand->hcy = lpBand->cyMaxChild; 1825 } 1826 if (lpBand->cyChild != 0xffffffff) 1827 lpBand->ccy = max (lpBand->cyChild, lpBand->lcy); 1827 1828 1828 1829 TRACE("_CHILDSIZE\n"); … … 1851 1852 1852 1853 if (lprbbi->fMask & RBBIM_STYLE) 1853 1854 lpBand->fStyle = lprbbi->fStyle; 1854 1855 1855 1856 if (lprbbi->fMask & RBBIM_COLORS) { 1856 1857 1857 lpBand->clrFore = lprbbi->clrFore; 1858 lpBand->clrBack = lprbbi->clrBack; 1858 1859 } 1859 1860 1860 1861 if (lprbbi->fMask & RBBIM_IMAGE) 1861 1862 lpBand->iImage = lprbbi->iImage; 1862 1863 1863 1864 if (lprbbi->fMask & RBBIM_CHILD) { 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 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 } 1878 1879 } 1879 1880 1880 1881 if (lprbbi->fMask & RBBIM_CHILDSIZE) { 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 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 } 1894 1895 } 1895 1896 1896 1897 if (lprbbi->fMask & RBBIM_SIZE) 1897 1898 lpBand->cx = lprbbi->cx; 1898 1899 1899 1900 if (lprbbi->fMask & RBBIM_BACKGROUND) 1900 1901 lpBand->hbmBack = lprbbi->hbmBack; 1901 1902 1902 1903 if (lprbbi->fMask & RBBIM_ID) 1903 1904 lpBand->wID = lprbbi->wID; 1904 1905 1905 1906 /* check for additional data */ 1906 1907 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) { 1907 1908 1909 1910 1911 1912 1913 1914 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; 1915 1916 } 1916 1917 } … … 1932 1933 for(i=0; i<infoPtr->uNumBands; i++) { 1933 1934 lpBand = &infoPtr->bands[i]; 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 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); 1990 1991 } 1991 1992 return TRUE; … … 2004 2005 if (PtInRect (&rect, *lpPt)) 2005 2006 { 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; 2058 2013 } 2059 2014 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; 2065 2066 } 2066 2067 … … 2091 2092 /* if this band is not shrinkable, then just move it */ 2092 2093 Leadjust = Readjust = movement; 2093 2094 ret = movement; 2094 2095 } 2095 2096 else { 2096 2097 if (movement < 0) { 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 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 } 2122 2123 } 2123 2124 … … 2125 2126 if (rcBlt(band) + Leadjust < 0) { 2126 2127 ERR("adjustment will fail, band %d: left=%d, right=%d, move=%d, rtn=%d\n", 2127 2128 i, Leadjust, Readjust, movement, ret); 2128 2129 } 2129 2130 … … 2132 2133 2133 2134 TRACE("band %d: left=%d, right=%d, move=%d, rtn=%d, rcBand=(%d,%d)-(%d,%d)\n", 2134 2135 2136 2135 i, Leadjust, Readjust, movement, ret, 2136 band->rcBand.left, band->rcBand.top, 2137 band->rcBand.right, band->rcBand.bottom); 2137 2138 return ret; 2138 2139 } … … 2157 2158 2158 2159 if (!(infoPtr->fStatus & BEGIN_DRAG_ISSUED)) { 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 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; 2169 2170 } 2170 2171 … … 2176 2177 for (i=0; i<infoPtr->uNumBands; i++) { 2177 2178 band = &infoPtr->bands[i]; 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 else 2188 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 } 2191 2192 } 2192 2193 if (RHeaderSum) RHeaderSum -= SEP_WIDTH; /* no separator afterlast band */ … … 2200 2201 /* limit movement to inside adjustable bands - Left */ 2201 2202 if ( (ptsmove->x < mindBand->rcBand.left) || 2202 2203 2204 2203 (ptsmove->x > maxdBand->rcBand.right) || 2204 (ptsmove->y < mindBand->rcBand.top) || 2205 (ptsmove->y > maxdBand->rcBand.bottom)) 2205 2206 return; /* should swap bands */ 2206 2207 2207 2208 if (infoPtr->dwStyle & CCS_VERT) 2208 2209 movement = ptsmove->y - ((hitBand->rcBand.top+REBAR_PRE_GRIPPER) - 2209 2210 infoPtr->ihitoffset); 2210 2211 else 2211 2212 movement = ptsmove->x - ((hitBand->rcBand.left+REBAR_PRE_GRIPPER) - 2212 2213 infoPtr->ihitoffset); 2213 2214 infoPtr->dragNow = *ptsmove; 2214 2215 2215 2216 TRACE("before: movement=%d (%d,%d), imindBand=%d, ihitBand=%d, imaxdBand=%d, LSum=%d, RSum=%d\n", 2216 2217 2217 movement, ptsmove->x, ptsmove->y, imindBand, ihitBand, 2218 imaxdBand, LHeaderSum, RHeaderSum); 2218 2219 REBAR_DumpBand (infoPtr); 2219 2220 2220 if (movement < 0) { 2221 if (movement < 0) { 2221 2222 2222 2223 /* *** Drag left/up *** */ 2223 2224 compress = rcBlt(hitBand) - rcBlt(mindBand) - 2224 2225 2226 2227 2228 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 } 2230 2231 2231 2232 for (i=ihitBand; i>=imindBand; i--) { 2232 2233 2234 2235 2236 2237 else 2238 2239 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 } 2241 2242 } 2242 2243 else { 2243 2244 BOOL first = TRUE; 2244 2245 2245 2246 /* *** Drag right/down *** */ 2246 2247 compress = rcBrb(maxdBand) - rcBlt(hitBand) - 2247 2248 2249 2250 2251 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 } 2253 2254 for (i=ihitBand-1; i<=imaxdBand; i++) { 2254 2255 2256 2257 2258 2259 2260 else 2261 2262 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 } 2264 2265 } 2265 2266 2266 2267 /* recompute all rectangles */ 2267 2268 if (infoPtr->dwStyle & CCS_VERT) { 2268 2269 2269 REBAR_CalcVertBand (infoPtr, imindBand, imaxdBand+1, 2270 FALSE); 2270 2271 } 2271 2272 else { 2272 REBAR_CalcHorzBand (infoPtr, imindBand, imaxdBand+1, 2273 2273 REBAR_CalcHorzBand (infoPtr, imindBand, imaxdBand+1, 2274 FALSE); 2274 2275 } 2275 2276 2276 2277 TRACE("bands after adjustment, see band # %d, %d\n", 2277 2278 imindBand, imaxdBand); 2278 2279 REBAR_DumpBand (infoPtr); 2279 2280 2280 SetRect (&newrect, 2281 2282 2283 2284 2281 SetRect (&newrect, 2282 mindBand->rcBand.left, 2283 mindBand->rcBand.top, 2284 maxdBand->rcBand.right, 2285 maxdBand->rcBand.bottom); 2285 2286 2286 2287 REBAR_MoveChildWindows (infoPtr, imindBand, imaxdBand+1); … … 2304 2305 2305 2306 if (uBand >= infoPtr->uNumBands) 2306 2307 return FALSE; 2307 2308 2308 2309 TRACE("deleting band %u!\n", uBand); … … 2311 2312 2312 2313 if (infoPtr->uNumBands == 1) { 2313 2314 2315 2316 2317 2318 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; 2319 2320 } 2320 2321 else { 2321 2322 REBAR_BAND *oldBands = infoPtr->bands; 2322 2323 TRACE("complex delete! [uBand=%u]\n", uBand); 2323 2324 2324 2325 2326 2327 2328 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); 2329 2330 if (uBand > 0) { 2330 2331 memcpy (&infoPtr->bands[0], &oldBands[0], … … 2337 2338 } 2338 2339 2339 2340 COMCTL32_Free (oldBands); 2340 2341 } 2341 2342 … … 2369 2370 2370 2371 if (!lParam) 2371 2372 return 0; 2372 2373 if ((UINT)wParam >= infoPtr->uNumBands) 2373 2374 return 0; 2374 2375 2375 2376 lpBand = &infoPtr->bands[(UINT)wParam]; … … 2381 2382 /* style. - GA */ 2382 2383 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; 2395 2389 } 2396 2390 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; 2398 2399 } 2399 2400 return 0; … … 2417 2418 2418 2419 if (lprbbi == NULL) 2419 2420 return FALSE; 2420 2421 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA) 2421 2422 return FALSE; 2422 2423 if ((UINT)wParam >= infoPtr->uNumBands) 2423 2424 return FALSE; 2424 2425 2425 2426 TRACE("index %u\n", (UINT)wParam); … … 2429 2430 2430 2431 if (lprbbi->fMask & RBBIM_STYLE) 2431 2432 lprbbi->fStyle = lpBand->fStyle; 2432 2433 2433 2434 if (lprbbi->fMask & RBBIM_COLORS) { 2434 2435 2436 2437 2435 lprbbi->clrFore = lpBand->clrFore; 2436 lprbbi->clrBack = lpBand->clrBack; 2437 if (lprbbi->clrBack == CLR_NONE) 2438 lprbbi->clrBack = infoPtr->clrBtnFace; 2438 2439 } 2439 2440 … … 2445 2446 lprbbi->lpText[lprbbi->cch-1] = 0; 2446 2447 } 2447 else 2448 2448 else 2449 *lprbbi->lpText = 0; 2449 2450 } 2450 2451 2451 2452 if (lprbbi->fMask & RBBIM_IMAGE) { 2452 2453 if (lpBand->fMask & RBBIM_IMAGE) 2453 2454 lprbbi->iImage = lpBand->iImage; 2454 2455 else 2455 2456 lprbbi->iImage = -1; 2456 2457 } 2457 2458 2458 2459 if (lprbbi->fMask & RBBIM_CHILD) 2459 2460 lprbbi->hwndChild = lpBand->hwndChild; 2460 2461 2461 2462 if (lprbbi->fMask & RBBIM_CHILDSIZE) { 2462 2463 2464 2465 2466 2467 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 } 2469 2470 } 2470 2471 2471 2472 if (lprbbi->fMask & RBBIM_SIZE) 2472 2473 lprbbi->cx = lpBand->cx; 2473 2474 2474 2475 if (lprbbi->fMask & RBBIM_BACKGROUND) 2475 2476 lprbbi->hbmBack = lpBand->hbmBack; 2476 2477 2477 2478 if (lprbbi->fMask & RBBIM_ID) 2478 2479 lprbbi->wID = lpBand->wID; 2479 2480 2480 2481 /* check for additional data */ 2481 2482 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) { 2482 2483 2484 2485 2486 2487 2488 2489 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; 2490 2491 } 2491 2492 … … 2503 2504 2504 2505 if (lprbbi == NULL) 2505 2506 return FALSE; 2506 2507 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW) 2507 2508 return FALSE; 2508 2509 if ((UINT)wParam >= infoPtr->uNumBands) 2509 2510 return FALSE; 2510 2511 2511 2512 TRACE("index %u\n", (UINT)wParam); … … 2515 2516 2516 2517 if (lprbbi->fMask & RBBIM_STYLE) 2517 2518 lprbbi->fStyle = lpBand->fStyle; 2518 2519 2519 2520 if (lprbbi->fMask & RBBIM_COLORS) { 2520 2521 2522 2523 2521 lprbbi->clrFore = lpBand->clrFore; 2522 lprbbi->clrBack = lpBand->clrBack; 2523 if (lprbbi->clrBack == CLR_NONE) 2524 lprbbi->clrBack = infoPtr->clrBtnFace; 2524 2525 } 2525 2526 2526 2527 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) { 2527 2528 if (lpBand->lpText && (lpBand->fMask & RBBIM_TEXT)) 2528 2529 else 2530 2529 lstrcpynW (lprbbi->lpText, lpBand->lpText, lprbbi->cch); 2530 else 2531 *lprbbi->lpText = 0; 2531 2532 } 2532 2533 2533 2534 if (lprbbi->fMask & RBBIM_IMAGE) { 2534 2535 if (lpBand->fMask & RBBIM_IMAGE) 2535 2536 lprbbi->iImage = lpBand->iImage; 2536 2537 else 2537 2538 lprbbi->iImage = -1; 2538 2539 } 2539 2540 2540 2541 if (lprbbi->fMask & RBBIM_CHILD) 2541 2542 lprbbi->hwndChild = lpBand->hwndChild; 2542 2543 2543 2544 if (lprbbi->fMask & RBBIM_CHILDSIZE) { 2544 2545 2546 2547 2548 2549 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 } 2551 2552 } 2552 2553 2553 2554 if (lprbbi->fMask & RBBIM_SIZE) 2554 2555 lprbbi->cx = lpBand->cx; 2555 2556 2556 2557 if (lprbbi->fMask & RBBIM_BACKGROUND) 2557 2558 lprbbi->hbmBack = lpBand->hbmBack; 2558 2559 2559 2560 if (lprbbi->fMask & RBBIM_ID) 2560 2561 lprbbi->wID = lpBand->wID; 2561 2562 2562 2563 /* check for additional data */ 2563 2564 if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) { 2564 2565 2566 2567 2568 2569 2570 2571 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; 2572 2573 } 2573 2574 … … 2597 2598 2598 2599 if (lpInfo == NULL) 2599 2600 return FALSE; 2600 2601 2601 2602 if (lpInfo->cbSize < sizeof (REBARINFO)) 2602 2603 return FALSE; 2603 2604 2604 2605 TRACE("getting bar info!\n"); 2605 2606 2606 2607 if (infoPtr->himl) { 2607 2608 2608 lpInfo->himl = infoPtr->himl; 2609 lpInfo->fMask |= RBIM_IMAGELIST; 2609 2610 } 2610 2611 … … 2648 2649 2649 2650 if ((iBand < 0) && ((UINT)iBand >= infoPtr->uNumBands)) 2650 2651 return FALSE; 2651 2652 if (!lprc) 2652 2653 return FALSE; 2653 2654 2654 2655 lpBand = &infoPtr->bands[iBand]; … … 2656 2657 2657 2658 TRACE("band %d, (%d,%d)-(%d,%d)\n", iBand, 2658 2659 lprc->left, lprc->top, lprc->right, lprc->bottom); 2659 2660 2660 2661 return TRUE; … … 2680 2681 2681 2682 for (i=0; i<infoPtr->uNumBands; i++) { 2682 2683 2684 2685 2686 2687 2688 2689 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; 2690 2691 } 2691 2692 … … 2715 2716 REBAR_GetUnicodeFormat (REBAR_INFO *infoPtr) 2716 2717 { 2717 TRACE("%s hwnd=0x%x\n", 2718 2718 TRACE("%s hwnd=0x%x\n", 2719 infoPtr->bUnicode ? "TRUE" : "FALSE", infoPtr->hwndSelf); 2719 2720 2720 2721 return infoPtr->bUnicode; … … 2733 2734 REBAR_HitTest (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam) 2734 2735 { 2735 LPRBHITTESTINFO lprbht = (LPRBHITTESTINFO)lParam; 2736 LPRBHITTESTINFO lprbht = (LPRBHITTESTINFO)lParam; 2736 2737 2737 2738 if (!lprbht) 2738 2739 return -1; 2739 2740 2740 2741 REBAR_InternalHitTest (infoPtr, &lprbht->pt, &lprbht->flags, &lprbht->iBand); … … 2750 2751 2751 2752 if (infoPtr == NULL) 2752 2753 return -1; 2753 2754 2754 2755 if (infoPtr->uNumBands < 1) 2755 2756 return -1; 2756 2757 2757 2758 for (i = 0; i < infoPtr->uNumBands; i++) { 2758 2759 2760 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 } 2762 2763 } 2763 2764 … … 2775 2776 2776 2777 if (infoPtr == NULL) 2777 2778 return FALSE; 2778 2779 if (lprbbi == NULL) 2779 2780 return FALSE; 2780 2781 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA) 2781 2782 return FALSE; 2782 2783 2783 2784 /* trace the index as signed to see the -1 */ … … 2786 2787 2787 2788 if (infoPtr->uNumBands == 0) { 2788 2789 2789 infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND)); 2790 uIndex = 0; 2790 2791 } 2791 2792 else { 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 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); 2811 2812 } 2812 2813 … … 2831 2832 lpBand->lpText = (LPWSTR)COMCTL32_Alloc (len*sizeof(WCHAR)); 2832 2833 MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, lpBand->lpText, len ); 2833 2834 } 2834 2835 } 2835 2836 … … 2837 2838 /* On insert of second band, revalidate band 1 to possible add gripper */ 2838 2839 if (infoPtr->uNumBands == 2) 2839 2840 REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]); 2840 2841 2841 2842 REBAR_DumpBand (infoPtr); … … 2855 2856 2856 2857 if (infoPtr == NULL) 2857 2858 return FALSE; 2858 2859 if (lprbbi == NULL) 2859 2860 return FALSE; 2860 2861 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW) 2861 2862 return FALSE; 2862 2863 2863 2864 /* trace the index as signed to see the -1 */ … … 2866 2867 2867 2868 if (infoPtr->uNumBands == 0) { 2868 2869 2869 infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND)); 2870 uIndex = 0; 2870 2871 } 2871 2872 else { 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 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); 2891 2892 } 2892 2893 … … 2907 2908 lpBand->lpText = NULL; 2908 2909 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) { 2909 2910 2911 2912 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 } 2914 2915 } 2915 2916 … … 2917 2918 /* On insert of second band, revalidate band 1 to possible add gripper */ 2918 2919 if (infoPtr->uNumBands == 2) 2919 2920 REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]); 2920 2921 2921 2922 REBAR_DumpBand (infoPtr); … … 2931 2932 { 2932 2933 FIXME("(uBand = %u fIdeal = %s) stub\n", 2933 2934 (UINT)wParam, lParam ? "TRUE" : "FALSE"); 2934 2935 2935 2936 return 0; … … 2954 2955 /* Validate */ 2955 2956 if ((infoPtr->uNumBands == 0) || 2956 2957 2958 2959 2960 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; 2961 2962 } 2962 2963 … … 2965 2966 2966 2967 if (infoPtr->dwStyle & CCS_VERT) 2967 2968 2968 movement = lpBand->rcBand.bottom - lpBand->rcBand.top - 2969 lpBand->cxHeader; 2969 2970 else 2970 2971 2971 movement = lpBand->rcBand.right - lpBand->rcBand.left - 2972 lpBand->cxHeader; 2972 2973 if (movement < 0) { 2973 2974 2975 2976 2977 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; 2978 2979 } 2979 2980 … … 2985 2986 for (i=0; i<infoPtr->uNumBands; i++) { 2986 2987 band = &infoPtr->bands[i]; 2987 2988 2989 2990 2991 2988 if (HIDDENBAND(band)) continue; 2989 if (band->iRow == lpBand->iRow) { 2990 imaxdBand = i; 2991 if (imindBand == -1) imindBand = i; 2992 } 2992 2993 } 2993 2994 … … 2995 2996 /* next visible band */ 2996 2997 if (imindBand == uBand) { 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 SetRect (&newrect, 3017 3018 3019 3020 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); 3021 3022 } 3022 3023 /* otherwise expand previous visible band */ 3023 3024 else { 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 SetRect (&newrect, 3043 3044 3045 3046 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); 3047 3048 } 3048 3049 … … 3051 3052 /* recompute all rectangles */ 3052 3053 if (infoPtr->dwStyle & CCS_VERT) { 3053 3054 3054 REBAR_CalcVertBand (infoPtr, startBand, endBand+1, 3055 FALSE); 3055 3056 } 3056 3057 else { 3057 REBAR_CalcHorzBand (infoPtr, startBand, endBand+1, 3058 3058 REBAR_CalcHorzBand (infoPtr, startBand, endBand+1, 3059 FALSE); 3059 3060 } 3060 3061 3061 3062 TRACE("bands after minimize, see band # %d, %d\n", 3062 3063 startBand, endBand); 3063 3064 REBAR_DumpBand (infoPtr); 3064 3065 … … 3081 3082 /* Validate */ 3082 3083 if ((infoPtr->uNumBands == 0) || 3083 3084 3085 3086 3087 3088 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; 3089 3090 } 3090 3091 … … 3094 3095 /* close up rest of bands (psuedo delete) */ 3095 3096 if (uFrom < infoPtr->uNumBands - 1) { 3096 3097 3097 memcpy (&oldBands[uFrom], &oldBands[uFrom+1], 3098 (infoPtr->uNumBands - uFrom - 1) * sizeof(REBAR_BAND)); 3098 3099 } 3099 3100 3100 3101 /* allocate new space and copy rest of bands into it */ 3101 3102 infoPtr->bands = 3102 3103 (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands)*sizeof(REBAR_BAND)); 3103 3104 3104 3105 /* pre insert copy */ 3105 3106 if (uTo > 0) { 3106 3107 3107 memcpy (&infoPtr->bands[0], &oldBands[0], 3108 uTo * sizeof(REBAR_BAND)); 3108 3109 } 3109 3110 … … 3113 3114 /* post copy */ 3114 3115 if (uTo < infoPtr->uNumBands - 1) { 3115 3116 3116 memcpy (&infoPtr->bands[uTo+1], &oldBands[uTo], 3117 (infoPtr->uNumBands - uTo - 1) * sizeof(REBAR_BAND)); 3117 3118 } 3118 3119 … … 3143 3144 3144 3145 if (lprbbi == NULL) 3145 3146 return FALSE; 3146 3147 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA) 3147 3148 return FALSE; 3148 3149 if ((UINT)wParam >= infoPtr->uNumBands) 3149 3150 return FALSE; 3150 3151 3151 3152 TRACE("index %u\n", (UINT)wParam); … … 3157 3158 REBAR_CommonSetupBand (infoPtr->hwndSelf, lprbbi, lpBand); 3158 3159 if (lprbbi->fMask & RBBIM_TEXT) { 3159 3160 3161 3162 3163 3160 if (lpBand->lpText) { 3161 COMCTL32_Free (lpBand->lpText); 3162 lpBand->lpText = NULL; 3163 } 3164 if (lprbbi->lpText) { 3164 3165 INT len = MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, NULL, 0 ); 3165 3166 lpBand->lpText = (LPWSTR)COMCTL32_Alloc (len*sizeof(WCHAR)); 3166 3167 MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, lpBand->lpText, len ); 3167 3168 } 3168 3169 } 3169 3170 … … 3173 3174 3174 3175 if (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE)) 3175 3176 REBAR_Layout (infoPtr, NULL, TRUE, FALSE); 3176 3177 3177 3178 return TRUE; … … 3186 3187 3187 3188 if (lprbbi == NULL) 3188 3189 return FALSE; 3189 3190 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW) 3190 3191 return FALSE; 3191 3192 if ((UINT)wParam >= infoPtr->uNumBands) 3192 3193 return FALSE; 3193 3194 3194 3195 TRACE("index %u\n", (UINT)wParam); … … 3200 3201 REBAR_CommonSetupBand (infoPtr->hwndSelf, (LPREBARBANDINFOA)lprbbi, lpBand); 3201 3202 if (lprbbi->fMask & RBBIM_TEXT) { 3202 3203 3204 3205 3206 3207 3208 3209 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 } 3211 3212 } 3212 3213 … … 3230 3231 3231 3232 if (lpInfo == NULL) 3232 3233 return FALSE; 3233 3234 3234 3235 if (lpInfo->cbSize < sizeof (REBARINFO)) 3235 3236 return FALSE; 3236 3237 3237 3238 TRACE("setting bar info!\n"); 3238 3239 3239 3240 if (lpInfo->fMask & RBIM_IMAGELIST) { 3240 3241 3241 infoPtr->himl = lpInfo->himl; 3242 if (infoPtr->himl) { 3242 3243 INT cx, cy; 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 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); 3253 3254 } 3254 3255 … … 3256 3257 for (i=0; i<infoPtr->uNumBands; i++) { 3257 3258 lpBand = &infoPtr->bands[i]; 3258 3259 REBAR_ValidateBand (infoPtr, lpBand); 3259 3260 } 3260 3261 … … 3314 3315 BOOL bTemp = infoPtr->bUnicode; 3315 3316 3316 TRACE("to %s hwnd=0x%04x, was %s\n", 3317 3318 3317 TRACE("to %s hwnd=0x%04x, was %s\n", 3318 ((BOOL)wParam) ? "TRUE" : "FALSE", infoPtr->hwndSelf, 3319 (bTemp) ? "TRUE" : "FALSE"); 3319 3320 3320 3321 infoPtr->bUnicode = (BOOL)wParam; 3321 3322 3322 3323 return bTemp; 3323 3324 } … … 3330 3331 3331 3332 if (iVersion > COMCTL32_VERSION) 3332 3333 return -1; 3333 3334 3334 3335 infoPtr->iVersion = iVersion; … … 3346 3347 3347 3348 if (((INT)wParam < 0) || ((INT)wParam > infoPtr->uNumBands)) 3348 3349 return FALSE; 3349 3350 3350 3351 lpBand = &infoPtr->bands[(INT)wParam]; 3351 3352 3352 3353 if ((BOOL)lParam) { 3353 3354 3355 3356 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); 3357 3358 } 3358 3359 else { 3359 3360 3361 3362 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); 3363 3364 } 3364 3365 … … 3379 3380 3380 3381 TRACE("[%d %d %d %d]\n", 3381 3382 lpRect->left, lpRect->top, lpRect->right, lpRect->bottom); 3382 3383 3383 3384 /* what is going on???? */ 3384 3385 GetWindowRect(infoPtr->hwndSelf, &t1); 3385 3386 TRACE("window rect [%d %d %d %d]\n", 3386 3387 t1.left, t1.top, t1.right, t1.bottom); 3387 3388 GetClientRect(infoPtr->hwndSelf, &t1); 3388 3389 TRACE("client rect [%d %d %d %d]\n", 3389 3390 t1.left, t1.top, t1.right, t1.bottom); 3390 3391 3391 3392 /* force full _Layout processing */ … … 3406 3407 3407 3408 if (TRACE_ON(rebar)) { 3408 3409 3410 3411 3412 3413 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); 3414 3415 } 3415 3416 … … 3428 3429 /* free rebar bands */ 3429 3430 if ((infoPtr->uNumBands > 0) && infoPtr->bands) { 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 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; 3446 3447 } 3447 3448 … … 3522 3523 if (infoPtr->fStatus & BEGIN_DRAG_ISSUED) { 3523 3524 REBAR_Notify((NMHDR *) &layout, infoPtr, RBN_LAYOUTCHANGED); 3524 3525 3525 REBAR_Notify_NMREBAR (infoPtr, ihitBand, RBN_ENDDRAG); 3526 infoPtr->fStatus &= ~BEGIN_DRAG_ISSUED; 3526 3527 } 3527 3528 … … 3547 3548 /* if mouse did not move much, exit */ 3548 3549 if ((abs(ptsmove.x - infoPtr->dragNow.x) <= mindragx) && 3549 3550 (abs(ptsmove.y - infoPtr->dragNow.y) <= mindragy)) return 0; 3550 3551 3551 3552 band1 = &infoPtr->bands[infoPtr->ihitBand-1]; … … 3554 3555 /* Test for valid drag case - must not be first band in row */ 3555 3556 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"); 3564 3561 } 3565 3562 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 } 3574 3575 } 3575 3576 return 0; … … 3588 3589 #if 0 3589 3590 if (GetWindowLongA (infoPtr->hwndSelf, GWL_STYLE) & WS_BORDER) { 3590 3591 3592 3593 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); 3594 3595 } 3595 3596 #endif … … 3608 3609 3609 3610 if (infoPtr != NULL) { 3610 3611 3611 ERR("Strange info structure pointer *not* NULL\n"); 3612 return FALSE; 3612 3613 } 3613 3614 3614 3615 if (TRACE_ON(rebar)) { 3615 3616 3617 3618 3619 3620 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); 3621 3622 } 3622 3623 … … 3646 3647 /* issue WM_NOTIFYFORMAT to get unicode status of parent */ 3647 3648 i = SendMessageA(REBAR_GetNotifyParent (infoPtr), 3648 3649 WM_NOTIFYFORMAT, hwnd, NF_QUERY); 3649 3650 if ((i < NFR_ANSI) || (i > NFR_UNICODE)) { 3650 3651 3652 3651 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", 3652 i); 3653 i = NFR_ANSI; 3653 3654 } 3654 3655 infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0; … … 3659 3660 3660 3661 /* native does: 3661 3662 3663 3664 3665 3666 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); 3667 3668 WS_VISIBLE = 0x10000000; 3668 3669 CCS_TOP = 0x00000001; 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 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); 3682 3683 */ 3683 3684 return TRUE; … … 3707 3708 clpt = pt; 3708 3709 ScreenToClient (infoPtr->hwndSelf, &clpt); 3709 REBAR_InternalHitTest (infoPtr, &clpt, &scrap, 3710 3710 REBAR_InternalHitTest (infoPtr, &clpt, &scrap, 3711 (INT *)&nmmouse.dwItemSpec); 3711 3712 nmmouse.dwItemData = 0; 3712 3713 nmmouse.pt = clpt; 3713 3714 nmmouse.dwHitInfo = 0; 3714 3715 if ((i = REBAR_Notify((NMHDR *) &nmmouse, infoPtr, NM_NCHITTEST))) { 3715 3716 ret, i); 3717 3716 TRACE("notify changed return value from %ld to %d\n", 3717 ret, i); 3718 ret = (LRESULT) i; 3718 3719 } 3719 3720 TRACE("returning %ld, client point (%ld,%ld)\n", ret, clpt.x, clpt.y); … … 3729 3730 3730 3731 if (infoPtr->dwStyle & WS_MINIMIZE) 3731 3732 return 0; /* Nothing to do */ 3732 3733 3733 3734 DefWindowProcA (infoPtr->hwndSelf, WM_NCPAINT, wParam, lParam); 3734 3735 3735 3736 if (!(hdc = GetDCEx( infoPtr->hwndSelf, 0, DCX_USESTYLE | DCX_WINDOW ))) 3736 3737 return 0; 3737 3738 3738 3739 if (infoPtr->dwStyle & WS_BORDER) { 3739 3740 3741 3742 3743 3744 3745 3746 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); 3747 3748 } 3748 3749 … … 3759 3760 3760 3761 if (lParam == NF_REQUERY) { 3761 3762 3763 3764 3765 3766 3767 3768 3769 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; 3770 3771 } 3771 3772 return (LRESULT)((infoPtr->bUnicode) ? NFR_UNICODE : NFR_ANSI); … … 3784 3785 3785 3786 TRACE("painting (%d,%d)-(%d,%d) client (%d,%d)-(%d,%d)\n", 3786 3787 3788 3787 ps.rcPaint.left, ps.rcPaint.top, 3788 ps.rcPaint.right, ps.rcPaint.bottom, 3789 rc.left, rc.top, rc.right, rc.bottom); 3789 3790 3790 3791 if (ps.fErase) { 3791 3792 /* Erase area of paint if requested */ 3792 3793 REBAR_InternalEraseBkGnd (infoPtr, wParam, lParam, &ps.rcPaint); 3793 3794 } … … 3795 3796 REBAR_Refresh (infoPtr, hdc); 3796 3797 if (!wParam) 3797 3798 EndPaint (infoPtr->hwndSelf, &ps); 3798 3799 return 0; 3799 3800 } … … 3814 3815 3815 3816 if (flags == RBHT_GRABBER) { 3816 3817 3818 3819 3820 3817 if ((infoPtr->dwStyle & CCS_VERT) && 3818 !(infoPtr->dwStyle & RBS_VERTICALGRIPPER)) 3819 SetCursor (infoPtr->hcurVert); 3820 else 3821 SetCursor (infoPtr->hcurHorz); 3821 3822 } 3822 3823 else if (flags != RBHT_CLIENT) 3823 3824 SetCursor (infoPtr->hcurArrow); 3824 3825 3825 3826 return 0; … … 3839 3840 for (i=0; i<infoPtr->uNumBands; i++) { 3840 3841 lpBand = &infoPtr->bands[i]; 3841 3842 REBAR_ValidateBand (infoPtr, lpBand); 3842 3843 } 3843 3844 … … 3860 3861 * 3861 3862 * Documentation: 3862 * According to testing V4.71 of COMCTL32 returns the 3863 * According to testing V4.71 of COMCTL32 returns the 3863 3864 * *previous* status of the redraw flag (either 0 or -1) 3864 3865 * instead of the MSDN documented value of 0 if handled … … 3868 3869 BOOL oldredraw = infoPtr->DoRedraw; 3869 3870 3870 TRACE("set to %s, fStatus=%08x\n", 3871 3871 TRACE("set to %s, fStatus=%08x\n", 3872 (wParam) ? "TRUE" : "FALSE", infoPtr->fStatus); 3872 3873 infoPtr->DoRedraw = (BOOL) wParam; 3873 3874 if (wParam) { 3874 3875 3876 3877 3878 3879 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; 3880 3881 } 3881 3882 return (oldredraw) ? -1 : 0; … … 3890 3891 /* auto resize deadlock check */ 3891 3892 if (infoPtr->fStatus & AUTO_RESIZE) { 3892 3893 3894 3895 3893 infoPtr->fStatus &= ~AUTO_RESIZE; 3894 TRACE("AUTO_RESIZE was set, reset, fStatus=%08x lparam=%08lx\n", 3895 infoPtr->fStatus, lParam); 3896 return 0; 3896 3897 } 3897 3898 3898 3899 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); 3931 3915 } 3932 3916 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 } 3950 3951 } 3951 3952 3952 3953 if (infoPtr->dwStyle & RBS_AUTOSIZE) { 3953 3954 3955 3956 3957 3958 3959 TRACE("RBN_AUTOSIZE client=(%d,%d), lp=%08lx\n", 3960 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); 3961 3962 } 3962 3963 3963 3964 if ((infoPtr->calcSize.cx != rcClient.right) || 3964 3965 3965 (infoPtr->calcSize.cy != rcClient.bottom)) 3966 infoPtr->fStatus |= BAND_NEEDS_LAYOUT; 3966 3967 3967 3968 REBAR_Layout (infoPtr, &rcClient, TRUE, TRUE); … … 3978 3979 3979 3980 TRACE("current style=%08lx, styleOld=%08lx, style being set to=%08lx\n", 3980 3981 infoPtr->dwStyle, ss->styleOld, ss->styleNew); 3981 3982 infoPtr->dwStyle = ss->styleNew; 3982 3983 … … 3990 3991 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); 3991 3992 3992 TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n", 3993 3993 TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n", 3994 hwnd, uMsg, /* SPY_GetMsgName(uMsg), */ wParam, lParam); 3994 3995 if (!infoPtr && (uMsg != WM_NCCREATE)) 3995 3996 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 3996 3997 switch (uMsg) 3997 3998 { 3998 /* 3999 4000 4001 4002 4003 /* 4004 /* 4005 4006 4007 4008 4009 4010 4011 4012 case RB_GETBANDINFO:/* obsoleted after IE3, but we have to4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 /* 4030 /* 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 /* 4090 /* 4091 /* 4092 4093 4094 4095 4096 4097 4098 4099 /* 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 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); 4112 4113 4113 4114 4114 4115 /* Messages passed to parent */ 4115 4116 4117 4118 4119 4120 4121 4122 4123 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); 4124 4125 4125 4126 4126 4127 /* case WM_CHARTOITEM: supported according to ControlSpy */ 4127 4128 4128 4129 4130 4131 4132 4129 case WM_CREATE: 4130 return REBAR_Create (infoPtr, wParam, lParam); 4131 4132 case WM_DESTROY: 4133 return REBAR_Destroy (infoPtr, wParam, lParam); 4133 4134 4134 4135 case WM_ERASEBKGND: 4135 4136 4137 4138 4136 return REBAR_EraseBkGnd (infoPtr, wParam, lParam); 4137 4138 case WM_GETFONT: 4139 return REBAR_GetFont (infoPtr, wParam, lParam); 4139 4140 4140 4141 /* case WM_LBUTTONDBLCLK: supported according to ControlSpy */ 4141 4142 4142 4143 4144 4145 4146 4143 case WM_LBUTTONDOWN: 4144 return REBAR_LButtonDown (infoPtr, wParam, lParam); 4145 4146 case WM_LBUTTONUP: 4147 return REBAR_LButtonUp (infoPtr, wParam, lParam); 4147 4148 4148 4149 /* case WM_MEASUREITEM: supported according to ControlSpy */ 4149 4150 4150 4151 4152 4153 4154 4151 case WM_MOUSEMOVE: 4152 return REBAR_MouseMove (infoPtr, wParam, lParam); 4153 4154 case WM_NCCALCSIZE: 4155 return REBAR_NCCalcSize (infoPtr, wParam, lParam); 4155 4156 4156 4157 case WM_NCCREATE: 4157 4158 return REBAR_NCCreate (hwnd, wParam, lParam); 4158 4159 4159 4160 case WM_NCHITTEST: 4160 4161 4162 4163 4161 return REBAR_NCHitTest (infoPtr, wParam, lParam); 4162 4163 case WM_NCPAINT: 4164 return REBAR_NCPaint (infoPtr, wParam, lParam); 4164 4165 4165 4166 case WM_NOTIFYFORMAT: 4166 4167 4168 4169 4167 return REBAR_NotifyFormat (infoPtr, wParam, lParam); 4168 4169 case WM_PAINT: 4170 return REBAR_Paint (infoPtr, wParam, lParam); 4170 4171 4171 4172 /* case WM_PALETTECHANGED: supported according to ControlSpy */ … … 4175 4176 /* case WM_RBUTTONUP: supported according to ControlSpy */ 4176 4177 4177 4178 4179 4180 4181 4178 case WM_SETCURSOR: 4179 return REBAR_SetCursor (infoPtr, wParam, lParam); 4180 4181 case WM_SETFONT: 4182 return REBAR_SetFont (infoPtr, wParam, lParam); 4182 4183 4183 4184 case WM_SETREDRAW: 4184 4185 4186 4187 4185 return REBAR_SetRedraw (infoPtr, wParam, lParam); 4186 4187 case WM_SIZE: 4188 return REBAR_Size (infoPtr, wParam, lParam); 4188 4189 4189 4190 case WM_STYLECHANGED: 4190 4191 return REBAR_StyleChanged (infoPtr, wParam, lParam); 4191 4192 4192 4193 /* case WM_SYSCOLORCHANGE: supported according to ControlSpy */ 4193 4194 /* "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 4195 4196 system colors." per MSDN */ 4196 4197 4197 4198 /* case WM_VKEYTOITEM: supported according to ControlSpy */ 4198 /* 4199 4200 4201 4202 4203 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); 4204 4205 #ifdef __WIN32OS2__ 4205 4206 return defComCtl32ProcA (hwnd, uMsg, wParam, lParam); 4206 4207 #else 4207 4208 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 4208 4209 #endif 4209 4210 } … … 4225 4226 wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1); 4226 4227 wndClass.lpszClassName = REBARCLASSNAMEA; 4227 4228 4228 4229 RegisterClassA (&wndClass); 4229 4230 -
trunk/src/comctl32/status.c
r6391 r6644 1 /* $Id: status.c,v 1.23 2001-09-05 12:05:02 bird Exp $ */ 1 2 /* 2 3 * Interface code to StatusWindow widget/control … … 26 27 typedef struct 27 28 { 28 INT 29 INT 30 RECT 31 LPWSTR 29 INT x; 30 INT style; 31 RECT bound; 32 LPWSTR text; 32 33 HICON hIcon; 33 34 } STATUSWINDOWPART; … … 48 49 COLORREF clrBk; /* background color */ 49 50 BOOL bUnicode; /* unicode flag */ 50 STATUSWINDOWPART part0;/* simple window */51 STATUSWINDOWPART part0; /* simple window */ 51 52 STATUSWINDOWPART *parts; 52 53 } STATUSWINDOWINFO; … … 93 94 SelectObject (hdc, GetSysColorPen (COLOR_3DSHADOW)); 94 95 for (i = 1; i < 11; i += 4) { 95 96 97 98 99 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); 100 101 } 101 102 102 103 SelectObject (hdc, GetSysColorPen (COLOR_3DHIGHLIGHT)); 103 104 for (i = 3; i < 13; i += 4) { 104 105 105 MoveToEx (hdc, pt.x - i, pt.y, NULL); 106 LineTo (hdc, pt.x, pt.y - i); 106 107 } 107 108 … … 110 111 111 112 112 static void 113 static void 113 114 STATUSBAR_DrawPart (HDC hdc, STATUSWINDOWPART *part) 114 115 { … … 126 127 /* draw the icon */ 127 128 if (part->hIcon) { 128 129 130 131 132 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; 133 134 } 134 135 … … 139 140 UINT align = DT_LEFT; 140 141 if (*p == L'\t') { 141 142 143 144 145 146 147 142 p++; 143 align = DT_CENTER; 144 145 if (*p == L'\t') { 146 p++; 147 align = DT_RIGHT; 148 } 148 149 } 149 150 r.left += 3; … … 151 152 DrawTextW (hdc, p, -1, &r, align|DT_VCENTER|DT_SINGLELINE); 152 153 if (oldbkmode != TRANSPARENT) 153 154 SetBkMode(hdc, oldbkmode); 154 155 } 155 156 } … … 169 170 170 171 if (infoPtr->clrBk != CLR_DEFAULT) 171 172 hbrBk = CreateSolidBrush (infoPtr->clrBk); 172 173 else 173 174 hbrBk = GetSysColorBrush (COLOR_3DFACE); 174 175 FillRect(hdc, &part->bound, hbrBk); 175 176 … … 177 178 178 179 if (part->style & SBT_OWNERDRAW) { 179 180 181 182 183 184 185 186 187 188 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); 189 190 } else 190 191 STATUSBAR_DrawPart (hdc, part); 191 192 192 193 SelectObject (hdc, hOldFont); 193 194 194 195 if (infoPtr->clrBk != CLR_DEFAULT) 195 196 DeleteObject (hbrBk); 196 197 197 198 if (GetWindowLongA (hwnd, GWL_STYLE) & SBARS_SIZEGRIP) { 198 199 200 201 199 RECT rect; 200 201 GetClientRect (hwnd, &rect); 202 STATUSBAR_DrawSizeGrip (hdc, &rect); 202 203 } 203 204 } … … 221 222 222 223 if (infoPtr->clrBk != CLR_DEFAULT) 223 224 hbrBk = CreateSolidBrush (infoPtr->clrBk); 224 225 else 225 226 hbrBk = GetSysColorBrush (COLOR_3DFACE); 226 227 FillRect(hdc, &rect, hbrBk); 227 228 … … 229 230 230 231 if (infoPtr->simple) { 231 232 STATUSBAR_RefreshPart (infoPtr, hwnd, &infoPtr->part0, hdc, 0); 232 233 } else { 233 234 235 236 237 238 239 240 241 242 243 244 245 246 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 } 248 249 } 249 250 … … 251 252 252 253 if (infoPtr->clrBk != CLR_DEFAULT) 253 254 DeleteObject (hbrBk); 254 255 255 256 if (GetWindowLongA(hwnd, GWL_STYLE) & SBARS_SIZEGRIP) 256 257 STATUSBAR_DrawSizeGrip (hdc, &rect); 257 258 258 259 return TRUE; … … 265 266 STATUSWINDOWPART *part; 266 267 RECT rect, *r; 267 int 268 int i; 268 269 269 270 /* get our window size */ … … 278 279 /* set bounds for non-simple rectangles */ 279 280 for (i = 0; i < infoPtr->numParts; i++) { 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 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 } 303 304 } 304 305 } … … 307 308 static VOID 308 309 STATUSBAR_RelayEvent (HWND hwndTip, HWND hwndMsg, UINT uMsg, 309 310 WPARAM wParam, LPARAM lParam) 310 311 { 311 312 MSG msg; … … 345 346 TRACE("%d\n", nPart); 346 347 if ((nPart < -1) || (nPart >= infoPtr->numParts)) 347 348 return 0; 348 349 349 350 if (nPart == -1) … … 365 366 parts = (LPINT) lParam; 366 367 if (parts) { 367 368 369 368 for (i = 0; i < num_parts; i++) { 369 parts[i] = infoPtr->parts[i].x; 370 } 370 371 } 371 372 return (infoPtr->numParts); … … 376 377 STATUSBAR_GetRect (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam) 377 378 { 378 int 379 int nPart; 379 380 LPRECT rect; 380 381 … … 383 384 rect = (LPRECT) lParam; 384 385 if (infoPtr->simple) 385 386 *rect = infoPtr->part0.bound; 386 387 else 387 388 *rect = infoPtr->parts[nPart].bound; 388 389 return TRUE; 389 390 } … … 400 401 TRACE("part %d\n", nPart); 401 402 if (infoPtr->simple) 402 403 part = &infoPtr->part0; 403 404 else 404 405 #ifdef __WIN32OS2__ 405 406 { 406 407 if (nPart >= infoPtr->numParts) 407 408 408 return FALSE; 409 part = &infoPtr->parts[nPart]; 409 410 } 410 411 #else 411 412 part = &infoPtr->parts[nPart]; 412 413 #endif 413 414 414 415 if (part->style & SBT_OWNERDRAW) 415 416 result = (LRESULT)part->text; 416 417 else { 417 418 DWORD len = part->text ? WideCharToMultiByte( CP_ACP, 0, part->text, -1, … … 435 436 TRACE("part %d\n", nPart); 436 437 if (infoPtr->simple) 437 438 part = &infoPtr->part0; 438 439 else 439 440 #ifdef __WIN32OS2__ 440 441 { 441 442 if (nPart >= infoPtr->numParts) 442 443 443 return FALSE; 444 part = &infoPtr->parts[nPart]; 444 445 } 445 446 #else 446 447 part = &infoPtr->parts[nPart]; 447 448 #endif 448 449 449 450 if (part->style & SBT_OWNERDRAW) 450 451 result = (LRESULT)part->text; 451 452 else { 452 453 454 455 453 result = part->text ? strlenW (part->text) : 0; 454 result |= (part->style << 16); 455 if (part->text && lParam) 456 strcpyW ((LPWSTR)lParam, part->text); 456 457 } 457 458 return result; … … 471 472 472 473 if (infoPtr->simple) 473 474 part = &infoPtr->part0; 474 475 else 475 476 #ifdef __WIN32OS2__ 476 477 { 477 478 if (nPart >= infoPtr->numParts) 478 479 479 return FALSE; 480 part = &infoPtr->parts[nPart]; 480 481 } 481 482 #else 482 483 part = &infoPtr->parts[nPart]; 483 484 #endif 484 485 485 486 if (part->text) 486 487 result = strlenW(part->text); 487 488 else 488 489 result = 0; 489 490 490 491 result |= (part->style << 16); … … 526 527 buf[0]=0; 527 528 528 529 530 531 532 529 if (infoPtr->hwndToolTip) { 530 TTTOOLINFOW ti; 531 ti.cbSize = sizeof(TTTOOLINFOW); 532 ti.hwnd = hwnd; 533 ti.uId = LOWORD(wParam); 533 534 ti.lpszText = buf; 534 535 536 535 SendMessageW(infoPtr->hwndToolTip, TTM_GETTEXTW, 0, (LPARAM)&ti); 536 } 537 lstrcpynW(tip, buf, HIWORD(wParam)); 537 538 } 538 539 … … 575 576 576 577 if ((nPart < -1) || (nPart >= infoPtr->numParts)) 577 578 return FALSE; 578 579 579 580 TRACE("setting part %d, icon %lx\n",nPart,lParam); 580 581 581 582 if (nPart == -1) { 582 583 584 585 583 if (infoPtr->part0.hIcon == (HICON)lParam) /* same as - no redraw */ 584 return TRUE; 585 infoPtr->part0.hIcon = (HICON)lParam; 586 if (infoPtr->simple) 586 587 InvalidateRect(hwnd, &infoPtr->part0.bound, FALSE); 587 588 } else { 588 589 590 591 592 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)) 593 594 InvalidateRect(hwnd, &infoPtr->parts[nPart].bound, FALSE); 594 595 } … … 603 604 TRACE("\n"); 604 605 if (IsWindowVisible (hwnd)) { 605 606 607 608 609 610 611 612 613 614 615 616 617 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); 618 619 } 619 620 … … 627 628 STATUSWINDOWPART *tmp; 628 629 LPINT parts; 629 int 630 int 630 int i; 631 int oldNumParts; 631 632 632 633 TRACE("(%d,%p)\n",wParam,(LPVOID)lParam); … … 634 635 /* FIXME: should return FALSE sometimes (maybe when wParam == 0 ?) */ 635 636 if (infoPtr->simple) 636 637 infoPtr->simple = FALSE; 637 638 638 639 oldNumParts = infoPtr->numParts; … … 640 641 parts = (LPINT) lParam; 641 642 if (oldNumParts > infoPtr->numParts) { 642 643 644 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 } 646 647 } 647 648 if (oldNumParts < infoPtr->numParts) { 648 649 650 651 652 653 654 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; 655 656 } 656 657 if (oldNumParts == infoPtr->numParts) { 657 658 659 660 661 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 664 665 for (i = 0; i < infoPtr->numParts; i++) 665 666 infoPtr->parts[i].x = parts[i]; 666 667 667 668 if (infoPtr->hwndToolTip) { 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 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 } 694 695 } 695 696 STATUSBAR_SetPartBounds (infoPtr, hwnd); … … 703 704 { 704 705 STATUSWINDOWPART *part=NULL; 705 int 706 int 706 int nPart; 707 int style; 707 708 LPSTR text; 708 BOOL 709 BOOL changed = FALSE; 709 710 710 711 text = (LPSTR) lParam; … … 715 716 716 717 if (nPart==255) 717 718 part = &infoPtr->part0; 718 719 else if (!infoPtr->simple && infoPtr->parts!=NULL) 719 720 #ifdef __WIN32OS2__ 720 721 { 721 722 if (nPart >= infoPtr->numParts) 722 723 723 return FALSE; 724 part = &infoPtr->parts[nPart]; 724 725 } 725 726 #else 726 727 part = &infoPtr->parts[nPart]; 727 728 #endif 728 729 if (!part) return FALSE; 729 730 730 731 if (part->style != style) 731 732 changed = TRUE; 732 733 733 734 part->style = style; 734 735 if (style & SBT_OWNERDRAW) { 735 736 737 736 if (part->text == (LPWSTR)text) 737 return TRUE; 738 part->text = (LPWSTR)text; 738 739 } else { 739 740 741 742 740 LPWSTR ntext; 741 742 /* check if text is unchanged -> no need to redraw */ 743 if (text) { 743 744 DWORD len = MultiByteToWideChar( CP_ACP, 0, text, -1, NULL, 0 ); 744 745 LPWSTR tmptext = COMCTL32_Alloc(len*sizeof(WCHAR)); 745 746 MultiByteToWideChar( CP_ACP, 0, text, -1, tmptext, len ); 746 747 747 748 749 750 751 752 753 if (!changed && !part->text) 754 755 756 757 758 759 760 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; 761 762 } 762 763 InvalidateRect(hwnd, &part->bound, FALSE); … … 780 781 TRACE("part %d -> '%s' with style %04x\n", nPart, debugstr_w(text), style); 781 782 if ((infoPtr->simple) || (infoPtr->parts==NULL) || (nPart==255)) 782 783 part = &infoPtr->part0; 783 784 else 784 785 #ifdef __WIN32OS2__ 785 786 { 786 787 if (nPart >= infoPtr->numParts) 787 788 788 return FALSE; 789 part = &infoPtr->parts[nPart]; 789 790 } 790 791 #else 791 792 part = &infoPtr->parts[nPart]; 792 793 #endif 793 794 if (!part) return FALSE; … … 801 802 if (style & SBT_OWNERDRAW) 802 803 { 803 804 part->text = text; 804 805 bRedraw = TRUE; 805 806 } else if(!text) … … 813 814 } else if(!part->text || strcmpW(part->text, text)) /* see if the new string differs from the existing string */ 814 815 { 815 816 if(part->text) COMCTL32_Free(part->text); 816 817 817 818 len = strlenW(text); 818 819 part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR)); 819 820 strcpyW(part->text, text); 820 821 bRedraw = TRUE; 821 822 } … … 833 834 TRACE("part %d: \"%s\"\n", (INT)wParam, (LPSTR)lParam); 834 835 if (infoPtr->hwndToolTip) { 835 836 837 838 839 840 841 842 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); 843 844 } 844 845 … … 852 853 TRACE("part %d: \"%s\"\n", (INT)wParam, (LPSTR)lParam); 853 854 if (infoPtr->hwndToolTip) { 854 855 856 857 858 859 860 861 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); 862 863 } 863 864 … … 885 886 TRACE("(is simple: %d)\n", wParam); 886 887 if (infoPtr->simple == wParam) /* no need to change */ 887 888 return TRUE; 888 889 889 890 infoPtr->simple = (BOOL)wParam; … … 905 906 NONCLIENTMETRICSA nclm; 906 907 DWORD dwStyle; 907 RECT 908 int 909 HDC 908 RECT rect; 909 int width, len; 910 HDC hdc; 910 911 STATUSWINDOWINFO *infoPtr; 911 912 … … 951 952 952 953 if (IsWindowUnicode (hwnd)) { 953 954 955 956 957 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 } 959 960 } 960 961 else { 961 962 962 if (lpCreate->lpszName && 963 (len = strlen((LPCSTR)lpCreate->lpszName))) { 963 964 DWORD lenW = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)lpCreate->lpszName, -1, NULL, 0 ); 964 965 infoPtr->parts[0].text = COMCTL32_Alloc (lenW*sizeof(WCHAR)); 965 966 MultiByteToWideChar( CP_ACP, 0, (LPCSTR)lpCreate->lpszName, -1, 966 967 infoPtr->parts[0].text, lenW ); 967 968 } 968 969 } 969 970 … … 977 978 #endif 978 979 if ((hdc = GetDC (0))) { 979 980 981 982 983 984 985 986 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); 987 988 } 988 989 989 990 if (dwStyle & SBT_TOOLTIPS) { 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 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 } 1008 1009 } 1009 1010 … … 1014 1015 infoPtr->height = infoPtr->textHeight + 4 + VERT_BORDER; 1015 1016 SetWindowPos(hwnd, 0, lpCreate->x, lpCreate->y - 1, 1016 1017 width, infoPtr->height, SWP_NOZORDER); 1017 1018 STATUSBAR_SetPartBounds (infoPtr, hwnd); 1018 1019 } … … 1025 1026 STATUSBAR_WMDestroy (STATUSWINDOWINFO *infoPtr, HWND hwnd) 1026 1027 { 1027 int 1028 int i; 1028 1029 1029 1030 TRACE("\n"); 1030 1031 for (i = 0; i < infoPtr->numParts; i++) { 1031 1032 1032 if (infoPtr->parts[i].text && !(infoPtr->parts[i].style & SBT_OWNERDRAW)) 1033 COMCTL32_Free (infoPtr->parts[i].text); 1033 1034 } 1034 1035 if (infoPtr->part0.text && !(infoPtr->part0.style & SBT_OWNERDRAW)) 1035 1036 COMCTL32_Free (infoPtr->part0.text); 1036 1037 COMCTL32_Free (infoPtr->parts); 1037 1038 1038 1039 /* delete default font */ 1039 1040 if (infoPtr->hDefaultFont) 1040 1041 DeleteObject (infoPtr->hDefaultFont); 1041 1042 1042 1043 /* delete tool tip control */ 1043 1044 if (infoPtr->hwndToolTip) 1044 1045 DestroyWindow (infoPtr->hwndToolTip); 1045 1046 1046 1047 COMCTL32_Free (infoPtr); … … 1074 1075 1075 1076 if (wParam > len) { 1076 1077 1078 1077 if (infoPtr->bUnicode) 1078 strcpyW ((LPWSTR)lParam, infoPtr->parts[0].text); 1079 else 1079 1080 WideCharToMultiByte( CP_ACP, 0, infoPtr->parts[0].text, -1, 1080 1081 (LPSTR)lParam, len+1, NULL, NULL ); 1081 1082 return len; 1082 1083 } 1083 1084 … … 1090 1091 { 1091 1092 if (infoPtr->hwndToolTip) 1092 1093 1093 STATUSBAR_RelayEvent (infoPtr->hwndToolTip, hwnd, 1094 WM_MOUSEMOVE, wParam, lParam); 1094 1095 return 0; 1095 1096 } … … 1100 1101 { 1101 1102 if (GetWindowLongA (hwnd, GWL_STYLE) & SBARS_SIZEGRIP) { 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 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; 1116 1117 } 1117 1118 … … 1149 1150 STATUSBAR_Refresh (infoPtr, hwnd, hdc); 1150 1151 if (!wParam) 1151 1152 EndPaint (hwnd, &ps); 1152 1153 1153 1154 return 0; … … 1194 1195 TRACE("\n"); 1195 1196 if (infoPtr->numParts == 0) 1196 1197 return FALSE; 1197 1198 1198 1199 part = &infoPtr->parts[0]; … … 1202 1203 part->text = 0; 1203 1204 if (infoPtr->bUnicode) { 1204 1205 1206 1207 1205 if (lParam && (len = strlenW((LPCWSTR)lParam))) { 1206 part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR)); 1207 strcpyW (part->text, (LPCWSTR)lParam); 1208 } 1208 1209 } 1209 1210 else { 1210 1211 if (lParam && (len = lstrlenA((LPCSTR)lParam))) { 1211 1212 DWORD lenW = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)lParam, -1, NULL, 0 ); 1212 1213 part->text = COMCTL32_Alloc (lenW*sizeof(WCHAR)); 1213 1214 MultiByteToWideChar( CP_ACP, 0, (LPCSTR)lParam, -1, part->text, lenW ); 1214 1215 } 1215 1216 } 1216 1217 … … 1240 1241 { 1241 1242 if (flags == SIZE_RESTORED) { 1242 1243 1244 1245 1246 1247 MoveWindow (hwnd, parent_rect.left, 1248 1249 1250 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); 1251 1252 } 1252 1253 return 0; /* FIXME: ok to return here ? */ 1253 1254 } 1254 1255 … … 1283 1284 1284 1285 switch (msg) { 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 case SB_SETPARTS: 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 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: 1357 1358 return STATUSBAR_WMGetFont (infoPtr, hwnd); 1358 1359 1359 1360 case WM_GETTEXT: 1360 1361 return STATUSBAR_WMGetText (infoPtr, hwnd, wParam, lParam); 1361 1362 1362 1363 1364 1365 1363 case WM_GETTEXTLENGTH: 1364 return STATUSBAR_GetTextLength (infoPtr, hwnd, 0); 1365 1366 case WM_LBUTTONDBLCLK: 1366 1367 return STATUSBAR_SendNotify (hwnd, NM_DBLCLK); 1367 1368 1368 1369 1370 1371 1369 case WM_LBUTTONUP: 1370 return STATUSBAR_SendNotify (hwnd, NM_CLICK); 1371 1372 case WM_MOUSEMOVE: 1372 1373 return STATUSBAR_WMMouseMove (infoPtr, hwnd, wParam, lParam); 1373 1374 1374 1375 case WM_NCHITTEST: 1375 1376 return STATUSBAR_WMNCHitTest (hwnd, wParam, lParam); 1376 1377 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 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); 1405 1406 #ifdef __WIN32OS2__ 1406 1407 return defComCtl32ProcA (hwnd, msg, wParam, lParam); 1407 1408 #else 1408 1409 return DefWindowProcA (hwnd, msg, wParam, lParam); 1409 1410 #endif 1410 1411 } … … 1432 1433 wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1); 1433 1434 wndClass.lpszClassName = STATUSCLASSNAMEA; 1434 1435 1435 1436 RegisterClassA (&wndClass); 1436 1437 } -
trunk/src/comctl32/tab.c
r5630 r6644 1 /* $Id: tab.c,v 1.21 2001-09-05 12:05:02 bird Exp $ */ 1 2 /* 2 3 * Tab control … … 36 37 LPARAM lParam; 37 38 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 * 41 42 * additionally the top member hold the row number 42 43 * and bottom is unused and should be 0 */ … … 49 50 #endif 50 51 UINT uNumItem; /* number of tab items */ 51 UINT uNumRows; 52 UINT uNumRows; /* number of tab rows */ 52 53 INT tabHeight; /* height of the tab row */ 53 54 INT tabWidth; /* width of tabs */ … … 57 58 HWND hwndToolTip; /* handle to tab's tooltip */ 58 59 INT leftmostVisible; /* Used for scrolling, this member contains 59 60 * the index of the first visible item */ 60 61 INT iSelected; /* the currently selected item */ 61 62 INT iHotTracked; /* the highlighted item under the mouse */ … … 63 64 TAB_ITEM* items; /* pointer to an array of TAB_ITEM's */ 64 65 BOOL DoRedraw; /* flag for redrawing when tab contents is changed*/ 65 BOOL needsScrolling; /* TRUE if the size of the tabs is greater than 66 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? */ 68 69 BOOL bUnicode; /* Unicode control? */ 69 70 HWND hwndUpDown; /* Updown control used for scrolling */ … … 81 82 #define CONTROL_BORDER_SIZEX 2 82 83 #define CONTROL_BORDER_SIZEY 2 83 #define BUTTON_SPACINGX 4 84 #define BUTTON_SPACINGX 4 84 85 #define BUTTON_SPACINGY 4 85 86 #define FLAT_BTN_SPACINGX 8 … … 137 138 { 138 139 TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); 139 140 140 141 return infoPtr->iSelected; 141 142 } … … 145 146 { 146 147 TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); 147 148 148 149 return infoPtr->uFocus; 149 150 } … … 164 165 INT iItem = (INT)wParam; 165 166 INT prevItem; 166 167 167 168 prevItem = -1; 168 169 if ((iItem >= 0) && (iItem < infoPtr->uNumItem)) { … … 180 181 TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); 181 182 INT iItem=(INT) wParam; 182 183 183 184 if ((iItem < 0) || (iItem >= infoPtr->uNumItem)) return 0; 184 185 185 186 if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BUTTONS) { 186 187 FIXME("Should set input focus\n"); 187 } else { 188 } else { 188 189 int oldFocus = infoPtr->uFocus; 189 190 if (infoPtr->iSelected != iItem || infoPtr->uFocus == -1 ) { … … 232 233 RECT tmpItemRect,clientRect; 233 234 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); 234 235 235 236 /* Perform a sanity check and a trivial visibility check. */ 236 237 if ( (infoPtr->uNumItem <= 0) || … … 245 246 if (itemRect == NULL) 246 247 itemRect = &tmpItemRect; 247 248 248 249 /* Retrieve the unmodified item rect. */ 249 250 *itemRect = infoPtr->items[itemIndex].rect; … … 280 281 else if(!(lStyle & TCS_VERTICAL) && !(lStyle & TCS_BOTTOM)) /* not TCS_BOTTOM and not TCS_VERTICAL */ 281 282 { 282 itemRect->bottom = clientRect.top + 283 itemRect->bottom = clientRect.top + 283 284 infoPtr->tabHeight + 284 285 itemRect->top * (infoPtr->tabHeight - 2) + 285 286 ((lStyle & TCS_BUTTONS) ? itemRect->top * BUTTON_SPACINGY : 0); 286 itemRect->top = clientRect.top + 287 itemRect->top = clientRect.top + 287 288 SELECTED_TAB_OFFSET + 288 289 itemRect->top * (infoPtr->tabHeight - 2) + … … 291 292 292 293 /* 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 294 295 * tab control is the leftmost visible tab. 295 296 */ … … 297 298 { 298 299 OffsetRect(itemRect, 299 300 300 0, 301 -(clientRect.bottom - infoPtr->items[infoPtr->leftmostVisible].rect.bottom)); 301 302 302 303 /* … … 305 306 */ 306 307 OffsetRect(itemRect, 307 308 308 0, 309 -SELECTED_TAB_OFFSET); 309 310 310 311 } else 311 312 { 312 313 OffsetRect(itemRect, 313 -infoPtr->items[infoPtr->leftmostVisible].rect.left, 314 314 -infoPtr->items[infoPtr->leftmostVisible].rect.left, 315 0); 315 316 316 317 /* … … 319 320 */ 320 321 OffsetRect(itemRect, 321 322 322 SELECTED_TAB_OFFSET, 323 0); 323 324 } 324 325 … … 336 337 /* If it also a bit higher. */ 337 338 if ((lStyle & TCS_BOTTOM) && !(lStyle & TCS_VERTICAL)) 338 { 339 { 339 340 selectedRect->top -= 2; /* the border is thicker on the bottom */ 340 341 selectedRect->bottom += SELECTED_TAB_OFFSET; … … 362 363 static BOOL TAB_GetItemRect(HWND hwnd, WPARAM wParam, LPARAM lParam) 363 364 { 364 return TAB_InternalGetItemRect(hwnd, TAB_GetInfoPtr(hwnd), (INT)wParam, 365 return TAB_InternalGetItemRect(hwnd, TAB_GetInfoPtr(hwnd), (INT)wParam, 365 366 (LPRECT)lParam, (LPRECT)NULL); 366 367 } … … 372 373 */ 373 374 static LRESULT TAB_KeyUp( 374 HWND hwnd, 375 HWND hwnd, 375 376 WPARAM keyCode) 376 377 { … … 387 388 break; 388 389 } 389 390 390 391 /* 391 392 * If we changed to a valid item, change the selection … … 416 417 */ 417 418 static LRESULT TAB_FocusChanging( 418 HWND hwnd, 419 UINT uMsg, 420 WPARAM wParam, 419 HWND hwnd, 420 UINT uMsg, 421 WPARAM wParam, 421 422 LPARAM lParam) 422 423 { … … 429 430 */ 430 431 isVisible = TAB_InternalGetItemRect(hwnd, 431 432 433 434 435 432 infoPtr, 433 infoPtr->uFocus, 434 NULL, 435 &selectedRect); 436 436 437 /* 437 438 * If the rectangle is not completely invisible, invalidate that … … 451 452 static HWND TAB_InternalHitTest ( 452 453 HWND hwnd, 453 TAB_INFO* infoPtr, 454 POINT pt, 454 TAB_INFO* infoPtr, 455 POINT pt, 455 456 UINT* flags) 456 457 457 458 { 458 459 RECT rect; 459 int iCount; 460 460 int iCount; 461 461 462 for (iCount = 0; iCount < infoPtr->uNumItem; iCount++) 462 463 { … … 479 480 TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); 480 481 LPTCHITTESTINFO lptest = (LPTCHITTESTINFO) lParam; 481 482 482 483 return TAB_InternalHitTest (hwnd, infoPtr, lptest->pt, &lptest->flags); 483 484 } … … 521 522 if (infoPtr->hwndToolTip) 522 523 TAB_RelayEvent (infoPtr->hwndToolTip, hwnd, 523 524 WM_LBUTTONDOWN, wParam, lParam); 524 525 525 526 if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_FOCUSONBUTTONDOWN ) { … … 529 530 if (infoPtr->hwndToolTip) 530 531 TAB_RelayEvent (infoPtr->hwndToolTip, hwnd, 531 532 532 WM_LBUTTONDOWN, wParam, lParam); 533 533 534 pt.x = (INT)LOWORD(lParam); 534 535 pt.y = (INT)HIWORD(lParam); 535 536 536 537 newItem = TAB_InternalHitTest (hwnd, infoPtr, pt, &dummy); 537 538 538 539 TRACE("On Tab, item %d\n", newItem); 539 540 … … 619 620 ** overlaps. Note also that the case where the cursor stayed within our 620 621 ** window but has moved off the hot-tracked tab will be handled by the 621 ** WM_MOUSEMOVE event. 622 ** WM_MOUSEMOVE event. 622 623 */ 623 624 if (!GetCursorPos(&pt) || WindowFromPoint(pt) != hwnd) … … 721 722 if (item >= 0) 722 723 { 723 724 /* Mark new hot-tracked to be redrawn to look highlighted */ 724 725 if (out_redrawEnter != NULL) 725 726 *out_redrawEnter = item; … … 743 744 if (infoPtr->hwndToolTip) 744 745 TAB_RelayEvent (infoPtr->hwndToolTip, hwnd, 745 746 WM_LBUTTONDOWN, wParam, lParam); 746 747 747 748 /* Determine which tab to highlight. Redraw tabs which change highlight … … 764 765 */ 765 766 static LRESULT TAB_AdjustRect( 766 HWND hwnd, 767 WPARAM fLarger, 767 HWND hwnd, 768 WPARAM fLarger, 768 769 LPRECT prc) 769 770 { … … 845 846 */ 846 847 static LRESULT TAB_OnHScroll( 847 HWND hwnd, 848 HWND hwnd, 848 849 int nScrollCode, 849 850 int nPos, … … 871 872 * TAB_SetupScrolling 872 873 * 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 874 875 * scrolling control is displayed (or not). 875 876 */ … … 930 931 { 931 932 infoPtr->hwndUpDown = CreateWindowA("msctls_updown32", 932 933 934 935 936 937 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); 941 942 } 942 943 else 943 944 { 944 SetWindowPos(infoPtr->hwndUpDown, 945 946 947 948 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); 950 951 } 951 952 … … 1010 1011 * a font. 1011 1012 */ 1012 hdc = GetDC(hwnd); 1013 1013 hdc = GetDC(hwnd); 1014 1014 1015 hFont = infoPtr->hFont ? infoPtr->hFont : GetStockObject (SYSTEM_FONT); 1015 1016 hOldFont = SelectObject (hdc, hFont); … … 1022 1023 1023 1024 /* 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 1025 1026 rather than duplicate all of the below code */ 1026 1027 if(lStyle & TCS_VERTICAL) … … 1054 1055 1055 1056 /* 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. 1058 1059 */ 1059 1060 infoPtr->tabHeight = item_height + 2 * VERTICAL_ITEM_PADDING + … … 1085 1086 * for button style tabs */ 1086 1087 if (lStyle & TCS_BUTTONS) 1087 1088 size.cx = max(size.cx, 2 * (infoPtr->tabHeight - 2)); 1088 1089 1089 1090 /* Add the icon width */ … … 1095 1096 1096 1097 infoPtr->items[curItem].rect.right = infoPtr->items[curItem].rect.left + 1097 size.cx + icon_width + 1098 size.cx + icon_width + 1098 1099 num * HORIZONTAL_ITEM_PADDING; 1099 1100 } … … 1114 1115 infoPtr->items[curItem].rect.left; 1115 1116 1116 1117 infoPtr->items[curItem].rect.left = 0; 1117 1118 curItemRowCount++; 1118 1119 } … … 1122 1123 1123 1124 TRACE("TextSize: %li\n", size.cx); 1124 TRACE("Rect: T %i, L %i, B %i, R %i\n", 1125 1126 1127 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); 1129 1130 1130 1131 /* … … 1152 1153 /* Don't need scrolling, then update infoPtr->leftmostVisible */ 1153 1154 if(!infoPtr->needsScrolling) 1154 infoPtr->leftmostVisible = 0; 1155 infoPtr->leftmostVisible = 0; 1155 1156 1156 1157 TAB_SetupScrolling(hwnd, infoPtr, &clientRect); … … 1193 1194 1194 1195 /* shift the item to the left side of the clientRect */ 1195 infoPtr->items[iItm].rect.right -= 1196 infoPtr->items[iItm].rect.right -= 1196 1197 infoPtr->items[iItm].rect.left; 1197 1198 infoPtr->items[iItm].rect.left = 0; … … 1202 1203 infoPtr->items[iItm].rect.top = iRow; 1203 1204 if (lStyle & TCS_BUTTONS) 1204 1205 { 1205 1206 curItemLeftPos = infoPtr->items[iItm].rect.right + 1; 1206 1207 if (lStyle & TCS_FLATBUTTONS) 1207 1208 1208 curItemLeftPos += FLAT_BTN_SPACINGX; 1209 } 1209 1210 else 1210 1211 curItemLeftPos = infoPtr->items[iItm].rect.right; 1211 1212 } 1212 1213 1213 1214 /* 1214 1215 * Justify the rows … … 1217 1218 while(iIndexStart < infoPtr->uNumItem) 1218 1219 { 1219 /* 1220 /* 1220 1221 * find the indexs of the row 1221 1222 */ 1222 1223 /* find the first item on the next row */ 1223 1224 for (iIndexEnd=iIndexStart; 1224 (iIndexEnd < infoPtr->uNumItem) && 1225 1225 (iIndexEnd < infoPtr->uNumItem) && 1226 (infoPtr->items[iIndexEnd].rect.top == 1226 1227 infoPtr->items[iIndexStart].rect.top) ; 1227 1228 iIndexEnd++) 1228 1229 /* intentionaly blank */; 1229 1230 1230 /* 1231 /* 1231 1232 * we need to justify these tabs so they fill the whole given 1232 1233 * client area … … 1246 1247 widthDiff = widthDiff / iCount; 1247 1248 /* 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; 1249 1250 iIndex++,iCount++) 1250 1251 { … … 1297 1298 * This method is used to draw the interior (text and icon) of a single tab 1298 1299 * into the tab control. 1299 */ 1300 */ 1300 1301 static void 1301 1302 TAB_DrawItemInterior … … 1390 1391 id = GetWindowLongA( hwnd, GWL_ID ); 1391 1392 1392 /* 1393 /* 1393 1394 * put together the DRAWITEMSTRUCT 1394 1395 */ 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; 1399 1400 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; /* */ 1406 1407 dis.itemData = infoPtr->items[iItem].lParam; 1407 1408 … … 1538 1539 if(lStyle & TCS_VERTICAL) 1539 1540 { 1540 if (!GetObjectA((infoPtr->hFont) ? 1541 if (!GetObjectA((infoPtr->hFont) ? 1541 1542 infoPtr->hFont : GetStockObject(SYSTEM_FONT), 1542 1543 sizeof(LOGFONTA),&logfont)) … … 1545 1546 1546 1547 lstrcpyA(logfont.lfFaceName, "Arial"); 1547 logfont.lfHeight = -MulDiv(iPointSize, GetDeviceCaps(hdc, LOGPIXELSY), 1548 logfont.lfHeight = -MulDiv(iPointSize, GetDeviceCaps(hdc, LOGPIXELSY), 1548 1549 72); 1549 1550 logfont.lfWeight = FW_NORMAL; … … 1604 1605 * 1605 1606 * This method is used to draw a single tab into the tab control. 1606 */ 1607 */ 1607 1608 static void TAB_DrawItem( 1608 HWND hwnd, 1609 HDC hdc, 1609 HWND hwnd, 1610 HDC hdc, 1610 1611 INT iItem) 1611 1612 { … … 1621 1622 */ 1622 1623 isVisible = TAB_InternalGetItemRect(hwnd, 1623 1624 1625 1626 1624 infoPtr, 1625 iItem, 1626 &itemRect, 1627 &selectedRect); 1627 1628 1628 1629 if (isVisible) 1629 1630 { 1630 HBRUSH hbr = CreateSolidBrush (GetSysColor(COLOR_BTNFACE)); 1631 HBRUSH hbr = CreateSolidBrush (GetSysColor(COLOR_BTNFACE)); 1631 1632 HPEN hwPen = GetSysColorPen (COLOR_3DHILIGHT); 1632 1633 HPEN hbPen = GetSysColorPen (COLOR_3DDKSHADOW); … … 1645 1646 /* Separators between flat buttons */ 1646 1647 /* FIXME: test and correct this if necessary for TCS_FLATBUTTONS style */ 1647 if (lStyle & TCS_FLATBUTTONS) 1648 if (lStyle & TCS_FLATBUTTONS) 1648 1649 { 1649 1650 int x = r.right + FLAT_BTN_SPACINGX - 2; … … 1669 1670 /* Background color */ 1670 1671 if (!((lStyle & TCS_OWNERDRAWFIXED) && infoPtr->fSizeSet)) 1671 1672 { 1672 1673 COLORREF bk = GetSysColor(COLOR_3DHILIGHT); 1673 1674 DeleteObject(hbr); … … 1685 1686 1686 1687 deleteBrush = FALSE; 1687 1688 } 1688 1689 1689 1690 /* Erase the background */ … … 1704 1705 LineTo (hdc, r.right, r.bottom); 1705 1706 LineTo (hdc, r.right, r.top + 1); 1706 1707 1707 1708 /* shadow */ 1708 1709 SelectObject(hdc, hbPen); … … 1721 1722 FillRect(hdc, &r, hbr); 1722 1723 1723 1724 1724 if (!(lStyle & TCS_FLATBUTTONS)) 1725 { 1725 1726 /* highlight */ 1726 1727 MoveToEx (hdc, r.left, r.bottom, NULL); 1727 1728 LineTo (hdc, r.left, r.top); 1728 1729 LineTo (hdc, r.right, r.top); 1729 1730 1730 1731 /* shadow */ 1731 1732 SelectObject(hdc, hbPen); … … 1738 1739 LineTo (hdc, r.right - 1, r.bottom - 1); 1739 1740 LineTo (hdc, r.left + 1, r.bottom - 1); 1740 1741 } 1741 1742 } 1742 1743 } … … 1745 1746 /* Background color */ 1746 1747 DeleteObject(hbr); 1747 hbr = CreateSolidBrush(GetSysColor(COLOR_BTNFACE)); 1748 hbr = CreateSolidBrush(GetSysColor(COLOR_BTNFACE)); 1748 1749 1749 1750 /* We draw a rectangle of different sizes depending on the selection … … 1756 1757 /* 1757 1758 * 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 1760 1761 * other tabs 1761 */ 1762 */ 1762 1763 FillRect(hdc, &r, hbr); 1763 1764 … … 1770 1771 r.right--; 1771 1772 r.bottom--; 1772 1773 1773 1774 holdPen = SelectObject (hdc, hwPen); 1774 1775 if(lStyle & TCS_VERTICAL) … … 1859 1860 } 1860 1861 } 1861 1862 1862 1863 /* This modifies r to be the text rectangle. */ 1863 1864 { … … 1868 1869 /* Draw the focus rectangle */ 1869 1870 if (((lStyle & TCS_FOCUSNEVER) == 0) && 1870 1871 1871 (GetFocus() == hwnd) && 1872 (iItem == infoPtr->uFocus) ) 1872 1873 { 1873 1874 r = itemRect; … … 1888 1889 * This method is used to draw the raised border around the tab control 1889 1890 * "content" area. 1890 */ 1891 */ 1891 1892 static void TAB_DrawBorder (HWND hwnd, HDC hdc) 1892 1893 { … … 1957 1958 * 1958 1959 * This method repaints the tab control.. 1959 */ 1960 */ 1960 1961 static void TAB_Refresh (HWND hwnd, HDC hdc) 1961 1962 { … … 1971 1972 if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BUTTONS) 1972 1973 { 1973 for (i = 0; i < infoPtr->uNumItem; i++) 1974 for (i = 0; i < infoPtr->uNumItem; i++) 1974 1975 TAB_DrawItem (hwnd, hdc, i); 1975 1976 } … … 1977 1978 { 1978 1979 /* Draw all the non selected item first */ 1979 for (i = 0; i < infoPtr->uNumItem; i++) 1980 for (i = 0; i < infoPtr->uNumItem; i++) 1980 1981 { 1981 1982 if (i != infoPtr->iSelected) 1982 1983 TAB_DrawItem (hwnd, hdc, i); 1983 1984 } 1984 1985 … … 2011 2012 { 2012 2013 TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); 2013 2014 2014 2015 infoPtr->DoRedraw=(BOOL) wParam; 2015 2016 return 0; … … 2017 2018 2018 2019 static LRESULT TAB_EraseBackground( 2019 HWND hwnd, 2020 HWND hwnd, 2020 2021 HDC givenDC) 2021 2022 { … … 2207 2208 HDC hdc; 2208 2209 PAINTSTRUCT ps; 2209 2210 2210 2211 hdc = wParam== 0 ? BeginPaint (hwnd, &ps) : (HDC)wParam; 2211 2212 TAB_Refresh (hwnd, hdc); 2212 2213 2213 2214 if(!wParam) 2214 2215 EndPaint (hwnd, &ps); … … 2219 2220 static LRESULT 2220 2221 TAB_InsertItemA (HWND hwnd, WPARAM wParam, LPARAM lParam) 2221 { 2222 { 2222 2223 TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); 2223 2224 TCITEMA *pti; 2224 2225 INT iItem; 2225 2226 RECT rect; 2226 2227 2227 2228 GetClientRect (hwnd, &rect); 2228 2229 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 2231 2232 pti = (TCITEMA *)lParam; 2232 2233 iItem = (INT)wParam; 2233 2234 2234 2235 if (iItem < 0) return -1; 2235 2236 if (iItem > infoPtr->uNumItem) 2236 2237 iItem = infoPtr->uNumItem; 2237 2238 2238 2239 if (infoPtr->uNumItem == 0) { 2239 2240 infoPtr->items = COMCTL32_Alloc (sizeof (TAB_ITEM)); … … 2243 2244 else { 2244 2245 TAB_ITEM *oldItems = infoPtr->items; 2245 2246 2246 2247 infoPtr->uNumItem++; 2247 2248 infoPtr->items = COMCTL32_Alloc (sizeof (TAB_ITEM) * infoPtr->uNumItem); 2248 2249 2249 2250 /* pre insert copy */ 2250 2251 if (iItem > 0) { 2251 2252 memcpy (&infoPtr->items[0], &oldItems[0], 2252 2253 } 2254 2253 iItem * sizeof(TAB_ITEM)); 2254 } 2255 2255 2256 /* post insert copy */ 2256 2257 if (iItem < infoPtr->uNumItem - 1) { 2257 2258 memcpy (&infoPtr->items[iItem+1], &oldItems[iItem], 2258 2259 2259 (infoPtr->uNumItem - iItem - 1) * sizeof(TAB_ITEM)); 2260 2260 2261 } 2261 2262 … … 2265 2266 COMCTL32_Free (oldItems); 2266 2267 } 2267 2268 2268 2269 infoPtr->items[iItem].mask = pti->mask; 2269 2270 if (pti->mask & TCIF_TEXT) … … 2272 2273 if (pti->mask & TCIF_IMAGE) 2273 2274 infoPtr->items[iItem].iImage = pti->iImage; 2274 2275 2275 2276 if (pti->mask & TCIF_PARAM) 2276 2277 infoPtr->items[iItem].lParam = pti->lParam; 2277 2278 2278 2279 TAB_SetItemBounds(hwnd); 2279 2280 TAB_InvalidateTabArea(hwnd, infoPtr); 2280 2281 2281 2282 TRACE("[%04x]: added item %d '%s'\n", 2282 2283 hwnd, iItem, debugstr_w(infoPtr->items[iItem].pszText)); 2283 2284 2284 2285 return iItem; … … 2319 2320 if (iItem > 0) { 2320 2321 memcpy (&infoPtr->items[0], &oldItems[0], 2321 2322 iItem * sizeof(TAB_ITEM)); 2322 2323 } 2323 2324 … … 2325 2326 if (iItem < infoPtr->uNumItem - 1) { 2326 2327 memcpy (&infoPtr->items[iItem+1], &oldItems[iItem], 2327 2328 2329 } 2330 2328 (infoPtr->uNumItem - iItem - 1) * sizeof(TAB_ITEM)); 2329 2330 } 2331 2331 2332 if (iItem <= infoPtr->iSelected) 2332 2333 infoPtr->iSelected++; … … 2341 2342 if (pti->mask & TCIF_IMAGE) 2342 2343 infoPtr->items[iItem].iImage = pti->iImage; 2343 2344 2344 2345 if (pti->mask & TCIF_PARAM) 2345 2346 infoPtr->items[iItem].lParam = pti->lParam; 2346 2347 2347 2348 TAB_SetItemBounds(hwnd); 2348 2349 TAB_InvalidateTabArea(hwnd, infoPtr); 2349 2350 2350 2351 TRACE("[%04x]: added item %d '%s'\n", 2351 2352 hwnd, iItem, debugstr_w(infoPtr->items[iItem].pszText)); 2352 2353 2353 2354 return iItem; … … 2355 2356 2356 2357 2357 static LRESULT 2358 static LRESULT 2358 2359 TAB_SetItemSize (HWND hwnd, WPARAM wParam, LPARAM lParam) 2359 2360 { … … 2373 2374 } 2374 2375 2375 static LRESULT 2376 static LRESULT 2376 2377 TAB_SetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam) 2377 2378 { 2378 2379 TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); 2379 TCITEMA *tabItem; 2380 TCITEMA *tabItem; 2380 2381 TAB_ITEM *wineItem; 2381 2382 INT iItem; … … 2395 2396 wineItem->lParam = tabItem->lParam; 2396 2397 2397 if (tabItem->mask & TCIF_RTLREADING) 2398 if (tabItem->mask & TCIF_RTLREADING) 2398 2399 FIXME("TCIF_RTLREADING\n"); 2399 2400 2400 if (tabItem->mask & TCIF_STATE) 2401 if (tabItem->mask & TCIF_STATE) 2401 2402 wineItem->dwState = tabItem->dwState; 2402 2403 … … 2451 2452 2452 2453 2453 static LRESULT 2454 static LRESULT 2454 2455 TAB_GetItemCount (HWND hwnd, WPARAM wParam, LPARAM lParam) 2455 2456 { … … 2460 2461 2461 2462 2462 static LRESULT 2463 static LRESULT 2463 2464 TAB_GetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam) 2464 2465 { … … 2476 2477 wineItem = &infoPtr->items[iItem]; 2477 2478 2478 if (tabItem->mask & TCIF_IMAGE) 2479 if (tabItem->mask & TCIF_IMAGE) 2479 2480 tabItem->iImage = wineItem->iImage; 2480 2481 2481 if (tabItem->mask & TCIF_PARAM) 2482 if (tabItem->mask & TCIF_PARAM) 2482 2483 tabItem->lParam = wineItem->lParam; 2483 2484 2484 if (tabItem->mask & TCIF_RTLREADING) 2485 if (tabItem->mask & TCIF_RTLREADING) 2485 2486 FIXME("TCIF_RTLREADING\n"); 2486 2487 2487 if (tabItem->mask & TCIF_STATE) 2488 if (tabItem->mask & TCIF_STATE) 2488 2489 tabItem->dwState = wineItem->dwState; 2489 2490 2490 if (tabItem->mask & TCIF_TEXT) 2491 if (tabItem->mask & TCIF_TEXT) 2491 2492 Str_GetPtrWtoA (wineItem->pszText, tabItem->pszText, tabItem->cchTextMax); 2492 2493 … … 2495 2496 2496 2497 2497 static LRESULT 2498 static LRESULT 2498 2499 TAB_GetItemW (HWND hwnd, WPARAM wParam, LPARAM lParam) 2499 2500 { … … 2530 2531 2531 2532 2532 static LRESULT 2533 static LRESULT 2533 2534 TAB_DeleteItem (HWND hwnd, WPARAM wParam, LPARAM lParam) 2534 2535 { … … 2540 2541 { 2541 2542 TAB_ITEM *oldItems = infoPtr->items; 2542 2543 2543 2544 infoPtr->uNumItem--; 2544 2545 infoPtr->items = COMCTL32_Alloc(sizeof (TAB_ITEM) * infoPtr->uNumItem); 2545 2546 if (iItem > 0) 2546 2547 if (iItem > 0) 2547 2548 memcpy(&infoPtr->items[0], &oldItems[0], iItem * sizeof(TAB_ITEM)); 2548 2549 if (iItem < infoPtr->uNumItem) 2549 2550 if (iItem < infoPtr->uNumItem) 2550 2551 memcpy(&infoPtr->items[iItem], &oldItems[iItem + 1], 2551 2552 (infoPtr->uNumItem - iItem) * sizeof(TAB_ITEM)); 2552 2553 2553 2554 COMCTL32_Free(oldItems); 2554 2555 … … 2556 2557 if ((iItem == infoPtr->iSelected) && (iItem > 0)) 2557 2558 infoPtr->iSelected--; 2558 2559 2559 2560 if (iItem < infoPtr->iSelected) 2560 2561 infoPtr->iSelected--; … … 2573 2574 } 2574 2575 2575 static LRESULT 2576 static LRESULT 2576 2577 TAB_DeleteAllItems (HWND hwnd, WPARAM wParam, LPARAM lParam) 2577 2578 { … … 2584 2585 KillTimer(hwnd, TAB_HOTTRACK_TIMER); 2585 2586 infoPtr->iHotTracked = -1; 2586 2587 2587 2588 TAB_SetItemBounds(hwnd); 2588 2589 TAB_InvalidateTabArea(hwnd,infoPtr); … … 2605 2606 { 2606 2607 TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); 2607 2608 2608 2609 TRACE("%x %lx\n",wParam, lParam); 2609 2610 2610 2611 infoPtr->hFont = (HFONT)wParam; 2611 2612 2612 2613 TAB_SetItemBounds(hwnd); 2613 2614 … … 2676 2677 cx=LOWORD (lParam); 2677 2678 cy=HIWORD (lParam); 2678 if (GetWindowLongA(hwnd, GWL_STYLE) & CCS_NORESIZE) 2679 if (GetWindowLongA(hwnd, GWL_STYLE) & CCS_NORESIZE) 2679 2680 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE); 2680 2681 … … 2695 2696 2696 2697 2697 static LRESULT 2698 static LRESULT 2698 2699 TAB_Create (HWND hwnd, WPARAM wParam, LPARAM lParam) 2699 2700 { … … 2711 2712 2712 2713 SetWindowLongA(hwnd, 0, (DWORD)infoPtr); 2713 2714 2714 2715 infoPtr->uNumItem = 0; 2715 2716 infoPtr->uNumRows = 0; … … 2719 2720 infoPtr->iSelected = -1; 2720 2721 infoPtr->iHotTracked = -1; 2721 infoPtr->uFocus = -1; 2722 infoPtr->uFocus = -1; 2722 2723 infoPtr->hwndToolTip = 0; 2723 2724 infoPtr->DoRedraw = TRUE; … … 2725 2726 infoPtr->hwndUpDown = 0; 2726 2727 infoPtr->leftmostVisible = 0; 2727 infoPtr->fSizeSet 2728 infoPtr->bUnicode 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 2734 2735 order for paint to work correctly. This follows windows behaviour. */ 2735 2736 dwStyle = GetWindowLongA(hwnd, GWL_STYLE); … … 2740 2741 infoPtr->hwndToolTip = 2741 2742 CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0, 2742 2743 2744 2745 2743 CW_USEDEFAULT, CW_USEDEFAULT, 2744 CW_USEDEFAULT, CW_USEDEFAULT, 2745 hwnd, 0, 0, 0); 2746 2746 2747 /* Send NM_TOOLTIPSCREATED notification */ 2747 2748 if (infoPtr->hwndToolTip) { 2748 2749 NMTOOLTIPSCREATED nmttc; 2749 2750 2750 2751 nmttc.hdr.hwndFrom = hwnd; 2751 2752 nmttc.hdr.idFrom = GetWindowLongA(hwnd, GWL_ID); 2752 2753 nmttc.hdr.code = NM_TOOLTIPSCREATED; 2753 2754 nmttc.hwndToolTips = infoPtr->hwndToolTip; 2754 2755 2755 2756 SendMessageA (GetParent (hwnd), WM_NOTIFY, 2756 2757 } 2758 } 2759 2757 (WPARAM)GetWindowLongA(hwnd, GWL_ID), (LPARAM)&nmttc); 2758 } 2759 } 2760 2760 2761 /* 2761 2762 * We need to get text information so we need a DC and we need to select 2762 2763 * a font. 2763 2764 */ 2764 hdc = GetDC(hwnd); 2765 hdc = GetDC(hwnd); 2765 2766 hOldFont = SelectObject (hdc, GetStockObject (SYSTEM_FONT)); 2766 2767 … … 2769 2770 2770 2771 /* 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. 2773 2774 */ 2774 2775 infoPtr->tabHeight = fontMetrics.tmHeight + 2 * VERTICAL_ITEM_PADDING + … … 2796 2797 for (iItem = 0; iItem < infoPtr->uNumItem; iItem++) { 2797 2798 if (infoPtr->items[iItem].pszText) 2798 2799 COMCTL32_Free (infoPtr->items[iItem].pszText); 2799 2800 } 2800 2801 COMCTL32_Free (infoPtr->items); 2801 2802 } 2802 2803 if (infoPtr->hwndToolTip) 2803 2804 if (infoPtr->hwndToolTip) 2804 2805 DestroyWindow (infoPtr->hwndToolTip); 2805 2806 2806 2807 if (infoPtr->hwndUpDown) 2807 2808 DestroyWindow(infoPtr->hwndUpDown); … … 2827 2828 case TCM_GETIMAGELIST: 2828 2829 return TAB_GetImageList (hwnd, wParam, lParam); 2829 2830 2830 2831 case TCM_SETIMAGELIST: 2831 2832 return TAB_SetImageList (hwnd, wParam, lParam); 2832 2833 2833 2834 case TCM_GETITEMCOUNT: 2834 2835 return TAB_GetItemCount (hwnd, wParam, lParam); 2835 2836 2836 2837 case TCM_GETITEMA: 2837 2838 return TAB_GetItemA (hwnd, wParam, lParam); 2838 2839 2839 2840 case TCM_GETITEMW: 2840 2841 return TAB_GetItemW (hwnd, wParam, lParam); 2841 2842 2842 2843 case TCM_SETITEMA: 2843 2844 return TAB_SetItemA (hwnd, wParam, lParam); 2844 2845 2845 2846 case TCM_SETITEMW: 2846 2847 return TAB_SetItemW (hwnd, wParam, lParam); 2847 2848 2848 2849 case TCM_DELETEITEM: 2849 2850 return TAB_DeleteItem (hwnd, wParam, lParam); 2850 2851 2851 2852 case TCM_DELETEALLITEMS: 2852 2853 return TAB_DeleteAllItems (hwnd, wParam, lParam); 2853 2854 2854 2855 case TCM_GETITEMRECT: 2855 2856 return TAB_GetItemRect (hwnd, wParam, lParam); 2856 2857 2857 2858 case TCM_GETCURSEL: 2858 2859 return TAB_GetCurSel (hwnd); 2859 2860 2860 2861 case TCM_HITTEST: 2861 2862 return TAB_HitTest (hwnd, wParam, lParam); 2862 2863 2863 2864 case TCM_SETCURSEL: 2864 2865 return TAB_SetCurSel (hwnd, wParam); 2865 2866 2866 2867 case TCM_INSERTITEMA: 2867 2868 return TAB_InsertItemA (hwnd, wParam, lParam); 2868 2869 2869 2870 case TCM_INSERTITEMW: 2870 2871 return TAB_InsertItemW (hwnd, wParam, lParam); 2871 2872 2872 2873 case TCM_SETITEMEXTRA: 2873 2874 FIXME("Unimplemented msg TCM_SETITEMEXTRA\n"); 2874 2875 return 0; 2875 2876 2876 2877 case TCM_ADJUSTRECT: 2877 2878 return TAB_AdjustRect (hwnd, (BOOL)wParam, (LPRECT)lParam); 2878 2879 2879 2880 case TCM_SETITEMSIZE: 2880 2881 return TAB_SetItemSize (hwnd, wParam, lParam); 2881 2882 2882 2883 case TCM_REMOVEIMAGE: 2883 2884 FIXME("Unimplemented msg TCM_REMOVEIMAGE\n"); 2884 2885 return 0; 2885 2886 2886 2887 case TCM_SETPADDING: 2887 2888 FIXME("Unimplemented msg TCM_SETPADDING\n"); 2888 2889 return 0; 2889 2890 2890 2891 case TCM_GETROWCOUNT: 2891 2892 return TAB_GetRowCount(hwnd); … … 2900 2901 FIXME("Unimplemented msg TCM_HIGHLIGHTITEM\n"); 2901 2902 return 0; 2902 2903 2903 2904 case TCM_GETTOOLTIPS: 2904 2905 return TAB_GetToolTips (hwnd, wParam, lParam); 2905 2906 2906 2907 case TCM_SETTOOLTIPS: 2907 2908 return TAB_SetToolTips (hwnd, wParam, lParam); 2908 2909 2909 2910 case TCM_GETCURFOCUS: 2910 2911 return TAB_GetCurFocus (hwnd); 2911 2912 2912 2913 case TCM_SETCURFOCUS: 2913 2914 return TAB_SetCurFocus (hwnd, wParam); 2914 2915 2915 2916 case TCM_SETMINTABWIDTH: 2916 2917 FIXME("Unimplemented msg TCM_SETMINTABWIDTH\n"); 2917 2918 return 0; 2918 2919 2919 2920 case TCM_DESELECTALL: 2920 2921 FIXME("Unimplemented msg TCM_DESELECTALL\n"); 2921 2922 return 0; 2922 2923 2923 2924 case TCM_GETEXTENDEDSTYLE: 2924 2925 FIXME("Unimplemented msg TCM_GETEXTENDEDSTYLE\n"); … … 2931 2932 case WM_GETFONT: 2932 2933 return TAB_GetFont (hwnd, wParam, lParam); 2933 2934 2934 2935 case WM_SETFONT: 2935 2936 return TAB_SetFont (hwnd, wParam, lParam); 2936 2937 2937 2938 case WM_CREATE: 2938 2939 return TAB_Create (hwnd, wParam, lParam); 2939 2940 2940 2941 case WM_NCDESTROY: 2941 2942 return TAB_Destroy (hwnd, wParam, lParam); 2942 2943 2943 2944 case WM_GETDLGCODE: 2944 2945 return DLGC_WANTARROWS | DLGC_WANTCHARS; 2945 2946 2946 2947 case WM_LBUTTONDOWN: 2947 2948 return TAB_LButtonDown (hwnd, wParam, lParam); 2948 2949 2949 2950 case WM_LBUTTONUP: 2950 2951 return TAB_LButtonUp (hwnd, wParam, lParam); 2951 2952 2952 2953 case WM_RBUTTONDOWN: 2953 2954 return TAB_RButtonDown (hwnd, wParam, lParam); 2954 2955 2955 2956 case WM_MOUSEMOVE: 2956 2957 return TAB_MouseMove (hwnd, wParam, lParam); 2957 2958 2958 2959 case WM_ERASEBKGND: 2959 2960 return TAB_EraseBackground (hwnd, (HDC)wParam); … … 2964 2965 case WM_SIZE: 2965 2966 return TAB_Size (hwnd, wParam, lParam); 2966 2967 2967 2968 case WM_SETREDRAW: 2968 2969 return TAB_SetRedraw (hwnd, wParam); … … 2975 2976 InvalidateRect(hwnd, NULL, TRUE); 2976 2977 return 0; 2977 2978 2978 2979 case WM_KILLFOCUS: 2979 2980 case WM_SETFOCUS: … … 2987 2988 default: 2988 2989 if (uMsg >= WM_USER) 2989 2990 2990 WARN("unknown msg %04x wp=%08x lp=%08lx\n", 2991 uMsg, wParam, lParam); 2991 2992 #ifdef __WIN32OS2__ 2992 2993 return defComCtl32ProcA (hwnd, uMsg, wParam, lParam); … … 3013 3014 wndClass.hbrBackground = (HBRUSH)NULL; 3014 3015 wndClass.lpszClassName = WC_TABCONTROLA; 3015 3016 3016 3017 RegisterClassA (&wndClass); 3017 3018 } -
trunk/src/comctl32/toolbar.c
r6380 r6644 1 /* $Id: toolbar.c,v 1.29 2001-09-05 12:05:03 bird Exp $ */ 1 2 /* 2 3 * Toolbar control … … 62 63 INT nRow; 63 64 RECT rect; 64 } TBUTTON_INFO; 65 } TBUTTON_INFO; 65 66 66 67 #ifdef __WIN32OS2__ … … 131 132 #define TOP_BORDER 2 132 133 #define BOTTOM_BORDER 2 133 #define DDARROW_WIDTH 11 134 #define DDARROW_WIDTH 11 134 135 135 136 #define TOOLBAR_GetInfoPtr(hwnd) ((TOOLBAR_INFO *)GetWindowLongA(hwnd,0)) … … 147 148 else if ((btnPtr->iString >= 0) && (btnPtr->iString < infoPtr->nNumStrings)) 148 149 lpText = infoPtr->strings[btnPtr->iString]; 149 150 150 151 return lpText; 151 152 } 152 153 153 static BOOL 154 static BOOL 154 155 TOOLBAR_IsValidBitmapIndex(TOOLBAR_INFO *infoPtr, INT index) 155 156 { … … 195 196 * Draw the text string for this button. 196 197 * note: infoPtr->himlDis *SHOULD* be non-zero when infoPtr->himlDef 197 * 198 * is non-zero, so we can simply check himlDef to see if we have 198 199 * an image list 199 200 */ 200 201 static void 201 202 TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, 202 203 HDC hdc, INT nState, DWORD dwStyle) 203 204 { 204 205 RECT rcText = btnPtr->rect; … … 219 220 if (lpText) { 220 221 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 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); 260 261 } 261 262 } … … 275 276 static void 276 277 TOOLBAR_DrawMasked (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, 277 278 HDC hdc, INT x, INT y) 278 279 { 279 280 /* FIXME: this function is a hack since it uses image list 280 281 internals directly */ 281 282 282 283 HIMAGELIST himl = infoPtr->himlDef; … … 286 287 287 288 if (!himl) 288 289 return; 289 290 290 291 /* create new dc's */ … … 301 302 SetTextColor (hdcImageList, RGB(0, 0, 0)); 302 303 BitBlt (hdcMask, 0, 0, himl->cx, himl->cy, 303 304 hdcImageList, himl->cx * btnPtr->iBitmap, 0, SRCCOPY); 304 305 305 306 /* draw the new mask */ 306 307 SelectObject (hdc, GetSysColorBrush (COLOR_3DHILIGHT)); 307 308 BitBlt (hdc, x+1, y+1, himl->cx, himl->cy, 308 309 hdcMask, 0, 0, 0xB8074A); 309 310 310 311 SelectObject (hdc, GetSysColorBrush (COLOR_3DSHADOW)); 311 312 BitBlt (hdc, x, y, himl->cx, himl->cy, 312 313 hdcMask, 0, 0, 0xB8074A); 313 314 314 315 DeleteObject (hbmMask); … … 324 325 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); 325 326 BOOL hasDropDownArrow = TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) && 326 327 (btnPtr->fsStyle & TBSTYLE_DROPDOWN); 327 328 RECT rc, rcArrow, rcBitmap; 328 329 329 330 if (btnPtr->fsState & TBSTATE_HIDDEN) 330 331 return; 331 332 332 333 rc = btnPtr->rect; … … 338 339 if (hasDropDownArrow) 339 340 { 340 341 if (dwStyle & TBSTYLE_FLAT) 341 342 rc.right = max(rc.left, rc.right - DDARROW_WIDTH); 342 343 else 343 344 rc.right = max(rc.left, rc.right - DDARROW_WIDTH - 2); 344 rcArrow.left = rc.right; 345 rcArrow.left = rc.right; 345 346 } 346 347 … … 363 364 /* when drawing the vertical bar... */ 364 365 if ((dwStyle & TBSTYLE_FLAT) /* && (btnPtr->iBitmap == 0) */) 365 366 366 TOOLBAR_DrawFlatSeparator (&rc, hdc); 367 return; 367 368 } 368 369 369 370 /* disabled */ 370 371 if (!(btnPtr->fsState & TBSTATE_ENABLED)) { 371 372 373 374 372 if (!(dwStyle & TBSTYLE_FLAT)) 373 { 374 DrawEdge (hdc, &rc, EDGE_RAISED, 375 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 375 376 if (hasDropDownArrow) 376 377 DrawEdge (hdc, &rcArrow, EDGE_RAISED, 377 378 379 378 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 379 } 380 380 381 if (hasDropDownArrow) 381 382 383 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 && 387 388 TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) 388 389 390 391 392 393 394 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; 395 396 } 396 397 397 398 /* pressed TBSTYLE_BUTTON */ 398 399 if (btnPtr->fsState & TBSTATE_PRESSED) { 399 400 401 400 if (dwStyle & TBSTYLE_FLAT) 401 { 402 DrawEdge (hdc, &rc, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE | BF_ADJUST); 402 403 if (hasDropDownArrow) 403 404 405 406 407 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); 408 409 if (hasDropDownArrow) 409 410 410 DrawEdge (hdc, &rcArrow, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST); 411 } 411 412 412 413 if (hasDropDownArrow) 413 414 TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_WINDOWFRAME); 414 415 415 416 if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) 416 417 418 419 420 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; 421 422 } 422 423 423 424 /* checked TBSTYLE_CHECK */ 424 425 if ((btnPtr->fsStyle & TBSTYLE_CHECK) && 425 426 427 428 429 430 431 432 433 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 435 436 if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) 436 437 438 439 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 */ 443 444 if (btnPtr->fsState & TBSTATE_INDETERMINATE) { 444 445 446 447 448 449 450 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; 451 452 } 452 453 … … 454 455 if (dwStyle & TBSTYLE_FLAT) 455 456 { 456 457 458 457 if (btnPtr->bHot) 458 { 459 DrawEdge (hdc, &rc, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE); 459 460 if (hasDropDownArrow) 460 461 461 DrawEdge (hdc, &rcArrow, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE); 462 } 462 463 else 463 464 { 464 465 FrameRect(hdc, &rc, GetSysColorBrush(COLOR_BTNFACE)); 465 466 if (hasDropDownArrow) 466 467 FrameRect(hdc, &rcArrow, GetSysColorBrush(COLOR_BTNFACE)); 467 468 } 468 469 469 470 if (hasDropDownArrow) 470 471 472 471 TOOLBAR_DrawArrow(hdc, rcArrow.left+1, rcArrow.top, COLOR_WINDOWFRAME); 472 473 if (btnPtr->bHot && infoPtr->himlHot && 473 474 TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) 474 475 476 477 478 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); 479 480 } 480 481 else 481 482 { 482 483 483 DrawEdge (hdc, &rc, EDGE_RAISED, 484 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 484 485 485 486 if (hasDropDownArrow) 486 487 488 489 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 } 491 492 492 493 if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) 493 494 494 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc, 495 rcBitmap.left, rcBitmap.top, ILD_NORMAL); 495 496 } 496 497 … … 537 538 if (!(btnPtr->fsState & TBSTATE_HIDDEN) && 538 539 (btnPtr->iString > -1) && 539 (btnPtr->iString < infoPtr->nNumStrings)) 540 (btnPtr->iString < infoPtr->nNumStrings)) 540 541 { 541 542 LPWSTR lpText = infoPtr->strings[btnPtr->iString]; … … 577 578 578 579 /*********************************************************************** 579 * 580 * TOOLBAR_WrapToolbar 580 581 * 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 587 588 * flag, and set the TBSTATE_WRAP flags manually on the appropriate items. 588 */ 589 */ 589 590 590 591 static void … … 597 598 BOOL bWrap, bButtonWrap; 598 599 599 /* When the toolbar window style is not TBSTYLE_WRAPABLE, */600 /* 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. */ 602 603 if( !(dwStyle & TBSTYLE_WRAPABLE) ) 603 604 return; 604 605 605 606 btnPtr = infoPtr->buttons; … … 616 617 for (i = 0; i < infoPtr->nNumButtons; i++ ) 617 618 { 618 619 620 621 622 623 624 625 626 627 628 cx = (btnPtr[i].iBitmap > 0) ? 629 630 631 632 633 /* Two or more adjacent separators form a separator group. */ 634 635 /* next row if the previous wrapping is on a button.*/636 637 (btnPtr[i].fsStyle & TBSTYLE_SEP) && 638 639 (btnPtr[i + 1].fsStyle & TBSTYLE_SEP) ) 640 641 642 643 644 645 646 647 648 649 if ( x + cx - (infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2 650 > infoPtr->nWidth ) 651 652 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 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 /* If the current button is not a separator, find the last */ 677 /* separator and wrap it.*/678 679 680 681 682 683 bFound = TRUE; 684 i = j; 685 686 687 bButtonWrap = FALSE; 688 689 690 691 692 /* If no separator available for wrapping, wrap one of*/693 /* non-hidden previous button.*/694 695 696 for ( j = i - 1; 697 698 699 if (btnPtr[j].fsState & TBSTATE_HIDDEN) 700 701 702 bFound = TRUE; 703 i = j; 704 705 706 707 708 709 710 711 712 if (!bFound) 713 714 715 716 717 718 719 720 721 } 722 723 724 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; 725 726 } 726 727 } … … 728 729 729 730 /*********************************************************************** 730 * 731 * TOOLBAR_CalcToolbar 731 732 * 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 735 736 * 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 */ 739 740 740 741 static void … … 755 756 if (dwStyle & TBSTYLE_LIST) 756 757 { 757 758 758 infoPtr->nButtonHeight = max(infoPtr->nBitmapHeight, sizeString.cy) + 6; 759 infoPtr->nButtonWidth = infoPtr->nBitmapWidth + sizeString.cx + 6; 759 760 } 760 761 else { 761 762 for (i = 0; i < infoPtr->nNumButtons && !usesBitmaps; i++) 762 763 { 763 764 764 if (TOOLBAR_IsValidBitmapIndex(infoPtr,infoPtr->buttons[i].iBitmap)) 765 usesBitmaps = TRUE; 765 766 } 766 767 … … 768 769 { 769 770 if (usesBitmaps) 770 771 infoPtr->nButtonHeight = sizeString.cy + 771 772 infoPtr->nBitmapHeight + 6; 772 else 773 else 773 774 infoPtr->nButtonHeight = sizeString.cy + 6; 774 775 } 775 776 else if (infoPtr->nButtonHeight < infoPtr->nBitmapHeight + 6) 776 777 infoPtr->nButtonHeight = infoPtr->nBitmapHeight + 6; 777 778 778 779 if (sizeString.cx > infoPtr->nBitmapWidth) 779 780 infoPtr->nButtonWidth = sizeString.cx + 6; 780 781 else if (infoPtr->nButtonWidth < infoPtr->nBitmapWidth + 6) 781 782 infoPtr->nButtonWidth = infoPtr->nBitmapWidth + 6; 782 783 } 783 784 … … 793 794 794 795 /* 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.. 797 798 */ 798 799 #if 0 … … 829 830 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++ ) 830 831 { 831 832 833 834 835 836 837 838 839 840 841 842 843 844 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) 847 848 { 848 849 SIZE sz; … … 851 852 } 852 853 else 853 854 855 856 cx += DDARROW_WIDTH; 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & TBSTYLE_SEP )) 874 875 876 877 878 879 880 881 882 883 884 885 886 /* btnPtr->nRow is zero based. The space between the rows is*/887 /* also considered as a row.*/888 889 890 891 892 893 else 894 { 895 896 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 904 905 906 907 908 909 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; 910 911 } 911 912 … … 913 914 infoPtr->nRows = nRows + nSepRows + 1; 914 915 915 /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following 916 /* the last row. 917 infoPtr->nHeight = TOP_BORDER + (nRows + 1) * infoPtr->nButtonHeight + 918 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; 921 922 TRACE("toolbar height %d, button width %d\n", infoPtr->nHeight, infoPtr->nButtonWidth); 922 923 } … … 929 930 TBUTTON_INFO *btnPtr; 930 931 INT i; 931 932 932 933 btnPtr = infoPtr->buttons; 933 934 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) { 934 935 936 937 938 939 940 941 942 943 944 945 946 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 } 949 950 } 950 951 … … 962 963 btnPtr = infoPtr->buttons; 963 964 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) { 964 965 966 967 965 if (btnPtr->idCommand == idCommand) { 966 TRACE("command=%d index=%d\n", idCommand, i); 967 return i; 968 } 968 969 } 969 970 TRACE("no index found for command=%d\n", idCommand); … … 979 980 980 981 if ((nIndex < 0) || (nIndex > infoPtr->nNumButtons)) 981 982 return -1; 982 983 983 984 /* check index button */ 984 985 btnPtr = &infoPtr->buttons[nIndex]; 985 986 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) { 986 987 987 if (btnPtr->fsState & TBSTATE_CHECKED) 988 return nIndex; 988 989 } 989 990 … … 991 992 nRunIndex = nIndex - 1; 992 993 while (nRunIndex >= 0) { 993 994 995 996 997 998 999 1000 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--; 1001 1002 } 1002 1003 … … 1004 1005 nRunIndex = nIndex + 1; 1005 1006 while (nRunIndex < infoPtr->nNumButtons) { 1006 btnPtr = &infoPtr->buttons[nRunIndex]; 1007 1008 1009 1010 1011 1012 1013 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++; 1014 1015 } 1015 1016 … … 1020 1021 static VOID 1021 1022 TOOLBAR_RelayEvent (HWND hwndTip, HWND hwndMsg, UINT uMsg, 1022 1023 WPARAM wParam, LPARAM lParam) 1023 1024 { 1024 1025 MSG msg; … … 1049 1050 switch (uMsg) 1050 1051 { 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); 1422 1134 } 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; 1504 1505 } 1505 1506 } … … 1520 1521 TRACE("hwnd=%x wParam=%x lParam=%lx\n", hwnd, wParam, lParam); 1521 1522 if (!lpAddBmp) 1522 1523 return -1; 1523 1524 1524 1525 if (lpAddBmp->hInst == HINST_COMMCTRL) 1525 1526 { 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 if (lpAddBmp->nID & 1) 1539 1540 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 1543 1544 */ 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)); 1559 1549 } 1560 1550 else 1561 1551 { 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 1569 1570 if (!(infoPtr->himlDef)) { 1570 1571 1572 1573 1574 1575 1576 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; 1577 1578 } 1578 1579 … … 1582 1583 if (lpAddBmp->hInst == (HINSTANCE)0) 1583 1584 { 1584 nIndex = 1585 1586 1585 nIndex = 1586 ImageList_AddMasked (infoPtr->himlDef, (HBITMAP)lpAddBmp->nID, 1587 CLR_DEFAULT); 1587 1588 } 1588 1589 else if (lpAddBmp->hInst == HINST_COMMCTRL) 1589 1590 { 1590 1591 1592 { 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 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 } 1646 1647 } 1647 1648 else 1648 1649 { 1649 1650 1651 1650 hbmLoad = LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID); 1651 nIndex = ImageList_AddMasked (infoPtr->himlDef, hbmLoad, CLR_DEFAULT); 1652 DeleteObject (hbmLoad); 1652 1653 } 1653 1654 … … 1659 1660 { 1660 1661 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 1662 1663 1664 1662 infoPtr->nNumBitmaps, nCount, imagecount - nCount, 1663 infoPtr->nNumBitmaps+nButtons,imagecount); 1664 1665 infoPtr->nNumBitmaps = imagecount; 1665 1666 } 1666 1667 else … … 1688 1689 1689 1690 if (infoPtr->nNumButtons == 0) { 1690 1691 1691 infoPtr->buttons = 1692 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons); 1692 1693 } 1693 1694 else { 1694 1695 1696 1697 1698 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)); 1699 1700 COMCTL32_Free (oldButtons); 1700 1701 } … … 1704 1705 /* insert new button data */ 1705 1706 for (nCount = 0; nCount < nAddButtons; nCount++) { 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 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 } 1728 1729 } 1729 1730 … … 1750 1751 1751 1752 if (infoPtr->nNumButtons == 0) { 1752 1753 1753 infoPtr->buttons = 1754 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons); 1754 1755 } 1755 1756 else { 1756 1757 1758 1759 1760 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)); 1761 1762 COMCTL32_Free (oldButtons); 1762 1763 } … … 1766 1767 /* insert new button data */ 1767 1768 for (nCount = 0; nCount < nAddButtons; nCount++) { 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 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 } 1790 1791 } 1791 1792 … … 1805 1806 1806 1807 if ((wParam) && (HIWORD(lParam) == 0)) { 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 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 } 1828 1829 1829 1830 lenW = MultiByteToWideChar( CP_ACP, 0, szString, -1, NULL, 0 ); … … 1831 1832 MultiByteToWideChar( CP_ACP, 0, szString, -1, 1832 1833 infoPtr->strings[infoPtr->nNumStrings], lenW ); 1833 1834 infoPtr->nNumStrings++; 1834 1835 } 1835 1836 else { 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 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 } 1860 1861 1861 1862 lenW = MultiByteToWideChar( CP_ACP, 0, p, -1, NULL, 0 ); … … 1863 1864 MultiByteToWideChar( CP_ACP, 0, p, -1, 1864 1865 infoPtr->strings[infoPtr->nNumStrings], lenW ); 1865 1866 1867 1868 1866 infoPtr->nNumStrings++; 1867 1868 p += (len+1); 1869 } 1869 1870 } 1870 1871 … … 1881 1882 1882 1883 if ((wParam) && (HIWORD(lParam) == 0)) { 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 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 { 1924 1925 nIndex = infoPtr->nNumStrings; 1925 1926 if (infoPtr->nNumStrings == 0) { … … 1943 1944 } 1944 1945 else { 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 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 } 1976 1977 } 1977 1978 … … 2004 2005 2005 2006 if (dwStyle & CCS_NORESIZE) { 2006 2007 2008 2007 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE); 2008 cx = 0; 2009 cy = 0; 2009 2010 } 2010 2011 else { 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 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 } 2022 2023 } 2023 2024 2024 2025 if (dwStyle & CCS_NOPARENTALIGN) 2025 2026 uPosFlags |= SWP_NOMOVE; 2026 2027 2027 2028 if (!(dwStyle & CCS_NODIVIDER)) 2028 2029 cy += GetSystemMetrics(SM_CYEDGE); 2029 2030 2030 2031 if (dwStyle & WS_BORDER) … … 2061 2062 2062 2063 if (infoPtr == NULL) { 2063 2064 2065 2064 ERR("(0x%x, 0x%x, 0x%lx)\n", hwnd, wParam, lParam); 2065 ERR("infoPtr == NULL!\n"); 2066 return 0; 2066 2067 } 2067 2068 … … 2081 2082 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2082 2083 if (nIndex == -1) 2083 2084 return FALSE; 2084 2085 2085 2086 btnPtr = &infoPtr->buttons[nIndex]; … … 2105 2106 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2106 2107 if (nIndex == -1) 2107 2108 return FALSE; 2108 2109 2109 2110 btnPtr = &infoPtr->buttons[nIndex]; 2110 2111 2111 2112 if (!(btnPtr->fsStyle & TBSTYLE_CHECK)) 2112 2113 return FALSE; 2113 2114 2114 2115 bChecked = (btnPtr->fsState & TBSTATE_CHECKED) ? TRUE : FALSE; 2115 2116 2116 2117 if (LOWORD(lParam) == FALSE) 2117 2118 btnPtr->fsState &= ~TBSTATE_CHECKED; 2118 2119 else { 2119 2120 nOldIndex = 2121 2122 2123 2124 2125 2126 2127 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; 2128 2129 } 2129 2130 2130 2131 if( bChecked != LOWORD(lParam) ) 2131 2132 { 2132 2133 if (nOldIndex != -1) 2133 2134 { 2134 2135 InvalidateRect(hwnd, &infoPtr->buttons[nOldIndex].rect, … … 2171 2172 2172 2173 SendMessageA (custInfo.tbInfo->hwndNotify, WM_NOTIFY, 2173 2174 (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr); 2174 2175 2175 2176 if (!(hRes = FindResourceA (COMCTL32_hModule, 2176 2177 MAKEINTRESOURCEA(IDD_TBCUSTOMIZE), 2177 2178 RT_DIALOGA))) 2178 2179 return FALSE; 2179 2180 2180 2181 if(!(template = (LPVOID)LoadResource (COMCTL32_hModule, hRes))) 2181 2182 return FALSE; 2182 2183 2183 2184 ret = DialogBoxIndirectParamA (GetWindowLongA (hwnd, GWL_HINSTANCE), … … 2190 2191 nmhdr.code = TBN_ENDADJUST; 2191 2192 SendMessageA (custInfo.tbInfo->hwndNotify, WM_NOTIFY, 2192 2193 (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr); 2193 2194 2194 2195 return ret; … … 2203 2204 2204 2205 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons)) 2205 2206 2207 if ((infoPtr->hwndToolTip) && 2208 2209 2210 2211 2212 2213 2214 2215 2216 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); 2217 2218 } 2218 2219 2219 2220 if (infoPtr->nNumButtons == 1) { 2220 2221 2222 2223 2221 TRACE(" simple delete!\n"); 2222 COMCTL32_Free (infoPtr->buttons); 2223 infoPtr->buttons = NULL; 2224 infoPtr->nNumButtons = 0; 2224 2225 } 2225 2226 else { 2226 2227 TBUTTON_INFO *oldButtons = infoPtr->buttons; 2227 2228 TRACE("complex delete! [nIndex=%d]\n", nIndex); 2228 2229 2229 2230 2230 infoPtr->nNumButtons--; 2231 infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons); 2231 2232 if (nIndex > 0) { 2232 2233 memcpy (&infoPtr->buttons[0], &oldButtons[0], … … 2239 2240 } 2240 2241 2241 2242 COMCTL32_Free (oldButtons); 2242 2243 } 2243 2244 … … 2260 2261 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2261 2262 if (nIndex == -1) 2262 2263 return FALSE; 2263 2264 2264 2265 btnPtr = &infoPtr->buttons[nIndex]; … … 2268 2269 /* update the toolbar button state */ 2269 2270 if(LOWORD(lParam) == FALSE) { 2270 2271 btnPtr->fsState &= ~(TBSTATE_ENABLED | TBSTATE_PRESSED); 2271 2272 } else { 2272 2273 btnPtr->fsState |= TBSTATE_ENABLED; 2273 2274 } 2274 2275 … … 2301 2302 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2302 2303 if (nIndex == -1) 2303 2304 return -1; 2304 2305 2305 2306 return infoPtr->buttons[nIndex].iBitmap; … … 2323 2324 2324 2325 if (infoPtr == NULL) 2325 2326 return FALSE; 2326 2327 2327 2328 if (lpTbb == NULL) 2328 2329 return FALSE; 2329 2330 2330 2331 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons)) 2331 2332 return FALSE; 2332 2333 2333 2334 btnPtr = &infoPtr->buttons[nIndex]; … … 2352 2353 2353 2354 if (infoPtr == NULL) 2354 2355 return -1; 2355 2356 if (lpTbInfo == NULL) 2356 2357 return -1; 2357 2358 if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOA)) 2358 2359 return -1; 2359 2360 2360 2361 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2361 2362 if (nIndex == -1) 2362 2363 return -1; 2363 2364 2364 2365 btnPtr = &infoPtr->buttons[nIndex]; 2365 2366 2366 2367 if (lpTbInfo->dwMask & TBIF_COMMAND) 2367 2368 lpTbInfo->idCommand = btnPtr->idCommand; 2368 2369 if (lpTbInfo->dwMask & TBIF_IMAGE) 2369 2370 lpTbInfo->iImage = btnPtr->iBitmap; 2370 2371 if (lpTbInfo->dwMask & TBIF_LPARAM) 2371 2372 lpTbInfo->lParam = btnPtr->dwData; 2372 2373 if (lpTbInfo->dwMask & TBIF_SIZE) 2373 2374 lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left); 2374 2375 if (lpTbInfo->dwMask & TBIF_STATE) 2375 2376 lpTbInfo->fsState = btnPtr->fsState; 2376 2377 if (lpTbInfo->dwMask & TBIF_STYLE) 2377 2378 lpTbInfo->fsStyle = btnPtr->fsStyle; 2378 2379 if (lpTbInfo->dwMask & TBIF_TEXT) { 2379 2380 if ((btnPtr->iString >= 0) && (btnPtr->iString < infoPtr->nNumStrings)) 2380 { 2381 { 2381 2382 if (!WideCharToMultiByte( CP_ACP, 0, (LPWSTR)infoPtr->strings[btnPtr->iString], -1, 2382 2383 lpTbInfo->pszText, lpTbInfo->cchText, NULL, NULL )) … … 2398 2399 2399 2400 if (infoPtr == NULL) 2400 2401 return -1; 2401 2402 if (lpTbInfo == NULL) 2402 2403 return -1; 2403 2404 if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOW)) 2404 2405 return -1; 2405 2406 2406 2407 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2407 2408 if (nIndex == -1) 2408 2409 return -1; 2409 2410 2410 2411 btnPtr = &infoPtr->buttons[nIndex]; 2411 2412 2412 2413 if (lpTbInfo->dwMask & TBIF_COMMAND) 2413 2414 lpTbInfo->idCommand = btnPtr->idCommand; 2414 2415 if (lpTbInfo->dwMask & TBIF_IMAGE) 2415 2416 lpTbInfo->iImage = btnPtr->iBitmap; 2416 2417 if (lpTbInfo->dwMask & TBIF_LPARAM) 2417 2418 lpTbInfo->lParam = btnPtr->dwData; 2418 2419 if (lpTbInfo->dwMask & TBIF_SIZE) 2419 2420 lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left); 2420 2421 if (lpTbInfo->dwMask & TBIF_STATE) 2421 2422 lpTbInfo->fsState = btnPtr->fsState; 2422 2423 if (lpTbInfo->dwMask & TBIF_STYLE) 2423 2424 lpTbInfo->fsStyle = btnPtr->fsStyle; 2424 2425 if (lpTbInfo->dwMask & TBIF_TEXT) { 2425 2426 2427 2428 2426 if ((btnPtr->iString >= 0) || (btnPtr->iString < infoPtr->nNumStrings)) 2427 lstrcpynW (lpTbInfo->pszText, 2428 (LPWSTR)infoPtr->strings[btnPtr->iString], 2429 lpTbInfo->cchText); 2429 2430 } 2430 2431 … … 2439 2440 2440 2441 return MAKELONG((WORD)infoPtr->nButtonWidth, 2441 2442 (WORD)infoPtr->nButtonHeight); 2442 2443 } 2443 2444 … … 2451 2452 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2452 2453 if (nIndex == -1) 2453 2454 return -1; 2454 2455 2455 2456 nStringIndex = infoPtr->buttons[nIndex].iString; … … 2458 2459 2459 2460 if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings)) 2460 2461 return -1; 2461 2462 2462 2463 if (lParam == 0) 2463 2464 return -1; 2464 2465 2465 2466 return WideCharToMultiByte( CP_ACP, 0, (LPWSTR)infoPtr->strings[nStringIndex], -1, … … 2476 2477 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2477 2478 if (nIndex == -1) 2478 2479 return -1; 2479 2480 2480 2481 nStringIndex = infoPtr->buttons[nIndex].iString; … … 2483 2484 2484 2485 if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings)) 2485 2486 return -1; 2486 2487 2487 2488 if (lParam == 0) 2488 2489 return -1; 2489 2490 2490 2491 strcpyW ((LPWSTR)lParam, (LPWSTR)infoPtr->strings[nStringIndex]); … … 2530 2531 2531 2532 if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)) 2532 2533 return -1; 2533 2534 2534 2535 if (infoPtr->nHotItem < 0) 2535 2536 return -1; 2536 2537 2537 2538 return (LRESULT)infoPtr->nHotItem; … … 2561 2562 2562 2563 if (infoPtr == NULL) 2563 2564 return FALSE; 2564 2565 nIndex = (INT)wParam; 2565 2566 btnPtr = &infoPtr->buttons[nIndex]; 2566 2567 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons)) 2567 2568 return FALSE; 2568 2569 lpRect = (LPRECT)lParam; 2569 2570 if (lpRect == NULL) 2570 2571 return FALSE; 2571 2572 if (btnPtr->fsState & TBSTATE_HIDDEN) 2572 2573 2573 return FALSE; 2574 2574 2575 lpRect->left = btnPtr->rect.left; 2575 2576 lpRect->right = btnPtr->rect.right; … … 2588 2589 2589 2590 if (lpSize == NULL) 2590 2591 return FALSE; 2591 2592 2592 2593 lpSize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left; … … 2594 2595 2595 2596 TRACE("maximum size %d x %d\n", 2596 2597 2597 infoPtr->rcBound.right - infoPtr->rcBound.left, 2598 infoPtr->rcBound.bottom - infoPtr->rcBound.top); 2598 2599 2599 2600 return TRUE; … … 2614 2615 2615 2616 if (infoPtr == NULL) 2616 2617 return FALSE; 2617 2618 nIndex = (INT)wParam; 2618 2619 btnPtr = &infoPtr->buttons[nIndex]; 2619 2620 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons)) 2620 2621 return FALSE; 2621 2622 lpRect = (LPRECT)lParam; 2622 2623 if (lpRect == NULL) 2623 2624 2624 return FALSE; 2625 2625 2626 lpRect->left = btnPtr->rect.left; 2626 2627 lpRect->right = btnPtr->rect.right; … … 2638 2639 2639 2640 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_WRAPABLE) 2640 2641 return infoPtr->nRows; 2641 2642 else 2642 2643 return 1; 2643 2644 } 2644 2645 … … 2652 2653 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2653 2654 if (nIndex == -1) 2654 2655 return -1; 2655 2656 2656 2657 return infoPtr->buttons[nIndex].fsState; … … 2666 2667 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2667 2668 if (nIndex == -1) 2668 2669 return -1; 2669 2670 2670 2671 return infoPtr->buttons[nIndex].fsStyle; … … 2678 2679 2679 2680 if (infoPtr == NULL) 2680 2681 return 0; 2681 2682 2682 2683 return infoPtr->nMaxTextRows; … … 2690 2691 2691 2692 if (infoPtr == NULL) 2692 2693 return 0; 2693 2694 return infoPtr->hwndToolTip; 2694 2695 } … … 2700 2701 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 2701 2702 2702 TRACE("%s hwnd=0x%x stub!\n", 2703 2703 TRACE("%s hwnd=0x%x stub!\n", 2704 infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd); 2704 2705 2705 2706 return infoPtr->bUnicode; … … 2726 2727 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2727 2728 if (nIndex == -1) 2728 2729 return FALSE; 2729 2730 2730 2731 btnPtr = &infoPtr->buttons[nIndex]; 2731 2732 if (LOWORD(lParam) == FALSE) 2732 2733 btnPtr->fsState &= ~TBSTATE_HIDDEN; 2733 2734 else 2734 2735 btnPtr->fsState |= TBSTATE_HIDDEN; 2735 2736 2736 2737 TOOLBAR_CalcToolbar (hwnd); … … 2758 2759 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2759 2760 if (nIndex == -1) 2760 2761 return FALSE; 2761 2762 2762 2763 btnPtr = &infoPtr->buttons[nIndex]; 2763 2764 if (LOWORD(lParam) == FALSE) 2764 2765 btnPtr->fsState &= ~TBSTATE_INDETERMINATE; 2765 2766 else 2766 2767 btnPtr->fsState |= TBSTATE_INDETERMINATE; 2767 2768 2768 2769 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, btnPtr)); … … 2781 2782 2782 2783 if (lpTbb == NULL) 2783 2784 return FALSE; 2784 2785 2785 2786 if (nIndex == -1) { 2786 2787 /* EPP: this seems to be an undocumented call (from my IE4) 2787 2788 2789 2790 2791 2792 2793 int 2794 LPSTR 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; 2795 2796 2796 2797 /* FIXME: iString == -1 is undocumented */ … … 2814 2815 TRACE("inserting button index=%d\n", nIndex); 2815 2816 if (nIndex > infoPtr->nNumButtons) { 2816 2817 2817 nIndex = infoPtr->nNumButtons; 2818 TRACE("adjust index=%d\n", nIndex); 2818 2819 } 2819 2820 … … 2823 2824 /* pre insert copy */ 2824 2825 if (nIndex > 0) { 2825 2826 2826 memcpy (&infoPtr->buttons[0], &oldButtons[0], 2827 nIndex * sizeof(TBUTTON_INFO)); 2827 2828 } 2828 2829 … … 2836 2837 2837 2838 if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) { 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 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); 2849 2850 } 2850 2851 2851 2852 /* post insert copy */ 2852 2853 if (nIndex < infoPtr->nNumButtons - 1) { 2853 2854 2854 memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex], 2855 (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO)); 2855 2856 } 2856 2857 … … 2874 2875 2875 2876 if (lpTbb == NULL) 2876 2877 return FALSE; 2877 2878 if (nIndex < 0) 2878 2879 return FALSE; 2879 2880 2880 2881 TRACE("inserting button index=%d\n", nIndex); 2881 2882 if (nIndex > infoPtr->nNumButtons) { 2882 2883 2883 nIndex = infoPtr->nNumButtons; 2884 TRACE("adjust index=%d\n", nIndex); 2884 2885 } 2885 2886 … … 2889 2890 /* pre insert copy */ 2890 2891 if (nIndex > 0) { 2891 2892 2892 memcpy (&infoPtr->buttons[0], &oldButtons[0], 2893 nIndex * sizeof(TBUTTON_INFO)); 2893 2894 } 2894 2895 … … 2902 2903 2903 2904 if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) { 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 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); 2915 2916 } 2916 2917 2917 2918 /* post insert copy */ 2918 2919 if (nIndex < infoPtr->nNumButtons - 1) { 2919 2920 2920 memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex], 2921 (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO)); 2921 2922 } 2922 2923 … … 2940 2941 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2941 2942 if (nIndex == -1) 2942 2943 return FALSE; 2943 2944 2944 2945 return (infoPtr->buttons[nIndex].fsState & TBSTATE_CHECKED); … … 2954 2955 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2955 2956 if (nIndex == -1) 2956 2957 return FALSE; 2957 2958 2958 2959 return (infoPtr->buttons[nIndex].fsState & TBSTATE_ENABLED); … … 2968 2969 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2969 2970 if (nIndex == -1) 2970 2971 return TRUE; 2971 2972 2972 2973 return (infoPtr->buttons[nIndex].fsState & TBSTATE_HIDDEN); … … 2982 2983 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2983 2984 if (nIndex == -1) 2984 2985 return FALSE; 2985 2986 2986 2987 return (infoPtr->buttons[nIndex].fsState & TBSTATE_MARKED); … … 2996 2997 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2997 2998 if (nIndex == -1) 2998 2999 return FALSE; 2999 3000 3000 3001 return (infoPtr->buttons[nIndex].fsState & TBSTATE_INDETERMINATE); … … 3010 3011 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 3011 3012 if (nIndex == -1) 3012 3013 return FALSE; 3013 3014 3014 3015 return (infoPtr->buttons[nIndex].fsState & TBSTATE_PRESSED); … … 3031 3032 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 3032 3033 if (nIndex == -1) 3033 3034 return FALSE; 3034 3035 3035 3036 btnPtr = &infoPtr->buttons[nIndex]; 3036 3037 if (LOWORD(lParam) == FALSE) 3037 3038 btnPtr->fsState &= ~TBSTATE_PRESSED; 3038 3039 else 3039 3040 btnPtr->fsState |= TBSTATE_PRESSED; 3040 3041 3041 3042 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, btnPtr)); … … 3058 3059 3059 3060 if ((BOOL)wParam) { 3060 3061 3062 3061 /* save toolbar information */ 3062 FIXME("save to \"%s\" \"%s\"\n", 3063 lpSave->pszSubKey, lpSave->pszValueName); 3063 3064 3064 3065 3065 3066 } 3066 3067 else { 3067 3068 3069 3070 3068 /* restore toolbar information */ 3069 3070 FIXME("restore from \"%s\" \"%s\"\n", 3071 lpSave->pszSubKey, lpSave->pszValueName); 3071 3072 3072 3073 … … 3086 3087 3087 3088 if (lpSave == NULL) 3088 3089 return 0; 3089 3090 3090 3091 if ((BOOL)wParam) { 3091 3092 3093 3092 /* save toolbar information */ 3093 FIXME("save to \"%s\" \"%s\"\n", 3094 lpSave->pszSubKey, lpSave->pszValueName); 3094 3095 3095 3096 3096 3097 } 3097 3098 else { 3098 3099 3100 3101 3099 /* restore toolbar information */ 3100 3101 FIXME("restore from \"%s\" \"%s\"\n", 3102 lpSave->pszSubKey, lpSave->pszValueName); 3102 3103 3103 3104 … … 3127 3128 3128 3129 if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0)) 3129 3130 return FALSE; 3130 3131 3131 3132 if (infoPtr->nNumButtons > 0) … … 3157 3158 3158 3159 if (lptbbi == NULL) 3159 3160 return FALSE; 3160 3161 if (lptbbi->cbSize < sizeof(TBBUTTONINFOA)) 3161 3162 3162 return FALSE; 3163 3163 3164 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 3164 3165 if (nIndex == -1) 3165 3166 return FALSE; 3166 3167 3167 3168 btnPtr = &infoPtr->buttons[nIndex]; 3168 3169 if (lptbbi->dwMask & TBIF_COMMAND) 3169 3170 btnPtr->idCommand = lptbbi->idCommand; 3170 3171 if (lptbbi->dwMask & TBIF_IMAGE) 3171 3172 btnPtr->iBitmap = lptbbi->iImage; 3172 3173 if (lptbbi->dwMask & TBIF_LPARAM) 3173 3174 btnPtr->dwData = lptbbi->lParam; 3174 3175 /* if (lptbbi->dwMask & TBIF_SIZE) */ 3175 /* 3176 /* btnPtr->cx = lptbbi->cx; */ 3176 3177 if (lptbbi->dwMask & TBIF_STATE) 3177 3178 btnPtr->fsState = lptbbi->fsState; 3178 3179 if (lptbbi->dwMask & TBIF_STYLE) 3179 3180 btnPtr->fsStyle = lptbbi->fsStyle; 3180 3181 3181 3182 if (lptbbi->dwMask & TBIF_TEXT) { 3182 if ((btnPtr->iString >= 0) || 3183 3184 3183 if ((btnPtr->iString >= 0) || 3184 (btnPtr->iString < infoPtr->nNumStrings)) { 3185 TRACE("Ooooooch\n"); 3185 3186 #if 0 3186 3187 3188 3187 WCHAR **lpString = &infoPtr->strings[btnPtr->iString]; 3188 INT len = lstrlenA (lptbbi->pszText); 3189 *lpString = COMCTL32_ReAlloc (lpString, sizeof(WCHAR)*(len+1)); 3189 3190 #endif 3190 3191 3191 3192 /* 3193 3192 /* this is the ultimate sollution */ 3193 /* Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */ 3194 } 3194 3195 } 3195 3196 … … 3207 3208 3208 3209 if (lptbbi == NULL) 3209 3210 return FALSE; 3210 3211 if (lptbbi->cbSize < sizeof(TBBUTTONINFOW)) 3211 3212 return FALSE; 3212 3213 3213 3214 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 3214 3215 if (nIndex == -1) 3215 3216 return FALSE; 3216 3217 3217 3218 btnPtr = &infoPtr->buttons[nIndex]; 3218 3219 if (lptbbi->dwMask & TBIF_COMMAND) 3219 3220 btnPtr->idCommand = lptbbi->idCommand; 3220 3221 if (lptbbi->dwMask & TBIF_IMAGE) 3221 3222 btnPtr->iBitmap = lptbbi->iImage; 3222 3223 if (lptbbi->dwMask & TBIF_LPARAM) 3223 3224 btnPtr->dwData = lptbbi->lParam; 3224 3225 /* if (lptbbi->dwMask & TBIF_SIZE) */ 3225 /* 3226 /* btnPtr->cx = lptbbi->cx; */ 3226 3227 if (lptbbi->dwMask & TBIF_STATE) 3227 3228 btnPtr->fsState = lptbbi->fsState; 3228 3229 if (lptbbi->dwMask & TBIF_STYLE) 3229 3230 btnPtr->fsStyle = lptbbi->fsStyle; 3230 3231 3231 3232 if (lptbbi->dwMask & TBIF_TEXT) { 3232 3233 3233 if ((btnPtr->iString >= 0) || 3234 (btnPtr->iString < infoPtr->nNumStrings)) { 3234 3235 #if 0 3235 3236 3237 3236 WCHAR **lpString = &infoPtr->strings[btnPtr->iString]; 3237 INT len = lstrlenW (lptbbi->pszText); 3238 *lpString = COMCTL32_ReAlloc (lpString, sizeof(WCHAR)*(len+1)); 3238 3239 #endif 3239 3240 3240 3241 /* 3242 3241 /* this is the ultimate solution */ 3242 /* Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */ 3243 } 3243 3244 } 3244 3245 … … 3255 3256 { 3256 3257 ERR("invalid parameter\n"); 3257 3258 return FALSE; 3258 3259 } 3259 3260 3260 3261 /* 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 3263 3264 * it to the toolbar, and it checks that the return value is nonzero - mjm 3264 3265 * Further testing shows that we must actually perform the change too. … … 3276 3277 3277 3278 if (infoPtr == NULL) { 3278 3279 3279 TRACE("Toolbar not initialized yet?????\n"); 3280 return FALSE; 3280 3281 } 3281 3282 3282 3283 /* if setting to current values, ignore */ 3283 3284 if ((infoPtr->cxMin == (INT)LOWORD(lParam)) && 3284 3285 3286 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; 3288 3289 } 3289 3290 … … 3294 3295 /* if both values are 0 then we are done */ 3295 3296 if (lParam == 0) { 3296 TRACE("setting both min and max to 0, norecalc\n"); 3297 3297 TRACE("setting both min and max to 0, norecalc\n"); 3298 return TRUE; 3298 3299 } 3299 3300 … … 3301 3302 recalc the bounding rectangle (does DrawText w/ DT_CALCRECT 3302 3303 which doesn't actually draw - GA). */ 3303 TRACE("number of buttons %d, cx=%d, cy=%d, recalcing\n", 3304 3304 TRACE("number of buttons %d, cx=%d, cy=%d, recalcing\n", 3305 infoPtr->nNumButtons, infoPtr->cxMin, infoPtr->cxMax); 3305 3306 3306 3307 TOOLBAR_CalcToolbar (hwnd); … … 3319 3320 3320 3321 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons)) 3321 3322 return FALSE; 3322 3323 3323 3324 infoPtr->buttons[nIndex].idCommand = (INT)lParam; … … 3325 3326 if (infoPtr->hwndToolTip) { 3326 3327 3327 3328 FIXME("change tool tip!\n"); 3328 3329 3329 3330 } … … 3348 3349 /* FIXME: redraw ? */ 3349 3350 3350 return (LRESULT)himlTemp; 3351 return (LRESULT)himlTemp; 3351 3352 } 3352 3353 … … 3360 3361 dwTemp = infoPtr->dwDTFlags; 3361 3362 infoPtr->dwDTFlags = 3362 3363 (infoPtr->dwDTFlags & (DWORD)wParam) | (DWORD)lParam; 3363 3364 3364 3365 return (LRESULT)dwTemp; … … 3375 3376 infoPtr->dwExStyle = (DWORD)lParam; 3376 3377 3377 return (LRESULT)dwTemp; 3378 return (LRESULT)dwTemp; 3378 3379 } 3379 3380 … … 3390 3391 /* FIXME: redraw ? */ 3391 3392 3392 return (LRESULT)himlTemp; 3393 return (LRESULT)himlTemp; 3393 3394 } 3394 3395 … … 3407 3408 { 3408 3409 3409 3410 infoPtr->nHotItem = (INT)wParam; 3410 3411 if ((INT)wParam >=0) 3411 3412 { 3412 3413 btnPtr = &infoPtr->buttons[(INT)wParam]; 3413 3414 btnPtr->bHot = TRUE; 3414 3415 InvalidateRect (hwnd, &btnPtr->rect, 3415 3416 TOOLBAR_HasText(infoPtr, btnPtr)); 3416 3417 } … … 3419 3420 btnPtr = &infoPtr->buttons[nOldHotItem]; 3420 3421 btnPtr->bHot = FALSE; 3421 3422 InvalidateRect (hwnd, &btnPtr->rect, 3422 3423 TOOLBAR_HasText(infoPtr, btnPtr)); 3423 3424 } … … 3425 3426 3426 3427 if (nOldHotItem < 0) 3427 3428 return -1; 3428 3429 3429 3430 return (LRESULT)nOldHotItem; … … 3443 3444 /* FIXME: redraw ? */ 3444 3445 3445 return (LRESULT)himlTemp; 3446 return (LRESULT)himlTemp; 3446 3447 } 3447 3448 … … 3490 3491 3491 3492 if (infoPtr == NULL) 3492 3493 return FALSE; 3493 3494 3494 3495 infoPtr->nMaxTextRows = (INT)wParam; … … 3510 3511 3511 3512 if (infoPtr == NULL) 3512 3513 return 0; 3513 3514 hwndOldNotify = infoPtr->hwndNotify; 3514 3515 infoPtr->hwndNotify = (HWND)wParam; … … 3527 3528 3528 3529 if (LOWORD(wParam) > 1) { 3529 3530 FIXME("multiple rows not supported!\n"); 3530 3531 } 3531 3532 … … 3543 3544 /* return bounding rectangle */ 3544 3545 if (lprc) { 3545 3546 3547 3548 3546 lprc->left = infoPtr->rcBound.left; 3547 lprc->right = infoPtr->rcBound.right; 3548 lprc->top = infoPtr->rcBound.top; 3549 lprc->bottom = infoPtr->rcBound.bottom; 3549 3550 } 3550 3551 … … 3562 3563 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 3563 3564 if (nIndex == -1) 3564 3565 return FALSE; 3565 3566 3566 3567 btnPtr = &infoPtr->buttons[nIndex]; … … 3587 3588 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 3588 3589 if (nIndex == -1) 3589 3590 return FALSE; 3590 3591 3591 3592 btnPtr = &infoPtr->buttons[nIndex]; … … 3599 3600 3600 3601 if (infoPtr->hwndToolTip) { 3601 3602 FIXME("change tool tip!\n"); 3602 3603 } 3603 3604 } … … 3613 3614 3614 3615 if (infoPtr == NULL) 3615 3616 return 0; 3616 3617 infoPtr->hwndToolTip = (HWND)wParam; 3617 3618 return 0; … … 3625 3626 BOOL bTemp; 3626 3627 3627 TRACE("%s hwnd=0x%04x stub!\n", 3628 3628 TRACE("%s hwnd=0x%04x stub!\n", 3629 ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd); 3629 3630 3630 3631 bTemp = infoPtr->bUnicode; … … 3683 3684 3684 3685 if (dwStyle & TBSTYLE_TOOLTIPS) { 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 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 } 3704 3705 } 3705 3706 … … 3717 3718 /* delete tooltip control */ 3718 3719 if (infoPtr->hwndToolTip) 3719 3720 DestroyWindow (infoPtr->hwndToolTip); 3720 3721 3721 3722 /* delete button data */ 3722 3723 if (infoPtr->buttons) 3723 3724 COMCTL32_Free (infoPtr->buttons); 3724 3725 3725 3726 /* delete strings */ 3726 3727 if (infoPtr->strings) { 3727 3728 3729 3730 3731 3732 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); 3733 3734 } 3734 3735 3735 3736 /* destroy internal image list */ 3736 3737 if (infoPtr->himlInt) 3737 3738 ImageList_Destroy (infoPtr->himlInt); 3738 3739 3739 3740 /* delete default font */ 3740 3741 if (infoPtr->hFont) 3741 3742 DeleteObject (infoPtr->hFont); 3742 3743 3743 3744 /* free toolbar info data */ … … 3755 3756 3756 3757 if (infoPtr->bTransparent) 3757 3758 return SendMessageA (GetParent (hwnd), WM_ERASEBKGND, wParam, lParam); 3758 3759 3759 3760 return DefWindowProcA (hwnd, WM_ERASEBKGND, wParam, lParam); … … 3783 3784 3784 3785 if (nHit >= 0) { 3785 3786 3787 3788 3789 3790 3791 3792 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; 3793 3794 3794 3795 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, … … 3796 3797 } 3797 3798 else if (GetWindowLongA (hwnd, GWL_STYLE) & CCS_ADJUSTABLE) 3798 3799 TOOLBAR_Customize (hwnd); 3799 3800 3800 3801 return 0; … … 3811 3812 3812 3813 if (infoPtr->hwndToolTip) 3813 3814 3814 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd, 3815 WM_LBUTTONDOWN, wParam, lParam); 3815 3816 3816 3817 pt.x = (INT)LOWORD(lParam); … … 3819 3820 3820 3821 if (nHit >= 0) { 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 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 } 3864 3865 } 3865 3866 … … 3878 3879 3879 3880 if (infoPtr->hwndToolTip) 3880 3881 3881 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd, 3882 WM_LBUTTONUP, wParam, lParam); 3882 3883 3883 3884 pt.x = (INT)LOWORD(lParam); … … 3891 3892 3892 3893 if ((infoPtr->bCaptured) && (infoPtr->nButtonDown >= 0)) { 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 if ((nOldIndex != infoPtr->nButtonDown) && 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 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) 3920 3921 { 3921 3922 InvalidateRect(hwnd, &infoPtr->buttons[nOldIndex].rect, … … 3923 3924 } 3924 3925 3925 3926 3927 3928 * and obliterates nButtonDown and nOldHit (see TOOLBAR_CaptureChanged) 3929 3930 3931 3932 3933 3934 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); 3935 3936 } 3936 3937 … … 3949 3950 { 3950 3951 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown]; 3951 3952 btnPtr->fsState &= ~TBSTATE_PRESSED; 3952 3953 3953 3954 infoPtr->nButtonDown = -1; … … 3975 3976 if((infoPtr->nOldHit == infoPtr->nHotItem) && (hotBtnPtr->fsState & TBSTATE_ENABLED)) 3976 3977 { 3977 3978 hotBtnPtr->bHot = FALSE; 3978 3979 3979 3980 InvalidateRect (hwnd, &hotBtnPtr->rect, TOOLBAR_HasText(infoPtr, … … 4019 4020 if(!(trackinfo.dwFlags & TME_LEAVE)) { 4020 4021 trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */ 4021 4022 4022 4023 /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */ 4023 4024 /* and can properly deactivate the hot toolbar button */ … … 4026 4027 4027 4028 if (infoPtr->hwndToolTip) 4028 4029 4029 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd, 4030 WM_MOUSEMOVE, wParam, lParam); 4030 4031 4031 4032 pt.x = (INT)LOWORD(lParam); … … 4036 4037 if (infoPtr->nOldHit != nHit) 4037 4038 { 4038 4039 4040 if(infoPtr->nOldHit >= 0 && infoPtr->nOldHit == infoPtr->nHotItem && 4041 4042 4043 4044 4045 4046 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, 4047 4048 TOOLBAR_HasText(infoPtr, oldBtnPtr)); 4048 4049 4050 4051 4052 4053 4054 4055 4056 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 */ 4059 4060 if(infoPtr->buttons[nHit].fsState & TBSTATE_ENABLED) 4060 4061 { … … 4063 4064 } 4064 4065 4065 4066 } 4066 4067 4067 4068 if (infoPtr->bCaptured) { 4068 4069 4070 4069 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown]; 4070 if (infoPtr->nOldHit == infoPtr->nButtonDown) { 4071 btnPtr->fsState &= ~TBSTATE_PRESSED; 4071 4072 InvalidateRect(hwnd, &btnPtr->rect, TRUE); 4072 4073 4074 4073 } 4074 else if (nHit == infoPtr->nButtonDown) { 4075 btnPtr->fsState |= TBSTATE_PRESSED; 4075 4076 InvalidateRect(hwnd, &btnPtr->rect, TRUE); 4076 4077 4078 4077 } 4078 } 4079 infoPtr->nOldHit = nHit; 4079 4080 } 4080 4081 return 0; … … 4086 4087 { 4087 4088 /* if (wndPtr->dwStyle & CCS_NODIVIDER) */ 4088 4089 return DefWindowProcA (hwnd, WM_NCACTIVATE, wParam, lParam); 4089 4090 /* else */ 4090 /* 4091 /* return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */ 4091 4092 } 4092 4093 … … 4096 4097 { 4097 4098 if (!(GetWindowLongA (hwnd, GWL_STYLE) & CCS_NODIVIDER)) 4098 4099 ((LPRECT)lParam)->top += GetSystemMetrics(SM_CYEDGE); 4099 4100 4100 4101 return DefWindowProcA (hwnd, WM_NCCALCSIZE, wParam, lParam); … … 4117 4118 if (!GetWindowLongA (hwnd, GWL_HINSTANCE)) { 4118 4119 HINSTANCE hInst = (HINSTANCE)GetWindowLongA (GetParent (hwnd), GWL_HINSTANCE); 4119 4120 SetWindowLongA (hwnd, GWL_HINSTANCE, (DWORD)hInst); 4120 4121 } 4121 4122 … … 4132 4133 4133 4134 if (dwStyle & WS_MINIMIZE) 4134 4135 return 0; /* Nothing to do */ 4135 4136 4136 4137 DefWindowProcA (hwnd, WM_NCPAINT, wParam, lParam); 4137 4138 4138 4139 if (!(hdc = GetDCEx (hwnd, 0, DCX_USESTYLE | DCX_WINDOW))) 4139 4140 return 0; 4140 4141 4141 4142 if (!(dwStyle & CCS_NODIVIDER)) 4142 4143 { 4143 4144 4145 4146 4147 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); 4148 4149 } 4149 4150 … … 4163 4164 4164 4165 if ((infoPtr->hwndToolTip) && (lpnmh->hwndFrom == infoPtr->hwndToolTip)) { 4165 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,wParam, lParam);4166 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, wParam, lParam); 4166 4167 4167 4168 #if 0 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 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 } 4180 4181 #endif 4181 4182 } … … 4193 4194 4194 4195 /* 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)); 4196 4197 4197 4198 hdc = wParam==0 ? BeginPaint(hwnd, &ps) : (HDC)wParam; 4198 4199 4199 4200 TRACE("psrect=(%d,%d)-(%d,%d)\n", 4200 4201 4201 ps.rcPaint.left, ps.rcPaint.top, 4202 ps.rcPaint.right, ps.rcPaint.bottom); 4202 4203 4203 4204 TOOLBAR_Refresh (hwnd, hdc, &ps); … … 4223 4224 /* Resize deadlock check */ 4224 4225 if (infoPtr->bAutoSize) { 4225 4226 4226 infoPtr->bAutoSize = FALSE; 4227 return 0; 4227 4228 } 4228 4229 … … 4239 4240 4240 4241 if (flags == SIZE_RESTORED) { 4241 4242 4243 4244 4245 4246 4247 4248 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 /* 4251 4252 * this sets the working width of the toolbar, and 4252 4253 * Calc Toolbar will not adjust it, only the height 4253 4254 */ 4254 infoPtr->nWidth = parent_rect.right - parent_rect.left; 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 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); 4292 4293 } 4293 4294 return 0; … … 4301 4302 4302 4303 if (nType == GWL_STYLE) { 4303 4304 4305 4306 4307 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 } 4309 4310 } 4310 4311 … … 4322 4323 { 4323 4324 if (!TOOLBAR_GetInfoPtr(hwnd) && (uMsg != WM_NCCREATE)) 4324 4325 return DefWindowProcA( hwnd, uMsg, wParam, lParam ); 4325 4326 4326 4327 switch (uMsg) 4327 4328 { 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 /* case TB_GETCOLORSCHEME:*/ /* 4.71 */4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 /* case TB_GETINSERTMARK:*/ /* 4.71 */4415 /* case TB_GETINSERTMARKCOLOR:*/ /* 4.71 */4416 4417 4418 4419 4420 4421 4422 4423 /* case TB_GETOBJECT:*/ /* 4.71 */4424 /* case TB_GETPADDING:*/ /* 4.71 */4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 /* case TB_INSERTMARKHITTEST:*/ /* 4.71 */4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 case TB_LOADIMAGES:/* 4.70 */4486 4487 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 4495 4496 4497 /* 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 /* case TB_SETCOLORSCHEME:*/ /* 4.71 */4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 /* case TB_SETINSERTMARK:*/ /* 4.71 */4550 4551 4552 4553 4554 4555 4556 4557 /* case TB_SETPADDING:*/ /* 4.71 */4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 /* 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 /* 4596 /* 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 return TOOLBAR_MouseLeave (hwnd, wParam, lParam); 4612 4613 4614 return TOOLBAR_CaptureChanged(hwnd); 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 /* 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 /* 4643 4644 /* 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 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); 4658 4659 } 4659 4660 return 0; … … 4674 4675 wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1); 4675 4676 wndClass.lpszClassName = TOOLBARCLASSNAMEA; 4676 4677 4677 4678 RegisterClassA (&wndClass); 4678 4679 }
Note:
See TracChangeset
for help on using the changeset viewer.