[Gambas-user] Modifying the popup menu on workspace tab

Benoit Minisini gambas at ...1...
Wed Mar 12 21:54:55 CET 2008


On mercredi 12 mars 2008, richard terry wrote:
> On Wed, 12 Mar 2008 10:22:51 am Benoit Minisini wrote:
> > On mardi 11 mars 2008, richard terry wrote:
> > > Currently when I add a new panel or form to the workspace, a tab
> > > appears where I can set the title.
> > >
> > > If I right mouse click on the tab there is a menu there which I didn't
> > > create, just with the name on the tab and a checkbox (checked) and a
> > > close current tab.
> > >
> > > I'd like to be able to have my own menu in place of this, is it
> > > possible?
> > >
> > > Regards
> > >
> > > Richard
> >
> > This is not directly possible at the moment.
> >
> > But you can hack it by finding the Workspace TabStrip: it is the parent
> > of every MDI child window. Then you create an Observer on the TabStrip,
> > and implements the Menu event. Then you call STOP EVENT in your Menu
> > event handler before returning, so that the default Workspace Menu event
> > handler
>
>  is not called.
>
> Not much success I wonder if you could tell me what's wrong:
> I have a text editor + buttons on a form called frmText editor
> On my Main form I create a new frm and add it to the workspace:
>  At the top of the form I did
>
>  public hObs as Observor
>
> In the routine I add each page I put:
>
>   Newpage = NEW frmTextEditor
>   WorkspaceEditor.Add(NewPage)
>
> I tried various comination and permutation of this to create an observer:
>
>    hObs = NEW Observer(NewPage.parent) AS "tabstrip"

I was wrong, The TabStrip is not the parent of the MDI child windows at all. 
You must find it "by hand":

DIM hTabStrip AS TabStrip
DIM hCtrl AS Control

FOR EACH hCtrl in aMDIChildWindow.Parent.Parent.Children
  IF hCtrl IS TabStrip THEN
     hTabStrip = hCtrl
     BREAK
  ENDIF
NEXT

It should work. :-)

Regards,

-- 
Benoit Minisini




More information about the User mailing list