how close external window in app designer?

조회 수: 14 (최근 30일)
Vincenzo Bianco
Vincenzo Bianco 2019년 5월 1일
댓글: Stephane Dauvillier 2019년 5월 2일
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
Stephane Dauvillier 2019년 5월 1일
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
Stephane Dauvillier 2019년 5월 2일
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