Changeset 304 for trunk/src/user32/new/win32class.cpp
- Timestamp:
- Jul 14, 1999, 11:05:59 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/new/win32class.cpp
r300 r304 1 /* $Id: win32class.cpp,v 1. 2 1999-07-14 08:35:36 sandervlExp $ */1 /* $Id: win32class.cpp,v 1.3 1999-07-14 21:05:58 cbratschi Exp $ */ 2 2 /* 3 3 * Win32 Window Class Managment Code for OS/2 … … 23 23 { 24 24 if(HIWORD(wndclass->lpszClassName)) { 25 if(isUnicode) { 26 classNameA = (PCHAR)malloc(lstrlenW((LPWSTR)wndclass->lpszClassName)+1); 27 classNameW = (WCHAR *)malloc((lstrlenW((LPWSTR)wndclass->lpszClassName)+1)*sizeof(WCHAR)); 28 } 29 else { 30 classNameA = (PCHAR)malloc(strlen(wndclass->lpszClassName)+1); 31 classNameW = (WCHAR *)malloc((strlen(wndclass->lpszClassName)+1)*sizeof(WCHAR)); 32 } 33 if(classNameA == NULL || classNameW == NULL) { 34 dprintf(("Win32Class ctr; classNameA/classNameW == NULL")); 35 exit(1); 36 } 37 if(isUnicode) { 38 lstrcpyW(classNameW, (LPWSTR)wndclass->lpszClassName); 39 UnicodeToAscii(classNameW, classNameA); 40 } 41 else { 42 strcpy((char *)classNameA, wndclass->lpszClassName); 43 AsciiToUnicode(classNameA, classNameW); 44 } 45 classAtom = GlobalAddAtomA(classNameA); 25 if(isUnicode) { 26 INT len = lstrlenW((LPWSTR)wndclass->lpszClassName)+1; 27 28 classNameA = (PCHAR)malloc(len); 29 classNameW = (WCHAR *)malloc(len*sizeof(WCHAR)); 30 } 31 else { 32 INT len = strlen(wndclass->lpszClassName)+1; 33 34 classNameA = (PCHAR)malloc(len); 35 classNameW = (WCHAR *)malloc(len*sizeof(WCHAR)); 36 } 37 if(classNameA == NULL || classNameW == NULL) { 38 dprintf(("Win32Class ctr; classNameA/classNameW == NULL")); 39 exit(1); 40 } 41 if(isUnicode) { 42 lstrcpyW(classNameW, (LPWSTR)wndclass->lpszClassName); 43 UnicodeToAscii(classNameW, classNameA); 44 } 45 else { 46 strcpy((char *)classNameA, wndclass->lpszClassName); 47 AsciiToUnicode(classNameA, classNameW); 48 } 49 classAtom = GlobalAddAtomA(classNameA); 46 50 } 47 51 else { 48 classNameA= NULL;49 50 classAtom= (DWORD)wndclass->lpszClassName;52 classNameA = NULL; 53 classNameW = NULL; 54 classAtom = (DWORD)wndclass->lpszClassName; 51 55 } 52 56 this->isUnicode = isUnicode; … … 62 66 dprintf(("USER32: wndclass->hbrBackground %X\n", wndclass->hbrBackground)); 63 67 if(HIWORD(wndclass->lpszClassName)) 64 dprintf(("USER32: wndclass->lpszClassName % X\n", wndclass->lpszClassName));65 else dprintf(("USER32: wndclass->lpszClassName % s\n", wndclass->lpszClassName));68 dprintf(("USER32: wndclass->lpszClassName %s\n", wndclass->lpszClassName)); 69 else dprintf(("USER32: wndclass->lpszClassName %X\n", wndclass->lpszClassName)); 66 70 67 71 if(HIWORD(wndclass->lpszMenuName)) {//convert string name identifier to numeric id … … 70 74 else dprintf(("USER32: wndclass->lpszMenuName %X\n", wndclass->lpszMenuName)); 71 75 72 nrExtraClassWords 73 nrExtraWindowWords 74 backgroundBrush = wndclass->hbrBackground;//TODO: fErase of PAINSTRUCT in WM_PAINT if == NULL75 hCursor 76 hIcon 77 hInstance 76 nrExtraClassWords = wndclass->cbClsExtra; 77 nrExtraWindowWords = wndclass->cbWndExtra; 78 backgroundBrush = wndclass->hbrBackground; //TODO: fErase of PAINSTRUCT in WM_PAINT if == NULL 79 hCursor = wndclass->hCursor; 80 hIcon = wndclass->hIcon; 81 hInstance = wndclass->hInstance; 78 82 79 83 menuNameA = 0; … … 81 85 setMenuName((LPSTR)wndclass->lpszMenuName); 82 86 83 windowStyle 84 windowProc 87 windowStyle = wndclass->style; 88 windowProc = wndclass->lpfnWndProc; 85 89 86 90 //User data class words/longs 87 91 if(nrExtraClassWords) { 88 89 90 91 92 93 94 } 95 else 92 userClassLong = (ULONG *)malloc(nrExtraClassWords); 93 if(userClassLong == NULL) { 94 dprintf(("Win32Class ctr: userClassLong == NULL!")); 95 exit(1); 96 } 97 memset(userClassLong, 0, nrExtraClassWords); 98 } 99 else userClassLong = NULL; 96 100 97 101 cWindows = 0; … … 102 106 Win32WndClass::~Win32WndClass() 103 107 { 104 if(userClassLong) 105 if(classNameA) 106 if(classNameW) 108 if(userClassLong) free(userClassLong); 109 if(classNameA) free(classNameA); 110 if(classNameW) free(classNameW); 107 111 if(menuNameA && HIWORD(menuNameA)) { 108 109 110 112 free(menuNameA); 113 assert(menuNameW); 114 free(menuNameW); 111 115 } 112 116 } … … 117 121 Win32WndClass *wndclass = (Win32WndClass *)wndclasses; 118 122 119 if(wndclass == NULL) 123 if(wndclass == NULL) return(NULL); 120 124 121 125 if(HIWORD(id) != 0) { 122 123 124 125 126 127 128 129 130 131 132 133 126 if(stricmp(wndclass->classNameA, id) == 0 && wndclass->hInstance == hInstance) { 127 return(wndclass); 128 } 129 else { 130 wndclass = (Win32WndClass *)wndclass->GetNext(); 131 while(wndclass != NULL) { 132 if(stricmp(wndclass->classNameA, id) == 0 && wndclass->hInstance == hInstance) { 133 return(wndclass); 134 } 135 wndclass = (Win32WndClass *)wndclass->GetNext(); 136 } 137 } 134 138 } 135 139 else { 136 137 138 139 140 141 142 143 144 145 146 147 140 if(wndclass->classAtom == (DWORD)id && wndclass->hInstance == hInstance) { 141 return(wndclass); 142 } 143 else { 144 wndclass = (Win32WndClass *)wndclass->GetNext(); 145 while(wndclass != NULL) { 146 if(wndclass->classAtom == (DWORD)id && wndclass->hInstance == hInstance) { 147 return(wndclass); 148 } 149 wndclass = (Win32WndClass *)wndclass->GetNext(); 150 } 151 } 148 152 } 149 153 dprintf(("Class %X (inst %X) not found!", id, hInstance)); … … 157 161 wndclass->cbWndExtra = nrExtraWindowWords; 158 162 wndclass->hbrBackground = backgroundBrush; 159 wndclass->hCursor 163 wndclass->hCursor = hCursor; 160 164 wndclass->hIcon = hIcon; 161 165 wndclass->hInstance = hInstance; 162 166 wndclass->lpszMenuName = (LPCTSTR)menuNameA; 163 167 wndclass->lpszClassName = (classNameA) ? (LPCTSTR)classNameA : (LPCTSTR)classAtom; 164 wndclass->style 165 wndclass->lpfnWndProc 166 wndclass->hIconSm 168 wndclass->style = windowStyle; 169 wndclass->lpfnWndProc = windowProc; 170 wndclass->hIconSm = hIconSm; 167 171 return(TRUE); 168 172 } … … 174 178 wndclass->cbWndExtra = nrExtraWindowWords; 175 179 wndclass->hbrBackground = backgroundBrush; 176 wndclass->hCursor 180 wndclass->hCursor = hCursor; 177 181 wndclass->hIcon = hIcon; 178 182 wndclass->hInstance = hInstance; 179 183 wndclass->lpszMenuName = (LPCWSTR)menuNameW; 180 184 wndclass->lpszClassName = (classNameW) ? (LPCWSTR)classNameW : (LPCWSTR)classAtom; 181 wndclass->style 182 wndclass->lpfnWndProc 183 wndclass->hIconSm 185 wndclass->style = windowStyle; 186 wndclass->lpfnWndProc = windowProc; 187 wndclass->hIconSm = hIconSm; 184 188 return(TRUE); 185 189 } … … 189 193 { 190 194 if(HIWORD(classNameA)) { 191 192 195 strncpy(lpszClassName, classNameA, cchClassName-1); 196 return strlen(lpszClassName); 193 197 } 194 198 *(ULONG *)lpszClassName = classAtom; … … 202 206 203 207 if(HIWORD(classNameW)) { 204 205 208 lstrcpyW(lpszClassName, classNameW); 209 return lstrlenW(lpszClassName)*sizeof(WCHAR); 206 210 } 207 211 *(ULONG *)lpszClassName = classAtom; … … 213 217 { 214 218 if(HIWORD(menuNameA)) { 215 216 217 219 free(menuNameA); 220 free(menuNameW); 221 menuNameA = 0; 218 222 menuNameW = 0; 219 223 } 220 224 if(HIWORD(newMenuName)) { 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 225 if(isUnicode) { 226 menuNameA = (PCHAR)malloc(lstrlenW((LPWSTR)newMenuName)+1); 227 menuNameW = (WCHAR *)malloc((lstrlenW((LPWSTR)newMenuName)+1)*sizeof(WCHAR)); 228 } 229 else { 230 menuNameA = (PCHAR)malloc(strlen(newMenuName)+1); 231 menuNameW = (WCHAR *)malloc((strlen(newMenuName)+1)*sizeof(WCHAR)); 232 } 233 if(menuNameA == NULL || menuNameW == NULL) { 234 dprintf(("Win32Class ctr; menuName/menuNameW == NULL")); 235 exit(1); 236 } 237 if(isUnicode) { 238 lstrcpyW(menuNameW, (LPWSTR)newMenuName); 239 UnicodeToAscii(menuNameW, menuNameA); 240 } 241 else { 242 strcpy((char *)menuNameA, newMenuName); 243 AsciiToUnicode(menuNameA, menuNameW); 244 } 241 245 } 242 246 else {//id 243 244 247 menuNameA = (PCHAR)newMenuName; 248 menuNameW = (WCHAR *)newMenuName; 245 249 } 246 250 } … … 250 254 { 251 255 switch(index) { 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 256 case GCL_CBCLSEXTRA: 257 return nrExtraClassWords; 258 case GCL_CBWNDEXTRA: 259 return nrExtraWindowWords; 260 case GCL_HBRBACKGROUND: 261 return backgroundBrush; 262 case GCL_HCURSOR: 263 return hCursor; 264 case GCL_HICON: 265 return hIcon; 266 case GCL_HMODULE: 267 return hInstance; 268 case GCL_MENUNAME: 269 return (isUnicode) ? (ULONG)menuNameW : (ULONG)menuNameA; 270 case GCL_STYLE: 271 return windowStyle; 272 case GCL_WNDPROC: 273 return (ULONG)windowProc; 274 case GCW_ATOM: //TODO: does this really happen in windows? 275 SetLastError(ERROR_INVALID_PARAMETER); 276 return 0; 277 default: 278 if(index > 0 && index < nrExtraClassWords - sizeof(ULONG)) { 279 return userClassLong[index]; 280 } 281 SetLastError(ERROR_INVALID_PARAMETER); 282 return 0; 279 283 } 280 284 } … … 284 288 { 285 289 switch(index) { 286 case GCW_ATOM: 287 288 289 290 291 292 293 290 case GCW_ATOM: 291 return (WORD)classAtom; 292 default: 293 if(index > 0 && index < nrExtraClassWords - sizeof(WORD)) { 294 return ((WORD *)userClassLong)[index]; 295 } 296 SetLastError(ERROR_INVALID_PARAMETER); 297 return 0; 294 298 } 295 299 } … … 302 306 303 307 switch(index) { 304 305 306 // 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 rc = 0;//old value is meaningless (according to Wine)330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 308 case GCL_CBCLSEXTRA: //TODO (doesn't affect allocated classes, so what does it do?) 309 rc = nrExtraClassWords; 310 // nrExtraClassWords = lNewVal; 311 break; 312 case GCL_CBWNDEXTRA: 313 rc = nrExtraWindowWords; 314 nrExtraWindowWords = lNewVal; 315 break; 316 case GCL_HBRBACKGROUND: 317 rc = backgroundBrush; 318 backgroundBrush = lNewVal; 319 break; 320 case GCL_HCURSOR: 321 rc = hCursor; 322 hCursor = lNewVal; 323 break; 324 case GCL_HICON: 325 rc = hIcon; 326 hIcon = lNewVal; 327 break; 328 case GCL_HMODULE: 329 rc = hInstance; 330 hInstance = lNewVal; 331 break; 332 case GCL_MENUNAME: 333 rc = 0; //old value is meaningless (according to Wine) 334 setMenuName((LPSTR)lNewVal); 335 break; 336 case GCL_STYLE: 337 rc = windowStyle; 338 windowStyle = lNewVal; 339 break; 340 case GCL_WNDPROC: 341 rc = (ULONG)windowProc; 342 windowProc = (WNDPROC)lNewVal; 343 break; 344 case GCW_ATOM: //TODO: does this really happen in windows? 345 SetLastError(ERROR_INVALID_PARAMETER); 346 return 0; 347 default: 348 if(index > 0 && index < nrExtraClassWords - sizeof(ULONG)) { 349 rc = userClassLong[index]; 350 userClassLong[index] = lNewVal; 351 return(rc); 352 } 353 SetLastError(ERROR_INVALID_PARAMETER); 354 return 0; 351 355 } 352 356 return(rc); … … 359 363 360 364 switch(index) { 361 case GCW_ATOM: 362 363 364 365 366 367 368 369 370 371 372 365 case GCW_ATOM: 366 rc = (WORD)classAtom; 367 classAtom = wNewVal; 368 return(rc); 369 default: 370 if(index > 0 && index < nrExtraClassWords - sizeof(WORD)) { 371 rc = ((WORD *)userClassLong)[index]; 372 ((WORD *)userClassLong)[index] = wNewVal; 373 return(rc); 374 } 375 SetLastError(ERROR_INVALID_PARAMETER); 376 return 0; 373 377 } 374 378 } … … 383 387 wndclass = FindClass(hinst, id); 384 388 if(wndclass) { 385 386 389 delete wndclass; 390 return; 387 391 } 388 392 dprintf(("::UnregisterClass, couldn't find class %X!!\n", id));
Note:
See TracChangeset
for help on using the changeset viewer.