I created simple project to show you my problem with TImage component. For example I added TCategoryPanelGroup, TCategoryPanel, TImage and two standard buttons which are use for hiding and showing Picture in TImage copomonent. You can see code for these buttons below:
unit Unit3;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Buttons,
Vcl.Imaging.jpeg, Vcl.ExtCtrls;
type
TForm3 = class(TForm)
CategoryPanelGroup1: TCategoryPanelGroup;
CategoryPanel1: TCategoryPanel;
imgTest: TImage;
btnShow: TBitBtn;
btnHide: TBitBtn;
procedure btnHideClick(Sender: TObject);
procedure btnShowClick(Sender: TObject);
end;
var
Form3: TForm3;
implementation
{$R *.dfm}
procedure TForm3.btnHideClick(Sender: TObject);
begin
imgTest.Visible := False;
imgTest.Refresh;
CategoryPanel1.Refresh;
CategoryPanelGroup1.Refresh; // Refreshing TCategoryPanel Parent
CategoryPanelGroup1.Invalidate;
CategoryPanelGroup1.Repaint;
{ Just one way which I found to 'refresh'- hide image dynamically
CategoryPanel1.Visible := False;
CategoryPanel1.Visible := True;
}
end;
procedure TForm3.btnShowClick(Sender: TObject);
begin
imgTest.Visible := True;
imgTest.Refresh;
CategoryPanel1.Refresh;
CategoryPanelGroup1.Refresh;
end;
end.
Unfortunatelly if we click on Hide button Picture stuck in the same place. If we would like refresh it we have to collapse and expand CategoryPanel1 (or uncomment the lines of code). Do you know how we can do it dynamically after click on button?