Установить заголовок для OLE-значка
Contents
[
Hide
]
В классы IOleObjectFrame и OleObjectFrame добавлены новые методы get_SubstitutePictureTitle() и set_SubstitutePictureTitle(). Это позволяет получать, устанавливать или изменять заголовок OLE-значка. Приведённый ниже фрагмент кода демонстрирует пример создания объекта Excel и установки его заголовка.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
System::String oleSourceFile = u"ExcelObject.xlsx"; | |
System::String oleIconFile = u"Image.png"; | |
System::String path = u"../templates/"; | |
System::SharedPtr<Presentation> pres = System::MakeObject<Presentation>(); | |
System::SharedPtr<IPPImage> image; | |
System::SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0); | |
// Add Ole objects | |
System::ArrayPtr<uint8_t> allbytes = System::IO::File::ReadAllBytes(System::IO::Path::Combine(path, oleSourceFile)); | |
System::SharedPtr<IOleObjectFrame> oof = slide->get_Shapes()->AddOleObjectFrame(20.0f, 20.0f, 50.0f, 50.0f, u"Excel.Sheet.12", allbytes); | |
oof->set_IsObjectIcon(true); | |
// Add image object | |
System::ArrayPtr<uint8_t> imgBuf = System::IO::File::ReadAllBytes(oleIconFile); | |
System::SharedPtr<System::IO::MemoryStream> ms = System::MakeObject<System::IO::MemoryStream>(imgBuf); | |
image = pres->get_Images()->AddImage(System::MakeObject<System::Drawing::Bitmap>(ms)); | |
oof->get_SubstitutePictureFormat()->get_Picture()->set_Image(image); | |
// Set caption to OLE icon | |
oof->set_SubstitutePictureTitle(u"Caption example"); |