ActiveX
Contents
[
Hide
]
บทความนี้สาธิตวิธีการเพิ่ม, เข้าถึง, ลบและกำหนดค่า ActiveX controls ในงานนำเสนอด้วย Aspose.Slides for Java.
เพิ่ม ActiveX Control
แทรก ActiveX control ใหม่และกำหนดค่าคุณสมบัติตามต้องการ.
static void addActiveX() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
// เพิ่ม ActiveX control ใหม่.
IControl control = slide.getControls().addControl(ControlType.WindowsMediaPlayer, 50, 50, 100, 50);
// ตั้งค่าบางคุณสมบัติตามต้องการ.
control.getProperties().add("Value", "Default text");
presentation.save("add_activex.pptm", SaveFormat.Pptm);
} finally {
presentation.dispose();
}
}
เข้าถึง ActiveX Control
อ่านข้อมูลจาก ActiveX control ตัวแรกบนสไลด์.
static void accessActiveX() {
Presentation presentation = new Presentation("add_activex.pptm");
try {
ISlide slide = presentation.getSlides().get_Item(0);
if (slide.getControls().size() > 0) {
// เข้าถึง ActiveX control ตัวแรก.
IControl control = slide.getControls().get_Item(0);
System.out.println("Control Name: " + control.getName());
System.out.println("Value: " + control.getProperties().get_Item("Value"));
}
} finally {
presentation.dispose();
}
}
ลบ ActiveX Control
ลบ ActiveX control ที่มีอยู่จากสไลด์.
public static void removeActiveX() {
Presentation presentation = new Presentation("add_activex.pptm");
try {
ISlide slide = presentation.getSlides().get_Item(0);
if (slide.getControls().size() > 0) {
// ลบ ActiveX control ตัวแรก.
slide.getControls().removeAt(0);
}
presentation.save("removed_activex.pptm", SaveFormat.Pptm);
} finally {
presentation.dispose();
}
}
ตั้งค่า ActiveX Properties
เพิ่ม control และกำหนดค่า ActiveX properties หลายอย่าง.
public static void setActiveXProperties() {
Presentation presentation = new Presentation();
try {
ISlide slide = presentation.getSlides().get_Item(0);
// เพิ่มคอนโทรล Windows Media Player และกำหนดค่าคุณสมบัติ.
IControl control = slide.getControls().addControl(ControlType.WindowsMediaPlayer, 50, 50, 150, 50);
control.getProperties().set_Item("Caption", "Click Me");
control.getProperties().set_Item("Enabled", "true");
presentation.save("set_activex_props.pptm", SaveFormat.Pptm);
} finally {
presentation.dispose();
}
}