mirror of
https://github.com/reactos/wine.git
synced 2025-02-11 07:05:30 +00:00
![Alexandre Julliard](/assets/img/avatar_default.png)
Sun Mar 19 16:30:20 1995 Alexandre Julliard (julliard@sunsite.unc.edu) * [*/*] Implemented a new memory mapping scheme. There's no longer a one-to-one mapping between 16-bit and 32-bit pointers. Please see file DEVELOPERS-HINTS for technical details. * [controls/scroll.c] Fixed bug when dragging mouse in horizontal scrollbars. * [tools/build.c] [if1632/*.spec] Removed support for C callback functions and for re-ordering of the 32-bit arguments, as these were never used. This should allow a more efficient callback scheme to be implemented. * [if1632/olecli.spec] Reduced the number of entries to make the 16-bit code fit in 64k. This limitation will soon be removed. * [loader/ldt.c] Rewrote LDT manipulation functions and implemented LDT_GetEntry(). * [memory/global.c] Rewrote Global*() routines to use the new selector allocation mechanism. * [memory/local.c] Rewrote local heap handling to use a Windows-compatible layout (not really finished yet). Implemented TOOLHELP heap-walking routines. * [memory/selector.c] Implemented LDT manipulation API functions. Tue Mar 14 19:50:28 EST 1995 William Magro (wmagro@tc.cornell.edu) * [windows/defdlg.c] Fixed problem where dialogs closed using the System menu ('Close' item or double click on close box) would hang Wine. Sun Mar 12 14:28:13 1995 Michael Patra <micky@marie.physik.TU-Berlin.DE> * [controls/listbox.c] Removed most of the statements for sending a notification message ListBoxDirectory(), DlgDirSelect(), DlgDirList(): Improved the code; Borland's standard file open dialog will work now. * [misc/main.c], [misc/file.c], [miscemu/int21.c] Added support for new command line option "-allowreadonly". If set an attempt to open a read only file in write mode will be converted to opening it read only (many programs try to open all files in read/write mode even if they only intend to read it - this might cause a few under problems under an unix-like environment where most files are read only for a "normal" user) * [loader/selector.c] GetMemoryReference(): Added support for __AHIncr and __AHShift * [misc/dos_fs.c] DOS_SimplifyPath(): This routine simplifies path names ( e.g., it will change "/usr///local/bin/../lib//a" to "/usr/local/lib/a" ) match(): rewritten * [objects/text.c] TEXT_NextLine(): Removed a bug in the handling of LF's * [miscemu/int21.c] GetFileDateTime(): Fixed. SetFileDateTime() is still broken. Sat Mar 11 19:46:19 1995 Martin von Loewis <loewis@informatik.hu-berlin.de> * [controls/menu.c] ChangeMenu: defaults to MF_INSERT InsertMenu: allow insertion even if position is one after last item * [if1632/Imakefile] [if1632/compobj.spec] [if1632/relay.c] [if1632/storage.spec] [include/dlls.h] Added stubs for STORAGE.DLL and COMPOBJ.DLL * [if1632/user.spec] [windows/message.c] InSendMessage: new function * [include/neexe.h][include/ne_image.c] NE_FixupSegment: fixed handling of additive records * [loader/selector.c] GetEntryDLLName: return NULL instead of pointer to DLL.0 if not found * [loader/signal.c] win_fault: Enter debugger on SIGFPE, too Wed Mar 1 21:47:42 1995 Cameron Heide (heide@ee.ualberta.ca) * [miscemu/int*.c] Various minor modifications to the clock tick counter, FindFirst/FindNext funcs, and DPB handling.
331 lines
9.3 KiB
C
331 lines
9.3 KiB
C
/*
|
|
* Window classes functions
|
|
*
|
|
* Copyright 1993 Alexandre Julliard
|
|
*
|
|
static char Copyright[] = "Copyright Alexandre Julliard, 1993";
|
|
*/
|
|
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include "class.h"
|
|
#include "user.h"
|
|
#include "win.h"
|
|
#include "dce.h"
|
|
#include "toolhelp.h"
|
|
#include "stddebug.h"
|
|
/* #define DEBUG_CLASS */
|
|
#include "debug.h"
|
|
|
|
|
|
static HCLASS firstClass = 0;
|
|
|
|
|
|
/***********************************************************************
|
|
* CLASS_FindClassByName
|
|
*
|
|
* Return a handle and a pointer to the class.
|
|
* 'ptr' can be NULL if the pointer is not needed.
|
|
*/
|
|
HCLASS CLASS_FindClassByName( char * name, WORD hinstance, CLASS **ptr )
|
|
{
|
|
ATOM atom;
|
|
HCLASS class;
|
|
CLASS * classPtr;
|
|
|
|
if (!(atom = GlobalFindAtom( name ))) return 0;
|
|
|
|
/* First search task-specific classes */
|
|
|
|
for (class = firstClass; (class); class = classPtr->hNext)
|
|
{
|
|
classPtr = (CLASS *) USER_HEAP_LIN_ADDR(class);
|
|
if (classPtr->wc.style & CS_GLOBALCLASS) continue;
|
|
if ((classPtr->atomName == atom) &&
|
|
((hinstance==0xffff )|| (hinstance == classPtr->wc.hInstance)))
|
|
{
|
|
if (ptr) *ptr = classPtr;
|
|
return class;
|
|
}
|
|
}
|
|
|
|
/* Then search global classes */
|
|
|
|
for (class = firstClass; (class); class = classPtr->hNext)
|
|
{
|
|
classPtr = (CLASS *) USER_HEAP_LIN_ADDR(class);
|
|
if (!(classPtr->wc.style & CS_GLOBALCLASS)) continue;
|
|
if (classPtr->atomName == atom)
|
|
{
|
|
if (ptr) *ptr = classPtr;
|
|
return class;
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* CLASS_FindClassPtr
|
|
*
|
|
* Return a pointer to the CLASS structure corresponding to a HCLASS.
|
|
*/
|
|
CLASS * CLASS_FindClassPtr( HCLASS hclass )
|
|
{
|
|
CLASS * ptr;
|
|
|
|
if (!hclass) return NULL;
|
|
ptr = (CLASS *) USER_HEAP_LIN_ADDR( hclass );
|
|
if (ptr->wMagic != CLASS_MAGIC) return NULL;
|
|
return ptr;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* RegisterClass (USER.57)
|
|
*/
|
|
ATOM RegisterClass( LPWNDCLASS class )
|
|
{
|
|
CLASS * newClass, * prevClassPtr;
|
|
HCLASS handle, prevClass;
|
|
int classExtra;
|
|
char *name = PTR_SEG_TO_LIN( class->lpszClassName );
|
|
|
|
dprintf_class(stddeb, "RegisterClass: wndproc=%p hinst=%d name='%s' background %x\n",
|
|
class->lpfnWndProc, class->hInstance, name, class->hbrBackground );
|
|
|
|
/* Check if a class with this name already exists */
|
|
|
|
prevClass = CLASS_FindClassByName( name, class->hInstance, &prevClassPtr );
|
|
if (prevClass)
|
|
{
|
|
/* Class can be created only if it is local and */
|
|
/* if the class with the same name is global. */
|
|
|
|
if (class->style & CS_GLOBALCLASS) return 0;
|
|
if (!(prevClassPtr->wc.style & CS_GLOBALCLASS)) return 0;
|
|
}
|
|
|
|
/* Create class */
|
|
|
|
classExtra = (class->cbClsExtra < 0) ? 0 : class->cbClsExtra;
|
|
handle = USER_HEAP_ALLOC( sizeof(CLASS) + classExtra );
|
|
if (!handle) return 0;
|
|
newClass = (CLASS *) USER_HEAP_LIN_ADDR( handle );
|
|
newClass->hNext = firstClass;
|
|
newClass->wMagic = CLASS_MAGIC;
|
|
newClass->cWindows = 0;
|
|
newClass->wc = *class;
|
|
newClass->wc.cbWndExtra = (class->cbWndExtra < 0) ? 0 : class->cbWndExtra;
|
|
newClass->wc.cbClsExtra = classExtra;
|
|
|
|
newClass->atomName = GlobalAddAtom( name );
|
|
newClass->wc.lpszClassName = NULL;
|
|
|
|
if (newClass->wc.style & CS_CLASSDC)
|
|
newClass->hdce = DCE_AllocDCE( DCE_CLASS_DC );
|
|
else newClass->hdce = 0;
|
|
|
|
/* Make a copy of the menu name (only if it is a string) */
|
|
|
|
if ((int)class->lpszMenuName & 0xffff0000)
|
|
{
|
|
char *menuname = PTR_SEG_TO_LIN( class->lpszMenuName );
|
|
HANDLE hname = USER_HEAP_ALLOC( strlen(menuname)+1 );
|
|
if (hname)
|
|
{
|
|
newClass->wc.lpszMenuName = (char *)USER_HEAP_SEG_ADDR( hname );
|
|
strcpy( USER_HEAP_LIN_ADDR( hname ), menuname );
|
|
}
|
|
}
|
|
|
|
if (classExtra) memset( newClass->wExtra, 0, classExtra );
|
|
firstClass = handle;
|
|
return newClass->atomName;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* UnregisterClass (USER.403)
|
|
*/
|
|
BOOL UnregisterClass( LPSTR className, HANDLE instance )
|
|
{
|
|
HANDLE class, prevClass;
|
|
CLASS * classPtr, * prevClassPtr;
|
|
|
|
/* Check if we can remove this class */
|
|
class = CLASS_FindClassByName( className, instance, &classPtr );
|
|
if (!class) return FALSE;
|
|
if ((classPtr->wc.hInstance != instance) || (classPtr->cWindows > 0))
|
|
return FALSE;
|
|
|
|
/* Remove the class from the linked list */
|
|
if (firstClass == class) firstClass = classPtr->hNext;
|
|
else
|
|
{
|
|
for (prevClass = firstClass; prevClass; prevClass=prevClassPtr->hNext)
|
|
{
|
|
prevClassPtr = (CLASS *) USER_HEAP_LIN_ADDR(prevClass);
|
|
if (prevClassPtr->hNext == class) break;
|
|
}
|
|
if (!prevClass)
|
|
{
|
|
fprintf(stderr, "ERROR: Class list corrupted\n" );
|
|
return FALSE;
|
|
}
|
|
prevClassPtr->hNext = classPtr->hNext;
|
|
}
|
|
|
|
/* Delete the class */
|
|
if (classPtr->hdce) DCE_FreeDCE( classPtr->hdce );
|
|
if (classPtr->wc.hbrBackground) DeleteObject( classPtr->wc.hbrBackground );
|
|
/*if (classPtr->wc.style & CS_GLOBALCLASS)*/ GlobalDeleteAtom( classPtr->atomName );
|
|
/*else DeleteAtom( classPtr->atomName );*/
|
|
if ((int)classPtr->wc.lpszMenuName & 0xffff0000)
|
|
USER_HEAP_FREE( (int)classPtr->wc.lpszMenuName & 0xffff );
|
|
USER_HEAP_FREE( class );
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* GetClassWord (USER.129)
|
|
*/
|
|
WORD GetClassWord( HWND hwnd, short offset )
|
|
{
|
|
return (WORD)GetClassLong( hwnd, offset );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* SetClassWord (USER.130)
|
|
*/
|
|
WORD SetClassWord( HWND hwnd, short offset, WORD newval )
|
|
{
|
|
CLASS * classPtr;
|
|
WND * wndPtr;
|
|
WORD *ptr, retval = 0;
|
|
|
|
if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
|
|
if (!(classPtr = CLASS_FindClassPtr( wndPtr->hClass ))) return 0;
|
|
ptr = (WORD *)(((char *)classPtr->wExtra) + offset);
|
|
retval = *ptr;
|
|
*ptr = newval;
|
|
return retval;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* GetClassLong (USER.131)
|
|
*/
|
|
LONG GetClassLong( HWND hwnd, short offset )
|
|
{
|
|
CLASS * classPtr;
|
|
WND * wndPtr;
|
|
|
|
if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
|
|
if (!(classPtr = CLASS_FindClassPtr( wndPtr->hClass ))) return 0;
|
|
return *(LONG *)(((char *)classPtr->wExtra) + offset);
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* SetClassLong (USER.132)
|
|
*/
|
|
LONG SetClassLong( HWND hwnd, short offset, LONG newval )
|
|
{
|
|
CLASS * classPtr;
|
|
WND * wndPtr;
|
|
LONG *ptr, retval = 0;
|
|
|
|
if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
|
|
if (!(classPtr = CLASS_FindClassPtr( wndPtr->hClass ))) return 0;
|
|
ptr = (LONG *)(((char *)classPtr->wExtra) + offset);
|
|
retval = *ptr;
|
|
*ptr = newval;
|
|
return retval;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* GetClassName (USER.58)
|
|
*/
|
|
int GetClassName(HWND hwnd, LPSTR lpClassName, short maxCount)
|
|
{
|
|
WND *wndPtr;
|
|
CLASS *classPtr;
|
|
|
|
/* FIXME: We have the find the correct hInstance */
|
|
dprintf_class(stddeb,"GetClassName(%x,%p,%d\n)",hwnd,lpClassName,maxCount);
|
|
if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
|
|
if (!(classPtr = CLASS_FindClassPtr(wndPtr->hClass))) return 0;
|
|
|
|
return (GetAtomName(classPtr->atomName, lpClassName, maxCount));
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* GetClassInfo (USER.404)
|
|
*/
|
|
BOOL GetClassInfo(HANDLE hInstance, LPSTR lpClassName,
|
|
LPWNDCLASS lpWndClass)
|
|
{
|
|
CLASS *classPtr;
|
|
|
|
if (HIWORD(lpClassName))
|
|
{
|
|
dprintf_class(stddeb, "GetClassInfo hInstance=%04x lpClassName=%s\n",
|
|
hInstance, lpClassName);
|
|
}
|
|
else
|
|
dprintf_class(stddeb, "GetClassInfo hInstance=%04x lpClassName=#%d\n",
|
|
hInstance, (int)lpClassName);
|
|
|
|
|
|
/* if (!(CLASS_FindClassByName(lpClassName, &classPtr))) return FALSE; */
|
|
if (!(CLASS_FindClassByName(lpClassName, hInstance, &classPtr)))
|
|
{
|
|
if (!HIWORD(lpClassName))
|
|
{
|
|
char temp[10];
|
|
sprintf(temp, "#%d", (int)lpClassName);
|
|
if (!(CLASS_FindClassByName(temp, hInstance, &classPtr))) return FALSE;
|
|
|
|
}
|
|
else return FALSE;
|
|
}
|
|
|
|
if (hInstance && (hInstance != classPtr->wc.hInstance)) return FALSE;
|
|
|
|
memcpy(lpWndClass, &(classPtr->wc), sizeof(WNDCLASS));
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* ClassFirst (TOOLHELP.69)
|
|
*/
|
|
BOOL ClassFirst( CLASSENTRY *pClassEntry )
|
|
{
|
|
pClassEntry->wNext = firstClass;
|
|
return ClassNext( pClassEntry );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* ClassNext (TOOLHELP.70)
|
|
*/
|
|
BOOL ClassNext( CLASSENTRY *pClassEntry )
|
|
{
|
|
CLASS *classPtr = (CLASS *) USER_HEAP_LIN_ADDR( pClassEntry->wNext );
|
|
if (!classPtr) return FALSE;
|
|
|
|
pClassEntry->hInst = classPtr->wc.hInstance;
|
|
pClassEntry->wNext = classPtr->hNext;
|
|
GlobalGetAtomName( classPtr->atomName, pClassEntry->szClassName,
|
|
sizeof(pClassEntry->szClassName) );
|
|
return TRUE;
|
|
}
|