Solved

TTreeview bugs?

Posted on 1997-06-30
10
533 Views
Last Modified: 2010-04-04
null
0
Comment
Question by:millerw
  • 5
  • 4
10 Comments
 

Expert Comment

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

(Just a thought)
0
 
LVL 1

Author Comment

by:millerw
ID: 1338013
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
 
LVL 1

Author Comment

by:millerw
ID: 1338014
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
 
LVL 3

Accepted Solution

by:
mirek071497 earned 50 total points
ID: 1338015
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
 
LVL 1

Author Comment

by:millerw
ID: 1338016
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 3

Expert Comment

by:mirek071497
ID: 1338017
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
 
LVL 3

Expert Comment

by:mirek071497
ID: 1338018
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
 
LVL 1

Author Comment

by:millerw
ID: 1338019
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
 
LVL 1

Author Comment

by:millerw
ID: 1338020
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
 
LVL 3

Expert Comment

by:mirek071497
ID: 1338021
No problem. Thank You.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now