Changeset 304 for trunk/src/user32/new/win32wnd.cpp
- Timestamp:
- Jul 14, 1999, 11:05:59 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/new/win32wnd.cpp
r300 r304 1 /* $Id: win32wnd.cpp,v 1. 1 1999-07-14 08:35:37 sandervlExp $ */1 /* $Id: win32wnd.cpp,v 1.2 1999-07-14 21:05:58 cbratschi Exp $ */ 2 2 /* 3 3 * Win32 Window Code for OS/2 … … 45 45 //****************************************************************************** 46 46 Win32Window::Win32Window(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode) 47 47 : GenericObject(&windows, OBJTYPE_WINDOW) 48 48 { 49 49 Init(); … … 57 57 isUnicode = FALSE; 58 58 59 *windowName= NULL;59 windowName = NULL; 60 60 wndNameLength = 0; 61 61 62 *windowText= NULL;;62 windowText = NULL;; 63 63 wndTextLength = 0; 64 65 *userWindowLong= NULL;;64 65 userWindowLong = NULL;; 66 66 nrUserWindowLong = 0; 67 67 … … 69 69 OS2Hwnd = 0; 70 70 Win32Hwnd = 0; 71 if(HMHandleAllocate(&Win32Hwnd, (ULONG)this) != 0) 72 { 73 dprintf(("Win32Window::Init HMHandleAllocate failed!!")); 74 DebugInt3(); 71 72 //CB: what does this code? Win32Hwnd is always 0! 73 if(HMHandleAllocate(&Win32Hwnd, (ULONG)this) != 0) 74 { 75 dprintf(("Win32Window::Init HMHandleAllocate failed!!")); 76 DebugInt3(); 75 77 } 76 78 posx = posy = 0; … … 78 80 79 81 dwExStyle = 0; 80 dwStyle 82 dwStyle = 0; 81 83 win32wndproc = 0; 82 84 hInstance = 0; 83 85 parent = 0; 84 windowId = 0xFFFFFFFF; 86 windowId = 0xFFFFFFFF; //default = -1 85 87 userData = 0; 86 88 … … 95 97 { 96 98 if(Win32Hwnd) 97 99 HMHandleFree(Win32Hwnd); 98 100 if(windowName) 99 101 free(windowName); 100 102 if(windowText) 101 103 free(windowText); 102 104 if(userWindowLong) 103 105 free(userWindowLong); 104 106 } 105 107 //****************************************************************************** … … 109 111 char buffer[256]; 110 112 DWORD tmp; 111 INT sw = SW_SHOW; 113 INT sw = SW_SHOW; 112 114 POINT maxSize, maxPos, minTrack, maxTrack; 113 115 … … 117 119 if (cs->hwndParent) 118 120 { 119 121 /* Make sure parent is valid */ 120 122 if (!IsWindow( cs->hwndParent )) 121 123 { 122 123 124 125 126 } 127 else 124 dprintf(("Bad parent %04x\n", cs->hwndParent )); 125 SetLastError(ERROR_INVALID_PARAMETER); 126 return FALSE; 127 } 128 } 129 else 128 130 if ((cs->style & WS_CHILD) && !(cs->style & WS_POPUP)) { 129 131 dprintf(("No parent for child window\n" )); 130 132 SetLastError(ERROR_INVALID_PARAMETER); 131 133 return FALSE; /* WS_CHILD needs a parent, but WS_POPUP doesn't */ 132 134 } … … 141 143 } 142 144 143 /* Fix the lpszClass field: from existing programs, it seems ok to call a CreateWindowXXX 144 * with an atom as the class name, put some programs expect to have a *REAL* string in 145 * lpszClass when the CREATESTRUCT is sent with WM_CREATE 145 /* Fix the lpszClass field: from existing programs, it seems ok to call a CreateWindowXXX 146 * with an atom as the class name, put some programs expect to have a *REAL* string in 147 * lpszClass when the CREATESTRUCT is sent with WM_CREATE 146 148 */ 147 if (!HIWORD(cs->lpszClass) ) { 149 if (!HIWORD(cs->lpszClass) ) { 148 150 if (isUnicode) { 149 150 } 151 152 153 154 151 GlobalGetAtomNameW( classAtom, (LPWSTR)buffer, sizeof(buffer) ); 152 } 153 else { 154 GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) ); 155 } 156 cs->lpszClass = buffer; 155 157 } 156 158 … … 160 162 // PDB *pdb = PROCESS_Current(); 161 163 162 /* Never believe Microsoft's documentation... CreateWindowEx doc says 163 * that if an overlapped window is created with WS_VISIBLE style bit 164 /* Never believe Microsoft's documentation... CreateWindowEx doc says 165 * that if an overlapped window is created with WS_VISIBLE style bit 164 166 * set and the x parameter is set to CW_USEDEFAULT, the system ignores 165 167 * the y parameter. However, disassembling NT implementation (WIN32K.SYS) 166 168 * reveals that 167 169 * 168 * 1) not only if checks for CW_USEDEFAULT but also for CW_USEDEFAULT16 169 * 2) it does not ignore the y parameter as the docs claim; instead, it 170 * 1) not only if checks for CW_USEDEFAULT but also for CW_USEDEFAULT16 171 * 2) it does not ignore the y parameter as the docs claim; instead, it 170 172 * uses it as second parameter to ShowWindow() unless y is either 171 173 * CW_USEDEFAULT or CW_USEDEFAULT16. 172 * 174 * 173 175 * The fact that we didn't do 2) caused bogus windows pop up when wine 174 * was running apps that were using this obscure feature. Example - 175 * calc.exe that comes with Win98 (only Win98, it's different from 176 * was running apps that were using this obscure feature. Example - 177 * calc.exe that comes with Win98 (only Win98, it's different from 176 178 * the one that comes with Win95 and NT) 177 179 */ … … 212 214 nrUserWindowLong = windowClass->getExtraWndWords(); 213 215 if(nrUserWindowLong) { 214 215 216 userWindowLong = (ULONG *)malloc(nrUserWindowLong); 217 memset(userWindowLong, 0, nrUserWindowLong); 216 218 } 217 219 218 220 if ((cs->style & WS_CHILD) && cs->hwndParent) 219 221 { 220 221 222 223 224 225 222 if(HMHandleTranslateToOS2(cs->hwndParent, &tmp) != NO_ERROR) 223 { 224 dprintf(("HMHandleTranslateToOS2 couldn't find parent window %x!!!", cs->hwndParent)); 225 return FALSE; 226 } 227 parent = (Win32Window *)tmp; 226 228 } 227 229 else 228 230 { 229 parent = NULL; 231 parent = NULL; //desktop 230 232 if (!cs->hwndParent) { 231 232 233 owner = NULL; 234 } 233 235 else 234 236 { 235 236 237 238 239 240 241 237 if(HMHandleTranslateToOS2(cs->hwndParent, &tmp) != NO_ERROR) 238 { 239 dprintf(("HMHandleTranslateToOS2 couldn't find owner window %x!!!", cs->hwndParent)); 240 return FALSE; 241 } 242 owner = (Win32Window *)tmp; 243 } 242 244 } 243 245 … … 256 258 if (!(cs->style & WS_CHILD)) 257 259 { 258 259 260 260 dwStyle |= WS_CLIPSIBLINGS; 261 if (!(cs->style & WS_POPUP)) 262 { 261 263 dwStyle |= WS_CAPTION; 262 264 flags |= WIN_NEED_SIZE; 263 265 } 264 266 } 265 267 if (cs->dwExStyle & WS_EX_DLGMODALFRAME) dwStyle &= ~WS_THICKFRAME; … … 300 302 else 301 303 { 302 303 304 305 306 } 307 } 308 else 304 if (windowClass->getMenuNameA()) { 305 cs->hMenu = LoadMenuA(cs->hInstance, windowClass->getMenuNameA()); 306 if (cs->hMenu) SetMenu( getWindowHandle(), cs->hMenu ); 307 } 308 } 309 } 310 else windowId = (UINT)cs->hMenu; 309 311 310 312 DWORD dwOSWinStyle, dwOSFrameStyle; … … 314 316 OS2Hwnd = OSLibWinCreateWindow((parent) ? parent->getOS2WindowHandle() : 0, 315 317 dwOSWinStyle, dwOSFrameStyle, (char *)cs->lpszName, 316 cs->x, cs->y, cs->cx, cs->cy, 317 318 cs->x, cs->y, cs->cx, cs->cy, 319 (owner) ? owner->getOS2WindowHandle() : 0, 318 320 (hwndLinkAfter == HWND_BOTTOM) ? TRUE : FALSE); 319 321 320 322 if(OS2Hwnd == 0) { 321 322 323 dprintf(("Window creation failed!!")); 324 return FALSE; 323 325 } 324 326 if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, (ULONG)this) == FALSE) { 325 326 327 dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2Hwnd)); 328 return FALSE; 327 329 } 328 330 if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) { 329 dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd)); 330 return FALSE; 331 } 332 331 dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd)); 332 return FALSE; 333 } 334 335 return TRUE; 333 336 } 334 337 /******************************************************************* … … 338 341 */ 339 342 void Win32Window::GetMinMaxInfo(POINT *maxSize, POINT *maxPos, 340 343 POINT *minTrack, POINT *maxTrack ) 341 344 { 342 345 MINMAXINFO MinMax; … … 378 381 lpPos = (LPINTERNALPOS)GetPropA( wndPtr->hwndSelf, atomInternalPos ); 379 382 if( lpPos && !EMPTYPOINT(lpPos->ptMaxPos) ) 380 383 CONV_POINT16TO32( &lpPos->ptMaxPos, &MinMax.ptMaxPosition ); 381 384 else 382 385 { … … 454 457 { 455 458 WORD fwSizeType = 0; 456 459 457 460 if(fMinimize) { 458 461 fwSizeType = SIZE_MINIMIZED; 459 462 } 460 463 else 461 464 if(fMaximize) { 462 463 } 464 else 465 fwSizeType = SIZE_MAXIMIZED; 466 } 467 else fwSizeType = SIZE_RESTORED; 465 468 466 469 return SendMessageA(WM_SIZE, fwSizeType, MAKELONG((USHORT)width, (USHORT)height)); … … 491 494 492 495 switch(msg) { 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 496 case BUTTON_LEFTDOWN: 497 win32msg = WM_LBUTTONDOWN; 498 break; 499 case BUTTON_LEFTUP: 500 win32msg = WM_LBUTTONUP; 501 break; 502 case BUTTON_LEFTDBLCLICK: 503 win32msg = WM_LBUTTONDBLCLK; 504 break; 505 case BUTTON_RIGHTUP: 506 win32msg = WM_RBUTTONUP; 507 break; 508 case BUTTON_RIGHTDOWN: 509 win32msg = WM_RBUTTONDOWN; 510 break; 511 case BUTTON_RIGHTDBLCLICK: 512 win32msg = WM_RBUTTONDBLCLK; 513 break; 514 default: 515 dprintf(("Win32Window::Button: invalid msg!!!!")); 516 return 1; 514 517 } 515 518 return SendMessageA(win32msg, 0, MAKELONG(x, OS2TOWIN32POINT(height, y))); … … 532 535 { 533 536 if(PostSpyMessage(getWindowHandle(), Msg, wParam, lParam) == FALSE) 534 537 dprintf(("SendMessageA %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam)); 535 538 536 539 if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg … … 539 542 switch(Msg) 540 543 { 541 542 544 case WM_CREATE: 545 { 543 546 if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) { 544 545 547 dprintf(("WM_NCCREATE returned FALSE\n")); 548 return(0); //don't create window 546 549 } 547 550 if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == 0) { 548 549 550 } 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 551 dprintf(("WM_CREATE returned FALSE\n")); 552 return(0); //don't create window 553 } 554 NotifyParent(Msg, wParam, lParam); 555 556 return(1); 557 } 558 case WM_LBUTTONDOWN: 559 case WM_MBUTTONDOWN: 560 case WM_RBUTTONDOWN: 561 NotifyParent(Msg, wParam, lParam); 562 return win32wndproc(getWindowHandle(), Msg, wParam, lParam); 563 564 case WM_DESTROY: 565 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0); 566 NotifyParent(Msg, wParam, lParam); 567 return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0); 568 default: 569 return win32wndproc(getWindowHandle(), Msg, wParam, lParam); 567 570 } 568 571 } … … 574 577 Win32Window *parentwindow; 575 578 576 while(window) 579 while(window) 577 580 { 578 579 580 581 582 583 584 585 586 elseparentwindow->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, window->getWindowId()), lParam );587 588 589 elsebreak;590 591 581 if(window->getStyle() & WS_CHILD && !(window->getExStyle() & WS_EX_NOPARENTNOTIFY) ) 582 { 583 /* Notify the parent window only */ 584 parentwindow = window->getParent(); 585 if(parentwindow) { 586 if(Msg == WM_CREATE || Msg == WM_DESTROY) { 587 parentwindow->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, window->getWindowId()), (LPARAM)window->getWindowHandle()); 588 } 589 else parentwindow->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, window->getWindowId()), lParam ); 590 } 591 } 592 else break; 593 594 window = parentwindow; 592 595 } 593 596 } … … 599 602 600 603 switch(index) { 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 elseoldval = 0;625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 604 case GWL_EXSTYLE: 605 oldval = dwExStyle; 606 dwExStyle = value; 607 return oldval; 608 case GWL_STYLE: 609 oldval = dwStyle; 610 dwStyle = value; 611 return oldval; 612 case GWL_WNDPROC: 613 oldval = (LONG)getWindowProc(); 614 setWindowProc((WNDPROC)value); 615 return oldval; 616 case GWL_HINSTANCE: 617 oldval = hInstance; 618 hInstance = value; 619 return oldval; 620 case GWL_HWNDPARENT: 621 { 622 ULONG tmp; 623 624 if(getParent()) { 625 oldval = getParent()->getWindowHandle(); 626 } 627 else oldval = 0; 628 629 if(value == 0) {//desktop window = parent 630 setParent(NULL); 631 OSLibWinSetParent(getOS2WindowHandle(), OSLIB_HWND_DESKTOP); 632 return oldval; 633 } 634 if(HMHandleTranslateToOS2(value, &tmp) == NO_ERROR) 635 { 636 setParent((Win32Window *)tmp); 637 OSLibWinSetParent(getOS2WindowHandle(), getParent()->getOS2WindowHandle()); 638 return oldval; 639 } 640 SetLastError(ERROR_INVALID_PARAMETER); 641 return 0; 642 } 643 case GWL_ID: 644 oldval = getWindowId(); 645 setWindowId(value); 646 return oldval; 647 case GWL_USERDATA: 648 oldval = userData; 649 userData = value; 650 return oldval; 651 default: 652 if(index >= 0 && index/4 < nrUserWindowLong) 653 { 654 oldval = userWindowLong[index/4]; 655 userWindowLong[index/4] = value; 656 return oldval; 657 } 658 SetLastError(ERROR_INVALID_PARAMETER); 659 return 0; 657 660 } 658 661 } … … 662 665 { 663 666 switch(index) { 664 665 666 667 668 669 670 671 672 673 674 675 676 elsereturn 0;677 678 679 680 681 682 683 684 685 686 687 667 case GWL_EXSTYLE: 668 return dwExStyle; 669 case GWL_STYLE: 670 return dwStyle; 671 case GWL_WNDPROC: 672 return (ULONG)getWindowProc(); 673 case GWL_HINSTANCE: 674 return hInstance; 675 case GWL_HWNDPARENT: 676 if(getParent()) { 677 return getParent()->getWindowHandle(); 678 } 679 else return 0; 680 case GWL_ID: 681 return getWindowId(); 682 case GWL_USERDATA: 683 return userData; 684 default: 685 if(index >= 0 && index/4 < nrUserWindowLong) 686 { 687 return userWindowLong[index/4]; 688 } 689 SetLastError(ERROR_INVALID_PARAMETER); 690 return 0; 688 691 } 689 692 } … … 696 699 if(index >= 0 && index/4 < nrUserWindowLong) 697 700 { 698 699 700 701 oldval = ((WORD *)userWindowLong)[index/2]; 702 ((WORD *)userWindowLong)[index/2] = value; 703 return oldval; 701 704 } 702 705 SetLastError(ERROR_INVALID_PARAMETER); … … 709 712 if(index >= 0 && index/4 < nrUserWindowLong) 710 713 { 711 714 return ((WORD *)userWindowLong)[index/2]; 712 715 } 713 716 SetLastError(ERROR_INVALID_PARAMETER);
Note:
See TracChangeset
for help on using the changeset viewer.