Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#16812 closed defect (fixed)

wxTreeCtrl with checkboxes on MSW systems with two screens doesn't handle check events properly.

Reported by: Antal Owned by: VZ
Priority: low Milestone:
Component: wxMSW Version: 3.0.2
Keywords: wxTreeCtrl, checkbox Cc:
Blocked By: Blocking:
Patch: yes

Description

Good day!=)

Windows 7: We are implementing our own tree control with checkboxes that is based on wxTreeCtrl. When application is used on the systems with two displays, there appears to be no reaction on checkbox click in the secondary screen.

Looking into the problem, it was found that LOWORD and HIWORD macrodefinitions are used in \src\msw\treectrl.cpp [namely in

bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)

], which are not recommended (according to https://msdn.microsoft.com/en-us/library/windows/desktop/ms644938%28v=vs.85%29.aspx).

On the page given is a proposal to change "bad" ones to "good" ones, namely GET_X_LPARAM and GET_Y_LPARAM, which worked for us.

Unified diff is included.

Thank you!

Attachments (1)

patch.patch download (640 bytes) - added by Antal 5 years ago.
The .patch file for possible solution of the problem described.

Download all attachments as: .zip

Change History (6)

Changed 5 years ago by Antal

The .patch file for possible solution of the problem described.

comment:1 Changed 5 years ago by Antal

Forgot to say, sorry.

These macrodefinitions lead to the wrong calculation of x and y click coordinates:

        case NM_CLICK:
            {
                DWORD pos = GetMessagePos();
                POINT point;
                point.x = LOWORD(pos);
                point.y = HIWORD(pos);
                ::MapWindowPoints(HWND_DESKTOP, GetHwnd(), &point, 1);
                int htFlags = 0;
                wxTreeItemId item = HitTest(wxPoint(point.x, point.y), htFlags);

                if ( htFlags & wxTREE_HITTEST_ONITEMSTATEICON )
                {
                    event.m_item = item;
                    eventType = wxEVT_TREE_STATE_IMAGE_CLICK;
                }

                break;
            }

, thus HitTest() returns the wrong htFlags and the right type of event is not set and it is not handled properly.

Last edited 5 years ago by Antal (previous) (diff)

comment:2 Changed 5 years ago by VZ

  • Owner set to VZ
  • Resolution set to fixed
  • Status changed from new to closed

In 78419/svn-wx:

Fix wxEVT_TREE_STATE_IMAGE_CLICK generation in wxMSW wxTreeCtrl.

Use GET_{X,Y}_LPARAM() to extract them from the event position, which handle
negative coordinates (and coordinates can perfectly well be negative when
using multiple displays) correctly, unlike {LO,HI}WORD().

Closes #16812.

comment:3 Changed 5 years ago by Vadim Zeitlin <vadim@…>

In f047d93c6a1d9c6b7bacf885555cbe4724f2c602/git-wxWidgets:

Fix wxEVT_TREE_STATE_IMAGE_CLICK generation in wxMSW wxTreeCtrl.

Use GET_{X,Y}_LPARAM() to extract them from the event position, which handle
negative coordinates (and coordinates can perfectly well be negative when
using multiple displays) correctly, unlike {LO,HI}WORD().

Closes #16812.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_3_0_BRANCH@78419 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

comment:4 Changed 5 years ago by VZ

In 78420/svn-wx:

Fix wxEVT_TREE_STATE_IMAGE_CLICK generation in wxMSW wxTreeCtrl.

Use GET_{X,Y}_LPARAM() to extract them from the event position, which handle
negative coordinates (and coordinates can perfectly well be negative when
using multiple displays) correctly, unlike {LO,HI}WORD().

Closes #16812.

comment:5 Changed 5 years ago by Vadim Zeitlin <vadim@…>

In 041f9a4cf2df55661388ace15d43164070b00085/git-wxWidgets:

Fix wxEVT_TREE_STATE_IMAGE_CLICK generation in wxMSW wxTreeCtrl.

Use GET_{X,Y}_LPARAM() to extract them from the event position, which handle
negative coordinates (and coordinates can perfectly well be negative when
using multiple displays) correctly, unlike {LO,HI}WORD().

Closes #16812.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78420 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

Note: See TracTickets for help on using tickets.