Changeset 2677 for trunk/src/user32/win32wbase.cpp
- Timestamp:
- Feb 7, 2000, 9:32:43 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/win32wbase.cpp
r2676 r2677 1 /* $Id: win32wbase.cpp,v 1.15 7 2000-02-07 14:30:18 sandervlExp $ */1 /* $Id: win32wbase.cpp,v 1.158 2000-02-07 20:32:42 cbratschi Exp $ */ 2 2 /* 3 3 * Win32 Window Base Class for OS/2 … … 228 228 //****************************************************************************** 229 229 //****************************************************************************** 230 #if 1231 230 BOOL Win32BaseWindow::CreateWindowExA(CREATESTRUCTA *cs, ATOM classAtom) 232 231 { 233 232 char buffer[256]; 234 POINT maxSize, maxPos, minTrack, maxTrack;235 233 236 234 #ifdef DEBUG … … 303 301 304 302 /* Fix the coordinates */ 305 if ((cs->x == CW_USEDEFAULT) || (cs->x == CW_USEDEFAULT16)) 306 { 307 // PDB *pdb = PROCESS_Current(); 308 309 /* Never believe Microsoft's documentation... CreateWindowEx doc says 310 * that if an overlapped window is created with WS_VISIBLE style bit 311 * set and the x parameter is set to CW_USEDEFAULT, the system ignores 312 * the y parameter. However, disassembling NT implementation (WIN32K.SYS) 313 * reveals that 314 * 315 * 1) not only if checks for CW_USEDEFAULT but also for CW_USEDEFAULT16 316 * 2) it does not ignore the y parameter as the docs claim; instead, it 317 * uses it as second parameter to ShowWindow() unless y is either 318 * CW_USEDEFAULT or CW_USEDEFAULT16. 319 * 320 * The fact that we didn't do 2) caused bogus windows pop up when wine 321 * was running apps that were using this obscure feature. Example - 322 * calc.exe that comes with Win98 (only Win98, it's different from 323 * the one that comes with Win95 and NT) 324 */ 325 if ((cs->y != CW_USEDEFAULT) && (cs->y != CW_USEDEFAULT16)) sw = cs->y; 326 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()); 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 */ 303 fXDefault = FALSE; 304 fCXDefault = FALSE; 619 305 if ((cs->x == CW_USEDEFAULT) || (cs->x == CW_USEDEFAULT16)) 620 306 { … … 640 326 cs->x = 0; 641 327 cs->y = 0; 642 xDefault = TRUE;328 fXDefault = TRUE; 643 329 } 644 330 if ((cs->cx == CW_USEDEFAULT) || (cs->cx == CW_USEDEFAULT16)) … … 646 332 cs->cx = 600; /* FIXME */ 647 333 cs->cy = 400; 648 cxDefault = TRUE; 649 } 334 fCXDefault = TRUE; 335 } 336 if (fXDefault && !fCXDefault) fXDefault = FALSE; //CB: only x positioning doesn't work (calc.exe,cdrlabel.exe) 650 337 651 338 if (cs->x < 0) cs->x = 0; … … 798 485 (owner) ? owner->getOS2WindowHandle() : OSLIB_HWND_DESKTOP, 799 486 (hwndLinkAfter == HWND_BOTTOM) ? TRUE : FALSE, 800 &OS2HwndFrame, 0, fTaskList, xDefault | cxDefault,windowClass->getStyle() & CS_SAVEBITS);487 &OS2HwndFrame, 0, fTaskList,fXDefault | fCXDefault,windowClass->getStyle() & CS_SAVEBITS); 801 488 if(OS2Hwnd == 0) { 802 489 dprintf(("Window creation failed!!")); … … 805 492 } 806 493 494 SetLastError(0); 495 return TRUE; 496 } 497 //****************************************************************************** 498 //****************************************************************************** 499 BOOL Win32BaseWindow::MsgCreate(HWND hwndFrame, HWND hwndClient) 500 { 501 CREATESTRUCTA *cs = tmpcs; //pointer to CREATESTRUCT used in CreateWindowExA method 502 POINT maxSize, maxPos, minTrack, maxTrack; 503 504 OS2Hwnd = hwndClient; 505 OS2HwndFrame = hwndFrame; 506 507 fNoSizeMsg = TRUE; 508 509 if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, (ULONG)this) == FALSE) { 510 dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2Hwnd)); 511 SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error 512 return FALSE; 513 } 514 if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) { 515 dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd)); 516 SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error 517 return FALSE; 518 } 519 807 520 //adjust CW_USEDEFAULT position 808 if ( xDefault | cxDefault)521 if (fXDefault | fCXDefault) 809 522 { 810 523 RECT rect; 811 524 812 525 OSLibWinQueryWindowRect(OS2HwndFrame,&rect,RELATIVE_TO_SCREEN); 813 if (getParent()) mapWin32Rect(OSLIB_HWND_DESKTOP,getParent()->getOS2 FrameWindowHandle(),&rect);814 if ( xDefault)526 if (getParent()) mapWin32Rect(OSLIB_HWND_DESKTOP,getParent()->getOS2WindowHandle(),&rect); 527 if (fXDefault) 815 528 { 816 529 cs->x = rect.left; 817 530 cs->y = rect.top; 818 } 819 if (cxDefault) 531 if (!fCXDefault) 532 { 533 //CB: todo: adjust pos to screen rect 534 } 535 } 536 if (fCXDefault) 820 537 { 821 538 cs->cx = rect.right-rect.left; … … 843 560 if (cs->cx <= 0) cs->cx = 1; 844 561 if (cs->cy <= 0) cs->cy = 1; 845 }846 847 SetLastError(0);848 return TRUE;849 }850 #endif851 //******************************************************************************852 //******************************************************************************853 BOOL Win32BaseWindow::MsgCreate(HWND hwndFrame, HWND hwndClient)854 {855 POINT maxPos;856 CREATESTRUCTA *cs = tmpcs; //pointer to CREATESTRUCT used in CreateWindowExA method857 858 OS2Hwnd = hwndClient;859 OS2HwndFrame = hwndFrame;860 861 fNoSizeMsg = TRUE;862 863 if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, (ULONG)this) == FALSE) {864 dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2Hwnd));865 SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error866 return FALSE;867 }868 if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) {869 dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd));870 SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error871 return FALSE;872 562 } 873 563
Note:
See TracChangeset
for help on using the changeset viewer.