Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
75c297f2
Commit
75c297f2
authored
Apr 30, 2022
by
Jacek Caban
Committed by
Alexandre Julliard
May 02, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user32: Perform Unicode conversion in InsertMenuItemA.
Signed-off-by:
Jacek Caban
<
jacek@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
d5a36778
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
31 deletions
+27
-31
menu.c
dlls/user32/menu.c
+27
-31
No files found.
dlls/user32/menu.c
View file @
75c297f2
...
...
@@ -127,7 +127,7 @@ static BOOL fEndMenu = FALSE;
DWORD
WINAPI
DrawMenuBarTemp
(
HWND
hwnd
,
HDC
hDC
,
LPRECT
lprect
,
HMENU
hMenu
,
HFONT
hFont
);
static
BOOL
SetMenuItemInfo_common
(
MENUITEM
*
,
const
MENUITEMINFOW
*
,
BOOL
);
static
BOOL
SetMenuItemInfo_common
(
MENUITEM
*
,
const
MENUITEMINFOW
*
);
static
BOOL
is_win_menu_disallowed
(
HWND
hwnd
)
{
...
...
@@ -3895,7 +3895,7 @@ BOOL WINAPI InsertMenuW( HMENU hMenu, UINT pos, UINT flags,
mii
.
fMask
|=
MIIM_CHECKMARKS
;
item
=
&
menu
->
items
[
newpos
];
ret
=
SetMenuItemInfo_common
(
item
,
&
mii
,
TRUE
);
ret
=
SetMenuItemInfo_common
(
item
,
&
mii
);
if
(
!
ret
)
RemoveMenu
(
hMenu
,
pos
,
flags
);
release_menu_ptr
(
menu
);
...
...
@@ -4032,7 +4032,7 @@ BOOL WINAPI ModifyMenuW( HMENU hMenu, UINT pos, UINT flags,
}
menu
->
Height
=
0
;
/* force size recalculate */
MENU_mnu2mnuii
(
flags
,
id
,
str
,
&
mii
);
ret
=
SetMenuItemInfo_common
(
&
menu
->
items
[
item_pos
],
&
mii
,
TRUE
);
ret
=
SetMenuItemInfo_common
(
&
menu
->
items
[
item_pos
],
&
mii
);
release_menu_ptr
(
menu
);
return
ret
;
}
...
...
@@ -4654,26 +4654,6 @@ BOOL WINAPI GetMenuItemInfoW( HMENU hmenu, UINT item, BOOL bypos,
}
/* set a menu item text from an ANSI or Unicode string */
static
inline
void
set_menu_item_text
(
MENUITEM
*
menu
,
LPCWSTR
text
,
BOOL
unicode
)
{
if
(
!
text
)
menu
->
text
=
NULL
;
else
if
(
unicode
)
{
if
((
menu
->
text
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
lstrlenW
(
text
)
+
1
)
*
sizeof
(
WCHAR
)
)))
lstrcpyW
(
menu
->
text
,
text
);
}
else
{
LPCSTR
str
=
(
LPCSTR
)
text
;
int
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
str
,
-
1
,
NULL
,
0
);
if
((
menu
->
text
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
*
sizeof
(
WCHAR
)
)))
MultiByteToWideChar
(
CP_ACP
,
0
,
str
,
-
1
,
menu
->
text
,
len
);
}
}
/**********************************************************************
* MENU_depth
*
...
...
@@ -4709,9 +4689,7 @@ static int MENU_depth( POPUPMENU *pmenu, int depth)
* MIIM_BITMAP and MIIM_STRING flags instead.
*/
static
BOOL
SetMenuItemInfo_common
(
MENUITEM
*
menu
,
const
MENUITEMINFOW
*
lpmii
,
BOOL
unicode
)
static
BOOL
SetMenuItemInfo_common
(
MENUITEM
*
menu
,
const
MENUITEMINFOW
*
lpmii
)
{
if
(
!
menu
)
return
FALSE
;
...
...
@@ -4722,9 +4700,13 @@ static BOOL SetMenuItemInfo_common(MENUITEM * menu,
menu
->
fType
|=
lpmii
->
fType
&
MENUITEMINFO_TYPE_MASK
;
}
if
(
lpmii
->
fMask
&
MIIM_STRING
)
{
const
WCHAR
*
text
=
lpmii
->
dwTypeData
;
/* free the string when used */
HeapFree
(
GetProcessHeap
(),
0
,
menu
->
text
);
set_menu_item_text
(
menu
,
lpmii
->
dwTypeData
,
unicode
);
if
(
!
text
)
menu
->
text
=
NULL
;
else
if
((
menu
->
text
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
lstrlenW
(
text
)
+
1
)
*
sizeof
(
WCHAR
)
)))
lstrcpyW
(
menu
->
text
,
text
);
}
if
(
lpmii
->
fMask
&
MIIM_STATE
)
...
...
@@ -4850,7 +4832,7 @@ BOOL WINAPI SetMenuItemInfoA(HMENU hmenu, UINT item, BOOL bypos,
if
(
item
==
SC_TASKLIST
&&
!
bypos
)
return
TRUE
;
return
FALSE
;
}
ret
=
SetMenuItemInfo_common
(
&
menu
->
items
[
pos
],
&
mii
,
TRUE
);
ret
=
SetMenuItemInfo_common
(
&
menu
->
items
[
pos
],
&
mii
);
release_menu_ptr
(
menu
);
HeapFree
(
GetProcessHeap
(),
0
,
strW
);
return
ret
;
...
...
@@ -4878,7 +4860,7 @@ BOOL WINAPI SetMenuItemInfoW(HMENU hmenu, UINT item, BOOL bypos,
return
FALSE
;
}
ret
=
SetMenuItemInfo_common
(
&
menu
->
items
[
pos
],
&
mii
,
TRUE
);
ret
=
SetMenuItemInfo_common
(
&
menu
->
items
[
pos
],
&
mii
);
release_menu_ptr
(
menu
);
return
ret
;
}
...
...
@@ -4931,6 +4913,7 @@ UINT WINAPI GetMenuDefaultItem(HMENU hmenu, UINT bypos, UINT flags)
BOOL
WINAPI
InsertMenuItemA
(
HMENU
hMenu
,
UINT
uItem
,
BOOL
bypos
,
const
MENUITEMINFOA
*
lpmii
)
{
WCHAR
*
strW
=
NULL
;
MENUITEMINFOW
mii
;
POPUPMENU
*
menu
;
UINT
pos
;
...
...
@@ -4940,11 +4923,24 @@ BOOL WINAPI InsertMenuItemA(HMENU hMenu, UINT uItem, BOOL bypos,
if
(
!
MENU_NormalizeMenuItemInfoStruct
(
(
const
MENUITEMINFOW
*
)
lpmii
,
&
mii
))
return
FALSE
;
if
((
mii
.
fMask
&
MIIM_STRING
)
&&
mii
.
dwTypeData
)
{
const
char
*
str
=
(
const
char
*
)
mii
.
dwTypeData
;
UINT
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
str
,
-
1
,
NULL
,
0
);
if
(
!
(
strW
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
*
sizeof
(
WCHAR
)
)))
return
FALSE
;
MultiByteToWideChar
(
CP_ACP
,
0
,
str
,
-
1
,
strW
,
len
);
mii
.
dwTypeData
=
strW
;
}
if
(
!
(
menu
=
insert_menu_item
(
hMenu
,
uItem
,
bypos
?
MF_BYPOSITION
:
0
,
&
pos
)))
{
HeapFree
(
GetProcessHeap
(),
0
,
strW
);
return
FALSE
;
}
ret
=
SetMenuItemInfo_common
(
&
menu
->
items
[
pos
],
&
mii
,
FALSE
);
ret
=
SetMenuItemInfo_common
(
&
menu
->
items
[
pos
],
&
mii
);
release_menu_ptr
(
menu
);
HeapFree
(
GetProcessHeap
(),
0
,
strW
);
return
ret
;
}
...
...
@@ -4967,7 +4963,7 @@ BOOL WINAPI InsertMenuItemW(HMENU hMenu, UINT uItem, BOOL bypos,
if
(
!
(
menu
=
insert_menu_item
(
hMenu
,
uItem
,
bypos
?
MF_BYPOSITION
:
0
,
&
pos
)))
return
FALSE
;
ret
=
SetMenuItemInfo_common
(
&
menu
->
items
[
pos
],
&
mii
,
TRUE
);
ret
=
SetMenuItemInfo_common
(
&
menu
->
items
[
pos
],
&
mii
);
release_menu_ptr
(
menu
);
return
ret
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment