MATLAB SIMULINK 7 - GRAPHICAL USER INTERFACE Bedienungsanleitung Seite 205

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 330
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 204
Examples: Programming GUI Components
8-33
3 View the ActiveX Properties with the Property Inspector. Select the control
in the Layout Editor, and then select
Property Inspector from the View
menu or by clicking the Property Inspector icon .
The following figure shows the properties of the
mwsamp ActiveX control as
they appear in the Property Inspector.
The ActiveX control
mwsamp has just two properties:
-
Label, which contains the text that appears at the top of the control
-
Radius, the default radius of the circle, which is 20
4 Add the following code to the mswamp control’s Click callback. This code
programs the ActiveX control to change the circle radius when the user
clicks the circle, and updates the label to display the new radius.
hObject.radius = .9*hObject.radius;
hObject.label = ['Radius = ' num2str(hObject.radius)];
refresh(handles.figure1);
To locate the Click callback in the GUI M-file, select View Callbacks from
the
View menu and then select Click.
5 Add the following commands to the opening function. This code initializes
the label when you first open the GUI.
handles.activex1.label = ...
['Radius = ' num2str(handles.activex1.radius)];
Now, when you open the GUI and click the ActiveX control, the radius of the
circle is reduced by 10 percent and the new value of the radius is displayed. The
following figure shows the GUI after clicking the circle six times.
Seitenansicht 204
1 2 ... 200 201 202 203 204 205 206 207 208 209 210 ... 329 330

Kommentare zu diesen Handbüchern

Keine Kommentare