Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7798401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:59:35+00:00 2026-06-01T23:59:35+00:00

I have an array holds data will be represented on TVirtualStringTree. This array is

  • 0

I have an array holds data will be represented on TVirtualStringTree. This array is thread-safe and lockable. And grown by another thread.

My problem is that, when VST executes OnMeasureItem event to measure height of the node, data used for measurement can change when it come to the point of printing data with OnGetText event.

I have checked the execution order of events and it is not good for my design. First It fires OnMeasureItem event for all nodes which is not initialized then it starts calling OnGetText events.
I mean, suppose we have 3 nodes, events will be fired in that order:

OnMeasureItem for node 1
OnMeasureItem for node 2
OnMeasureItem for node 3
OnGetText for node 1
OnGetText for node 2
OnGetText for node 3

But I need something like this so that I can lock:

OnMeasureItem for node 1
OnGetText for node 1

OnMeasureItem for node 2
OnGetText for node 2

OnMeasureItem for node 3
OnGetText for node 3

What is the best way to maintain synchronization of data obtained between OnMeasureItem and OnGetText events?

I don’t want to lock my array during all OnMeasureItem() and OnGetText() events.

Thank you.

Added onTimer:

procedure TMainForm.SyncHexLog;
begin
  HexLog.BeginUpdate;
  Try
    if (HexLog.RootNodeCount <> FirpList.ComOperationCountLagged) then
      begin
          HexLog.RootNodeCount := FirpList.ComOperationCountLagged;

          // measure for fast scrolling
          HexLog.ReInitNode(HexLog.GetLastNoInit(), True);    

          if FAutoScroll then
          begin
            HexLog.ScrollIntoView(HexLog.GetLast, False, False);
          end;
      end;
  Finally
    HexLog.EndUpdate;
  End;
end;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T23:59:37+00:00Added an answer on June 1, 2026 at 11:59 pm

    I would try to force the item measurement manually by removing the vsHeightMeasured from node’s states with subsequent calling of the MeasureItemHeight method. It will trigger the OnMeasureItem again. The problem is the again here, because you shouldn’t measure the item more than once the text of the node is changed, but still have to handle the OnMeasureItem because of that scrolling stuff.

    So as you mentioned in you comment you may include your own NodeMeasured flag into your data structure and reset it when the text of the node will change (when some data in your log item are changed) and set it after you pass the OnGetText event with the forced node height measurement. Here is a pseudocode:

    procedure TForm1.VirtualStringTreeGetText(Sender: TBaseVirtualTree;
      Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
      var CellText: string);
    begin
      ThreadList.LockList;
      try
        // check if the own flag which indicates that the text is new, that
        // the data has changed since the last time you were here in OnGetText
        // is False and if so, force the node measurement to set current node
        // height and set this flag to True to remember we already did this
        if not ThreadList.Items[Node.Index].NodeMeasured then
        begin
          // fake the node measurement, remove the measured flag
          Exclude(Node.States, vsHeightMeasured);
          // this will trigger the OnMeasureItem again because of removed
          // vsHeightMeasured flag from the node's state
          VirtualStringTree.MeasureItemHeight(VirtualStringTree.Canvas, Node);
          // set the NodeMeasured flag to remember we've measured the item
          ThreadList.Items[Node.Index].NodeMeasured := True;
        end;
        // here set the node's text and unlock your thread safe list
        CellText := ThreadList[Node.Index].SomeText;
      finally
        ThreadList.UnlockList;
      end;
    end;
    

    And in your thread when the data gets changed, you have to set this NodeMeasured flag to False.

    if LogHasChanged then
    begin
      ThreadList.LockList;
      try
        ThreadList.Items[X].NodeMeasured := False;
        ThreadList.Items[X].SomeText := 'Something new';
      finally
        ThreadList.UnlockList;
      end;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array, which holds values like this: $items_pool = Array ( [0]
I have a class that holds some constants and will receive an object literal
I have this array: unsigned char* data = CGBitmapContextGetData(cgctx); then I tried to get
If I have a class that will be instantiated that needs to reference data
I have a text file that holds values like this: 30 Text 21 Text
I have a string array which holds the name of 500 stocks. Now i
If I have a variant array which holds nothing but simple types, and possible
Let's say I have an array, @theArr, which holds 1,000 or so elements such
I have array like this: $path = array ( [0] => site\projects\terrace_and_balcony\mexico.jpg [1] =>
I have array result like this: Array ( [0] => stdClass Object ( [id_global_info]

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.