* * *

Author Topic: Lazarus V1.6.2 Error on Showmodal - Form cannot focus.  (Read 493 times)

phil_v

  • New member
  • *
  • Posts: 10
Lazarus V1.6.2 Error on Showmodal - Form cannot focus.
« on: February 28, 2017, 05:49:44 am »
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

  • Hero Member
  • *****
  • Posts: 653
Re: Lazarus V1.6.2 Error on Showmodal - Form cannot focus.
« Reply #1 on: February 28, 2017, 08:43:22 am »
AFAIK focus only works in Onactivate or when the form is visible on screen.

On Delphi site:
Quote
The 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.
Lazarus 1.6 (32b) / FPC 3.0
Windows Vista /  10

FTurtle

  • Full Member
  • ***
  • Posts: 176
Re: Lazarus V1.6.2 Error on Showmodal - Form cannot focus.
« Reply #2 on: February 28, 2017, 09:56:18 am »
1. You dont need install/uninstall different versions. You can install few versions at same time.
2. Show your code.

phil_v

  • New member
  • *
  • Posts: 10
Re: Lazarus V1.6.2 Error on Showmodal - Form cannot focus.
« Reply #3 on: March 01, 2017, 12:47:45 am »
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;

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus