Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Menu on non-toplevel form
Message
 
À
10/06/2003 07:59:41
Walter Meester
HoogkarspelPays-Bas
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire de menu & Menus
Divers
Thread ID:
00798293
Message ID:
00798323
Vues:
25
Hi Walter,

I use to use menu in top level form but later i dropped the idea and followed the convention.
Though i am not much update if something has been added in VFP8 with this respect.

In vfp6 i used to follow the following code. Maintenance is heavy but it works perfectly fine.
* To attach any menu to your Top-Level form, 
* call it from the Init event of the form:

* Syntax: DO <mprname> WITH <oFormRef> [,<cMenuname>|<lRename>]

*			oFormRef - form object reference (THIS)
*			cMenuname - name for menu
*			lRename - renames Name property of your form

* example:

*		PROCEDURE Init
*			DO mymenu.mpr WITH THIS,.T.
*		ENDPROC

* Use the optional 2nd parameter if you plan on running 
* multiple instances of your Top-Level form. The logical 
* lRename parameter will change the name property of your 
* form to the same name given the menu and may cause conflicts 
* in your code if you directly reference the form by name.

* You will also need to remove the menu when the form is 
* destroyed so that it does not remain around in memory 
* unless you wish to reactivate it later in a new form.

* If you passed the optional lRename parameter as .T. as in 
* the above example, you can easily remove the menu in the 
* form's Destroy event as shown below. This strategy is ideal 
* when using multiple instances of Top-Level forms.

* example:

*		PROCEDURE Destroy
*			RELEASE MENU (THIS.Name)
*		ENDPROC


*!*	LPARAMETER oFormRef,getMenuName
*!*	LOCAL cMenuName
*!*	IF TYPE("m.oFormRef") # "O" OR ;
*!*	  LOWER(m.oFormRef.BaseClass) # 'form' OR ;
*!*	  m.oFormRef.ShowWindow # 2
*!*		MESSAGEBOX([This menu can only be called from a Top-Level form. Ensure that your form's ShowWindow property is set to 2. Read the header section of the menu's MPR file for more details.])
*!*		RETURN
*!*	ENDIF
*!*	m.cMenuName = IIF(TYPE("m.getMenuName")="C",m.getMenuName,SYS(2015))
*!*	IF TYPE("m.getMenuName")="L" AND m.getMenuName
*!*		m.oFormRef.Name = m.cMenuName 
*!*	ENDIF

*!*	DEFINE MENU (m.cMenuName) IN (m.oFormRef.Name) BAR

*!* ALL CODE FOR THE MENUS AND POPUPS

*!* ACTIVATE MENU (m.cMenuName) NOWAIT

*!* ALL CODE FOR THE MENUS AND POPUPS SNIPPETS

*!*  Replace all code with '(m.cMenuName)' with '(m.cMenuName)' 
>Hi all,
>
>I want to have a menubar on my non-toplevel form. Anyone knows how to do this ?
>
>Walter,
--
--
Aashish Sharma
Tele Nos: +1-201-490-5405
Mobile: +91-9821053938
E-Mail:
aashish@aashishsharma.com
write2aashish@gmail.com

You better believe in yourself... if you don't, who else will ?
TODAY is a gift, that's why it's called PRESENT
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform