Changeset 2200 for trunk/src/user32/win32wbase.cpp
- Timestamp:
- Dec 24, 1999, 7:42:46 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/win32wbase.cpp
r2145 r2200 1 /* $Id: win32wbase.cpp,v 1.11 6 1999-12-19 19:55:41sandervl Exp $ */1 /* $Id: win32wbase.cpp,v 1.117 1999-12-24 18:39:12 sandervl Exp $ */ 2 2 /* 3 3 * Win32 Window Base Class for OS/2 … … 778 778 { 779 779 if(SendInternalMessageA(WM_CLOSE, 0, 0) == 0) { 780 dprintf(("Win32BaseWindow::MsgClose, app handles msg"));780 dprintf(("Win32BaseWindow::MsgClose, app handles msg")); 781 781 return 0; //app handles this message 782 782 } … … 872 872 //****************************************************************************** 873 873 //****************************************************************************** 874 ULONG Win32BaseWindow::MsgMove(ULONG x, ULONG y)875 {876 dprintf(("MsgMove to (%d,%d)", x, y));877 if(fNoSizeMsg || (getParent() && getParent()->InMovingChildren()))878 return 1;879 880 return SendInternalMessageA(WM_MOVE, 0, MAKELONG((USHORT)x, (USHORT)y));881 }882 //******************************************************************************883 //******************************************************************************884 874 #if 0 885 875 ULONG Win32BaseWindow::MsgMinMax() … … 888 878 } 889 879 #endif 890 //******************************************************************************891 //******************************************************************************892 ULONG Win32BaseWindow::MsgTimer(ULONG TimerID)893 {894 // TODO: call TIMERPROC if not NULL895 return SendInternalMessageA(WM_TIMER, TimerID, 0);896 }897 //******************************************************************************898 //******************************************************************************899 ULONG Win32BaseWindow::MsgSysTimer(ULONG TimerID)900 {901 // TODO: call TIMERPROC if not NULL902 return SendInternalMessageA(WM_SYSTIMER, TimerID, 0);903 }904 880 //****************************************************************************** 905 881 //****************************************************************************** … … 912 888 //****************************************************************************** 913 889 //****************************************************************************** 914 ULONG Win32BaseWindow::MsgCommand(ULONG cmd, ULONG Id, HWND hwnd) 915 { 916 switch(cmd) { 917 case CMD_MENU: 918 return SendInternalMessageA(WM_COMMAND, MAKELONG(Id, 0), 0); 919 case CMD_CONTROL: 920 return 0; //todo 921 case CMD_ACCELERATOR: 922 // this fit not really windows behavior. 923 // maybe TranslateAccelerator() is better 924 dprintf(("accelerator command")); 925 return SendInternalMessageA(WM_COMMAND, MAKELONG(Id, 0), 0); 926 } 927 return 0; 928 } 929 //****************************************************************************** 930 //****************************************************************************** 931 ULONG Win32BaseWindow::MsgHitTest(ULONG x, ULONG y) 932 { 933 lastHitTestVal = SendInternalMessageA(WM_NCHITTEST, 0, MAKELONG((USHORT)x, (USHORT)y)); 934 dprintf(("MsgHitTest returned %x", lastHitTestVal)); 890 ULONG Win32BaseWindow::MsgHitTest(MSG *msg) 891 { 892 lastHitTestVal = SendInternalMessageA(WM_NCHITTEST, 0, MAKELONG((USHORT)msg->pt.x, (USHORT)msg->pt.y)); 893 dprintf2(("MsgHitTest returned %x", lastHitTestVal)); 935 894 return 1; //TODO: May need to change this 936 }937 //******************************************************************************938 //TODO: Send WM_NCCALCSIZE message here and correct size if necessary939 //******************************************************************************940 ULONG Win32BaseWindow::MsgSize(ULONG width, ULONG height, BOOL fMinimize, BOOL fMaximize)941 {942 WORD fwSizeType = 0;943 944 dwStyle &= ~(WS_MINIMIZE|WS_MAXIMIZE);945 if(fMinimize) {946 fwSizeType = SIZE_MINIMIZED;947 dwStyle |= WS_MINIMIZE;948 }949 else950 if(fMaximize) {951 fwSizeType = SIZE_MAXIMIZED;952 dwStyle |= WS_MAXIMIZE;953 }954 else fwSizeType = SIZE_RESTORED;955 956 return SendInternalMessageA(WM_SIZE, fwSizeType, MAKELONG((USHORT)width, (USHORT)height));957 895 } 958 896 //****************************************************************************** … … 981 919 } 982 920 return rc; 983 }984 //******************************************************************************985 //******************************************************************************986 ULONG Win32BaseWindow::MsgSysCommand(ULONG win32sc, ULONG x, ULONG y)987 {988 return SendInternalMessageA(WM_SYSCOMMAND, win32sc, MAKELONG((USHORT)x, (USHORT)y));989 921 } 990 922 //****************************************************************************** … … 1011 943 } 1012 944 //****************************************************************************** 1013 //TODO: virtual key & (possibly) scancode translation, extended keyboard bit & Unicode 1014 //****************************************************************************** 1015 ULONG Win32BaseWindow::MsgChar(ULONG cmd, ULONG repeatcnt, ULONG scancode, ULONG vkey, ULONG keyflags) 1016 { 1017 ULONG lParam = 0; 1018 1019 lParam = repeatcnt; 1020 lParam |= (scancode << 16); 1021 setExtendedKey(vkey, &lParam); 1022 1023 if(keyflags & KEY_ALTDOWN) 1024 lParam |= (1<<29); 1025 if(keyflags & KEY_PREVDOWN) 1026 lParam |= (1<<30); 1027 if(keyflags & KEY_UP) 1028 lParam |= (1<<31); 1029 if(keyflags & KEY_DEADKEY) { 1030 dprintf(("WM_DEADCHAR: %x %x %08x", OS2Hwnd, cmd, lParam)); 1031 return SendInternalMessageA(WM_DEADCHAR, cmd, lParam); 1032 } 1033 else { 1034 dprintf(("WM_CHAR: %x %x %08x", OS2Hwnd, cmd, lParam)); 1035 return SendInternalMessageA(WM_CHAR, cmd, lParam); 1036 } 1037 } 1038 //****************************************************************************** 1039 //****************************************************************************** 1040 ULONG Win32BaseWindow::MsgKeyUp (ULONG repeatCount, ULONG scancode, ULONG virtualKey) 1041 { 1042 ULONG lParam=0; 1043 1044 lParam = repeatCount & 0x0FFFF; // bit 0-15, repeatcount 1045 lParam |= (scancode & 0x0FF) << 16; // bit 16-23, scancode 1046 // bit 24, 1=extended key 1047 // bit 25-28, reserved 1048 lParam |= 0 << 29; // bit 29, key is released, always 0 for WM_KEYUP ?? <- conflict according to the MS docs 1049 lParam |= 1 << 30; // bit 30, previous state, always 1 for a WM_KEYUP message 1050 lParam |= 1 << 31; // bit 31, transition state, always 1 for WM_KEYUP 1051 1052 dprintf(("WM_KEYUP: vkey:(%x) param:(%x)", virtualKey, lParam)); 1053 1054 setExtendedKey(virtualKey, &lParam); 1055 return SendInternalMessageA (WM_KEYUP, virtualKey, lParam); 1056 } 1057 //****************************************************************************** 1058 //****************************************************************************** 1059 ULONG Win32BaseWindow::MsgKeyDown (ULONG repeatCount, ULONG scancode, ULONG virtualKey, BOOL keyWasPressed) 1060 { 1061 ULONG lParam=0; 1062 1063 lParam = repeatCount & 0x0FFFF; // bit 0-15, repeatcount 1064 lParam |= (scancode & 0x0FF) << 16; // bit 16-23, scancode 1065 // bit 24, 1=extended key 1066 // bit 25-28, reserved 1067 // bit 29, key is pressed, always 0 for WM_KEYDOWN ?? <- conflict according to the MS docs 1068 if (keyWasPressed) 1069 lParam |= 1 << 30; // bit 30, previous state, 1 means key was pressed 1070 // bit 31, transition state, always 0 for WM_KEYDOWN 1071 1072 setExtendedKey(virtualKey, &lParam); 1073 1074 dprintf(("WM_KEYDOWN: vkey:(%x) param:(%x)", virtualKey, lParam)); 1075 1076 return SendInternalMessageA (WM_KEYDOWN, virtualKey, lParam); 1077 } 1078 //****************************************************************************** 1079 //****************************************************************************** 1080 ULONG Win32BaseWindow::MsgSysKeyUp (ULONG repeatCount, ULONG scancode, ULONG virtualKey) 1081 { 1082 ULONG lParam=0; 1083 1084 lParam = repeatCount & 0x0FFFF; // bit 0-15,repeatcount 1085 lParam |= (scancode & 0x0FF) << 16; // bit 16-23, scancode 1086 // bit 24, 1=extended key 1087 // bit 25-28, reserved 1088 lParam |= 0 << 29; // bit 29, key is released, always 1 for WM_SYSKEYUP ?? <- conflict according to the MS docs 1089 lParam |= 1 << 30; // bit 30, previous state, always 1 for a WM_KEYUP message 1090 lParam |= 1 << 31; // bit 31, transition state, always 1 for WM_KEYUP 1091 1092 setExtendedKey(virtualKey, &lParam); 1093 dprintf(("WM_SYSKEYUP: vkey:(%x) param:(%x)", virtualKey, lParam)); 1094 1095 return SendInternalMessageA (WM_SYSKEYUP, virtualKey, lParam); 1096 } 1097 //****************************************************************************** 1098 //****************************************************************************** 1099 ULONG Win32BaseWindow::MsgSysKeyDown (ULONG repeatCount, ULONG scancode, ULONG virtualKey, BOOL keyWasPressed) 1100 { 1101 ULONG lParam=0; 1102 1103 lParam = repeatCount & 0x0FFFF; // bit 0-15, repeatcount 1104 lParam |= (scancode & 0x0FF) << 16; // bit 16-23, scancode 1105 // bit 24, 1=extended key 1106 // bit 25-28, reserved 1107 // bit 29, key is released, always 1 for WM_SYSKEYUP ?? <- conflict according to the MS docs 1108 if (keyWasPressed) 1109 lParam |= 1 << 30; // bit 30, previous state, 1 means key was pressed 1110 // bit 31, transition state, always 0 for WM_KEYDOWN 1111 1112 setExtendedKey(virtualKey, &lParam); 1113 dprintf(("WM_SYSKEYDOWN: vkey:(%x) param:(%x)", virtualKey, lParam)); 1114 1115 return SendInternalMessageA (WM_SYSKEYDOWN, virtualKey, lParam); 945 //****************************************************************************** 946 ULONG Win32BaseWindow::DispatchMsg(MSG *msg) 947 { 948 return SendInternalMessageA(msg->message, msg->wParam, msg->lParam); 1116 949 } 1117 950 //****************************************************************************** … … 1129 962 //****************************************************************************** 1130 963 //****************************************************************************** 1131 ULONG Win32BaseWindow::MsgButton(ULONG msg, ULONG ncx, ULONG ncy, ULONG clx, ULONG cly) 1132 { 1133 ULONG win32msg; 1134 ULONG win32ncmsg; 964 ULONG Win32BaseWindow::MsgButton(MSG *msg) 965 { 1135 966 BOOL fClick = FALSE; 1136 967 1137 if(ISMOUSE_CAPTURED()) { 1138 if(DInputMouseHandler(getWindowHandle(), MOUSEMSG_BUTTON, ncx, ncy, msg)) 1139 return 0; 1140 } 1141 1142 dprintf(("MsgButton to (%d,%d)", ncx, ncy)); 1143 switch(msg) { 1144 case BUTTON_LEFTDOWN: 1145 win32msg = WM_LBUTTONDOWN; 1146 win32ncmsg = WM_NCLBUTTONDOWN; 968 dprintf(("MsgButton at (%d,%d)", msg->pt.x, msg->pt.y)); 969 switch(msg->message) { //TODO: double click also? 970 case WM_LBUTTONDBLCLK: 971 case WM_RBUTTONDBLCLK: 972 case WM_MBUTTONDBLCLK: 973 if (!(windowClass && windowClass->getClassLongA(GCL_STYLE) & CS_DBLCLKS)) 974 { 975 msg->message = msg->message - (WM_LBUTTONDBLCLK - WM_LBUTTONDOWN); //dblclick -> down 976 MsgButton(msg); 977 return MsgButton(msg); 978 } 979 break; 980 case WM_LBUTTONDOWN: 981 case WM_RBUTTONDOWN: 982 case WM_MBUTTONDOWN: 1147 983 fClick = TRUE; 1148 984 break; 1149 case BUTTON_LEFTUP: 1150 win32msg = WM_LBUTTONUP; 1151 win32ncmsg = WM_NCLBUTTONUP; 1152 break; 1153 case BUTTON_LEFTDBLCLICK: 1154 if (windowClass && windowClass->getClassLongA(GCL_STYLE) & CS_DBLCLKS) 1155 { 1156 win32msg = WM_LBUTTONDBLCLK; 1157 win32ncmsg = WM_NCLBUTTONDBLCLK; 1158 } else 1159 { 1160 MsgButton(BUTTON_LEFTDOWN,ncx,ncy,clx,cly); 1161 return MsgButton(BUTTON_LEFTUP,ncx,ncy,clx,cly); 1162 } 1163 break; 1164 case BUTTON_RIGHTUP: 1165 win32msg = WM_RBUTTONUP; 1166 win32ncmsg = WM_NCRBUTTONUP; 1167 break; 1168 case BUTTON_RIGHTDOWN: 1169 win32msg = WM_RBUTTONDOWN; 1170 win32ncmsg = WM_NCRBUTTONDOWN; 1171 fClick = TRUE; 1172 break; 1173 case BUTTON_RIGHTDBLCLICK: 1174 if (windowClass && windowClass->getClassLongA(GCL_STYLE) & CS_DBLCLKS) 1175 { 1176 win32msg = WM_RBUTTONDBLCLK; 1177 win32ncmsg = WM_NCRBUTTONDBLCLK; 1178 } else 1179 { 1180 MsgButton(BUTTON_RIGHTDOWN,ncx,ncy,clx,cly); 1181 return MsgButton(BUTTON_RIGHTUP,ncx,ncy,clx,cly); 1182 } 1183 break; 1184 case BUTTON_MIDDLEUP: 1185 win32msg = WM_MBUTTONUP; 1186 win32ncmsg = WM_NCMBUTTONUP; 1187 break; 1188 case BUTTON_MIDDLEDOWN: 1189 win32msg = WM_MBUTTONDOWN; 1190 win32ncmsg = WM_NCMBUTTONDOWN; 1191 fClick = TRUE; 1192 break; 1193 case BUTTON_MIDDLEDBLCLICK: 1194 if (windowClass && windowClass->getClassLongA(GCL_STYLE) & CS_DBLCLKS) 1195 { 1196 win32msg = WM_MBUTTONDBLCLK; 1197 win32ncmsg = WM_NCMBUTTONDBLCLK; 1198 } else 1199 { 1200 MsgButton(BUTTON_MIDDLEDOWN,ncx,ncy,clx,cly); 1201 return MsgButton(BUTTON_MIDDLEUP,ncx,ncy,clx,cly); 1202 } 1203 break; 1204 default: 1205 dprintf(("Win32BaseWindow::Button: invalid msg!!!!")); 1206 return 1; 985 } 986 987 if(ISMOUSE_CAPTURED()) 988 { 989 if(DInputMouseHandler(getWindowHandle(), MOUSEMSG_BUTTON, msg->pt.x, msg->pt.y)) 990 return 0; 1207 991 } 1208 992 … … 1224 1008 { 1225 1009 LONG ret = SendInternalMessageA(WM_MOUSEACTIVATE, hwndTop, 1226 MAKELONG( HTCLIENT, win32msg) );1010 MAKELONG( HTCLIENT, msg->message) ); 1227 1011 1228 1012 #if 0 … … 1238 1022 } 1239 1023 1240 SendInternalMessageA(WM_SETCURSOR, Win32Hwnd, MAKELONG(lastHitTestVal, win32ncmsg)); 1241 1242 //WM_NC*BUTTON* is posted when the cursor is in a non-client area of the window 1243 if(lastHitTestVal != HTCLIENT) { 1244 return SendInternalMessageA(win32ncmsg, lastHitTestVal, MAKELONG(ncx, ncy)); //TODO: 1245 } 1246 return SendInternalMessageA(win32msg, 0, MAKELONG(clx, cly)); 1247 } 1248 //****************************************************************************** 1249 //****************************************************************************** 1250 ULONG Win32BaseWindow::MsgMouseMove(ULONG keystate, ULONG x, ULONG y) 1251 { 1252 ULONG winstate = 0; 1253 ULONG setcursormsg = WM_MOUSEMOVE; 1254 1255 if(ISMOUSE_CAPTURED()) { 1256 POINT point = {x,y}; 1257 1258 MapWindowPoints(getWindowHandle(), HWND_DESKTOP, &point, 1); 1259 if(DInputMouseHandler(getWindowHandle(), MOUSEMSG_MOVE, point.x, point.y, keystate)) 1260 return 0; 1261 } 1262 1263 if(keystate & WMMOVE_LBUTTON) 1264 winstate |= MK_LBUTTON; 1265 if(keystate & WMMOVE_RBUTTON) 1266 winstate |= MK_RBUTTON; 1267 if(keystate & WMMOVE_MBUTTON) 1268 winstate |= MK_MBUTTON; 1269 if(keystate & WMMOVE_SHIFT) 1270 winstate |= MK_SHIFT; 1271 if(keystate & WMMOVE_CTRL) 1272 winstate |= MK_CONTROL; 1273 1274 if(lastHitTestVal != HTCLIENT) { 1275 setcursormsg = WM_NCMOUSEMOVE; 1276 } 1277 //TODO: hiword should be 0 if window enters menu mode (SDK docs) 1278 SendInternalMessageA(WM_SETCURSOR, Win32Hwnd, MAKELONG(lastHitTestVal, setcursormsg)); 1279 1280 //WM_NCMOUSEMOVE is posted when the cursor moves into a non-client area of the window 1281 if(lastHitTestVal != HTCLIENT) { 1282 SendInternalMessageA(WM_NCMOUSEMOVE, lastHitTestVal, MAKELONG(x, y)); 1283 } 1284 return SendInternalMessageA(WM_MOUSEMOVE, winstate, MAKELONG(x, y)); 1285 } 1286 //****************************************************************************** 1287 //TODO: Depending on menu type, we should send WM_INITMENU or WM_INITPOPUPMENU 1288 //TODO: PM sends it for each submenu that gets activated; Windows only for the first 1289 // submenu; once the menu bar is active, moving the cursor doesn't generate other 1290 // WM_INITMENU msgs. Not really a problem, but might need to fix this later on. 1291 //****************************************************************************** 1292 void Win32BaseWindow::MsgInitMenu(HWND hMenu) 1293 { 1294 SendInternalMessageA(WM_INITMENU, (WPARAM)hMenu, 0); 1024 SendInternalMessageA(WM_SETCURSOR, getWindowHandle(), MAKELONG(lastHitTestVal, msg->message)); 1025 1026 return SendInternalMessageA(msg->message, msg->wParam, msg->lParam); 1295 1027 } 1296 1028 //****************************************************************************** … … 1322 1054 O32_ReleaseDC(OS2Hwnd, hdcErase); 1323 1055 return (rc); 1056 } 1057 //****************************************************************************** 1058 //****************************************************************************** 1059 ULONG Win32BaseWindow::MsgMouseMove(MSG *msg) 1060 { 1061 if(ISMOUSE_CAPTURED()) { 1062 if(DInputMouseHandler(getWindowHandle(), MOUSEMSG_MOVE, msg->pt.x, msg->pt.y)) 1063 return 0; 1064 } 1065 1066 //TODO: hiword should be 0 if window enters menu mode (SDK docs) 1067 SendInternalMessageA(WM_SETCURSOR, Win32Hwnd, MAKELONG(lastHitTestVal, msg->message)); 1068 1069 //translated message == WM_(NC)MOUSEMOVE 1070 return SendInternalMessageA(msg->message, msg->wParam, msg->lParam); 1071 } 1072 //****************************************************************************** 1073 //TODO: Depending on menu type, we should send WM_INITMENU or WM_INITPOPUPMENU 1074 //TODO: PM sends it for each submenu that gets activated; Windows only for the first 1075 // submenu; once the menu bar is active, moving the cursor doesn't generate other 1076 // WM_INITMENU msgs. Not really a problem, but might need to fix this later on. 1077 //****************************************************************************** 1078 ULONG Win32BaseWindow::MsgInitMenu(MSG *msg) 1079 { 1080 return SendInternalMessageA(msg->message, msg->wParam, msg->lParam); 1081 } 1082 //****************************************************************************** 1083 //****************************************************************************** 1084 ULONG Win32BaseWindow::MsgNCPaint() 1085 { 1086 return SendInternalMessageA(WM_PAINT, 0, 0); 1324 1087 } 1325 1088 //****************************************************************************** … … 1604 1367 { 1605 1368 case WM_CLOSE: 1369 dprintf(("DefWindowProcA: WM_CLOSE %x", getWindowHandle())); 1606 1370 DestroyWindow(); 1607 1371 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.