Switch Ribbon Default Menu

Discussion forum about all things Team Developer 5.x and 6.x
Peter Grob
Germany
Posts: 6
Joined: 23 Jun 2017, 10:48
Location: Volkach Germany

Switch Ribbon Default Menu

Post by Peter Grob » 23 Jun 2017, 11:04

Hi,

I would like to switch between real ribbon and default menu at runtime. Is there a way to do that?

Peter

Team Developer 6.3

Jeff Luther
Site Admin
Site Admin
United States of America
Posts: 2166
Joined: 04 Mar 2017, 18:34
Location: Palm Springs, California

Switch Ribbon Default Menu

Post by Jeff Luther » 23 Jun 2017, 15:53

Well, maybe Peter. That is, if your code is able to destroy, then recreate the form with the menu you want to switch. (Though you can only switch it to TRUE one time. See below for details.)

Normally in TD, you turn on the Ribbon Bar feather here:

Code: Select all

On SAM_AppStartup
	Set bMenuBarAsRibbonBar = TRUE
But I just experimented and see that you can turn this feature on (or off) by 'catching' a very early form msg. before TD actually creates it. The Windows' constant is:

Code: Select all

Constants - System
	Number: WM_NCCREATE	= 0x0081
Then use it like this:

Code: Select all

Form Window: frm1
	...
	Message Actions
		On WM_NCCREATE
			Set bMenuBarAsRibbonBar = TRUE
and the form's menus will be displayed as a Ribbon Bar.

I've attached a test case showing this. Note, though, that the Ribbon Bar setting is global: Once you set it TRUE, then it's true for the life of the running appl.

TO TEST: Click Create PB in form 1 to create form2 with a prompt in the WM_NCCREATE msg. whether to show the menu as a RB or not. Click Yes, destroy that window, then click the PB again and click No. Form2 will still display as a RB.

There may be a way using the CDK to reset that TD internal constant value while the appl. but that would be a further exercise with the CDK to see if it is possible. Otherwise, it would seem that the only way to rest that TD Boolean would be to close, then reopen the appl. again.
You do not have the required permissions to view the files attached to this post.
Jeff Luther @ PC Design
Palm Springs, California
TD info. & samples: http://www.jeffluther.net/TD/

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 1137
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Switch Ribbon Default Menu

Post by Dave Rabelink » 26 Jun 2017, 05:13

Hi Jeff,

I tested your sample but setting back the boolean values in the same running appl actually works.

Code: Select all

On WM_NCCREATE
	If SalMessageBox( 'Dislay menus as a Ribbon Bar?', '', MB_YesNo ) = IDYES
		Set bMenuBarAsRibbonBar = TRUE
	Else
		! Added this line to set back to FALSE.
		Set bMenuBarAsRibbonBar = FALSE
The form can be created having ribbon or menu without restarting the application.
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

Peter Grob
Germany
Posts: 6
Joined: 23 Jun 2017, 10:48
Location: Volkach Germany

Switch Ribbon Default Menu

Post by Peter Grob » 26 Jun 2017, 12:13

Hi Jeff, Hi Dave,

thanks for response. I tested the bMenuBarAsRibbonBar-switch, but it looks very strange.
Mayby it is because I have no Icons in the menu. I will check it with icons.

Peter

Jeff Luther
Site Admin
Site Admin
United States of America
Posts: 2166
Joined: 04 Mar 2017, 18:34
Location: Palm Springs, California

Switch Ribbon Default Menu

Post by Jeff Luther » 26 Jun 2017, 17:58

Dave -- Yes, the "IDYES" is the thing to code in, all right ~ Thanks for catching that!
Jeff Luther @ PC Design
Palm Springs, California
TD info. & samples: http://www.jeffluther.net/TD/

Return to “General Discussion”

Who is online

Users browsing this forum: [Ccbot] and 0 guests