Changeset 819 for trunk/src/user32/new/win32wbase.cpp
- Timestamp:
- Sep 4, 1999, 7:56:41 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/new/win32wbase.cpp
r780 r819 1 /* $Id: win32wbase.cpp,v 1. 5 1999-09-01 19:12:22 phallerExp $ */1 /* $Id: win32wbase.cpp,v 1.6 1999-09-04 17:56:41 dengert Exp $ */ 2 2 /* 3 3 * Win32 Window Base Class for OS/2 … … 62 62 //****************************************************************************** 63 63 Win32BaseWindow::Win32BaseWindow(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode) 64 64 : GenericObject(&windows, OBJTYPE_WINDOW), ChildWindow() 65 65 { 66 66 Init(); … … 72 72 void Win32BaseWindow::Init() 73 73 { 74 isUnicode 75 fCreated 76 fFirstShow 77 78 windowNameA 79 windowNameW 74 isUnicode = FALSE; 75 fCreated = FALSE; 76 fFirstShow = TRUE; 77 78 windowNameA = NULL; 79 windowNameW = NULL; 80 80 wndNameLength = 0; 81 81 … … 83 83 nrUserWindowLong = 0; 84 84 85 magic 86 OS2Hwnd 87 OS2HwndFrame 88 OS2HwndMenu 89 Win32Hwnd 85 magic = WIN32PM_MAGIC; 86 OS2Hwnd = 0; 87 OS2HwndFrame = 0; 88 OS2HwndMenu = 0; 89 Win32Hwnd = 0; 90 90 91 91 if(HwAllocateWindowHandle(&Win32Hwnd, (ULONG)this) == FALSE) 92 92 { 93 94 95 } 96 97 posx = posy 93 dprintf(("Win32BaseWindow::Init HwAllocateWindowHandle failed!!")); 94 DebugInt3(); 95 } 96 97 posx = posy = 0; 98 98 width = height = 0; 99 99 100 dwExStyle 101 dwStyle 102 win32wndproc 103 hInstance 104 windowId = 0xFFFFFFFF;//default = -1105 userData 100 dwExStyle = 0; 101 dwStyle = 0; 102 win32wndproc = 0; 103 hInstance = 0; 104 windowId = 0xFFFFFFFF; //default = -1 105 userData = 0; 106 106 107 107 hwndLinkAfter = HWND_BOTTOM; 108 flags 109 isIcon 108 flags = 0; 109 isIcon = FALSE; 110 110 lastHitTestVal = 0; 111 owner 112 windowClass 111 owner = NULL; 112 windowClass = 0; 113 113 114 114 acceltableResource = NULL; 115 menuResource 116 iconResource 115 menuResource = NULL; 116 iconResource = NULL; 117 117 } 118 118 //****************************************************************************** … … 125 125 126 126 if(Win32Hwnd) 127 127 HwFreeWindowHandle(Win32Hwnd); 128 128 129 129 if(userWindowLong) 130 130 free(userWindowLong); 131 131 if(windowNameA) { 132 133 132 free(windowNameA); 133 windowNameA = NULL; 134 134 } 135 135 if(windowNameW) { 136 137 136 free(windowNameW); 137 windowNameW = NULL; 138 138 } 139 139 } … … 157 157 if (cs->hwndParent) 158 158 { 159 160 161 162 163 164 165 166 167 168 169 170 171 159 Win32BaseWindow *window = GetWindowFromHandle(cs->hwndParent); 160 if(!window) { 161 dprintf(("Bad parent %04x\n", cs->hwndParent )); 162 SetLastError(ERROR_INVALID_PARAMETER); 163 return FALSE; 164 } 165 /* Make sure parent is valid */ 166 if (!window->IsWindow() ) 167 { 168 dprintf(("Bad parent %04x\n", cs->hwndParent )); 169 SetLastError(ERROR_INVALID_PARAMETER); 170 return FALSE; 171 } 172 172 } 173 173 else 174 174 if ((cs->style & WS_CHILD) && !(cs->style & WS_POPUP)) { 175 176 177 175 dprintf(("No parent for child window\n" )); 176 SetLastError(ERROR_INVALID_PARAMETER); 177 return FALSE; /* WS_CHILD needs a parent, but WS_POPUP doesn't */ 178 178 } 179 179 … … 182 182 if (!windowClass) 183 183 { 184 185 186 184 GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) ); 185 dprintf(("Bad class '%s'\n", buffer )); 186 return 0; 187 187 } 188 188 … … 192 192 */ 193 193 if (!HIWORD(cs->lpszClass) ) { 194 195 196 197 198 199 200 194 if (isUnicode) { 195 GlobalGetAtomNameW( classAtom, (LPWSTR)buffer, sizeof(buffer) ); 196 } 197 else { 198 GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) ); 199 } 200 cs->lpszClass = buffer; 201 201 } 202 202 … … 204 204 if (cs->x == CW_USEDEFAULT || cs->x == CW_USEDEFAULT16) 205 205 { 206 // 206 // PDB *pdb = PROCESS_Current(); 207 207 208 208 /* Never believe Microsoft's documentation... CreateWindowEx doc says 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 209 * that if an overlapped window is created with WS_VISIBLE style bit 210 * set and the x parameter is set to CW_USEDEFAULT, the system ignores 211 * the y parameter. However, disassembling NT implementation (WIN32K.SYS) 212 * reveals that 213 * 214 * 1) not only if checks for CW_USEDEFAULT but also for CW_USEDEFAULT16 215 * 2) it does not ignore the y parameter as the docs claim; instead, it 216 * uses it as second parameter to ShowWindow() unless y is either 217 * CW_USEDEFAULT or CW_USEDEFAULT16. 218 * 219 * The fact that we didn't do 2) caused bogus windows pop up when wine 220 * was running apps that were using this obscure feature. Example - 221 * calc.exe that comes with Win98 (only Win98, it's different from 222 * the one that comes with Win95 and NT) 223 */ 224 if (cs->y != CW_USEDEFAULT && cs->y != CW_USEDEFAULT16) sw = cs->y; 225 226 /* We have saved cs->y, now we can trash it */ 227 227 #if 0 228 229 &&(pdb->env_db->startup_info->dwFlags & STARTF_USEPOSITION) )230 231 232 233 228 if ( !(cs->style & (WS_CHILD | WS_POPUP)) 229 && (pdb->env_db->startup_info->dwFlags & STARTF_USEPOSITION) ) 230 { 231 cs->x = pdb->env_db->startup_info->dwX; 232 cs->y = pdb->env_db->startup_info->dwY; 233 } 234 234 #endif 235 236 237 // 235 cs->x = 0; 236 cs->y = 0; 237 // } 238 238 } 239 239 if (cs->cx == CW_USEDEFAULT || cs->cx == CW_USEDEFAULT16) 240 240 { 241 241 #if 0 242 243 244 &&(pdb->env_db->startup_info->dwFlags & STARTF_USESIZE) )245 246 247 248 249 250 242 PDB *pdb = PROCESS_Current(); 243 if ( !(cs->style & (WS_CHILD | WS_POPUP)) 244 && (pdb->env_db->startup_info->dwFlags & STARTF_USESIZE) ) 245 { 246 cs->cx = pdb->env_db->startup_info->dwXSize; 247 cs->cy = pdb->env_db->startup_info->dwYSize; 248 } 249 else 250 { 251 251 #endif 252 253 254 // 252 cs->cx = 600; /* FIXME */ 253 cs->cy = 400; 254 // } 255 255 } 256 256 … … 261 261 nrUserWindowLong = windowClass->getExtraWndWords(); 262 262 if(nrUserWindowLong) { 263 264 263 userWindowLong = (ULONG *)_smalloc(nrUserWindowLong); 264 memset(userWindowLong, 0, nrUserWindowLong); 265 265 } 266 266 267 267 if ((cs->style & WS_CHILD) && cs->hwndParent) 268 268 { 269 270 271 272 273 274 275 269 SetParent(cs->hwndParent); 270 owner = GetWindowFromHandle(cs->hwndParent); 271 if(owner == NULL) 272 { 273 dprintf(("HwGetWindowHandleData couldn't find owner window %x!!!", cs->hwndParent)); 274 return FALSE; 275 } 276 276 } 277 277 else 278 278 { 279 280 281 282 283 284 285 286 287 288 289 290 279 if (!cs->hwndParent) { 280 owner = NULL; 281 } 282 else 283 { 284 owner = GetWindowFromHandle(cs->hwndParent); 285 if(owner == NULL) 286 { 287 dprintf(("HwGetWindowHandleData couldn't find owner window %x!!!", cs->hwndParent)); 288 return FALSE; 289 } 290 } 291 291 } 292 292 … … 297 297 298 298 hwndLinkAfter = ((cs->style & (WS_CHILD|WS_MAXIMIZE)) == WS_CHILD) 299 299 ? HWND_BOTTOM : HWND_TOP; 300 300 301 301 #if 0 … … 306 306 { 307 307 CBT_CREATEWNDA cbtc; 308 308 LRESULT ret; 309 309 310 310 cbtc.lpcs = cs; 311 311 cbtc.hwndInsertAfter = hwndLinkAfter; 312 313 314 312 ret = unicode ? HOOK_CallHooksW(WH_CBT, HCBT_CREATEWND, Win32Hwnd, (LPARAM)&cbtc) 313 : HOOK_CallHooksA(WH_CBT, HCBT_CREATEWND, Win32Hwnd, (LPARAM)&cbtc); 314 if (ret) 315 315 { 316 317 318 retvalue =0;319 316 TRACE_(win)("CBT-hook returned 0\n"); 317 wndPtr->pDriver->pFinalize(wndPtr); 318 retvalue = 0; 319 goto end; 320 320 } 321 321 } … … 328 328 if (!(cs->style & WS_CHILD)) 329 329 { 330 331 332 333 334 335 330 dwStyle |= WS_CLIPSIBLINGS; 331 if (!(cs->style & WS_POPUP)) 332 { 333 dwStyle |= WS_CAPTION; 334 flags |= WIN_NEED_SIZE; 335 } 336 336 } 337 337 if (cs->dwExStyle & WS_EX_DLGMODALFRAME) dwStyle &= ~WS_THICKFRAME; … … 348 348 if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD))) 349 349 { 350 351 352 353 354 350 GetMinMaxInfo(&maxSize, &maxPos, &minTrack, &maxTrack); 351 if (maxSize.x < cs->cx) cs->cx = maxSize.x; 352 if (maxSize.y < cs->cy) cs->cy = maxSize.y; 353 if (cs->cx < minTrack.x ) cs->cx = minTrack.x; 354 if (cs->cy < minTrack.y ) cs->cy = minTrack.y; 355 355 } 356 356 357 357 if(cs->style & WS_CHILD) 358 358 { 359 360 359 if(cs->cx < 0) cs->cx = 0; 360 if(cs->cy < 0) cs->cy = 0; 361 361 } 362 362 else 363 363 { 364 365 364 if (cs->cx <= 0) cs->cx = 1; 365 if (cs->cy <= 0) cs->cy = 1; 366 366 } 367 367 … … 370 370 rectWindow.right = cs->x + cs->cx; 371 371 rectWindow.bottom = cs->y + cs->cy; 372 rectClient 372 rectClient = rectWindow; 373 373 374 374 DWORD dwOSWinStyle, dwOSFrameStyle; … … 379 379 #if 1 380 380 if(cs->style & WS_CHILD) { 381 381 dwOSFrameStyle = 0; 382 382 } 383 383 #endif 384 384 385 385 if(cs->lpszName) 386 386 SetWindowText((LPSTR)cs->lpszName); 387 387 388 388 OS2Hwnd = OSLibWinCreateWindow((getParent()) ? getParent()->getOS2WindowHandle() : OSLIB_HWND_DESKTOP, 389 390 391 392 389 dwOSWinStyle, dwOSFrameStyle, (char *)windowNameA, 390 (owner) ? owner->getOS2WindowHandle() : OSLIB_HWND_DESKTOP, 391 (hwndLinkAfter == HWND_BOTTOM) ? TRUE : FALSE, 392 &OS2HwndFrame); 393 393 394 394 if(OS2Hwnd == 0) { 395 396 395 dprintf(("Window creation failed!!")); 396 return FALSE; 397 397 } 398 398 399 399 if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, (ULONG)this) == FALSE) { 400 401 400 dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2Hwnd)); 401 return FALSE; 402 402 } 403 403 if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) { 404 405 404 dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd)); 405 return FALSE; 406 406 } 407 407 //SvL: Need to store the shared memory base, or else other apps can map it into their memory space 408 408 if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_SHAREDMEM, HeapGetSharedMemBase()) == FALSE) { 409 410 409 dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd)); 410 return FALSE; 411 411 } 412 412 #if 0 413 413 if(OS2Hwnd != OS2HwndFrame) { 414 414 if(OSLibWinSetWindowULong(OS2HwndFrame, OFFSET_WIN32WNDPTR, (ULONG)this) == FALSE) { 415 416 415 dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2HwndFrame)); 416 return FALSE; 417 417 } 418 418 if(OSLibWinSetWindowULong(OS2HwndFrame, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) { 419 420 419 dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2HwndFrame)); 420 return FALSE; 421 421 } 422 422 //SvL: Need to store the shared memory base, or else other apps can map it into their memory space 423 423 if(OSLibWinSetWindowULong(OS2HwndFrame, OFFSET_WIN32PM_SHAREDMEM, HeapGetSharedMemBase()) == FALSE) { 424 425 424 dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2HwndFrame)); 425 return FALSE; 426 426 } 427 427 } 428 428 #endif 429 430 fakeWinBase.hwndThisObject = OS2Hwnd; 431 fakeWinBase.pWindowClass = windowClass; 432 *(PULONG)&fakeWinBase -= 0x90 - 8; 433 // SetFakeOpen32(); 429 434 430 435 /* Set the window menu */ 431 436 if ((dwStyle & (WS_CAPTION | WS_CHILD)) == WS_CAPTION ) 432 437 { 433 434 435 436 437 438 439 440 441 } 442 else 438 if (cs->hMenu) SetMenu(cs->hMenu); 439 else 440 { 441 if (windowClass->getMenuNameA()) { 442 cs->hMenu = LoadMenuA(cs->hInstance, windowClass->getMenuNameA()); 443 if (cs->hMenu) SetMenu(cs->hMenu ); 444 } 445 } 446 } 447 else windowId = (UINT)cs->hMenu; 443 448 444 449 //Set icon from class 445 450 if(windowClass->getIcon()) 446 451 SetIcon(windowClass->getIcon()); 447 452 448 453 if(getParent()) { 449 450 451 452 454 SetWindowPos(getParent()->getWindowHandle(), rectClient.left, rectClient.top, 455 rectClient.right-rectClient.left, 456 rectClient.bottom-rectClient.top, 457 SWP_NOACTIVATE | SWP_NOZORDER); 453 458 } 454 459 else { 455 456 457 458 460 SetWindowPos(HWND_TOP, rectClient.left, rectClient.top, 461 rectClient.right-rectClient.left, 462 rectClient.bottom-rectClient.top, 463 SWP_NOACTIVATE); 459 464 } 460 465 //Get the client window rectangle … … 470 475 if(SendInternalMessage(WM_NCCREATE, 0, (LPARAM)cs) ) 471 476 { 472 477 //doesn't work right, messes up client rectangle 473 478 #if 0 474 479 SendNCCalcSize(FALSE, &rectWindow, NULL, NULL, 0, &rectClient ); 475 480 #endif 476 477 478 479 480 481 482 483 484 485 486 481 OffsetRect(&rectWindow, maxPos.x - rectWindow.left, maxPos.y - rectWindow.top); 482 dprintf(("Sending WM_CREATE")); 483 if( (SendInternalMessage(WM_CREATE, 0, (LPARAM)cs )) != -1 ) 484 { 485 if(!(flags & WIN_NEED_SIZE)) { 486 SendMessageA(WM_SIZE, SIZE_RESTORED, 487 MAKELONG(rectClient.right-rectClient.left, 488 rectClient.bottom-rectClient.top)); 489 SendMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) ); 490 } 491 if (cs->style & WS_VISIBLE) ShowWindow( sw ); 487 492 488 493 #if 0 489 490 491 492 494 /* Call WH_SHELL hook */ 495 496 if (!(dwStyle & WS_CHILD) && !owner) 497 HOOK_CallHooks16( WH_SHELL, HSHELL_WINDOWCREATED, hwnd, 0 ); 493 498 #endif 494 495 496 499 SetLastError(0); 500 return TRUE; 501 } 497 502 } 498 503 fCreated = FALSE; … … 504 509 #if 0 505 510 /*********************************************************************** 506 * 511 * WINPOS_MinMaximize 507 512 * 508 513 * Fill in lpRect and return additional flags to be used with SetWindowPos(). … … 523 528 if( dwStyle & WS_MINIMIZE ) 524 529 { 525 526 527 530 if( !SendInternalMessageA(WM_QUERYOPEN, 0, 0L ) ) 531 return (SWP_NOSIZE | SWP_NOMOVE); 532 swpFlags |= SWP_NOCOPYBITS; 528 533 } 529 534 switch( cmd ) 530 535 { 531 532 533 534 535 536 537 538 539 536 case SW_MINIMIZE: 537 if( dwStyle & WS_MAXIMIZE) 538 { 539 flags |= WIN_RESTORE_MAX; 540 dwStyle &= ~WS_MAXIMIZE; 541 } 542 else 543 flags &= ~WIN_RESTORE_MAX; 544 dwStyle |= WS_MINIMIZE; 540 545 541 546 #if 0 542 543 544 547 if( flags & WIN_NATIVE ) 548 if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, TRUE ) ) 549 swpFlags |= MINMAX_NOSWP; 545 550 #endif 546 551 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 552 lpPos->ptIconPos = WINPOS_FindIconPos( wndPtr, lpPos->ptIconPos ); 553 554 SetRect(lpRect, lpPos->ptIconPos.x, lpPos->ptIconPos.y, 555 GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON) ); 556 swpFlags |= SWP_NOCOPYBITS; 557 break; 558 559 case SW_MAXIMIZE: 560 WINPOS_GetMinMaxInfo( wndPtr, &size, &pt, NULL, NULL ); 561 562 if( dwStyle & WS_MINIMIZE ) 563 { 564 if( flags & WIN_NATIVE ) 565 if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, FALSE ) ) 566 swpFlags |= MINMAX_NOSWP; 567 568 WINPOS_ShowIconTitle( wndPtr, FALSE ); 569 dwStyle &= ~WS_MINIMIZE; 570 } 571 dwStyle |= WS_MAXIMIZE; 572 573 SetRect16( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y, 574 size.x, size.y ); 575 break; 576 577 case SW_RESTORE: 578 if( dwStyle & WS_MINIMIZE ) 579 { 580 if( flags & WIN_NATIVE ) 581 if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, FALSE ) ) 582 swpFlags |= MINMAX_NOSWP; 583 584 dwStyle &= ~WS_MINIMIZE; 585 WINPOS_ShowIconTitle( wndPtr, FALSE ); 586 587 if( flags & WIN_RESTORE_MAX) 588 { 589 /* Restore to maximized position */ 590 CONV_POINT16TO32( &lpPos->ptMaxPos, &pt ); 591 WINPOS_GetMinMaxInfo( wndPtr, &size, &pt, NULL, NULL); 592 CONV_POINT32TO16( &pt, &lpPos->ptMaxPos ); 593 dwStyle |= WS_MAXIMIZE; 594 SetRect16( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y, size.x, size.y ); 595 break; 596 } 597 } 598 else 599 if( !(dwStyle & WS_MAXIMIZE) ) return (UINT16)(-1); 600 else dwStyle &= ~WS_MAXIMIZE; 601 602 /* Restore to normal position */ 603 604 *lpRect = lpPos->rectNormal; 605 lpRect->right -= lpRect->left; 606 lpRect->bottom -= lpRect->top; 607 608 break; 604 609 } 605 610 } else swpFlags |= SWP_NOSIZE | SWP_NOMOVE; … … 608 613 #endif 609 614 /******************************************************************* 610 * 615 * GetMinMaxInfo 611 616 * 612 617 * Get the minimized and maximized information for a window. 613 618 */ 614 619 void Win32BaseWindow::GetMinMaxInfo(POINT *maxSize, POINT *maxPos, 615 620 POINT *minTrack, POINT *maxTrack ) 616 621 { 617 622 MINMAXINFO MinMax; … … 630 635 else if (HAS_DLGFRAME( dwStyle, dwExStyle )) 631 636 { 632 633 637 xinc = GetSystemMetrics(SM_CXDLGFRAME); 638 yinc = GetSystemMetrics(SM_CYDLGFRAME); 634 639 } 635 640 else 636 641 { 637 638 639 640 641 642 643 644 645 646 647 642 xinc = yinc = 0; 643 if (HAS_THICKFRAME(dwStyle)) 644 { 645 xinc += GetSystemMetrics(SM_CXFRAME); 646 yinc += GetSystemMetrics(SM_CYFRAME); 647 } 648 if (dwStyle & WS_BORDER) 649 { 650 xinc += GetSystemMetrics(SM_CXBORDER); 651 yinc += GetSystemMetrics(SM_CYBORDER); 652 } 648 653 } 649 654 MinMax.ptMaxSize.x += 2 * xinc; … … 653 658 lpPos = (LPINTERNALPOS)GetPropA( hwndSelf, atomInternalPos ); 654 659 if( lpPos && !EMPTYPOINT(lpPos->ptMaxPos) ) 655 660 CONV_POINT16TO32( &lpPos->ptMaxPos, &MinMax.ptMaxPosition ); 656 661 else 657 662 { 658 663 #endif 659 660 664 MinMax.ptMaxPosition.x = -xinc; 665 MinMax.ptMaxPosition.y = -yinc; 661 666 // } 662 667 … … 666 671 667 672 dprintf(("GetMinMaxInfo: %ld %ld / %ld %ld / %ld %ld / %ld %ld\n", 668 669 670 671 673 MinMax.ptMaxSize.x, MinMax.ptMaxSize.y, 674 MinMax.ptMaxPosition.x, MinMax.ptMaxPosition.y, 675 MinMax.ptMaxTrackSize.x, MinMax.ptMaxTrackSize.y, 676 MinMax.ptMinTrackSize.x, MinMax.ptMinTrackSize.y)); 672 677 MinMax.ptMaxTrackSize.x = MAX( MinMax.ptMaxTrackSize.x, 673 678 MinMax.ptMinTrackSize.x ); 674 679 MinMax.ptMaxTrackSize.y = MAX( MinMax.ptMaxTrackSize.y, 675 680 MinMax.ptMinTrackSize.y ); 676 681 677 682 if (maxSize) *maxSize = MinMax.ptMaxSize; … … 681 686 } 682 687 /*********************************************************************** 683 * 688 * WINPOS_SendNCCalcSize 684 689 * 685 690 * Send a WM_NCCALCSIZE message to a window. … … 689 694 */ 690 695 LONG Win32BaseWindow::SendNCCalcSize(BOOL calcValidRect, RECT *newWindowRect, RECT *oldWindowRect, 691 692 696 RECT *oldClientRect, WINDOWPOS *winpos, 697 RECT *newClientRect ) 693 698 { 694 699 NCCALCSIZE_PARAMS params; … … 699 704 if (calcValidRect) 700 705 { 701 702 703 704 706 winposCopy = *winpos; 707 params.rgrc[1] = *oldWindowRect; 708 params.rgrc[2] = *oldClientRect; 709 params.lppos = &winposCopy; 705 710 } 706 711 result = SendInternalMessageA(WM_NCCALCSIZE, calcValidRect, 707 712 (LPARAM)¶ms ); 708 713 *newClientRect = params.rgrc[0]; 709 714 return result; … … 727 732 { 728 733 if(SendInternalMessageA(WM_CLOSE, 0, 0) == 0) { 729 734 return 0; //app handles this message 730 735 } 731 736 delete this; … … 762 767 #if 1 763 768 if(fCreated == FALSE) { 764 769 return 1; 765 770 } 766 771 #endif … … 774 779 #if 1 775 780 if(fCreated == FALSE) { 776 781 return 1; 777 782 } 778 783 #endif … … 785 790 dprintf(("MsgMove to (%d,%d)", x, y)); 786 791 if(fCreated == FALSE) { 787 792 return 1; 788 793 } 789 794 … … 796 801 switch(cmd) { 797 802 case CMD_MENU: 798 803 return SendInternalMessageA(WM_COMMAND, MAKELONG(Id, 0), 0); 799 804 case CMD_CONTROL: 800 805 return 0; //todo 801 806 case CMD_ACCELERATOR: 802 803 807 dprintf(("accelerator command")); 808 return 0; //todo 804 809 } 805 810 return 0; … … 820 825 821 826 if(fCreated == FALSE) {//Solitaire crashes if it receives a WM_SIZE during CreateWindowEx (normal or our fault?) 822 827 return 1; 823 828 } 824 829 825 830 if(fMinimize) { 826 831 fwSizeType = SIZE_MINIMIZED; 827 832 } 828 833 else 829 834 if(fMaximize) { 830 835 fwSizeType = SIZE_MAXIMIZED; 831 836 } 832 837 else fwSizeType = SIZE_RESTORED; … … 840 845 if(SendInternalMessageA(WM_NCACTIVATE, fActivate, 0) == FALSE) 841 846 { 842 843 844 847 if(!fActivate) { 848 return 1; 849 } 845 850 } 846 851 return SendInternalMessageA(WM_ACTIVATE, (fActivate) ? WA_ACTIVE : WA_INACTIVE, hwnd); … … 862 867 lParam |= (scancode << 16); 863 868 if(keyflags & KEY_ALTDOWN) 864 869 lParam |= (1<<29); 865 870 if(keyflags & KEY_PREVDOWN) 866 871 lParam |= (1<<30); 867 872 if(keyflags & KEY_UP) 868 873 lParam |= (1<<31); 869 874 if(keyflags & KEY_DEADKEY) { 870 871 875 dprintf(("WM_DEADCHAR: %x %x %08x", OS2Hwnd, cmd, lParam)); 876 return SendInternalMessageA(WM_DEADCHAR, cmd, lParam); 872 877 } 873 878 else { 874 875 879 dprintf(("WM_CHAR: %x %x %08x", OS2Hwnd, cmd, lParam)); 880 return SendInternalMessageA(WM_CHAR, cmd, lParam); 876 881 } 877 882 } … … 881 886 { 882 887 if(hwnd == 0) { 883 884 888 //other app lost focus 889 SendInternalMessageA(WM_ACTIVATEAPP, TRUE, 0); //TODO: Need thread id from hwnd app 885 890 } 886 891 return SendInternalMessageA(WM_SETFOCUS, hwnd, 0); … … 891 896 { 892 897 if(hwnd == 0) { 893 894 898 //other app lost focus 899 SendInternalMessageA(WM_ACTIVATEAPP, FALSE, 0); //TODO: Need thread id from hwnd app 895 900 } 896 901 return SendInternalMessageA(WM_KILLFOCUS, hwnd, 0); … … 905 910 dprintf(("MsgButton to (%d,%d)", ncx, ncy)); 906 911 switch(msg) { 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 912 case BUTTON_LEFTDOWN: 913 win32msg = WM_LBUTTONDOWN; 914 win32ncmsg = WM_NCLBUTTONDOWN; 915 break; 916 case BUTTON_LEFTUP: 917 win32msg = WM_LBUTTONUP; 918 win32ncmsg = WM_NCLBUTTONUP; 919 break; 920 case BUTTON_LEFTDBLCLICK: 921 win32msg = WM_LBUTTONDBLCLK; 922 win32ncmsg = WM_NCLBUTTONDBLCLK; 923 break; 924 case BUTTON_RIGHTUP: 925 win32msg = WM_RBUTTONUP; 926 win32ncmsg = WM_NCRBUTTONUP; 927 break; 928 case BUTTON_RIGHTDOWN: 929 win32msg = WM_RBUTTONDOWN; 930 win32ncmsg = WM_NCRBUTTONDOWN; 931 break; 932 case BUTTON_RIGHTDBLCLICK: 933 win32msg = WM_RBUTTONDBLCLK; 934 win32ncmsg = WM_NCRBUTTONDBLCLK; 935 break; 936 case BUTTON_MIDDLEUP: 937 win32msg = WM_MBUTTONUP; 938 win32ncmsg = WM_NCMBUTTONUP; 939 break; 940 case BUTTON_MIDDLEDOWN: 941 win32msg = WM_MBUTTONDOWN; 942 win32ncmsg = WM_NCMBUTTONDOWN; 943 break; 944 case BUTTON_MIDDLEDBLCLICK: 945 win32msg = WM_MBUTTONDBLCLK; 946 win32ncmsg = WM_NCMBUTTONDBLCLK; 947 break; 948 default: 949 dprintf(("Win32BaseWindow::Button: invalid msg!!!!")); 950 return 1; 946 951 } 947 952 if(win32msg == WM_MBUTTONDBLCLK || win32msg == WM_RBUTTONDBLCLK || win32msg == WM_LBUTTONDBLCLK) { 948 949 950 953 if(!(windowClass->getClassLongA(GCL_STYLE) & CS_DBLCLKS)) { 954 return 1; 955 } 951 956 } 952 957 SendInternalMessageA(WM_SETCURSOR, Win32Hwnd, MAKELONG(lastHitTestVal, win32ncmsg)); … … 954 959 //WM_NC*BUTTON* is posted when the cursor is in a non-client area of the window 955 960 if(lastHitTestVal != HTCLIENT) { 956 961 SendInternalMessageA(win32ncmsg, lastHitTestVal, MAKELONG(ncx, ncy)); //TODO: 957 962 } 958 963 return SendInternalMessageA(win32msg, 0, MAKELONG(clx, cly)); … … 966 971 967 972 if(keystate & WMMOVE_LBUTTON) 968 973 winstate |= MK_LBUTTON; 969 974 if(keystate & WMMOVE_RBUTTON) 970 975 winstate |= MK_RBUTTON; 971 976 if(keystate & WMMOVE_MBUTTON) 972 977 winstate |= MK_MBUTTON; 973 978 if(keystate & WMMOVE_SHIFT) 974 979 winstate |= MK_SHIFT; 975 980 if(keystate & WMMOVE_CTRL) 976 981 winstate |= MK_CONTROL; 977 982 978 983 if(lastHitTestVal != HTCLIENT) { 979 984 setcursormsg = WM_NCMOUSEMOVE; 980 985 } 981 986 //TODO: hiword should be 0 if window enters menu mode (SDK docs) … … 984 989 //WM_NCMOUSEMOVE is posted when the cursor moves into a non-client area of the window 985 990 if(lastHitTestVal != HTCLIENT) { 986 991 SendInternalMessageA(WM_NCMOUSEMOVE, lastHitTestVal, MAKELONG(x, y)); 987 992 } 988 993 return SendInternalMessageA(WM_MOUSEMOVE, keystate, MAKELONG(x, y)); … … 996 1001 //****************************************************************************** 997 1002 //TODO: Is the clipper region of the window DC equal to the invalidated rectangle? 998 // 1003 // (or are we simply erasing too much here) 999 1004 //****************************************************************************** 1000 1005 ULONG Win32BaseWindow::MsgEraseBackGround(HDC hdc) … … 1004 1009 1005 1010 if (hdcErase == 0) 1006 1011 hdcErase = O32_GetDC(OS2Hwnd); 1007 1012 1008 1013 if(isIcon) 1009 1014 rc = SendInternalMessageA(WM_ICONERASEBKGND, hdcErase, 0); 1010 1015 else 1011 1016 rc = SendInternalMessageA(WM_ERASEBKGND, hdcErase, 0); 1012 1017 if (hdc == 0) 1013 1018 O32_ReleaseDC(OS2Hwnd, hdcErase); 1014 1019 return (rc); 1015 1020 } … … 1019 1024 { 1020 1025 if(isUnicode) { 1021 1026 return SendInternalMessageW(WM_SETTEXT, 0, (LPARAM)lpsz); 1022 1027 } 1023 1028 else return SendInternalMessageA(WM_SETTEXT, 0, (LPARAM)lpsz); … … 1035 1040 { 1036 1041 if(isUnicode) { 1037 1042 SendInternalMessageW(WM_GETTEXT, wndNameLength, (LPARAM)windowNameW); 1038 1043 } 1039 1044 else { 1040 1045 SendInternalMessageA(WM_GETTEXT, wndNameLength, (LPARAM)windowNameA); 1041 1046 } 1042 1047 return windowNameA; … … 1049 1054 { 1050 1055 case WM_GETTEXTLENGTH: 1051 1056 return wndNameLength; 1052 1057 1053 1058 case WM_GETTEXT: //TODO: SS_ICON controls 1054 1055 1059 strncpy((LPSTR)lParam, windowNameA, wParam); 1060 return min(wndNameLength, wParam); 1056 1061 1057 1062 case WM_SETTEXT: 1058 1063 return 0; 1059 1064 1060 1065 case WM_SETREDRAW: 1061 1062 1063 elseSetWindowLongA (GWL_STYLE, GetWindowLongA (GWL_STYLE) & ~WS_VISIBLE);1064 1065 1066 if(wParam) 1067 SetWindowLongA (GWL_STYLE, GetWindowLongA (GWL_STYLE) | WS_VISIBLE); 1068 else SetWindowLongA (GWL_STYLE, GetWindowLongA (GWL_STYLE) & ~WS_VISIBLE); 1069 1070 return 0; //TODO 1066 1071 1067 1072 case WM_NCCREATE: 1068 1073 return(TRUE); 1069 1074 1070 1075 case WM_CTLCOLORMSGBOX: … … 1075 1080 case WM_CTLCOLORSTATIC: 1076 1081 case WM_CTLCOLORSCROLLBAR: 1077 1078 1079 1082 SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW)); 1083 SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT)); 1084 return GetSysColorBrush(COLOR_BTNFACE); 1080 1085 1081 1086 case WM_PARENTNOTIFY: 1082 1087 return 0; 1083 1088 1084 1089 case WM_MOUSEACTIVATE: 1085 1090 { 1086 1087 1088 1089 1090 1091 1092 1093 if(rc)return rc;1094 1095 1096 1091 DWORD dwStyle = GetWindowLongA(GWL_STYLE); 1092 DWORD dwExStyle = GetWindowLongA(GWL_EXSTYLE); 1093 dprintf(("DefWndProc: WM_MOUSEACTIVATE for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam)))); 1094 if(dwStyle & WS_CHILD && !(dwExStyle & WS_EX_NOPARENTNOTIFY) ) 1095 { 1096 if(getParent()) { 1097 LRESULT rc = getParent()->SendMessageA(WM_MOUSEACTIVATE, wParam, lParam ); 1098 if(rc) return rc; 1099 } 1100 } 1101 return (LOWORD(lParam) == HTCAPTION) ? MA_NOACTIVATE : MA_ACTIVATE; 1097 1102 } 1098 1103 case WM_SETCURSOR: 1099 1104 { 1100 1101 1102 1103 1104 1105 1106 1107 if(rc)return rc;1108 1109 1110 1105 DWORD dwStyle = GetWindowLongA(GWL_STYLE); 1106 DWORD dwExStyle = GetWindowLongA(GWL_EXSTYLE); 1107 dprintf(("DefWndProc: WM_SETCURSOR for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam)))); 1108 if(dwStyle & WS_CHILD && !(dwExStyle & WS_EX_NOPARENTNOTIFY) ) 1109 { 1110 if(getParent()) { 1111 LRESULT rc = getParent()->SendMessageA(WM_SETCURSOR, wParam, lParam); 1112 if(rc) return rc; 1113 } 1114 } 1115 return 1; 1111 1116 } 1112 1117 case WM_MOUSEMOVE: 1113 1118 return 0; 1114 1119 1115 1120 case WM_WINDOWPOSCHANGED: … … 1117 1122 1118 1123 /* undocumented SWP flags - from SDK 3.1 */ 1119 #define SWP_NOCLIENTSIZE 1120 #define SWP_NOCLIENTMOVE 1121 1122 1123 WPARAM wp= SIZE_RESTORED;1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 SendMessageA(WM_SIZE, wp, MAKELONG(rectClient.right- rectClient.left,1134 1135 1136 1124 #define SWP_NOCLIENTSIZE 0x0800 1125 #define SWP_NOCLIENTMOVE 0x1000 1126 1127 PWINDOWPOS wpos = (PWINDOWPOS)lParam; 1128 WPARAM wp = SIZE_RESTORED; 1129 1130 if (!(wpos->flags & SWP_NOCLIENTMOVE)) 1131 SendMessageA(WM_MOVE, 0, MAKELONG(rectClient.left, rectClient.top)); 1132 1133 if (!(wpos->flags & SWP_NOCLIENTSIZE)) 1134 { 1135 if (dwStyle & WS_MAXIMIZE) wp = SIZE_MAXIMIZED; 1136 else if (dwStyle & WS_MINIMIZE) wp = SIZE_MINIMIZED; 1137 1138 SendMessageA(WM_SIZE, wp, MAKELONG(rectClient.right - rectClient.left, 1139 rectClient.bottom - rectClient.top)); 1140 } 1141 return 0; 1137 1142 } 1138 1143 case WM_ERASEBKGND: … … 1142 1147 int rc; 1143 1148 1144 1145 1146 1147 1148 /* the device context.*/1149 1150 1151 1152 1153 1149 if (!windowClass->getBackgroundBrush()) return 0; 1150 1151 /* Since WM_ERASEBKGND may receive either a window dc or a */ 1152 /* client dc, the area to be erased has to be retrieved from */ 1153 /* the device context. */ 1154 rc = GetClipBox( (HDC)wParam, &rect ); 1155 if ((rc == SIMPLEREGION) || (rc == COMPLEXREGION)) 1156 FillRect( (HDC)wParam, &rect, windowClass->getBackgroundBrush()); 1157 1158 return 1; 1154 1159 } 1155 1160 … … 1163 1168 case WM_NCMBUTTONUP: 1164 1169 case WM_NCMBUTTONDBLCLK: 1165 return 0;//TODO: Send WM_SYSCOMMAND if required1170 return 0; //TODO: Send WM_SYSCOMMAND if required 1166 1171 1167 1172 case WM_NCHITTEST: //TODO: Calculate position of 1168 1173 return HTCLIENT; 1169 1174 1170 1175 default: 1171 1176 return 1; 1172 1177 } 1173 1178 } … … 1179 1184 { 1180 1185 case WM_GETTEXTLENGTH: 1181 1186 return wndNameLength; 1182 1187 1183 1188 case WM_GETTEXT: //TODO: SS_ICON controls 1184 1185 1189 lstrcpynW((LPWSTR)lParam, windowNameW, wParam); 1190 return min(wndNameLength, wParam); 1186 1191 1187 1192 default: 1188 1193 return DefWindowProcA(Msg, wParam, lParam); 1189 1194 } 1190 1195 } … … 1194 1199 { 1195 1200 if(PostSpyMessage(getWindowHandle(), Msg, wParam, lParam) == FALSE) 1196 1201 dprintf(("SendMessageA %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam)); 1197 1202 1198 1203 if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg 1199 1204 return(0); 1200 1205 } 1201 1206 switch(Msg) 1202 1207 { 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1208 case WM_CREATE: 1209 { 1210 if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) { 1211 dprintf(("WM_NCCREATE returned FALSE\n")); 1212 return(-1); //don't create window 1213 } 1214 if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == -1) { 1215 dprintf(("WM_CREATE returned -1\n")); 1216 return(-1); //don't create window 1217 } 1218 NotifyParent(Msg, wParam, lParam); 1219 1220 return(0); 1221 } 1222 case WM_SETTEXT: //TODO: Nothing happens if passed to DefWindowProc 1223 return win32wndproc(getWindowHandle(), WM_SETTEXT, wParam, lParam); 1224 1225 case WM_LBUTTONDOWN: 1226 case WM_MBUTTONDOWN: 1227 case WM_RBUTTONDOWN: 1228 NotifyParent(Msg, wParam, lParam); 1229 return win32wndproc(getWindowHandle(), Msg, wParam, lParam); 1230 1231 case WM_DESTROY: 1232 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0); 1233 NotifyParent(Msg, wParam, lParam); 1234 return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0); 1235 default: 1236 return win32wndproc(getWindowHandle(), Msg, wParam, lParam); 1232 1237 } 1233 1238 } … … 1237 1242 { 1238 1243 if(PostSpyMessage(getWindowHandle(), Msg, wParam, lParam) == FALSE) 1239 1244 dprintf(("SendMessageA %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam)); 1240 1245 1241 1246 if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg 1242 1247 return(0); 1243 1248 } 1244 1249 switch(Msg) 1245 1250 { 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1251 case WM_CREATE: 1252 { 1253 if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) { 1254 dprintf(("WM_NCCREATE returned FALSE\n")); 1255 return(0); //don't create window 1256 } 1257 if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == 0) { 1258 dprintf(("WM_CREATE returned FALSE\n")); 1259 return(0); //don't create window 1260 } 1261 NotifyParent(Msg, wParam, lParam); 1262 1263 return(1); 1264 } 1265 case WM_SETTEXT: //TODO: Nothing happens if passed to DefWindowProc 1266 return win32wndproc(getWindowHandle(), WM_SETTEXT, wParam, lParam); 1267 1268 case WM_LBUTTONDOWN: 1269 case WM_MBUTTONDOWN: 1270 case WM_RBUTTONDOWN: 1271 NotifyParent(Msg, wParam, lParam); 1272 return win32wndproc(getWindowHandle(), Msg, wParam, lParam); 1273 1274 case WM_DESTROY: 1275 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0); 1276 NotifyParent(Msg, wParam, lParam); 1277 return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0); 1278 1279 default: 1280 return win32wndproc(getWindowHandle(), Msg, wParam, lParam); 1276 1281 } 1277 1282 } … … 1282 1287 { 1283 1288 if(PostSpyMessage(getWindowHandle(), Msg, wParam, lParam) == FALSE) 1284 1289 dprintf(("SendInternalMessageA %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam)); 1285 1290 1286 1291 if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg 1287 1292 return(0); 1288 1293 } 1289 1294 switch(Msg) 1290 1295 { 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 1296 case WM_CREATE: 1297 { 1298 if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) { 1299 dprintf(("WM_NCCREATE returned FALSE\n")); 1300 return(0); //don't create window 1301 } 1302 if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == 0) { 1303 dprintf(("WM_CREATE returned FALSE\n")); 1304 return(0); //don't create window 1305 } 1306 NotifyParent(Msg, wParam, lParam); 1307 1308 return(1); 1309 } 1310 case WM_LBUTTONDOWN: 1311 case WM_MBUTTONDOWN: 1312 case WM_RBUTTONDOWN: 1313 NotifyParent(Msg, wParam, lParam); 1314 return win32wndproc(getWindowHandle(), Msg, wParam, lParam); 1315 1316 case WM_DESTROY: 1317 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0); 1318 NotifyParent(Msg, wParam, lParam); 1319 return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0); 1320 default: 1321 return win32wndproc(getWindowHandle(), Msg, wParam, lParam); 1317 1322 } 1318 1323 } … … 1324 1329 { 1325 1330 if(PostSpyMessage(getWindowHandle(), Msg, wParam, lParam) == FALSE) 1326 1331 dprintf(("SendInternalMessageW %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam)); 1327 1332 1328 1333 if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg 1329 1334 return(0); 1330 1335 } 1331 1336 switch(Msg) 1332 1337 { 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 1338 case WM_CREATE: 1339 { 1340 if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) { 1341 dprintf(("WM_NCCREATE returned FALSE\n")); 1342 return(0); //don't create window 1343 } 1344 if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == 0) { 1345 dprintf(("WM_CREATE returned FALSE\n")); 1346 return(0); //don't create window 1347 } 1348 NotifyParent(Msg, wParam, lParam); 1349 1350 return(1); 1351 } 1352 case WM_LBUTTONDOWN: 1353 case WM_MBUTTONDOWN: 1354 case WM_RBUTTONDOWN: 1355 NotifyParent(Msg, wParam, lParam); 1356 return win32wndproc(getWindowHandle(), Msg, wParam, lParam); 1357 1358 case WM_DESTROY: 1359 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0); 1360 NotifyParent(Msg, wParam, lParam); 1361 return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0); 1362 default: 1363 return win32wndproc(getWindowHandle(), Msg, wParam, lParam); 1359 1364 } 1360 1365 } … … 1381 1386 while(window) 1382 1387 { 1383 1384 1385 1386 1387 1388 1389 1390 1391 elseparentwindow->SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, window->getWindowId()), lParam );1392 1393 1394 elsebreak;1395 1396 1388 if(window->getStyle() & WS_CHILD && !(window->getExStyle() & WS_EX_NOPARENTNOTIFY) ) 1389 { 1390 /* Notify the parent window only */ 1391 parentwindow = window->getParent(); 1392 if(parentwindow) { 1393 if(Msg == WM_CREATE || Msg == WM_DESTROY) { 1394 parentwindow->SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, window->getWindowId()), (LPARAM)window->getWindowHandle()); 1395 } 1396 else parentwindow->SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, window->getWindowId()), lParam ); 1397 } 1398 } 1399 else break; 1400 1401 window = parentwindow; 1397 1402 } 1398 1403 } … … 1401 1406 BOOL Win32BaseWindow::SetMenu(HMENU hMenu) 1402 1407 { 1403 PVOID 1408 PVOID menutemplate; 1404 1409 Win32Resource *winres = (Win32Resource *)hMenu; 1405 1410 1406 1411 dprintf(("SetMenu %x", hMenu)); 1407 1412 if(HIWORD(winres) == 0) { 1408 1409 1410 1413 dprintf(("Win32BaseWindow:: Win32Resource *winres == 0")); 1414 SetLastError(ERROR_INVALID_PARAMETER); 1415 return FALSE; 1411 1416 } 1412 1417 menutemplate = winres->lockOS2Resource(); 1413 1418 if(menutemplate == NULL) 1414 1419 { 1415 1416 1420 dprintf(("Win32BaseWindow::SetMenu menutemplate == 0")); 1421 return FALSE; 1417 1422 } 1418 1423 OS2HwndMenu = OSLibWinCreateMenu(OS2HwndFrame, menutemplate); 1419 1424 if(OS2HwndMenu == 0) { 1420 1421 1425 dprintf(("Win32BaseWindow::SetMenu OS2HwndMenu == 0")); 1426 return FALSE; 1422 1427 } 1423 1428 winres->setOS2Handle(OS2HwndMenu); … … 1430 1435 { 1431 1436 Win32Resource *winres = (Win32Resource *)hAccel; 1432 HANDLE 1437 HANDLE accelhandle; 1433 1438 1434 1439 if(HIWORD(hAccel) == 0) { 1435 1436 1437 1440 dprintf(("SetAccelTable: hAccel %x invalid", hAccel)); 1441 SetLastError(ERROR_INVALID_PARAMETER); 1442 return FALSE; 1438 1443 } 1439 1444 acceltableResource = winres; … … 1457 1462 dprintf(("ShowWindow %x", nCmdShow)); 1458 1463 if(fFirstShow) { 1459 1460 1461 1462 1463 1464 1465 1466 1464 if(isFrameWindow() && IS_OVERLAPPED(getStyle())) { 1465 SendMessageA(WM_SIZE, SIZE_RESTORED, 1466 MAKELONG(rectClient.right-rectClient.left, 1467 rectClient.bottom-rectClient.top)); 1468 SendMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) ); 1469 1470 } 1471 fFirstShow = FALSE; 1467 1472 } 1468 1473 switch(nCmdShow) … … 1470 1475 case SW_SHOW: 1471 1476 case SW_SHOWDEFAULT: //todo 1472 1473 1477 showstate = SWPOS_SHOW | SWPOS_ACTIVATE; 1478 break; 1474 1479 case SW_HIDE: 1475 1476 1480 showstate = SWPOS_HIDE; 1481 break; 1477 1482 case SW_RESTORE: 1478 1479 1483 showstate = SWPOS_RESTORE | SWPOS_SHOW | SWPOS_ACTIVATE; 1484 break; 1480 1485 case SW_MINIMIZE: 1481 1482 1486 showstate = SWPOS_MINIMIZE; 1487 break; 1483 1488 case SW_SHOWMAXIMIZED: 1484 1485 1489 showstate = SWPOS_MAXIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE; 1490 break; 1486 1491 case SW_SHOWMINIMIZED: 1487 1488 1492 showstate = SWPOS_MINIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE; 1493 break; 1489 1494 case SW_SHOWMINNOACTIVE: 1490 1491 1495 showstate = SWPOS_MINIMIZE | SWPOS_SHOW; 1496 break; 1492 1497 case SW_SHOWNA: 1493 1494 1498 showstate = SWPOS_SHOW; 1499 break; 1495 1500 case SW_SHOWNOACTIVATE: 1496 1497 1501 showstate = SWPOS_SHOW; 1502 break; 1498 1503 case SW_SHOWNORMAL: 1499 1500 1504 showstate = SWPOS_RESTORE | SWPOS_ACTIVATE | SWPOS_SHOW; 1505 break; 1501 1506 } 1502 1507 return OSLibWinShowWindow(OS2HwndFrame, showstate); … … 1512 1517 dprintf (("SetWindowPos %x %x (%d,%d)(%d,%d) %x", Win32Hwnd, hwndInsertAfter, x, y, cx, cy, fuFlags)); 1513 1518 1514 /* Validate the flags passed in ... 1519 /* Validate the flags passed in ... */ 1515 1520 if ( fuFlags & 1516 ~(SWP_NOSIZE | SWP_NOMOVE| SWP_NOZORDER |1517 SWP_NOREDRAW| SWP_NOACTIVATE | SWP_FRAMECHANGED |1518 1519 1521 ~(SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | 1522 SWP_NOREDRAW | SWP_NOACTIVATE | SWP_FRAMECHANGED | 1523 SWP_SHOWWINDOW | SWP_HIDEWINDOW | SWP_NOCOPYBITS | 1524 SWP_NOOWNERZORDER) ) 1520 1525 { 1521 1526 return FALSE; … … 1528 1533 // Set up with Windows values. 1529 1534 //**************************** 1530 wpos.flags 1531 wpos.cy 1532 wpos.cx 1533 wpos.x 1534 wpos.y 1535 wpos.flags = fuFlags; 1536 wpos.cy = cy; 1537 wpos.cx = cx; 1538 wpos.x = x; 1539 wpos.y = y; 1535 1540 wpos.hwndInsertAfter = hwndInsertAfter; 1536 wpos.hwnd 1541 wpos.hwnd = getWindowHandle(); 1537 1542 1538 1543 //********************************************** … … 1542 1547 if (isChild()) 1543 1548 { 1544 1545 1549 hParent = getParent()->getOS2WindowHandle(); 1550 OSLibWinQueryWindowPos(OS2Hwnd, &swpOld); 1546 1551 } else 1547 1552 OSLibWinQueryWindowPos(OS2HwndFrame, &swpOld); 1548 1553 } 1549 1554 OSLibMapWINDOWPOStoSWP(&wpos, &swp, &swpOld, hParent, OS2HwndFrame); … … 1590 1595 if (rc == FALSE) 1591 1596 { 1592 // 1597 // SET_ERROR_LAST(); 1593 1598 } 1594 1599 else … … 1602 1607 ** a WM_UPDATEFRAME, which will provide the behavior of WM_NCCALCSIZE. 1603 1608 */ 1604 // 1605 // 1609 // if (fuFlags & SWP_FRAMECHANGED_W) 1610 // WinSendMsg(hWindow, WM_UPDATEFRAME, (MPARAM)-1, 0); 1606 1611 } 1607 1612 … … 1622 1627 return getParent()->getWindowHandle(); 1623 1628 } 1624 else 1629 else return 0; 1625 1630 } 1626 1631 //****************************************************************************** … … 1632 1637 1633 1638 if(getParent()) { 1634 1639 oldhwnd = getParent()->getWindowHandle(); 1635 1640 } 1636 1641 else oldhwnd = 0; … … 1638 1643 if(hwndNewParent == 0) {//desktop window = parent 1639 1644 setParent(NULL); 1640 1641 1645 OSLibWinSetParent(getOS2WindowHandle(), OSLIB_HWND_DESKTOP); 1646 return oldhwnd; 1642 1647 } 1643 1648 newparent = GetWindowFromHandle(hwndNewParent); 1644 1649 if(newparent) 1645 1650 { 1646 1647 1648 1651 setParent(newparent); 1652 OSLibWinSetParent(getOS2WindowHandle(), getParent()->getOS2WindowHandle()); 1653 return oldhwnd; 1649 1654 } 1650 1655 SetLastError(ERROR_INVALID_PARAMETER); … … 1658 1663 return getParent()->getWindowHandle() == hwndParent; 1659 1664 } 1660 else 1665 else return 0; 1661 1666 } 1662 1667 //****************************************************************************** … … 1677 1682 if(OSLibWinQueryUpdateRect(OS2Hwnd, &rect)) 1678 1683 {//update region not empty 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1684 HDC hdc; 1685 1686 hdc = O32_GetDC(OS2Hwnd); 1687 if (isIcon) 1688 { 1689 SendInternalMessageA(WM_ICONERASEBKGND, (WPARAM)hdc, 0); 1690 SendInternalMessageA(WM_PAINTICON, 0, 0); 1691 } else 1692 { 1693 SendInternalMessageA(WM_ERASEBKGND, (WPARAM)hdc, 0); 1694 SendInternalMessageA(WM_PAINT, 0, 0); 1695 } 1696 O32_ReleaseDC(OS2Hwnd, hdc); 1692 1697 } 1693 1698 return TRUE; … … 1705 1710 //****************************************************************************** 1706 1711 HWND Win32BaseWindow::FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPSTR lpszClass, LPSTR lpszWindow, 1707 1712 BOOL fUnicode) 1708 1713 { 1709 1714 Win32BaseWindow *parent = GetWindowFromHandle(hwndParent); … … 1714 1719 (hwndParent == OSLIB_HWND_DESKTOP && hwndChildAfter != 0)) 1715 1720 { 1716 1717 1718 1721 dprintf(("Win32BaseWindow::FindWindowEx: parent or child not found %x %x", hwndParent, hwndChildAfter)); 1722 SetLastError(ERROR_INVALID_WINDOW_HANDLE); 1723 return 0; 1719 1724 } 1720 1725 if(hwndParent != OSLIB_HWND_DESKTOP) 1721 1726 {//if the current process owns the window, just do a quick search 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1727 child = (Win32BaseWindow *)parent->getFirstChild(); 1728 if(hwndChildAfter != 0) 1729 { 1730 while(child) 1731 { 1732 if(child->getWindowHandle() == hwndChildAfter) 1733 { 1734 child = (Win32BaseWindow *)child->getNextChild(); 1735 break; 1736 } 1737 child = (Win32BaseWindow *)child->getNextChild(); 1738 } 1739 } 1740 while(child) 1741 { 1742 if(child->getWindowClass()->hasClassName(lpszClass, fUnicode) && 1743 (!lpszWindow || child->hasWindowName(lpszWindow, fUnicode))) 1744 { 1745 dprintf(("FindWindowEx: Found window %x", child->getWindowHandle())); 1746 return child->getWindowHandle(); 1747 } 1748 child = (Win32BaseWindow *)child->getNextChild(); 1749 } 1745 1750 } 1746 1751 else { 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1752 Win32BaseWindow *wnd; 1753 HWND henum, hwnd; 1754 1755 henum = OSLibWinBeginEnumWindows(OSLIB_HWND_DESKTOP); 1756 hwnd = OSLibWinGetNextWindow(henum); 1757 1758 while(hwnd) 1759 { 1760 wnd = GetWindowFromOS2Handle(hwnd); 1761 if(wnd == NULL) { 1762 hwnd = OSLibWinQueryClientWindow(hwnd); 1763 if(hwnd) wnd = GetWindowFromOS2Handle(hwnd); 1764 } 1765 1766 if(wnd) { 1767 LPVOID sharedmembase = (LPVOID)OSLibWinGetWindowULong(hwnd, OFFSET_WIN32PM_SHAREDMEM); 1768 1769 if(OSLibDosGetSharedMem(sharedmembase, MAX_HEAPSIZE, OSLIB_PAG_READ) != 0) { 1770 dprintf(("OSLibDosGetSharedMem returned error for %x", wnd)); 1771 break; 1772 } 1773 if(wnd->getWindowClass()->hasClassName(lpszClass, fUnicode) && 1774 (!lpszWindow || wnd->hasWindowName(lpszWindow, fUnicode))) 1775 { 1776 OSLibWinEndEnumWindows(henum); 1777 dprintf(("FindWindowEx: Found window %x", wnd->getWindowHandle())); 1778 return wnd->getWindowHandle(); 1779 } 1780 } 1781 hwnd = OSLibWinGetNextWindow(henum); 1782 } 1783 OSLibWinEndEnumWindows(henum); 1779 1784 } 1780 1785 SetLastError(ERROR_CANNOT_FIND_WND_CLASS); //TODO: not always correct … … 1787 1792 { 1788 1793 Win32BaseWindow *win32wnd; 1789 ULONG 1790 ULONG 1791 HWND 1794 ULONG magic; 1795 ULONG getcmd = 0; 1796 HWND hwndRelated; 1792 1797 1793 1798 dprintf(("GetWindow %x %d NOT COMPLETE", getWindowHandle(), uCmd)); 1794 1799 switch(uCmd) 1795 1800 { 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1801 case GW_CHILD: 1802 getcmd = QWOS_TOP; 1803 break; 1804 case GW_HWNDFIRST: 1805 if(getParent()) { 1806 getcmd = QWOS_TOP; //top of child windows 1807 } 1808 else getcmd = QWOS_TOP; //TODO 1809 break; 1810 case GW_HWNDLAST: 1811 if(getParent()) { 1812 getcmd = QWOS_BOTTOM; //bottom of child windows 1813 } 1814 else getcmd = QWOS_BOTTOM; //TODO 1815 break; 1816 case GW_HWNDNEXT: 1817 getcmd = QWOS_NEXT; 1818 break; 1819 case GW_HWNDPREV: 1820 getcmd = QWOS_PREV; 1821 break; 1822 case GW_OWNER: 1823 if(owner) { 1824 return owner->getWindowHandle(); 1825 } 1826 else return 0; 1822 1827 } 1823 1828 hwndRelated = OSLibWinQueryWindow(OS2Hwnd, getcmd); 1824 1829 if(hwndRelated) 1825 1830 { 1826 1827 magic= OSLibWinGetWindowULong(hwndRelated, OFFSET_WIN32PM_MAGIC);1828 1829 1830 1831 1831 win32wnd = (Win32BaseWindow *)OSLibWinGetWindowULong(hwndRelated, OFFSET_WIN32WNDPTR); 1832 magic = OSLibWinGetWindowULong(hwndRelated, OFFSET_WIN32PM_MAGIC); 1833 if(CheckMagicDword(magic) && win32wnd) 1834 { 1835 return win32wnd->getWindowHandle(); 1836 } 1832 1837 } 1833 1838 return 0; … … 1856 1861 HWND Win32BaseWindow::GetActiveWindow() 1857 1862 { 1858 HWND 1863 HWND hwndActive; 1859 1864 Win32BaseWindow *win32wnd; 1860 ULONG 1865 ULONG magic; 1861 1866 1862 1867 hwndActive = OSLibWinQueryActiveWindow(); … … 1866 1871 if(CheckMagicDword(magic) && win32wnd) 1867 1872 { 1868 1873 return win32wnd->getWindowHandle(); 1869 1874 } 1870 1875 return hwndActive; … … 1899 1904 { 1900 1905 if(fUnicode) { 1901 1906 return (lstrcmpW(windowNameW, (LPWSTR)wndname) == 0); 1902 1907 } 1903 1908 else return (strcmp(windowNameA, wndname) == 0); … … 1920 1925 { 1921 1926 if(lpsz == NULL) 1922 1927 return FALSE; 1923 1928 1924 1929 if(isUnicode == FALSE) { 1925 1926 1927 1928 1930 windowNameA = (LPSTR)_smalloc(strlen(lpsz)+1); 1931 strcpy(windowNameA, lpsz); 1932 windowNameW = (LPWSTR)_smalloc((strlen(lpsz)+1)*sizeof(WCHAR)); 1933 lstrcpyAtoW(windowNameW, windowNameA); 1929 1934 } 1930 1935 else { 1931 1932 1933 1934 1936 windowNameW = (LPWSTR)_smalloc((lstrlenW((LPWSTR)lpsz)+1)*sizeof(WCHAR)); 1937 lstrcpyW(windowNameW, (LPWSTR)lpsz); 1938 windowNameA = (LPSTR)_smalloc(lstrlenW((LPWSTR)lpsz)+1); 1939 lstrcpyWtoA(windowNameA, windowNameW); 1935 1940 } 1936 1941 wndNameLength = strlen(windowNameA)+1; //including 0 terminator 1937 1942 1938 1943 if(OS2Hwnd) 1939 1944 return OSLibWinSetWindowText(OS2Hwnd, (LPSTR)windowNameA); 1940 1945 1941 1946 return TRUE; … … 1948 1953 1949 1954 switch(index) { 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 1955 case GWL_EXSTYLE: 1956 oldval = dwExStyle; 1957 setExStyle(value); 1958 return oldval; 1959 case GWL_STYLE: 1960 oldval = dwStyle; 1961 setStyle(value); 1962 return oldval; 1963 case GWL_WNDPROC: 1964 oldval = (LONG)getWindowProc(); 1965 setWindowProc((WNDPROC)value); 1966 return oldval; 1967 case GWL_HINSTANCE: 1968 oldval = hInstance; 1969 hInstance = value; 1970 return oldval; 1971 case GWL_HWNDPARENT: 1972 return SetParent((HWND)value); 1973 1974 case GWL_ID: 1975 oldval = getWindowId(); 1976 setWindowId(value); 1977 return oldval; 1978 case GWL_USERDATA: 1979 oldval = userData; 1980 userData = value; 1981 return oldval; 1982 default: 1983 if(index >= 0 && index/4 < nrUserWindowLong) 1984 { 1985 oldval = userWindowLong[index/4]; 1986 userWindowLong[index/4] = value; 1987 return oldval; 1988 } 1989 SetLastError(ERROR_INVALID_PARAMETER); 1990 return 0; 1986 1991 } 1987 1992 } … … 1991 1996 { 1992 1997 switch(index) { 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 elsereturn 0;2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 1998 case GWL_EXSTYLE: 1999 return dwExStyle; 2000 case GWL_STYLE: 2001 return dwStyle; 2002 case GWL_WNDPROC: 2003 return (ULONG)getWindowProc(); 2004 case GWL_HINSTANCE: 2005 return hInstance; 2006 case GWL_HWNDPARENT: 2007 if(getParent()) { 2008 return getParent()->getWindowHandle(); 2009 } 2010 else return 0; 2011 case GWL_ID: 2012 return getWindowId(); 2013 case GWL_USERDATA: 2014 return userData; 2015 default: 2016 if(index >= 0 && index/4 < nrUserWindowLong) 2017 { 2018 return userWindowLong[index/4]; 2019 } 2020 SetLastError(ERROR_INVALID_PARAMETER); 2021 return 0; 2017 2022 } 2018 2023 } … … 2025 2030 if(index >= 0 && index/4 < nrUserWindowLong) 2026 2031 { 2027 2028 2029 2032 oldval = ((WORD *)userWindowLong)[index/2]; 2033 ((WORD *)userWindowLong)[index/2] = value; 2034 return oldval; 2030 2035 } 2031 2036 SetLastError(ERROR_INVALID_PARAMETER); … … 2038 2043 if(index >= 0 && index/4 < nrUserWindowLong) 2039 2044 { 2040 2045 return ((WORD *)userWindowLong)[index/2]; 2041 2046 } 2042 2047 SetLastError(ERROR_INVALID_PARAMETER); … … 2050 2055 2051 2056 if(HwGetWindowHandleData(hwnd, (DWORD *)&window) == TRUE) { 2052 2057 return window; 2053 2058 } 2054 2059 else return NULL; … … 2059 2064 { 2060 2065 Win32BaseWindow *win32wnd; 2061 DWORD 2066 DWORD magic; 2062 2067 2063 2068 win32wnd = (Win32BaseWindow *)OSLibWinGetWindowULong(hwnd, OFFSET_WIN32WNDPTR); … … 2065 2070 2066 2071 if(win32wnd && CheckMagicDword(magic)) { 2067 2072 return win32wnd; 2068 2073 } 2069 2074 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.