Popup form when popups again it does not wait for close, how can i make it lazarus / 61-Beginners ---------------------------------------------------------------------- teochris · 2016-03-14 12:25 Hello, In my app there is a  mainform that I always need it to be open and be seen by the user and when button1 is clicked a popupRandom form appears - if the user clicks button2 on the popup form then the popupRandom form closes. If the user clicks again the button1 then the popup form reappears and again if the user clicks button2 on the popupRandom form then the popupRandom form closes. I use the following code on the button1 onclick event 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 PopUpRandom <> nil then      begin        PopUpRandom.Show;      end  else      begin        PopUpRandom := TPopUpRandom.Create(Application);        PopUpRandom.ShowModal;      end; and in button2 on the popupRandom form there is this code 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 PopUpRandom.close; The problem that I am facing is that after the first time the popupRandom window is created (with showmodal) the user can click in the mainform (that is something that i do not want it to happen while popupRandom form is shown - I want the user to be able to click again on mainform only after the popupRandom form closes) since it is not opened with showmodal the next times. If I use again Showmodal in the above code to reopen the popupRandom form the second and the following times, and user clicks button2 in the popupRandom form then the app crashes. So how can i alternative open again and again the popupRandom form and make it wait for close like showmodal? ---------------------------------------------------------------------- teochris · 2016-03-14 13:54 After a lot of google searching, by luck i found a solution that answered my question! now in the mainform button1 onclick i have this code 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 PopUpRandom <> nil then      begin        PopUpRandom.ShowModal;      end    else      begin        PopUpRandom := TPopUpRandom.Create(Application);        PopUpRandom.ShowModal;      end; and in the popupRandom button2 form i have the following code (instead of the close command) that seems to do what i needed 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 ModalResult := mrOK; ---------------------------------------------------------------------- FTurtle · 2016-03-14 15:12 Quote from: teochris on March 14, 2016, 02:54:19 pmCode: 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 PopUpRandom <> nil then      begin        PopUpRandom.ShowModal;      end    else      begin        PopUpRandom := TPopUpRandom.Create(Application);        PopUpRandom.ShowModal;      end; Optimization: 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 PopUpRandom = nil then    PopUpRandom := TPopUpRandom.Create(Application);  PopUpRandom.ShowModal; ---------------------------------------------------------------------- teochris · 2016-03-14 15:40 Quote from: FTurtle on March 14, 2016, 04:12:48 pm Optimization: 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 PopUpRandom = nil then    PopUpRandom := TPopUpRandom.Create(Application);  PopUpRandom.ShowModal;  Indeed thanks for reminding me!