Jump to content
Sign in to follow this  
Zazhir

OnChange in Ribbon not working Well

Recommended Posts

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;

 

image.png.0fbcd64e77df6e325db86f4f9e3c41a7.png

CODIGO needs to be focused, how can I do that??

 

Share this post


Link to post
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....

 

image.png.0fbcd64e77df6e325db86f4f9e3c41a7.png

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×