delphi – 在TVirtualStringTree中错误地绘制了主题复选框
启用toThemeAware时,VirtualTrees.pas 5.0.0版中的复选框处理显示已损坏. csUncheckedNormal的节点被绘制为热检查.
要使用DrawElement正确绘制未经检查的主题复选框,Details记录必须为:Element = teButton,Part = 3,State = 5.但是,当节点设置为csUncheckedNormal时,VirtualTrees.pas最终调用DrawElement,State = 1 . 似乎在VirtualTrees中声明了大量的间接和额外的常量,所以我不确定如何最好地解决这个问题.想法欢迎…… (甚至在屏幕上获取TVirtualStringTree并填充一些数据的最小代码在这里发布也有点冗长.除了基础知识之外,重现这一点所需要的只是在TreeOptions.MiscOptions中启用toCheckSupport,并设置Node.CheckType: = InitNode回调中的ctTriStateCheckBox.) 解决方法
好吧,因为我认为在移植到delphi XE2时VirtualTreeView不计入VCL样式,这可能会解决您的问题.您必须在绘制之前获取元素详细信息,否则您将得到类似的内容(这是VirtualTreeView绘制复选框如何指出的模拟).注意不同的顺序和工件;一旦禁用VCL样式,第二次启用时,它是相同代码的结果:
很奇怪我知道,但我不能回答你为什么会这样.我可以告诉你,你应该调用 procedure TBaseVirtualTree.PaintCheckImage(Canvas: TCanvas; const ImageInfo: TVTImageInfo; Selected: Boolean); var // add a new variable for calculating TThemedButton state from the input // ImageInfo.Index; I hope ImageInfo.Index has the proper state order State: Integer; begin ... case Index of 0..8: // radio buttons begin // get the low index of the first radio button state and increment it by // the ImageInfo.Index and get details of the button element State := Ord(TThemedButton(tbRadioButtonUncheckedNormal)) + Index - 1; Details := StyleServices.GetElementDetails(TThemedButton(State)); end; 9..20: // check boxes begin // get the low index of the first check box state and increment it by // the ImageInfo.Index and get details of the button element State := Ord(TThemedButton(tbCheckBoxUncheckedNormal)) + Index - 9; Details := StyleServices.GetElementDetails(TThemedButton(State)); end; 21..24: // buttons begin // get the low index of the first push button state and increment it by // the ImageInfo.Index and get details of the button element State := Ord(TThemedButton(tbPushButtonNormal)) + Index - 21; Details := StyleServices.GetElementDetails(TThemedButton(State)); end; else Details.Part := 0; Details.State := 0; end; ... end; 我已经为所有检查类型测试了这个,它对我有用. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |