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
39c4bbe5
Commit
39c4bbe5
authored
Oct 18, 2006
by
Mikołaj Zalewski
Committed by
Alexandre Julliard
Oct 19, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
comctl32: toolbar: Fix the tests and handling of TB_SETHOTITEM on a disabled button.
parent
2d6b9caf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
19 deletions
+51
-19
toolbar.c
dlls/comctl32/tests/toolbar.c
+36
-9
toolbar.c
dlls/comctl32/toolbar.c
+15
-10
No files found.
dlls/comctl32/tests/toolbar.c
View file @
39c4bbe5
...
...
@@ -35,7 +35,11 @@
HWND
hMainWnd
;
BOOL
g_fBlockHotItemChange
;
BOOL
g_fReceivedHotItemChange
;
BOOL
g_fExpectedHotItemOld
;
BOOL
g_fExpectedHotItemNew
;
#define compare(val, exp, format) ok((val) == (exp), #val " value " format " expected " format "\n", (val), (exp));
static
void
MakeButton
(
TBBUTTON
*
p
,
int
idCommand
,
int
fsStyle
,
int
nString
)
{
p
->
iBitmap
=
-
2
;
p
->
idCommand
=
idCommand
;
...
...
@@ -47,10 +51,17 @@ static void MakeButton(TBBUTTON *p, int idCommand, int fsStyle, int nString) {
LRESULT
MyWnd_Notify
(
hWnd
,
wParam
,
lParam
)
{
NMHDR
*
hdr
=
(
NMHDR
*
)
lParam
;
NMTBHOTITEM
*
nmhi
;
switch
(
hdr
->
code
)
{
case
TBN_HOTITEMCHANGE
:
nmhi
=
(
NMTBHOTITEM
*
)
lParam
;
g_fReceivedHotItemChange
=
TRUE
;
if
(
g_fExpectedHotItemOld
!=
g_fExpectedHotItemNew
)
{
compare
(
nmhi
->
idOld
,
g_fExpectedHotItemOld
,
"%d"
);
compare
(
nmhi
->
idNew
,
g_fExpectedHotItemNew
,
"%d"
);
}
if
(
g_fBlockHotItemChange
)
return
1
;
break
;
...
...
@@ -422,6 +433,17 @@ void test_add_string()
CHECK_STRING_TABLE
(
14
,
ret7
);
}
static
void
expect_hot_notify
(
int
idold
,
int
idnew
)
{
g_fExpectedHotItemOld
=
idold
;
g_fExpectedHotItemNew
=
idnew
;
g_fReceivedHotItemChange
=
FALSE
;
}
#define check_hot_notify() \
ok(g_fReceivedHotItemChange, "TBN_HOTITEMCHANGE not received\n"); \
g_fExpectedHotItemOld = g_fExpectedHotItemNew = 0;
void
test_hotitem
()
{
HWND
hToolbar
=
NULL
;
...
...
@@ -452,10 +474,10 @@ void test_hotitem()
ret
=
SendMessage
(
hToolbar
,
TB_GETHOTITEM
,
0
,
0
);
ok
(
ret
==
-
1
,
"Hot item: %lx, expected -1
\n
"
,
ret
);
g_fReceivedHotItemChange
=
FALSE
;
expect_hot_notify
(
0
,
7
)
;
ret
=
SendMessage
(
hToolbar
,
TB_SETHOTITEM
,
3
,
0
);
ok
(
ret
==
-
1
,
"TB_SETHOTITEM returned %ld, expected -1
\n
"
,
ret
);
ok
(
g_fReceivedHotItemChange
,
"TBN_HOTITEMCHANGE not received
\n
"
);
check_hot_notify
(
);
ret
=
SendMessage
(
hToolbar
,
TB_GETHOTITEM
,
0
,
0
);
ok
(
ret
==
3
,
"Hot item: %lx, expected 3
\n
"
,
ret
);
g_fBlockHotItemChange
=
TRUE
;
...
...
@@ -475,22 +497,27 @@ void test_hotitem()
ok
(
ret
==
3
,
"TB_SETHOTITEM returned %ld, expected 3
\n
"
,
ret
);
ok
(
g_fReceivedHotItemChange
==
FALSE
,
"TBN_HOTITEMCHANGE received after a duplication
\n
"
);
expect_hot_notify
(
7
,
0
);
ret
=
SendMessage
(
hToolbar
,
TB_SETHOTITEM
,
-
0xbeaf
,
0
);
ok
(
ret
==
3
,
"TB_SETHOTITEM returned %ld, expected 3
\n
"
,
ret
);
ok
(
g_fReceivedHotItemChange
,
"TBN_HOTITEMCHANGE not received
\n
"
);
check_hot_notify
(
);
SendMessage
(
hToolbar
,
TB_SETHOTITEM
,
3
,
0
);
/* setting disabled buttons
as hot failed and generates no notify
*/
g_fReceivedHotItemChange
=
FALSE
;
/* setting disabled buttons
will generate a notify with the button id but no button will be hot
*/
expect_hot_notify
(
7
,
9
)
;
ret
=
SendMessage
(
hToolbar
,
TB_SETHOTITEM
,
4
,
0
);
ok
(
ret
==
3
,
"TB_SETHOTITEM returned %ld, expected 3
\n
"
,
ret
);
ok
(
!
g_fReceivedHotItemChange
,
"TBN_HOTITEMCHANGE received
\n
"
);
check_hot_notify
(
);
ret
=
SendMessage
(
hToolbar
,
TB_GETHOTITEM
,
0
,
0
);
ok
(
ret
==
3
,
"Hot item: %lx, expected 3
\n
"
,
ret
);
ok
(
ret
==
-
1
,
"Hot item: %lx, expected -1
\n
"
,
ret
);
/* enabling the button won't change that */
SendMessage
(
hToolbar
,
TB_ENABLEBUTTON
,
9
,
TRUE
);
ret
=
SendMessage
(
hToolbar
,
TB_GETHOTITEM
,
0
,
0
);
ok
(
ret
==
-
1
,
"TB_SETHOTITEM returned %ld, expected -1
\n
"
,
ret
);
/*
but
disabling a hot button works */
/* disabling a hot button works */
ret
=
SendMessage
(
hToolbar
,
TB_SETHOTITEM
,
3
,
0
);
ok
(
ret
==
3
,
"TB_SETHOTITEM returned %ld, expected 3
\n
"
,
ret
);
ok
(
ret
==
-
1
,
"TB_SETHOTITEM returned %ld, expected -1
\n
"
,
ret
);
g_fReceivedHotItemChange
=
FALSE
;
SendMessage
(
hToolbar
,
TB_ENABLEBUTTON
,
7
,
FALSE
);
ret
=
SendMessage
(
hToolbar
,
TB_GETHOTITEM
,
0
,
0
);
...
...
dlls/comctl32/toolbar.c
View file @
39c4bbe5
...
...
@@ -4783,40 +4783,45 @@ TOOLBAR_SetHotItemEx (TOOLBAR_INFO *infoPtr, INT nHit, DWORD dwReason)
NMTBHOTITEM
nmhotitem
;
TBUTTON_INFO
*
btnPtr
=
NULL
,
*
oldBtnPtr
=
NULL
;
nmhotitem
.
dwFlags
=
dwReason
;
if
(
infoPtr
->
nHotItem
>=
0
)
{
oldBtnPtr
=
&
infoPtr
->
buttons
[
infoPtr
->
nHotItem
];
nmhotitem
.
idOld
=
oldBtnPtr
->
idCommand
;
}
else
{
nmhotitem
.
dwFlags
|=
HICF_ENTERING
;
nmhotitem
.
idOld
=
0
;
}
if
(
nHit
>=
0
)
{
btnPtr
=
&
infoPtr
->
buttons
[
nHit
];
nmhotitem
.
idNew
=
btnPtr
->
idCommand
;
/* setting disabled buttons as hot fails */
if
(
!
(
btnPtr
->
fsState
&
TBSTATE_ENABLED
))
return
;
}
else
{
nmhotitem
.
dwFlags
|=
HICF_LEAVING
;
nmhotitem
.
dwFlags
=
dwReason
;
nmhotitem
.
idNew
=
0
;
}
/* now change the hot and invalidate the old and new buttons - if the
* parent agrees */
if
(
!
TOOLBAR_SendNotify
(
&
nmhotitem
.
hdr
,
infoPtr
,
TBN_HOTITEMCHANGE
))
{
infoPtr
->
nHotItem
=
nHit
;
if
(
btnPtr
)
{
btnPtr
->
bHot
=
TRUE
;
InvalidateRect
(
infoPtr
->
hwndSelf
,
&
btnPtr
->
rect
,
TRUE
);
}
if
(
oldBtnPtr
)
{
oldBtnPtr
->
bHot
=
FALSE
;
InvalidateRect
(
infoPtr
->
hwndSelf
,
&
oldBtnPtr
->
rect
,
TRUE
);
}
/* setting disabled buttons as hot fails even if the notify contains the button id */
if
(
btnPtr
&&
(
btnPtr
->
fsState
&
TBSTATE_ENABLED
))
{
btnPtr
->
bHot
=
TRUE
;
InvalidateRect
(
infoPtr
->
hwndSelf
,
&
btnPtr
->
rect
,
TRUE
);
infoPtr
->
nHotItem
=
nHit
;
}
else
infoPtr
->
nHotItem
=
-
1
;
}
}
}
...
...
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