wine/windows/property.c
Alexandre Julliard 02e90087ff Release 980104
Sat Jan  3 17:15:56 1998  Alexandre Julliard  <julliard@lrc.epfl.ch>

	* [debugger/db_disasm.c]
	Added cpuid and cmpxchg instructions.

	* [if1632/builtin.c] [relay32/builtin32.c]
	Fixed broken -dll option with Win32 DLLs.

	* [include/heap.h]
	Added SYSTEM_LOCK/SYSTEM_UNLOCK macros.

	* [configure.in] [misc/lstr.c]
	Added check for wctype.h.
	Commented out --enable-ipc option (IPC code has been broken for a
	long time anyway).

	* [scheduler/critsection.c] [scheduler/event.c]
	  [scheduler/mutex.c] [scheduler/semaphore.c]
	Implemented Win32 synchronization objects.

	* [scheduler/synchro.c]
	Implemented WaitForMultipleObjects and related functions.

	* [scheduler/thread.c]
	If possible, use clone() in CreateThread().

	* [scheduler/thread.c] [scheduler/process.c]
	Made thread and process waitable objects.
	Thread and process id values are now different from the pointers
	they represent.

	* [win32/k32obj.c]
	Moved to scheduler directory.
	Added function table for waiting operations on objects.

	* [files/file.c] [memory/virtual.c]
	Added new K32OBJ function table.

Sun Jan  1 16:48:23 1997  Andreas Mohr <100.30936@germany.net>

	* [files/file.c]
	Fixed my patch for GetTempFileName16() as needed.
	It was ...Name32A() that didn't work properly, not ...Name16().

	* [graphics/x11drv/brush.c]
	Fixed a BadMatch error.

	* [msdos/int21.c]
	Fixed INT21_FindNextFCB() to get correct volume labels e.g.
	in "file open" dialog.

	* [multimedia/joystick.c] [relay32/winmm.spec]
	Stub JoyGetPosEx().

	* [scheduler/process.c] [relay32/kernel32.spec]
	Implemented RegisterServiceProcess().

Wed Dec 31 11:14:43 1997  Lawson Whitney  <lawson_whitney@juno.com>

	* [if1632/kernel.spec] [if1632/relay.c]
	Define CallProcEx32w - Thanks to Marcus Meissner for his excellent
	CallProc32W.

	* [loader/module.c]
	Take a shot at defining FreeLibrary32W.

Sun Dec 28 12:44:04 1997  Kai Morich <kai.morich@rhein-neckar.netsurf.de>

	* [controls/menu.c]
	Menu modification from WM_INITMENUPOPUP message fixed.
	Menu items now can have different wID and hSubMenu (Win95 behavior).

	* [misc/cpu.c]
	Improved IsProcessorFeaturePresent.

Sun Dec 28 03:21:08 1997  Ove Kaaven <ovek@main.arcticnet.no>

	* [include/winsock.h] [misc/winsock.c]
	Fixed WS_SOL_SOCKET for setsockopt(), and made select() return
	empty fd_sets if timeout.

	* [objects/palette.c]
	AnimatePalette() bailed out if entire palette is animated. Fixed.

	* [objects/dib.c]
	Added some code to SetDIBitsToDevice() and its helpers to fix
	some offseting problems.

	* [objects/cursoricon.c]
	Made CreateCursor32() convert the instance handle properly. Made
	DestroyCursor() return correct success status.

Wed Dec 24 17:56:34 1997  Dimitrie O. Paun  <dimi@cs.toronto.edu>

	* [windows/syscolor.c]
	Added definition of GetSysColorPen16/32. This function does not
	exist in the Win32 API but is a very close (and natural) relative
	to GetSysColorBrush function. Moreover, it is *very* much used 
	within Wine since there are a lot of places where we need to draw
	lines with the standard colors.

	* [controls/button.c] [controls/combo.c] [controls/icontitle.c]
	  [controls/menu.c] [controls/progress.c] [controls/scroll.c]
	  [controls/updown.c] [graphics/painting.c] [misc/tweak.c]
	  [windows/defwnd.c] [windows/graphics.c] [windows/nonclient.c]
	Replaced references to sysColorObjects with the appropriate
	call to GetSysColorBrush32/GetSysColorPen32. There is no need to
	expose the implementation of these functions, even within Wine.
	This makes the code easier to understand, debug, maintain.

	* [controls/uitools.c]
	Modified most of the functions in this file to use the now
	standard pens (i.e. GetSysColorPen32). These functions made
	*heavy* use of standard pens so I expect a lot less
	CreatePen/DeleteObject calls can do only good...:)
	Plus some minor modifications (*no* functional changes though).

	* [controls/updown.c]
	Used the new DrawFrameControl32 function to paint the control.
	I also deleted UDDOWN_DrawArrow since it was no longer required.

Tue Dec 23 00:03:33 1997  Steinar Hamre  <steinarh@stud.fim.ntnu.no>

	* [configure.in]
	Added check for -lw.

	* [include/wintypes.h] [tools/build.c]
	Changes to make the assembly understandable for even sun as.
	".ascii" -> ".string", "call %foo" -> "call *%foo",
	"pushw/popw %[cdes]s" written out to ".byte 0x66\npushl/popl %[cdes]s".

	* [memory/ldt.c]
	#ifdef added so <sys/seg.h> will not be included on Solaris.

Mon Dec 22 18:55:19 1997  Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>

	* [configure.in]
	Added XF86DGA check.

	* [multimedia/dsound.c][relay32/dsound.spec][include/dsound.h]
	Started DirectSound. Only stubs for now.

	* [graphics/ddraw.c][include/ddraw.h][relay32/ddraw.spec]
	Started to implement DirectDraw. Mostly stubs, some
	testcases work. Requires the XF86DGA extension to XFree86.
	(check demo/blizdemo.exe from the Diablo CD-ROM).

	* [files/drive.c]
	Return correct "CDFS" fsname so Diablo is a bit happier.

Sun Dec 21 21:45:48 1997  Kevin Cozens <kcozens@interlog.com>

	* [misc/registry.c]
	Fixed bugs in the routines which read the Windows '95 registry
	files. Added extra information regarding the format of the Windows
	'95 registry files.
1998-01-04 17:49:09 +00:00

361 lines
9.9 KiB
C

