Changeset 9866 for trunk/src/user32/oslibwin.cpp
- Timestamp:
- Feb 27, 2003, 3:22:45 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/oslibwin.cpp
r9810 r9866 1 /* $Id: oslibwin.cpp,v 1.1 39 2003-02-16 15:31:10sandervl Exp $ */1 /* $Id: oslibwin.cpp,v 1.140 2003-02-27 14:22:42 sandervl Exp $ */ 2 2 /* 3 3 * Window API wrappers for OS/2 … … 567 567 return WinWindowFromPoint((hwnd == OSLIB_HWND_DESKTOP) ? HWND_DESKTOP : hwnd, (PPOINTL)ppoint, TRUE); 568 568 } 569 570 //****************************************************************************** 571 //@PF This is exactly that weird message PM sends when we maximize window from 572 //icon - this coordinates NEVER surface later and this combination of SWP 573 //commands is useless, yet it starts the correct reaction of maximiztion from 574 //icon state 575 //****************************************************************************** 576 BOOL OSLibWinRestoreWindow(HWND hwnd) 577 { 578 BOOL rc = WinSetWindowPos(hwnd, 0, -32000, 32000, 32000, 32000 , SWP_MAXIMIZE | SWP_RESTORE | SWP_ACTIVATE); 579 return (rc); 580 } 581 569 582 //****************************************************************************** 570 583 //****************************************************************************** … … 972 985 //****************************************************************************** 973 986 //****************************************************************************** 987 //PF: PM Logic approved by numerous testcases shows this: 988 //There is no other way to tweak FID_MINMAX without deleting it 989 //Controls are created with size 0,0, invisible and should be immediately 990 //positioned. MINMAX control can't function properly without FID_SYSMENU 991 //control if it is present, so we need to recreate BOTH controls. 992 //Currently OSLibSetWindowStyle checks for changes and actually do the job 993 //only when it is needed so no additional messages are generated. 994 //TO-DO: There MAY BE some regressions here but I haven't seen them 995 //and yes this code is the only way to do WinCreateFrame controls, 996 //first delete old then create new - all other variants create new and 997 //leave old, WinCreateFrameControls can't tweak anything. 998 974 999 void OSLibSetWindowStyle(HWND hwndFrame, HWND hwndClient, ULONG dwStyle, 975 ULONG dwExStyle )1000 ULONG dwExStyle, ULONG dwOldWindowsStyle) 976 1001 { 977 1002 ULONG dwWinStyle; 978 1003 ULONG dwOldWinStyle; 979 1004 980 //client window: 981 dwWinStyle = WinQueryWindowULong(hwndClient, QWL_STYLE); 982 dwOldWinStyle = dwWinStyle; 983 984 if(dwStyle & WS_CLIPCHILDREN_W) { 985 dwWinStyle |= WS_CLIPCHILDREN; 986 } 987 else dwWinStyle &= ~WS_CLIPCHILDREN; 988 989 if(dwWinStyle != dwOldWinStyle) { 990 WinSetWindowULong(hwndClient, QWL_STYLE, dwWinStyle); 1005 int checksum, checksum2; 1006 DWORD dest_tid, dest_pid; 1007 1008 static int minmaxwidth = 0; 1009 static int minmaxheight = 0; 1010 1011 1012 //PF We can tweak OS/2 controls ONLY from thread that created them 1013 //in other case heavy PM lockups will follow 1014 1015 dest_tid = GetWindowThreadProcessId(OS2ToWin32Handle(hwndClient) , &dest_pid ); 1016 1017 if (dest_tid != GetCurrentThreadId()) 1018 { 1019 dprintf(("OSLibSetWindowStyle: Redirecting Change Frame controls to another thread")); 1020 WinSendMsg(hwndFrame, WIN32APP_CHNGEFRAMECTRLS, (MPARAM)dwStyle, (MPARAM)dwOldWindowsStyle); 1021 return; 1022 } 1023 if(minmaxwidth == 0) { 1024 minmaxwidth = WinQuerySysValue(HWND_DESKTOP, SV_CXMINMAXBUTTON); 1025 minmaxheight = WinQuerySysValue(HWND_DESKTOP, SV_CYMINMAXBUTTON); 1026 } 1027 1028 if (hwndClient) 1029 { 1030 //client window: 1031 dwWinStyle = WinQueryWindowULong(hwndClient, QWL_STYLE); 1032 dwOldWinStyle = dwWinStyle; 1033 1034 if(dwStyle & WS_CLIPCHILDREN_W) { 1035 dwWinStyle |= WS_CLIPCHILDREN; 1036 } 1037 else dwWinStyle &= ~WS_CLIPCHILDREN; 1038 1039 if(dwWinStyle != dwOldWinStyle) { 1040 WinSetWindowULong(hwndClient, QWL_STYLE, dwWinStyle); 1041 } 991 1042 } 992 1043 … … 994 1045 dwWinStyle = WinQueryWindowULong(hwndFrame, QWL_STYLE); 995 1046 dwOldWinStyle = dwWinStyle; 1047 1048 checksum = (dwOldWindowsStyle & WS_MINIMIZEBOX_W) + (dwOldWindowsStyle & WS_MAXIMIZEBOX_W) + (dwOldWindowsStyle & WS_SYSMENU_W); 1049 checksum2 = (dwStyle & WS_MINIMIZEBOX_W) + (dwStyle & WS_MAXIMIZEBOX_W) + (dwStyle & WS_SYSMENU_W); 1050 996 1051 if(dwStyle & WS_DISABLED_W) { 997 1052 dwWinStyle |= WS_DISABLED; … … 1017 1072 dwWinStyle |= WS_MAXIMIZED; 1018 1073 } 1019 else dwWinStyle &= ~WS_MAXIMIZED; 1020 1021 if(dwWinStyle != dwOldWinStyle) { 1022 WinSetWindowULong(hwndFrame, QWL_STYLE, dwWinStyle); 1023 } 1074 else 1075 dwWinStyle &= ~WS_MAXIMIZED; 1076 1024 1077 if(fOS2Look) { 1025 1078 ULONG OSFrameStyle = 0; 1079 SWP rc1,rc2,rc3; 1080 int totalwidth = 0; 1081 1026 1082 if((dwStyle & WS_CAPTION_W) == WS_CAPTION_W) 1027 1083 { … … 1029 1085 OSFrameStyle = FCF_TITLEBAR; 1030 1086 } 1031 1087 else 1088 WinQueryWindowPos(WinWindowFromID(hwndFrame, FID_TITLEBAR), &rc1); 1089 1032 1090 if((dwStyle & WS_SYSMENU_W) && !(dwExStyle & WS_EX_TOOLWINDOW_W)) 1033 1091 { 1034 if(WinWindowFromID(hwndFrame, FID_SYSMENU) == 0) { 1035 OSFrameStyle |= FCF_SYSMENU; 1036 } 1092 if(WinWindowFromID(hwndFrame, FID_SYSMENU) == 0) 1093 OSFrameStyle |= FCF_SYSMENU; 1037 1094 } 1038 1039 if((dwStyle & WS_MINIMIZEBOX_W) || (dwStyle & WS_MAXIMIZEBOX_W)) 1095 WinQueryWindowPos(WinWindowFromID(hwndFrame, FID_SYSMENU), &rc2); 1096 WinQueryWindowPos(WinWindowFromID(hwndFrame, FID_MINMAX), &rc3); 1097 1098 if (checksum != checksum2) 1040 1099 { 1041 HWND hwndMinMax = WinWindowFromID(hwndFrame, FID_MINMAX); 1042 if(dwStyle & WS_MINIMIZEBOX_W) { 1043 if(hwndMinMax == 0) { 1044 OSFrameStyle |= FCF_MINBUTTON; 1045 } 1046 else { 1047 if(WinIsMenuItemValid(hwndMinMax, SC_MINIMIZE) == FALSE) { 1048 //recreate mimize button 1049 //TODO: this method doesn't work (hang during destruction probably) 1050 // OSFrameStyle |= FCF_MINBUTTON; 1051 } 1052 } 1053 } 1054 else 1055 if(hwndMinMax) { 1056 WinSendMsg(hwndMinMax, MM_REMOVEITEM, MPFROM2SHORT(SC_MINIMIZE, TRUE), NULL); 1057 } 1058 1059 if(dwStyle & WS_MAXIMIZEBOX_W) { 1060 if(hwndMinMax == 0) { 1061 OSFrameStyle |= FCF_MAXBUTTON; 1062 } 1063 else { 1064 if(WinIsMenuItemValid(hwndMinMax, SC_MAXIMIZE) == FALSE) { 1065 //recreate maximize button 1066 //TODO: this method doesn't work (hang during destruction probably) 1067 // OSFrameStyle |= FCF_MAXBUTTON; 1068 } 1069 } 1070 } 1071 else 1072 if(hwndMinMax) { 1073 WinSendMsg(hwndMinMax, MM_REMOVEITEM, MPFROM2SHORT(SC_MAXIMIZE, TRUE), NULL); 1074 } 1075 } 1076 else 1077 if(dwStyle & WS_SYSMENU_W) { 1078 if(WinWindowFromID(hwndFrame, FID_MINMAX) == 0) { 1079 OSFrameStyle |= FCF_CLOSEBUTTON; 1080 } 1100 dprintf(("OSLibSetWindowStyle: Min/Max/Close state changed. Creating:")); 1101 if(dwStyle & WS_MINIMIZEBOX_W) 1102 { 1103 OSFrameStyle |= FCF_MINBUTTON; 1104 totalwidth += minmaxwidth/2; 1105 dprintf(("min button")); 1106 } 1107 1108 if(dwStyle & WS_MAXIMIZEBOX_W) 1109 { 1110 OSFrameStyle |= FCF_MAXBUTTON; 1111 totalwidth += minmaxwidth/2; 1112 dprintf(("max button")); 1113 } 1114 1115 if(dwStyle & WS_SYSMENU_W) 1116 { 1117 OSFrameStyle |= FCF_CLOSEBUTTON; 1118 OSFrameStyle |= FCF_SYSMENU; 1119 totalwidth += minmaxwidth/2; 1120 dprintf(("close button")); 1121 } 1081 1122 } 1082 1123 } 1083 // no caption, delete all controls if they exist1084 1124 else 1085 1125 { 1086 1126 if (WinWindowFromID(hwndFrame, FID_TITLEBAR)) 1087 1127 WinDestroyWindow(WinWindowFromID(hwndFrame, FID_TITLEBAR)); 1088 if (WinWindowFromID(hwndFrame, FID_SYSMENU))1089 WinDestroyWindow(WinWindowFromID(hwndFrame, FID_SYSMENU));1090 if (WinWindowFromID(hwndFrame, FID_MINMAX))1091 WinDestroyWindow(WinWindowFromID(hwndFrame, FID_MINMAX));1092 1128 } 1093 1129 1130 if (checksum != checksum2) 1131 { 1132 if (WinWindowFromID(hwndFrame, FID_SYSMENU)) 1133 WinDestroyWindow(WinWindowFromID(hwndFrame, FID_SYSMENU)); 1134 if (WinWindowFromID(hwndFrame, FID_MINMAX)) 1135 WinDestroyWindow(WinWindowFromID(hwndFrame, FID_MINMAX)); 1136 } 1137 1094 1138 if(OSFrameStyle) { 1095 1139 FRAMECDATA FCData = {sizeof (FRAMECDATA), 0, 0, 0}; 1096 1140 char buffer[255]; 1141 dprintf(("Controls will be created %x",OSFrameStyle)); 1097 1142 FCData.flCreateFlags = OSFrameStyle; 1098 1143 1099 1144 GetWindowTextA(OS2ToWin32Handle(hwndClient), buffer, sizeof(buffer)); 1100 1145 WinCreateFrameControls(hwndFrame, &FCData, buffer ); 1146 1147 if (totalwidth != rc3.cx) 1148 { 1149 rc3.cx = totalwidth; 1150 totalwidth = rc3.cx - totalwidth; 1151 rc1.cx = rc1.cx + totalwidth; 1152 rc3.x = rc3.x + totalwidth; 1153 } 1154 1155 WinSetWindowPos(WinWindowFromID(hwndFrame, FID_MINMAX),0,rc3.x,rc3.y,rc3.cx,rc3.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW); 1156 WinSetWindowPos(WinWindowFromID(hwndFrame, FID_SYSMENU),0,rc2.x,rc2.y,rc2.cx,rc2.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW); 1157 WinSetWindowPos(WinWindowFromID(hwndFrame, FID_TITLEBAR),0,rc1.x,rc1.y,rc1.cx,rc1.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW); 1101 1158 1102 1159 if (WinQueryActiveWindow(HWND_DESKTOP) == hwndFrame) … … 1105 1162 } 1106 1163 } // os2look 1164 1165 if(dwWinStyle != dwOldWinStyle) { 1166 dprintf(("Setting new window U long")); 1167 WinSetWindowULong(hwndFrame, QWL_STYLE, dwWinStyle); 1168 } 1169 1107 1170 } 1108 1171 //******************************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.