Commit 09d1c52f authored by Alexandre Julliard's avatar Alexandre Julliard

user32: Move 16-bit resource functions to user16.c.

parent a7adbf78
......@@ -26,9 +26,6 @@
#include "winerror.h"
#include "winternl.h"
#include "winnls.h"
#include "wine/winbase16.h"
#include "wine/winuser16.h"
#include "wownt32.h"
#include "wine/debug.h"
#include "user_private.h"
......@@ -53,24 +50,6 @@ struct accelerator
};
/**********************************************************************
* LoadAccelerators [USER.177]
*/
HACCEL16 WINAPI LoadAccelerators16(HINSTANCE16 instance, LPCSTR lpTableName)
{
HRSRC16 hRsrc;
TRACE_(accel)("%04x %s\n", instance, debugstr_a(lpTableName) );
if (!(hRsrc = FindResource16( instance, lpTableName, (LPSTR)RT_ACCELERATOR ))) {
WARN_(accel)("couldn't find accelerator table resource\n");
return 0;
}
TRACE_(accel)("returning HACCEL 0x%x\n", hRsrc);
return LoadResource16(instance,hRsrc);
}
/**********************************************************************
* LoadAcceleratorsW (USER32.@)
*/
HACCEL WINAPI LoadAcceleratorsW(HINSTANCE instance, LPCWSTR name)
......@@ -254,51 +233,6 @@ BOOL WINAPI DestroyAcceleratorTable( HACCEL handle )
}
/**********************************************************************
* LoadString (USER.176)
*/
INT16 WINAPI LoadString16( HINSTANCE16 instance, UINT16 resource_id,
LPSTR buffer, INT16 buflen )
{
HGLOBAL16 hmem;
HRSRC16 hrsrc;
unsigned char *p;
int string_num;
int i;
TRACE("inst=%04x id=%04x buff=%p len=%d\n",
instance, resource_id, buffer, buflen);
hrsrc = FindResource16( instance, MAKEINTRESOURCEA((resource_id>>4)+1), (LPSTR)RT_STRING );
if (!hrsrc) return 0;
hmem = LoadResource16( instance, hrsrc );
if (!hmem) return 0;
p = LockResource16(hmem);
string_num = resource_id & 0x000f;
for (i = 0; i < string_num; i++)
p += *p + 1;
TRACE("strlen = %d\n", (int)*p );
if (buffer == NULL) return *p;
i = min(buflen - 1, *p);
if (i > 0) {
memcpy(buffer, p + 1, i);
buffer[i] = '\0';
} else {
if (buflen > 1) {
buffer[0] = '\0';
return 0;
}
WARN("Don't know why caller gave buflen=%d *p=%d trying to obtain string '%s'\n", buflen, *p, p + 1);
}
FreeResource16( hmem );
TRACE("'%s' loaded !\n", buffer);
return i;
}
/**********************************************************************
* LoadStringW (USER32.@)
*/
INT WINAPI LoadStringW( HINSTANCE instance, UINT resource_id,
......
......@@ -612,6 +612,85 @@ HBITMAP16 WINAPI LoadBitmap16(HINSTANCE16 hInstance, LPCSTR name)
return HBITMAP_16(LoadBitmapA(HINSTANCE_32(hInstance), name));
}
/**********************************************************************
* LoadString (USER.176)
*/
INT16 WINAPI LoadString16( HINSTANCE16 instance, UINT16 resource_id, LPSTR buffer, INT16 buflen )
{
HGLOBAL16 hmem;
HRSRC16 hrsrc;
unsigned char *p;
int string_num;
int ret;
TRACE("inst=%04x id=%04x buff=%p len=%d\n", instance, resource_id, buffer, buflen);
hrsrc = FindResource16( instance, MAKEINTRESOURCEA((resource_id>>4)+1), (LPSTR)RT_STRING );
if (!hrsrc) return 0;
hmem = LoadResource16( instance, hrsrc );
if (!hmem) return 0;
p = LockResource16(hmem);
string_num = resource_id & 0x000f;
while (string_num--) p += *p + 1;
if (buffer == NULL) ret = *p;
else
{
ret = min(buflen - 1, *p);
if (ret > 0)
{
memcpy(buffer, p + 1, ret);
buffer[ret] = '\0';
}
else if (buflen > 1)
{
buffer[0] = '\0';
ret = 0;
}
TRACE( "%s loaded\n", debugstr_a(buffer));
}
FreeResource16( hmem );
return ret;
}
/**********************************************************************
* LoadAccelerators (USER.177)
*/
HACCEL16 WINAPI LoadAccelerators16(HINSTANCE16 instance, LPCSTR lpTableName)
{
HRSRC16 hRsrc;
HGLOBAL16 hMem;
ACCEL16 *table16;
HACCEL ret = 0;
TRACE("%04x %s\n", instance, debugstr_a(lpTableName) );
if (!(hRsrc = FindResource16( instance, lpTableName, (LPSTR)RT_ACCELERATOR )) ||
!(hMem = LoadResource16(instance,hRsrc)))
{
WARN("couldn't find %04x %s\n", instance, debugstr_a(lpTableName));
return 0;
}
if ((table16 = LockResource16( hMem )))
{
DWORD i, count = SizeofResource16( instance, hRsrc ) / sizeof(*table16);
ACCEL *table = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*table) );
if (table)
{
for (i = 0; i < count; i++)
{
table[i].fVirt = table16[i].fVirt & 0x7f;
table[i].key = table16[i].key;
table[i].cmd = table16[i].cmd;
}
ret = CreateAcceleratorTableA( table, count );
HeapFree( GetProcessHeap(), 0, table );
}
}
FreeResource16( hMem );
return HACCEL_16(ret);
}
/***********************************************************************
* GetSystemMetrics (USER.179)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment