<p style="padding:0 0 0 0; margin:0 0 0 0;">Hi,</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">I just tested. Active Form always returns Focused False. Use property Active instead.</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"><span style="font-size: 13.3333px;">Result := (</span><span style="font-size: 13.3333px;">FControl is TCustomForm) and </span><span style="font-size: 13.3333px;">TCustomForm</span><span style="font-size: 13.3333px;">(FControl).Active</span><span style="font-size: 13.3333px;">;</span></p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"><span style="font-size: 13.3333px;">V.</span></p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">______________________________________________________________<br />
> Od: Lubos Pintes via Lazarus <lazarus@lists.lazarus-ide.org><br />
> Komu: lazarus@lists.lazarus.freepascal.org<br />
> Datum: 04.03.2018 17:58<br />
> Předmět: [Lazarus] An expression is returning false, why?<br />
></p>
Hello,<br />
Sorry for possibly stupid subject and maybe off-topic question. In my <br />
UIA code, I am testing if a control has focus. So I have a FControl: <br />
TControl declared in my class.<br />
Now say FControl contains a TForm1 instance, simply we have very simple <br />
program with just an empty window. Then an expression:<br />
Result := FControl is TWinControl and TWinControl(FControl).Focused;<br />
returns false. I am sure the form has focus..., because <br />
ShowMessage(BoolToStr(Focused)) returns -1, which represents true...<br />
<br />
-- <br />
_______________________________________________<br />
Lazarus mailing list<br />
Lazarus@lists.lazarus-ide.org<br />
<a href="https://lists.lazarus-ide.org/listinfo/lazarus">https://lists.lazarus-ide.org/listinfo/lazarus</a><br />