SergioFeitoza Posted October 14, 2019 Share Posted October 14, 2019 Does anyone know of a demo that shows a Tunitreeview that uses customized icons and has the text of nodes and sub-nodes with colors and different letters? I'm trying to do it for days, but I am missing something and does not work. Please check the figure attached. The code I use to construct the navigator (navtree) is procedure TMainForm.ConstructNavigator; var RawS : RawByteString; S, S1, Path, SubS : string; sr: TSearchRec; Ls : TStringList; Txt : TextFile; I, iPos, index, groupindex, mainindex : Integer; Nd,Nd1 : TUniTreeNode; Mt, Mt1 : TUniMenuItem; iconfile, groupIconFile, mainIconFile: string; begin sAplicacao := TStringList.Create; sDescricao := TStringList.Create; sNivel := TStringList.Create; sItem := TStringList.Create; sSubItem := TStringList.Create; Path := UniServerModule.StartPath; Nd := NavTree.Items.Add(nil, 'Home'); Nd.Data := UniTabSheet1; mainIconFile := Path+'UNITSmy\icons\main.ico'; mainindex := CreateImageIndex(mainIconFile); nd.ImageIndex := mainindex; UniTabSheet1.Tag := NativeInt(Nd); UniTabSheet1.ImageIndex := mainindex; NavTree.Selected := Nd; With UniMainModule.qryAplicacao do begin Open; while Not eof do begin UniMainModule.qryPerfilAplicacao.Close; UniMainModule.qryPerfilAplicacao.Params[0].Value := UniMainModule.PERFIL; UniMainModule.qryPerfilAplicacao.Params[1].Value := UniMainModule.qryAplicacao.FieldByName('APLICACAO').AsString; UniMainModule.qryPerfilAplicacao.Open; mainindex := Nisfc.AddIconCls( UniMainModule.qryAplicacao.FieldByName('imagem').AsString ); if not UniMainModule.qryPerfilAplicacao.IsEmpty then begin // mainIconFile := Path+'UNITSmy\Icons\'+UniMainModule.qryaplicacaoNIVEL.AsString+'.ico'; // mainindex := CreateImageIndex(mainIconFile); if UniMainModule.qryAplicacao.FieldByName('NODE').AsInteger = 0 then begin Nd := NavTree.Items.Add(nil, UniMainModule.qryaplicacao.FieldByName('DESCRICAO').AsString); nd.ImageIndex := mainindex; Mt := TUniMenuItem.Create(Self); Mt.Caption := UniMainModule.qryAplicacao.FieldByName('DESCRICAO').AsString; Mt.ImageIndex := mainindex; end else begin Nd1 := NavTree.Items.Add(Nd, UniMainModule.qryAplicacao.FieldByName('DESCRICAO').AsString); nd1.ImageIndex := mainindex; sDescricao.Add( UniMainModule.qryAplicacao.FieldByName('DESCRICAO').AsString ); sAplicacao.Add( UniMainModule.qryAplicacao.FieldByName('NIVEL').AsString+'-'+UniMainModule.qryAplicacao.FieldByName('APLICACAO').AsString ); sNivel.Add( UniMainModule.qryAplicacao.FieldByName('NIVEL').AsString ); nd1.Tag := UniMainModule.qryAplicacao.FieldByName('NIVEL').AsInteger; sItem.Add( UniMainModule.qryAplicacao.FieldByName('item').AsString ); sSubItem.Add( UniMainModule.qryAplicacao.FieldByName('subItem').AsString ); Mt1 := TUniMenuItem.Create(Self); Mt1.Caption := UniMainModule.qryAplicacao.FieldByName('DESCRICAO').AsString; Mt1.ImageIndex := mainindex; Mt1.OnClick := Navigate1Click; Mt1.Tag := UniInteger(Nd1); Mt.Add(Mt1); end; end; Next; end; end; end; Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted October 15, 2019 Share Posted October 15, 2019 Hi, maybe something tlike : (thx to our Maestro Sherzod). Regards 1 Quote Link to comment Share on other sites More sharing options...
SergioFeitoza Posted October 16, 2019 Author Share Posted October 16, 2019 Thank you very much Abaksoft and Sherzod It works well. Now I will try to see about what I am doing wrong about icons Also I am trying to insert ad event in such a way that when I pass the mouse over the tree node I make visible a figure in the middle of the form Thanks again Quote Link to comment Share on other sites More sharing options...
Sherzod Posted October 16, 2019 Share Posted October 16, 2019 4 hours ago, SergioFeitoza said: Now I will try to see about what I am doing wrong about icons Also I am trying to insert ad event in such a way that when I pass the mouse over the tree node I make visible a figure in the middle of the form Hello, If this is an issue, make a simple testcase for check. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.