Changeset 693 for trunk/src/user32/new/win32wnd.cpp
- Timestamp:
- Aug 25, 1999, 5:08:51 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/new/win32wnd.cpp
r650 r693 1 /* $Id: win32wnd.cpp,v 1. 29 1999-08-23 15:34:47dengert Exp $ */1 /* $Id: win32wnd.cpp,v 1.30 1999-08-25 15:08:50 dengert Exp $ */ 2 2 /* 3 3 * Win32 Window Code for OS/2 … … 57 57 //****************************************************************************** 58 58 Win32Window::Win32Window(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode) 59 59 : GenericObject(&windows, OBJTYPE_WINDOW), ChildWindow() 60 60 { 61 61 Init(); … … 67 67 void Win32Window::Init() 68 68 { 69 isUnicode 70 fCreated 71 fFirstShow 69 isUnicode = FALSE; 70 fCreated = FALSE; 71 fFirstShow = TRUE; 72 72 73 73 memset(windowNameA, 0, MAX_WINDOW_NAMELENGTH); … … 78 78 nrUserWindowLong = 0; 79 79 80 magic 81 OS2Hwnd 82 OS2HwndFrame 83 OS2HwndMenu 84 Win32Hwnd 80 magic = WIN32PM_MAGIC; 81 OS2Hwnd = 0; 82 OS2HwndFrame = 0; 83 OS2HwndMenu = 0; 84 Win32Hwnd = 0; 85 85 86 86 if(HMHandleAllocate(&Win32Hwnd, (ULONG)this) != 0) 87 87 { 88 89 90 } 91 Win32Hwnd 92 Win32Hwnd 93 94 posx = posy 88 dprintf(("Win32Window::Init HMHandleAllocate failed!!")); 89 DebugInt3(); 90 } 91 Win32Hwnd &= 0xFFFF; 92 Win32Hwnd |= 0x68000000; 93 94 posx = posy = 0; 95 95 width = height = 0; 96 96 97 dwExStyle 98 dwStyle 99 win32wndproc 100 hInstance 101 windowId = 0xFFFFFFFF;//default = -1102 userData 97 dwExStyle = 0; 98 dwStyle = 0; 99 win32wndproc = 0; 100 hInstance = 0; 101 windowId = 0xFFFFFFFF; //default = -1 102 userData = 0; 103 103 104 104 hwndLinkAfter = HWND_BOTTOM; 105 flags 106 isIcon 105 flags = 0; 106 isIcon = FALSE; 107 107 lastHitTestVal = 0; 108 owner 109 windowClass 108 owner = NULL; 109 windowClass = 0; 110 110 111 111 acceltableResource = NULL; 112 menuResource 113 iconResource 112 menuResource = NULL; 113 iconResource = NULL; 114 114 } 115 115 //****************************************************************************** … … 122 122 123 123 if(Win32Hwnd) 124 124 HMHandleFree(Win32Hwnd & 0xFFFF); 125 125 if(userWindowLong) 126 126 free(userWindowLong); 127 127 } 128 128 //****************************************************************************** … … 145 145 if (cs->hwndParent) 146 146 { 147 148 149 150 151 152 153 154 155 156 157 158 159 147 Win32Window *window = GetWindowFromHandle(cs->hwndParent); 148 if(!window) { 149 dprintf(("Bad parent %04x\n", cs->hwndParent )); 150 SetLastError(ERROR_INVALID_PARAMETER); 151 return FALSE; 152 } 153 /* Make sure parent is valid */ 154 if (!window->IsWindow() ) 155 { 156 dprintf(("Bad parent %04x\n", cs->hwndParent )); 157 SetLastError(ERROR_INVALID_PARAMETER); 158 return FALSE; 159 } 160 160 } 161 161 else 162 162 if ((cs->style & WS_CHILD) && !(cs->style & WS_POPUP)) { 163 164 165 163 dprintf(("No parent for child window\n" )); 164 SetLastError(ERROR_INVALID_PARAMETER); 165 return FALSE; /* WS_CHILD needs a parent, but WS_POPUP doesn't */ 166 166 } 167 167 … … 170 170 if (!windowClass) 171 171 { 172 173 174 172 GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) ); 173 dprintf(("Bad class '%s'\n", buffer )); 174 return 0; 175 175 } 176 176 … … 180 180 */ 181 181 if (!HIWORD(cs->lpszClass) ) { 182 183 184 185 186 187 188 182 if (isUnicode) { 183 GlobalGetAtomNameW( classAtom, (LPWSTR)buffer, sizeof(buffer) ); 184 } 185 else { 186 GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) ); 187 } 188 cs->lpszClass = buffer; 189 189 } 190 190 … … 192 192 if (cs->x == CW_USEDEFAULT || cs->x == CW_USEDEFAULT16) 193 193 { 194 // 194 // PDB *pdb = PROCESS_Current(); 195 195 196 196 /* Never believe Microsoft's documentation... CreateWindowEx doc says 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 197 * that if an overlapped window is created with WS_VISIBLE style bit 198 * set and the x parameter is set to CW_USEDEFAULT, the system ignores 199 * the y parameter. However, disassembling NT implementation (WIN32K.SYS) 200 * reveals that 201 * 202 * 1) not only if checks for CW_USEDEFAULT but also for CW_USEDEFAULT16 203 * 2) it does not ignore the y parameter as the docs claim; instead, it 204 * uses it as second parameter to ShowWindow() unless y is either 205 * CW_USEDEFAULT or CW_USEDEFAULT16. 206 * 207 * The fact that we didn't do 2) caused bogus windows pop up when wine 208 * was running apps that were using this obscure feature. Example - 209 * calc.exe that comes with Win98 (only Win98, it's different from 210 * the one that comes with Win95 and NT) 211 */ 212 if (cs->y != CW_USEDEFAULT && cs->y != CW_USEDEFAULT16) sw = cs->y; 213 214 /* We have saved cs->y, now we can trash it */ 215 215 #if 0 216 217 &&(pdb->env_db->startup_info->dwFlags & STARTF_USEPOSITION) )218 219 220 221 216 if ( !(cs->style & (WS_CHILD | WS_POPUP)) 217 && (pdb->env_db->startup_info->dwFlags & STARTF_USEPOSITION) ) 218 { 219 cs->x = pdb->env_db->startup_info->dwX; 220 cs->y = pdb->env_db->startup_info->dwY; 221 } 222 222 #endif 223 224 225 // 223 cs->x = 0; 224 cs->y = 0; 225 // } 226 226 } 227 227 if (cs->cx == CW_USEDEFAULT || cs->cx == CW_USEDEFAULT16) 228 228 { 229 229 #if 0 230 231 232 &&(pdb->env_db->startup_info->dwFlags & STARTF_USESIZE) )233 234 235 236 237 238 230 PDB *pdb = PROCESS_Current(); 231 if ( !(cs->style & (WS_CHILD | WS_POPUP)) 232 && (pdb->env_db->startup_info->dwFlags & STARTF_USESIZE) ) 233 { 234 cs->cx = pdb->env_db->startup_info->dwXSize; 235 cs->cy = pdb->env_db->startup_info->dwYSize; 236 } 237 else 238 { 239 239 #endif 240 241 242 // 240 cs->cx = 600; /* FIXME */ 241 cs->cy = 400; 242 // } 243 243 } 244 244 … … 249 249 nrUserWindowLong = windowClass->getExtraWndWords(); 250 250 if(nrUserWindowLong) { 251 252 251 userWindowLong = (ULONG *)malloc(nrUserWindowLong); 252 memset(userWindowLong, 0, nrUserWindowLong); 253 253 } 254 254 255 255 if ((cs->style & WS_CHILD) && cs->hwndParent) 256 256 { 257 257 SetParent(cs->hwndParent); 258 258 } 259 259 else 260 260 { 261 262 263 264 265 266 267 268 269 270 271 272 261 if (!cs->hwndParent) { 262 owner = NULL; 263 } 264 else 265 { 266 owner = GetWindowFromHandle(cs->hwndParent); 267 if(owner == NULL) 268 { 269 dprintf(("HMHandleTranslateToOS2 couldn't find owner window %x!!!", cs->hwndParent)); 270 return FALSE; 271 } 272 } 273 273 } 274 274 … … 279 279 280 280 hwndLinkAfter = ((cs->style & (WS_CHILD|WS_MAXIMIZE)) == WS_CHILD) 281 281 ? HWND_BOTTOM : HWND_TOP; 282 282 283 283 #if 0 … … 288 288 { 289 289 CBT_CREATEWNDA cbtc; 290 290 LRESULT ret; 291 291 292 292 cbtc.lpcs = cs; 293 293 cbtc.hwndInsertAfter = hwndLinkAfter; 294 295 296 294 ret = unicode ? HOOK_CallHooksW(WH_CBT, HCBT_CREATEWND, Win32Hwnd, (LPARAM)&cbtc) 295 : HOOK_CallHooksA(WH_CBT, HCBT_CREATEWND, Win32Hwnd, (LPARAM)&cbtc); 296 if (ret) 297 297 { 298 299 300 retvalue =0;301 298 TRACE_(win)("CBT-hook returned 0\n"); 299 wndPtr->pDriver->pFinalize(wndPtr); 300 retvalue = 0; 301 goto end; 302 302 } 303 303 } … … 310 310 if (!(cs->style & WS_CHILD)) 311 311 { 312 313 314 315 316 317 312 dwStyle |= WS_CLIPSIBLINGS; 313 if (!(cs->style & WS_POPUP)) 314 { 315 dwStyle |= WS_CAPTION; 316 flags |= WIN_NEED_SIZE; 317 } 318 318 } 319 319 if (cs->dwExStyle & WS_EX_DLGMODALFRAME) dwStyle &= ~WS_THICKFRAME; … … 330 330 if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD))) 331 331 { 332 333 334 335 336 332 GetMinMaxInfo(&maxSize, &maxPos, &minTrack, &maxTrack); 333 if (maxSize.x < cs->cx) cs->cx = maxSize.x; 334 if (maxSize.y < cs->cy) cs->cy = maxSize.y; 335 if (cs->cx < minTrack.x ) cs->cx = minTrack.x; 336 if (cs->cy < minTrack.y ) cs->cy = minTrack.y; 337 337 } 338 338 339 339 if(cs->style & WS_CHILD) 340 340 { 341 342 341 if(cs->cx < 0) cs->cx = 0; 342 if(cs->cy < 0) cs->cy = 0; 343 343 } 344 344 else 345 345 { 346 347 346 if (cs->cx <= 0) cs->cx = 1; 347 if (cs->cy <= 0) cs->cy = 1; 348 348 } 349 349 … … 352 352 rectWindow.right = cs->x + cs->cx; 353 353 rectWindow.bottom = cs->y + cs->cy; 354 rectClient 354 rectClient = rectWindow; 355 355 356 356 DWORD dwOSWinStyle, dwOSFrameStyle; … … 361 361 #if 1 362 362 if(cs->style & WS_CHILD) { 363 363 dwOSFrameStyle = 0; 364 364 } 365 365 #endif 366 366 367 367 OS2Hwnd = OSLibWinCreateWindow((getParent()) ? getParent()->getOS2WindowHandle() : OSLIB_HWND_DESKTOP, 368 369 370 371 368 dwOSWinStyle, dwOSFrameStyle, (char *)cs->lpszName, 369 (owner) ? owner->getOS2FrameWindowHandle() : OSLIB_HWND_DESKTOP, 370 (hwndLinkAfter == HWND_BOTTOM) ? TRUE : FALSE, 371 &OS2HwndFrame); 372 372 373 373 if(OS2Hwnd == 0) { 374 375 374 dprintf(("Window creation failed!!")); 375 return FALSE; 376 376 } 377 377 378 378 if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, (ULONG)this) == FALSE) { 379 380 379 dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2Hwnd)); 380 return FALSE; 381 381 } 382 382 if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) { 383 384 383 dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd)); 384 return FALSE; 385 385 } 386 386 #if 0 387 387 if(OS2Hwnd != OS2HwndFrame) { 388 388 if(OSLibWinSetWindowULong(OS2HwndFrame, OFFSET_WIN32WNDPTR, (ULONG)this) == FALSE) { 389 390 389 dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2HwndFrame)); 390 return FALSE; 391 391 } 392 392 if(OSLibWinSetWindowULong(OS2HwndFrame, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) { 393 394 393 dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2HwndFrame)); 394 return FALSE; 395 395 } 396 396 } … … 400 400 if ((dwStyle & (WS_CAPTION | WS_CHILD)) == WS_CAPTION ) 401 401 { 402 403 404 405 406 407 408 409 410 } 411 else 402 if (cs->hMenu) SetMenu(cs->hMenu); 403 else 404 { 405 if (windowClass->getMenuNameA()) { 406 cs->hMenu = LoadMenuA(cs->hInstance, windowClass->getMenuNameA()); 407 if (cs->hMenu) SetMenu(cs->hMenu ); 408 } 409 } 410 } 411 else windowId = (UINT)cs->hMenu; 412 412 413 413 //Set icon from class 414 414 if(windowClass->getIcon()) 415 415 SetIcon(windowClass->getIcon()); 416 416 417 417 if(getParent()) { 418 419 420 421 418 SetWindowPos(getParent()->getWindowHandle(), rectClient.left, rectClient.top, 419 rectClient.right-rectClient.left, 420 rectClient.bottom-rectClient.top, 421 SWP_NOACTIVATE | SWP_NOZORDER); 422 422 } 423 423 else { 424 425 426 427 424 SetWindowPos(HWND_TOP, rectClient.left, rectClient.top, 425 rectClient.right-rectClient.left, 426 rectClient.bottom-rectClient.top, 427 SWP_NOACTIVATE); 428 428 } 429 429 //Get the client window rectangle … … 439 439 if(SendInternalMessage(WM_NCCREATE, 0, (LPARAM)cs) ) 440 440 { 441 441 //doesn't work right, messes up client rectangle 442 442 #if 0 443 443 SendNCCalcSize(FALSE, &rectWindow, NULL, NULL, 0, &rectClient ); 444 444 #endif 445 446 447 448 449 450 451 452 453 454 455 445 OffsetRect(&rectWindow, maxPos.x - rectWindow.left, maxPos.y - rectWindow.top); 446 dprintf(("Sending WM_CREATE")); 447 if( (SendInternalMessage(WM_CREATE, 0, (LPARAM)cs )) != -1 ) 448 { 449 if(!(flags & WIN_NEED_SIZE)) { 450 SendMessageA(WM_SIZE, SIZE_RESTORED, 451 MAKELONG(rectClient.right-rectClient.left, 452 rectClient.bottom-rectClient.top)); 453 SendMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) ); 454 } 455 if (cs->style & WS_VISIBLE) ShowWindow( sw ); 456 456 457 457 #if 0 458 459 460 461 458 /* Call WH_SHELL hook */ 459 460 if (!(dwStyle & WS_CHILD) && !owner) 461 HOOK_CallHooks16( WH_SHELL, HSHELL_WINDOWCREATED, hwnd, 0 ); 462 462 #endif 463 464 465 463 SetLastError(0); 464 return TRUE; 465 } 466 466 } 467 467 fCreated = FALSE; … … 473 473 #if 0 474 474 /*********************************************************************** 475 * 475 * WINPOS_MinMaximize 476 476 * 477 477 * Fill in lpRect and return additional flags to be used with SetWindowPos(). … … 492 492 if( dwStyle & WS_MINIMIZE ) 493 493 { 494 495 496 494 if( !SendInternalMessageA(WM_QUERYOPEN, 0, 0L ) ) 495 return (SWP_NOSIZE | SWP_NOMOVE); 496 swpFlags |= SWP_NOCOPYBITS; 497 497 } 498 498 switch( cmd ) 499 499 { 500 501 502 503 504 505 506 507 508 500 case SW_MINIMIZE: 501 if( dwStyle & WS_MAXIMIZE) 502 { 503 flags |= WIN_RESTORE_MAX; 504 dwStyle &= ~WS_MAXIMIZE; 505 } 506 else 507 flags &= ~WIN_RESTORE_MAX; 508 dwStyle |= WS_MINIMIZE; 509 509 510 510 #if 0 511 512 513 511 if( flags & WIN_NATIVE ) 512 if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, TRUE ) ) 513 swpFlags |= MINMAX_NOSWP; 514 514 #endif 515 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 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 516 lpPos->ptIconPos = WINPOS_FindIconPos( wndPtr, lpPos->ptIconPos ); 517 518 SetRect(lpRect, lpPos->ptIconPos.x, lpPos->ptIconPos.y, 519 GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON) ); 520 swpFlags |= SWP_NOCOPYBITS; 521 break; 522 523 case SW_MAXIMIZE: 524 WINPOS_GetMinMaxInfo( wndPtr, &size, &pt, NULL, NULL ); 525 526 if( dwStyle & WS_MINIMIZE ) 527 { 528 if( flags & WIN_NATIVE ) 529 if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, FALSE ) ) 530 swpFlags |= MINMAX_NOSWP; 531 532 WINPOS_ShowIconTitle( wndPtr, FALSE ); 533 dwStyle &= ~WS_MINIMIZE; 534 } 535 dwStyle |= WS_MAXIMIZE; 536 537 SetRect16( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y, 538 size.x, size.y ); 539 break; 540 541 case SW_RESTORE: 542 if( dwStyle & WS_MINIMIZE ) 543 { 544 if( flags & WIN_NATIVE ) 545 if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, FALSE ) ) 546 swpFlags |= MINMAX_NOSWP; 547 548 dwStyle &= ~WS_MINIMIZE; 549 WINPOS_ShowIconTitle( wndPtr, FALSE ); 550 551 if( flags & WIN_RESTORE_MAX) 552 { 553 /* Restore to maximized position */ 554 CONV_POINT16TO32( &lpPos->ptMaxPos, &pt ); 555 WINPOS_GetMinMaxInfo( wndPtr, &size, &pt, NULL, NULL); 556 CONV_POINT32TO16( &pt, &lpPos->ptMaxPos ); 557 dwStyle |= WS_MAXIMIZE; 558 SetRect16( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y, size.x, size.y ); 559 break; 560 } 561 } 562 else 563 if( !(dwStyle & WS_MAXIMIZE) ) return (UINT16)(-1); 564 else dwStyle &= ~WS_MAXIMIZE; 565 566 /* Restore to normal position */ 567 568 *lpRect = lpPos->rectNormal; 569 lpRect->right -= lpRect->left; 570 lpRect->bottom -= lpRect->top; 571 572 break; 573 573 } 574 574 } else swpFlags |= SWP_NOSIZE | SWP_NOMOVE; … … 577 577 #endif 578 578 /******************************************************************* 579 * 579 * GetMinMaxInfo 580 580 * 581 581 * Get the minimized and maximized information for a window. 582 582 */ 583 583 void Win32Window::GetMinMaxInfo(POINT *maxSize, POINT *maxPos, 584 584 POINT *minTrack, POINT *maxTrack ) 585 585 { 586 586 MINMAXINFO MinMax; … … 599 599 else if (HAS_DLGFRAME( dwStyle, dwExStyle )) 600 600 { 601 602 601 xinc = GetSystemMetrics(SM_CXDLGFRAME); 602 yinc = GetSystemMetrics(SM_CYDLGFRAME); 603 603 } 604 604 else 605 605 { 606 607 608 609 610 611 612 613 614 615 616 606 xinc = yinc = 0; 607 if (HAS_THICKFRAME(dwStyle)) 608 { 609 xinc += GetSystemMetrics(SM_CXFRAME); 610 yinc += GetSystemMetrics(SM_CYFRAME); 611 } 612 if (dwStyle & WS_BORDER) 613 { 614 xinc += GetSystemMetrics(SM_CXBORDER); 615 yinc += GetSystemMetrics(SM_CYBORDER); 616 } 617 617 } 618 618 MinMax.ptMaxSize.x += 2 * xinc; … … 622 622 lpPos = (LPINTERNALPOS)GetPropA( hwndSelf, atomInternalPos ); 623 623 if( lpPos && !EMPTYPOINT(lpPos->ptMaxPos) ) 624 624 CONV_POINT16TO32( &lpPos->ptMaxPos, &MinMax.ptMaxPosition ); 625 625 else 626 626 { 627 627 #endif 628 629 628 MinMax.ptMaxPosition.x = -xinc; 629 MinMax.ptMaxPosition.y = -yinc; 630 630 // } 631 631 … … 635 635 636 636 dprintf(("GetMinMaxInfo: %ld %ld / %ld %ld / %ld %ld / %ld %ld\n", 637 638 639 640 637 MinMax.ptMaxSize.x, MinMax.ptMaxSize.y, 638 MinMax.ptMaxPosition.x, MinMax.ptMaxPosition.y, 639 MinMax.ptMaxTrackSize.x, MinMax.ptMaxTrackSize.y, 640 MinMax.ptMinTrackSize.x, MinMax.ptMinTrackSize.y)); 641 641 MinMax.ptMaxTrackSize.x = MAX( MinMax.ptMaxTrackSize.x, 642 642 MinMax.ptMinTrackSize.x ); 643 643 MinMax.ptMaxTrackSize.y = MAX( MinMax.ptMaxTrackSize.y, 644 644 MinMax.ptMinTrackSize.y ); 645 645 646 646 if (maxSize) *maxSize = MinMax.ptMaxSize; … … 650 650 } 651 651 /*********************************************************************** 652 * 652 * WINPOS_SendNCCalcSize 653 653 * 654 654 * Send a WM_NCCALCSIZE message to a window. … … 658 658 */ 659 659 LONG Win32Window::SendNCCalcSize(BOOL calcValidRect, RECT *newWindowRect, RECT *oldWindowRect, 660 661 660 RECT *oldClientRect, WINDOWPOS *winpos, 661 RECT *newClientRect ) 662 662 { 663 663 NCCALCSIZE_PARAMS params; … … 668 668 if (calcValidRect) 669 669 { 670 671 672 673 670 winposCopy = *winpos; 671 params.rgrc[1] = *oldWindowRect; 672 params.rgrc[2] = *oldClientRect; 673 params.lppos = &winposCopy; 674 674 } 675 675 result = SendInternalMessageA(WM_NCCALCSIZE, calcValidRect, 676 676 (LPARAM)¶ms ); 677 677 *newClientRect = params.rgrc[0]; 678 678 return result; … … 696 696 { 697 697 if(SendInternalMessageA(WM_CLOSE, 0, 0) == 0) { 698 698 return 0; //app handles this message 699 699 } 700 700 delete this; … … 726 726 //****************************************************************************** 727 727 //****************************************************************************** 728 ULONG Win32Window::MsgPosChanging(LPARAM lp) 729 { 730 dprintf(("MsgPosChanging")); 731 #if 1 732 if(fCreated == FALSE) { 733 return 1; 734 } 735 #endif 736 return SendInternalMessageA(WM_WINDOWPOSCHANGING, 0, lp); 737 } 738 //****************************************************************************** 739 //****************************************************************************** 740 ULONG Win32Window::MsgPosChanged(LPARAM lp) 741 { 742 dprintf(("MsgPosChanged")); 743 #if 1 744 if(fCreated == FALSE) { 745 return 1; 746 } 747 #endif 748 return SendInternalMessageA(WM_WINDOWPOSCHANGED, 0, lp); 749 } 750 //****************************************************************************** 751 //****************************************************************************** 728 752 ULONG Win32Window::MsgMove(ULONG x, ULONG y) 729 753 { 730 754 dprintf(("MsgMove to (%d,%d)", x, y)); 731 755 if(fCreated == FALSE) { 732 756 return 1; 733 757 } 734 758 … … 741 765 switch(cmd) { 742 766 case CMD_MENU: 743 767 return SendInternalMessageA(WM_COMMAND, MAKELONG(Id, 0), 0); 744 768 case CMD_CONTROL: 745 769 return 0; //todo 746 770 case CMD_ACCELERATOR: 747 748 771 dprintf(("accelerator command")); 772 return 0; //todo 749 773 } 750 774 return 0; … … 765 789 766 790 if(fCreated == FALSE) {//Solitaire crashes if it receives a WM_SIZE during CreateWindowEx (normal or our fault?) 767 791 return 1; 768 792 } 769 793 770 794 if(fMinimize) { 771 795 fwSizeType = SIZE_MINIMIZED; 772 796 } 773 797 else 774 798 if(fMaximize) { 775 799 fwSizeType = SIZE_MAXIMIZED; 776 800 } 777 801 else fwSizeType = SIZE_RESTORED; … … 785 809 if(SendInternalMessageA(WM_NCACTIVATE, fActivate, 0) == FALSE) 786 810 { 787 788 789 811 if(!fActivate) { 812 return 1; 813 } 790 814 } 791 815 return SendInternalMessageA(WM_ACTIVATE, (fActivate) ? WA_ACTIVE : WA_INACTIVE, hwnd); … … 807 831 lParam |= (scancode << 16); 808 832 if(keyflags & KEY_ALTDOWN) 809 833 lParam |= (1<<29); 810 834 if(keyflags & KEY_PREVDOWN) 811 835 lParam |= (1<<30); 812 836 if(keyflags & KEY_UP) 813 837 lParam |= (1<<31); 814 838 if(keyflags & KEY_DEADKEY) { 815 816 839 dprintf(("WM_DEADCHAR: %x %x %08x", OS2Hwnd, cmd, lParam)); 840 return SendInternalMessageA(WM_DEADCHAR, cmd, lParam); 817 841 } 818 842 else { 819 820 843 dprintf(("WM_CHAR: %x %x %08x", OS2Hwnd, cmd, lParam)); 844 return SendInternalMessageA(WM_CHAR, cmd, lParam); 821 845 } 822 846 } … … 826 850 { 827 851 if(hwnd == 0) { 828 829 852 //other app lost focus 853 SendInternalMessageA(WM_ACTIVATEAPP, TRUE, 0); //TODO: Need thread id from hwnd app 830 854 } 831 855 return SendInternalMessageA(WM_SETFOCUS, hwnd, 0); … … 836 860 { 837 861 if(hwnd == 0) { 838 839 862 //other app lost focus 863 SendInternalMessageA(WM_ACTIVATEAPP, FALSE, 0); //TODO: Need thread id from hwnd app 840 864 } 841 865 return SendInternalMessageA(WM_KILLFOCUS, hwnd, 0); … … 850 874 dprintf(("MsgButton to (%d,%d)", ncx, ncy)); 851 875 switch(msg) { 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 876 case BUTTON_LEFTDOWN: 877 win32msg = WM_LBUTTONDOWN; 878 win32ncmsg = WM_NCLBUTTONDOWN; 879 break; 880 case BUTTON_LEFTUP: 881 win32msg = WM_LBUTTONUP; 882 win32ncmsg = WM_NCLBUTTONUP; 883 break; 884 case BUTTON_LEFTDBLCLICK: 885 win32msg = WM_LBUTTONDBLCLK; 886 win32ncmsg = WM_NCLBUTTONDBLCLK; 887 break; 888 case BUTTON_RIGHTUP: 889 win32msg = WM_RBUTTONUP; 890 win32ncmsg = WM_NCRBUTTONUP; 891 break; 892 case BUTTON_RIGHTDOWN: 893 win32msg = WM_RBUTTONDOWN; 894 win32ncmsg = WM_NCRBUTTONDOWN; 895 break; 896 case BUTTON_RIGHTDBLCLICK: 897 win32msg = WM_RBUTTONDBLCLK; 898 win32ncmsg = WM_NCRBUTTONDBLCLK; 899 break; 900 case BUTTON_MIDDLEUP: 901 win32msg = WM_MBUTTONUP; 902 win32ncmsg = WM_NCMBUTTONUP; 903 break; 904 case BUTTON_MIDDLEDOWN: 905 win32msg = WM_MBUTTONDOWN; 906 win32ncmsg = WM_NCMBUTTONDOWN; 907 break; 908 case BUTTON_MIDDLEDBLCLICK: 909 win32msg = WM_MBUTTONDBLCLK; 910 win32ncmsg = WM_NCMBUTTONDBLCLK; 911 break; 912 default: 913 dprintf(("Win32Window::Button: invalid msg!!!!")); 914 return 1; 891 915 } 892 916 if(win32msg == WM_MBUTTONDBLCLK || win32msg == WM_RBUTTONDBLCLK || win32msg == WM_LBUTTONDBLCLK) { 893 894 895 917 if(!(windowClass->getClassLongA(GCL_STYLE) & CS_DBLCLKS)) { 918 return 1; 919 } 896 920 } 897 921 SendInternalMessageA(win32ncmsg, lastHitTestVal, MAKELONG(ncx, ncy)); //TODO: … … 905 929 906 930 if(keystate & WMMOVE_LBUTTON) 907 931 winstate |= MK_LBUTTON; 908 932 if(keystate & WMMOVE_RBUTTON) 909 933 winstate |= MK_RBUTTON; 910 934 if(keystate & WMMOVE_MBUTTON) 911 935 winstate |= MK_MBUTTON; 912 936 if(keystate & WMMOVE_SHIFT) 913 937 winstate |= MK_SHIFT; 914 938 if(keystate & WMMOVE_CTRL) 915 939 winstate |= MK_CONTROL; 916 940 917 941 return SendInternalMessageA(WM_MOUSEMOVE, keystate, MAKELONG(x, y)); … … 925 949 //****************************************************************************** 926 950 //TODO: Is the clipper region of the window DC equal to the invalidated rectangle? 927 // 951 // (or are we simply erasing too much here) 928 952 //****************************************************************************** 929 953 ULONG Win32Window::MsgEraseBackGround(HDC hdc) 930 954 { 931 955 if(isIcon) { 932 956 return SendInternalMessageA(WM_ICONERASEBKGND, hdc, 0); 933 957 } 934 958 else return SendInternalMessageA(WM_ERASEBKGND, hdc, 0); … … 939 963 { 940 964 if(isUnicode) { 941 965 return SendInternalMessageW(WM_SETTEXT, 0, (LPARAM)lpsz); 942 966 } 943 967 else return SendInternalMessageA(WM_SETTEXT, 0, (LPARAM)lpsz); … … 955 979 { 956 980 if(isUnicode) { 957 981 SendInternalMessageW(WM_GETTEXT, MAX_WINDOW_NAMELENGTH, (LPARAM)windowNameW); 958 982 } 959 983 else { 960 984 SendInternalMessageA(WM_GETTEXT, MAX_WINDOW_NAMELENGTH, (LPARAM)windowNameA); 961 985 } 962 986 return windowNameA; … … 969 993 { 970 994 case WM_GETTEXTLENGTH: 971 995 return wndNameLength; 972 996 973 997 case WM_GETTEXT: //TODO: SS_ICON controls 974 975 998 strncpy((LPSTR)lParam, windowNameA, wParam); 999 return min(wndNameLength, wParam); 976 1000 977 1001 case WM_SETTEXT: 978 1002 return 0; 979 1003 980 1004 case WM_SETREDRAW: 981 982 983 elseSetWindowLongA (GWL_STYLE, GetWindowLongA (GWL_STYLE) & ~WS_VISIBLE);984 985 1005 if(wParam) 1006 SetWindowLongA (GWL_STYLE, GetWindowLongA (GWL_STYLE) | WS_VISIBLE); 1007 else SetWindowLongA (GWL_STYLE, GetWindowLongA (GWL_STYLE) & ~WS_VISIBLE); 1008 1009 return 0; //TODO 986 1010 987 1011 case WM_NCCREATE: 988 1012 return(TRUE); 989 1013 990 1014 case WM_CTLCOLORMSGBOX: … … 995 1019 case WM_CTLCOLORSTATIC: 996 1020 case WM_CTLCOLORSCROLLBAR: 997 998 999 1021 SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW)); 1022 SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT)); 1023 return GetSysColorBrush(COLOR_BTNFACE); 1000 1024 1001 1025 case WM_PARENTNOTIFY: 1002 1026 return 0; 1003 1027 1004 1028 case WM_MOUSEACTIVATE: 1005 1029 { 1006 1007 1008 1009 1010 1011 1012 1013 if(rc)return rc;1014 1015 1016 1030 DWORD dwStyle = GetWindowLongA(GWL_STYLE); 1031 DWORD dwExStyle = GetWindowLongA(GWL_EXSTYLE); 1032 dprintf(("DefWndProc: WM_MOUSEACTIVATE for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam)))); 1033 if(dwStyle & WS_CHILD && !(dwExStyle & WS_EX_NOPARENTNOTIFY) ) 1034 { 1035 if(getParent()) { 1036 LRESULT rc = getParent()->SendMessageA(WM_MOUSEACTIVATE, wParam, lParam ); 1037 if(rc) return rc; 1038 } 1039 } 1040 return (LOWORD(lParam) == HTCAPTION) ? MA_NOACTIVATE : MA_ACTIVATE; 1017 1041 } 1018 1042 case WM_SETCURSOR: 1019 1043 { 1020 1021 1022 1023 1024 1025 1026 1027 if(rc)return rc;1028 1029 1030 1044 DWORD dwStyle = GetWindowLongA(GWL_STYLE); 1045 DWORD dwExStyle = GetWindowLongA(GWL_EXSTYLE); 1046 dprintf(("DefWndProc: WM_SETCURSOR for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam)))); 1047 if(dwStyle & WS_CHILD && !(dwExStyle & WS_EX_NOPARENTNOTIFY) ) 1048 { 1049 if(getParent()) { 1050 LRESULT rc = getParent()->SendMessageA(WM_SETCURSOR, wParam, lParam); 1051 if(rc) return rc; 1052 } 1053 } 1054 return 1; 1031 1055 } 1032 1056 case WM_MOUSEMOVE: 1033 return 0; 1034 1057 return 0; 1058 1059 case WM_WINDOWPOSCHANGED: 1060 { 1061 1062 /* undocumented SWP flags - from SDK 3.1 */ 1063 #define SWP_NOCLIENTSIZE 0x0800 1064 #define SWP_NOCLIENTMOVE 0x1000 1065 1066 PWINDOWPOS wpos = (PWINDOWPOS)lParam; 1067 WPARAM wp = SIZE_RESTORED; 1068 1069 if (!(wpos->flags & SWP_NOCLIENTMOVE)) 1070 SendMessageA(WM_MOVE, 0, MAKELONG(wpos->x, wpos->y)); 1071 1072 if (!(wpos->flags & SWP_NOCLIENTSIZE)) 1073 { 1074 if (dwStyle & WS_MAXIMIZE) wp = SIZE_MAXIMIZED; 1075 else if (dwStyle & WS_MINIMIZE) wp = SIZE_MINIMIZED; 1076 1077 SendMessageA(WM_SIZE, wp, MAKELONG(wpos->cx,wpos->cy)); 1078 } 1079 return 0; 1080 } 1035 1081 case WM_ERASEBKGND: 1036 1082 case WM_ICONERASEBKGND: … … 1038 1084 RECT rect; 1039 1085 1040 1041 1042 1043 1044 /* the device context.*/1045 1046 1047 1048 1049 1086 if (!windowClass->getBackgroundBrush()) return 0; 1087 1088 /* Since WM_ERASEBKGND may receive either a window dc or a */ 1089 /* client dc, the area to be erased has to be retrieved from */ 1090 /* the device context. */ 1091 GetClipBox( (HDC)wParam, &rect ); 1092 1093 FillRect( (HDC)wParam, &rect, windowClass->getBackgroundBrush()); 1094 1095 return 1; 1050 1096 } 1051 1097 … … 1059 1105 case WM_NCMBUTTONUP: 1060 1106 case WM_NCMBUTTONDBLCLK: 1061 return 0;//TODO: Send WM_SYSCOMMAND if required1107 return 0; //TODO: Send WM_SYSCOMMAND if required 1062 1108 1063 1109 case WM_NCHITTEST: //TODO: 1064 1110 return 0; 1065 1111 1066 1112 default: 1067 1113 return 1; 1068 1114 } 1069 1115 } … … 1075 1121 { 1076 1122 case WM_GETTEXTLENGTH: 1077 1123 return wndNameLength; 1078 1124 1079 1125 case WM_GETTEXT: //TODO: SS_ICON controls 1080 1081 1126 lstrcpynW((LPWSTR)lParam, windowNameW, wParam); 1127 return min(wndNameLength, wParam); 1082 1128 1083 1129 default: 1084 1130 return DefWindowProcA(Msg, wParam, lParam); 1085 1131 } 1086 1132 } … … 1090 1136 { 1091 1137 if(PostSpyMessage(getWindowHandle(), Msg, wParam, lParam) == FALSE) 1092 1138 dprintf(("SendMessageA %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam)); 1093 1139 1094 1140 if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg 1095 1141 return(0); 1096 1142 } 1097 1143 switch(Msg) 1098 1144 { 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1145 case WM_CREATE: 1146 { 1147 if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) { 1148 dprintf(("WM_NCCREATE returned FALSE\n")); 1149 return(-1); //don't create window 1150 } 1151 if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == -1) { 1152 dprintf(("WM_CREATE returned -1\n")); 1153 return(-1); //don't create window 1154 } 1155 NotifyParent(Msg, wParam, lParam); 1156 1157 return(0); 1158 } 1159 case WM_SETTEXT: //TODO: Nothing happens if passed to DefWindowProc 1160 return win32wndproc(getWindowHandle(), WM_SETTEXT, wParam, lParam); 1161 1162 case WM_LBUTTONDOWN: 1163 case WM_MBUTTONDOWN: 1164 case WM_RBUTTONDOWN: 1165 NotifyParent(Msg, wParam, lParam); 1166 return win32wndproc(getWindowHandle(), Msg, wParam, lParam); 1167 1168 case WM_DESTROY: 1169 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0); 1170 NotifyParent(Msg, wParam, lParam); 1171 return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0); 1172 default: 1173 return win32wndproc(getWindowHandle(), Msg, wParam, lParam); 1128 1174 } 1129 1175 } … … 1133 1179 { 1134 1180 if(PostSpyMessage(getWindowHandle(), Msg, wParam, lParam) == FALSE) 1135 1181 dprintf(("SendMessageA %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam)); 1136 1182 1137 1183 if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg 1138 1184 return(0); 1139 1185 } 1140 1186 switch(Msg) 1141 1187 { 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1188 case WM_CREATE: 1189 { 1190 if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) { 1191 dprintf(("WM_NCCREATE returned FALSE\n")); 1192 return(0); //don't create window 1193 } 1194 if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == 0) { 1195 dprintf(("WM_CREATE returned FALSE\n")); 1196 return(0); //don't create window 1197 } 1198 NotifyParent(Msg, wParam, lParam); 1199 1200 return(1); 1201 } 1202 case WM_SETTEXT: //TODO: Nothing happens if passed to DefWindowProc 1203 return win32wndproc(getWindowHandle(), WM_SETTEXT, wParam, lParam); 1204 1205 case WM_LBUTTONDOWN: 1206 case WM_MBUTTONDOWN: 1207 case WM_RBUTTONDOWN: 1208 NotifyParent(Msg, wParam, lParam); 1209 return win32wndproc(getWindowHandle(), Msg, wParam, lParam); 1210 1211 case WM_DESTROY: 1212 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0); 1213 NotifyParent(Msg, wParam, lParam); 1214 return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0); 1215 1216 default: 1217 return win32wndproc(getWindowHandle(), Msg, wParam, lParam); 1172 1218 } 1173 1219 } … … 1178 1224 { 1179 1225 if(PostSpyMessage(getWindowHandle(), Msg, wParam, lParam) == FALSE) 1180 1226 dprintf(("SendInternalMessageA %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam)); 1181 1227 1182 1228 if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg 1183 1229 return(0); 1184 1230 } 1185 1231 switch(Msg) 1186 1232 { 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1233 case WM_CREATE: 1234 { 1235 if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) { 1236 dprintf(("WM_NCCREATE returned FALSE\n")); 1237 return(0); //don't create window 1238 } 1239 if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == 0) { 1240 dprintf(("WM_CREATE returned FALSE\n")); 1241 return(0); //don't create window 1242 } 1243 NotifyParent(Msg, wParam, lParam); 1244 1245 return(1); 1246 } 1247 case WM_LBUTTONDOWN: 1248 case WM_MBUTTONDOWN: 1249 case WM_RBUTTONDOWN: 1250 NotifyParent(Msg, wParam, lParam); 1251 return win32wndproc(getWindowHandle(), Msg, wParam, lParam); 1252 1253 case WM_DESTROY: 1254 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0); 1255 NotifyParent(Msg, wParam, lParam); 1256 return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0); 1257 default: 1258 return win32wndproc(getWindowHandle(), Msg, wParam, lParam); 1213 1259 } 1214 1260 } … … 1220 1266 { 1221 1267 if(PostSpyMessage(getWindowHandle(), Msg, wParam, lParam) == FALSE) 1222 1268 dprintf(("SendInternalMessageW %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam)); 1223 1269 1224 1270 if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg 1225 1271 return(0); 1226 1272 } 1227 1273 switch(Msg) 1228 1274 { 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1275 case WM_CREATE: 1276 { 1277 if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) { 1278 dprintf(("WM_NCCREATE returned FALSE\n")); 1279 return(0); //don't create window 1280 } 1281 if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == 0) { 1282 dprintf(("WM_CREATE returned FALSE\n")); 1283 return(0); //don't create window 1284 } 1285 NotifyParent(Msg, wParam, lParam); 1286 1287 return(1); 1288 } 1289 case WM_LBUTTONDOWN: 1290 case WM_MBUTTONDOWN: 1291 case WM_RBUTTONDOWN: 1292 NotifyParent(Msg, wParam, lParam); 1293 return win32wndproc(getWindowHandle(), Msg, wParam, lParam); 1294 1295 case WM_DESTROY: 1296 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0); 1297 NotifyParent(Msg, wParam, lParam); 1298 return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0); 1299 default: 1300 return win32wndproc(getWindowHandle(), Msg, wParam, lParam); 1255 1301 } 1256 1302 } … … 1266 1312 return 0; 1267 1313 } 1268 postmsg->Msg 1314 postmsg->Msg = msg; 1269 1315 postmsg->wParam = wParam; 1270 1316 postmsg->lParam = lParam; … … 1282 1328 return 0; 1283 1329 } 1284 postmsg->Msg 1330 postmsg->Msg = msg; 1285 1331 postmsg->wParam = wParam; 1286 1332 postmsg->lParam = lParam; … … 1297 1343 while(window) 1298 1344 { 1299 1300 1301 1302 1303 1304 1305 1306 1307 elseparentwindow->SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, window->getWindowId()), lParam );1308 1309 1310 elsebreak;1311 1312 1345 if(window->getStyle() & WS_CHILD && !(window->getExStyle() & WS_EX_NOPARENTNOTIFY) ) 1346 { 1347 /* Notify the parent window only */ 1348 parentwindow = window->getParent(); 1349 if(parentwindow) { 1350 if(Msg == WM_CREATE || Msg == WM_DESTROY) { 1351 parentwindow->SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, window->getWindowId()), (LPARAM)window->getWindowHandle()); 1352 } 1353 else parentwindow->SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, window->getWindowId()), lParam ); 1354 } 1355 } 1356 else break; 1357 1358 window = parentwindow; 1313 1359 } 1314 1360 } … … 1317 1363 BOOL Win32Window::SetMenu(HMENU hMenu) 1318 1364 { 1319 PVOID 1365 PVOID menutemplate; 1320 1366 Win32Resource *winres = (Win32Resource *)hMenu; 1321 1367 1322 1368 dprintf(("SetMenu %x", hMenu)); 1323 1369 if(HIWORD(winres) == 0) { 1324 1325 1326 1370 dprintf(("Win32Window:: Win32Resource *winres == 0")); 1371 SetLastError(ERROR_INVALID_PARAMETER); 1372 return FALSE; 1327 1373 } 1328 1374 menutemplate = winres->lockOS2Resource(); 1329 1375 if(menutemplate == NULL) 1330 1376 { 1331 1332 1377 dprintf(("Win32Window::SetMenu menutemplate == 0")); 1378 return FALSE; 1333 1379 } 1334 1380 OS2HwndMenu = OSLibWinCreateMenu(OS2HwndFrame, menutemplate); 1335 1381 if(OS2HwndMenu == 0) { 1336 1337 1382 dprintf(("Win32Window::SetMenu OS2HwndMenu == 0")); 1383 return FALSE; 1338 1384 } 1339 1385 menuResource = winres; … … 1345 1391 { 1346 1392 Win32Resource *winres = (Win32Resource *)hAccel; 1347 HANDLE 1393 HANDLE accelhandle; 1348 1394 1349 1395 if(HIWORD(hAccel) == 0) { 1350 1351 1352 1396 dprintf(("SetAccelTable: hAccel %x invalid", hAccel)); 1397 SetLastError(ERROR_INVALID_PARAMETER); 1398 return FALSE; 1353 1399 } 1354 1400 acceltableResource = winres; … … 1372 1418 dprintf(("ShowWindow %x", nCmdShow)); 1373 1419 if(fFirstShow) { 1374 1375 1376 1377 1378 1379 1380 1381 1420 if(isFrameWindow() && IS_OVERLAPPED(getStyle())) { 1421 SendMessageA(WM_SIZE, SIZE_RESTORED, 1422 MAKELONG(rectClient.right-rectClient.left, 1423 rectClient.bottom-rectClient.top)); 1424 SendMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) ); 1425 1426 } 1427 fFirstShow = FALSE; 1382 1428 } 1383 1429 switch(nCmdShow) … … 1385 1431 case SW_SHOW: 1386 1432 case SW_SHOWDEFAULT: //todo 1387 1388 1433 showstate = SWPOS_SHOW | SWPOS_ACTIVATE; 1434 break; 1389 1435 case SW_HIDE: 1390 1391 1436 showstate = SWPOS_HIDE; 1437 break; 1392 1438 case SW_RESTORE: 1393 1394 1439 showstate = SWPOS_RESTORE | SWPOS_SHOW | SWPOS_ACTIVATE; 1440 break; 1395 1441 case SW_MINIMIZE: 1396 1397 1442 showstate = SWPOS_MINIMIZE; 1443 break; 1398 1444 case SW_SHOWMAXIMIZED: 1399 1400 1445 showstate = SWPOS_MAXIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE; 1446 break; 1401 1447 case SW_SHOWMINIMIZED: 1402 1403 1448 showstate = SWPOS_MINIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE; 1449 break; 1404 1450 case SW_SHOWMINNOACTIVE: 1405 1406 1451 showstate = SWPOS_MINIMIZE | SWPOS_SHOW; 1452 break; 1407 1453 case SW_SHOWNA: 1408 1409 1454 showstate = SWPOS_SHOW; 1455 break; 1410 1456 case SW_SHOWNOACTIVATE: 1411 1412 1457 showstate = SWPOS_SHOW; 1458 break; 1413 1459 case SW_SHOWNORMAL: 1414 1415 1460 showstate = SWPOS_RESTORE | SWPOS_ACTIVATE | SWPOS_SHOW; 1461 break; 1416 1462 } 1417 1463 return OSLibWinShowWindow(OS2HwndFrame, showstate); … … 1421 1467 BOOL Win32Window::SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags) 1422 1468 { 1423 Win32Window *window; 1424 ULONG setstate = 0; 1425 1426 switch(hwndInsertAfter) { 1427 case HWND_BOTTOM: 1428 hwndInsertAfter = HWNDOS_BOTTOM; 1429 break; 1430 case HWND_TOPMOST: //TODO 1431 case HWND_NOTOPMOST: //TODO: 1432 case HWND_TOP: 1433 hwndInsertAfter = HWNDOS_TOP; 1434 break; 1435 default: 1436 window = GetWindowFromHandle(hwndInsertAfter); 1437 if(window) { 1438 hwndInsertAfter = window->getOS2WindowHandle(); 1439 PRECT clientRect = window->getClientRect(); 1440 1441 #if 1 1442 if(x+cx > clientRect->right - clientRect->left) { 1443 dprintf(("Adjusting cx from %d to %d", cx, (clientRect->right - clientRect->left) - x)); 1444 cx = (clientRect->right - clientRect->left) - x; 1445 } 1446 if(y+cy > clientRect->bottom - clientRect->top) { 1447 dprintf(("Adjusting cy from %d to %d", cy, (clientRect->bottom - clientRect->top) - y)); 1448 cy = (clientRect->bottom - clientRect->top) - y; 1449 } 1450 #endif 1451 #if 0 1452 //Correct coordinates if parent is a frame window (border adjustment) 1453 //TODO: Not quite right (Solitaire child window placement slightly wrong) 1454 if (window->isFrameWindow() && !(fuFlags & SWP_NOMOVE)) { 1455 if (HAS_DLGFRAME(window->getStyle(), window->getExStyle() )) 1456 { 1457 x += GetSystemMetrics(SM_CXDLGFRAME); 1458 y -= GetSystemMetrics(SM_CYDLGFRAME); 1459 } 1460 else 1461 { 1462 if (HAS_THICKFRAME(window->getStyle())) 1463 { 1464 x += GetSystemMetrics(SM_CXFRAME); 1465 y -= GetSystemMetrics(SM_CYFRAME); 1466 } 1467 else 1468 if (window->getStyle() & WS_BORDER) 1469 { 1470 x += GetSystemMetrics(SM_CXBORDER); 1471 y -= GetSystemMetrics(SM_CYBORDER); 1472 } 1473 } 1474 } 1475 #endif 1476 } 1477 else { 1478 dprintf(("Win32Window::SetWindowPos, unknown hwndInsertAfter %x", hwndInsertAfter)); 1479 hwndInsertAfter = 0; 1480 } 1481 1482 break; 1483 1484 } 1485 setstate = SWPOS_MOVE | SWPOS_SIZE | SWPOS_ACTIVATE | SWPOS_ZORDER; 1486 if(fuFlags & SWP_DRAWFRAME) 1487 setstate |= 0; //TODO 1488 if(fuFlags & SWP_FRAMECHANGED) 1489 setstate |= 0; //TODO 1490 if(fuFlags & SWP_HIDEWINDOW) 1491 setstate &= ~SWPOS_ZORDER; 1492 if(fuFlags & SWP_NOACTIVATE) 1493 setstate &= ~SWPOS_ACTIVATE; 1494 if(fuFlags & SWP_NOCOPYBITS) 1495 setstate |= 0; //TODO 1496 if(fuFlags & SWP_NOMOVE) 1497 setstate &= ~SWPOS_MOVE; 1498 if(fuFlags & SWP_NOSIZE) 1499 setstate &= ~SWPOS_SIZE; 1500 if(fuFlags & SWP_NOREDRAW) 1501 setstate |= SWPOS_NOREDRAW; 1502 if(fuFlags & SWP_NOZORDER) 1503 setstate &= ~SWPOS_ZORDER; 1504 if(fuFlags & SWP_SHOWWINDOW) 1505 setstate |= SWPOS_SHOW; 1506 1507 //TODO send NCCREATE if size changed or SWP_FRAMECHANGED flag specified. 1508 return OSLibWinSetWindowPos(OS2HwndFrame, hwndInsertAfter, x, y, cx, cy, setstate); 1469 BOOL rc = FALSE; 1470 Win32Window *window; 1471 1472 dprintf (("SetWindowPos %x %x (%d,%d)(%d,%d) %x", Win32Hwnd, hwndInsertAfter, x, y, cx, cy, fuFlags)); 1473 1474 /* Validate the flags passed in ... */ 1475 if ( fuFlags & 1476 ~(SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | 1477 SWP_NOREDRAW | SWP_NOACTIVATE | SWP_FRAMECHANGED | 1478 SWP_SHOWWINDOW | SWP_HIDEWINDOW | SWP_NOCOPYBITS | 1479 SWP_NOOWNERZORDER) ) 1480 { 1481 return FALSE; 1482 } 1483 1484 WINDOWPOS wpos; 1485 SWP swp, swpOld; 1486 ULONG parentHeight; 1487 1488 //**************************** 1489 // Set up with Windows values. 1490 //**************************** 1491 wpos.flags = fuFlags; 1492 wpos.cy = cy; 1493 wpos.cx = cx; 1494 wpos.x = x; 1495 wpos.y = y; 1496 wpos.hwndInsertAfter = hwndInsertAfter; 1497 wpos.hwnd = getWindowHandle(); 1498 1499 //********************************************** 1500 // Convert from Windows to PM coords and flags. 1501 //********************************************** 1502 if(~fuFlags & (SWP_NOMOVE | SWP_NOSIZE)) { 1503 OSLibWinQueryWindowPos(OS2Hwnd, &swpOld); 1504 parentHeight = isChild() ? 1505 OSLibGetWindowHeight(getParent()->getOS2WindowHandle()) 1506 : OSLibQueryScreenHeight(); 1507 } 1508 OSLibMapWINDOWPOStoSWP(&wpos, &swp, &swpOld, parentHeight); 1509 1510 /* MapSWP can clear the SWP_MOVE and SWP_SIZE flags if the window is not 1511 * being moved or sized. If these were the only operations to be done 1512 * and they have been cleared, return now. 1513 */ 1514 if (swp.fl == 0) 1515 return TRUE; 1516 1517 //********************************************************************* 1518 //On Windows, a WM_GETMINMAXINFO is made to the app from within this API. 1519 //We'll send a WM_QUERYTRACKINFO which is translated into a WM_GETMINMAXINFO 1520 //and passed on to the app. Compare the values returned with the SWP cx and 1521 //cy values. They cannot be bigger than the max nor smaller than the min. 1522 //********************************************************************* 1523 1524 if ((swp.fl & SWPOS_ZORDER) && (swp.hwndInsertBehind > HWNDOS_BOTTOM)) 1525 { 1526 Win32Window *wndBehind = Win32Window::GetWindowFromHandle(swp.hwndInsertBehind); 1527 swp.hwndInsertBehind = wndBehind->getOS2WindowHandle(); 1528 } 1529 if (isFrameWindow()) 1530 { 1531 POINT maxSize, maxPos, minTrack, maxTrack; 1532 1533 GetMinMaxInfo(&maxSize, &maxPos, &minTrack, &maxTrack); 1534 1535 if (swp.cx > maxTrack.x) swp.cx = maxTrack.x; 1536 if (swp.cy > maxTrack.y) swp.cy = maxTrack.y; 1537 if (swp.cx < minTrack.x) swp.cx = minTrack.x; 1538 if (swp.cy < minTrack.y) swp.cy = minTrack.y; 1539 swp.hwnd = OS2HwndFrame; 1540 } else 1541 swp.hwnd = OS2Hwnd; 1542 dprintf (("WinSetWindowPos %x %x (%d,%d)(%d,%d) %x", swp.hwnd, swp.hwndInsertBehind, swp.x, swp.y, swp.cx, swp.cy, swp.fl)); 1543 1544 //***************************************************************************** 1545 // Squibble the window. (WinSetMultWindowPos is faster than WinSetWindowPos.) 1546 //***************************************************************************** 1547 rc = OSLibWinSetMultWindowPos(&swp, 1); 1548 1549 if (rc == FALSE) 1550 { 1551 // SET_ERROR_LAST(); 1552 } 1553 else 1554 { 1555 /* To implement support for SWP_FRAMECHANGED_W correctly, we would need 1556 ** to send a WM_NCCALCSIZE message. This means DAX would have to support 1557 ** the WM_NCCALCSIZE message. I don't think DAX can support this 1558 ** message because it is tightly bound with the architecture of 1559 ** overlapped windows (the "just one window" architecture). However, 1560 ** we *can* support the SWP_FRAMECHANGED flag by sending the window 1561 ** a WM_UPDATEFRAME, which will provide the behavior of WM_NCCALCSIZE. 1562 */ 1563 // if (fuFlags & SWP_FRAMECHANGED_W) 1564 // WinSendMsg(hWindow, WM_UPDATEFRAME, (MPARAM)-1, 0); 1565 } 1566 1567 return (rc); 1509 1568 } 1510 1569 //****************************************************************************** … … 1522 1581 return getParent()->getWindowHandle(); 1523 1582 } 1524 else 1583 else return 0; 1525 1584 } 1526 1585 //****************************************************************************** … … 1532 1591 1533 1592 if(getParent()) { 1534 1593 oldhwnd = getParent()->getWindowHandle(); 1535 1594 } 1536 1595 else oldhwnd = 0; … … 1538 1597 if(hwndNewParent == 0) {//desktop window = parent 1539 1598 setParent(NULL); 1540 1541 1599 OSLibWinSetParent(getOS2WindowHandle(), OSLIB_HWND_DESKTOP); 1600 return oldhwnd; 1542 1601 } 1543 1602 newparent = GetWindowFromHandle(hwndNewParent); 1544 1603 if(newparent) 1545 1604 { 1546 1547 1548 1605 setParent(newparent); 1606 OSLibWinSetParent(getOS2WindowHandle(), getParent()->getOS2WindowHandle()); 1607 return oldhwnd; 1549 1608 } 1550 1609 SetLastError(ERROR_INVALID_PARAMETER); … … 1558 1617 return getParent()->getWindowHandle() == hwndParent; 1559 1618 } 1560 else 1619 else return 0; 1561 1620 } 1562 1621 //****************************************************************************** … … 1577 1636 if(OSLibWinQueryUpdateRect(OS2Hwnd, &rect)) 1578 1637 {//update region not empty 1579 1638 SendInternalMessageA((isIcon) ? WM_PAINTICON : WM_PAINT, 0, 0); 1580 1639 } 1581 1640 return TRUE; … … 1593 1652 { 1594 1653 Win32Window *win32wnd; 1595 ULONG 1596 ULONG 1597 HWND 1654 ULONG magic; 1655 ULONG getcmd = 0; 1656 HWND hwndRelated; 1598 1657 1599 1658 dprintf(("GetWindow %x %d NOT COMPLETE", getWindowHandle(), uCmd)); 1600 1659 switch(uCmd) 1601 1660 { 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1661 case GW_CHILD: 1662 getcmd = QWOS_TOP; 1663 break; 1664 case GW_HWNDFIRST: 1665 if(getParent()) { 1666 getcmd = QWOS_TOP; //top of child windows 1667 } 1668 else getcmd = QWOS_TOP; //TODO 1669 break; 1670 case GW_HWNDLAST: 1671 if(getParent()) { 1672 getcmd = QWOS_BOTTOM; //bottom of child windows 1673 } 1674 else getcmd = QWOS_BOTTOM; //TODO 1675 break; 1676 case GW_HWNDNEXT: 1677 getcmd = QWOS_NEXT; 1678 break; 1679 case GW_HWNDPREV: 1680 getcmd = QWOS_PREV; 1681 break; 1682 case GW_OWNER: 1683 if(owner) { 1684 return owner->getWindowHandle(); 1685 } 1686 else return 0; 1628 1687 } 1629 1688 hwndRelated = OSLibWinQueryWindow(OS2Hwnd, getcmd); 1630 1689 if(hwndRelated) 1631 1690 { 1632 1633 magic= OSLibWinGetWindowULong(hwndRelated, OFFSET_WIN32PM_MAGIC);1634 1635 1636 1637 1691 win32wnd = (Win32Window *)OSLibWinGetWindowULong(hwndRelated, OFFSET_WIN32WNDPTR); 1692 magic = OSLibWinGetWindowULong(hwndRelated, OFFSET_WIN32PM_MAGIC); 1693 if(CheckMagicDword(magic) && win32wnd) 1694 { 1695 return win32wnd->getWindowHandle(); 1696 } 1638 1697 } 1639 1698 return 0; … … 1662 1721 HWND Win32Window::GetActiveWindow() 1663 1722 { 1664 HWND 1723 HWND hwndActive; 1665 1724 Win32Window *win32wnd; 1666 ULONG 1725 ULONG magic; 1667 1726 1668 1727 hwndActive = OSLibWinQueryActiveWindow(); … … 1725 1784 1726 1785 switch(index) { 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1786 case GWL_EXSTYLE: 1787 oldval = dwExStyle; 1788 dwExStyle = value; 1789 return oldval; 1790 case GWL_STYLE: 1791 oldval = dwStyle; 1792 dwStyle = value; 1793 return oldval; 1794 case GWL_WNDPROC: 1795 oldval = (LONG)getWindowProc(); 1796 setWindowProc((WNDPROC)value); 1797 return oldval; 1798 case GWL_HINSTANCE: 1799 oldval = hInstance; 1800 hInstance = value; 1801 return oldval; 1802 case GWL_HWNDPARENT: 1803 return SetParent((HWND)value); 1804 1805 case GWL_ID: 1806 oldval = getWindowId(); 1807 setWindowId(value); 1808 return oldval; 1809 case GWL_USERDATA: 1810 oldval = userData; 1811 userData = value; 1812 return oldval; 1813 default: 1814 if(index >= 0 && index/4 < nrUserWindowLong) 1815 { 1816 oldval = userWindowLong[index/4]; 1817 userWindowLong[index/4] = value; 1818 return oldval; 1819 } 1820 SetLastError(ERROR_INVALID_PARAMETER); 1821 return 0; 1763 1822 } 1764 1823 } … … 1768 1827 { 1769 1828 switch(index) { 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 elsereturn 0;1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1829 case GWL_EXSTYLE: 1830 return dwExStyle; 1831 case GWL_STYLE: 1832 return dwStyle; 1833 case GWL_WNDPROC: 1834 return (ULONG)getWindowProc(); 1835 case GWL_HINSTANCE: 1836 return hInstance; 1837 case GWL_HWNDPARENT: 1838 if(getParent()) { 1839 return getParent()->getWindowHandle(); 1840 } 1841 else return 0; 1842 case GWL_ID: 1843 return getWindowId(); 1844 case GWL_USERDATA: 1845 return userData; 1846 default: 1847 if(index >= 0 && index/4 < nrUserWindowLong) 1848 { 1849 return userWindowLong[index/4]; 1850 } 1851 SetLastError(ERROR_INVALID_PARAMETER); 1852 return 0; 1794 1853 } 1795 1854 } … … 1802 1861 if(index >= 0 && index/4 < nrUserWindowLong) 1803 1862 { 1804 1805 1806 1863 oldval = ((WORD *)userWindowLong)[index/2]; 1864 ((WORD *)userWindowLong)[index/2] = value; 1865 return oldval; 1807 1866 } 1808 1867 SetLastError(ERROR_INVALID_PARAMETER); … … 1815 1874 if(index >= 0 && index/4 < nrUserWindowLong) 1816 1875 { 1817 1876 return ((WORD *)userWindowLong)[index/2]; 1818 1877 } 1819 1878 SetLastError(ERROR_INVALID_PARAMETER); … … 1840 1899 { 1841 1900 Win32Window *win32wnd; 1842 DWORD 1901 DWORD magic; 1843 1902 1844 1903 win32wnd = (Win32Window *)OSLibWinGetWindowULong(hwnd, OFFSET_WIN32WNDPTR);
Note:
See TracChangeset
for help on using the changeset viewer.