On Mon, 27 Apr 2009 12:44:21 am you wrote: > the code is good but why did you use an observer ??? You just need to > set the handle in the new request. Thanks, I'll do that. I looked everywhere trying to figure this out, perhaps there should be this type of example in the help file.
Regards Richard > > An observer is mde to catch an event before or after the objet observed. > > to change the event parent and handle : Object.Attach(... > http://gambasdoc.org/help/comp/gb/object/attach?en > > For Each Printer_name InMyApp.available_printers > '-------------------------------------------------- > 'make a menu item for each printer > '-------------------------------------------------- > menu_item = New Menu(mnuPrinter) As "mnuPrinter" > With menu_item > .Caption = Printer_name > .Tag = Printer_name > .Name = Printer_name > End With > Next > > > Regards, > > Fabien Bodard > > 2009/4/26 richard terry <rte...@pacific.net.au>: > > On Sun, 26 Apr 2009 12:22:51 pm richard terry wrote: > >> Is it possible to create/add to a menu at runtime. > >> > >> If so, I wonder if anyone could give me an example. > >> > >> Regards > >> > >> Richard > >> > >> ------------------------------------------------------------------------ > >>--- --- Crystal Reports - New Free Runtime and 30 Day Trial > >> Check out the new simplified licensign option that enables unlimited > >> royalty-free distribution of the report engine for externally facing > >> server and web deployment. > >> http://p.sf.net/sfu/businessobjects > >> _______________________________________________ > >> Gambas-user mailing list > >> Gambas-user@lists.sourceforge.net > >> https://lists.sourceforge.net/lists/listinfo/gambas-user > > > > Answering myself, but perhaps someone can check this code and see if it > > is valid, or could improve it. > > > > The object was to put a popup menu on the print button in my prescription > > writer, so that if I didn't want to send the script to the default > > printer I could right mouse click and get up a list, so this is what I > > did: > > > > Public Sub Editor_SpecialButtons_Menu() > > Dim menu_item As Menu > > Dim hObs As Observer > > Dim Printer_name As String > > '------------------------------------------ > > 'Create a new menu on the fly > > '------------------------------------------ > > Dim mnuPrinter As New Menu(Me) > > > > '----------------------------------------------------------------- > > 'Only do this at the moment in the script writer > > 'and only on the print button > > '----------------------------------------------------------------- > > Select Case WorkspaceEditor.ActiveWindow.Tag > > Case "Scripts" > > Select Case Last.tag 'the buttons > > Case "print" > > > > 'Get list of printers attatched to this machine > > MyApp.Printers_Get_Available() > > For Each Printer_name InMyApp.available_printers > > '-------------------------------------------------- > > 'make a menu item for each printer > > '-------------------------------------------------- > > menu_item = New Menu(mnuPrinter) > > With menu_item > > .Caption = Printer_name > > .Tag = Printer_name > > .Name = Printer_name > > hobs = New Observer(menu_item) As "mnuPrinter" > > End With > > Next > > mnuPrinter.Popup() > > > > End Select > > End Select > > End > > > > > > Public Sub mnuPrinter_Click() > > > > Print "in the new menu", Last.tag > > > > End > > > > This seems to give the desired result, but is the code ok? > > > > Regards > > > > Richard > > > > ------------------------------------------------------------------------- > >----- Crystal Reports - New Free Runtime and 30 Day Trial > > Check out the new simplified licensign option that enables unlimited > > royalty-free distribution of the report engine for externally facing > > server and web deployment. > > http://p.sf.net/sfu/businessobjects > > _______________________________________________ > > Gambas-user mailing list > > Gambas-user@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/gambas-user ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensign option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user