TTreeview bugs?

null
LVL 1
millerwAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GGRCommented:
As far as the StateIndex, I have found that in some cases you need to call the refresh method.

(Just a thought)
0
millerwAuthor Commented:
Program is kinda in limbo right now---ran into some other problems and am having to rewrite some of the components.  Will try your suggestion when the program is up and running and get back to you.

I'm not sure it will work either--it is not a display problem it is a call problem---it never calls my procedures (eg breakpoints are in the procedures and they are never called) so the stateindex for each node is NOT changed at all so a refresh would do nothing but redraw the unchanged stateindex.  I need to fix the "bug" of it never calling the OnCollapse/OnCollapsing events.  

Really I'm just looking to see if anyone else encountered these problems and if they are bugs with Delphi 2 or bugs with my code somewhere (I have checked my code several times and cannot find the error if I'm making one).  

Thanks for the comment and I will try it within the week (I hope).
0
millerwAuthor Commented:
Got it to run just about 10 min ago and tried your idea.  My fears were correct, it had no effect.  The stateindex is not being changed by the OnCollapse event and therefore a refresh had not effect.

Thanks for the idea anyway
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

mirek071497Commented:
Borland Made error in this component.

You'r problem can be resolved only by writing new component.
When You call Collapse or Expand then TNode send Message TVM_EXPAND but this message does not send the VN_ITEMEXPANDING and TVN_ITEMEXPANDED notification  messages to the parent window !

You must make changes in TNode with procedure ExpandItem

procedure TTreeNode.ExpandItem(Expand: Boolean; Recurse: Boolean);
var
  Flag: Integer;
  Node: TTreeNode;
begin
  if Recurse then
  begin
    Node := Self;
    repeat
      Node.ExpandItem(Expand, False);
      Node := Node.GetNext;
    until (Node = nil) or not Node.HasAsParent(Self);
  end
  else begin
    { this must be added }
    if Expand then
      begin
        if not Expanded then TreeView.Expand( self )
      end
    else
      begin
        if Expanded then TreeView.Collapse( self )
      end;
    { end adding }
    if Expand then Flag := TVE_EXPAND
    else Flag := TVE_COLLAPSE;
    TreeView_Expand(Handle, ItemId, Flag);
  end;
end;

I can mail to You example of the new component but not for 10pt.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
millerwAuthor Commented:
I fixed the problem, kinda by a back door.  I am going though the tree maually with a recursive function that fixes all the images everytime they expand or collapse the tree.  It works and is quite fast---haven't had a problem yet.  Your answer is kind of late since the section of the program in question is going into production today.  

I do have one question about your approach.  Doesn't the entire TTreeView have to be rewritten to use the New TTreeNode.  For example, all of the inserts and adds have to be rewritten to use the new TTreeNode instead of the old one.  Is that correct?

Additionally, the recursive function is quick, efficient and doesn't entail entirely rewritting a component (2 components actually).  If you want to see the code, I can show it to you.  

How do you learn about all of those messages that windows is throwing around?  Everyone is using them, but i have no clue how to go about finding out about them (does the Delphi help have all that information?).  Is there a good book?

Thanks for the time,
Scott
0
mirek071497Commented:
Hi millerw

1.When You make new component then you must change use in all you'r unit's. This is big work but you can mad changes in VCL source (if you have this).

2. Of cource i'll be hapy when you show the code.

3. I have Microsoft SDK for Win95. This have big documentation set but this problem is described in Win32 help which is included in Delphi (try serach TVM_EXPAND). I have Delphi 2.0 Developer which came with VCL source code.

Regards
Mirek
0
mirek071497Commented:
I read now Borland licence and i think so i can mail to you source code for VCL. This is not full source code but can help you with more and more problems.

I live in poland so my book's probably not for you but here is only 2 books and very bad. Sorry for my english but i think so you can understand all my ideas.

Regards
Mirek
0
millerwAuthor Commented:
I have Delphi Developer 2, and have the VCL code.  I can look into it and see what I can find.  Maybe a few days before I am able to respond again.  The program is going into in house beta testing today.  Am going to be busy answering questions and helping people with it.  I'll try the suggestion at a later date.  Thanks and talk to you again soon.

Scott
0
millerwAuthor Commented:
Well, mirek, I have no clue how this got graded.  I got on today and it just graded itself.  Anyway, your answer was good, just a little late.  That is why I was going to give you a B, but the service seems to have made the decision for me.  I told you I would show you my code for the recursive image fix and so here it is:

procedure TfrmAccountTree.FixImages (Node: TTreeNode);
begin
     If Node.Level <> 0 then
     begin
          If Node.Expanded then
          begin
               Node.ImageIndex := ImageIndexNum(Node.Text) + 1;
               Node.SelectedIndex := Node.ImageIndex;
          end
          else
          begin
               Node.ImageIndex := ImageIndexNum(Node.Text);
               Node.SelectedIndex := Node.ImageIndex;
          end;
     end;
     Node := Node.GetFirstChild;
     While Node <> nil do
     begin
          FixImages (Node);
          Node := Node.GetNextSibling;
     end;
end;

As you can see, it takes very little code.  All it does is calculate the appropriate image in an image list.  Sorry it took so long to get you this!

Thanks for the answer and sorry about the grade,
Scott
0
mirek071497Commented:
No problem. Thank You.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.