- Timestamp:
- Feb 6, 2000, 11:00:25 PM (26 years ago)
- Location:
- trunk/src/user32
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/dc.cpp
r2663 r2672 1 /* $Id: dc.cpp,v 1.4 2 2000-02-05 16:24:57sandervl Exp $ */1 /* $Id: dc.cpp,v 1.43 2000-02-06 22:00:22 sandervl Exp $ */ 2 2 3 3 /* … … 29 29 #include <limits.h> 30 30 #include "oslibwin.h" 31 #include "oslibmsg.h" 31 32 #include <dcdata.h> 32 33 … … 71 72 HWND WIN32API GetDesktopWindow(void); 72 73 INT WIN32API GetUpdateRgn(HWND, HRGN, BOOL); 74 BOOL WIN32API HideCaret(HWND hwnd); 75 BOOL WIN32API ShowCaret(HWND hwnd); 76 HDC WIN32API GetDCEx(HWND hwnd, HRGN hrgn, ULONG flags); 77 int WIN32API ReleaseDC(HWND hwnd, HDC hdc); 78 BOOL WIN32API PostMessageA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); 73 79 74 80 //****************************************************************************** … … 427 433 if (pHps->hdc) 428 434 DevCloseDC(pHps->hdc); 429 430 // how can a memory chunk allocated by GpiAllocateDCData freed by delete?431 // delete pHps;432 435 } 433 436 } … … 436 439 HDC WIN32API BeginPaint (HWND hWnd, PPAINTSTRUCT_W lpps) 437 440 { 438 HWND hwnd = hWnd ? hWnd : HWND_DESKTOP; 439 pDCData pHps = NULLHANDLE; 440 RECTL rect; 441 HPS hPS_ownDC = NULLHANDLE; 442 443 if ( !lpps ) 444 { 441 HWND hwnd = hWnd ? hWnd : HWND_DESKTOP; 442 pDCData pHps = NULLHANDLE; 443 HPS hPS_ownDC = NULLHANDLE, hpsPaint = 0; 444 RECTL rectl = {0, 0, 1, 1}; 445 HRGN hrgnUpdate, hrgnOld; 446 LONG lComplexity; 447 448 Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd); 449 if(!lpps || !wnd) { 445 450 dprintf (("USER32: BeginPaint %x invalid parameter %x", hWnd, lpps)); 446 451 O32_SetLastError (ERROR_INVALID_PARAMETER); 447 return (HDC)NULLHANDLE; 448 } 449 450 Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd); 451 452 if ((hwnd != HWND_DESKTOP) && wnd->isOwnDC()) 452 return (HDC)0; 453 } 454 HWND hwndClient = wnd->getOS2WindowHandle(); 455 456 if(hwnd != HWND_DESKTOP && wnd->isOwnDC()) 453 457 { 454 458 hPS_ownDC = wnd->getOwnDC(); … … 462 466 return (HDC)NULLHANDLE; 463 467 } 468 hpsPaint = hPS_ownDC; 464 469 } 465 470 } 466 467 //SvL: Get update region for WM_ERASEBACKGROUND handling in the def wndproc 468 GetUpdateRgn(hWnd, wnd->GetUpdateRegion(), FALSE); 469 470 HWND hwndClient = wnd->getOS2WindowHandle(); 471 if(!hpsPaint) { 472 hpsPaint = GetDCEx(hwnd, 0, DCX_CACHE_W); 473 pHps = (pDCData)GpiQueryDCData(hpsPaint); 474 if (!pHps) 475 { 476 dprintf (("USER32: BeginPaint %x invalid parameter %x", hWnd, lpps)); 477 O32_SetLastError (ERROR_INVALID_PARAMETER); 478 return (HDC)NULLHANDLE; 479 } 480 } 481 482 #if 0 471 483 HPS hps = WinBeginPaint(hwndClient, hPS_ownDC, &rect); 472 484 … … 476 488 pHps = (pDCData)GpiQueryDCData(hps); 477 489 } 490 #endif 478 491 479 492 if (hPS_ownDC == 0) … … 483 496 484 497 pHps->hdcType = TYPE_3; 485 lpps->hdc = (HDC)hps; 486 487 if(!wnd->isSuppressErase()) { 498 499 hrgnUpdate = GpiCreateRegion(pHps->hps, 1, &rectl); 500 lComplexity = WinQueryUpdateRegion(hwndClient, hrgnUpdate); 501 if(lComplexity == RGN_ERROR) { 502 dprintf (("USER32: BeginPaint update region error!!")); 503 O32_SetLastError (ERROR_INVALID_PARAMETER); 504 return 0; 505 } 506 WinQueryUpdateRect(hwndClient, &rectl); 507 508 if(lComplexity != RGN_NULL) { 509 WinValidateRegion(hwndClient, hrgnUpdate, FALSE); 510 511 GpiSetClipRegion(pHps->hps, hrgnUpdate, &hrgnOld); 512 //save old clip region (restored for CS_OWNDC windows in EndPaint) 513 wnd->SetClipRegion(hrgnOld); 514 } 515 516 if(!wnd->isSuppressErase() && lComplexity != RGN_NULL) { 488 517 wnd->setSuppressErase(TRUE); 489 wnd->setEraseBkgnd (FALSE, !wnd->MsgEraseBackGround( lpps->hdc));490 } 491 lpps->fErase = wnd->isPSErase(); 492 493 if (!hPS_ownDC)494 {495 496 rect.yTop = height - rect.yTop;497 rect.yBottom = height - rect.yBottom;498 }499 else500 {501 rect.yTop--;502 rect.yBottom--;503 GpiConvert(pHps->hps, CVTC_DEVICE, CVTC_WORLD, 2, (PPOINTL)&rect);504 } 505 506 WINRECT_FROM_PMRECT(lpps->rcPaint, rect);518 wnd->setEraseBkgnd (FALSE, !wnd->MsgEraseBackGround(pHps->hps)); 519 } 520 lpps->fErase = wnd->isPSErase(); //correct ?? 521 lpps->hdc = (HDC)pHps->hps; 522 523 if(lComplexity != RGN_NULL) { 524 long height = wnd->getClientHeight(); 525 lpps->rcPaint.top = height - rectl.yTop; 526 lpps->rcPaint.left = rectl.xLeft; 527 lpps->rcPaint.bottom = height - rectl.yBottom; 528 lpps->rcPaint.right = rectl.xRight; 529 } 530 else { 531 lpps->rcPaint.bottom = lpps->rcPaint.top = 0; 532 lpps->rcPaint.right = lpps->rcPaint.left = 0; 533 } 534 535 HideCaret(hwnd); 507 536 508 537 O32_SetLastError(0); 509 dprintf(("USER32: BeginPaint %x -> hdc %x ", hWnd, pHps->hps));538 dprintf(("USER32: BeginPaint %x -> hdc %x (%d,%d)(%d,%d)", hWnd, pHps->hps, lpps->rcPaint.left, lpps->rcPaint.top, lpps->rcPaint.right, lpps->rcPaint.bottom)); 510 539 return (HDC)pHps->hps; 511 540 } 512 541 //****************************************************************************** 513 542 //****************************************************************************** 514 BOOL WIN32API EndPaint (HWND hwnd, const PAINTSTRUCT_W *pPaint) 515 { 543 BOOL WIN32API EndPaint (HWND hWnd, const PAINTSTRUCT_W *pPaint) 544 { 545 HWND hwnd = hWnd ? hWnd : HWND_DESKTOP; 546 HRGN hrgnOld; 547 pDCData pHps; 548 516 549 dprintf (("USER32: EndPaint(%x)", hwnd)); 517 550 … … 523 556 if (!wnd) goto exit; 524 557 525 //SvL: Hack for memory.exe (doesn't get repainted properly otherwise) 526 if(wnd->isOwnDC() && wnd->getOwnDC()) 527 // if(wnd->isOwnDC()) 528 { 529 pDCData pHps = (pDCData)GpiQueryDCData((HPS)pPaint->hdc); 530 if (pHps && (pHps->hdcType == TYPE_3)) 531 { 532 WinEndPaint (pHps->hps); 533 } 534 } 535 else 536 { 537 O32_EndPaint (HWND_DESKTOP, pPaint); 558 pHps = (pDCData)GpiQueryDCData((HPS)pPaint->hdc); 559 if (pHps && (pHps->hdcType == TYPE_3)) 560 { 561 GpiSetClipRegion(pHps->hps, NULLHANDLE, &hrgnOld); 562 if(hrgnOld) { 563 GpiDestroyRegion(pHps->hps, hrgnOld); 564 } 565 //todo restore old clip region for CS_OWNDC windows 566 if(hwnd == HWND_DESKTOP || !wnd->isOwnDC()) { 567 ReleaseDC(hwnd, pPaint->hdc); 568 } 569 else 570 if(wnd->GetClipRegion()) { 571 //TODO: What else do we need to restore here??? 572 GpiSetClipRegion(pHps->hps, wnd->GetClipRegion(), &hrgnOld); 573 wnd->SetClipRegion(0); 574 pHps->hdcType = TYPE_1; 575 } 576 577 //// WinEndPaint (pHps->hps); 578 } 579 else { 580 dprintf(("EndPaint: wrong hdc %x!!", pPaint->hdc)); 538 581 } 539 582 wnd->setSuppressErase(FALSE); 583 ShowCaret(hwnd); 540 584 541 585 exit: … … 569 613 if (updateRegionExists) 570 614 { 571 //CB: for PM empty rect is valid 572 if ((rectl.xLeft == rectl.xRight) || (rectl.yTop == rectl.yBottom)) return FALSE; 573 //SvL: Hack for memory.exe (doesn't get repainted properly otherwise) 615 //CB: for PM empty rect is valid 616 if ((rectl.xLeft == rectl.xRight) || (rectl.yTop == rectl.yBottom)) { 617 if(pRect) { 618 pRect->left = pRect->top = pRect->right = pRect->bottom = 0; 619 } 620 return FALSE; 621 } 622 #if 0 623 //SvL: Hack for memory.exe (doesn't get repainted properly otherwise) 574 624 // if (wnd->isOwnDC() && wnd->getOwnDC()) 575 if (wnd->isOwnDC()) 576 { 577 pDCData pHps = NULL; 578 pHps = (pDCData)GpiQueryDCData(wnd->getOwnDC()); 579 if (!pHps) 580 { 581 O32_SetLastError (ERROR_INVALID_HANDLE); 582 return FALSE; 583 } 584 GpiConvert (pHps->hps, CVTC_DEVICE, CVTC_WORLD, 2, (PPOINTL)&rectl); 585 } 586 else 587 { 588 long height = wnd->getClientHeight(); 589 rectl.yTop = height - rectl.yTop; 590 rectl.yBottom = height - rectl.yBottom; 591 } 592 593 if (pRect) 594 WINRECT_FROM_PMRECT (*pRect, rectl); 595 596 if (erase) 597 sendEraseBkgnd (wnd); 625 if (wnd->isOwnDC()) 626 { 627 pDCData pHps = NULL; 628 pHps = (pDCData)GpiQueryDCData(wnd->getOwnDC()); 629 if (!pHps) 630 { 631 O32_SetLastError (ERROR_INVALID_HANDLE); 632 return FALSE; 633 } 634 GpiConvert (pHps->hps, CVTC_DEVICE, CVTC_WORLD, 2, (PPOINTL)&rectl); 635 } 636 else 637 { 638 #endif 639 long height = wnd->getClientHeight(); 640 rectl.yTop = height - rectl.yTop; 641 rectl.yBottom = height - rectl.yBottom; 642 ////////// } 643 644 if (pRect) 645 WINRECT_FROM_PMRECT (*pRect, rectl); 646 647 if (erase) 648 sendEraseBkgnd (wnd); 598 649 } 599 650 else 600 651 { 601 if (pRect) 602 pRect->left = pRect->top = pRect->right = pRect->bottom = 0; 652 if(pRect) { 653 pRect->left = pRect->top = pRect->right = pRect->bottom = 0; 654 } 603 655 } 604 656 … … 627 679 if ((rectl.xLeft == rectl.xRight) || (rectl.yTop == rectl.yBottom)) return FALSE; 628 680 mapOS2ToWin32Rect(hwnd,(PRECTLOS2)&rectl,pRect); 629 } else 681 } 682 else 630 683 pRect->left = pRect->top = pRect->right = pRect->bottom = 0; 631 684 … … 647 700 648 701 Complexity = O32_GetUpdateRgn (wnd->getOS2WindowHandle(), hrgn, FALSE); 649 if (erase && (Complexity > NULLREGION_W)) sendEraseBkgnd 702 if (erase && (Complexity > NULLREGION_W)) sendEraseBkgnd(wnd); 650 703 651 704 return Complexity; … … 696 749 } 697 750 698 //SvL: Hack for memory.exe (doesn't get repainted properly otherwise)699 // isWindowOwnDC = (((hWindow == HWND_DESKTOP) ? FALSE : (wnd->isOwnDC() && wnd->getOwnDC()))700 751 isWindowOwnDC = (((hWindow == HWND_DESKTOP) ? FALSE : (wnd->isOwnDC())) 701 752 && !(flags & DCX_CACHE_W|DCX_WINDOW_W)); … … 768 819 { 769 820 #if 0 //CB: todo 821 long height; 822 if (flags & DCX_WINDOW_W) 823 height = wnd->getWindowHeight(); 824 else height = wnd->getClientHeight(); 825 770 826 for (; (i > 0) && success; i--, pr++) { 771 827 LONG y = pr->yBottom; … … 776 832 } 777 833 #endif 778 } else //DCX_INTERSECTRGN_W 834 } 835 else //DCX_INTERSECTRGN_W 779 836 { 780 837 O32_SelectClipRgn(pHps->hps,hrgn); //CB: works so far … … 855 912 dprintf(("ReleaseDC %x %x", hwnd, hdc)); 856 913 return (rc); 857 }858 //******************************************************************************859 //******************************************************************************860 BOOL WIN32API UpdateWindow (HWND hwnd)861 {862 Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);863 864 if(!wnd) {865 O32_SetLastError(ERROR_INVALID_WINDOW_HANDLE);866 return FALSE;867 }868 869 dprintf (("User32: UpdateWindow hwnd %x", hwnd));870 871 //SvL: Should update client window, not the frame872 WinUpdateWindow(wnd->getOS2WindowHandle());873 874 return (TRUE);875 914 } 876 915 //****************************************************************************** … … 941 980 if (redraw & RDW_UPDATENOW_W) redraw &= ~RDW_ERASENOW_W; 942 981 943 if (redraw & RDW_NOERASE_W) 944 wnd->setEraseBkgnd (FALSE); 982 if (redraw & RDW_NOERASE_W || !(redraw & (RDW_ERASE_W|RDW_ERASENOW_W))) { 983 wnd->setSuppressErase(TRUE); 984 } 985 else wnd->setSuppressErase(FALSE); 986 987 // if (redraw & RDW_NOERASE_W) 988 // wnd->setEraseBkgnd (FALSE); 945 989 946 990 //SvL: Test … … 1014 1058 } 1015 1059 1016 if (WinQueryUpdateRect(hwnd, NULL))1017 { 1018 if (redraw & RDW_UPDATENOW_W)1019 wnd->MsgPaint (0, FALSE);1020 1021 else if ((redraw & RDW_ERASE_W) && (redraw & RDW_ERASENOW_W))1022 wnd->setEraseBkgnd (FALSE, !sendEraseBkgnd (wnd));1023 }1024 else if ((redraw & RDW_INTERNALPAINT_W) && !(redraw & RDW_INVALIDATE_W))1025 {1026 if (redraw & RDW_UPDATENOW_W)1027 wnd->MsgPaint (0, FALSE);1028 // else 1029 // WinPostMsg( hwnd, WM_VIRTUAL_INTERNALPAINT, MPVOID, MPVOID);1060 if(WinQueryUpdateRect(hwnd, NULL)) 1061 { 1062 if(redraw & RDW_UPDATENOW_W) { 1063 wnd->MsgPaint (0, FALSE); 1064 } 1065 else 1066 if((redraw & RDW_ERASE_W) && (redraw & RDW_ERASENOW_W)) 1067 wnd->setEraseBkgnd (FALSE, !sendEraseBkgnd (wnd)); 1068 } 1069 else if((redraw & RDW_INTERNALPAINT_W) && !(redraw & RDW_INVALIDATE_W)) 1070 { 1071 if(redraw & RDW_UPDATENOW_W) 1072 wnd->MsgPaint (0, FALSE); 1073 else PostMessageA(hwnd, WINWM_PAINT, 0, 0); 1030 1074 } 1031 1075 … … 1048 1092 1049 1093 return (success); 1094 } 1095 //****************************************************************************** 1096 //****************************************************************************** 1097 BOOL WIN32API UpdateWindow (HWND hwnd) 1098 { 1099 Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle (hwnd); 1100 1101 if(!wnd) { 1102 O32_SetLastError(ERROR_INVALID_WINDOW_HANDLE); 1103 return FALSE; 1104 } 1105 1106 dprintf (("User32: UpdateWindow hwnd %x", hwnd)); 1107 ////SvL: This doesn't work right (it's what Wine does) -> TODO 1108 //// return RedrawWindow( hwnd, NULL, 0, RDW_UPDATENOW_W | RDW_NOCHILDREN_W); 1109 WinUpdateWindow(wnd->getOS2WindowHandle()); 1110 return TRUE; 1050 1111 } 1051 1112 //****************************************************************************** -
trunk/src/user32/win32class.cpp
r2469 r2672 1 /* $Id: win32class.cpp,v 1.1 2 2000-01-18 20:10:51sandervl Exp $ */1 /* $Id: win32class.cpp,v 1.13 2000-02-06 22:00:23 sandervl Exp $ */ 2 2 /* 3 3 * Win32 Window Class Managment Code for OS/2 … … 105 105 hInstance = wndclass->hInstance; 106 106 107 if(wndclass->style & CS_CLASSDC) { 108 hdcClass = 0; //TODO: 109 } 110 else hdcClass = 0; 111 107 112 windowStyle = wndclass->style; 108 113 WINPROC_SetProc((HWINDOWPROC *)&windowProc, wndclass->lpfnWndProc, (isUnicode) ? WIN_PROC_32W : WIN_PROC_32A, WIN_PROC_CLASS); … … 394 399 395 400 if(classNameA) { 396 397 } 398 else 401 dprintf2(("Win32WndClass::setClassLongA %s: %d %x", classNameA, index, lNewVal)); 402 } 403 else dprintf2(("Win32WndClass::setClassLongA %d: %d %x", classAtom, index, lNewVal)); 399 404 switch(index) { 400 405 case GCL_CBCLSEXTRA: //TODO (doesn't affect allocated classes, so what does it do?) -
trunk/src/user32/win32class.h
r2469 r2672 1 /* $Id: win32class.h,v 1. 8 2000-01-18 20:08:16sandervl Exp $ */1 /* $Id: win32class.h,v 1.9 2000-02-06 22:00:23 sandervl Exp $ */ 2 2 /* 3 3 * Win32 Window Class Managment Code for OS/2 … … 50 50 ULONG getStyle() { return windowStyle; }; 51 51 52 HDC getClassDC() { return hdcClass; }; 53 52 54 void setMenuName(LPSTR newMenuName); 53 55 … … 84 86 WCHAR *classNameW; 85 87 HICON hIconSm; 88 HDC hdcClass; 86 89 87 90 //User data class words/longs -
trunk/src/user32/win32dlg.cpp
r2663 r2672 1 /* $Id: win32dlg.cpp,v 1.4 2 2000-02-05 16:24:58sandervl Exp $ */1 /* $Id: win32dlg.cpp,v 1.43 2000-02-06 22:00:23 sandervl Exp $ */ 2 2 /* 3 3 * Win32 Dialog Code for OS/2 … … 700 700 if (!windowClass || !windowClass->getBackgroundBrush()) return 0; 701 701 702 // rc = GetClipBox( (HDC)wParam, &rect ); 703 rc = GetRgnBox(hUpdateRegion, &rect); 702 rc = GetClipBox( (HDC)wParam, &rect ); 704 703 if ((rc == SIMPLEREGION) || (rc == COMPLEXREGION)) 705 704 { … … 709 708 hBrush = GetSysColorBrush(hBrush-1); 710 709 711 // FillRect( (HDC)wParam, &rect, hBrush); 712 FillRgn((HDC)wParam, hUpdateRegion, hBrush); 710 FillRect( (HDC)wParam, &rect, hBrush); 713 711 } 714 712 -
trunk/src/user32/win32wbase.cpp
r2668 r2672 1 /* $Id: win32wbase.cpp,v 1.15 5 2000-02-06 17:39:34 cbratschiExp $ */1 /* $Id: win32wbase.cpp,v 1.156 2000-02-06 22:00:24 sandervl Exp $ */ 2 2 /* 3 3 * Win32 Window Base Class for OS/2 … … 146 146 ownDC = 0; 147 147 hWindowRegion = 0; 148 h UpdateRegion = CreateRectRgn(0, 0, 0, 0);148 hClipRegion = 0; 149 149 150 150 if(currentProcessId == -1) … … 180 180 } 181 181 182 if(hUpdateRegion) {183 DeleteObject(hUpdateRegion);184 hUpdateRegion = 0;185 }186 187 182 if(isOwnDC()) 188 183 releaseOwnDC(ownDC); … … 233 228 //****************************************************************************** 234 229 //****************************************************************************** 230 #if 1 235 231 BOOL Win32BaseWindow::CreateWindowExA(CREATESTRUCTA *cs, ATOM classAtom) 236 232 { 237 233 char buffer[256]; 238 234 POINT maxSize, maxPos, minTrack, maxTrack; 239 BOOL xDefault = FALSE,cxDefault = FALSE;240 235 241 236 #ifdef DEBUG … … 310 305 if ((cs->x == CW_USEDEFAULT) || (cs->x == CW_USEDEFAULT16)) 311 306 { 307 // PDB *pdb = PROCESS_Current(); 308 312 309 /* Never believe Microsoft's documentation... CreateWindowEx doc says 313 310 * that if an overlapped window is created with WS_VISIBLE style bit … … 329 326 330 327 /* We have saved cs->y, now we can trash it */ 328 #if 0 329 if ( !(cs->style & (WS_CHILD | WS_POPUP)) 330 && (pdb->env_db->startup_info->dwFlags & STARTF_USEPOSITION) ) 331 { 332 cs->x = pdb->env_db->startup_info->dwX; 333 cs->y = pdb->env_db->startup_info->dwY; 334 } 335 #endif 336 cs->x = 0; 337 cs->y = 0; 338 // } 339 } 340 if ((cs->cx == CW_USEDEFAULT) || (cs->cx == CW_USEDEFAULT16)) 341 { 342 #if 0 343 PDB *pdb = PROCESS_Current(); 344 if ( !(cs->style & (WS_CHILD | WS_POPUP)) 345 && (pdb->env_db->startup_info->dwFlags & STARTF_USESIZE) ) 346 { 347 cs->cx = pdb->env_db->startup_info->dwXSize; 348 cs->cy = pdb->env_db->startup_info->dwYSize; 349 } 350 else 351 { 352 #endif 353 cs->cx = 600; /* FIXME */ 354 cs->cy = 400; 355 // } 356 } 357 358 if (cs->x < 0) cs->x = 0; 359 if (cs->y < 0) cs->y = 0; 360 361 //Allocate window words 362 nrUserWindowLong = windowClass->getExtraWndWords(); 363 if(nrUserWindowLong) { 364 userWindowLong = (ULONG *)_smalloc(nrUserWindowLong); 365 memset(userWindowLong, 0, nrUserWindowLong); 366 } 367 368 if ((cs->style & WS_CHILD) && cs->hwndParent) 369 { 370 SetParent(cs->hwndParent); 371 owner = GetWindowFromHandle(cs->hwndParent); 372 if(owner == NULL) 373 { 374 dprintf(("HwGetWindowHandleData couldn't find owner window %x!!!", cs->hwndParent)); 375 SetLastError(ERROR_INVALID_WINDOW_HANDLE); 376 return FALSE; 377 } 378 } 379 else 380 { 381 SetParent(0); 382 if (!cs->hwndParent || (cs->hwndParent == windowDesktop->getWindowHandle())) { 383 owner = NULL; 384 } 385 else 386 { 387 owner = GetWindowFromHandle(cs->hwndParent)->GetTopParent(); 388 if(owner == NULL) 389 { 390 dprintf(("HwGetWindowHandleData couldn't find owner window %x!!!", cs->hwndParent)); 391 SetLastError(ERROR_INVALID_WINDOW_HANDLE); 392 return FALSE; 393 } 394 } 395 } 396 397 WINPROC_SetProc((HWINDOWPROC *)&win32wndproc, windowClass->getWindowProc(), WINPROC_GetProcType(windowClass->getWindowProc()), WIN_PROC_WINDOW); 398 hInstance = cs->hInstance; 399 dwStyle = cs->style & ~WS_VISIBLE; 400 dwExStyle = cs->dwExStyle; 401 402 hwndLinkAfter = HWND_TOP; 403 if(CONTROLS_IsControl(this, BUTTON_CONTROL) && ((dwStyle & 0x0f) == BS_GROUPBOX)) 404 { 405 hwndLinkAfter = HWND_BOTTOM; 406 dwStyle |= WS_CLIPSIBLINGS; 407 } 408 else 409 if(CONTROLS_IsControl(this, STATIC_CONTROL) && !(dwStyle & WS_GROUP)) { 410 dwStyle |= WS_CLIPSIBLINGS; 411 } 412 413 /* Increment class window counter */ 414 windowClass->IncreaseWindowCount(); 415 416 if (HOOK_IsHooked( WH_CBT )) 417 { 418 CBT_CREATEWNDA cbtc; 419 LRESULT ret; 420 421 cbtc.lpcs = cs; 422 cbtc.hwndInsertAfter = hwndLinkAfter; 423 ret = HOOK_CallHooksA(WH_CBT, HCBT_CREATEWND, getWindowHandle(), (LPARAM)&cbtc); 424 if(ret) 425 { 426 dprintf(("CBT-hook returned 0!!")); 427 SetLastError(ERROR_CAN_NOT_COMPLETE); //todo: wrong error 428 return FALSE; 429 } 430 } 431 432 /* Correct the window style */ 433 if (!(cs->style & WS_CHILD)) 434 { 435 dwStyle |= WS_CLIPSIBLINGS; 436 if (!(cs->style & WS_POPUP)) 437 { 438 dwStyle |= WS_CAPTION; 439 flags |= WIN_NEED_SIZE; 440 } 441 } 442 if (cs->dwExStyle & WS_EX_DLGMODALFRAME) dwStyle &= ~WS_THICKFRAME; 443 444 if (cs->style & WS_HSCROLL) 445 { 446 horzScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO)); 447 horzScrollInfo->MinVal = horzScrollInfo->CurVal = horzScrollInfo->Page = 0; 448 horzScrollInfo->MaxVal = 100; 449 horzScrollInfo->flags = ESB_ENABLE_BOTH; 450 } 451 452 if (cs->style & WS_VSCROLL) 453 { 454 vertScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO)); 455 vertScrollInfo->MinVal = vertScrollInfo->CurVal = vertScrollInfo->Page = 0; 456 vertScrollInfo->MaxVal = 100; 457 vertScrollInfo->flags = ESB_ENABLE_BOTH; 458 } 459 460 /* Send the WM_GETMINMAXINFO message and fix the size if needed */ 461 if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD))) 462 { 463 GetMinMaxInfo(&maxSize, &maxPos, &minTrack, &maxTrack); 464 if (maxSize.x < cs->cx) cs->cx = maxSize.x; 465 if (maxSize.y < cs->cy) cs->cy = maxSize.y; 466 if (cs->cx < minTrack.x) cs->cx = minTrack.x; 467 if (cs->cy < minTrack.y) cs->cy = minTrack.y; 468 } 469 470 if(cs->style & WS_CHILD) 471 { 472 if(cs->cx < 0) cs->cx = 0; 473 if(cs->cy < 0) cs->cy = 0; 474 } 475 else 476 { 477 if (cs->cx <= 0) cs->cx = 1; 478 if (cs->cy <= 0) cs->cy = 1; 479 } 480 481 if(((dwStyle & 0xC0000000) == WS_OVERLAPPED) && ((dwStyle & WS_CAPTION) == WS_CAPTION) && owner == NULL 482 && dwStyle & WS_SYSMENU) 483 { 484 fTaskList = TRUE; 485 } 486 487 DWORD dwOSWinStyle; 488 489 OSLibWinConvertStyle(dwStyle, dwExStyle, &dwOSWinStyle); 490 491 if(HIWORD(cs->lpszName)) 492 { 493 if (!isUnicode) 494 { 495 wndNameLength = strlen(cs->lpszName); 496 windowNameA = (LPSTR)_smalloc(wndNameLength+1); 497 strcpy(windowNameA,cs->lpszName); 498 windowNameW = (LPWSTR)_smalloc((wndNameLength+1)*sizeof(WCHAR)); 499 lstrcpyAtoW(windowNameW,windowNameA); 500 windowNameA[wndNameLength] = 0; 501 windowNameW[wndNameLength] = 0; 502 } 503 else 504 { 505 wndNameLength = lstrlenW((LPWSTR)cs->lpszName); 506 windowNameA = (LPSTR)_smalloc(wndNameLength+1); 507 lstrcpyWtoA(windowNameA,(LPWSTR)cs->lpszName); 508 windowNameW = (LPWSTR)_smalloc((wndNameLength+1)*sizeof(WCHAR)); 509 lstrcpyW(windowNameW,(LPWSTR)cs->lpszName); 510 windowNameA[wndNameLength] = 0; 511 windowNameW[wndNameLength] = 0; 512 } 513 } 514 515 //copy pointer of CREATESTRUCT for usage in MsgCreate method 516 tmpcs = cs; 517 518 //Store our window object pointer in thread local memory, so PMWINDOW.CPP can retrieve it 519 THDB *thdb = GetThreadTHDB(); 520 521 if(thdb == NULL) { 522 dprintf(("Window creation failed - thdb == NULL")); //this is VERY bad 523 ExitProcess(666); 524 return FALSE; 525 } 526 527 thdb->newWindow = (ULONG)this; 528 529 OS2Hwnd = OSLibWinCreateWindow((getParent()) ? getParent()->getOS2WindowHandle() : OSLIB_HWND_DESKTOP, 530 dwOSWinStyle,(char *)windowNameA, 531 (owner) ? owner->getOS2WindowHandle() : OSLIB_HWND_DESKTOP, 532 (hwndLinkAfter == HWND_BOTTOM) ? TRUE : FALSE, 533 &OS2HwndFrame, 0, fTaskList, 0, windowClass->getStyle() & CS_SAVEBITS); 534 if(OS2Hwnd == 0) { 535 dprintf(("Window creation failed!!")); 536 SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error 537 return FALSE; 538 } 539 540 SetLastError(0); 541 return TRUE; 542 } 543 #else 544 BOOL Win32BaseWindow::CreateWindowExA(CREATESTRUCTA *cs, ATOM classAtom) 545 { 546 char buffer[256]; 547 POINT maxSize, maxPos, minTrack, maxTrack; 548 BOOL xDefault = FALSE,cxDefault = FALSE; 549 550 #ifdef DEBUG 551 PrintWindowStyle(cs->style, cs->dwExStyle); 552 #endif 553 554 sw = SW_SHOW; 555 SetLastError(0); 556 557 /* Find the parent window */ 558 if (cs->hwndParent) 559 { 560 Win32BaseWindow *window = GetWindowFromHandle(cs->hwndParent); 561 if(!window) { 562 dprintf(("Bad parent %04x\n", cs->hwndParent )); 563 SetLastError(ERROR_INVALID_PARAMETER); 564 return FALSE; 565 } 566 /* Make sure parent is valid */ 567 if (!window->IsWindow() ) 568 { 569 dprintf(("Bad parent %04x\n", cs->hwndParent )); 570 SetLastError(ERROR_INVALID_PARAMETER); 571 return FALSE; 572 } 573 } 574 else 575 if ((cs->style & WS_CHILD) && !(cs->style & WS_POPUP)) { 576 dprintf(("No parent for child window\n" )); 577 SetLastError(ERROR_INVALID_PARAMETER); 578 return FALSE; /* WS_CHILD needs a parent, but WS_POPUP doesn't */ 579 } 580 581 /* Find the window class */ 582 windowClass = Win32WndClass::FindClass(cs->hInstance, (LPSTR)classAtom); 583 if (!windowClass) 584 { 585 GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) ); 586 dprintf(("Bad class '%s'\n", buffer )); 587 SetLastError(ERROR_INVALID_PARAMETER); 588 return 0; 589 } 590 #ifdef DEBUG 591 if(HIWORD(cs->lpszClass)) 592 { 593 char *astring; 594 595 if(isUnicode) astring = UnicodeToAsciiString((LPWSTR)cs->lpszClass); 596 else astring = (char *)cs->lpszClass; 597 598 dprintf(("Window class %s", astring)); 599 if(isUnicode) FreeAsciiString(astring); 600 } 601 else dprintf(("Window class %x", cs->lpszClass)); 602 #endif 603 604 /* Fix the lpszClass field: from existing programs, it seems ok to call a CreateWindowXXX 605 * with an atom as the class name, put some programs expect to have a *REAL* string in 606 * lpszClass when the CREATESTRUCT is sent with WM_CREATE 607 */ 608 if (!HIWORD(cs->lpszClass) ) { 609 if (isUnicode) { 610 GlobalGetAtomNameW( classAtom, (LPWSTR)buffer, sizeof(buffer) ); 611 } 612 else { 613 GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) ); 614 } 615 cs->lpszClass = buffer; 616 } 617 618 /* Fix the coordinates */ 619 if ((cs->x == CW_USEDEFAULT) || (cs->x == CW_USEDEFAULT16)) 620 { 621 /* Never believe Microsoft's documentation... CreateWindowEx doc says 622 * that if an overlapped window is created with WS_VISIBLE style bit 623 * set and the x parameter is set to CW_USEDEFAULT, the system ignores 624 * the y parameter. However, disassembling NT implementation (WIN32K.SYS) 625 * reveals that 626 * 627 * 1) not only if checks for CW_USEDEFAULT but also for CW_USEDEFAULT16 628 * 2) it does not ignore the y parameter as the docs claim; instead, it 629 * uses it as second parameter to ShowWindow() unless y is either 630 * CW_USEDEFAULT or CW_USEDEFAULT16. 631 * 632 * The fact that we didn't do 2) caused bogus windows pop up when wine 633 * was running apps that were using this obscure feature. Example - 634 * calc.exe that comes with Win98 (only Win98, it's different from 635 * the one that comes with Win95 and NT) 636 */ 637 if ((cs->y != CW_USEDEFAULT) && (cs->y != CW_USEDEFAULT16)) sw = cs->y; 638 639 /* We have saved cs->y, now we can trash it */ 331 640 cs->x = 0; 332 641 cs->y = 0; … … 539 848 return TRUE; 540 849 } 850 #endif 541 851 //****************************************************************************** 542 852 //****************************************************************************** … … 572 882 /* Get class or window DC if needed */ 573 883 if(windowClass->getStyle() & CS_OWNDC) { 574 dprintf(("Class with CS_OWNDC style"));575 // ownDC = GetWindowDC(getWindowHandle()); 884 dprintf(("Class with CS_OWNDC style")); 885 ownDC = GetDC(getWindowHandle()); //TODO: or GetWindowDC??? 576 886 } 577 887 else 578 888 if (windowClass->getStyle() & CS_PARENTDC) { 579 dprintf(("WARNING: Class with CS_PARENTDC style!"));580 fParentDC = TRUE;581 ownDC = 0;889 dprintf(("WARNING: Class with CS_PARENTDC style!")); 890 fParentDC = TRUE; 891 ownDC = 0; 582 892 } 583 893 else 584 894 if (windowClass->getStyle() & CS_CLASSDC) { 585 dprintf(("WARNING: Class with CS_CLASSDC style!"));586 ownDC = 0;895 dprintf(("WARNING: Class with CS_CLASSDC style!")); 896 ownDC = 0; 587 897 } 588 898 /* Set the window menu */ … … 1435 1745 if (!windowClass || !windowClass->getBackgroundBrush()) return 0; 1436 1746 1437 // rc = GetClipBox( (HDC)wParam, &rect ); 1438 rc = GetRgnBox(hUpdateRegion, &rect); 1747 rc = GetClipBox( (HDC)wParam, &rect ); 1439 1748 if ((rc == SIMPLEREGION) || (rc == COMPLEXREGION)) 1440 1749 { … … 1444 1753 hBrush = GetSysColorBrush(hBrush-1); 1445 1754 1446 // FillRect( (HDC)wParam, &rect, hBrush); 1447 FillRgn((HDC)wParam, hUpdateRegion, hBrush); 1448 } 1449 1755 FillRect( (HDC)wParam, &rect, hBrush); 1756 } 1450 1757 return 1; 1451 1758 } … … 1593 1900 break; 1594 1901 } 1595 1596 1902 case WM_SETHOTKEY: 1597 1903 hotkey = wParam; -
trunk/src/user32/win32wbase.h
r2666 r2672 1 /* $Id: win32wbase.h,v 1.8 1 2000-02-05 19:45:19 cbratschiExp $ */1 /* $Id: win32wbase.h,v 1.82 2000-02-06 22:00:25 sandervl Exp $ */ 2 2 /* 3 3 * Win32 Window Base Class for OS/2 … … 198 198 void SetWindowRegion(HRGN hRegion) { hWindowRegion = hRegion; }; 199 199 HRGN GetWindowRegion() { return hWindowRegion; }; 200 HRGN GetUpdateRegion() { return hUpdateRegion; }; 200 201 //Save old clip region for CS_OWNDC windows (in BeginPaint) 202 HRGN GetClipRegion() { return hClipRegion; }; 203 void SetClipRegion(HRGN hRegion) { hClipRegion = hRegion; }; 201 204 202 205 BOOL ShowWindow(ULONG nCmdShow); … … 343 346 344 347 HRGN hWindowRegion; 345 HRGN h UpdateRegion;348 HRGN hClipRegion; 346 349 347 350 DWORD dwThreadId; //id of thread that created this window
Note:
See TracChangeset
for help on using the changeset viewer.