[solved for now] Form1 calling Form2 via Command-Line-param lazarus / 21-General ---------------------------------------------------------------------- Zvoni · 2022-03-10 09:33 Hi Folks, program starts, code in the lpr Creates Form1, there with Menus i call Form2 So far, so good Now i want to offer the option to start the program from the CLI with passing some options (e.g. "myapp.exe -report ODBC") In the lpr i check HasOption and use GetOptionValue if True. Works! BUT: How can i show Form2 only AFTER Form1 is completely painted? I'm looking for something like "AfterShow"-Event. NB: i already tried OnActivate of Form1, but for some unknown reason that one doesn't fire Form2 is Modal with Form1 as Parent Pseudo-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 //in lprIf Application.HasOption('r','report') Then Report:=Application.GetOptionValue('r','report');Form1.Show;//In Form1If Report='ODBC' Then        If Form1 is completely visbile Then Form2.ShowModal;  EDIT: Right, easy to workaround with a Timer set to 500, but..... seriously? And i got Activate to fire. No idea what i did wrong in the first run ---------------------------------------------------------------------- MarkMLl · 2022-03-10 10:04 I normally use something like 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 (* This is called when the wm_After_Show message is dequeued, which is  guaranteed to be after form creation has completed.*)procedure TWatchxxxForm.OnAfterShow(afterShowParam: PtrInt);... (* The form is being created, but sizes might not yet be known particularly if  there's rescaling due to DPI variation.*)procedure TWatchxxxForm.FormCreate(Sender: TObject); begin...  if Screen.Width < 854 then            (* Last-ditch attempt to handle small   *)    Width := 768;                       (* screens for support via VNC etc.     *)  Application.QueueAsyncCall(@OnAfterShow, WatchxxxCodeMagicNumber) (* Keep at end *)end { TWatchxxxForm.FormCreate } ;  But I don't know whether than delays until after everything has been displayed or just until everything has been created/initialised. MarkMLl ---------------------------------------------------------------------- Zvoni · 2022-03-10 11:30 Mark, i take it the "WatchxxxCodeMagicNumber" is the WM_AFTER_SHOW? You got a value for me? All i could find was WM_AFTER_SHOW=WM_USER+1 I'd at least try it out ---------------------------------------------------------------------- MarkMLl · 2022-03-10 11:44 Quote from: Zvoni on March 10, 2022, 12:30:11 pmMark, i take it the "WatchxxxCodeMagicNumber" is the WM_AFTER_SHOW? You got a value for me? All i could find was WM_AFTER_SHOW=WM_USER+1 I'd at least try it out Sorry, no: it's just an arbitrary number which is checked at the point of consumption. In practice I use a datecode, declared private to the unit. Back in the Delphi era that was a windows message, but when I started using Lazarus somebody suggested an asynccall instead. There's a complete example at https://github.com/MarkMLl/Contec_cms50d plus/blob/main/cms50dplus4v6/cms50dpluscode.pas MarkMLl