Solved

Manipulating event sequencing

Posted on 2002-04-14
7
211 Views
Last Modified: 2010-04-04
My application maintains a tree full of nodes and a property sheet window (PS for brevity) that shows an appropriate editor for the object at which Node.Data points.

The TreeView Change event calls an Edit(Node) method on the PS form, which in turn loads the correct editor and gives it a reference to the object on which it should operate.

Each edit widget in a PS editor uses its Enter and Exit events to manage updates.

The problem occurs when the user edits a property and then clicks a different node in the tree without first moving focus off the edit widget.

The tree's change event fires BEFORE the edit widget's exit event. This sets a different object reference in the editor, so when the Exit event occurs the changes are written to the wrong object.

I have tried to no avail Application.ProcessMessages and Application.HandleMessage in the start of the tree's Change event handler.

Eventually [sic] I gave the PS form a FinaliseEditing method that calls the exit method explicitly and then sets a flag to prevent it from running again when the even is processed naturally.

This works, but, well, YUCK!

Any suggestions, people?
0
Comment
Question by:wamoz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 1

Expert Comment

by:MBo
ID: 6941080
I checked this problem with exit code in OnDeactivate of PSForm. All works fine.
0
 
LVL 10

Accepted Solution

by:
Jacco earned 200 total points
ID: 6941170
This is also not very beatiful but it worked for me:

procedure TForm1.TreeView1Change(Sender: TObject; Node: TTreeNode);
begin
  TreeView1.SetFocus;
  // .. rest of the code
end;

Regards Jacco
0
 
LVL 1

Author Comment

by:wamoz
ID: 6941210
MBo, there's some more pertinent info that I forgot to mention last time. The PS can be docked, and when it is docked, you don't get FormDeactivate events.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 27

Expert Comment

by:kretzschmar
ID: 6941257
add a condition-flag (boolean or integer)

just check set this on your editing

in your onchange-event check the flag,
if allowed, then do there your code,
otherwise not

or remove the event by assigning nil there,
and after your work reassign your event-procedure

meikl ;-)
0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 6941515
how about 'Apply' and 'Cancel' buttons ? :)
you update all the data with the apply button
still the simplest solution would be as jacco suggested
eg OnMouseDown of the listview do Windows.SetFocus(ListView.Handle);
that should trigger the active controls exit event
0
 
LVL 1

Expert Comment

by:MBo
ID: 6941828
Have you tried OnChanging treeview event?
0
 
LVL 1

Expert Comment

by:pnh73
ID: 9003214
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept answer from Jacco

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Paul (pnh73)
EE Cleanup Volunteer
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

691 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