Button with menu
Posted: Fri Nov 15, 2019 4:42 am
Hi,
I'm adding a menu to our printbutton. In this menu there are extra options to export the data. Since there are a lot of buttons in our application I would like to do the following.
Create a function which return an 'omenu'. See the code below.
With this function it is rather easy to modify the print buttons by adding the following code to the button as below:
This is working fine.
My question about this is how about the dialog oDlg that is created in the buttonprintmenu function. When will this oDlg get destroyed, or how do I destroy this? Will this give a problem if a user has executed this a lot of times during the day.
I'm adding a menu to our printbutton. In this menu there are extra options to export the data. Since there are a lot of buttons in our application I would like to do the following.
Create a function which return an 'omenu'. See the code below.
Code: Select all
Function buttonprintmenu(oBrowse,_cTitel)
**************************************
Local getlist := {} , oDlg , getoptions := {}
Local oPrintMenu
DCSUBMENU oPrintMenu PROMPT 'Menu'
DCMENUITEM 'Export to Screenreport' PARENT oPrintMenu ;
ACTION {||ABO_printbrowse(oBrowse,.T.,.F.,_cTitel,'')}
DCMENUITEM 'Export to XLS' PARENT oPrintMenu ;
ACTION {||ABO_printbrowse(oBrowse,.T.,.T.,_cTitel,'X')}
DCMENUITEM 'Export to PDF' PARENT oPrintMenu ;
ACTION {||ABO_printbrowse(oBrowse,.T.,.T.,_cTitel,'P')}
dcgetoptions NOTITLEBAR BORDER XBPDLG_DLGBORDER NOESCAPEKEY ;
NOEDITNAVKEYS {|| .T. } FITPAD 1
dcread gui exit PARENT @oDlg FIT options getoptions
return oPrintMenu
Code: Select all
...
MENUACTION {|a,b,o,oPrintMenu|oPrintMenu:=buttonprintmenu(@oBrowse,''),oPrintMenu:PopUp( o:setParent(), o:currentPos(), 2 , ;
XBPMENU_PU_DEFAULT + XBPMENU_PU_MOUSE_RBDOWN ) } ;
My question about this is how about the dialog oDlg that is created in the buttonprintmenu function. When will this oDlg get destroyed, or how do I destroy this? Will this give a problem if a user has executed this a lot of times during the day.