Getting object reference inside Delphi IDE

This follows from my answer to this question Q:

Can I change the display format of the rows in the watch list?

It turns out that at some point between D7 and XE3, the implementation of the IDE viewport changed from using TListView to TVirtualStringTree.

Despite the fact that I posted an update for my answer that works with XE4, ignoring VST and getting the clock value from the clipboard, I still would like to get the cost of the clock from VST if I can. I think I know how to do this as soon as I have a link to VST, but the problem is that my attempt to get one fails.

The following is the MCVE code that I use in my custom package. Hope this is not clear. The problem is that the code in the block

if WatchWindow.Components[i] is TVirtualStringTree then begin [...] end; 

never executed, the DESPITE class name "TVirtualStringTree" appears in Memo1. Obviously, a component with this class did not pass the "eat" test. I assume that the reason is that TVirtualTreeView compiled in the IDE is the other version I use, v.5.3.0, which is the closest predecessor I can find for XE4.

So my question is, what is the likely explanation, and is there anything I can do about it? I suspect that someone might flourish the version of TVirtualStringTree that was used for XE4 from the hat, which might solve my problem.

 type TOtaMenuForm = class(TForm) Memo1: TMemo; procedure FormCreate(Sender: TObject); private WatchWindow : TForm; VST : TVirtualStringTree; end; procedure TOtaMenuForm.FormCreate(Sender: TObject); var i : Integer; S : String; begin WatchWindow := Nil; VST := Nil; // Iterate the IDE forms to find the Watch Window for i := 0 to Screen.FormCount - 1 do begin S := Screen.Forms[i].Name; if CompareText(S, 'WatchWindow') = 0 then begin WatchWindow := Screen.Forms[i]; Break; end; end; Assert(WatchWindow <> Nil); if WatchWindow <> Nil then begin Memo1.Lines.Add('Looking for VST'); for i := 0 to WatchWindow.ComponentCount - 1 do begin Memo1.Lines.Add(IntToStr(i) + ':' + WatchWindow.Components[i].ClassName); if WatchWindow.Components[i] is TVirtualStringTree then begin VST := TVirtualStringTree(WatchWindow.Components[i]); Memo1.Lines.Add('found VST'); Break; end; end; if VST = Nil then Memo1.Lines.Add('VST not found'); end; end; 

Btw, I understand that decisions that depend on the resulting IDE details are likely to be fragile, but it's just for fun (I liked the task of getting string data from a component that goes out of its way to avoid storing any).

+6
source share
1 answer

Maybe you can try to use only the published properties built into the implementation of the TVirtualStringTree IDE using the RTTI methods to do what you want?

0
source

All Articles