PageControl + SynEdit - PageControl.ActivePage.Free lazarus / 31-LCL ---------------------------------------------------------------------- BIT · 2018-01-05 08:43 Здравствуйте возникла не преодолимая ошибка c динамическими созданными компонентами TabSheet+TSynEdit (PageControl.ActivePage.Free) Если удалить последнею вкладку все работает отлично, а если удалить любую другую предыдущие вкладки по index в основном 2 теряют sender внутри TabSheet то есть больше нельзя скопировать вставить текст обратиться к SynEdit по имени и т.п. Hello was no insurmountable error c dynamic created components TabSheet+TSynEdit (PageControl.ActivePage.Free) If you remove the last tab, everything works fine, but if remove any other previous tab index is basically 2 lose a sender inside a TabSheet that is no longer possible to copy paste the text to refer to SynEdit by name, etc. Еще раз: Есть 10 вкладок с редактором, удаляем  вкладку 7, остается 9 вкладок, вкладка 1,2,3,4,5,6 остаются рабочими, вкладки 7,8,9 вызывают ошибку! Again: There are 10 tabs with the editor, remove the tab 7, is 9 tabs, tab 1,2,3,4,5,6 remain working, tabs 7,8,9 fail! Так создаю: So creating: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var Tab: TTabSheet;  rSynEdit: TSynEdit;    ................................... .................................   Tab := TTabSheet.Create(self);  Tab.PageControl := PageControl1;  Tab.Caption := TabCaption;  Tab.PageControl.ActivePage := Tab;   rSynEdit := TSynEdit.Create(Tab);  rSynEdit.Parent := Tab;  rSynEdit.Align := alClient;  rSynEdit.Name := 'syed' + IntToStr(PageControl1.PageCount); Так удаляю: So remove: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  procedure TForm1.MenuItem16Click(Sender: TObject);begin  PageControl1.ActivePage.Free;  end;   VIDEO : https://youtu.be/N8PC2XOx5dc Прикрепил картинку тут я удалил ActivePage и после в активной вкладке попытался скопировать текст в буфер обмена и получил ошибку. Attached the picture here I have removed ActivePage and after the active tab has tried to copy the text to clipboard and got an error. ---------------------------------------------------------------------- Bart · 2018-01-05 09:52 Use Applicatione.ReleaseComponent() instead? Bart ---------------------------------------------------------------------- BIT · 2018-01-05 09:57 Quote from: Bart on January 05, 2018, 10:52:32 amUse Applicatione.ReleaseComponent() instead? Bart Пробовал все тоже самое даже пытался удалять по отдельности отвязывать друг от друга ничего не помогает(( Tried all the same even tried to remove individually, to decouple from each other helps nothing(( ---------------------------------------------------------------------- BIT · 2018-01-05 10:04 Quote from: Bart on January 05, 2018, 10:52:32 amUse Applicatione.ReleaseComponent() instead? Bart PageControl1.ActivePage.Free; Удаляет компонент и все что в нем вложено но еще что то зацепляет по index компонентов других вкладок а вот что понять не могу Кстати если удалить компонент SynEdit отдельно не удаляя самой вкладки тогда остальные SynEdit работают отлично PageControl1.ActivePage.Free; Removes a component and all that invested in it but still that gear for index components the other tabs but what I can not understand By the way if you remove SynEdit component separately without deleting the tab itself then the rest SynEdit works fine VIDEO : https://youtu.be/N8PC2XOx5dc ---------------------------------------------------------------------- howardpc · 2018-01-05 11:20 You can't use TTabsheet.Free in this case because tabsheets are managed internally by the control. You need access to the protected RemovePage() method. Note that you are not allowed to remove the last tabsheet if it is the only one remaining (a widgetset limitation I think). Try this: in a new Lazarus project drop a button and a pagecontrol on the main form. Complete as follows: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$mode objfpc}{$H+} interface uses  SysUtils, Forms, Controls, ComCtrls, StdCtrls, SynEdit; type   TPageControl = class(ComCtrls.TPageControl)  // this is a hack to give access to protected methods  end;   TForm1 = class(TForm)    PageControl1: TPageControl;    RemoveButton: TButton;    procedure FormCreate(Sender: TObject);    procedure RemoveButtonClick(Sender: TObject);  end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.FormCreate(Sender: TObject);var  Tab: TTabSheet;  rSynEdit: TSynEdit;  i: Integer;begin  for i:=0 to 3 do begin    Tab := TTabSheet.Create(self);    Tab.PageControl := PageControl1;    Tab.Caption := Format('Tab%d',[i]);    Tab.PageControl.ActivePage := Tab;     rSynEdit := TSynEdit.Create(Tab);    rSynEdit.Parent := Tab;    rSynEdit.Align := alClient;    rSynEdit.RightEdge := 0;    rSynEdit.BorderStyle := bsNone;  end;end; procedure TForm1.RemoveButtonClick(Sender: TObject);var  tab: TTabSheet;begin  tab:=PageControl1.ActivePage;  if Assigned(tab) and    (PageControl1.PageCount > 1) then // you cannot remove the last tabsheet    PageControl1.RemovePage(tab.TabIndex);end; end. ---------------------------------------------------------------------- BIT · 2018-01-05 11:29 Quote from: howardpc on January 05, 2018, 12:20:52 pmYou can't use TTabsheet.Free in this case because tabsheets are managed internally by the control. You need access to the protected RemovePage() method. Note that you are not allowed to remove the last tabsheet if it is the only one remaining (a widgetset limitation I think). Try this: in a new Lazarus project drop a button and a pagecontrol on the main form. Complete as follows: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$mode objfpc}{$H+} interface uses  SysUtils, Forms, Controls, ComCtrls, StdCtrls, SynEdit; type   TPageControl = class(ComCtrls.TPageControl)  // this is a hack to give access to protected methods  end;   TForm1 = class(TForm)    PageControl1: TPageControl;    RemoveButton: TButton;    procedure FormCreate(Sender: TObject);    procedure RemoveButtonClick(Sender: TObject);  end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.FormCreate(Sender: TObject);var  Tab: TTabSheet;  rSynEdit: TSynEdit;  i: Integer;begin  for i:=0 to 3 do begin    Tab := TTabSheet.Create(self);    Tab.PageControl := PageControl1;    Tab.Caption := Format('Tab%d',[i]);    Tab.PageControl.ActivePage := Tab;     rSynEdit := TSynEdit.Create(Tab);    rSynEdit.Parent := Tab;    rSynEdit.Align := alClient;    rSynEdit.RightEdge := 0;    rSynEdit.BorderStyle := bsNone;  end;end; procedure TForm1.RemoveButtonClick(Sender: TObject);var  tab: TTabSheet;begin  tab:=PageControl1.ActivePage;  if Assigned(tab) and    (PageControl1.PageCount > 1) then // you cannot remove the last tabsheet    PageControl1.RemovePage(tab.TabIndex);end; end. сейчас попробую ваш код а вот VIDEO: https://youtu.be/N8PC2XOx5dc с моей ошибкой now I will try your code and here is the VIDEO: https://youtu.be/N8PC2XOx5dc my mistake ---------------------------------------------------------------------- taazz · 2018-01-05 11:32 Quote from: howardpc on January 05, 2018, 12:20:52 pmYou can't use TTabsheet.Free in this case because tabsheets are managed internally by the control. that is a bug not a feature and needs to be reported. Quote from: howardpc on January 05, 2018, 12:20:52 pmYou need access to the protected RemovePage() method. isn't this method called indirectly by setting the ttabsheet.pagecontrol := nil ? ---------------------------------------------------------------------- BIT · 2018-01-05 11:34 Quote from: taazz on January 05, 2018, 12:32:20 pmQuote from: howardpc on January 05, 2018, 12:20:52 pmYou can't use TTabsheet.Free in this case because tabsheets are managed internally by the control. that is a bug not a feature and needs to be reported. Quote from: howardpc on January 05, 2018, 12:20:52 pmYou need access to the protected RemovePage() method. isn't this method called indirectly by setting the ttabsheet.pagecontrol := nil ? Пробовал nil self указывал компонент parent вообщем пока ничего не помогает Tried nil self component parent indicated generally while helps nothing ---------------------------------------------------------------------- BIT · 2018-01-05 12:01 Application.ReleaseComponent(PageControl 1.ActivePage);     PageControl1.ActivePage.Free;       PageControl1.ActivePage.Destroy;         PageControl1.RemoveControl(PageControl1.ActivePage);           PageControl1.RemoveComponent(PageControl1.ActivePage);                                                                                         не помогает((( ---------------------------------------------------------------------- taazz · 2018-01-05 12:28 tested on lazarus 1.6.4 I see no problem to free any tabsheet at any position from both pagecontrol and extendednotebook components. I do not have lazarus 1.8 installed so I can't test it for now. Find attached my test application. As far as I can tell it should work. Edit: Sorry I attached the wrong sample application re download the new one. ---------------------------------------------------------------------- BIT · 2018-01-05 12:32 Quote from: howardpc on January 05, 2018, 12:20:52 pmYou can't use TTabsheet.Free in this case because tabsheets are managed internally by the control. You need access to the protected RemovePage() method. Note that you are not allowed to remove the last tabsheet if it is the only one remaining (a widgetset limitation I think). Try this: in a new Lazarus project drop a button and a pagecontrol on the main form. Complete as follows: slightly modified code but the meaning is the same and the error below Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, FileUtil, SynEdit, Forms, Controls, Graphics, Dialogs,  StdCtrls, ComCtrls, Menus; type   TPageControl = class(ComCtrls.TPageControl)  // this is a hack to give access to protected methods  end; type   { TForm1 }   TForm1 = class(TForm)    Button1: TButton;    MenuItem1: TMenuItem;    PageControl1: TPageControl;    PopupMenu1: TPopupMenu;  procedure Button1Click(Sender: TObject);    procedure FormCreate(Sender: TObject);    procedure MenuItem1Click(Sender: TObject);  private   public   end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.FormCreate(Sender: TObject);var  Tab: TTabSheet;  rSynEdit: TSynEdit;  i: integer;begin  for i := 0 to 7 do  begin    Tab := TTabSheet.Create(self);    Tab.PageControl := PageControl1;    Tab.Caption := Format('Tab%d', [i]);    Tab.PageControl.ActivePage := Tab;     rSynEdit := TSynEdit.Create(Tab);    rSynEdit.Parent := Tab;    rSynEdit.Name := 'syed' + IntToStr(PageControl1.PageCount);    rSynEdit.PopupMenu := PopupMenu1;    rSynEdit.Align := alClient;    rSynEdit.RightEdge := 0;    rSynEdit.BorderStyle := bsNone;  end; end; procedure TForm1.MenuItem1Click(Sender: TObject);begin  (PageControl1.ActivePage.FindComponent('syed' + IntToStr(    PageControl1.ActivePageIndex + 1)) as TSynEdit).CopyToClipboard; end; procedure TForm1.Button1Click(Sender: TObject);var  tab: TTabSheet;begin  tab := PageControl1.ActivePage;  if Assigned(tab) and (PageControl1.PageCount > 1) then    // you cannot remove the last tabsheet    PageControl1.RemovePage(tab.TabIndex);end; end. Also not helped ---------------------------------------------------------------------- BIT · 2018-01-05 12:43 Quote from: taazz on January 05, 2018, 01:28:36 pmtested on lazarus 1.6.4 I see no problem to free any tabsheet at any position from both pagecontrol and extendednotebook components. I do not have lazarus 1.8 installed so I can't test it for now. Find attached my test application. As far as I can tell it should work. Edit: Sorry I attached the wrong sample application re download the new one. Удалить нет проблемы но и больше доступа ниже по Index нету к вложенным в вкладку компонентам это во всех версиях Lazarusa так было просто я сейчас только поднял вопрос Remove no problem but more access lower Index not attached to the tab component is in all versions of Lazarusa was so simple I just raised the issue ---------------------------------------------------------------------- howardpc · 2018-01-05 13:14 Actually I think your problem is not related to TPageControl or TTabsheet, but how you use synedit clipboard functionality. The error message you get appears to show that a synedit you expect to be instantiated is not. As with nearly all bugs, getting others to help you locate them without providing a compilable example that shows the bug, is almost certain to result in a wild goose chase. ---------------------------------------------------------------------- BIT · 2018-01-05 13:36 Прикрепил пример и видео как вызвать ошибку https://youtu.be/VtExS2W8oWs Attached example and video how to cause an error https://youtu.be/VtExS2W8oWs Example https://drive.google.com/open?id=1pltuCnMphmWqybPGv7XtXSwCePR7vxef ---------------------------------------------------------------------- ASerge · 2018-01-05 14:26 Quote from: BIT on January 05, 2018, 01:32:12 pmslightly modified code but the meaning is the same and the error below ... Also not helped I replaced TSynEdit, because it cannot compile to me, with TMemo. I saw a demonstration. The error does not reproduced. Lazarus 1.8 x64, Windows. ---------------------------------------------------------------------- BIT · 2018-01-05 14:30 Quote from: ASerge on January 05, 2018, 03:26:12 pmQuote from: BIT on January 05, 2018, 01:32:12 pmslightly modified code but the meaning is the same and the error below ... Also not helped I replaced TSynEdit, because it cannot compile to me, with TMemo. I saw a demonstration. The error does not reproduced. Lazarus 1.8 x64, Windows. Lazarus 1.8 x32, Windows. the same error with TSynEdi checked ---------------------------------------------------------------------- taazz · 2018-01-05 14:38 Some basic changes to the provided code that should stop any sigsegv errors on the sample provided. I had no problem deleting all the pages created at start up and exit the application. as always tests where run with lazarus 1.6.4 only on windows 7. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FormCreate(Sender: TObject);var  Tab: TTabSheet;  rSynEdit: TSynEdit;  i: integer;begin  for i := 0 to 7 do  begin    Tab := TTabSheet.Create(self);    Tab.PageControl := PageControl1;    Tab.Caption := Format('Tab%d', [i]);    Tab.PageControl.ActivePage := Tab;     rSynEdit := TSynEdit.Create(Tab);    rSynEdit.Parent := Tab;    rSynEdit.Name := 'syed' + IntToStr(PageControl1.PageCount);    rSynEdit.PopupMenu := PopupMenu1;    rSynEdit.Align := alClient;    rSynEdit.RightEdge := 0;    rSynEdit.BorderStyle := bsNone;  end; end; procedure TForm1.MenuItem1Click(Sender: TObject);begin  if Assigned(PageControl1.ActivePage) then    (PageControl1.ActivePage.FindComponent('syed' + IntToStr(PageControl1.ActivePageIndex + 1)) as TSynEdit).CopyToClipboard;end; procedure TForm1.MenuItem2Click(Sender: TObject);begin  if Assigned(PageControl1.ActivePage) then    ShowMessage((PageControl1.ActivePage.FindComponent('syed' + IntToStr(PageControl1.ActivePageIndex + 1)) as TSynEdit).Name);end; procedure TForm1.MenuItem3Click(Sender: TObject);begin  if Assigned(PageControl1.ActivePage) then PageControl1.ActivePage.Free;end; procedure TForm1.Button1Click(Sender: TObject);var  tab: TTabSheet;begin  if not Assigned(PageControl1.ActivePage) then Exit;  tab := PageControl1.ActivePage;  tab.Free;end; ---------------------------------------------------------------------- BIT · 2018-01-05 14:46 Quote from: taazz on January 05, 2018, 03:38:56 pmSome basic changes to the provided code that should stop any sigsegv errors on the sample provided. I had no problem deleting all the pages created at start up and exit the application. as always tests where run with lazarus 1.6.4 only on windows 7. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FormCreate(Sender: TObject);var  Tab: TTabSheet;  rSynEdit: TSynEdit;  i: integer;begin  for i := 0 to 7 do  begin    Tab := TTabSheet.Create(self);    Tab.PageControl := PageControl1;    Tab.Caption := Format('Tab%d', [i]);    Tab.PageControl.ActivePage := Tab;     rSynEdit := TSynEdit.Create(Tab);    rSynEdit.Parent := Tab;    rSynEdit.Name := 'syed' + IntToStr(PageControl1.PageCount);    rSynEdit.PopupMenu := PopupMenu1;    rSynEdit.Align := alClient;    rSynEdit.RightEdge := 0;    rSynEdit.BorderStyle := bsNone;  end; end; procedure TForm1.MenuItem1Click(Sender: TObject);begin  if Assigned(PageControl1.ActivePage) then    (PageControl1.ActivePage.FindComponent('syed' + IntToStr(PageControl1.ActivePageIndex + 1)) as TSynEdit).CopyToClipboard;end; procedure TForm1.MenuItem2Click(Sender: TObject);begin  if Assigned(PageControl1.ActivePage) then    ShowMessage((PageControl1.ActivePage.FindComponent('syed' + IntToStr(PageControl1.ActivePageIndex + 1)) as TSynEdit).Name);end; procedure TForm1.MenuItem3Click(Sender: TObject);begin  if Assigned(PageControl1.ActivePage) then PageControl1.ActivePage.Free;end; procedure TForm1.Button1Click(Sender: TObject);var  tab: TTabSheet;begin  if not Assigned(PageControl1.ActivePage) then Exit;  tab := PageControl1.ActivePage;  tab.Free;end; Та же ошибка возможно это связано с версией Lazarus попробую скачать пониже версию но хотя я давно не мог побороть эту ошибку как проверю отпишу если у кого есть идеи пишите буду пробовать все варианты! The same error probably it is connected with the version of Lazarus I'll try to download lower version but although I wasn't able to overcome this error how to check otpishu if anyone has ideas please write I will try all the options! ---------------------------------------------------------------------- taazz · 2018-01-05 15:01 Quote from: BIT on January 05, 2018, 03:46:41 pmThe same error probably it is connected with the version of Lazarus I'll try to download lower version but although I wasn't able to overcome this error how to check otpishu if anyone has ideas please write I will try all the options! the problem has nothing to do with the lcl or its components it has to do with your code. For example, you never check if findcomponent returned nil or not and that is enough to raise a sigsegv. The problem is in your code alone. ---------------------------------------------------------------------- BIT · 2018-01-05 15:05 Quote from: taazz on January 05, 2018, 04:01:40 pmQuote from: BIT on January 05, 2018, 03:46:41 pmThe same error probably it is connected with the version of Lazarus I'll try to download lower version but although I wasn't able to overcome this error how to check otpishu if anyone has ideas please write I will try all the options! the problem has nothing to do with the lcl or its components it has to do with your code and your code only. for example you never check if findcomponent returned nil or not and that is enough to raise an sigsegv. The problem is in your code alone. Я ваш код скопировал 1 в 1 и испробовал та же ошибка еще скачал Lazarus 1.6.4 все та же ошибка Если не верите что я проверяю ваш код могу скинуть проект для меня это важней чем кому либо кто мне помогает так что я проверяю все варианты! I copied your code 1 to 1 and tried the same error even downloaded Lazarus 1.6.4 all the same error If you do not believe what I test your code can throw off the project for me is more important than anyone else who helps me so I check all the options! ---------------------------------------------------------------------- BIT · 2018-01-05 15:12 Quote from: taazz on January 05, 2018, 04:01:40 pmQuote from: BIT on January 05, 2018, 03:46:41 pmThe same error probably it is connected with the version of Lazarus I'll try to download lower version but although I wasn't able to overcome this error how to check otpishu if anyone has ideas please write I will try all the options! the problem has nothing to do with the lcl or its components it has to do with your code. For example, you never check if findcomponent returned nil or not and that is enough to raise a sigsegv. The problem is in your code alone. Сейчас еще попробую на другом компьютере возможно ошибка в системе windows Now another try on a different computer, maybe the error in windows ---------------------------------------------------------------------- taazz · 2018-01-05 15:15 Quote from: BIT on January 05, 2018, 04:05:12 pmI copied your code 1 to 1 and tried the same error even downloaded Lazarus 1.6.4 all the same error If you do not believe what I test your code can throw off the project for me is more important than anyone else who helps me so I check all the options! OK here it is in pascal, you might understand it better. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FormCreate(Sender: TObject);var  Tab: TTabSheet;  rSynEdit: TSynEdit;  i: integer;begin  for i := 0 to 7 do  begin    Tab := TTabSheet.Create(self);    Tab.PageControl := PageControl1;    Tab.Caption := Format('Tab%d', [i]);    Tab.PageControl.ActivePage := Tab;     rSynEdit := TSynEdit.Create(Tab);    rSynEdit.Parent := Tab;    rSynEdit.Name := 'syed' + IntToStr(PageControl1.PageCount);    rSynEdit.PopupMenu := PopupMenu1;    rSynEdit.Align := alClient;    rSynEdit.RightEdge := 0;    rSynEdit.BorderStyle := bsNone;  end; end; procedure TForm1.MenuItem1Click(Sender: TObject);var  vCmp:TComponent;begin  //If (sender is TSynedit) then TSynedit(Sender).CopyToClipBoard; //<--- better option.  if Assigned(PageControl1.ActivePage) then begin    vCmp := PageControl1.ActivePage.FindComponent('syed' + IntToStr(PageControl1.ActivePageIndex + 1));    if Assigned(vCmp) and (vCmp is TSynEdit) then begin      TSynEdit(vCmp).CopyToClipboard;    end else showmessage('synedit not found');  end;end; procedure TForm1.MenuItem2Click(Sender: TObject);var  vCmp : TComponent;begin  if Assigned(PageControl1.ActivePage) then begin    vCmp := PageControl1.ActivePage.FindComponent('syed' + IntToStr(PageControl1.ActivePageIndex + 1));    if Assigned(vCmp) and (vCmp is TSynEdit) then      ShowMessage(TSynEdit(vCmp).Name);    else showmessage('synedit not found');  end end; procedure TForm1.MenuItem3Click(Sender: TObject);begin  if Assigned(PageControl1.ActivePage) then PageControl1.ActivePage.Free;end; procedure TForm1.Button1Click(Sender: TObject);var  tab: TTabSheet;begin  if not Assigned(PageControl1.ActivePage) then Exit;  tab := PageControl1.ActivePage;  tab.Free;end; ---------------------------------------------------------------------- BIT · 2018-01-05 15:31 Quote from: taazz on January 05, 2018, 04:15:29 pmQuote from: BIT on January 05, 2018, 04:05:12 pmI copied your code 1 to 1 and tried the same error even downloaded Lazarus 1.6.4 all the same error If you do not believe what I test your code can throw off the project for me is more important than anyone else who helps me so I check all the options! OK here it is in pascal, you might understand it better. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FormCreate(Sender: TObject);var  Tab: TTabSheet;  rSynEdit: TSynEdit;  i: integer;begin  for i := 0 to 7 do  begin    Tab := TTabSheet.Create(self);    Tab.PageControl := PageControl1;    Tab.Caption := Format('Tab%d', [i]);    Tab.PageControl.ActivePage := Tab;     rSynEdit := TSynEdit.Create(Tab);    rSynEdit.Parent := Tab;    rSynEdit.Name := 'syed' + IntToStr(PageControl1.PageCount);    rSynEdit.PopupMenu := PopupMenu1;    rSynEdit.Align := alClient;    rSynEdit.RightEdge := 0;    rSynEdit.BorderStyle := bsNone;  end; end; procedure TForm1.MenuItem1Click(Sender: TObject);var  vCmp:TComponent;begin  //If (sender is TSynedit) then TSynedit(Sender).CopyToClipBoard; //<--- better option.  if Assigned(PageControl1.ActivePage) then begin    vCmp := PageControl1.ActivePage.FindComponent('syed' + IntToStr(PageControl1.ActivePageIndex + 1));    if Assigned(vCmp) and (vCmp is TSynEdit) then begin      TSynEdit(vCmp).CopyToClipboard;    end else showmessage('synedit not found');  end;end; procedure TForm1.MenuItem2Click(Sender: TObject);var  vCmp : TComponent;begin  if Assigned(PageControl1.ActivePage) then begin    vCmp := PageControl1.ActivePage.FindComponent('syed' + IntToStr(PageControl1.ActivePageIndex + 1));    if Assigned(vCmp) and (vCmp is TSynEdit) then      ShowMessage(TSynEdit(vCmp).Name);    else showmessage('synedit not found');  end end; procedure TForm1.MenuItem3Click(Sender: TObject);begin  if Assigned(PageControl1.ActivePage) then PageControl1.ActivePage.Free;end; procedure TForm1.Button1Click(Sender: TObject);var  tab: TTabSheet;begin  if not Assigned(PageControl1.ActivePage) then Exit;  tab := PageControl1.ActivePage;  tab.Free;end; Sorry but I'm in the first post wrote that there is no TObject where he go I'm interested but not this)) showmessage('synedit' not found'); Ps: In Pascal programming for 16 years I think that you understand half the words) ---------------------------------------------------------------------- taazz · 2018-01-05 15:34 Quote from: BIT on January 05, 2018, 04:31:32 pmSorry but I'm in the first post wrote that there is no TObject where he go I'm interested but not this)) showmessage('synedit' not found'); Ps: In Pascal programming for 16 years I think that you understand half the words) I understand none of the words sorry. I'm out. I'll let some one that talks your language to explain. ---------------------------------------------------------------------- BIT · 2018-01-05 15:40 Quote from: taazz on January 05, 2018, 04:34:09 pmQuote from: BIT on January 05, 2018, 04:31:32 pmSorry but I'm in the first post wrote that there is no TObject where he go I'm interested but not this)) showmessage('synedit' not found'); Ps: In Pascal programming for 16 years I think that you understand half the words) I understand none of the words sorry. I'm out. I'll let some one that talks your language to explain. I don't want to hurt me too hard in their own language to communicate I just want to solve the problem and thank you for your help. ---------------------------------------------------------------------- BIT · 2018-01-05 16:06 Quote from: taazz on January 05, 2018, 04:34:09 pmQuote from: BIT on January 05, 2018, 04:31:32 pmSorry but I'm in the first post wrote that there is no TObject where he go I'm interested but not this)) showmessage('synedit' not found'); Ps: In Pascal programming for 16 years I think that you understand half the words) I understand none of the words sorry. I'm out. I'll let some one that talks your language to explain. If you have been offended?) Ps: In Pascal programming for 16 years I think that you understand half the words) In the Russian language this means that we understand each other well) (I hope this time the translator has translated correctly) ---------------------------------------------------------------------- BIT · 2018-01-05 16:17 Проверка на другом компьютере вызывает  ошибку Check on another computer causing the error ---------------------------------------------------------------------- BIT · 2018-01-05 16:33 Еще раз: Есть 10 вкладок с редактором, удаляем  вкладку 7, остается 9 вкладок, вкладка 1,2,3,4,5,6 остаются рабочими, вкладки 7,8,9 вызывают ошибку! Again: There are 10 tabs with the editor, remove the tab 7, is 9 tabs, tab 1,2,3,4,5,6 remain working, tabs 7,8,9 fail! ---------------------------------------------------------------------- Edson · 2018-01-05 16:46 It's difficult to me too, understand the english translation. But I think @taazz is right: I think Quote from: taazz on January 05, 2018, 04:01:40 pmthe problem has nothing to do with the lcl or its components it has to do with your code. For example, you never check if findcomponent returned nil or not and that is enough to raise a sigsegv. The problem is in your code alone. I see in your code, you use the name of the component to  obtain the reference: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i 'syed' + IntToStr(PageControl1.ActivePageIndex + 1) That's a bad idea. Every time you delete pages, the name of the SynEdit is not yet related to the "PageControl1.ActivePageIndex". As I told you in other post: You really need to include better error routines in your code. ---------------------------------------------------------------------- taazz · 2018-01-05 16:47 One last effort to explain. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.MenuItem1Click(Sender: TObject);var  vCmp:TComponent;begin  if Assigned(PageControl1.ActivePage) then begin    vCmp := PageControl1.ActivePage.FindComponent('syed' + IntToStr(PageControl1.ActivePageIndex + 1));    if Assigned(vCmp) and (vCmp is TSynEdit) then begin      TSynEdit(vCmp).CopyToClipboard;    end else showmessage('synedit not found');  end;end; activepageindex is not always synchronised with the synedit name you can't use it. try this. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.MenuItem1Click(Sender: TObject);begin  if (ActiveControl is TSynEdit) then TSynEdit(ActiveControl).CopyToClipboard;end; Quote from: BIT on January 05, 2018, 05:06:53 pmIf you have been offended?) I'm not offended no. But I can't think of any more ways to say the same thing, perhaps some one can translate to Russian to help. ---------------------------------------------------------------------- BIT · 2018-01-05 17:10 Quote from: Edson on January 05, 2018, 05:46:22 pmIt's difficult to me too, understand the english translation. But I think @taazz is right: I think Quote from: taazz on January 05, 2018, 04:01:40 pmthe problem has nothing to do with the lcl or its components it has to do with your code. For example, you never check if findcomponent returned nil or not and that is enough to raise a sigsegv. The problem is in your code alone. I see in your code, you use the name of the component to  obtain the reference: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i 'syed' + IntToStr(PageControl1.ActivePageIndex + 1) That's a bad idea. Every time you delete pages, the name of the SynEdit is not yet related to the "PageControl1.ActivePageIndex". As I told you in other post: You really need to include better error routines in your code. You really need to include better error routines in your code.  | Google Translator Does not make sense in words (( ---------------------------------------------------------------------- BIT · 2018-01-05 17:17 Quote from: taazz on January 05, 2018, 05:47:17 pmOne last effort to explain. Hurray it works !! Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  if (ActiveControl is TSynEdit) then TSynEdit(ActiveControl).CopyToClipboard; Now how to get TObject -> TSynEdit? ---------------------------------------------------------------------- BIT · 2018-01-05 17:38 Forgive me I did not think there lies TSynEdit (ActiveControl) Thanks big for the help I will go to think now as in SynFacilCompletion to transfer dynamic TSynEdit