Zazhir 0 Posted October 26, 2022 I need to set a focus inside a Tedit, simple like this. But the problem is, the component is inside a TRibbonPage, which is only showed if a clicked on. The only event that have is the RibbonTabChange (in TRibbon). I've done like this, but all the others attempts have gonne wrong.... Quote procedure TfrmSIG.RibbonTabChange(Sender: TObject; const NewIndex, OldIndex: Integer; var AllowChange: Boolean); begin if Ribbon.ActivePage = rpPesquisas then FcodImovLot.setFocus; if NewIndex = 3 then FcodImovLot.setFocus; //both didn't work end; CODIGO needs to be focused, how can I do that?? Share this post Link to post
PeterBelow 238 Posted October 26, 2022 2 hours ago, Zazhir said: I need to set a focus inside a Tedit, simple like this. But the problem is, the component is inside a TRibbonPage, which is only showed if a clicked on. The only event that have is the RibbonTabChange (in TRibbon). I've done like this, but all the others attempts have gonne wrong.... CODIGO needs to be focused, how can I do that?? You have a timing issue here, the event fires before the page has become visible and the controls on it can be focused. The usual fix for such problems is to post (PostMessage) a custom message to the form and do the focus change in the handler for this message. There is also a OnTabVisibleChanged event for TRibbon, perhaps that fits better with your goal. Share this post Link to post
Zazhir 0 Posted October 27, 2022 begin If Handle <> 0 then begin SendMessage (Handlee, WM_SETFOCUS, 0, 0); end; SendMessage(ax, WM_SETFOCUS, 0, 0); end; The final code is like this Peter, I've looking more deep then the ocean to find a solution and where was my mistake. Lukely I've founded. The thing is that I has to defined the variables as global, in the beggin of all. Thanks for your attention, you really save me on this one! best regards, Zazhir. Share this post Link to post