> >
> >
> > Check DEFINE PAD in HELP.
> >
> >
> > -----------------
> > Borislav Borissov
> >
> >
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller> >
The only thing normal about database guys is their tables.>
>
> Hi Borislav Borissov !
>
> thanks ! but i already did this and as i stated in my original post i was able to insert a NEW PAD in the MENU
> my problem was that i cant insert a NEW BAR in a target PAD. maybe because the MENU is already created ?
>
> i was able to DO MENU.MPR with thisform, "MY_PREFERRED_MENU_NAME" so that AFTER the menu is created i can reference it using its name MY_PREFERRED_MENU_NAME
>
> NOW lets say i wanted to add a new BAR called "ADJUSTMENTS" under PAD "TRANSACTIONS"
>
> TRANSACTION_PAD = GETPAD("MY_PREFERRED_MENU_NAME", 2 ) && it appears to be a SYS(2015) name generated by GENMENU
>
> CAN I do ?
> DEFINE BAR (SOMEBARNUMBER) OF (TRANSACTION_PAD) PROMPT "ADJUSTMENTS"
>
> It gives me an error that the menu is not defined in define menu etc.
If you want to use the Menu Designer, you can define Pad Names and Bar Numbers there.
Alternatively, you can create, i.e. DEFINE Menus, Pads, Bars etc anytime directly in your code.
The Menu name itself would depend on your goal, e.g. whether you want to use the _Screen Menu, _MSYSMENU,
as opposed to a so called "SDI" menu belonging to a certain Form window,
or a right-click Shortcut / Context menu.
When you run the following sample, you'd get a dynamic right-click context menu of a TestForm where the content would get dynamically changed depending on a hypothetical "User Privileges" concept
hth
-Stefan
#define _USER_PRIVILEGE_LEVEL_GUEST 1
#define _USER_PRIVILEGE_LEVEL_OPERATOR 3
#define _USER_PRIVILEGE_LEVEL_ADMIN 5
LOCAL oForm as Form
oForm = CREATEOBJECT('TestForm')
oForm.Show(1)
RETURN
DEFINE CLASS TestForm as Form
AutoCenter = .T.
nUserLevelCurrent = _USER_PRIVILEGE_LEVEL_OPERATOR
PROCEDURE RightClick
Thisform.ShortcutMenu()
ENDPROC
PROCEDURE ShortcutMenu
DEFINE POPUP sc SHORTCUT RELATIVE FROM MROW(),MCOL()
DEFINE BAR 1 OF sc PROMPT "Operator's Bar"
ON SELECTION BAR 1 OF sc MESSAGEBOX("Operator's Bar")
SET SKIP OF BAR 1 OF sc (_screen.ActiveForm.nUserLevelCurrent < _USER_PRIVILEGE_LEVEL_OPERATOR)
DEFINE BAR 2 OF sc PROMPT "Admin Bar"
ON SELECTION BAR 2 OF sc MESSAGEBOX("Admin's Bar")
SET SKIP OF BAR 2 OF sc (_screen.ActiveForm.nUserLevelCurrent < _USER_PRIVILEGE_LEVEL_ADMIN)
DO CASE
CASE Thisform.nUserLevelCurrent = _USER_PRIVILEGE_LEVEL_ADMIN
DEFINE BAR 3 OF sc PROMPT "Admin's optional Bar"
ON SELECTION BAR 3 OF sc MESSAGEBOX("Admin's optional Bar")
CASE Thisform.nUserLevelCurrent = _USER_PRIVILEGE_LEVEL_OPERATOR
DEFINE BAR 4 OF sc PROMPT "Operator's optional Bar"
ON SELECTION BAR 4 OF sc MESSAGEBOX("Operator's optional Bar")
ENDCASE
ACTIVATE POPUP sc
ENDPROC
PROCEDURE GetUserPrivileges()
* In a "real" context, this method might ask something
* like a "global application object" m.goApp
RETURN Thisform.nUserLevelCurrent
ENDPROC
ADD OBJECT cboPrivilegeLevel as PrivilegeCombo WITH ;
Left = 100, Top = 100, ControlSource = 'Thisform.nUserLevelCurrent'
ENDDEFINE
DEFINE CLASS PrivilegeCombo as ComboBox
BoundColumn = 2
BoundTo = .T.
PROCEDURE Init
LOCAL lcLevel
This.AddItem('')
This.AddItem('Guest')
lcLevel = TRANSFORM(_USER_PRIVILEGE_LEVEL_GUEST)
This.AddListItem(m.lcLevel,This.NewItemID,2)
This.AddItem('Operator')
lcLevel = TRANSFORM(_USER_PRIVILEGE_LEVEL_OPERATOR)
This.AddListItem(m.lcLevel,This.NewItemID,2)
This.AddItem('Admin')
lcLevel = TRANSFORM(_USER_PRIVILEGE_LEVEL_ADMIN)
This.AddListItem(m.lcLevel,This.NewItemID,2)
ENDPROC
ENDDEFINE