Forum > LCL
[Solved]error release when memo.setfocus
badmintonfan:
What's wrong on my code?
dseligo:
--- Quote from: badmintonfan on January 26, 2023, 05:42:08 am ---What's wrong on my code?
--- End quote ---
You can't focus controls in OnCreate event. Put your code in OnShow event.
badmintonfan:
--- Quote from: dseligo on January 26, 2023, 06:34:39 am ---
--- Quote from: badmintonfan on January 26, 2023, 05:42:08 am ---What's wrong on my code?
--- End quote ---
You can't focus controls in OnCreate event. Put your code in OnShow event.
--- End quote ---
I did it alreay,but the same error message had been released
KodeZwerg:
Never ever explicit check for "True" or "False". That is really bad code up there.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---if (not Edit1.Enabled) then Memo1.SetFocus;
dseligo:
--- Quote from: badmintonfan on January 26, 2023, 10:38:36 am ---
--- Quote from: dseligo on January 26, 2023, 06:34:39 am ---
--- Quote from: badmintonfan on January 26, 2023, 05:42:08 am ---What's wrong on my code?
--- End quote ---
You can't focus controls in OnCreate event. Put your code in OnShow event.
--- End quote ---
I did it alreay,but the same error message had been released
--- End quote ---
It doesn't look like you did that in your original post. You try to focus Memo1 in method named FormCreate, which is default when you double click on form or if you click on OnCreate event in object inspector.
I think you didn't do put your code in OnShow event properly. I mean: if you get this error, then focusing in OnCreate is still happening.
I suggest you make small project that shows this behaviour and post it here.
Navigation
[0] Message Index
[#] Next page