how close external window in app designer?

14 次查看(过去 30 天)
I have two windows in app designer. "window1" create "window2".
I want to close all window with a button in window1. If i use "close all" or "close all force", it does not work.
  2 个评论
Walter Roberson
Walter Roberson 2019-5-1
You mentioned external. Was the second window created by outside software such as Word or Fortnite?
Vincenzo Bianco
Vincenzo Bianco 2019-5-2
no. it's created inside the execution of window1.

请先登录,再进行评论。

采纳的回答

Stephane Dauvillier
close instruction will only close figure
If you have created your windows1 (I suppose it's an app) like this
hWin1 = windows1 ;
Then you should be able to delete it with
delete(hWin1)
  2 个评论
Vincenzo Bianco
Vincenzo Bianco 2019-5-2
it does not work. window1 and window2 are both .mlapp files.
I have an error: "Undefined function or variable hWin1"
Stephane Dauvillier
if hWin1 doesn't exist it will not work.
I suppose, you're not in the same workspace between the call of this
hWin1 = windows1 ;
And the call of this
delete(hWin1)
Otherwise, you wouldn't have this error message.
What you have to do is pass the variable hWin1
Without any other knowledge of your code it's pure guess.
So, what I'm guessing is your main app open other app. Then during this opening you have to assign the output of windows1 to a property of your main app.
By doing so, you will be able to delete this "sub app" when appropriate.
You can add properties in your main app named
mySubApps
In the initialization methods of your app you have to initialize this new property
function myInitiazeFunction(app)
app.mySubApps = [] ;
% put the rest of your initialization
end
Then In the methods where your main app open windows1
function myWhatever(app,someOtherParameter)
hWin1 = windows1 ;
app.mySubApps = [app.mySubApps;hwin1];
end
Do the same thing for every "sub app"
An then in the methodyou want your main app to close your sub app:
function deleteSubApps(app,someOtherParameters)
delete(app.mySubApps)
end

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by