user32: Move the 16-bit menu functions to user16.c.

This commit is contained in:
Alexandre Julliard 2009-12-17 15:04:21 +01:00
parent 8494682f2d
commit 15000f32b6
3 changed files with 114 additions and 89 deletions

View File

@ -51,9 +51,6 @@
#include "winbase.h" #include "winbase.h"
#include "wingdi.h" #include "wingdi.h"
#include "winnls.h" #include "winnls.h"
#include "wine/winbase16.h"
#include "wine/winuser16.h"
#include "wownt32.h"
#include "wine/server.h" #include "wine/server.h"
#include "wine/unicode.h" #include "wine/unicode.h"
#include "wine/exception.h" #include "wine/exception.h"
@ -2132,10 +2129,10 @@ static MENUITEM *MENU_InsertItem( HMENU hMenu, UINT pos, UINT flags )
* *
* NOTE: flags is equivalent to the mtOption field * NOTE: flags is equivalent to the mtOption field
*/ */
static LPCSTR MENU_ParseResource( LPCSTR res, HMENU hMenu, BOOL unicode ) static LPCSTR MENU_ParseResource( LPCSTR res, HMENU hMenu )
{ {
WORD flags, id = 0; WORD flags, id = 0;
LPCSTR str; LPCWSTR str;
BOOL end_flag; BOOL end_flag;
do do
@ -2150,23 +2147,18 @@ static LPCSTR MENU_ParseResource( LPCSTR res, HMENU hMenu, BOOL unicode )
id = GET_WORD(res); id = GET_WORD(res);
res += sizeof(WORD); res += sizeof(WORD);
} }
str = res; str = (LPCWSTR)res;
if (!unicode) res += strlen(str) + 1; res += (strlenW(str) + 1) * sizeof(WCHAR);
else res += (strlenW((LPCWSTR)str) + 1) * sizeof(WCHAR);
if (flags & MF_POPUP) if (flags & MF_POPUP)
{ {
HMENU hSubMenu = CreatePopupMenu(); HMENU hSubMenu = CreatePopupMenu();
if (!hSubMenu) return NULL; if (!hSubMenu) return NULL;
if (!(res = MENU_ParseResource( res, hSubMenu, unicode ))) if (!(res = MENU_ParseResource( res, hSubMenu ))) return NULL;
return NULL; AppendMenuW( hMenu, flags, (UINT_PTR)hSubMenu, str );
if (!unicode) AppendMenuA( hMenu, flags, (UINT_PTR)hSubMenu, str );
else AppendMenuW( hMenu, flags, (UINT_PTR)hSubMenu, (LPCWSTR)str );
} }
else /* Not a popup */ else /* Not a popup */
{ {
if (!unicode) AppendMenuA( hMenu, flags, id, *str ? str : NULL ); AppendMenuW( hMenu, flags, id, *str ? str : NULL );
else AppendMenuW( hMenu, flags, id,
*(LPCWSTR)str ? (LPCWSTR)str : NULL );
} }
} while (!end_flag); } while (!end_flag);
return res; return res;
@ -3791,7 +3783,7 @@ static void MENU_mnu2mnuii( UINT flags, UINT_PTR id, LPCWSTR str,
pmii->dwTypeData = (LPWSTR)str; pmii->dwTypeData = (LPWSTR)str;
} else if( flags & MFT_BITMAP){ } else if( flags & MFT_BITMAP){
pmii->fMask |= MIIM_BITMAP | MIIM_STRING; pmii->fMask |= MIIM_BITMAP | MIIM_STRING;
pmii->hbmpItem = HBITMAP_32(LOWORD(str)); pmii->hbmpItem = ULongToHandle(LOWORD(str));
} }
if( flags & MF_OWNERDRAW){ if( flags & MF_OWNERDRAW){
pmii->fMask |= MIIM_DATA; pmii->fMask |= MIIM_DATA;
@ -4326,39 +4318,6 @@ BOOL WINAPI EndMenu(void)
} }
/***********************************************************************
* LookupMenuHandle (USER.217)
*/
HMENU16 WINAPI LookupMenuHandle16( HMENU16 hmenu, INT16 id )
{
HMENU hmenu32 = HMENU_32(hmenu);
UINT id32 = id;
if (!MENU_FindItem( &hmenu32, &id32, MF_BYCOMMAND )) return 0;
else return HMENU_16(hmenu32);
}
/**********************************************************************
* LoadMenu (USER.150)
*/
HMENU16 WINAPI LoadMenu16( HINSTANCE16 instance, LPCSTR name )
{
HRSRC16 hRsrc;
HGLOBAL16 handle;
HMENU16 hMenu;
if (HIWORD(name) && name[0] == '#') name = ULongToPtr(atoi( name + 1 ));
if (!name) return 0;
instance = GetExePtr( instance );
if (!(hRsrc = FindResource16( instance, name, (LPSTR)RT_MENU ))) return 0;
if (!(handle = LoadResource16( instance, hRsrc ))) return 0;
hMenu = LoadMenuIndirect16(LockResource16(handle));
FreeResource16( handle );
return hMenu;
}
/***************************************************************** /*****************************************************************
* LoadMenuA (USER32.@) * LoadMenuA (USER32.@)
*/ */
@ -4381,35 +4340,6 @@ HMENU WINAPI LoadMenuW( HINSTANCE instance, LPCWSTR name )
} }
/**********************************************************************
* LoadMenuIndirect (USER.220)
*/
HMENU16 WINAPI LoadMenuIndirect16( LPCVOID template )
{
HMENU hMenu;
WORD version, offset;
LPCSTR p = template;
TRACE("(%p)\n", template );
version = GET_WORD(p);
p += sizeof(WORD);
if (version)
{
WARN("version must be 0 for Win16\n" );
return 0;
}
offset = GET_WORD(p);
p += sizeof(WORD) + offset;
if (!(hMenu = CreateMenu())) return 0;
if (!MENU_ParseResource( p, hMenu, FALSE ))
{
DestroyMenu( hMenu );
return 0;
}
return HMENU_16(hMenu);
}
/********************************************************************** /**********************************************************************
* LoadMenuIndirectW (USER32.@) * LoadMenuIndirectW (USER32.@)
*/ */
@ -4428,7 +4358,7 @@ HMENU WINAPI LoadMenuIndirectW( LPCVOID template )
offset = GET_WORD(p); offset = GET_WORD(p);
p += sizeof(WORD) + offset; p += sizeof(WORD) + offset;
if (!(hMenu = CreateMenu())) return 0; if (!(hMenu = CreateMenu())) return 0;
if (!MENU_ParseResource( p, hMenu, TRUE )) if (!MENU_ParseResource( p, hMenu ))
{ {
DestroyMenu( hMenu ); DestroyMenu( hMenu );
return 0; return 0;
@ -4784,7 +4714,7 @@ static BOOL MENU_NormalizeMenuItemInfoStruct( const MENUITEMINFOW *pmii_in,
pmii_out->fMask |= MIIM_STRING; pmii_out->fMask |= MIIM_STRING;
} else if( (pmii_out->fType) & MFT_BITMAP){ } else if( (pmii_out->fType) & MFT_BITMAP){
pmii_out->fMask |= MIIM_BITMAP; pmii_out->fMask |= MIIM_BITMAP;
pmii_out->hbmpItem = HBITMAP_32(LOWORD(pmii_out->dwTypeData)); pmii_out->hbmpItem = UlongToHandle(LOWORD(pmii_out->dwTypeData));
} }
} }
return TRUE; return TRUE;

View File

@ -190,6 +190,15 @@ BOOL16 WINAPI GetCursorPos16( POINT16 *pt )
} }
/*******************************************************************
* AnyPopup (USER.52)
*/
BOOL16 WINAPI AnyPopup16(void)
{
return AnyPopup();
}
/*********************************************************************** /***********************************************************************
* SetCursor (USER.69) * SetCursor (USER.69)
*/ */
@ -510,6 +519,27 @@ INT16 WINAPI GetClipboardFormatName16( UINT16 id, LPSTR buffer, INT16 maxlen )
} }
/**********************************************************************
* LoadMenu (USER.150)
*/
HMENU16 WINAPI LoadMenu16( HINSTANCE16 instance, LPCSTR name )
{
HRSRC16 hRsrc;
HGLOBAL16 handle;
HMENU16 hMenu;
if (HIWORD(name) && name[0] == '#') name = ULongToPtr(atoi( name + 1 ));
if (!name) return 0;
instance = GetExePtr( instance );
if (!(hRsrc = FindResource16( instance, name, (LPSTR)RT_MENU ))) return 0;
if (!(handle = LoadResource16( instance, hRsrc ))) return 0;
hMenu = LoadMenuIndirect16(LockResource16(handle));
FreeResource16( handle );
return hMenu;
}
/********************************************************************** /**********************************************************************
* CreateMenu (USER.151) * CreateMenu (USER.151)
*/ */
@ -869,6 +899,80 @@ DWORD WINAPI UserSeeUserDo16(WORD wReqType, WORD wParam1, WORD wParam2, WORD wPa
} }
/***********************************************************************
* LookupMenuHandle (USER.217)
*/
HMENU16 WINAPI LookupMenuHandle16( HMENU16 hmenu, INT16 id )
{
FIXME( "%04x %04x: stub\n", hmenu, id );
return hmenu;
}
static LPCSTR parse_menu_resource( LPCSTR res, HMENU hMenu )
{
WORD flags, id = 0;
LPCSTR str;
BOOL end_flag;
do
{
flags = GET_WORD(res);
end_flag = flags & MF_END;
/* Remove MF_END because it has the same value as MF_HILITE */
flags &= ~MF_END;
res += sizeof(WORD);
if (!(flags & MF_POPUP))
{
id = GET_WORD(res);
res += sizeof(WORD);
}
str = res;
res += strlen(str) + 1;
if (flags & MF_POPUP)
{
HMENU hSubMenu = CreatePopupMenu();
if (!hSubMenu) return NULL;
if (!(res = parse_menu_resource( res, hSubMenu ))) return NULL;
AppendMenuA( hMenu, flags, (UINT_PTR)hSubMenu, str );
}
else /* Not a popup */
{
AppendMenuA( hMenu, flags, id, *str ? str : NULL );
}
} while (!end_flag);
return res;
}
/**********************************************************************
* LoadMenuIndirect (USER.220)
*/
HMENU16 WINAPI LoadMenuIndirect16( LPCVOID template )
{
HMENU hMenu;
WORD version, offset;
LPCSTR p = template;
TRACE("(%p)\n", template );
version = GET_WORD(p);
p += sizeof(WORD);
if (version)
{
WARN("version must be 0 for Win16\n" );
return 0;
}
offset = GET_WORD(p);
p += sizeof(WORD) + offset;
if (!(hMenu = CreateMenu())) return 0;
if (!parse_menu_resource( p, hMenu ))
{
DestroyMenu( hMenu );
return 0;
}
return HMENU_16(hMenu);
}
/************************************************************************* /*************************************************************************
* ScrollDC (USER.221) * ScrollDC (USER.221)
*/ */

View File

@ -3081,15 +3081,6 @@ BOOL WINAPI EnumChildWindows( HWND parent, WNDENUMPROC func, LPARAM lParam )
} }
/*******************************************************************
* AnyPopup (USER.52)
*/
BOOL16 WINAPI AnyPopup16(void)
{
return AnyPopup();
}
/******************************************************************* /*******************************************************************
* AnyPopup (USER32.@) * AnyPopup (USER32.@)
*/ */