Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
5693ecd2
Commit
5693ecd2
authored
Nov 26, 2003
by
Huw Davies
Committed by
Alexandre Julliard
Nov 26, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unicodification. Based on a patch by Aric Stewart.
parent
6ce99f23
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
268 additions
and
244 deletions
+268
-244
treeview.c
dlls/comctl32/treeview.c
+268
-244
No files found.
dlls/comctl32/treeview.c
View file @
5693ecd2
...
...
@@ -3,6 +3,7 @@
* Copyright 1998 Eric Kohl <ekohl@abo.rhein-zeitung.de>
* Copyright 1998,1999 Alex Priem <alexp@sci.kun.nl>
* Copyright 1999 Sylvain St-Germain
* Copyright 2002 CodeWeavers, Aric Stewart
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
...
...
@@ -57,6 +58,7 @@
#include "winnls.h"
#include "commctrl.h"
#include "comctl32.h"
#include "wine/unicode.h"
#include "wine/debug.h"
/* internal structures */
...
...
@@ -66,7 +68,7 @@ typedef struct _TREEITEM /* HTREEITEM is a _TREEINFO *. */
UINT
callbackMask
;
UINT
state
;
UINT
stateMask
;
LP
STR
pszText
;
LP
WSTR
pszText
;
int
cchTextMax
;
int
iImage
;
int
iSelectedImage
;
...
...
@@ -137,7 +139,6 @@ typedef struct tagTREEVIEW_INFO
BOOL
bLabelChanged
;
BOOL
bNtfUnicode
;
/* TRUE if should send NOTIFY with W */
BOOL
bUnicode
;
/* set by CCM_SETUNICODEFORMAT */
HIMAGELIST
himlNormal
;
int
normalImageHeight
;
int
normalImageWidth
;
...
...
@@ -149,7 +150,7 @@ typedef struct tagTREEVIEW_INFO
DWORD
lastKeyPressTimestamp
;
/* Added */
WPARAM
charCode
;
/* Added */
INT
nSearchParamLength
;
/* Added */
CHAR
szSearchParam
[
MAX_PATH
];
/* Added */
W
CHAR
szSearchParam
[
MAX_PATH
];
/* Added */
}
TREEVIEW_INFO
;
...
...
@@ -224,7 +225,7 @@ static void TREEVIEW_VerifyTree(TREEVIEW_INFO *infoPtr);
static
TREEVIEW_INFO
*
TREEVIEW_GetInfoPtr
(
HWND
hwnd
)
{
return
(
TREEVIEW_INFO
*
)
GetWindowLong
A
(
hwnd
,
0
);
return
(
TREEVIEW_INFO
*
)
GetWindowLong
W
(
hwnd
,
0
);
}
/* Don't call this. Nothing wants an item index. */
...
...
@@ -272,9 +273,9 @@ static const char *
TREEVIEW_ItemName
(
TREEVIEW_ITEM
*
item
)
{
if
(
item
==
NULL
)
return
"<null item>"
;
if
(
item
->
pszText
==
LPSTR_TEXTCALLBACK
A
)
return
"<callback>"
;
if
(
item
->
pszText
==
LPSTR_TEXTCALLBACK
W
)
return
"<callback>"
;
if
(
item
->
pszText
==
NULL
)
return
"<null>"
;
return
item
->
pszText
;
return
debugstr_w
(
item
->
pszText
)
;
}
/* An item is not a child of itself. */
...
...
@@ -457,7 +458,7 @@ TREEVIEW_SendSimpleNotify(TREEVIEW_INFO *infoPtr, UINT code)
TRACE
(
"%d
\n
"
,
code
);
nmhdr
.
hwndFrom
=
hwnd
;
nmhdr
.
idFrom
=
GetWindowLong
A
(
hwnd
,
GWL_ID
);
nmhdr
.
idFrom
=
GetWindowLong
W
(
hwnd
,
GWL_ID
);
nmhdr
.
code
=
get_notifycode
(
infoPtr
,
code
);
return
(
BOOL
)
TREEVIEW_SendRealNotify
(
infoPtr
,
...
...
@@ -465,33 +466,37 @@ TREEVIEW_SendSimpleNotify(TREEVIEW_INFO *infoPtr, UINT code)
}
static
VOID
TREEVIEW_TVItemFromItem
(
TREEVIEW_INFO
*
infoPtr
,
UINT
mask
,
TVITEM
A
*
tvItem
,
TREEVIEW_ITEM
*
item
)
TREEVIEW_TVItemFromItem
(
TREEVIEW_INFO
*
infoPtr
,
UINT
mask
,
TVITEM
W
*
tvItem
,
TREEVIEW_ITEM
*
item
)
{
tvItem
->
mask
=
mask
;
tvItem
->
hItem
=
item
;
tvItem
->
state
=
item
->
state
;
tvItem
->
stateMask
=
0
;
tvItem
->
iImage
=
item
->
iImage
;
tvItem
->
cchTextMax
=
item
->
cchTextMax
;
tvItem
->
iImage
=
item
->
iImage
;
tvItem
->
iSelectedImage
=
item
->
iSelectedImage
;
tvItem
->
cChildren
=
item
->
cChildren
;
tvItem
->
lParam
=
item
->
lParam
;
/* **** **** **** **** WARNING **** **** **** **** */
/* This control stores all the data in A format */
/* we will convert it to W if the notify format */
/* is Unicode. */
/* **** **** **** **** WARNING **** **** **** **** */
if
(
infoPtr
->
bNtfUnicode
)
{
INT
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
item
->
pszText
,
-
1
,
NULL
,
0
);
if
(
len
>
1
)
{
tvItem
->
pszText
=
(
LPSTR
)
Alloc
(
len
*
sizeof
(
WCHAR
));
MultiByteToWideChar
(
CP_ACP
,
0
,
item
->
pszText
,
-
1
,
(
LPWSTR
)
tvItem
->
pszText
,
len
*
sizeof
(
WCHAR
)
);
}
if
(
mask
&
TVIF_TEXT
)
{
if
(
!
infoPtr
->
bNtfUnicode
)
{
tvItem
->
cchTextMax
=
WideCharToMultiByte
(
CP_ACP
,
0
,
item
->
pszText
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
tvItem
->
pszText
=
Alloc
(
tvItem
->
cchTextMax
);
WideCharToMultiByte
(
CP_ACP
,
0
,
item
->
pszText
,
-
1
,
(
LPSTR
)
tvItem
->
pszText
,
tvItem
->
cchTextMax
,
0
,
0
);
}
else
{
tvItem
->
cchTextMax
=
item
->
cchTextMax
;
tvItem
->
pszText
=
item
->
pszText
;
}
}
else
{
tvItem
->
cchTextMax
=
0
;
tvItem
->
pszText
=
NULL
;
}
}
static
BOOL
...
...
@@ -499,7 +504,7 @@ TREEVIEW_SendTreeviewNotify(TREEVIEW_INFO *infoPtr, UINT code, UINT action,
UINT
mask
,
HTREEITEM
oldItem
,
HTREEITEM
newItem
)
{
HWND
hwnd
=
infoPtr
->
hwnd
;
NMTREEVIEW
A
nmhdr
;
NMTREEVIEW
W
nmhdr
;
BOOL
ret
;
TRACE
(
"code:%d action:%x olditem:%p newitem:%p
\n
"
,
...
...
@@ -508,7 +513,7 @@ TREEVIEW_SendTreeviewNotify(TREEVIEW_INFO *infoPtr, UINT code, UINT action,
ZeroMemory
(
&
nmhdr
,
sizeof
(
NMTREEVIEWA
));
nmhdr
.
hdr
.
hwndFrom
=
hwnd
;
nmhdr
.
hdr
.
idFrom
=
GetWindowLong
A
(
hwnd
,
GWL_ID
);
nmhdr
.
hdr
.
idFrom
=
GetWindowLong
W
(
hwnd
,
GWL_ID
);
nmhdr
.
hdr
.
code
=
get_notifycode
(
infoPtr
,
code
);
nmhdr
.
action
=
action
;
...
...
@@ -522,9 +527,10 @@ TREEVIEW_SendTreeviewNotify(TREEVIEW_INFO *infoPtr, UINT code, UINT action,
nmhdr
.
ptDrag
.
y
=
0
;
ret
=
(
BOOL
)
TREEVIEW_SendRealNotify
(
infoPtr
,
(
WPARAM
)
GetWindowLongA
(
hwnd
,
GWL_ID
)
,
(
WPARAM
)
nmhdr
.
hdr
.
idFrom
,
(
LPARAM
)
&
nmhdr
);
if
(
infoPtr
->
bNtfUnicode
)
{
if
(
!
infoPtr
->
bNtfUnicode
)
{
Free
(
nmhdr
.
itemOld
.
pszText
);
Free
(
nmhdr
.
itemNew
.
pszText
);
}
...
...
@@ -536,12 +542,12 @@ TREEVIEW_SendTreeviewDnDNotify(TREEVIEW_INFO *infoPtr, UINT code,
HTREEITEM
dragItem
,
POINT
pt
)
{
HWND
hwnd
=
infoPtr
->
hwnd
;
NMTREEVIEW
A
nmhdr
;
NMTREEVIEW
W
nmhdr
;
TRACE
(
"code:%d dragitem:%p
\n
"
,
code
,
dragItem
);
nmhdr
.
hdr
.
hwndFrom
=
hwnd
;
nmhdr
.
hdr
.
idFrom
=
GetWindowLong
A
(
hwnd
,
GWL_ID
);
nmhdr
.
hdr
.
idFrom
=
GetWindowLong
W
(
hwnd
,
GWL_ID
);
nmhdr
.
hdr
.
code
=
get_notifycode
(
infoPtr
,
code
);
nmhdr
.
action
=
0
;
nmhdr
.
itemNew
.
mask
=
TVIF_STATE
|
TVIF_PARAM
|
TVIF_HANDLE
;
...
...
@@ -553,7 +559,7 @@ TREEVIEW_SendTreeviewDnDNotify(TREEVIEW_INFO *infoPtr, UINT code,
nmhdr
.
ptDrag
.
y
=
pt
.
y
;
return
(
BOOL
)
TREEVIEW_SendRealNotify
(
infoPtr
,
(
WPARAM
)
GetWindowLongA
(
hwnd
,
GWL_ID
)
,
(
WPARAM
)
nmhdr
.
hdr
.
idFrom
,
(
LPARAM
)
&
nmhdr
);
}
...
...
@@ -570,7 +576,7 @@ TREEVIEW_SendCustomDrawNotify(TREEVIEW_INFO *infoPtr, DWORD dwDrawStage,
nmcd
=
&
nmcdhdr
.
nmcd
;
nmcd
->
hdr
.
hwndFrom
=
hwnd
;
nmcd
->
hdr
.
idFrom
=
GetWindowLong
A
(
hwnd
,
GWL_ID
);
nmcd
->
hdr
.
idFrom
=
GetWindowLong
W
(
hwnd
,
GWL_ID
);
nmcd
->
hdr
.
code
=
NM_CUSTOMDRAW
;
nmcd
->
dwDrawStage
=
dwDrawStage
;
nmcd
->
hdc
=
hdc
;
...
...
@@ -583,7 +589,7 @@ TREEVIEW_SendCustomDrawNotify(TREEVIEW_INFO *infoPtr, DWORD dwDrawStage,
nmcdhdr
.
iLevel
=
0
;
return
(
BOOL
)
TREEVIEW_SendRealNotify
(
infoPtr
,
(
WPARAM
)
GetWindowLongA
(
hwnd
,
GWL_ID
)
,
(
WPARAM
)
nmcd
->
hdr
.
idFrom
,
(
LPARAM
)
&
nmcdhdr
);
}
...
...
@@ -614,7 +620,7 @@ TREEVIEW_SendCustomDrawItemNotify(TREEVIEW_INFO *infoPtr, HDC hdc,
nmcd
=
&
nmcdhdr
.
nmcd
;
nmcd
->
hdr
.
hwndFrom
=
hwnd
;
nmcd
->
hdr
.
idFrom
=
GetWindowLong
A
(
hwnd
,
GWL_ID
);
nmcd
->
hdr
.
idFrom
=
GetWindowLong
W
(
hwnd
,
GWL_ID
);
nmcd
->
hdr
.
code
=
NM_CUSTOMDRAW
;
nmcd
->
dwDrawStage
=
dwDrawStage
;
nmcd
->
hdc
=
hdc
;
...
...
@@ -631,7 +637,7 @@ TREEVIEW_SendCustomDrawItemNotify(TREEVIEW_INFO *infoPtr, HDC hdc,
nmcd
->
uItemState
,
nmcd
->
lItemlParam
);
retval
=
TREEVIEW_SendRealNotify
(
infoPtr
,
(
WPARAM
)
GetWindowLongA
(
hwnd
,
GWL_ID
)
,
(
WPARAM
)
nmcd
->
hdr
.
idFrom
,
(
LPARAM
)
&
nmcdhdr
);
infoPtr
->
clrText
=
nmcdhdr
.
clrText
;
...
...
@@ -643,40 +649,21 @@ static BOOL
TREEVIEW_BeginLabelEditNotify
(
TREEVIEW_INFO
*
infoPtr
,
TREEVIEW_ITEM
*
editItem
)
{
HWND
hwnd
=
infoPtr
->
hwnd
;
LPSTR
allocated
=
NULL
;
NMTVDISPINFOA
tvdi
;
NMTVDISPINFOW
tvdi
;
BOOL
ret
;
tvdi
.
hdr
.
hwndFrom
=
hwnd
;
tvdi
.
hdr
.
idFrom
=
GetWindowLong
A
(
hwnd
,
GWL_ID
);
tvdi
.
hdr
.
idFrom
=
GetWindowLong
W
(
hwnd
,
GWL_ID
);
tvdi
.
hdr
.
code
=
get_notifycode
(
infoPtr
,
TVN_BEGINLABELEDITW
);
tvdi
.
item
.
mask
=
TVIF_HANDLE
|
TVIF_STATE
|
TVIF_PARAM
|
TVIF_TEXT
;
tvdi
.
item
.
hItem
=
editItem
;
tvdi
.
item
.
state
=
editItem
->
state
;
tvdi
.
item
.
lParam
=
editItem
->
lParam
;
if
(
infoPtr
->
bNtfUnicode
)
{
INT
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
editItem
->
pszText
,
-
1
,
NULL
,
0
);
if
(
len
>
1
)
{
tvdi
.
item
.
pszText
=
allocated
=
(
LPSTR
)
Alloc
(
len
*
sizeof
(
WCHAR
));
MultiByteToWideChar
(
CP_ACP
,
0
,
editItem
->
pszText
,
-
1
,
(
LPWSTR
)
tvdi
.
item
.
pszText
,
len
*
sizeof
(
WCHAR
)
);
tvdi
.
item
.
cchTextMax
=
len
*
sizeof
(
WCHAR
);
}
else
{
tvdi
.
item
.
pszText
=
editItem
->
pszText
;
/* ??? */
tvdi
.
item
.
cchTextMax
=
editItem
->
cchTextMax
;
/* ??? */
}
}
else
{
tvdi
.
item
.
pszText
=
editItem
->
pszText
;
tvdi
.
item
.
cchTextMax
=
editItem
->
cchTextMax
;
}
TREEVIEW_TVItemFromItem
(
infoPtr
,
TVIF_HANDLE
|
TVIF_STATE
|
TVIF_PARAM
|
TVIF_TEXT
,
&
tvdi
.
item
,
editItem
);
ret
=
(
BOOL
)
TREEVIEW_SendRealNotify
(
infoPtr
,
tvdi
.
hdr
.
idFrom
,
(
LPARAM
)
&
tvdi
);
if
(
!
infoPtr
->
bNtfUnicode
)
Free
(
tvdi
.
item
.
pszText
);
ret
=
(
BOOL
)
TREEVIEW_SendRealNotify
(
infoPtr
,
tvdi
.
hdr
.
idFrom
,
(
LPARAM
)
&
tvdi
);
if
(
allocated
)
Free
(
allocated
);
return
ret
;
}
...
...
@@ -684,15 +671,16 @@ static void
TREEVIEW_UpdateDispInfo
(
TREEVIEW_INFO
*
infoPtr
,
TREEVIEW_ITEM
*
wineItem
,
UINT
mask
)
{
NMTVDISPINFO
A
callback
;
NMTVDISPINFO
W
callback
;
HWND
hwnd
=
infoPtr
->
hwnd
;
TRACE
(
"mask %x callbackMask %x
\n
"
,
mask
,
wineItem
->
callbackMask
);
mask
&=
wineItem
->
callbackMask
;
if
(
mask
==
0
)
return
;
callback
.
hdr
.
hwndFrom
=
hwnd
;
callback
.
hdr
.
idFrom
=
GetWindowLong
A
(
hwnd
,
GWL_ID
);
callback
.
hdr
.
idFrom
=
GetWindowLong
W
(
hwnd
,
GWL_ID
);
callback
.
hdr
.
code
=
get_notifycode
(
infoPtr
,
TVN_GETDISPINFOW
);
/* 'state' always contains valid value, as well as 'lParam'.
...
...
@@ -718,68 +706,67 @@ TREEVIEW_UpdateDispInfo(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *wineItem,
if
((
mask
&
TVIF_TEXT
)
&&
callback
.
item
.
pszText
!=
wineItem
->
pszText
)
{
/* Instead of copying text into our buffer user specified its own */
if
(
infoPtr
->
bNtfUnicode
)
{
if
(
!
infoPtr
->
bNtfUnicode
)
{
LPWSTR
newText
;
int
buflen
;
int
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
(
LP
W
STR
)
callback
.
item
.
pszText
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
buflen
=
max
((
len
+
1
)
*
sizeof
(
WCHAR
),
TEXT_CALLBACK_SIZE
);
int
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
(
LPSTR
)
callback
.
item
.
pszText
,
-
1
,
NULL
,
0
);
buflen
=
max
((
len
)
*
sizeof
(
WCHAR
),
TEXT_CALLBACK_SIZE
);
newText
=
(
LPWSTR
)
ReAlloc
(
wineItem
->
pszText
,
buflen
);
TRACE
(
"returned
w
str %s, len=%d, buflen=%d
\n
"
,
debugstr_
w
((
LPW
STR
)
callback
.
item
.
pszText
),
len
,
buflen
);
TRACE
(
"returned str %s, len=%d, buflen=%d
\n
"
,
debugstr_
a
((
LP
STR
)
callback
.
item
.
pszText
),
len
,
buflen
);
if
(
newText
)
{
wineItem
->
pszText
=
(
LPSTR
)
newText
;
WideCharToMultiByte
(
CP_ACP
,
0
,
(
LPWSTR
)
callback
.
item
.
pszText
,
-
1
,
wineItem
->
pszText
,
buflen
,
NULL
,
NULL
);
wineItem
->
pszText
=
newText
;
MultiByteToWideChar
(
CP_ACP
,
0
,
(
LPSTR
)
callback
.
item
.
pszText
,
-
1
,
wineItem
->
pszText
,
buflen
);
wineItem
->
cchTextMax
=
buflen
;
}
/* If ReAlloc fails we have nothing to do, but keep original text */
}
else
{
int
len
=
max
(
lstrlen
A
(
callback
.
item
.
pszText
)
+
1
,
int
len
=
max
(
lstrlen
W
(
callback
.
item
.
pszText
)
+
1
,
TEXT_CALLBACK_SIZE
);
LPSTR
newText
=
ReAlloc
(
wineItem
->
pszText
,
len
);
LP
W
STR
newText
=
ReAlloc
(
wineItem
->
pszText
,
len
);
TRACE
(
"returned str %s, len=%d
\n
"
,
debugstr_
a
(
callback
.
item
.
pszText
),
len
);
TRACE
(
"returned
w
str %s, len=%d
\n
"
,
debugstr_
w
(
callback
.
item
.
pszText
),
len
);
if
(
newText
)
{
wineItem
->
pszText
=
newText
;
strcpy
(
wineItem
->
pszText
,
callback
.
item
.
pszText
);
strcpy
W
(
wineItem
->
pszText
,
callback
.
item
.
pszText
);
wineItem
->
cchTextMax
=
len
;
}
/* If ReAlloc fails we have nothing to do, but keep original text */
}
}
else
if
(
mask
&
TVIF_TEXT
)
{
/* User put text into our buffer, that is ok unless
W
string */
if
(
infoPtr
->
bNtfUnicode
)
{
/* User put text into our buffer, that is ok unless
A
string */
if
(
!
infoPtr
->
bNtfUnicode
)
{
LPWSTR
newText
;
LPSTR
oldText
=
NULL
;
LP
W
STR
oldText
=
NULL
;
int
buflen
;
int
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
(
LPW
STR
)
callback
.
item
.
pszText
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
buflen
=
max
((
len
+
1
)
*
sizeof
(
WCHAR
),
TEXT_CALLBACK_SIZE
);
int
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
(
LP
STR
)
callback
.
item
.
pszText
,
-
1
,
NULL
,
0
);
buflen
=
max
((
len
)
*
sizeof
(
WCHAR
),
TEXT_CALLBACK_SIZE
);
newText
=
(
LPWSTR
)
Alloc
(
buflen
);
TRACE
(
"same buffer
w
str %s, len=%d, buflen=%d
\n
"
,
debugstr_
w
((
LPW
STR
)
callback
.
item
.
pszText
),
len
,
buflen
);
TRACE
(
"same buffer str %s, len=%d, buflen=%d
\n
"
,
debugstr_
a
((
LP
STR
)
callback
.
item
.
pszText
),
len
,
buflen
);
if
(
newText
)
{
oldText
=
wineItem
->
pszText
;
wineItem
->
pszText
=
(
LPSTR
)
newText
;
WideCharToMultiByte
(
CP_ACP
,
0
,
(
LP
W
STR
)
callback
.
item
.
pszText
,
-
1
,
wineItem
->
pszText
,
buflen
,
NULL
,
NULL
);
wineItem
->
pszText
=
newText
;
MultiByteToWideChar
(
CP_ACP
,
0
,
(
LPSTR
)
callback
.
item
.
pszText
,
-
1
,
wineItem
->
pszText
,
buflen
);
wineItem
->
cchTextMax
=
buflen
;
if
(
oldText
)
Free
(
oldText
);
...
...
@@ -870,7 +857,7 @@ TREEVIEW_ComputeTextWidth(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item, HDC hDC)
hOldFont
=
SelectObject
(
hdc
,
TREEVIEW_FontForItem
(
infoPtr
,
item
));
}
GetTextExtentPoint32
A
(
hdc
,
item
->
pszText
,
strlen
(
item
->
pszText
),
&
sz
);
GetTextExtentPoint32
W
(
hdc
,
item
->
pszText
,
strlenW
(
item
->
pszText
),
&
sz
);
item
->
textWidth
=
sz
.
cx
;
if
(
hDC
==
0
)
...
...
@@ -1075,19 +1062,21 @@ TREEVIEW_InsertAfter(TREEVIEW_ITEM *newItem, TREEVIEW_ITEM *sibling,
static
BOOL
TREEVIEW_DoSetItem
(
TREEVIEW_INFO
*
infoPtr
,
TREEVIEW_ITEM
*
wineItem
,
const
TVITEMEX
A
*
tvItem
)
const
TVITEMEX
W
*
tvItem
)
{
UINT
callbackClear
=
0
;
UINT
callbackSet
=
0
;
TRACE
(
"item %p
\n
"
,
wineItem
);
/* Do this first in case it fails. */
if
(
tvItem
->
mask
&
TVIF_TEXT
)
{
wineItem
->
textWidth
=
0
;
/* force width recalculation */
if
(
tvItem
->
pszText
!=
LPSTR_TEXTCALLBACK
A
)
if
(
tvItem
->
pszText
!=
LPSTR_TEXTCALLBACK
W
)
{
int
len
=
lstrlenA
(
tvItem
->
pszText
)
+
1
;
LPSTR
newText
=
ReAlloc
(
wineItem
->
pszText
,
len
);
int
len
=
lstrlenW
(
tvItem
->
pszText
)
+
1
;
LPWSTR
newText
=
ReAlloc
(
wineItem
->
pszText
,
len
*
sizeof
(
WCHAR
));
if
(
newText
==
NULL
)
return
FALSE
;
...
...
@@ -1095,16 +1084,16 @@ TREEVIEW_DoSetItem(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *wineItem,
wineItem
->
pszText
=
newText
;
wineItem
->
cchTextMax
=
len
;
lstrcpyn
A
(
wineItem
->
pszText
,
tvItem
->
pszText
,
len
);
lstrcpyn
W
(
wineItem
->
pszText
,
tvItem
->
pszText
,
len
);
TRACE
(
"setting text %s, item %p
\n
"
,
debugstr_
a
(
wineItem
->
pszText
),
wineItem
);
debugstr_
w
(
wineItem
->
pszText
),
wineItem
);
}
else
{
callbackSet
|=
TVIF_TEXT
;
wineItem
->
pszText
=
ReAlloc
(
wineItem
->
pszText
,
TEXT_CALLBACK_SIZE
);
TEXT_CALLBACK_SIZE
*
sizeof
(
WCHAR
)
);
wineItem
->
cchTextMax
=
TEXT_CALLBACK_SIZE
;
TRACE
(
"setting callback, item %p
\n
"
,
wineItem
);
...
...
@@ -1155,9 +1144,6 @@ TREEVIEW_DoSetItem(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *wineItem,
tvItem
->
stateMask
);
wineItem
->
state
&=
~
tvItem
->
stateMask
;
wineItem
->
state
|=
(
tvItem
->
state
&
tvItem
->
stateMask
);
if
(
tvItem
->
stateMask
&
TVIS_BOLD
)
callbackSet
|=
TVIF_TEXT
;
}
wineItem
->
callbackMask
|=
callbackSet
;
...
...
@@ -1168,10 +1154,10 @@ TREEVIEW_DoSetItem(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *wineItem,
/* Note that the new item is pre-zeroed. */
static
LRESULT
TREEVIEW_InsertItem
A
(
TREEVIEW_INFO
*
infoPtr
,
LPARAM
lParam
)
TREEVIEW_InsertItem
W
(
TREEVIEW_INFO
*
infoPtr
,
LPARAM
lParam
)
{
const
TVINSERTSTRUCT
A
*
ptdi
=
(
LPTVINSERTSTRUCTA
)
lParam
;
const
TVITEMEX
A
*
tvItem
=
&
ptdi
->
DUMMYUNIONNAME
.
itemex
;
const
TVINSERTSTRUCT
W
*
ptdi
=
(
LPTVINSERTSTRUCTW
)
lParam
;
const
TVITEMEX
W
*
tvItem
=
&
ptdi
->
DUMMYUNIONNAME
.
itemex
;
HTREEITEM
insertAfter
;
TREEVIEW_ITEM
*
newItem
,
*
parentItem
;
BOOL
bTextUpdated
=
FALSE
;
...
...
@@ -1210,10 +1196,10 @@ TREEVIEW_InsertItemA(TREEVIEW_INFO *infoPtr, LPARAM lParam)
}
}
TRACE
(
"parent %p position %p:
'%s'
\n
"
,
parentItem
,
insertAfter
,
TRACE
(
"parent %p position %p:
%s
\n
"
,
parentItem
,
insertAfter
,
(
tvItem
->
mask
&
TVIF_TEXT
)
?
((
tvItem
->
pszText
==
LPSTR_TEXTCALLBACK
A
)
?
"<callback>"
:
tvItem
->
pszText
)
?
((
tvItem
->
pszText
==
LPSTR_TEXTCALLBACK
W
)
?
"<callback>"
:
debugstr_w
(
tvItem
->
pszText
)
)
:
"<no label>"
);
newItem
=
TREEVIEW_AllocateItem
(
infoPtr
);
...
...
@@ -1267,7 +1253,7 @@ TREEVIEW_InsertItemA(TREEVIEW_INFO *infoPtr, LPARAM lParam)
INT
comp
;
TREEVIEW_UpdateDispInfo
(
infoPtr
,
aChild
,
TVIF_TEXT
);
comp
=
lstrcmp
A
(
newItem
->
pszText
,
aChild
->
pszText
);
comp
=
lstrcmp
W
(
newItem
->
pszText
,
aChild
->
pszText
);
if
(
comp
<
0
)
/* we are smaller than the current one */
{
...
...
@@ -1370,56 +1356,57 @@ TREEVIEW_InsertItemA(TREEVIEW_INFO *infoPtr, LPARAM lParam)
static
LRESULT
TREEVIEW_InsertItem
W
(
TREEVIEW_INFO
*
infoPtr
,
LPARAM
lParam
)
TREEVIEW_InsertItem
A
(
TREEVIEW_INFO
*
infoPtr
,
LPARAM
lParam
)
{
TVINSERTSTRUCTW
*
tvisW
;
TVINSERTSTRUCTA
tvisA
;
TVINSERTSTRUCTW
tvisW
;
TVINSERTSTRUCTA
*
tvisA
;
LRESULT
lRes
;
tvis
W
=
(
LPTVINSERTSTRUCTW
)
lParam
;
tvis
A
=
(
LPTVINSERTSTRUCTA
)
lParam
;
tvis
A
.
hParent
=
tvisW
->
hParent
;
tvis
A
.
hInsertAfter
=
tvisW
->
hInsertAfter
;
tvis
W
.
hParent
=
tvisA
->
hParent
;
tvis
W
.
hInsertAfter
=
tvisA
->
hInsertAfter
;
tvisA
.
DUMMYUNIONNAME
.
item
.
mask
=
tvisW
->
DUMMYUNIONNAME
.
item
.
mask
;
tvisA
.
DUMMYUNIONNAME
.
item
.
hItem
=
tvisW
->
DUMMYUNIONNAME
.
item
.
hItem
;
tvisA
.
DUMMYUNIONNAME
.
item
.
state
=
tvisW
->
DUMMYUNIONNAME
.
item
.
state
;
tvisA
.
DUMMYUNIONNAME
.
item
.
stateMask
=
tvisW
->
DUMMYUNIONNAME
.
item
.
stateMask
;
tvisA
.
DUMMYUNIONNAME
.
item
.
cchTextMax
=
tvisW
->
DUMMYUNIONNAME
.
item
.
cchTextMax
;
tvisW
.
DUMMYUNIONNAME
.
item
.
mask
=
tvisA
->
DUMMYUNIONNAME
.
item
.
mask
;
tvisW
.
DUMMYUNIONNAME
.
item
.
hItem
=
tvisA
->
DUMMYUNIONNAME
.
item
.
hItem
;
tvisW
.
DUMMYUNIONNAME
.
item
.
state
=
tvisA
->
DUMMYUNIONNAME
.
item
.
state
;
tvisW
.
DUMMYUNIONNAME
.
item
.
stateMask
=
tvisA
->
DUMMYUNIONNAME
.
item
.
stateMask
;
tvisW
.
DUMMYUNIONNAME
.
item
.
cchTextMax
=
tvisA
->
DUMMYUNIONNAME
.
item
.
cchTextMax
;
if
((
tvisA
->
DUMMYUNIONNAME
.
item
.
pszText
)
&&
(
tvisA
->
DUMMYUNIONNAME
.
item
.
mask
&
TVIF_TEXT
))
if
(
tvisW
->
DUMMYUNIONNAME
.
item
.
pszText
)
{
if
(
tvis
W
->
DUMMYUNIONNAME
.
item
.
pszText
!=
LPSTR_TEXTCALLBACKW
)
if
(
tvis
A
->
DUMMYUNIONNAME
.
item
.
pszText
!=
LPSTR_TEXTCALLBACKA
)
{
int
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
tvisW
->
DUMMYUNIONNAME
.
item
.
pszText
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
tvis
A
.
DUMMYUNIONNAME
.
item
.
pszText
=
Alloc
(
len
);
WideCharToMultiByte
(
CP_ACP
,
0
,
tvisW
->
DUMMYUNIONNAME
.
item
.
pszText
,
-
1
,
tvis
A
.
DUMMYUNIONNAME
.
item
.
pszText
,
len
,
NULL
,
NULL
);
int
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
tvisA
->
DUMMYUNIONNAME
.
item
.
pszText
,
-
1
,
NULL
,
0
);
tvis
W
.
DUMMYUNIONNAME
.
item
.
pszText
=
Alloc
(
len
*
sizeof
(
WCHAR
)
);
MultiByteToWideChar
(
CP_ACP
,
0
,
tvisA
->
DUMMYUNIONNAME
.
item
.
pszText
,
-
1
,
tvis
W
.
DUMMYUNIONNAME
.
item
.
pszText
,
len
);
}
else
{
tvis
A
.
DUMMYUNIONNAME
.
item
.
pszText
=
LPSTR_TEXTCALLBACKA
;
tvis
A
.
DUMMYUNIONNAME
.
item
.
cchTextMax
=
0
;
tvis
W
.
DUMMYUNIONNAME
.
item
.
pszText
=
LPSTR_TEXTCALLBACKW
;
tvis
W
.
DUMMYUNIONNAME
.
item
.
cchTextMax
=
0
;
}
}
tvis
A
.
DUMMYUNIONNAME
.
item
.
iImage
=
tvisW
->
DUMMYUNIONNAME
.
item
.
iImage
;
tvis
A
.
DUMMYUNIONNAME
.
item
.
iSelectedImage
=
tvis
W
->
DUMMYUNIONNAME
.
item
.
iSelectedImage
;
tvis
A
.
DUMMYUNIONNAME
.
item
.
cChildren
=
tvisW
->
DUMMYUNIONNAME
.
item
.
cChildren
;
tvis
A
.
DUMMYUNIONNAME
.
item
.
lParam
=
tvisW
->
DUMMYUNIONNAME
.
item
.
lParam
;
tvis
W
.
DUMMYUNIONNAME
.
item
.
iImage
=
tvisA
->
DUMMYUNIONNAME
.
item
.
iImage
;
tvis
W
.
DUMMYUNIONNAME
.
item
.
iSelectedImage
=
tvis
A
->
DUMMYUNIONNAME
.
item
.
iSelectedImage
;
tvis
W
.
DUMMYUNIONNAME
.
item
.
cChildren
=
tvisA
->
DUMMYUNIONNAME
.
item
.
cChildren
;
tvis
W
.
DUMMYUNIONNAME
.
item
.
lParam
=
tvisA
->
DUMMYUNIONNAME
.
item
.
lParam
;
lRes
=
TREEVIEW_InsertItem
A
(
infoPtr
,
(
LPARAM
)
&
tvisA
);
lRes
=
TREEVIEW_InsertItem
W
(
infoPtr
,
(
LPARAM
)
&
tvisW
);
if
(
tvis
A
.
DUMMYUNIONNAME
.
item
.
pszText
!=
LPSTR_TEXTCALLBACKA
)
if
(
tvis
W
.
DUMMYUNIONNAME
.
item
.
pszText
&&
tvisW
.
DUMMYUNIONNAME
.
item
.
pszText
!=
LPSTR_TEXTCALLBACKW
)
{
Free
(
tvis
A
.
DUMMYUNIONNAME
.
item
.
pszText
);
Free
(
tvis
W
.
DUMMYUNIONNAME
.
item
.
pszText
);
}
return
lRes
;
}
...
...
@@ -1486,7 +1473,7 @@ TREEVIEW_RemoveItem(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *wineItem)
infoPtr
->
uNumItems
--
;
if
(
wineItem
->
pszText
!=
LPSTR_TEXTCALLBACKA
)
if
(
wineItem
->
pszText
&&
wineItem
->
pszText
!=
LPSTR_TEXTCALLBACKW
)
Free
(
wineItem
->
pszText
);
TREEVIEW_FreeItem
(
infoPtr
,
wineItem
);
...
...
@@ -1658,6 +1645,19 @@ TREEVIEW_SetToolTips(TREEVIEW_INFO *infoPtr, HWND hwndTT)
return
(
LRESULT
)
prevToolTip
;
}
static
LRESULT
TREEVIEW_SetUnicodeFormat
(
TREEVIEW_INFO
*
infoPtr
,
BOOL
fUnicode
)
{
BOOL
rc
=
infoPtr
->
bNtfUnicode
;
infoPtr
->
bNtfUnicode
=
fUnicode
;
return
rc
;
}
static
LRESULT
TREEVIEW_GetUnicodeFormat
(
TREEVIEW_INFO
*
infoPtr
)
{
return
infoPtr
->
bNtfUnicode
;
}
static
LRESULT
TREEVIEW_GetScrollTime
(
TREEVIEW_INFO
*
infoPtr
)
...
...
@@ -1753,11 +1753,11 @@ TREEVIEW_SetImageList(TREEVIEW_INFO *infoPtr, WPARAM wParam, HIMAGELIST himlNew)
static
UINT
TREEVIEW_NaturalHeight
(
TREEVIEW_INFO
*
infoPtr
)
{
TEXTMETRIC
A
tm
;
TEXTMETRIC
W
tm
;
HDC
hdc
=
GetDC
(
0
);
HFONT
hOldFont
=
SelectObject
(
hdc
,
infoPtr
->
hFont
);
GetTextMetrics
A
(
hdc
,
&
tm
);
GetTextMetrics
W
(
hdc
,
&
tm
);
SelectObject
(
hdc
,
hOldFont
);
ReleaseDC
(
0
,
hdc
);
...
...
@@ -2007,7 +2007,7 @@ TREEVIEW_GetVisibleCount(TREEVIEW_INFO *infoPtr)
static
LRESULT
TREEVIEW_GetItem
A
(
TREEVIEW_INFO
*
infoPtr
,
LPTVITEMEXA
tvItem
)
TREEVIEW_GetItem
W
(
TREEVIEW_INFO
*
infoPtr
,
LPTVITEMEXW
tvItem
)
{
TREEVIEW_ITEM
*
wineItem
;
...
...
@@ -2045,7 +2045,7 @@ TREEVIEW_GetItemA(TREEVIEW_INFO *infoPtr, LPTVITEMEXA tvItem)
}
if
(
tvItem
->
mask
&
TVIF_TEXT
)
lstrcpyn
A
(
tvItem
->
pszText
,
wineItem
->
pszText
,
tvItem
->
cchTextMax
);
lstrcpyn
W
(
tvItem
->
pszText
,
wineItem
->
pszText
,
tvItem
->
cchTextMax
);
TRACE
(
"item <%p>, txt %p, img %p, mask %x
\n
"
,
wineItem
,
tvItem
->
pszText
,
&
tvItem
->
iImage
,
tvItem
->
mask
);
...
...
@@ -2056,7 +2056,7 @@ TREEVIEW_GetItemA(TREEVIEW_INFO *infoPtr, LPTVITEMEXA tvItem)
/* Beware MSDN Library Visual Studio 6.0. It says -1 on failure, 0 on success,
* which is wrong. */
static
LRESULT
TREEVIEW_SetItem
A
(
TREEVIEW_INFO
*
infoPtr
,
LPTVITEMEXA
tvItem
)
TREEVIEW_SetItem
W
(
TREEVIEW_INFO
*
infoPtr
,
LPTVITEMEXW
tvItem
)
{
TREEVIEW_ITEM
*
wineItem
;
TREEVIEW_ITEM
originalItem
;
...
...
@@ -2111,11 +2111,9 @@ TREEVIEW_SetItemA(TREEVIEW_INFO *infoPtr, LPTVITEMEXA tvItem)
}
static
LRESULT
TREEVIEW_GetItem
W
(
TREEVIEW_INFO
*
infoPtr
,
LPTVITEMEXW
tvItem
)
TREEVIEW_GetItem
A
(
TREEVIEW_INFO
*
infoPtr
,
LPTVITEMEXA
tvItem
)
{
TREEVIEW_ITEM
*
wineItem
;
INT
iItem
;
iItem
=
(
INT
)
tvItem
->
hItem
;
wineItem
=
tvItem
->
hItem
;
if
(
!
TREEVIEW_ValidItem
(
infoPtr
,
wineItem
))
...
...
@@ -2149,57 +2147,64 @@ TREEVIEW_GetItemW(TREEVIEW_INFO *infoPtr, LPTVITEMEXW tvItem)
}
if
(
tvItem
->
mask
&
TVIF_TEXT
)
{
if
(
wineItem
->
pszText
==
LPSTR_TEXTCALLBACK
A
)
{
tvItem
->
pszText
=
LPSTR_TEXTCALLBACK
W
;
if
(
wineItem
->
pszText
==
LPSTR_TEXTCALLBACK
W
)
{
tvItem
->
pszText
=
LPSTR_TEXTCALLBACK
A
;
FIXME
(
" GetItem called with LPSTR_TEXTCALLBACK
\n
"
);
}
else
if
(
wineItem
->
pszText
)
{
TRACE
(
"orig str %s at %p
\n
"
,
debugstr_
a
(
wineItem
->
pszText
),
wineItem
->
pszText
);
MultiByteToWideChar
(
CP_ACP
,
0
,
wineItem
->
pszText
,
-
1
,
tvItem
->
pszText
,
tvItem
->
cchTextMax
);
debugstr_
w
(
wineItem
->
pszText
),
wineItem
->
pszText
);
WideCharToMultiByte
(
CP_ACP
,
0
,
wineItem
->
pszText
,
-
1
,
tvItem
->
pszText
,
tvItem
->
cchTextMax
,
NULL
,
NULL
);
}
}
TRACE
(
"item %d<%p>, txt %p<%s>, img %p, action %x
\n
"
,
iItem
,
tvItem
,
tvItem
->
pszText
,
debugstr_w
(
tvItem
->
pszText
),
&
tvItem
->
iImage
,
tvItem
->
mask
);
TRACE
(
"item <%p>, txt %p, img %p, action %x
\n
"
,
tvItem
,
tvItem
->
pszText
,
&
tvItem
->
iImage
,
tvItem
->
mask
);
return
TRUE
;
}
static
LRESULT
TREEVIEW_SetItem
W
(
TREEVIEW_INFO
*
infoPtr
,
LPTVITEMEXW
tvItem
)
TREEVIEW_SetItem
A
(
TREEVIEW_INFO
*
infoPtr
,
LPTVITEMEXA
tvItem
)
{
TVITEMEX
A
tvItemA
;
TVITEMEX
W
tvItemW
;
INT
len
;
LRESULT
rc
;
tvItemA
.
mask
=
tvItem
->
mask
;
tvItemA
.
hItem
=
tvItem
->
hItem
;
tvItemA
.
state
=
tvItem
->
state
;
tvItemA
.
stateMask
=
tvItem
->
stateMask
;
if
(
tvItem
->
mask
&
TVIF_TEXT
)
{
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
tvItem
->
pszText
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
if
(
len
)
{
len
++
;
tvItemA
.
pszText
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
*
sizeof
(
WCHAR
));
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
tvItem
->
pszText
,
-
1
,
tvItemA
.
pszText
,
len
*
sizeof
(
WCHAR
),
NULL
,
NULL
);
tvItemW
.
mask
=
tvItem
->
mask
;
tvItemW
.
hItem
=
tvItem
->
hItem
;
tvItemW
.
state
=
tvItem
->
state
;
tvItemW
.
stateMask
=
tvItem
->
stateMask
;
tvItemW
.
cchTextMax
=
0
;
tvItemW
.
pszText
=
0
;
if
(
tvItem
->
mask
&
TVIF_TEXT
)
{
if
(
tvItem
->
pszText
&&
tvItem
->
pszText
!=
LPSTR_TEXTCALLBACKA
)
{
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
tvItem
->
pszText
,
-
1
,
NULL
,
0
);
if
(
len
)
{
tvItemW
.
pszText
=
Alloc
(
len
*
sizeof
(
WCHAR
));
MultiByteToWideChar
(
CP_ACP
,
0
,
tvItem
->
pszText
,
-
1
,
tvItemW
.
pszText
,
len
);
tvItemW
.
cchTextMax
=
len
;
}
else
tvItemA
.
pszText
=
NULL
;
}
tvItemA
.
cchTextMax
=
tvItem
->
cchTextMax
;
tvItemA
.
iImage
=
tvItem
->
iImage
;
tvItemA
.
iSelectedImage
=
tvItem
->
iSelectedImage
;
tvItemA
.
cChildren
=
tvItem
->
cChildren
;
tvItemA
.
lParam
=
tvItem
->
lParam
;
tvItemA
.
iIntegral
=
tvItem
->
iIntegral
;
else
if
(
tvItem
->
pszText
==
LPSTR_TEXTCALLBACKA
)
tvItemW
.
pszText
=
LPSTR_TEXTCALLBACKW
;
}
tvItemW
.
iImage
=
tvItem
->
iImage
;
tvItemW
.
iSelectedImage
=
tvItem
->
iSelectedImage
;
tvItemW
.
cChildren
=
tvItem
->
cChildren
;
tvItemW
.
lParam
=
tvItem
->
lParam
;
tvItemW
.
iIntegral
=
tvItem
->
iIntegral
;
rc
=
TREEVIEW_SetItemA
(
infoPtr
,
&
tvItemA
);
HeapFree
(
GetProcessHeap
(),
0
,
tvItemA
.
pszText
);
rc
=
TREEVIEW_SetItemW
(
infoPtr
,
&
tvItemW
);
if
(
tvItemW
.
pszText
&&
tvItemW
.
pszText
!=
LPSTR_TEXTCALLBACKW
)
Free
(
tvItemW
.
pszText
);
return
rc
;
}
...
...
@@ -2582,13 +2587,13 @@ TREEVIEW_DrawItem(TREEVIEW_INFO *infoPtr, HDC hdc, TREEVIEW_ITEM *wineItem)
InflateRect
(
&
rcText
,
-
2
,
-
1
);
/* allow for the focus rect */
TRACE
(
"drawing text %s at (%ld,%ld)-(%ld,%ld)
\n
"
,
debugstr_
a
(
wineItem
->
pszText
),
debugstr_
w
(
wineItem
->
pszText
),
rcText
.
left
,
rcText
.
top
,
rcText
.
right
,
rcText
.
bottom
);
/* Draw it */
DrawText
A
(
hdc
,
DrawText
W
(
hdc
,
wineItem
->
pszText
,
lstrlen
A
(
wineItem
->
pszText
),
lstrlen
W
(
wineItem
->
pszText
),
&
rcText
,
DT_CENTER
|
DT_VCENTER
|
DT_SINGLELINE
|
DT_NOPREFIX
);
...
...
@@ -2910,7 +2915,14 @@ TREEVIEW_SortOnName(TREEVIEW_ITEM *first, TREEVIEW_ITEM *second,
TREEVIEW_UpdateDispInfo
(
infoPtr
,
first
,
TVIF_TEXT
);
TREEVIEW_UpdateDispInfo
(
infoPtr
,
second
,
TVIF_TEXT
);
return
strcasecmp
(
first
->
pszText
,
second
->
pszText
);
if
(
first
->
pszText
&&
second
->
pszText
)
return
lstrcmpiW
(
first
->
pszText
,
second
->
pszText
);
else
if
(
first
->
pszText
)
return
-
1
;
else
if
(
second
->
pszText
)
return
1
;
else
return
0
;
}
/* Returns the number of physical children belonging to item. */
...
...
@@ -3455,7 +3467,7 @@ TREEVIEW_Edit_SubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
case
WM_PAINT
:
TRACE
(
"WM_PAINT start
\n
"
);
rc
=
CallWindowProc
A
(
infoPtr
->
wpEditOrig
,
hwnd
,
uMsg
,
wParam
,
rc
=
CallWindowProc
W
(
infoPtr
->
wpEditOrig
,
hwnd
,
uMsg
,
wParam
,
lParam
);
TRACE
(
"WM_PAINT done
\n
"
);
return
rc
;
...
...
@@ -3481,7 +3493,7 @@ TREEVIEW_Edit_SubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
/* fall through */
default:
return
CallWindowProc
A
(
infoPtr
->
wpEditOrig
,
hwnd
,
uMsg
,
wParam
,
lParam
);
return
CallWindowProc
W
(
infoPtr
->
wpEditOrig
,
hwnd
,
uMsg
,
wParam
,
lParam
);
}
/* Processing TVN_ENDLABELEDIT message could kill the focus */
...
...
@@ -3509,7 +3521,7 @@ TREEVIEW_Command(TREEVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
/*
* Adjust the edit window size
*/
char
buffer
[
1024
];
WCHAR
buffer
[
1024
];
TREEVIEW_ITEM
*
editItem
=
infoPtr
->
selectedItem
;
HDC
hdc
=
GetDC
(
infoPtr
->
hwndEdit
);
SIZE
sz
;
...
...
@@ -3518,21 +3530,22 @@ TREEVIEW_Command(TREEVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
infoPtr
->
bLabelChanged
=
TRUE
;
len
=
GetWindowText
A
(
infoPtr
->
hwndEdit
,
buffer
,
sizeof
(
buffer
));
len
=
GetWindowText
W
(
infoPtr
->
hwndEdit
,
buffer
,
sizeof
(
buffer
));
/* Select font to get the right dimension of the string */
hFont
=
(
HFONT
)
SendMessageA
(
infoPtr
->
hwndEdit
,
WM_GETFONT
,
0
,
0
);
hFont
=
(
HFONT
)
SendMessageW
(
infoPtr
->
hwndEdit
,
WM_GETFONT
,
0
,
0
);
if
(
hFont
!=
0
)
{
hOldFont
=
SelectObject
(
hdc
,
hFont
);
}
if
(
GetTextExtentPoint32
A
(
hdc
,
buffer
,
strlen
(
buffer
),
&
sz
))
if
(
GetTextExtentPoint32
W
(
hdc
,
buffer
,
strlenW
(
buffer
),
&
sz
))
{
TEXTMETRIC
A
textMetric
;
TEXTMETRIC
W
textMetric
;
/* Add Extra spacing for the next character */
GetTextMetrics
A
(
hdc
,
&
textMetric
);
GetTextMetrics
W
(
hdc
,
&
textMetric
);
sz
.
cx
+=
(
textMetric
.
tmMaxCharWidth
*
2
);
sz
.
cx
=
max
(
sz
.
cx
,
textMetric
.
tmMaxCharWidth
*
3
);
...
...
@@ -3558,23 +3571,24 @@ TREEVIEW_Command(TREEVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
}
default:
return
SendMessage
A
(
infoPtr
->
hwndNotify
,
WM_COMMAND
,
wParam
,
lParam
);
return
SendMessage
W
(
infoPtr
->
hwndNotify
,
WM_COMMAND
,
wParam
,
lParam
);
}
return
0
;
}
static
HWND
TREEVIEW_EditLabel
A
(
TREEVIEW_INFO
*
infoPtr
,
HTREEITEM
hItem
)
TREEVIEW_EditLabel
(
TREEVIEW_INFO
*
infoPtr
,
HTREEITEM
hItem
)
{
HWND
hwnd
=
infoPtr
->
hwnd
;
HWND
hwndEdit
;
SIZE
sz
;
TREEVIEW_ITEM
*
editItem
=
hItem
;
HINSTANCE
hinst
=
(
HINSTANCE
)
GetWindowLong
A
(
hwnd
,
GWL_HINSTANCE
);
HINSTANCE
hinst
=
(
HINSTANCE
)
GetWindowLong
W
(
hwnd
,
GWL_HINSTANCE
);
HDC
hdc
;
HFONT
hOldFont
=
0
;
TEXTMETRICA
textMetric
;
TEXTMETRICW
textMetric
;
WCHAR
EditW
[]
=
{
'E'
,
'd'
,
'i'
,
't'
,
0
};
TRACE
(
"%x %p
\n
"
,
(
unsigned
)
hwnd
,
hItem
);
if
(
!
TREEVIEW_ValidItem
(
infoPtr
,
editItem
))
...
...
@@ -3599,11 +3613,11 @@ TREEVIEW_EditLabelA(TREEVIEW_INFO *infoPtr, HTREEITEM hItem)
}
/* Get string length in pixels */
GetTextExtentPoint32
A
(
hdc
,
editItem
->
pszText
,
strlen
(
editItem
->
pszText
),
GetTextExtentPoint32
W
(
hdc
,
editItem
->
pszText
,
strlenW
(
editItem
->
pszText
),
&
sz
);
/* Add Extra spacing for the next character */
GetTextMetrics
A
(
hdc
,
&
textMetric
);
GetTextMetrics
W
(
hdc
,
&
textMetric
);
sz
.
cx
+=
(
textMetric
.
tmMaxCharWidth
*
2
);
sz
.
cx
=
max
(
sz
.
cx
,
textMetric
.
tmMaxCharWidth
*
3
);
...
...
@@ -3615,8 +3629,8 @@ TREEVIEW_EditLabelA(TREEVIEW_INFO *infoPtr, HTREEITEM hItem)
}
ReleaseDC
(
hwnd
,
hdc
);
hwndEdit
=
CreateWindowEx
A
(
WS_EX_LEFT
,
"EDIT"
,
hwndEdit
=
CreateWindowEx
W
(
WS_EX_LEFT
,
EditW
,
0
,
WS_CHILD
|
WS_BORDER
|
ES_AUTOHSCROLL
|
WS_CLIPSIBLINGS
|
ES_WANTRETURN
|
...
...
@@ -3629,15 +3643,15 @@ TREEVIEW_EditLabelA(TREEVIEW_INFO *infoPtr, HTREEITEM hItem)
infoPtr
->
hwndEdit
=
hwndEdit
;
/* Get a 2D border. */
SetWindowLong
A
(
hwndEdit
,
GWL_EXSTYLE
,
GetWindowLong
A
(
hwndEdit
,
GWL_EXSTYLE
)
&
~
WS_EX_CLIENTEDGE
);
SetWindowLong
A
(
hwndEdit
,
GWL_STYLE
,
GetWindowLong
A
(
hwndEdit
,
GWL_STYLE
)
|
WS_BORDER
);
SetWindowLong
W
(
hwndEdit
,
GWL_EXSTYLE
,
GetWindowLong
W
(
hwndEdit
,
GWL_EXSTYLE
)
&
~
WS_EX_CLIENTEDGE
);
SetWindowLong
W
(
hwndEdit
,
GWL_STYLE
,
GetWindowLong
W
(
hwndEdit
,
GWL_STYLE
)
|
WS_BORDER
);
SendMessage
A
(
hwndEdit
,
WM_SETFONT
,
SendMessage
W
(
hwndEdit
,
WM_SETFONT
,
(
WPARAM
)
TREEVIEW_FontForItem
(
infoPtr
,
editItem
),
FALSE
);
infoPtr
->
wpEditOrig
=
(
WNDPROC
)
SetWindowLong
A
(
hwndEdit
,
GWL_WNDPROC
,
infoPtr
->
wpEditOrig
=
(
WNDPROC
)
SetWindowLong
W
(
hwndEdit
,
GWL_WNDPROC
,
(
DWORD
)
TREEVIEW_Edit_SubclassProc
);
...
...
@@ -3649,9 +3663,9 @@ TREEVIEW_EditLabelA(TREEVIEW_INFO *infoPtr, HTREEITEM hItem)
}
infoPtr
->
selectedItem
=
hItem
;
SetWindowText
A
(
hwndEdit
,
editItem
->
pszText
);
SetWindowText
W
(
hwndEdit
,
editItem
->
pszText
);
SetFocus
(
hwndEdit
);
SendMessage
A
(
hwndEdit
,
EM_SETSEL
,
0
,
-
1
);
SendMessage
W
(
hwndEdit
,
EM_SETSEL
,
0
,
-
1
);
ShowWindow
(
hwndEdit
,
SW_SHOW
);
return
hwndEdit
;
...
...
@@ -3663,16 +3677,17 @@ TREEVIEW_EndEditLabelNow(TREEVIEW_INFO *infoPtr, BOOL bCancel)
{
HWND
hwnd
=
infoPtr
->
hwnd
;
TREEVIEW_ITEM
*
editedItem
=
infoPtr
->
selectedItem
;
NMTVDISPINFO
A
tvdi
;
NMTVDISPINFO
W
tvdi
;
BOOL
bCommit
;
char
tmpText
[
1024
]
=
{
'\0'
};
WCHAR
tmpText
[
1024
]
=
{
'\0'
};
WCHAR
*
newText
=
tmpText
;
int
iLength
=
0
;
if
(
!
infoPtr
->
hwndEdit
)
return
FALSE
;
tvdi
.
hdr
.
hwndFrom
=
hwnd
;
tvdi
.
hdr
.
idFrom
=
GetWindowLong
A
(
hwnd
,
GWL_ID
);
tvdi
.
hdr
.
idFrom
=
GetWindowLong
W
(
hwnd
,
GWL_ID
);
tvdi
.
hdr
.
code
=
get_notifycode
(
infoPtr
,
TVN_ENDLABELEDITW
);
tvdi
.
item
.
mask
=
0
;
tvdi
.
item
.
hItem
=
editedItem
;
...
...
@@ -3681,13 +3696,17 @@ TREEVIEW_EndEditLabelNow(TREEVIEW_INFO *infoPtr, BOOL bCancel)
if
(
!
bCancel
)
{
iLength
=
GetWindowTextA
(
infoPtr
->
hwndEdit
,
tmpText
,
1023
);
if
(
!
infoPtr
->
bNtfUnicode
)
iLength
=
GetWindowTextA
(
infoPtr
->
hwndEdit
,
(
LPSTR
)
tmpText
,
1023
);
else
iLength
=
GetWindowTextW
(
infoPtr
->
hwndEdit
,
tmpText
,
1023
);
if
(
iLength
>=
1023
)
{
ERR
(
"Insufficient space to retrieve new item label
\n
"
);
}
tvdi
.
item
.
mask
=
TVIF_TEXT
;
tvdi
.
item
.
pszText
=
tmpText
;
tvdi
.
item
.
cchTextMax
=
iLength
+
1
;
}
...
...
@@ -3702,7 +3721,15 @@ TREEVIEW_EndEditLabelNow(TREEVIEW_INFO *infoPtr, BOOL bCancel)
if
(
!
bCancel
&&
bCommit
)
/* Apply the changes */
{
if
(
strcmp
(
tmpText
,
editedItem
->
pszText
)
!=
0
)
if
(
!
infoPtr
->
bNtfUnicode
)
{
DWORD
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
(
LPSTR
)
tmpText
,
-
1
,
NULL
,
0
);
newText
=
Alloc
(
len
*
sizeof
(
WCHAR
));
MultiByteToWideChar
(
CP_ACP
,
0
,
(
LPSTR
)
tmpText
,
-
1
,
newText
,
len
);
iLength
=
len
-
1
;
}
if
(
strcmpW
(
newText
,
editedItem
->
pszText
)
!=
0
)
{
if
(
NULL
==
ReAlloc
(
editedItem
->
pszText
,
iLength
+
1
))
{
...
...
@@ -3714,9 +3741,10 @@ TREEVIEW_EndEditLabelNow(TREEVIEW_INFO *infoPtr, BOOL bCancel)
else
{
editedItem
->
cchTextMax
=
iLength
+
1
;
lstrcpyA
(
editedItem
->
pszText
,
tmp
Text
);
strcpyW
(
editedItem
->
pszText
,
new
Text
);
}
}
if
(
newText
!=
tmpText
)
Free
(
newText
);
}
ShowWindow
(
infoPtr
->
hwndEdit
,
SW_HIDE
);
...
...
@@ -3737,7 +3765,7 @@ TREEVIEW_HandleTimer(TREEVIEW_INFO *infoPtr, WPARAM wParam)
KillTimer
(
infoPtr
->
hwnd
,
TV_EDIT_TIMER
);
infoPtr
->
Timer
&=
~
TV_EDIT_TIMER_SET
;
TREEVIEW_EditLabel
A
(
infoPtr
,
infoPtr
->
selectedItem
);
TREEVIEW_EditLabel
(
infoPtr
,
infoPtr
->
selectedItem
);
return
0
;
}
...
...
@@ -4089,10 +4117,10 @@ TREEVIEW_CreateDragImage(TREEVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
hdc
=
CreateCompatibleDC
(
htopdc
);
hOldFont
=
SelectObject
(
hdc
,
infoPtr
->
hFont
);
GetTextExtentPoint32
A
(
hdc
,
dragItem
->
pszText
,
lstrlenA
(
dragItem
->
pszText
),
GetTextExtentPoint32
W
(
hdc
,
dragItem
->
pszText
,
strlenW
(
dragItem
->
pszText
),
&
size
);
TRACE
(
"%ld %ld %s %d
\n
"
,
size
.
cx
,
size
.
cy
,
d
ragItem
->
pszText
,
lstrlenA
(
dragItem
->
pszText
));
TRACE
(
"%ld %ld %s %d
\n
"
,
size
.
cx
,
size
.
cy
,
d
ebugstr_w
(
dragItem
->
pszText
)
,
strlenW
(
dragItem
->
pszText
));
hbmp
=
CreateCompatibleBitmap
(
htopdc
,
size
.
cx
,
size
.
cy
);
hOldbmp
=
SelectObject
(
hdc
,
hbmp
);
...
...
@@ -4113,7 +4141,7 @@ TREEVIEW_CreateDragImage(TREEVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
/* draw item text */
SetRect
(
&
rc
,
cx
,
0
,
size
.
cx
,
size
.
cy
);
DrawText
A
(
hdc
,
dragItem
->
pszText
,
lstrlenA
(
dragItem
->
pszText
),
&
rc
,
DrawText
W
(
hdc
,
dragItem
->
pszText
,
strlenW
(
dragItem
->
pszText
),
&
rc
,
DT_LEFT
);
SelectObject
(
hdc
,
hOldFont
);
SelectObject
(
hdc
,
hOldbmp
);
...
...
@@ -4275,15 +4303,15 @@ static INT TREEVIEW_ProcessLetterKeys(
TREEVIEW_INFO
*
infoPtr
;
HTREEITEM
nItem
;
HTREEITEM
endidx
,
idx
;
TVITEMEX
A
item
;
CHAR
buffer
[
MAX_PATH
];
TVITEMEX
W
item
;
W
CHAR
buffer
[
MAX_PATH
];
DWORD
timestamp
,
elapsed
;
/* simple parameter checking */
if
(
!
hwnd
||
!
charCode
||
!
keyData
)
return
0
;
infoPtr
=
(
TREEVIEW_INFO
*
)
GetWindowLong
A
(
hwnd
,
0
);
infoPtr
=
(
TREEVIEW_INFO
*
)
GetWindowLong
W
(
hwnd
,
0
);
if
(
!
infoPtr
)
return
0
;
...
...
@@ -4311,7 +4339,7 @@ static INT TREEVIEW_ProcessLetterKeys(
/* update the search parameters */
infoPtr
->
lastKeyPressTimestamp
=
timestamp
;
if
(
elapsed
<
KEY_DELAY
)
{
if
(
infoPtr
->
nSearchParamLength
<
sizeof
(
infoPtr
->
szSearchParam
))
{
if
(
infoPtr
->
nSearchParamLength
<
sizeof
(
infoPtr
->
szSearchParam
)
/
sizeof
(
WCHAR
)
)
{
infoPtr
->
szSearchParam
[
infoPtr
->
nSearchParamLength
++
]
=
charCode
;
}
if
(
infoPtr
->
charCode
!=
charCode
)
{
...
...
@@ -4353,15 +4381,15 @@ static INT TREEVIEW_ProcessLetterKeys(
item
.
hItem
=
idx
;
item
.
pszText
=
buffer
;
item
.
cchTextMax
=
sizeof
(
buffer
);
TREEVIEW_GetItem
A
(
infoPtr
,
&
item
);
TREEVIEW_GetItem
W
(
infoPtr
,
&
item
);
/* check for a match */
if
(
strnc
asecmp
(
item
.
pszText
,
infoPtr
->
szSearchParam
,
infoPtr
->
nSearchParamLength
)
==
0
)
{
if
(
strnc
mpiW
(
item
.
pszText
,
infoPtr
->
szSearchParam
,
infoPtr
->
nSearchParamLength
)
==
0
)
{
nItem
=
idx
;
break
;
}
else
if
(
(
charCode
!=
0
)
&&
(
nItem
==
NULL
)
&&
(
nItem
!=
infoPtr
->
selectedItem
)
&&
(
strnc
asecmp
(
item
.
pszText
,
infoPtr
->
szSearchParam
,
1
)
==
0
)
)
{
(
strnc
mpiW
(
item
.
pszText
,
infoPtr
->
szSearchParam
,
1
)
==
0
)
)
{
/* This would work but we must keep looking for a longer match */
nItem
=
idx
;
}
...
...
@@ -4435,12 +4463,12 @@ TREEVIEW_EnsureVisible(TREEVIEW_INFO *infoPtr, HTREEITEM item, BOOL bHScroll)
/* Scroll window so item's text is visible as much as possible */
/* Calculation of amount of extra space is taken from EditLabel code */
INT
pos
,
x
;
TEXTMETRIC
A
textMetric
;
TEXTMETRIC
W
textMetric
;
HDC
hdc
=
GetWindowDC
(
infoPtr
->
hwnd
);
x
=
item
->
textWidth
;
GetTextMetrics
A
(
hdc
,
&
textMetric
);
GetTextMetrics
W
(
hdc
,
&
textMetric
);
ReleaseDC
(
infoPtr
->
hwnd
,
hdc
);
x
+=
(
textMetric
.
tmMaxCharWidth
*
2
);
...
...
@@ -4725,7 +4753,7 @@ TREEVIEW_Create(HWND hwnd, const CREATESTRUCTW *lpcs)
RECT
rcClient
;
TREEVIEW_INFO
*
infoPtr
;
TRACE
(
"wnd %p, style %lx
\n
"
,
hwnd
,
GetWindowLong
A
(
hwnd
,
GWL_STYLE
));
TRACE
(
"wnd %p, style %lx
\n
"
,
hwnd
,
GetWindowLong
W
(
hwnd
,
GWL_STYLE
));
infoPtr
=
(
TREEVIEW_INFO
*
)
Alloc
(
sizeof
(
TREEVIEW_INFO
));
...
...
@@ -4735,10 +4763,10 @@ TREEVIEW_Create(HWND hwnd, const CREATESTRUCTW *lpcs)
return
0
;
}
SetWindowLong
A
(
hwnd
,
0
,
(
DWORD
)
infoPtr
);
SetWindowLong
W
(
hwnd
,
0
,
(
DWORD
)
infoPtr
);
infoPtr
->
hwnd
=
hwnd
;
infoPtr
->
dwStyle
=
GetWindowLong
A
(
hwnd
,
GWL_STYLE
);
infoPtr
->
dwStyle
=
GetWindowLong
W
(
hwnd
,
GWL_STYLE
);
infoPtr
->
uInternalStatus
=
0
;
infoPtr
->
Timer
=
0
;
infoPtr
->
uNumItems
=
0
;
...
...
@@ -4801,12 +4829,12 @@ TREEVIEW_Create(HWND hwnd, const CREATESTRUCTW *lpcs)
infoPtr
->
hwndNotify
=
lpcs
->
hwndParent
;
#if 0
infoPtr->bTransparent = ( GetWindowLong
A
( hwnd, GWL_STYLE) & TBSTYLE_FLAT);
infoPtr->bTransparent = ( GetWindowLong
W
( hwnd, GWL_STYLE) & TBSTYLE_FLAT);
#endif
infoPtr
->
hwndToolTip
=
0
;
infoPtr
->
bUnicode
=
IsWindowUnicode
(
hwnd
);
infoPtr
->
b
Ntf
Unicode
=
IsWindowUnicode
(
hwnd
);
/* Determine what type of notify should be issued */
/* sets infoPtr->bNtfUnicode */
...
...
@@ -4873,11 +4901,11 @@ TREEVIEW_Destroy(TREEVIEW_INFO *infoPtr)
/* Restore original wndproc */
if
(
infoPtr
->
hwndEdit
)
SetWindowLong
A
(
infoPtr
->
hwndEdit
,
GWL_WNDPROC
,
SetWindowLong
W
(
infoPtr
->
hwndEdit
,
GWL_WNDPROC
,
(
LONG
)
infoPtr
->
wpEditOrig
);
/* Deassociate treeview from the window before doing anything drastic. */
SetWindowLong
A
(
infoPtr
->
hwnd
,
0
,
(
LONG
)
NULL
);
SetWindowLong
W
(
infoPtr
->
hwnd
,
0
,
(
LONG
)
NULL
);
DeleteObject
(
infoPtr
->
hBoldFont
);
Free
(
infoPtr
);
...
...
@@ -5195,11 +5223,10 @@ TREEVIEW_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
return
TREEVIEW_DeleteItem
(
infoPtr
,
(
HTREEITEM
)
lParam
);
case
TVM_EDITLABELA
:
return
(
LRESULT
)
TREEVIEW_EditLabel
A
(
infoPtr
,
(
HTREEITEM
)
lParam
);
return
(
LRESULT
)
TREEVIEW_EditLabel
(
infoPtr
,
(
HTREEITEM
)
lParam
);
case
TVM_EDITLABELW
:
FIXME
(
"Unimplemented msg TVM_EDITLABELW
\n
"
);
return
0
;
return
(
LRESULT
)
TREEVIEW_EditLabel
(
infoPtr
,
(
HTREEITEM
)
lParam
);
case
TVM_ENDEDITLABELNOW
:
return
TREEVIEW_EndEditLabelNow
(
infoPtr
,
(
BOOL
)
wParam
);
...
...
@@ -5267,8 +5294,7 @@ TREEVIEW_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
return
TREEVIEW_GetToolTips
(
infoPtr
);
case
TVM_GETUNICODEFORMAT
:
FIXME
(
"Unimplemented msg TVM_GETUNICODEFORMAT
\n
"
);
return
0
;
return
TREEVIEW_GetUnicodeFormat
(
infoPtr
);
case
TVM_GETVISIBLECOUNT
:
return
TREEVIEW_GetVisibleCount
(
infoPtr
);
...
...
@@ -5305,7 +5331,6 @@ TREEVIEW_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
case
TVM_SETITEMW
:
return
TREEVIEW_SetItemW
(
infoPtr
,
(
LPTVITEMEXW
)
lParam
);
return
0
;
case
TVM_SETLINECOLOR
:
return
TREEVIEW_SetLineColor
(
infoPtr
,
(
COLORREF
)
lParam
);
...
...
@@ -5323,8 +5348,7 @@ TREEVIEW_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
return
TREEVIEW_SetToolTips
(
infoPtr
,
(
HWND
)
wParam
);
case
TVM_SETUNICODEFORMAT
:
FIXME
(
"Unimplemented msg TVM_SETUNICODEFORMAT
\n
"
);
return
0
;
return
TREEVIEW_SetUnicodeFormat
(
infoPtr
,
(
BOOL
)
wParam
);
case
TVM_SORTCHILDREN
:
return
TREEVIEW_SortChildren
(
infoPtr
,
wParam
,
lParam
);
...
...
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