A newbie shelltreeview question lazarus / 31-LCL ---------------------------------------------------------------------- ballhawk · 2013-02-18 21:48 I'm new to Lazarus/freepascal but not to programming. I have searched extensively here and on the net but still need help. I have a form with shelltreeview and shellLstview and a button on it. Eventually I'd like to mimic the windows explorer feature of typing a letter and having the first matching directory highlighted but I'm starting simple and just trying to hard code a string into the button and show a message. this is the code for the button clicked event: showmessage(shelltreeview1.Items.FindNodeWithText('a')) I get this error message: Error: Incompatible type for arg no. 1: Got "TTreeNode", expected "AnsiString" I'm not sure if I left out any semicolons, colons, etc., or if I need more to make this work. It's just combining properties with a function as far as I can tell. but I am a newbie  Certainly not asking anyone to do work for me, I'm ok with doing my own. If anyone can help, or point me in the right direction to find answers I'd appreciate it. ---------------------------------------------------------------------- taazz · 2013-02-18 21:57 showmessage takes a string as parameter findNodewithText returns a TTreeNode class try using showmessage(ShellTreeView1.Items.FindNodeWithText('a').Text); ---------------------------------------------------------------------- ballhawk · 2013-02-18 22:01 I'll give that a try. Thanks! ---------------------------------------------------------------------- theo · 2013-02-18 22:02 Quote from: taazz on February 18, 2013, 10:57:10 pmshowmessage(ShellTreeView1.Items.FindNodeWithText('a').Text); Correct but dangerous. If the text is not found the function will return nil. Accessing the Text property will crash in this case. Code: [Select]MyTreeNode:=ShellTreeView1.Items.FindNodeWithText('a'); if Assigned(MyTreeNode) then Showmessage(MyTreeNode.Text); ---------------------------------------------------------------------- taazz · 2013-02-18 22:11 Quote from: theo on February 18, 2013, 11:02:25 pmQuote from: taazz on February 18, 2013, 10:57:10 pmshowmessage(ShellTreeView1.Items.FindNodeWithText('a').Text); Correct but dangerous. If the text is not found the function will return nil. Accessing the Text property will crash in this case. Code: [Select]MyTreeNode:=ShellTreeView1.Items.FindNodeWithText('a'); if Assigned(MyTreeNode) then Showmessage(MyTreeNode.Text); True, I haven't elaborated farther because the code posted makes no sense in the 1st place. Why go to the trouble of searching a treenode using its text property as a criterion to just show that text on a message when a simple showmessage('a') accomplishes the same result. So I assumed that the code is a sample of a bigger procedure that is there for debugging or analyses purposes and not to be used on a release software. ---------------------------------------------------------------------- Blaazen · 2013-02-18 22:17 Quote...  because the code posted makes no sense in the 1st place. Why go to the trouble of searching a treenode using its text property as a criterion to just show that text on a message when a simple showmessage('a') accomplishes the same result.I agree. I think OP wants something like this: Code: [Select]procedure TForm1.Button1Click(Sender: TObject); var     mytreenode:TTreeNode; var i: Integer; begin   for i:=0 to ShellTreeView1.Items.Count-1 do     if ShellTreeView1.Items[i].Text[1] = 'D' then       showmessage(shelltreeview1.Items[i].Text); end; ---------------------------------------------------------------------- ballhawk · 2013-02-18 22:35 QuoteCorrect but dangerous. If the text is not found the function will return nil. Accessing the Text property will crash in this case. Yes, got some SIGSERVG (sp.?) error QuoteI haven't elaborated farther because the code posted makes no sense in the 1st place. My code never makes sense.  QuoteI agree. I think OP wants something like this: Code: [Select] procedure TForm1.Button1Click(Sender: TObject); var     mytreenode:TTreeNode; var i: Integer; begin   for i:=0 to ShellTreeView1.Items.Count-1 do     if ShellTreeView1.Items.Text[1] = 'D' then       showmessage(shelltreeview1.Items.Text); end;      Yes that's closer to what I want. I'm attempting to write my own utill and learn FPL and expand my knowledge. Ultimately I'd like to navigate to a group of files on my disk, multiselect from the interface and run the files through a process. I already do this using other tools. I tend to prefer using combinations of keypresses (left over from my DOS days) and gui to navigate. Strange the stuff we get into to have "fun". Sincerely appreciate all the posts so far. Very helpful to me.