JAM-Software / Virtual-TreeView

Virtual Treeview is a Delphi treeview control
http://www.jam-software.de/virtual-treeview/
642 stars 250 forks source link

OnHeaderClick Event triggered twice if vclstyle enabled #1221

Closed mercedwang closed 11 months ago

mercedwang commented 12 months ago

I found this problem on VirtuanTreeView 7.6.5 on Delphi Community Edition 11.3. Create a new VCL project. Put a TVirtualStringTree control on Form1. Add a few columns in Header.Columns. Include hoVisible and exclude hoDrag in Header.Options. Select a custom vclstyle in Project Options > Application > Appearance. Add an event handler of OnHeaderClick and write a statement such as ShowMessage('error') in it. Run the Application and click the header, you can see that event is triggered twice.

joachimmarder commented 11 months ago

If a VCL style is applied, the click messages WM_NCLBUTTONUP arrives two times in the control header: Once via TWinControl.MainWndProc(), which is the normal way, and once via TStyleHook.CallDefaultProc():

GeneralAbilitiesDemo.TGeneralForm.VST2HeaderClick($36C4340,(444, 15, mbLeft, [], -1, [hhiNoWhere]))
VirtualTrees.TBaseVirtualTree.DoHeaderClick((7336644, 57003296, mbLeft, [ssShift,ssAlt,ssRight,ssMiddle,ssDouble,ssTouch,ssPen,ssCommand,ssHorizontal,(out of bound) 11,(out of bound) 13,(out of bound) 14], 16071187, [hhiOnColumn,(out of bound) 5,(out of bound) 7]))
VirtualTrees.TVirtualTreeColumns.HandleClick((444, 15),mbLeft,False,False)
VirtualTrees.TVTHeader.HandleMessage((162, 18, 35587128, 0, 18, 0, (), 1080, 543, (), 0, 0, ()))
VirtualTrees.TBaseVirtualTree.WndProc((162, 18, 35587128, 0, 18, 0, (), 1080, 543, (), 0, 0, ()))
Vcl.Themes.TStyleHook.CallDefaultProc(???)
Vcl.Forms.TScrollingStyleHook.WMNCLButtonUp((162, (), 18, (), 1080, 543, (), (1080, 543), (), 0))
Vcl.Themes.TStyleHook.WndProc((162, 18, 35587128, 0, 18, 0, (), 1080, 543, (), 0, 0, ()))
Vcl.Themes.TMouseTrackControlStyleHook.WndProc((162, 18, 35587128, 0, 18, 0, (), 1080, 543, (), 0, 0, ()))
Vcl.Forms.TScrollingStyleHook.WndProc(???)
Vcl.Themes.TStyleHook.HandleMessage((162, 18, 35587128, 0, 18, 0, (), 1080, 543, (), 0, 0, ()))
Vcl.Styles.TStyleEngine.HandleMessage($365CD20,(162, 18, 35587128, 0, 18, 0, (), 1080, 543, (), 0, 0, ()),(VirtualTrees.TBaseVirtualTree.WndProc,$365CD20))
Vcl.Themes.TStyleManager.HandleMessage($365CD20,(162, 18, 35587128, 0, 18, 0, (), 1080, 543, (), 0, 0, ()),(VirtualTrees.TBaseVirtualTree.WndProc,$365CD20))
Vcl.Controls.TWinControl.DoHandleStyleMessage(???)
Vcl.Controls.TWinControl.WndProc((162, 18, 35587128, 0, 18, 0, (), 1080, 543, (), 0, 0, ()))

The issue also affects the master branch.

mercedwang commented 11 months ago

I understood. Thanks anyway.

I have just found a solution to workaround this problem: Keep hoDrag Enabled, add an event handler function of OnHeaderDragging which sets Allowed to False, then OnHeaderClick event wil be triggered only once when the header is clicked if custom vclstyle is enabled. :-)

Ou Wang

@.***

13910034497

电子名片新出VIP模板啦,快来体验>>

扫一扫,

快速添加名片到手机


------------------ 原始邮件 ------------------

发件人: Joachim Marder @.***>

发送时间: 2023-10-14 16:21:01

收件人:JAM-Software/Virtual-TreeView @.***>

抄送:ouwang @.>,Author @.>

主题: Re: [JAM-Software/Virtual-TreeView] OnHeaderClick Event triggeredtwice when the header is clicked if custom vclstyle enabled and hoDrag not inHeader.Options (Issue #1221)

If a VCL style is applied, the click messages arrives two times in the control: Once via TWinControl.MainWndProc() and once via TStyleHook.CallDefaultProc():

GeneralAbilitiesDemo.TGeneralForm.VST2HeaderClick($36C4340,(444, 15, mbLeft, [], -1, [hhiNoWhere])) VirtualTrees.TBaseVirtualTree.DoHeaderClick((7336644, 57003296, mbLeft, [ssShift,ssAlt,ssRight,ssMiddle,ssDouble,ssTouch,ssPen,ssCommand,ssHorizontal,(out of bound) 11,(out of bound) 13,(out of bound) 14], 16071187, [hhiOnColumn,(out of bound) 5,(out of bound) 7])) VirtualTrees.TVirtualTreeColumns.HandleClick((444, 15),mbLeft,False,False) VirtualTrees.TVTHeader.HandleMessage((162, 18, 35587128, 0, 18, 0, (), 1080, 543, (), 0, 0, ())) VirtualTrees.TBaseVirtualTree.WndProc((162, 18, 35587128, 0, 18, 0, (), 1080, 543, (), 0, 0, ())) Vcl.Themes.TStyleHook.CallDefaultProc(???) Vcl.Forms.TScrollingStyleHook.WMNCLButtonUp((162, (), 18, (), 1080, 543, (), (1080, 543), (), 0)) Vcl.Themes.TStyleHook.WndProc((162, 18, 35587128, 0, 18, 0, (), 1080, 543, (), 0, 0, ())) Vcl.Themes.TMouseTrackControlStyleHook.WndProc((162, 18, 35587128, 0, 18, 0, (), 1080, 543, (), 0, 0, ())) Vcl.Forms.TScrollingStyleHook.WndProc(???) Vcl.Themes.TStyleHook.HandleMessage((162, 18, 35587128, 0, 18, 0, (), 1080, 543, (), 0, 0, ())) Vcl.Styles.TStyleEngine.HandleMessage($365CD20,(162, 18, 35587128, 0, 18, 0, (), 1080, 543, (), 0, 0, ()),(VirtualTrees.TBaseVirtualTree.WndProc,$365CD20)) Vcl.Themes.TStyleManager.HandleMessage($365CD20,(162, 18, 35587128, 0, 18, 0, (), 1080, 543, (), 0, 0, ()),(VirtualTrees.TBaseVirtualTree.WndProc,$365CD20)) Vcl.Controls.TWinControl.DoHandleStyleMessage(???) Vcl.Controls.TWinControl.WndProc((162, 18, 35587128, 0, 18, 0, (), 1080, 543, (), 0, 0, ()))

I don't have a quick solution.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>