Changeset 1336 for trunk/src/user32/window.cpp
- Timestamp:
- Oct 17, 1999, 5:46:10 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/window.cpp
r1307 r1336 1 /* $Id: window.cpp,v 1.1 6 1999-10-15 10:03:16sandervl Exp $ */1 /* $Id: window.cpp,v 1.17 1999-10-17 15:46:10 sandervl Exp $ */ 2 2 /* 3 3 * Win32 window apis for OS/2 … … 29 29 #include "user32.h" 30 30 #include "winicon.h" 31 #include <win\winpos.h> 31 32 32 33 //****************************************************************************** … … 58 59 { 59 60 if (!HIWORD(className)) { 60 dprintf(("CreateWindowEx32 W: bad class name %04x\n", LOWORD(className)));61 dprintf(("CreateWindowEx32A: bad class name %04x\n", LOWORD(className))); 61 62 } 62 else dprintf(("CreateWindowEx32 W: bad class name '%s'\n", className ));63 else dprintf(("CreateWindowEx32A: bad class name '%s'\n", className )); 63 64 64 65 SetLastError(ERROR_INVALID_PARAMETER); … … 81 82 cs.dwExStyle = exStyle; 82 83 if(HIWORD(className)) { 83 84 dprintf(("CreateWindowExA: class %s parent %x (%d,%d) (%d,%d), %x %x", className, parent, x, y, width, height, style, exStyle)); 84 85 } 85 86 else dprintf(("CreateWindowExA: class %d parent %x (%d,%d) (%d,%d), %x %x", className, parent, x, y, width, height, style, exStyle)); … … 88 89 window = (Win32BaseWindow *) new Win32MDIClientWindow(&cs, classAtom, FALSE); 89 90 } 90 else 91 if(!strcmpi((char *) className, DIALOG_CLASS_NAMEA)) 91 else 92 if(!strcmpi((char *) className, DIALOG_CLASS_NAMEA)) 92 93 { 93 94 DLG_TEMPLATE dlgTemplate = {0}; … … 146 147 { 147 148 sprintf(tmpClassA,"#%d", (int) className); 148 AsciiToUnicode(tmpClassA, tmpClassW);149 AsciiToUnicode(tmpClassA, tmpClassW); 149 150 classAtom = GlobalFindAtomW(tmpClassW); 150 151 className = (LPCWSTR)tmpClassW; … … 155 156 dprintf(("CreateWindowEx32W: bad class name %04x\n", LOWORD(className))); 156 157 } 157 158 else dprintf(("CreateWindowEx32W: bad class name ")); 158 159 159 160 SetLastError(ERROR_INVALID_PARAMETER); … … 180 181 } 181 182 else 182 if(!lstrcmpiW(className, (LPWSTR)DIALOG_CLASS_NAMEW)) 183 if(!lstrcmpiW(className, (LPWSTR)DIALOG_CLASS_NAMEW)) 183 184 { 184 185 DLG_TEMPLATE dlgTemplate = {0}; … … 258 259 if(!window) { 259 260 dprintf(("CreateMDIWindowW, window %x not found", hwndParent)); 260 261 SetLastError(ERROR_INVALID_WINDOW_HANDLE); 261 262 return 0; 262 263 } … … 284 285 if(!window) { 285 286 dprintf(("DestroyWindow, window %x not found", hwnd)); 286 287 SetLastError(ERROR_INVALID_WINDOW_HANDLE); 287 288 return 0; 288 289 } … … 299 300 if(!window) { 300 301 dprintf(("SetActiveWindow, window %x not found", hwnd)); 301 302 SetLastError(ERROR_INVALID_WINDOW_HANDLE); 302 303 return 0; 303 304 } … … 314 315 if(!window) { 315 316 dprintf(("GetParent, window %x not found", hwnd)); 316 317 SetLastError(ERROR_INVALID_WINDOW_HANDLE); 317 318 return 0; 318 319 } … … 329 330 if(!window) { 330 331 dprintf(("SetParent, window %x not found", hwndChild)); 331 332 SetLastError(ERROR_INVALID_WINDOW_HANDLE); 332 333 return 0; 333 334 } … … 344 345 if(!window) { 345 346 dprintf(("IsChild, window %x not found", hwnd)); 346 347 SetLastError(ERROR_INVALID_WINDOW_HANDLE); 347 348 return 0; 348 349 } … … 359 360 if(!window) { 360 361 dprintf(("GetTopWindow, window %x not found", hwnd)); 361 362 SetLastError(ERROR_INVALID_WINDOW_HANDLE); 362 363 return 0; 363 364 } … … 389 390 if(!window) { 390 391 dprintf(("IsIconic, window %x not found", hwnd)); 391 392 SetLastError(ERROR_INVALID_WINDOW_HANDLE); 392 393 return 0; 393 394 } … … 405 406 if(!window) { 406 407 dprintf(("GetWindow, window %x not found", hwnd)); 407 408 SetLastError(ERROR_INVALID_WINDOW_HANDLE); 408 409 return 0; 409 410 } 410 411 rc = window->GetWindow(uCmd); 411 dprintf(("GetWindow %x %d returned %x", hwnd, uCmd, rc));412 412 return rc; 413 413 } … … 421 421 if(!window) { 422 422 dprintf(("EnableWindow, window %x not found", hwnd)); 423 423 SetLastError(ERROR_INVALID_WINDOW_HANDLE); 424 424 return 0; 425 425 } … … 448 448 if(!window) { 449 449 dprintf(("ShowWindow, window %x not found", hwnd)); 450 450 SetLastError(ERROR_INVALID_WINDOW_HANDLE); 451 451 return 0; 452 452 } … … 463 463 if(!window) { 464 464 dprintf(("SetWindowPos, window %x not found", hwnd)); 465 465 SetLastError(ERROR_INVALID_WINDOW_HANDLE); 466 466 return 0; 467 467 } … … 522 522 if(!window) { 523 523 dprintf(("IsWindowVisible, window %x not found", hwnd)); 524 524 SetLastError(ERROR_INVALID_WINDOW_HANDLE); 525 525 return 0; 526 526 } … … 553 553 dprintf(("USER32: GetFocus %x\n", hwnd)); 554 554 hwnd = Win32BaseWindow::OS2ToWin32Handle(hwnd); 555 return hwnd; 555 return hwnd; 556 556 } 557 557 //****************************************************************************** … … 625 625 if(!window) { 626 626 dprintf(("GetWindowRect, window %x not found", hwnd)); 627 627 SetLastError(ERROR_INVALID_WINDOW_HANDLE); 628 628 return 0; 629 629 } … … 641 641 if(!window) { 642 642 dprintf(("GetWindowTextLength, window %x not found", hwnd)); 643 643 SetLastError(ERROR_INVALID_WINDOW_HANDLE); 644 644 return 0; 645 645 } … … 657 657 if(!window) { 658 658 dprintf(("GetWindowTextA, window %x not found", hwnd)); 659 659 SetLastError(ERROR_INVALID_WINDOW_HANDLE); 660 660 return 0; 661 661 } … … 680 680 if(!window) { 681 681 dprintf(("GetWindowTextW, window %x not found", hwnd)); 682 682 SetLastError(ERROR_INVALID_WINDOW_HANDLE); 683 683 return 0; 684 684 } … … 695 695 if(!window) { 696 696 dprintf(("SetWindowTextA, window %x not found", hwnd)); 697 697 SetLastError(ERROR_INVALID_WINDOW_HANDLE); 698 698 return 0; 699 699 } … … 710 710 if(!window) { 711 711 dprintf(("SetWindowTextA, window %x not found", hwnd)); 712 712 SetLastError(ERROR_INVALID_WINDOW_HANDLE); 713 713 return 0; 714 714 } … … 746 746 HWND hwndWin32 = hwnd; 747 747 748 #if 1 749 Win32BaseWindow *window; 750 751 window = Win32BaseWindow::GetWindowFromHandle(hwnd); 752 if(!window) { 753 dprintf(("GetClientRect, window %x not found", hwnd)); 754 SetLastError(ERROR_INVALID_WINDOW_HANDLE); 755 return 0; 756 } 757 *pRect = *window->getClientRect(); 758 OffsetRect(pRect, -pRect->left, -pRect->top); 759 dprintf(("GetClientRect of %X returned (%d,%d) (%d,%d)\n", hwndWin32, pRect->left, pRect->top, pRect->right, pRect->bottom)); 760 return TRUE; 761 #else 748 762 hwnd = Win32BaseWindow::Win32ToOS2Handle(hwnd); 749 763 rc = OSLibWinQueryWindowRect(hwnd, pRect); 750 764 dprintf(("GetClientRect of %X returned (%d,%d) (%d,%d)\n", hwndWin32, pRect->left, pRect->top, pRect->right, pRect->bottom)); 751 765 return rc; 752 }753 //******************************************************************************754 //******************************************************************************755 BOOL WIN32API AdjustWindowRect( PRECT arg1, DWORD arg2, BOOL arg3)756 {757 #ifdef DEBUG758 WriteLog("USER32: AdjustWindowRect\n");759 766 #endif 760 return O32_AdjustWindowRect(arg1, arg2, arg3); 761 } 762 //****************************************************************************** 763 //****************************************************************************** 764 BOOL WIN32API AdjustWindowRectEx( PRECT arg1, DWORD arg2, BOOL arg3, DWORD arg4) 765 { 766 #ifdef DEBUG 767 WriteLog("USER32: AdjustWindowRectEx\n"); 767 } 768 //****************************************************************************** 769 //****************************************************************************** 770 BOOL WIN32API AdjustWindowRect(PRECT rect, DWORD style, BOOL menu) 771 { 772 return AdjustWindowRectEx(rect, style, menu, 0); 773 } 774 //****************************************************************************** 775 //****************************************************************************** 776 BOOL WIN32API AdjustWindowRectEx( PRECT rect, DWORD style, BOOL menu, DWORD exStyle) 777 { 778 dprintf(("AdjustWindowRectEx %x %x %d (%d,%d)(%d,%d)\n", style, exStyle, menu, rect->right, rect->top, rect->left, rect->bottom)); 779 780 #if 0 781 O32_AdjustWindowRectEx(rect, style, menu, exStyle); 782 #else 783 /* Correct the window style */ 784 if (!(style & (WS_POPUP | WS_CHILD))) /* Overlapped window */ 785 style |= WS_CAPTION; 786 787 style &= (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME | WS_CHILD | WS_VSCROLL | WS_HSCROLL); 788 exStyle &= (WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | 789 WS_EX_STATICEDGE | WS_EX_TOOLWINDOW); 790 if (exStyle & WS_EX_DLGMODALFRAME) style &= ~WS_THICKFRAME; 791 792 Win32BaseWindow::NC_AdjustRectOuter( rect, style, menu, exStyle ); 793 Win32BaseWindow::NC_AdjustRectInner( rect, style, exStyle ); 768 794 #endif 769 return O32_AdjustWindowRectEx(arg1, arg2, arg3, arg4); 795 796 dprintf(("AdjustWindowRectEx returned (%d,%d)(%d,%d)\n", rect->right, rect->top, rect->left, rect->bottom)); 797 return TRUE; 770 798 } 771 799 //****************************************************************************** … … 781 809 { 782 810 if(!lpszClass) { 783 784 811 SetLastError(ERROR_INVALID_PARAMETER); 812 return 0; 785 813 } 786 814 if(HIWORD(lpszClass)) { … … 793 821 //****************************************************************************** 794 822 //****************************************************************************** 823 HWND WIN32API FindWindowW( LPCWSTR lpClassName, LPCWSTR lpWindowName) 824 { 825 char *astring1 = UnicodeToAsciiString((LPWSTR)lpClassName); 826 char *astring2 = UnicodeToAsciiString((LPWSTR)lpWindowName); 827 HWND rc; 828 829 rc = FindWindowA(astring1, astring2); 830 FreeAsciiString(astring1); 831 FreeAsciiString(astring2); 832 return rc; 833 } 834 //****************************************************************************** 835 //****************************************************************************** 795 836 HWND WIN32API FindWindowExA(HWND hwndParent, HWND hwndChildAfter, LPCSTR lpszClass, LPCSTR lpszWindow) 796 837 { 797 838 if(!lpszClass) { 798 799 839 SetLastError(ERROR_INVALID_PARAMETER); 840 return 0; 800 841 } 801 842 if(HIWORD(lpszClass)) { … … 833 874 { 834 875 if(!lpszClass) { 835 836 876 SetLastError(ERROR_INVALID_PARAMETER); 877 return 0; 837 878 } 838 879 dprintf(("USER32: FindWindowExW (%x,%x) %x %s\n", hwndParent, hwndChildAfter, lpszClass, lpszWindow)); … … 870 911 871 912 if (!hwnd) { 872 873 913 SetLastError(ERROR_INVALID_PARAMETER); 914 return (FALSE); 874 915 } 875 916 wnd = Win32BaseWindow::GetWindowFromHandle (hwnd); 876 917 if (!wnd) { 877 878 918 SetLastError(ERROR_INVALID_WINDOW_HANDLE); 919 return (FALSE); 879 920 } 880 921 … … 887 928 //****************************************************************************** 888 929 //****************************************************************************** 889 HDWP WIN32API BeginDeferWindowPos( int arg1) 890 { 891 #ifdef DEBUG 892 WriteLog("USER32: BeginDeferWindowPos\n"); 930 HDWP WIN32API BeginDeferWindowPos(int count) 931 { 932 HDWP handle; 933 DWP *pDWP; 934 935 dprintf(("USER32: BeginDeferWindowPos\n")); 936 if (count <= 0) 937 { 938 SetLastError(ERROR_INVALID_PARAMETER); 939 return 0; 940 } 941 handle = (HDWP)HeapAlloc(GetProcessHeap(), 0, sizeof(DWP) + (count-1)*sizeof(WINDOWPOS) ); 942 if (!handle) 943 return 0; 944 945 pDWP = (DWP *) handle; 946 pDWP->actualCount = 0; 947 pDWP->suggestedCount = count; 948 pDWP->valid = TRUE; 949 pDWP->wMagic = DWP_MAGIC; 950 pDWP->hwndParent = 0; 951 return handle; 952 } 953 /*********************************************************************** 954 * DeferWindowPos (USER32.128) 955 */ 956 HDWP WIN32API DeferWindowPos( HDWP hdwp, HWND hwnd, HWND hwndAfter, 957 INT x, INT y, INT cx, INT cy, 958 UINT flags ) 959 { 960 DWP *pDWP; 961 int i; 962 HDWP newhdwp = hdwp,retvalue; 963 Win32BaseWindow *window; 964 965 pDWP = (DWP *)hdwp; 966 if (!pDWP) { 967 SetLastError(ERROR_INVALID_PARAMETER); 968 return 0; 969 } 970 971 if (hwnd == GetDesktopWindow()) 972 return 0; 973 974 window = Win32BaseWindow::GetWindowFromHandle(hwnd); 975 if(!window) { 976 dprintf(("DeferWindowPos, window %x not found", hwnd)); 977 SetLastError(ERROR_INVALID_WINDOW_HANDLE); 978 HeapFree(GetProcessHeap(), 0, (LPVOID)hdwp); 979 return 0; 980 } 981 982 983 /* Numega Bounds Checker Demo dislikes the following code. 984 In fact, I've not been able to find any "same parent" requirement in any docu 985 [AM 980509] 986 */ 987 #if 0 988 /* All the windows of a DeferWindowPos() must have the same parent */ 989 parent = pWnd->parent->hwndSelf; 990 if (pDWP->actualCount == 0) pDWP->hwndParent = parent; 991 else if (parent != pDWP->hwndParent) 992 { 993 USER_HEAP_FREE( hdwp ); 994 retvalue = 0; 995 goto END; 996 } 893 997 #endif 894 return O32_BeginDeferWindowPos(arg1); 895 } 896 //****************************************************************************** 897 //****************************************************************************** 898 HDWP WIN32API DeferWindowPos( HDWP arg1, HWND arg2, HWND arg3, int arg4, int arg5, int arg6, int arg7, UINT arg8) 899 { 900 #ifdef DEBUG 901 WriteLog("USER32: DeferWindowPos\n"); 902 #endif 903 return O32_DeferWindowPos(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); 998 999 for (i = 0; i < pDWP->actualCount; i++) 1000 { 1001 if (pDWP->winPos[i].hwnd == hwnd) 1002 { 1003 /* Merge with the other changes */ 1004 if (!(flags & SWP_NOZORDER)) 1005 { 1006 pDWP->winPos[i].hwndInsertAfter = hwndAfter; 1007 } 1008 if (!(flags & SWP_NOMOVE)) 1009 { 1010 pDWP->winPos[i].x = x; 1011 pDWP->winPos[i].y = y; 1012 } 1013 if (!(flags & SWP_NOSIZE)) 1014 { 1015 pDWP->winPos[i].cx = cx; 1016 pDWP->winPos[i].cy = cy; 1017 } 1018 pDWP->winPos[i].flags &= flags | ~(SWP_NOSIZE | SWP_NOMOVE | 1019 SWP_NOZORDER | SWP_NOREDRAW | 1020 SWP_NOACTIVATE | SWP_NOCOPYBITS| 1021 SWP_NOOWNERZORDER); 1022 pDWP->winPos[i].flags |= flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW | 1023 SWP_FRAMECHANGED); 1024 retvalue = hdwp; 1025 goto END; 1026 } 1027 } 1028 if (pDWP->actualCount >= pDWP->suggestedCount) 1029 { 1030 newhdwp = (HDWP)HeapReAlloc(GetProcessHeap(), 0, (LPVOID)hdwp, 1031 sizeof(DWP) + pDWP->suggestedCount*sizeof(WINDOWPOS)); 1032 if (!newhdwp) 1033 { 1034 retvalue = 0; 1035 goto END; 1036 } 1037 pDWP = (DWP *) newhdwp; 1038 pDWP->suggestedCount++; 1039 } 1040 pDWP->winPos[pDWP->actualCount].hwnd = hwnd; 1041 pDWP->winPos[pDWP->actualCount].hwndInsertAfter = hwndAfter; 1042 pDWP->winPos[pDWP->actualCount].x = x; 1043 pDWP->winPos[pDWP->actualCount].y = y; 1044 pDWP->winPos[pDWP->actualCount].cx = cx; 1045 pDWP->winPos[pDWP->actualCount].cy = cy; 1046 pDWP->winPos[pDWP->actualCount].flags = flags; 1047 pDWP->actualCount++; 1048 retvalue = newhdwp; 1049 END: 1050 return retvalue; 1051 } 1052 //****************************************************************************** 1053 //****************************************************************************** 1054 BOOL WIN32API EndDeferWindowPos( HDWP hdwp) 1055 { 1056 DWP *pDWP; 1057 WINDOWPOS *winpos; 1058 BOOL res = TRUE; 1059 int i; 1060 1061 dprintf(("EndDeferWindowPos\n")); 1062 pDWP = (DWP *) hdwp; 1063 if (!pDWP) { 1064 SetLastError(ERROR_INVALID_PARAMETER); 1065 return FALSE; 1066 } 1067 for (i = 0, winpos = pDWP->winPos; i < pDWP->actualCount; i++, winpos++) 1068 { 1069 if (!(res = SetWindowPos(winpos->hwnd, winpos->hwndInsertAfter, 1070 winpos->x, winpos->y, winpos->cx, 1071 winpos->cy, winpos->flags ))) 1072 break; 1073 } 1074 HeapFree(GetProcessHeap(), 0, (LPVOID)hdwp); 1075 return res; 904 1076 } 905 1077 //****************************************************************************** … … 940 1112 if (GetWindowRect (hwndParent, &rect) == 0) { 941 1113 // oops, invalid handle 942 1114 SetLastError(ERROR_INVALID_WINDOW_HANDLE); 943 1115 return NULL; 944 1116 } … … 985 1157 } 986 1158 987 1159 dprintf(("ChildWindowFromPointEx returned %x", hWnd)); 988 1160 // found it! 989 1161 return hWnd; … … 992 1164 // the point is in the parentwindow but the parentwindow has no child 993 1165 // at this coordinate 994 1166 dprintf(("ChildWindowFromPointEx returned parent %x", hwndParent)); 995 1167 return hwndParent; 996 1168 } … … 1004 1176 if(!window) { 1005 1177 dprintf(("CloseWindow, window %x not found", hwnd)); 1006 1178 SetLastError(ERROR_INVALID_WINDOW_HANDLE); 1007 1179 return 0; 1008 1180 } … … 1033 1205 if(!window) { 1034 1206 dprintf(("IsWindowUnicode, window %x not found", hwnd)); 1035 1207 SetLastError(ERROR_INVALID_WINDOW_HANDLE); 1036 1208 return 0; 1037 1209 } … … 1139 1311 if(!parentwindow) { 1140 1312 dprintf(("EnumChildWindows, window %x not found", hwnd)); 1141 1313 SetLastError(ERROR_INVALID_WINDOW_HANDLE); 1142 1314 return FALSE; 1143 1315 }
Note:
See TracChangeset
for help on using the changeset viewer.