Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
How can I remove the close item menu on my figure?

Subject: How can I remove the close item menu on my figure?

From: Camille Couzi

Date: 24 Aug, 2010 14:27:04

Message: 1 of 5

Hi!
I have a little figure (that we are going to call fig2 here) created from my first GUI (fig1), and I want to close it only by pushing on a button which is on my fig1. I need that because when I close the fig2 by clicking on the close item menu (X button on the rigth up corner of the fig2), that makes many errors (because I have defined a WindowButtonMotionFcn inside the fig, so if I close this figure by this way, matlab becomes crazy with this Fcn...
So my question is: how can I make this X button (close item menu) of my fig2:
- disapear,
- enable 'off',
-or hwatever?!!!!!

i have been looking in the CloseRequestFcn, but if I modify it, then when I close the fig2 by another way, that makes errors too!!

Thanks in advance for your help

Camille.

Subject: How can I remove the close item menu on my figure?

From: Matthew Whitaker

Date: 27 Aug, 2010 17:58:11

Message: 2 of 5

"Camille Couzi" <camillecouzi@yahoo.fr> wrote in message <i50kro$om8$1@fred.mathworks.com>...
> Hi!
> I have a little figure (that we are going to call fig2 here) created from my first GUI (fig1), and I want to close it only by pushing on a button which is on my fig1. I need that because when I close the fig2 by clicking on the close item menu (X button on the rigth up corner of the fig2), that makes many errors (because I have defined a WindowButtonMotionFcn inside the fig, so if I close this figure by this way, matlab becomes crazy with this Fcn...
> So my question is: how can I make this X button (close item menu) of my fig2:
> - disapear,
> - enable 'off',
> -or hwatever?!!!!!
>
> i have been looking in the CloseRequestFcn, but if I modify it, then when I close the fig2 by another way, that makes errors too!!
>
> Thanks in advance for your help
>
> Camille.


There is no easy way to remove the X button. However reading through your description the classic solution is to make the callback for the figure close request and the button the same so that no matter how the user closes the figure the same code is executed. Here is a short demo of how you could do that:

function closeRequestDemo
    figHdl = dialog('Name','Close Request Demo',...
                    'CloseRequestFcn',@cmdClose_Callback);...dialog creates a nice stripped down figure
        
    uicontrol('Parent',figHdl,...
              'String','Close',...
              'Callback',@cmdClose_Callback);
          
          
    function cmdClose_Callback(hObject,varargin)
        disp(['Close Request coming from: ',get(hObject,'Type')]);
        
        %do cleanup here
        delete(figHdl);
        
    end %cmdClose_Callback
end %closeRequestDemo


Hope this helps
Matt W

Subject: How can I remove the close item menu on my figure?

From: Camille Couzi

Date: 27 Aug, 2010 19:21:08

Message: 3 of 5

Hi Matt

Thanks for your help, I created a closrequestfcn for my figure and now all is working fine.
 Thank you so much!!!!

another question related with that: you said that it is very difficult to hide this up right corner of figure (where close, minimize and maximize buttons are), but as it is possible to hide menubar, and toolbar, I can image that there could be a possibility somewhere... or: is there a way to enable the maximize item, ie I define the size of a figure and I don't want possibility by the user to make it larger...

Thanks again!

Camille.

Subject: How can I remove the close item menu on my figure?

From: Matthew Whitaker

Date: 27 Aug, 2010 19:34:06

Message: 4 of 5

"Camille Couzi" <camillecouzi@yahoo.fr> wrote in message <i59374$si6$1@fred.mathworks.com>...
> Hi Matt
>
> Thanks for your help, I created a closrequestfcn for my figure and now all is working fine.
> Thank you so much!!!!
>
> another question related with that: you said that it is very difficult to hide this up right corner of figure (where close, minimize and maximize buttons are), but as it is possible to hide menubar, and toolbar, I can image that there could be a possibility somewhere... or: is there a way to enable the maximize item, ie I define the size of a figure and I don't want possibility by the user to make it larger...
>
> Thanks again!
>
> Camille.

To make the figure a fixed size set its Resize property off

so
f = figure('Resize','off');

Now the figure can not be resized. It can still be minimized however.

Matt

Subject: How can I remove the close item menu on my figure?

From: Walter Roberson

Date: 27 Aug, 2010 19:35:24

Message: 5 of 5

On 10-08-27 02:21 PM, Camille Couzi wrote:

> another question related with that: you said that it is very difficult
> to hide this up right corner of figure (where close, minimize and
> maximize buttons are), but as it is possible to hide menubar, and
> toolbar, I can image that there could be a possibility somewhere...

The close, minimize, and maximize button are all handled by the Window Manager
that is being run on your behalf. MS Windows only has a single window manager
available that I know of (though you can customize various properties and
effects such as Aero); Linux systems can generally be configured to use
different window managers for different users; Mac OS X has a standard window
manager but does not make it impossible to run additional window managers
(e.g., you can install X Windows on OS X.)

Anyhow, it is a common principle of window managers that those three controls
are the responsibility of the window manager and not of the individual
program. Window managers tend to make it difficult to impossible to remove
those controls from a windowed program -- but they do usually provide some
mechanism for a program to go "full-screen" (e.g., games).

So, yes, it _might_ be possible to remove those buttons... but it might be
messy to do so.

> or:
> is there a way to enable the maximize item, ie I define the size of a
> figure and I don't want possibility by the user to make it larger...

That is usually possible and not _too_ hard in Window Managers.

Within Matlab, you can set the Resize property of any figure to be 'off'.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us