Jump to content

steelha

Members
  • Content Count

    3
  • Joined

  • Last visited

Everything posted by steelha

  1. steelha

    Is TImage empty

    Sorry dont pass all the code imgFLogin.Picture.Assign(nil); then i call the procedure LoginImage(ExtractFilePath(Application.ExeName))
  2. steelha

    Is TImage empty

    I hope this code help you procedure LoginImage(const RutaBase: string); var filename : string; ImagenBMP: TBitmap; ImagenJPG: TJPEGImage; ImagenPNG: TPngImage; filefind: Boolean; begin ImagenBMP := nil; ImagenJPG := nil; ImagenPNG := nil; filefind:= False; try // Intentar cargar como BMP filename:= IncludeTrailingPathDelimiter(RutaBase) + 'flogin.bmp'; if FileExists(filename) then begin ImagenBMP := TBitmap.Create; ImagenBMP.LoadFromFile(filename); imgFLogin.Picture.Assign(ImagenBMP); filefind := True; end else begin Showmessage('File not fouund') end; finally // Liberar los objetos si fueron creados ImagenBMP.Free; ImagenJPG.Free; ImagenPNG.Free; end; end; just pass the file path. Can change Tbimap.create for TJPEGImage.Create; or TPngImage.Create;, imgFLogin its the image timage visual component you want load the image
  3. steelha

    Delphi 12 Ribbon Issue

    Hello, I'm having trouble creating a dynamic menu from a table using the Ribbon component in Delphi 12. I've created the tabs as the main menu options and the groups as submenus, but when I try to create the items for each group, I only get one. Here's the image and code. If anyone knows how to solve the problem I would be very grateful. CODE: procedure TfrmPrincipal.Cargar_Menu; var TabItem : TRibbonTabItem; Group : TRibbonGroup; BarAction : TActionClientItem; PadreIDTab : Integer; PadreIDGrupo : Integer; BarItem : TActionBarItem; Bg : TRibbonLargeButtonControl; Bs : TRibbonSmallButtonControl; begin ribMenu.Tabs.Clear; QryMenu.Close; QryMenu.SQL.Clear; QryMenu.SQL.Add('SELECT * '); QryMenu.SQL.Add('FROM Menu '); QryMenu.SQL.Add('WHERE (padre_id IS NULL OR padre_id = 0) AND activo = 1 '); QryMenu.SQL.Add('ORDER BY orden'); QryMenu.Open; QryMenu.First; while not QryMenu.Eof do // Crear las pestañas principales begin TabItem := ribMenu.Tabs.Add; TabItem.Caption := Trim(QryMenu.FieldByName('titulo').Value); PadreIDTab := QryMenu.FieldByName('menu_item_id').Value; QrySubMenu.Close; QrySubMenu.SQL.Clear; QrySubMenu.SQL.Add('SELECT * '); QrySubMenu.SQL.Add('FROM Menu '); QrySubMenu.SQL.Add('WHERE padre_id = :PadreIDTab AND activo = 1 '); // Obtener los grupos de la pestaña QrySubMenu.SQL.Add('ORDER BY orden'); QrySubMenu.Parameters.ParamByName('PadreIDTab').Value := PadreIDTab; QrySubMenu.Open; QrySubMenu.First; while not QrySubMenu.Eof do // Crear los grupos dentro de la pestaña begin if UpperCase(QrySubMenu.FieldByName('tipo').Value) = 'GRUPO' then begin Group := TRibbonGroup.Create(ribMenu); Group.Parent := TabItem.Page; Group.Caption := Trim(QrySubMenu.FieldByName('titulo').AsString); PadreIDGrupo := QrySubMenu.FieldByName('menu_item_id').Value; // Capturar el ID del grupo QryItems.Close; QryItems.SQL.Clear; QryItems.SQL.Add('SELECT * '); QryItems.SQL.Add('FROM Menu '); QryItems.SQL.Add('WHERE padre_id = :PadreIDGrupo AND activo = 1 '); // Obtener los ítems del grupo QryItems.SQL.Add('ORDER BY orden'); QryItems.Parameters.ParamByName('PadreIDGrupo').Value := PadreIDGrupo; QryItems.Open; QryItems.First; while not QryItems.Eof do // Crear los ítems dentro del grupo begin if UpperCase(QryItems.FieldByName('tipo').Value) = 'ITEM' then begin BarItem := amMenu.ActionBars.Add; BarAction := BarItem.Items.Add; BarAction.Caption := Trim(QryItems.FieldByName('titulo').Value); BarItem.ActionBar := Group; end; QryItems.Next; end; QryItems.Close; // Cerrar la consulta de ítems end; QrySubMenu.Next; end; QrySubMenu.Close; // Cerrar la consulta de grupos QryMenu.Next; end; QryMenu.Close; // Cerrar la consulta de pestañas end;
×