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
Can function be used for ...
by
VisualLab
[
Today
at 12:18:23 pm]
Multithreading - synchron...
by
mika
[
Today
at 12:08:20 pm]
A fairly simple sound sol...
by
Giorgos
[
Today
at 11:45:19 am]
match automatic highlight...
by
Чебурашка
[
Today
at 11:35:14 am]
Tchart with dual numbers ...
by
wp
[
Today
at 10:48:18 am]
trunk compiler bug for mi...
by
Key-Real
[
Today
at 10:44:52 am]
Generics - correct syntax
by
VisualLab
[
Today
at 10:23:16 am]
Compile/Convert Delphi pr...
by
TRon
[
Today
at 09:59:52 am]
add new targets to make
by
Key-Real
[
Today
at 09:38:23 am]
Debugger crashes with App...
by
Martin_fr
[
Today
at 09:29:46 am]
Copyrights Q
by
BrassGear
[
Today
at 09:13:14 am]
[SOLVED] how to build the...
by
Key-Real
[
Today
at 09:12:33 am]
Quirky windows
by
tetrastes
[
Today
at 08:59:06 am]
May be useful to somebody
by
Handoko
[
Today
at 07:35:48 am]
How can I draw a rectangl...
by
Handoko
[
Today
at 07:30:55 am]
Draw a line in the Scroll...
by
Handoko
[
Today
at 07:27:54 am]
Offical launch of the 1 B...
by
Handoko
[
Today
at 06:05:11 am]
web development using pas...
by
Nate897
[
Today
at 02:04:05 am]
questionable function def...
by
440bx
[
Today
at 01:35:28 am]
Why isn't TTIRadioGroup's...
by
jamie
[
Today
at 12:13:45 am]
Same project and two Pcs
by
caiov1n1c1us
[
Today
at 12:04:00 am]
v3.99 code completion que...
by
440bx
[April 22, 2024, 11:08:26 pm]
[SOLVED]RichMemo StringRe...
by
KodeZwerg
[April 22, 2024, 08:44:40 pm]
[SOLVED] LAMW/Linux - Ins...
by
Alcatiz
[April 22, 2024, 08:04:06 pm]
[SOLVED] TimeStampToMSecs...
by
korba812
[April 22, 2024, 06:23:33 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Help VirtualStringTree search/filter nodes (Read 7944 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: 231
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: 14377
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: 14377
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: 505
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: 505
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