في احد البرامج احتجت ان اعمل سحب و افلات في نفس TreeView و بالتالي احتجت الى ان يكون هناك Scroll لكي اتمكن من
الذهاب الى العنصر في حال كان غير مرئي بحثت في الانترنت عن كيفية عمل هذا فوجدت عدة طرق و لك هناك خطأ يظهر احيانا
AccessViolation
الطريقة التي استخدمتها هي احد الحلول التالية
procedure TFTreeView.TreeView1DragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); var TargetNode, SourceNode: TTreeNode; begin TargetNode := TreeView1.GetNodeAt (X, Y); if TargetNode = nil then exit; SourceNode := TreeView1.Selected; ////////////////////////////////////////////////////////////////////// //To Make the Treeview scroll when the Node is not showm in the tree// ////////////////////////////////////////////////////////////////////// TargetNode.MakeVisible; If ( y <= 30) Then //On the upper edge - should scroll up begin PostMessage(TreeView1.Handle,WM_VSCROLL,SB_LINEUP,0); // SendMessage(TreeView1.Handle,WM_VSCROLL,SB_LINEUP,0); // treeview1.perform( wm_vscroll, SB_LINEUP, 0 ); end else If (TreeView1.Height - y <= 30) Then // On the lower edge - should scroll begin PostMessage(TreeView1.Handle,WM_VSCROLL,SB_LINEDOWN,0); // treeview1.perform( wm_vscroll, SB_LINEDOWN, 0 ); // SendMessage(TreeView1.Handle,WM_VSCROLL,SB_LINEDOWN,0); end; end;
من خلال البحث تبين لي انّ هذه القصة او Bug قد تم حلها في نسخة 2005 و 2006
فهل لدى احد اقتراح معين