1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 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 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 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 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 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 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 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 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 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 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 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 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 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 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 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 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348
|
/*
* Window classes functions
*
* Copyright 1993, 1996 Alexandre Julliard
* 1998 Juergen Schmied (jsch)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* FIXME: In win32 all classes are local. They are registered at
* program start. Processes CANNOT share classes. (Source: some
* win31->NT migration book)
*
* FIXME: There seems to be a general problem with hInstance in WINE
* classes are getting registered with wrong hInstance.
*/
#include "config.h"
#include "wine/port.h"
#include <stdlib.h>
#include <string.h>
#include "wine/winbase16.h"
#include "winerror.h"
#include "windef.h"
#include "wingdi.h"
#include "wine/winuser16.h"
#include "wine/unicode.h"
#include "win.h"
#include "user.h"
#include "controls.h"
#include "dce.h"
#include "winproc.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(class);
typedef struct tagCLASS
{
struct tagCLASS *next; /* Next class */
struct tagCLASS *prev; /* Prev class */
UINT cWindows; /* Count of existing windows */
UINT style; /* Class style */
HWINDOWPROC winprocA; /* Window procedure (ASCII) */
HWINDOWPROC winprocW; /* Window procedure (Unicode) */
INT cbClsExtra; /* Class extra bytes */
INT cbWndExtra; /* Window extra bytes */
LPWSTR menuName; /* Default menu name (Unicode followed by ASCII) */
SEGPTR segMenuName; /* Default menu name as SEGPTR */
struct tagDCE *dce; /* Class DCE (if CS_CLASSDC) */
HINSTANCE hInstance; /* Module that created the task */
HICON hIcon; /* Default icon */
HICON hIconSm; /* Default small icon */
HCURSOR hCursor; /* Default cursor */
HBRUSH hbrBackground; /* Default background */
ATOM atomName; /* Name of the class */
} CLASS;
static CLASS *firstClass;
/***********************************************************************
* get_class_ptr
*/
static CLASS *get_class_ptr( HWND hwnd, BOOL write_access )
{
WND *ptr = WIN_GetPtr( hwnd );
if (ptr)
{
if (ptr != WND_OTHER_PROCESS) return ptr->class;
if (IsWindow( hwnd )) /* check other processes */
{
if (write_access)
{
/* modifying classes in other processes is not allowed */
SetLastError( ERROR_ACCESS_DENIED );
return NULL;
}
FIXME( "reading from class of other process window %04x\n", hwnd );
/* DbgBreakPoint(); */
}
}
SetLastError( ERROR_INVALID_WINDOW_HANDLE );
return NULL;
}
/***********************************************************************
* release_class_ptr
*/
inline static void release_class_ptr( CLASS *ptr )
{
USER_Unlock();
}
/***********************************************************************
* CLASS_GetProc
*
* Get the class winproc for a given proc type
*/
static WNDPROC16 CLASS_GetProc( CLASS *classPtr, WINDOWPROCTYPE type )
{
HWINDOWPROC proc = classPtr->winprocA;
if (classPtr->winprocW)
{
/* if we have a Unicode proc, use it if we have no ASCII proc
* or if we have both and Unicode was requested
*/
if (!proc || type == WIN_PROC_32W) proc = classPtr->winprocW;
}
return WINPROC_GetProc( proc, type );
}
/***********************************************************************
* CLASS_SetProc
*
* Set the class winproc for a given proc type.
* Returns the previous window proc.
*/
static WNDPROC16 CLASS_SetProc( CLASS *classPtr, WNDPROC newproc, WINDOWPROCTYPE type )
{
HWINDOWPROC *proc = &classPtr->winprocA;
WNDPROC16 ret;
if (classPtr->winprocW)
{
/* if we have a Unicode proc, use it if we have no ASCII proc
* or if we have both and Unicode was requested
*/
if (!*proc || type == WIN_PROC_32W) proc = &classPtr->winprocW;
}
ret = WINPROC_GetProc( *proc, type );
WINPROC_SetProc( proc, (HWINDOWPROC)newproc, type, WIN_PROC_CLASS );
/* now free the one that we didn't set */
if (classPtr->winprocA && classPtr->winprocW)
{
if (proc == &classPtr->winprocA)
{
WINPROC_FreeProc( classPtr->winprocW, WIN_PROC_CLASS );
classPtr->winprocW = 0;
}
else
{
WINPROC_FreeProc( classPtr->winprocA, WIN_PROC_CLASS );
classPtr->winprocA = 0;
}
}
return ret;
}
/***********************************************************************
* CLASS_GetMenuNameA
*
* Get the menu name as a ASCII string.
*/
inline static LPSTR CLASS_GetMenuNameA( CLASS *classPtr )
{
if (!HIWORD(classPtr->menuName)) return (LPSTR)classPtr->menuName;
return (LPSTR)(classPtr->menuName + strlenW(classPtr->menuName) + 1);
}
/***********************************************************************
* CLASS_GetMenuName16
*
* Get the menu name as a SEGPTR.
*/
inline static SEGPTR CLASS_GetMenuName16( CLASS *classPtr )
{
if (!HIWORD(classPtr->menuName)) return (SEGPTR)classPtr->menuName;
if (!classPtr->segMenuName)
classPtr->segMenuName = MapLS( CLASS_GetMenuNameA(classPtr) );
return classPtr->segMenuName;
}
/***********************************************************************
* CLASS_GetMenuNameW
*
* Get the menu name as a Unicode string.
*/
inline static LPWSTR CLASS_GetMenuNameW( CLASS *classPtr )
{
return classPtr->menuName;
}
/***********************************************************************
* CLASS_SetMenuNameA
*
* Set the menu name in a class structure by copying the string.
*/
static void CLASS_SetMenuNameA( CLASS *classPtr, LPCSTR name )
{
UnMapLS( classPtr->segMenuName );
classPtr->segMenuName = 0;
if (HIWORD(classPtr->menuName)) HeapFree( GetProcessHeap(), 0, classPtr->menuName );
if (HIWORD(name))
{
DWORD lenA = strlen(name) + 1;
DWORD lenW = MultiByteToWideChar( CP_ACP, 0, name, lenA, NULL, 0 );
classPtr->menuName = HeapAlloc( GetProcessHeap(), 0, lenA + lenW*sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, name, lenA, classPtr->menuName, lenW );
memcpy( classPtr->menuName + lenW, name, lenA );
}
else classPtr->menuName = (LPWSTR)name;
}
/***********************************************************************
* CLASS_SetMenuNameW
*
* Set the menu name in a class structure by copying the string.
*/
static void CLASS_SetMenuNameW( CLASS *classPtr, LPCWSTR name )
{
UnMapLS( classPtr->segMenuName );
classPtr->segMenuName = 0;
if (HIWORD(classPtr->menuName)) HeapFree( GetProcessHeap(), 0, classPtr->menuName );
if (HIWORD(name))
{
DWORD lenW = strlenW(name) + 1;
DWORD lenA = WideCharToMultiByte( CP_ACP, 0, name, lenW, NULL, 0, NULL, NULL );
classPtr->menuName = HeapAlloc( GetProcessHeap(), 0, lenA + lenW*sizeof(WCHAR) );
memcpy( classPtr->menuName, name, lenW*sizeof(WCHAR) );
WideCharToMultiByte( CP_ACP, 0, name, lenW,
(char *)(classPtr->menuName + lenW), lenA, NULL, NULL );
}
else classPtr->menuName = (LPWSTR)name;
}
/***********************************************************************
* CLASS_FreeClass
*
* Free a class structure.
*/
static BOOL CLASS_FreeClass( CLASS *classPtr )
{
TRACE("%p\n", classPtr);
/* Check if we can remove this class */
if (classPtr->cWindows > 0)
{
SetLastError( ERROR_CLASS_HAS_WINDOWS );
return FALSE;
}
/* Remove the class from the linked list */
if (classPtr->next) classPtr->next->prev = classPtr->prev;
if (classPtr->prev) classPtr->prev->next = classPtr->next;
else firstClass = classPtr->next;
/* Delete the class */
if (classPtr->dce) DCE_FreeDCE( classPtr->dce );
if (classPtr->hbrBackground > (HBRUSH)(COLOR_GRADIENTINACTIVECAPTION + 1))
DeleteObject( classPtr->hbrBackground );
GlobalDeleteAtom( classPtr->atomName );
WINPROC_FreeProc( classPtr->winprocA, WIN_PROC_CLASS );
WINPROC_FreeProc( classPtr->winprocW, WIN_PROC_CLASS );
UnMapLS( classPtr->segMenuName );
HeapFree( GetProcessHeap(), 0, classPtr->menuName );
HeapFree( GetProcessHeap(), 0, classPtr );
return TRUE;
}
/***********************************************************************
* CLASS_FreeModuleClasses
*/
void CLASS_FreeModuleClasses( HMODULE16 hModule )
{
CLASS *ptr, *next;
TRACE("0x%08x\n", hModule);
USER_Lock();
for (ptr = firstClass; ptr; ptr = next)
{
next = ptr->next;
if (ptr->hInstance == hModule) CLASS_FreeClass( ptr );
}
USER_Unlock();
}
/***********************************************************************
* CLASS_FindClassByAtom
*
* Return a pointer to the class.
* hinstance has been normalized by the caller.
*
* NOTES
* 980805 a local class will be found now if registred with hInst=0
* and looed up with a hInst!=0. msmoney does it (jsch)
*
* Local class registered with a USER instance handle are found as if
* they were global classes.
*/
static CLASS *CLASS_FindClassByAtom( ATOM atom, HINSTANCE hinstance )
{
CLASS * class, *tclass = 0, *user_class = 0;
HINSTANCE16 hUser = GetModuleHandle16("USER");
TRACE("0x%08x 0x%08x\n", atom, hinstance);
/* First search task-specific classes */
for (class = firstClass; (class); class = class->next)
{
if (class->style & CS_GLOBALCLASS) continue;
if (class->atomName == atom)
{
if (hinstance==class->hInstance || hinstance==0xffff)
{
TRACE("-- found local %p\n", class);
return class;
}
if (class->hInstance == 0) tclass = class;
else if(class->hInstance == hUser)
{
user_class = class;
}
}
}
/* Then search global classes */
for (class = firstClass; (class); class = class->next)
{
if (!(class->style & CS_GLOBALCLASS)) continue;
if (class->atomName == atom)
{
TRACE("-- found global %p\n", class);
return class;
}
}
/* Check if there was a local class registered with USER */
if( user_class )
{
TRACE("--found local USER class %p\n", user_class);
return user_class;
}
/* Then check if there was a local class with hInst=0*/
if ( tclass )
{
WARN("-- found local Class registred with hInst=0\n");
return tclass;
}
TRACE("-- not found\n");
return 0;
}
/***********************************************************************
* CLASS_RegisterClass
*
* The real RegisterClass() functionality.
*/
static CLASS *CLASS_RegisterClass( ATOM atom, HINSTANCE hInstance,
DWORD style, INT classExtra, INT winExtra )
{
CLASS *classPtr;
TRACE("atom=0x%x hinst=0x%x style=0x%lx clExtr=0x%x winExtr=0x%x\n",
atom, hInstance, style, classExtra, winExtra );
/* Check if a class with this name already exists */
classPtr = CLASS_FindClassByAtom( atom, hInstance );
if (classPtr)
{
/* Class can be created only if it is local and */
/* if the class with the same name is global. */
if ((style & CS_GLOBALCLASS) || !(classPtr->style & CS_GLOBALCLASS))
{
SetLastError( ERROR_CLASS_ALREADY_EXISTS );
return NULL;
}
}
/* Fix the extra bytes value */
if (classExtra < 0) classExtra = 0;
else if (classExtra > 40) /* Extra bytes are limited to 40 in Win32 */
WARN("Class extra bytes %d is > 40\n", classExtra);
if (winExtra < 0) winExtra = 0;
else if (winExtra > 40) /* Extra bytes are limited to 40 in Win32 */
WARN("Win extra bytes %d is > 40\n", winExtra );
/* Create the class */
classPtr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CLASS) + classExtra );
if (!classPtr) return NULL;
classPtr->style = style;
classPtr->cbWndExtra = winExtra;
classPtr->cbClsExtra = classExtra;
classPtr->hInstance = hInstance;
classPtr->atomName = atom;
classPtr->dce = (style & CS_CLASSDC) ? DCE_AllocDCE( 0, DCE_CLASS_DC ) : NULL;
/* Other non-null values must be set by caller */
if ((classPtr->next = firstClass)) firstClass->prev = classPtr;
firstClass = classPtr;
return classPtr;
}
/***********************************************************************
* CLASS_UnregisterClass
*
* The real UnregisterClass() functionality.
*/
static BOOL CLASS_UnregisterClass( ATOM atom, HINSTANCE hInstance )
{
CLASS *classPtr;
BOOL ret = FALSE;
USER_Lock();
if (atom &&
(classPtr = CLASS_FindClassByAtom( atom, hInstance )) &&
(!hInstance || classPtr->hInstance == hInstance))
{
ret = CLASS_FreeClass( classPtr );
}
else SetLastError( ERROR_CLASS_DOES_NOT_EXIST );
USER_Unlock();
return ret;
}
/***********************************************************************
* CLASS_RegisterBuiltinClass
*
* Register a builtin control class.
* This allows having both ASCII and Unicode winprocs for the same class.
*/
ATOM CLASS_RegisterBuiltinClass( const struct builtin_class_descr *descr )
{
ATOM atom;
CLASS *classPtr;
if (!(atom = GlobalAddAtomA( descr->name ))) return 0;
if (!(classPtr = CLASS_RegisterClass( atom, 0, descr->style, 0, descr->extra )))
{
GlobalDeleteAtom( atom );
return 0;
}
classPtr->hCursor = LoadCursorA( 0, descr->cursor );
classPtr->hbrBackground = descr->brush;
if (descr->procA) WINPROC_SetProc( &classPtr->winprocA, (HWINDOWPROC)descr->procA,
WIN_PROC_32A, WIN_PROC_CLASS );
if (descr->procW) WINPROC_SetProc( &classPtr->winprocW, (HWINDOWPROC)descr->procW,
WIN_PROC_32W, WIN_PROC_CLASS );
return atom;
}
/***********************************************************************
* CLASS_AddWindow
*
* Add a new window using this class, and return the necessary
* information for creating the window.
*/
CLASS *CLASS_AddWindow( ATOM atom, HINSTANCE inst, WINDOWPROCTYPE type,
INT *winExtra, WNDPROC *winproc, DWORD *style, struct tagDCE **dce )
{
CLASS *class;
if (type == WIN_PROC_16) inst = GetExePtr(inst);
if (!(class = CLASS_FindClassByAtom( atom, inst ))) return NULL;
class->cWindows++;
if (type == WIN_PROC_32W)
{
if (!(*winproc = class->winprocW)) *winproc = class->winprocA;
}
else
{
if (!(*winproc = class->winprocA)) *winproc = class->winprocW;
}
*winExtra = class->cbWndExtra;
*style = class->style;
*dce = class->dce;
return class;
}
/***********************************************************************
* CLASS_RemoveWindow
*
* Remove a window from the class window count.
*/
void CLASS_RemoveWindow( CLASS *cls )
{
if (cls && cls->cWindows) cls->cWindows--;
}
/***********************************************************************
* RegisterClass (USER.57)
*/
ATOM WINAPI RegisterClass16( const WNDCLASS16 *wc )
{
ATOM atom;
CLASS *classPtr;
int iSmIconWidth, iSmIconHeight;
HINSTANCE16 hInstance=GetExePtr(wc->hInstance);
if (!(atom = GlobalAddAtomA( MapSL(wc->lpszClassName) ))) return 0;
if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
wc->cbClsExtra, wc->cbWndExtra )))
{
GlobalDeleteAtom( atom );
return 0;
}
TRACE("atom=%04x wndproc=%08lx hinst=%04x "
"bg=%04x style=%08x clsExt=%d winExt=%d class=%p name='%s'\n",
atom, (DWORD)wc->lpfnWndProc, hInstance,
wc->hbrBackground, wc->style, wc->cbClsExtra,
wc->cbWndExtra, classPtr,
HIWORD(wc->lpszClassName) ?
(char *)MapSL(wc->lpszClassName) : "" );
iSmIconWidth = GetSystemMetrics(SM_CXSMICON);
iSmIconHeight = GetSystemMetrics(SM_CYSMICON);
classPtr->hIcon = wc->hIcon;
classPtr->hIconSm = CopyImage(wc->hIcon, IMAGE_ICON,
iSmIconWidth, iSmIconHeight,
LR_COPYFROMRESOURCE);
classPtr->hCursor = wc->hCursor;
classPtr->hbrBackground = wc->hbrBackground;
WINPROC_SetProc( &classPtr->winprocA, (HWINDOWPROC)wc->lpfnWndProc,
WIN_PROC_16, WIN_PROC_CLASS );
CLASS_SetMenuNameA( classPtr, MapSL(wc->lpszMenuName) );
return atom;
}
/***********************************************************************
* RegisterClassA (USER32.@)
* RETURNS
* >0: Unique identifier
* 0: Failure
*/
ATOM WINAPI RegisterClassA( const WNDCLASSA* wc ) /* [in] Address of structure with class data */
{
ATOM atom;
int iSmIconWidth, iSmIconHeight;
CLASS *classPtr;
if (!(atom = GlobalAddAtomA( wc->lpszClassName ))) return 0;
if (!(classPtr = CLASS_RegisterClass( atom, wc->hInstance, wc->style,
wc->cbClsExtra, wc->cbWndExtra )))
{
GlobalDeleteAtom( atom );
return 0;
}
TRACE("atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p name='%s'\n",
atom, (DWORD)wc->lpfnWndProc, wc->hInstance,
wc->hbrBackground, wc->style, wc->cbClsExtra,
wc->cbWndExtra, classPtr,
HIWORD(wc->lpszClassName) ? wc->lpszClassName : "" );
iSmIconWidth = GetSystemMetrics(SM_CXSMICON);
iSmIconHeight = GetSystemMetrics(SM_CYSMICON);
classPtr->hIcon = wc->hIcon;
classPtr->hIconSm = CopyImage(wc->hIcon, IMAGE_ICON,
iSmIconWidth, iSmIconHeight,
LR_COPYFROMRESOURCE);
classPtr->hCursor = (HCURSOR16)wc->hCursor;
classPtr->hbrBackground = (HBRUSH16)wc->hbrBackground;
WINPROC_SetProc( &classPtr->winprocA, (HWINDOWPROC)wc->lpfnWndProc,
WIN_PROC_32A, WIN_PROC_CLASS );
CLASS_SetMenuNameA( classPtr, wc->lpszMenuName );
return atom;
}
/***********************************************************************
* RegisterClassW (USER32.@)
*/
ATOM WINAPI RegisterClassW( const WNDCLASSW* wc )
{
ATOM atom;
int iSmIconWidth, iSmIconHeight;
CLASS *classPtr;
if (!(atom = GlobalAddAtomW( wc->lpszClassName ))) return 0;
if (!(classPtr = CLASS_RegisterClass( atom, wc->hInstance, wc->style,
wc->cbClsExtra, wc->cbWndExtra )))
{
GlobalDeleteAtom( atom );
return 0;
}
TRACE("atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
atom, (DWORD)wc->lpfnWndProc, wc->hInstance,
wc->hbrBackground, wc->style, wc->cbClsExtra,
wc->cbWndExtra, classPtr );
iSmIconWidth = GetSystemMetrics(SM_CXSMICON);
iSmIconHeight = GetSystemMetrics(SM_CYSMICON);
classPtr->hIcon = wc->hIcon;
classPtr->hIconSm = CopyImage(wc->hIcon, IMAGE_ICON,
iSmIconWidth, iSmIconHeight,
LR_COPYFROMRESOURCE);
classPtr->hCursor = (HCURSOR16)wc->hCursor;
classPtr->hbrBackground = (HBRUSH16)wc->hbrBackground;
WINPROC_SetProc( &classPtr->winprocW, (HWINDOWPROC)wc->lpfnWndProc,
WIN_PROC_32W, WIN_PROC_CLASS );
CLASS_SetMenuNameW( classPtr, wc->lpszMenuName );
return atom;
}
/***********************************************************************
* RegisterClassEx (USER.397)
*/
ATOM WINAPI RegisterClassEx16( const WNDCLASSEX16 *wc )
{
ATOM atom;
CLASS *classPtr;
HINSTANCE16 hInstance = GetExePtr( wc->hInstance );
if (!(atom = GlobalAddAtomA( MapSL(wc->lpszClassName) ))) return 0;
if (!(classPtr = CLASS_RegisterClass( atom, hInstance, wc->style,
wc->cbClsExtra, wc->cbWndExtra )))
{
GlobalDeleteAtom( atom );
return 0;
}
TRACE("atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
atom, (DWORD)wc->lpfnWndProc, hInstance,
wc->hbrBackground, wc->style, wc->cbClsExtra,
wc->cbWndExtra, classPtr );
classPtr->hIcon = wc->hIcon;
classPtr->hIconSm = wc->hIconSm;
classPtr->hCursor = wc->hCursor;
classPtr->hbrBackground = wc->hbrBackground;
WINPROC_SetProc( &classPtr->winprocA, (HWINDOWPROC)wc->lpfnWndProc,
WIN_PROC_16, WIN_PROC_CLASS );
CLASS_SetMenuNameA( classPtr, MapSL(wc->lpszMenuName) );
return atom;
}
/***********************************************************************
* RegisterClassExA (USER32.@)
*/
ATOM WINAPI RegisterClassExA( const WNDCLASSEXA* wc )
{
ATOM atom;
CLASS *classPtr;
if (!(atom = GlobalAddAtomA( wc->lpszClassName ))) return 0;
if (!(classPtr = CLASS_RegisterClass( atom, wc->hInstance, wc->style,
wc->cbClsExtra, wc->cbWndExtra )))
{
GlobalDeleteAtom( atom );
return 0;
}
TRACE("atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
atom, (DWORD)wc->lpfnWndProc, wc->hInstance,
wc->hbrBackground, wc->style, wc->cbClsExtra,
wc->cbWndExtra, classPtr );
classPtr->hIcon = (HICON16)wc->hIcon;
classPtr->hIconSm = (HICON16)wc->hIconSm;
classPtr->hCursor = (HCURSOR16)wc->hCursor;
classPtr->hbrBackground = (HBRUSH16)wc->hbrBackground;
WINPROC_SetProc( &classPtr->winprocA, (HWINDOWPROC)wc->lpfnWndProc,
WIN_PROC_32A, WIN_PROC_CLASS );
CLASS_SetMenuNameA( classPtr, wc->lpszMenuName );
return atom;
}
/***********************************************************************
* RegisterClassExW (USER32.@)
*/
ATOM WINAPI RegisterClassExW( const WNDCLASSEXW* wc )
{
ATOM atom;
CLASS *classPtr;
if (!(atom = GlobalAddAtomW( wc->lpszClassName ))) return 0;
if (!(classPtr = CLASS_RegisterClass( atom, wc->hInstance, wc->style,
wc->cbClsExtra, wc->cbWndExtra )))
{
GlobalDeleteAtom( atom );
return 0;
}
TRACE("atom=%04x wndproc=%08lx hinst=%04x bg=%04x style=%08x clsExt=%d winExt=%d class=%p\n",
atom, (DWORD)wc->lpfnWndProc, wc->hInstance,
wc->hbrBackground, wc->style, wc->cbClsExtra,
wc->cbWndExtra, classPtr );
classPtr->hIcon = (HICON16)wc->hIcon;
classPtr->hIconSm = (HICON16)wc->hIconSm;
classPtr->hCursor = (HCURSOR16)wc->hCursor;
classPtr->hbrBackground = (HBRUSH16)wc->hbrBackground;
WINPROC_SetProc( &classPtr->winprocW, (HWINDOWPROC)wc->lpfnWndProc,
WIN_PROC_32W, WIN_PROC_CLASS );
CLASS_SetMenuNameW( classPtr, wc->lpszMenuName );
return atom;
}
/***********************************************************************
* UnregisterClass (USER.403)
*/
BOOL16 WINAPI UnregisterClass16( LPCSTR className, HINSTANCE16 hInstance )
{
return UnregisterClassA( className, GetExePtr( hInstance ) );
}
/***********************************************************************
* UnregisterClassA (USER32.@)
*
*/
BOOL WINAPI UnregisterClassA( LPCSTR className, HINSTANCE hInstance )
{
TRACE("%s %x\n",debugres_a(className), hInstance);
return CLASS_UnregisterClass( GlobalFindAtomA( className ), hInstance );
}
/***********************************************************************
* UnregisterClassW (USER32.@)
*/
BOOL WINAPI UnregisterClassW( LPCWSTR className, HINSTANCE hInstance )
{
TRACE("%s %x\n",debugres_w(className), hInstance);
return CLASS_UnregisterClass( GlobalFindAtomW( className ), hInstance );
}
/***********************************************************************
* GetClassWord (USER32.@)
*/
WORD WINAPI GetClassWord( HWND hwnd, INT offset )
{
CLASS *class;
WORD retvalue = 0;
if (offset < 0) return GetClassLongA( hwnd, offset );
TRACE("%x %x\n",hwnd, offset);
if (!(class = get_class_ptr( hwnd, FALSE ))) return 0;
if (offset <= class->cbClsExtra - sizeof(WORD))
retvalue = GET_WORD((char *)(class + 1) + offset);
else
SetLastError( ERROR_INVALID_INDEX );
release_class_ptr( class );
return retvalue;
}
/***********************************************************************
* GetClassLong (USER.131)
*/
LONG WINAPI GetClassLong16( HWND16 hwnd16, INT16 offset )
{
CLASS *class;
LONG ret;
HWND hwnd = (HWND)(ULONG_PTR)hwnd16; /* no need for full handle */
TRACE("%x %d\n",hwnd, offset);
switch( offset )
{
case GCL_WNDPROC:
if (!(class = get_class_ptr( hwnd, FALSE ))) return 0;
ret = (LONG)CLASS_GetProc( class, WIN_PROC_16 );
release_class_ptr( class );
return ret;
case GCL_MENUNAME:
if (!(class = get_class_ptr( hwnd, FALSE ))) return 0;
ret = (LONG)CLASS_GetMenuName16( class );
release_class_ptr( class );
return ret;
default:
return GetClassLongA( hwnd, offset );
}
}
/***********************************************************************
* GetClassLongA (USER32.@)
*/
LONG WINAPI GetClassLongA( HWND hwnd, INT offset )
{
CLASS *class;
LONG retvalue = 0;
TRACE("%x %d\n", hwnd, offset);
if (!(class = get_class_ptr( hwnd, FALSE ))) return 0;
if (offset >= 0)
{
if (offset <= class->cbClsExtra - sizeof(LONG))
retvalue = GET_DWORD((char *)(class + 1) + offset);
else
SetLastError( ERROR_INVALID_INDEX );
release_class_ptr( class );
return retvalue;
}
switch(offset)
{
case GCL_HBRBACKGROUND:
retvalue = (LONG)class->hbrBackground;
break;
case GCL_HCURSOR:
retvalue = (LONG)class->hCursor;
break;
case GCL_HICON:
retvalue = (LONG)class->hIcon;
break;
case GCL_HICONSM:
retvalue = (LONG)class->hIconSm;
break;
case GCL_STYLE:
retvalue = (LONG)class->style;
break;
case GCL_CBWNDEXTRA:
retvalue = (LONG)class->cbWndExtra;
break;
case GCL_CBCLSEXTRA:
retvalue = (LONG)class->cbClsExtra;
break;
case GCL_HMODULE:
retvalue = (LONG)class->hInstance;
break;
case GCL_WNDPROC:
retvalue = (LONG)CLASS_GetProc( class, WIN_PROC_32A );
break;
case GCL_MENUNAME:
retvalue = (LONG)CLASS_GetMenuNameA( class );
break;
case GCW_ATOM:
retvalue = (DWORD)class->atomName;
break;
default:
SetLastError( ERROR_INVALID_INDEX );
break;
}
release_class_ptr( class );
return retvalue;
}
/***********************************************************************
* GetClassLongW (USER32.@)
*/
LONG WINAPI GetClassLongW( HWND hwnd, INT offset )
{
CLASS *class;
LONG retvalue;
if (offset != GCL_WNDPROC && offset != GCL_MENUNAME)
return GetClassLongA( hwnd, offset );
TRACE("%x %d\n", hwnd, offset);
if (!(class = get_class_ptr( hwnd, FALSE ))) return 0;
if (offset == GCL_WNDPROC)
retvalue = (LONG)CLASS_GetProc( class, WIN_PROC_32W );
else /* GCL_MENUNAME */
retvalue = (LONG)CLASS_GetMenuNameW( class );
release_class_ptr( class );
return retvalue;
}
/***********************************************************************
* SetClassWord (USER32.@)
*/
WORD WINAPI SetClassWord( HWND hwnd, INT offset, WORD newval )
{
CLASS *class;
WORD retval = 0;
if (offset < 0) return SetClassLongA( hwnd, offset, (DWORD)newval );
TRACE("%x %d %x\n", hwnd, offset, newval);
if (!(class = get_class_ptr( hwnd, TRUE ))) return 0;
if (offset <= class->cbClsExtra - sizeof(WORD))
{
void *ptr = (char *)(class + 1) + offset;
retval = GET_WORD(ptr);
PUT_WORD( ptr, newval );
}
else SetLastError( ERROR_INVALID_INDEX );
release_class_ptr( class );
return retval;
}
/***********************************************************************
* SetClassLong (USER.132)
*/
LONG WINAPI SetClassLong16( HWND16 hwnd16, INT16 offset, LONG newval )
{
CLASS *class;
LONG retval;
HWND hwnd = (HWND)(ULONG_PTR)hwnd16; /* no need for full handle */
TRACE("%x %d %lx\n", hwnd, offset, newval);
switch(offset)
{
case GCL_WNDPROC:
if (!(class = get_class_ptr( hwnd, TRUE ))) return 0;
retval = (LONG)CLASS_SetProc( class, (WNDPROC)newval, WIN_PROC_16 );
release_class_ptr( class );
return retval;
case GCL_MENUNAME:
newval = (LONG)MapSL( newval );
/* fall through */
default:
return SetClassLongA( hwnd, offset, newval );
}
}
/***********************************************************************
* SetClassLongA (USER32.@)
*/
LONG WINAPI SetClassLongA( HWND hwnd, INT offset, LONG newval )
{
CLASS *class;
LONG retval = 0;
TRACE("%x %d %lx\n", hwnd, offset, newval);
if (!(class = get_class_ptr( hwnd, TRUE ))) return 0;
if (offset >= 0)
{
if (offset <= class->cbClsExtra - sizeof(LONG))
{
void *ptr = (char *)(class + 1) + offset;
retval = GET_DWORD(ptr);
PUT_DWORD( ptr, newval );
}
else SetLastError( ERROR_INVALID_INDEX );
}
else switch(offset)
{
case GCL_MENUNAME:
CLASS_SetMenuNameA( class, (LPCSTR)newval );
retval = 0; /* Old value is now meaningless anyway */
break;
case GCL_WNDPROC:
retval = (LONG)CLASS_SetProc( class, (WNDPROC)newval, WIN_PROC_32A );
break;
case GCL_HBRBACKGROUND:
retval = (LONG)class->hbrBackground;
class->hbrBackground = newval;
break;
case GCL_HCURSOR:
retval = (LONG)class->hCursor;
class->hCursor = newval;
break;
case GCL_HICON:
retval = (LONG)class->hIcon;
class->hIcon = newval;
break;
case GCL_HICONSM:
retval = (LONG)class->hIconSm;
class->hIconSm = newval;
break;
case GCL_STYLE:
retval = (LONG)class->style;
class->style = newval;
break;
case GCL_CBWNDEXTRA:
retval = (LONG)class->cbWndExtra;
class->cbWndExtra = newval;
break;
case GCL_HMODULE:
retval = (LONG)class->hInstance;
class->hInstance = newval;
break;
case GCW_ATOM:
retval = (DWORD)class->atomName;
class->atomName = newval;
break;
case GCL_CBCLSEXTRA: /* cannot change this one */
SetLastError( ERROR_INVALID_PARAMETER );
break;
default:
SetLastError( ERROR_INVALID_INDEX );
break;
}
release_class_ptr( class );
return retval;
}
/***********************************************************************
* SetClassLongW (USER32.@)
*/
LONG WINAPI SetClassLongW( HWND hwnd, INT offset, LONG newval )
{
CLASS *class;
LONG retval;
if (offset != GCL_WNDPROC && offset != GCL_MENUNAME)
return SetClassLongA( hwnd, offset, newval );
TRACE("%x %d %lx\n", hwnd, offset, newval);
if (!(class = get_class_ptr( hwnd, TRUE ))) return 0;
if (offset == GCL_WNDPROC)
retval = (LONG)CLASS_SetProc( class, (WNDPROC)newval, WIN_PROC_32W );
else /* GCL_MENUNAME */
{
CLASS_SetMenuNameW( class, (LPCWSTR)newval );
retval = 0; /* Old value is now meaningless anyway */
}
release_class_ptr( class );
return retval;
}
/***********************************************************************
* GetClassNameA (USER32.@)
*/
INT WINAPI GetClassNameA( HWND hwnd, LPSTR buffer, INT count )
{
INT ret = GlobalGetAtomNameA( GetClassLongA( hwnd, GCW_ATOM ), buffer, count );
TRACE("%x %s %x\n",hwnd, debugstr_a(buffer), count);
return ret;
}
/***********************************************************************
* GetClassNameW (USER32.@)
*/
INT WINAPI GetClassNameW( HWND hwnd, LPWSTR buffer, INT count )
{
INT ret = GlobalGetAtomNameW( GetClassLongW( hwnd, GCW_ATOM ), buffer, count );
TRACE("%x %s %x\n",hwnd, debugstr_w(buffer), count);
return ret;
}
/***********************************************************************
* GetClassInfo (USER.404)
*/
BOOL16 WINAPI GetClassInfo16( HINSTANCE16 hInstance, SEGPTR name, WNDCLASS16 *wc )
{
ATOM atom;
CLASS *classPtr;
TRACE("%x %s %p\n",hInstance, debugres_a(MapSL(name)), wc);
hInstance = GetExePtr( hInstance );
if (!(atom = GlobalFindAtomA( MapSL(name) )) ||
!(classPtr = CLASS_FindClassByAtom( atom, hInstance )))
return FALSE;
if ((hInstance != classPtr->hInstance) &&
!(classPtr->style & CS_GLOBALCLASS)) /*BWCC likes to pass hInstance=0*/
return FALSE;
wc->style = (UINT16)classPtr->style;
wc->lpfnWndProc = CLASS_GetProc( classPtr, WIN_PROC_16 );
wc->cbClsExtra = (INT16)classPtr->cbClsExtra;
wc->cbWndExtra = (INT16)classPtr->cbWndExtra;
wc->hInstance = classPtr->style & CS_GLOBALCLASS ? GetModuleHandle16("USER") : (HINSTANCE16)classPtr->hInstance;
wc->hIcon = classPtr->hIcon;
wc->hCursor = classPtr->hCursor;
wc->hbrBackground = classPtr->hbrBackground;
wc->lpszClassName = name;
wc->lpszMenuName = CLASS_GetMenuName16( classPtr );
return TRUE;
}
/***********************************************************************
* GetClassInfoA (USER32.@)
*/
BOOL WINAPI GetClassInfoA( HINSTANCE hInstance, LPCSTR name,
WNDCLASSA *wc )
{
ATOM atom;
CLASS *classPtr;
TRACE("%x %p %p\n",hInstance, name, wc);
/* workaround: if hInstance=NULL you expect to get the system classes
but this classes (as example from comctl32.dll SysListView) won't be
registered with hInstance=NULL in WINE because of the late loading
of this dll. fixes file dialogs in WinWord95 (jsch)*/
if (!(atom=GlobalFindAtomA(name)) || !(classPtr=CLASS_FindClassByAtom(atom,hInstance)))
return FALSE;
if (!(classPtr->style & CS_GLOBALCLASS) &&
classPtr->hInstance &&
(hInstance != classPtr->hInstance))
{
if (hInstance) return FALSE;
WARN("systemclass %s (hInst=0) demanded but only class with hInst!=0 found\n",name);
}
wc->style = classPtr->style;
wc->lpfnWndProc = (WNDPROC)CLASS_GetProc( classPtr, WIN_PROC_32A );
wc->cbClsExtra = classPtr->cbClsExtra;
wc->cbWndExtra = classPtr->cbWndExtra;
wc->hInstance = hInstance;
wc->hIcon = (HICON)classPtr->hIcon;
wc->hCursor = (HCURSOR)classPtr->hCursor;
wc->hbrBackground = (HBRUSH)classPtr->hbrBackground;
wc->lpszMenuName = CLASS_GetMenuNameA( classPtr );
wc->lpszClassName = name;
return TRUE;
}
/***********************************************************************
* GetClassInfoW (USER32.@)
*/
BOOL WINAPI GetClassInfoW( HINSTANCE hInstance, LPCWSTR name,
WNDCLASSW *wc )
{
ATOM atom;
CLASS *classPtr;
TRACE("%x %p %p\n",hInstance, name, wc);
if ( !(atom=GlobalFindAtomW(name)) ||
!(classPtr=CLASS_FindClassByAtom(atom,hInstance))
)
return FALSE;
if (!(classPtr->style & CS_GLOBALCLASS) &&
classPtr->hInstance &&
(hInstance != classPtr->hInstance))
{
if (hInstance) return FALSE;
WARN("systemclass %s (hInst=0) demanded but only class with hInst!=0 found\n",debugstr_w(name));
}
wc->style = classPtr->style;
wc->lpfnWndProc = (WNDPROC)CLASS_GetProc( classPtr, WIN_PROC_32W );
wc->cbClsExtra = classPtr->cbClsExtra;
wc->cbWndExtra = classPtr->cbWndExtra;
wc->hInstance = hInstance;
wc->hIcon = (HICON)classPtr->hIcon;
wc->hCursor = (HCURSOR)classPtr->hCursor;
wc->hbrBackground = (HBRUSH)classPtr->hbrBackground;
wc->lpszMenuName = CLASS_GetMenuNameW( classPtr );
wc->lpszClassName = name;
return TRUE;
}
/***********************************************************************
* GetClassInfoEx (USER.398)
*
* FIXME: this is just a guess, I have no idea if GetClassInfoEx() is the
* same in Win16 as in Win32. --AJ
*/
BOOL16 WINAPI GetClassInfoEx16( HINSTANCE16 hInstance, SEGPTR name, WNDCLASSEX16 *wc )
{
ATOM atom;
CLASS *classPtr;
TRACE("%x %s %p\n",hInstance,debugres_a( MapSL(name) ), wc);
hInstance = GetExePtr( hInstance );
if (!(atom = GlobalFindAtomA( MapSL(name) )) ||
!(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
(hInstance != classPtr->hInstance)) return FALSE;
wc->style = classPtr->style;
wc->lpfnWndProc = CLASS_GetProc( classPtr, WIN_PROC_16 );
wc->cbClsExtra = (INT16)classPtr->cbClsExtra;
wc->cbWndExtra = (INT16)classPtr->cbWndExtra;
wc->hInstance = (HINSTANCE16)classPtr->hInstance;
wc->hIcon = classPtr->hIcon;
wc->hIconSm = classPtr->hIconSm;
wc->hCursor = classPtr->hCursor;
wc->hbrBackground = classPtr->hbrBackground;
wc->lpszClassName = (SEGPTR)0;
wc->lpszMenuName = CLASS_GetMenuName16( classPtr );
wc->lpszClassName = name;
/* We must return the atom of the class here instead of just TRUE. */
return atom;
}
/***********************************************************************
* GetClassInfoExA (USER32.@)
*/
BOOL WINAPI GetClassInfoExA( HINSTANCE hInstance, LPCSTR name,
WNDCLASSEXA *wc )
{
ATOM atom;
CLASS *classPtr;
TRACE("%x %p %p\n",hInstance, name, wc);
if (!(atom = GlobalFindAtomA( name )) ||
!(classPtr = CLASS_FindClassByAtom( atom, hInstance ))
/*|| (hInstance != classPtr->hInstance) */ ) return FALSE;
wc->style = classPtr->style;
wc->lpfnWndProc = (WNDPROC)CLASS_GetProc( classPtr, WIN_PROC_32A );
wc->cbClsExtra = classPtr->cbClsExtra;
wc->cbWndExtra = classPtr->cbWndExtra;
wc->hInstance = classPtr->hInstance;
wc->hIcon = (HICON)classPtr->hIcon;
wc->hIconSm = (HICON)classPtr->hIconSm;
wc->hCursor = (HCURSOR)classPtr->hCursor;
wc->hbrBackground = (HBRUSH)classPtr->hbrBackground;
wc->lpszMenuName = CLASS_GetMenuNameA( classPtr );
wc->lpszClassName = name;
/* We must return the atom of the class here instead of just TRUE. */
return atom;
}
/***********************************************************************
* GetClassInfoExW (USER32.@)
*/
BOOL WINAPI GetClassInfoExW( HINSTANCE hInstance, LPCWSTR name,
WNDCLASSEXW *wc )
{
ATOM atom;
CLASS *classPtr;
TRACE("%x %p %p\n",hInstance, name, wc);
if (!(atom = GlobalFindAtomW( name )) ||
!(classPtr = CLASS_FindClassByAtom( atom, hInstance )) ||
(hInstance != classPtr->hInstance)) return FALSE;
wc->style = classPtr->style;
wc->lpfnWndProc = (WNDPROC)CLASS_GetProc( classPtr, WIN_PROC_32W );
wc->cbClsExtra = classPtr->cbClsExtra;
wc->cbWndExtra = classPtr->cbWndExtra;
wc->hInstance = classPtr->hInstance;
wc->hIcon = (HICON)classPtr->hIcon;
wc->hIconSm = (HICON)classPtr->hIconSm;
wc->hCursor = (HCURSOR)classPtr->hCursor;
wc->hbrBackground = (HBRUSH)classPtr->hbrBackground;
wc->lpszMenuName = CLASS_GetMenuNameW( classPtr );
wc->lpszClassName = name;
/* We must return the atom of the class here instead of just TRUE. */
return atom;
}
#if 0 /* toolhelp is in kernel, so this cannot work */
/***********************************************************************
* ClassFirst (TOOLHELP.69)
*/
BOOL16 WINAPI ClassFirst16( CLASSENTRY *pClassEntry )
{
TRACE("%p\n",pClassEntry);
pClassEntry->wNext = 1;
return ClassNext16( pClassEntry );
}
/***********************************************************************
* ClassNext (TOOLHELP.70)
*/
BOOL16 WINAPI ClassNext16( CLASSENTRY *pClassEntry )
{
int i;
CLASS *class = firstClass;
TRACE("%p\n",pClassEntry);
if (!pClassEntry->wNext) return FALSE;
for (i = 1; (i < pClassEntry->wNext) && class; i++) class = class->next;
if (!class)
{
pClassEntry->wNext = 0;
return FALSE;
}
pClassEntry->hInst = class->hInstance;
pClassEntry->wNext++;
GlobalGetAtomNameA( class->atomName, pClassEntry->szClassName,
sizeof(pClassEntry->szClassName) );
return TRUE;
}
#endif
|