<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
I know that the other order works for my simple procedure. I asked
because i inspected a bug, that is described in the german forum (<a
href="http://www.lazarusforum.de/viewtopic.php?f=18&t=4599">http://www.lazarusforum.de/viewtopic.php?f=18&t=4599</a>):<br>
<br>
following code was tried in Stringgrid1.OnSelectEditor:<br>
<br>
<pre class="laz" style="font-family: monospace;"><span class="kw1">procedure</span> TForm1.<span
class="me1">StringGrid1SelectEditor</span><span class="br0">(</span>Sender<span
class="sy0">:</span> TObject; aCol<span class="sy0">,</span> aRow<span
class="sy0">:</span> Integer;
<span class="kw1">var</span> Editor<span class="sy0">:</span> TWinControl<span
class="br0">)</span>;
<span class="kw1">begin</span>
<span class="kw1">if</span> <span class="br0">(</span>aCol<span
class="sy0">=</span><span class="nu0">2</span><span class="br0">)</span> <span
class="kw1">and</span> <span class="br0">(</span>aRow><span
class="nu0">0</span><span class="br0">)</span> <span class="kw1">then</span>
<span class="kw1">begin</span>
Memo1.<span class="me1">Visible</span><span class="sy0">:=</span><span
class="kw1">True</span>;
Editor<span class="sy0">:=</span>Memo1;
Memo1.<span class="me1">BoundsRect</span><span class="sy0">:=</span>StringGrid1.<span
class="me1">CellRect</span><span class="br0">(</span><span class="nu0">2</span><span
class="sy0">,</span>aRow<span class="br0">)</span>;
Editor.<span class="me1">SetFocus</span>; <font
color="#ff6600">//!!! here is the focus that doesn't work</font>
<span class="kw1">end</span>;
<span class="kw1">end</span>;
//looking up the selecteditor-proceure:
procedure TCustomGrid.SelectEditor;
var
aEditor: TWinControl;
begin
aEditor := GetDefaultEditor(Col);
if EditingAllowed(FCol) and Assigned(OnSelectEditor) then begin
// in some situations there are only non-selectable cells
// if goAlwaysShowEditor is on set initially editor to nil,
// user can modify this value in OnSelectEditor if needed
if not SelectCell(FCol,FRow) then
aEditor:=nil;
OnSelectEditor(Self, fCol, FRow, aEditor); <font color="#ff6600">//!! here the above procedure with the setfocus is called</font>
end;
if aEditor<>Editor then
Editor := aEditor; <font color="#ff6600">//!! here SetEditor is called that contains changing Parent with impact on focus</font>
end;
</pre>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
Mattias Gaertner schrieb:
<blockquote
cite="mid:719124571.101979.1295889388032.JavaMail.open-xchange@cc-app2.netcologne.de"
type="cite">
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<title></title>
<p style="margin: 0px;"><span> </span></p>
<p style="margin: 0px;"> </p>
<div style="margin: 5px 0px;"> u-boot <a class="moz-txt-link-rfc2396E" href="mailto:myabos@t-online.de"><myabos@t-online.de></a> hat
am 24. Januar 2011 um 17:49 geschrieben:<br>
<br>
> Same question here as in irc nobody answered it a few hours ago.<br>
><br>
><br>
> I tried the following lines. It does not work with setfocus before<br>
> parent changing.<br>
> My question is, if it should work in this order or if this is
correct<br>
> behaviour.<br>
><br>
><br>
> procedure TForm1.Button1Click(Sender: TObject);<br>
> begin<br>
> edit1.SetFocus;<br>
> if (Edit1.Parent=Panel2) Then Edit1.Parent:=Panel1 else<br>
> Edit1.Parent:=Panel2;<br>
> end; </div>
<p style="margin: 0px;"> </p>
<p style="margin: 0px;">Changing the Parent switches the focus to
another control.</p>
<p style="margin: 0px;">So, you should set the focus after changing
the parent.</p>
<p style="margin: 0px;"> </p>
<p style="margin: 0px;">Mattias</p>
<br>
</blockquote>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<blockquote
cite="mid:719124571.101979.1295889388032.JavaMail.open-xchange@cc-app2.netcologne.de"
type="cite">
<pre wrap=""><hr size="4" width="90%">
--
_______________________________________________
Lazarus mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Lazarus@lists.lazarus.freepascal.org">Lazarus@lists.lazarus.freepascal.org</a>
<a class="moz-txt-link-freetext" href="http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus">http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus</a>
</pre>
</blockquote>
<br>
</body>
</html>