Lazarus V1.6.2 Error on Showmodal - Form cannot focus. lazarus / 31-LCL ---------------------------------------------------------------------- phil_v · 2017-02-28 04:49 Hope you can help. Thanks in advance. Lazarus 1.6.2 FPC 3.0.0 SVN 53354 i38s-win32-win32/win64 Windows 7 Pro 32 Bit I have an application that opens a form with Showmodal that works fine in Lazarus V1.6. When I upgrade to Lazarus 1.6.2 I get an error exception class 'EInvalidOperation' message : TCustomform.SetFocus)SchedFrm.TSchedfrm Can not focus I tried uninstall V1.6.2, and re-install V1.6, and all works OK with no error. Then re-install v1.6.2, and error happens again. The error occurs in customform.inc at line 2839,  before the forms OnShow event. I don't know how to resolve the error in V1.6.2. ---------------------------------------------------------------------- mangakissa · 2017-02-28 07:43 AFAIK focus only works in Onactivate or when the form is visible on screen. On Delphi site: QuoteThe location. The form's onShow event actually fires before the form is shown, and since you cannot set focus to an invisible window your scheme fails. ---------------------------------------------------------------------- FTurtle · 2017-02-28 08:56 1. You dont need install/uninstall different versions. You can install few versions at same time. 2. Show your code. ---------------------------------------------------------------------- phil_v · 2017-02-28 23:47 Thanks mangakissa, FTurtle With further tracing of the error, I found that it occurred at line 2883 in customform.inc... Code below. Line 2883 is executed if the forms PopupMode = pmNone. I changed the forms PopupMode to pmAuto in the IDE via Object Inspector, and the application worked OK. Confirmed by changing the property back to pmNone, and the application created the error again. customform.inc ... 2804 function TCustomForm.ShowModal: Integer; ... ... 2877 Application.ModalStarted; 2878  try 2879    Include(FFormState, fsModal); 2880    if PopupMode = pmNone then       <== <== 2881    begin 2882      RecreateWnd(Self); 2883      HandleNeeded; 2884    end;