Path: news.mathworks.com!not-for-mail
From: Loren Shure <loren@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Visible figure has no gui handle. Why?
Date: Wed, 29 Aug 2007 17:10:04 -0400
Organization: The MathWorks
Lines: 153
Message-ID: <MPG.213faab8f387c2f39897ab@news.mathworks.com>
References: <fav61d$7a5$1@fred.mathworks.com> <fav7q6$d5g$1@canopus.cc.umanitoba.ca> <fav8uo$5oc$1@fred.mathworks.com> <fb4l5m$4u4$1@fred.mathworks.com>
NNTP-Posting-Host: shurel.dhcp.mathworks.com
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-15"
Content-Transfer-Encoding: 7bit
X-Trace: fred.mathworks.com 1188421804 29238 144.212.219.159 (29 Aug 2007 21:10:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 29 Aug 2007 21:10:04 +0000 (UTC)
User-Agent: MicroPlanet-Gravity/2.70.2067
Xref: news.mathworks.com comp.soft-sys.matlab:426157


In article <fb4l5m$4u4$1@fred.mathworks.com>, x0zero@gmail.com says...
> Hello. I have been stumped by this problem for several days
> now. Using the tips provided previously, I have been
> debugging the problem. However, I still get an 'Invalid
> handle' error when using get('Tag', 'figureM'). 
> 
> Below is some interesting info that shows the figure exists
> and HandleVisibility = on. At the moment I execute these
> statements, the figure is visible on screen. Yet I still get
> an 'Invalid handle' error as shown below. Any tips? 
> 
> 
> K>> h1 = findall(0, 'Tag', 'figureM')
> 
> h1 =
> 
>   399.0098
> 
> K>> get(h1)
> 	Alphamap = [ (1 by 64) double array]
> 	BackingStore = on
> 	CloseRequestFcn = closereq
> 	Color = [0.709804 0.807843 0.909804]
> 	Colormap = [ (64 by 3) double array]
> 	CurrentAxes = [406.01]
> 	CurrentCharacter = 
> 	CurrentObject = [32.0095]
> 	CurrentPoint = [230 22]
> 	DockControls = off
> 	DoubleBuffer = on
> 	FileName = [ (1 by 84) char array]
> 	FixedColors = [ (12 by 3) double array]
> 	IntegerHandle = off
> 	InvertHardcopy = on
> 	KeyPressFcn = [ (1 by 1) function_handle array]
> 	KeyReleaseFcn = 
> 	MenuBar = none
> 	MinColormap = [64]
> 	Name = Figure_M
> 	NextPlot = add
> 	NumberTitle = off
> 	PaperUnits = inches
> 	PaperOrientation = portrait
> 	PaperPosition = [0.25 2.5 8 6]
> 	PaperPositionMode = manual
> 	PaperSize = [8.5 11]
> 	PaperType = usletter
> 	Pointer = arrow
> 	PointerShapeCData = [ (16 by 16) double array]
> 	PointerShapeHotSpot = [1 1]
> 	Position = [72 34 1494 1031]
> 	Renderer = painters
> 	RendererMode = auto
> 	Resize = on
> 	ResizeFcn = 
> 	SelectionType = normal
> 	ShareColors = on
> 	ToolBar = auto
> 	Units = pixels
> 	WindowButtonDownFcn = 
> 	WindowButtonMotionFcn = 
> 	WindowButtonUpFcn = 
> 	WindowScrollWheelFcn = 
> 	WindowStyle = normal
> 	WVisual = 00 (RGB 32  GDI, Bitmap, Window)
> 	WVisualMode = auto
> 
> 	BeingDeleted = off
> 	ButtonDownFcn = 
> 	Children = [ (16 by 1) double array]
> 	Clipping = on
> 	CreateFcn = 
> 	DeleteFcn = 
> 	BusyAction = queue
> 	HandleVisibility = on
> 	HitTest = on
> 	Interruptible = on
> 	Parent = [0]
> 	Selected = off
> 	SelectionHighlight = on
> 	Tag = figureM
> 	Type = figure
> 	UIContextMenu = []
> 	UserData = []
> 	Visible = on
> 
> K>> get('Tag', 'figureM')
> ??? Error using ==> get
> Invalid handle.
> 
> K>> 
> 
> "G.A.M. " <x0zero@gmail.com> wrote in message
> <fav8uo$5oc$1@fred.mathworks.com>...
> > Hi. Thank you for your tips. I now understand a bit about
> > handle visibility (and I now have some clues about what to
> > search for in help).
> > 
> > Using the property inspector I saw that the figure's
> > HandleVisibility property was set to 'callback'. I changed
> > it to 'on', as advised here:
> >
> http://www.mathworks.cn/matlabcentral/newsreader/view_thread/155215
> > 
> > However, that did not change the fact that my code cannot
> > find the handle. Apparently the HandleVisibility property is
> >  later being set to 'off' by some process I'm not aware of.
> > 
> > What built-in functions would set HandleVisibility to off? I
> > haven't written any code to do that, so I'm not sure why it
> > is happening. I appreciate any other tips.
> > 
> > roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in
> > message <fav7q6$d5g$1@canopus.cc.umanitoba.ca>...
> > > In article <fav61d$7a5$1@fred.mathworks.com>, G.A.M. 
> > <x0zero@gmail.com> wrote:
> > > >Hello. I have an application that creates and displays a
> > > >figure (as the main window for the GUI). The figure is
> > > >displayed on screen, but the gui handle doesn't exist
> > > >immediately after the figure is created.
> > > 
> > > >Executing h=findobj shows me that the figure and all its
> > > >uicontrols are not among the existing objects even though
> > > >the figure is currently visible on the screen.
> > > 
> > > The HandleVisibility property of the figure has been set
> > to 'off'.
> > > 
> > > See findall() and allchild()
> > > -- 
> > >    Okay, buzzwords only. Two syllables, tops.  -- Laurie
> > Anderson
> > 
> 
> 

You have to pass possible handles or ancestors into findall.  These all 
worked for me as I expected:

h = figure('Tag','figureM');
h(2) = figure;

>>findall(h,'tag','figureM')
   1
>>findall(0,'tag','figureM')
   1
>>findall(h(2),'tag','figureM')
   Empty matrix: 0-by-1


-- 
Loren
http://blogs.mathworks.com/loren/