/*
* Window properties
*
* Copyright 1995, 1996 Alexandre Julliard
*/
#include <string.h>
#include "win.h"
#include "heap.h"
#include "stddebug.h"
#include "debug.h"
typedef struct tagPROPERTY
{
struct tagPROPERTY *next; /* Next property in window list */
HANDLE32 handle; /* User's data */
LPSTR string; /* Property string (or atom) */
} PROPERTY;
/***********************************************************************
* PROP_FindProp
*/
static PROPERTY *PROP_FindProp( HWND32 hwnd, LPCSTR str )
{
ATOM atom;
PROPERTY *prop;
WND *pWnd = WIN_FindWndPtr( hwnd );
if (!pWnd) return NULL;
if (HIWORD(str))
{
atom = GlobalFindAtom32A( str );
for (prop = pWnd->pProp; prop; prop = prop->next)
{
if (HIWORD(prop->string))
{
if (!lstrcmpi32A( prop->string, str )) return prop;
}
else if (LOWORD(prop->string) == atom) return prop;
}
}
else /* atom */
{
atom = LOWORD(str);
for (prop = pWnd->pProp; (prop); prop = prop->next)
{
if (HIWORD(prop->string))
{
if (GlobalFindAtom32A( prop->string ) == atom) return prop;
}
else if (LOWORD(prop->string) == atom) return prop;
}
}
return NULL;
}
/***********************************************************************
* GetProp16 (USER.25)
*/
HANDLE16 WINAPI GetProp16( HWND16 hwnd, LPCSTR str )
{
return (HANDLE16)GetProp32A( hwnd, str );
}
/***********************************************************************
* GetProp32A (USER32.280)
*/
HANDLE32 WINAPI GetProp32A( HWND32 hwnd, LPCSTR str )
{
PROPERTY *prop = PROP_FindProp( hwnd, str );
if (HIWORD(str))
dprintf_prop( stddeb, "GetProp(%08x,'%s'): returning %08x\n",
hwnd, str, prop ? prop->handle : 0 );
else
dprintf_prop( stddeb, "GetProp(%08x,#%04x): returning %08x\n",
hwnd, LOWORD(str), prop ? prop->handle : 0 );
return prop ? prop->handle : 0;
}
/***********************************************************************
* GetProp32W (USER32.281)
*/
HANDLE32 WINAPI GetProp32W( HWND32 hwnd, LPCWSTR str )
{
LPSTR strA;
HANDLE32 ret;
if (!HIWORD(str)) return GetProp32A( hwnd, (LPCSTR)(UINT32)LOWORD(str) );
strA = HEAP_strdupWtoA( GetProcessHeap(), 0, str );
ret = GetProp32A( hwnd, strA );
HeapFree( GetProcessHeap(), 0, strA );
return ret;
}
/***********************************************************************
* SetProp16 (USER.26)
*/
BOOL16 WINAPI SetProp16( HWND16 hwnd, LPCSTR str, HANDLE16 handle )
{
return (BOOL16)SetProp32A( hwnd, str, handle );
}
/***********************************************************************
* SetProp32A (USER32.496)
*/
BOOL32 WINAPI SetProp32A( HWND32 hwnd, LPCSTR str, HANDLE32 handle )
{
PROPERTY *prop;
if (HIWORD(str))
dprintf_prop( stddeb, "SetProp: %04x '%s' %08x\n", hwnd, str, handle );
else
dprintf_prop( stddeb, "SetProp: %04x #%04x %08x\n",
hwnd, LOWORD(str), handle );
if (!(prop = PROP_FindProp( hwnd, str )))
{
/* We need to create it */
WND *pWnd = WIN_FindWndPtr( hwnd );
if (!pWnd) return FALSE;
if (!(prop = HeapAlloc( SystemHeap, 0, sizeof(*prop) ))) return FALSE;
if (!(prop->string = SEGPTR_STRDUP(str)))
{
HeapFree( SystemHeap, 0, prop );
return FALSE;
}
prop->next = pWnd->pProp;
pWnd->pProp = prop;
}
prop->handle = handle;
return TRUE;
}
/***********************************************************************
* SetProp32W (USER32.497)
*/
BOOL32 WINAPI SetProp32W( HWND32 hwnd, LPCWSTR str, HANDLE32 handle )
{
BOOL32 ret;
LPSTR strA;
if (!HIWORD(str))
return SetProp32A( hwnd, (LPCSTR)(UINT32)LOWORD(str), handle );
strA = HEAP_strdupWtoA( GetProcessHeap(), 0, str );
ret = SetProp32A( hwnd, strA, handle );
HeapFree( GetProcessHeap(), 0, strA );
return ret;
}
/***********************************************************************
* RemoveProp16 (USER.24)
*/
HANDLE16 WINAPI RemoveProp16( HWND16 hwnd, LPCSTR str )
{
return (HANDLE16)RemoveProp32A( hwnd, str );
}
/***********************************************************************
* RemoveProp32A (USER32.441)
*/
HANDLE32 WINAPI RemoveProp32A( HWND32 hwnd, LPCSTR str )
{
ATOM atom;
HANDLE32 handle;
PROPERTY **pprop, *prop;
WND *pWnd = WIN_FindWndPtr( hwnd );
if (HIWORD(str))
dprintf_prop( stddeb, "RemoveProp: %04x '%s'\n", hwnd, str );
else
dprintf_prop( stddeb, "RemoveProp: %04x #%04x\n", hwnd, LOWORD(str));
if (!pWnd) return NULL;
if (HIWORD(str))
{
atom = GlobalFindAtom32A( str );
for (pprop=(PROPERTY**)&pWnd->pProp; (*pprop); pprop = &(*pprop)->next)
{
if (HIWORD((*pprop)->string))
{
if (!lstrcmpi32A( (*pprop)->string, str )) break;
}
else if (LOWORD((*pprop)->string) == atom) break;
}
}
else /* atom */
{
atom = LOWORD(str);
for (pprop=(PROPERTY**)&pWnd->pProp; (*pprop); pprop = &(*pprop)->next)
{
if (HIWORD((*pprop)->string))
{
if (GlobalFindAtom32A( (*pprop)->string ) == atom) break;
}
else if (LOWORD((*pprop)->string) == atom) break;
}
}
if (!*pprop) return 0;
prop = *pprop;
handle = prop->handle;
*pprop = prop->next;
SEGPTR_FREE(prop->string);
HeapFree( SystemHeap, 0, prop );
return handle;
}
/***********************************************************************
* RemoveProp32W (USER32.442)
*/
HANDLE32 WINAPI RemoveProp32W( HWND32 hwnd, LPCWSTR str )
{
LPSTR strA;
HANDLE32 ret;
if (!HIWORD(str))
return RemoveProp32A( hwnd, (LPCSTR)(UINT32)LOWORD(str) );
strA = HEAP_strdupWtoA( GetProcessHeap(), 0, str );
ret = RemoveProp32A( hwnd, strA );
HeapFree( GetProcessHeap(), 0, strA );
return ret;
}
/***********************************************************************
* PROPERTY_RemoveWindowProps
*
* Remove all properties of a window.
*/
void PROPERTY_RemoveWindowProps( WND *pWnd )
{
PROPERTY *prop, *next;
for (prop = pWnd->pProp; (prop); prop = next)
{
next = prop->next;
SEGPTR_FREE( prop->string );
HeapFree( SystemHeap, 0, prop );
}
pWnd->pProp = NULL;
}
/***********************************************************************
* EnumProps16 (USER.27)
*/
INT16 WINAPI EnumProps16( HWND16 hwnd, PROPENUMPROC16 func )
{
PROPERTY *prop, *next;
WND *pWnd;
INT16 ret = -1;
dprintf_prop( stddeb, "EnumProps: %04x %08x\n", hwnd, (UINT32)func );
if (!(pWnd = WIN_FindWndPtr( hwnd ))) return -1;
for (prop = pWnd->pProp; (prop); prop = next)
{
/* Already get the next in case the callback */
/* function removes the current property. */
next = prop->next;
dprintf_prop( stddeb, " Callback: handle=%08x str='%s'\n",
prop->handle, prop->string );
ret = func( hwnd, SEGPTR_GET(prop->string), prop->handle );
if (!ret) break;
}
return ret;
}
/***********************************************************************
* EnumProps32A (USER32.185)
*/
INT32 WINAPI EnumProps32A( HWND32 hwnd, PROPENUMPROC32A func )
{
return EnumPropsEx32A( hwnd, (PROPENUMPROCEX32A)func, 0 );
}
/***********************************************************************
* EnumProps32W (USER32.188)
*/
INT32 WINAPI EnumProps32W( HWND32 hwnd, PROPENUMPROC32W func )
{
return EnumPropsEx32W( hwnd, (PROPENUMPROCEX32W)func, 0 );
}
/***********************************************************************
* EnumPropsEx32A (USER32.186)
*/
INT32 WINAPI EnumPropsEx32A(HWND32 hwnd, PROPENUMPROCEX32A func, LPARAM lParam)
{
PROPERTY *prop, *next;
WND *pWnd;
INT32 ret = -1;
dprintf_prop( stddeb, "EnumPropsEx32A: %04x %08x %08lx\n",
hwnd, (UINT32)func, lParam );
if (!(pWnd = WIN_FindWndPtr( hwnd ))) return -1;
for (prop = pWnd->pProp; (prop); prop = next)
{
/* Already get the next in case the callback */
/* function removes the current property. */
next = prop->next;
dprintf_prop( stddeb, " Callback: handle=%08x str='%s'\n",
prop->handle, prop->string );
ret = func( hwnd, prop->string, prop->handle, lParam );
if (!ret) break;
}
return ret;
}
/***********************************************************************
* EnumPropsEx32W (USER32.187)
*/
INT32 WINAPI EnumPropsEx32W(HWND32 hwnd, PROPENUMPROCEX32W func, LPARAM lParam)
{
PROPERTY *prop, *next;
WND *pWnd;
INT32 ret = -1;
dprintf_prop( stddeb, "EnumPropsEx32W: %04x %08x %08lx\n",
hwnd, (UINT32)func, lParam );
if (!(pWnd = WIN_FindWndPtr( hwnd ))) return -1;
for (prop = pWnd->pProp; (prop); prop = next)
{
/* Already get the next in case the callback */
/* function removes the current property. */
next = prop->next;
dprintf_prop( stddeb, " Callback: handle=%08x str='%s'\n",
prop->handle, prop->string );
if (HIWORD(prop->string))
{
LPWSTR str = HEAP_strdupAtoW( GetProcessHeap(), 0, prop->string );
ret = func( hwnd, str, prop->handle, lParam );
HeapFree( GetProcessHeap(), 0, str );
}
else
ret = func( hwnd, (LPCWSTR)(UINT32)LOWORD( prop->string ),
prop->handle, lParam );
if (!ret) break;
}
return ret;
}