Jump to content

Mouse over subitem TREEVIEW show image


SergioFeitoza

Recommended Posts

5 hours ago, SergioFeitoza said:

Can you post the code  of the mouse event ?

Hi,

First of all, can you please open a ticket in support portal as feature request?

http://jira.fmsoft.net/servicedesk/customer/portal/4

 

And, can you tell me how do you add nodes to the treeview, designtime or runtime? Can you provide part of your code or a simple testcase?!

Link to comment
Share on other sites

Hi Sherzod. I will open the ticket now. Below is the code for the creation of the treeview in DESGINTIME . Is not equal to the one in the unugui demo AllFeatures

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+'units\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 := Ni.AddIconCls( UniMainModule.qryAplicacao.FieldByName('imagem').AsString );

        if not UniMainModule.qryPerfilAplicacao.IsEmpty then
        begin
            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;

procedure TMainForm.Navigate1Click(Sender: TObject);
var
  Nd : TUniTreeNode;
begin
  Nd := Pointer((Sender as TUniMenuItem).Tag);
  if Assigned(Nd) then
  begin
    NavTree.Selected := Nd;
    NavTreeClick(Nd);
  end;
end;

procedure TMainForm.NavTreeClick(Sender: TObject);
var
  Nd : TUniTreeNode;
  Ts : TUniTabSheet;
  FrC : TUniFrameClass;
  Fr : TUniFrame;
  FClassName, iconfile, Path : string;
  index: Integer;
  vAplicacao : String;
begin
  Path := UniServerModule.StartPath + 'units\';
  Nd := NavTree.Selected;

  Try
    tipo_Projeto := sItem[    snivel.indexof( nd.tag.ToString ) ].ToInteger;
    tipo_calc    := sSubItem[ snivel.indexof( nd.tag.ToString ) ].ToInteger;
    vAplicacao := Copy( sAplicacao[ sDescricao.IndexOf(Nd.Text ) ], 8);
  Except
     Abort;
  End;

  if Nd.Count = 0 then
  begin
    Ts := Nd.Data;
    if not Assigned(Ts) then
    begin
      Ts := TUniTabSheet.Create(Self);
      Ts.Closable := True;
      Ts.OnClose := TabSheetClose;
      Ts.PageControl := UniPageControl1;
      Ts.Tag := NativeInt(Nd);
      Ts.Caption := Nd.Text;
      Ts.ImageIndex := Nd.ImageIndex;

      FClassName   :=  vAplicacao ;

      FrC := TUniFrameClass(FindClass(FClassName));

      Fr := FrC.Create(Ts);
      Fr.Align := alClient;
      Fr.Parent := Ts;

      Nd.Data := Ts;
    end;
    UniPageControl1.ActivePage := Ts;
  end;
end;

 

 

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...