Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Activate Menu Option on Application Startup

Status
Not open for further replies.

suec032a

Programmer
Jun 22, 2009
20
AU
Hi,

Can someone please help with using a keyboard{}action to select a menu option, both at startup and when my forms are released.
When my application starts, my custom menu is shown, but it is greyed out.

In the menu setup procedure I have the code
Code:
keyboard '{CTRL + B}'
and this menu pad is shown as being selected, but greyed out. If I click anywhere on the VFP screen the menu becomes available, but my menu pad no longer is selected.

This is the same behaviour when I release my forms. It seems to be in a wait state but not sure as to why?

In my app object I call the menu as follows:

Code:
DO (this.cMainMenu)
DO WHILE .T.
	*-- Start the event loop
	READ EVENTS

	*- We do cleanup here, if a grid has the focus.
	IF THIS.Cleanup()
		THIS.Cleanup2
		EXIT
	ENDIF
ENDDO

Thanks in advance

Sue




 
Sue,

Are you saying that you want to programmatically open the menu when the application starts - so the menu is open without user action?

I'm not sure why you would want to do that. But if that's what you want, wouldnt' ACTIVE POPUP <menu name> BAR <bar no.> be a simpler way of doing it?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Hi Mike,

The users have requested that the first menu option be selected as it used to be in their old 2.6 app. They are not used to using the mouse hence why I have had to place a lot of Hotkeys into the app.

Sorry for my ignorance, but would you place the active popup in the Menu setup proc or cleanup or am I really off track?

Also, do I need some other code to make the menu available and not greyed out at startup? It seems to be in a wait state and I am not sure what I have missed? This is the other problem I am having apart from the strange user menu request.

Thanks so much for your help

Sue

 
What looks odd about your code is READ EVENTS in the loop. I'd not do that. I wonder what cleanup does in regard to grids, why don't you have that in a grid base class in it's destroy?

Bye, Olaf.
 
Sue,

No problem. I understand now what your users are asking for (although it is not a very Windows-like thing to do, but never mind ...)

No, I wouldn't put the ACTIVATE POPUP in the menu's startup code (in fact, I never use the startup or cleanup code, but that's for reasons unrelated to your question). Instead, I would execute it in the main program, after you have launched the menu, but before your READ EVENTS.

Going back to your KEYBOARD '{CTRL + B}', I can see what you're are trying to do now. Presumably, Ctrl+B is a menu shortcut - like Ctrl+N is a shortcut in the Foxpro menu for File / New. In that case, keyboarding won't do what you want. It would be better to keyboard the accelerator key, which is an Alt+Letter combiniation (e.g Alt+F to open the File menu). After opening the menu, you would then keyboard some down-arrows to move the highlight to the required bar.

I'd also echo what Olaf said about your READ EVENTS in a loop. That definitely points to something basically wrong with the program's structure.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
You should really educate your users. DOS applications and WIndows applications behave differently. Your app will behave differently than all other Windows apps, which actually annoys users.

Craig Berntson
MCSD, Visual FoxPro MVP,
 
HI
I want to link menu to my form , how i do
i used : show menu namemenu but doesn t work
 
Thank you all so much. I agree the users need to be educated in the Windows based apps, but it is a slow progress. They only started using a mouse when the internet was connected in July this year. The original 2.6 app I wrote 15 years ago for them was all keyboard based.

Mike and Olaf, thanks for the advice on the READ EVENTS loop. I took this from the Tastrade app so I will review this again along with the grid cleanup code.

I will rewrite the read events and place the activate code as suggested and let you know.

Thanks so much again, this forum has been absolutely fantastic for newbies to VFP9 like me.

Sue

 
Hi Mike and Olaf,

All works now once I took out the Do loop for the Read Events, placed the Activate code after the menu call and relocated the cleanup code to the form with the grid.

Thanks again for all your assistance.

Sue
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top