Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
General
»
Help VirtualStringTree search/filter nodes
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
IRC channel
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
create system unit from s...
by
Laksen
[
Today
at 01:28:35 pm]
How to get along with the...
by
BrassGear
[
Today
at 01:24:31 pm]
Spiral of Theodorus: Reve...
by
Roland57
[
Today
at 01:24:14 pm]
I just released a commerc...
by
BrassGear
[
Today
at 01:20:51 pm]
InstallAware Using Lazaru...
by
dbannon
[
Today
at 01:05:38 pm]
Improvement of TFPTimerTh...
by
lagprogramming
[
Today
at 12:53:29 pm]
Assign (textfile) not com...
by
Thaddy
[
Today
at 12:18:09 pm]
Question for people who h...
by
marcov
[
Today
at 12:04:56 pm]
[SOLVED] assembler name i...
by
Laksen
[
Today
at 11:40:43 am]
Warning: Source OS Redefi...
by
Laksen
[
Today
at 11:32:46 am]
[SOLVED] how to see what ...
by
Laksen
[
Today
at 11:30:25 am]
Slow copying of small str...
by
alpine
[
Today
at 11:25:10 am]
How to: create DLL file f...
by
KodeZwerg
[
Today
at 10:53:20 am]
Text orientation in TMemo...
by
wp
[
Today
at 10:27:54 am]
Linux Workspaces -- StayO...
by
AmatCoder
[
Today
at 08:21:27 am]
Demoscene The Champs Crac...
by
Lulu
[
Today
at 08:15:12 am]
Azure sql database will n...
by
paweld
[
Today
at 07:24:47 am]
Find child controls by na...
by
Handoko
[
Today
at 04:17:05 am]
location of non visual co...
by
VisualLab
[April 17, 2024, 11:58:55 pm]
For-in loop over constant...
by
Joanna
[April 17, 2024, 11:57:15 pm]
Lazarus editor feature re...
by
440bx
[April 17, 2024, 11:49:08 pm]
How would you define a fi...
by
wp
[April 17, 2024, 11:04:00 pm]
Directx9 with mylogo insi...
by
KodeZwerg
[April 17, 2024, 11:03:54 pm]
Lazarus for Windows on aa...
by
Wallaby
[April 17, 2024, 10:25:46 pm]
[SOLVED] TDbf table, Leve...
by
1HuntnMan
[April 17, 2024, 10:03:16 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Help VirtualStringTree search/filter nodes (Read 7932 times)
todhuk
New Member
Posts: 15
Help VirtualStringTree search/filter nodes
«
on:
October 20, 2017, 05:05:47 pm »
I want to search for text in TVirtualStringTree.
However, I get a line error:
Error: Wrong number of parameters specified for call to "SearchText"
This is the code:
Code: Pascal
[Select]
[+]
[-]
procedure
TMainForm
.
SearchText
(
Sender
:
TBaseVirtualTree
;
Node
:
PVirtualNode
;
Data
:
Pointer
;
var
Abort
:
Boolean
)
;
var
NodeData
:
PData
;
sText
:
String
;
bVisible
:
Boolean
;
begin
NodeData
:
=
Sender
.
GetNodeData
(
Node
)
;
Abort
:
=
False
;
bVisible
:
=
True
;
sText
:
=
String
(
data
)
;
if
Length
(
sText
)
>
0
then
begin
if
Pos
(
sText
,
NodeData
^
.
BName
)
<>
1
then
begin
bVisible
:
=
False
;
end
;
end
;
Sender
.
IsVisible
[
Node
]
:
=
bVisible
;
end
;
procedure
TMainForm
.
btnSearch1Click
(
Sender
:
TObject
)
;
var
foundNode
:
PVirtualNode
;
begin
VST1
.
BeginUpdate
;
try
foundNode
:
=
VST1
.
IterateSubtree
(
nil
,
SearchText
,
PChar
(
findEdit
.
Text
)
)
;
finally
VST1
.
EndUpdate
;
end
;
end
;
Logged
taazz
Hero Member
Posts: 5368
Re: Help VirtualStringTree search/filter nodes
«
Reply #1 on:
October 20, 2017, 05:17:02 pm »
Code: Pascal
[Select]
[+]
[-]
foundNode
:
=
VST1
.
IterateSubtree
(
nil
,
@
SearchText
,
PChar
(
findEdit
.
Text
)
)
;
//Pay attention to the symbol @.
This should solve it, if not post again I'll take a closer look.
Logged
Good judgement is the result of experience … Experience is the result of bad judgement.
OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64
WooBean
Full Member
Posts: 230
Re: Help VirtualStringTree search/filter nodes
«
Reply #2 on:
October 20, 2017, 05:23:56 pm »
Hi, todhuk!
First, try to read what you are going to post.
Explain what is "VST1" (variable or property type). I think that you will find the answer by yourself.
«
Last Edit: October 20, 2017, 05:33:59 pm by WooBean
»
Logged
Platforms: Win7/64, Linux Mint Ulyssa/64
Thaddy
Hero Member
Posts: 14369
Sensorship about opinions does not belong here.
Re: Help VirtualStringTree search/filter nodes
«
Reply #3 on:
October 20, 2017, 05:34:36 pm »
SearchText needs a var parameter...... Which needs to be declared AND initialized beforehand.
Logged
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.
todhuk
New Member
Posts: 15
Re: Help VirtualStringTree search/filter nodes
«
Reply #4 on:
October 20, 2017, 05:35:15 pm »
Okay taazz
But why in the example "Advanced"(see unit VisibilityDemo) of the VirtualTreeView package, everything works without "@"?
Logged
Thaddy
Hero Member
Posts: 14369
Sensorship about opinions does not belong here.
Re: Help VirtualStringTree search/filter nodes
«
Reply #5 on:
October 20, 2017, 05:36:13 pm »
Mode delphi? First count your parameters...
Logged
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.
todhuk
New Member
Posts: 15
Re: Help VirtualStringTree search/filter nodes
«
Reply #6 on:
October 20, 2017, 06:00:48 pm »
well, thank you!
Logged
majid.ebru
Hero Member
Posts: 502
Re: Help VirtualStringTree search/filter nodes
«
Reply #7 on:
March 10, 2018, 06:06:12 am »
Hi
Code: Pascal
[Select]
[+]
[-]
procedure
SearchText
(
Sender
:
TBaseVirtualTree
;
Node
:
PVirtualNode
;
Data
:
Pointer
;
var
Abort
:
Boolean
)
;
var
NodeData
:
PMyNode
;
sText
:
String
;
bVisible
:
Boolean
;
begin
NodeData
:
=
Sender
.
GetNodeData
(
Node
)
;
Abort
:
=
False
;
bVisible
:
=
True
;
sText
:
=
String
(
data
)
;
if
Length
(
sText
)
>
0
then
begin
if
Pos
(
sText
,
NodeData
^
.
Col1
)
<>
1
then
begin
bVisible
:
=
False
;
end
;
end
;
Sender
.
IsVisible
[
Node
]
:
=
bVisible
;
end
;
//-----------------
procedure
TFormMain
.
B_T3_1_5Click
(
Sender
:
TObject
)
;
var
foundNode
:
PVirtualNode
;
begin
VST
.
BeginUpdate
;
try
foundNode
:
=
VST
.
IterateSubtree
(
nil
,
@
SearchText
,
PChar
(
E_T3_1_5
.
Text
)
)
;
finally
VST
.
EndUpdate
;
end
;
end
;
i use these codes but i have error:
Code: Pascal
[Select]
[+]
[-]
foundNode
:
=
VST
.
IterateSubtree
(
nil
,
@
SearchText
,
PChar
(
E_T3_1_5
.
Text
)
)
;
unit_Main.pas(4434,51) Error: Incompatible type for arg no. 2: Got "<address of procedure(TBaseVirtualTree;PVirtualNode;Pointer;var Boolean);Register>", expected "<procedure variable type of procedure(TBaseVirtualTree;PVirtualNode;Pointer;var Boolean) of object;Register>"
Logged
balazsszekely
Guest
Re: Help VirtualStringTree search/filter nodes
«
Reply #8 on:
March 10, 2018, 08:15:49 am »
Add SearchMain to TFormMain's private section:
procedure
TFormMain.
SearchText (...
Logged
majid.ebru
Hero Member
Posts: 502
Re: Help VirtualStringTree search/filter nodes
«
Reply #9 on:
March 10, 2018, 04:55:24 pm »
@GetMem thank you
it worked but it doesn't work true?!?
i search "B4000"
this item is visible ( visible is true)
but all parent of this item(B4000) is invisible(visible is false) and i can't see B4000?
how can i show all parent of item?
(how can i set visible ture all of parent?)
Logged
balazsszekely
Guest
Re: Help VirtualStringTree search/filter nodes
«
Reply #10 on:
March 10, 2018, 05:58:31 pm »
@maid.ebru
I have no idea what are you trying to achieve. Why B4000 parents are not visible? Anyway let's say you find B4000 and you wish to set all it's parents visibility to true, you can try something like this:
Code: Pascal
[Select]
[+]
[-]
// Node is B4000 here
Node
:
=
Node
^
.
Parent
;
//<--B4000 parent
while
Node <>
nil
do
begin
VST
.
IsVisible
[
Node
]
:
=
True
;
Node
:
=
Node
^
.
Parent
;
//<--B4000 grand parent and so one
end
;
Logged
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
General
»
Help VirtualStringTree search/filter nodes
TinyPortal
© 2005-2018