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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Custom menu problems

Status
Not open for further replies.

Rajesh Karunakaran

Programmer
Sep 29, 2016
549
MU
Hi Friends,

I am trying to implement a custom menu in my program. Main reason for not using _msysmenu is that the main menu bar and its pads do not support fonts, font size, style etc even though the subsequent bars of pads and popup have font specifications.

Below is my code I am trying. The problem is it displays the menu but the moment I click anywhere outside the menu, the menu disappears and I am stuck up and foxpro wouldn't allow me to do anything.

Code:
_menuFontFace  = 'Arial'
_menuFontSize  = 9
_menuStyleChar = 'B'

SET SYSMENU TO  

DEFINE MENU _mainmenu IN SCREEN FONT _menuFontFace,_menuFontSize STYLE _menuStyleChar COLOR SCHEME 3 NOMARGIN

DEFINE PAD padMasters   OF _mainmenu PROMPT "Masters    "     FONT _menuFontFace,_menuFontSize STYLE _menuStyleChar COLOR SCHEME 1
DEFINE PAD padExit      OF _mainmenu PROMPT "Exit       "      FONT _menuFontFace,_menuFontSize STYLE _menuStyleChar COLOR SCHEME 1

ON SELECTION PAD padMasters OF _mainmenu ACTIVATE POPUP popMasters
ON SELECTION PAD padExit    OF _mainmenu do QuitMenu

*/ Masters
DEFINE POPUP popMasters
    DEFINE BAR 01 OF popMasters PROMPT "  Masters First" FONT _menuFontFace,_menuFontSize STYLE _menuStyleChar
    DEFINE BAR 02 OF popMasters PROMPT "\-"	SKIP
    DEFINE BAR 03 OF popMasters PROMPT "  Masters Third" FONT _menuFontFace,_menuFontSize STYLE _menuStyleChar

    ON SELECTION BAR 01 OF popMasters do FORM frmMasters1	&& WITH 'SAVE', ,.T. TO lRcvdValue
    ON SELECTION BAR 03 OF popMasters do FORM frmMasters3	&& WITH 'SAVE', ,.T. TO lRcvdValue
    
ACTIVATE MENU _mainmenu 
READ EVENTS
	
*****************************	
PROCEDURE QuitMenu	
*****************************	
	CLEAR EVENTS 
	DEACTIVATE MENU _mainmenu 
	RELEASE MENUS _mainmenu EXTENDED 
	SET SYSMENU TO DEFAULT

By the way, I came across the below topic but it discusses about the _MSYSMENU which I do not want to use because of FONT issues.
That is why I created this new thread. Hope that makes sense.

What is I am missing? Can anyone help?

Thanks
Raj
 
Hi Koen,

Sorry, by 'different behavior of custom and default menu', I didn't mean the functioning but that the default menu doesn't allow font changes for the Top Menu Bar PADs but allow everything below that. Mike has already pointed out that default vfp menu doesn't allow font changes.

As for the issue in custom menu, the complete sample code is below (with which I am testing):
The Exit PAD also is not working. When I click Exit, the menu just disappear and screen freezes!
Code:
_menuFontFace  = 'Arial'
_menuFontSize  = 10
_menuStyleChar = 'B'

CLEAR 

SET SYSMENU TO 

DEFINE MENU _mainmenu BAR AT LINE 1 IN SCREEN NOMARGIN

DEFINE PAD padMasters OF _mainmenu PROMPT "  Masters        " FONT _menuFontFace,_menuFontSize STYLE _menuStyleChar
DEFINE PAD padExit    OF _mainmenu PROMPT "  Exit           " FONT _menuFontFace,_menuFontSize STYLE _menuStyleChar

ON PAD padMasters OF _mainmenu ACTIVATE POPUP popMasters
ON SELECTION PAD padExit OF _mainmenu do QuitMenu

*/ Masters
DEFINE POPUP popMasters 
    DEFINE BAR 01 OF popMasters PROMPT "\-"	SKIP
    DEFINE BAR 02 OF popMasters PROMPT "  Masters Second" FONT _menuFontFace,_menuFontSize STYLE _menuStyleChar

    ON SELECTION BAR 02 OF popMasters do FORM frmMasters2
    
ACTIVATE MENU _mainmenu 
READ EVENTS

RETURN 
	
*****************************	
PROCEDURE QuitMenu	
*****************************	
	CLEAR EVENTS 
	DEACTIVATE MENU _mainmenu 
	RELEASE MENUS _mainmenu EXTENDED 
	SET SYSMENU TO DEFAULT

Thank you,
Rajesh




 
Hi Tamar,

What you say (and Olaf inferred) regarding the flexibility for users (say people with disabilities) is correct. On the other hand it's a matter of aesthetics from the client's point of view. I am just following their needs.

Rajesh.
 
Link


Rajesh,

To my opinion your code has several errors. I have attached a zip file, example of a main form with a menu. Open Form1 and Form2 to read how I did it.
Koen
 
Dear all,

Sorry for coming back after a gap :-(

Will look into all suggestions and will let all you know what I decided finally.

Thank you team!
Rajesh
 
Dear Koen,

Thank you for the time you spent to prepare that demo set.
I will try those options you mentioned.

By the way, the Exit option really doesn't exit from menu and come to the command prompt.
I will have to see further into that.

Rajesh
 
Hi all,

I have decided to go with the foxpro system menu with it's own menu fonts.

Rest of the trials will be done later time as per all of your suggestions and guidance
for using a Custom Menu with font changes.

I will try to post here the complete code when I create a custom menu with font changes.

Thank you all for your time,
Rajesh
 
Glad to see you have settled on a solution you are happy with, Rajesh. I'm sure this thread will be of interest to other people.

By the way, you say "the Exit option really doesn't exit from menu". The Exit option that you have in your code will execute a CLEAR EVENTS. The effect is to transfer control to the line after the READ EVENTS. The result of that will depend on what comes after your menu code. The normal thing would be to clean up (close any open forms, etc), and then QUIT.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hi Mike,

Mike said:
By the way, you say "the Exit option really doesn't exit from menu". The Exit option that you have in your code will execute a CLEAR EVENTS. The effect is to transfer control to the line after the READ EVENTS. The result of that will depend on what comes after your menu code. The normal thing would be to clean up (close any open forms, etc), and then QUIT.

Koen had taken his precious time to prepare and upload a full project to
demonstrate the menu implementation (you can see his (or 'her' I am not sure ;-) ) post above).
I was talking about the 'Exit' of the menu in that program.

Rajesh
 
Rajesh,

To exit a project or to exit an exe, are two different things. To exit an exe, built with VFP, will work with
Code:
clear events
in your exit bar command.
To exit a pjx you have to restore your default VFP menu.
Further more, f.y.i. you can find more info about me on
Regards,
Koen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top