ATL 獲取PPT控制元件內容
全屏模式下獲取資料
GetTitleNameWithSlide(strTitleName,m_spApp.p->ActivePresentation->SlideShowWindow->View->Slide);
BOOL MyPptTest::GetTitleNameWithSlide(char *sOutTitleName, _SlidePtr Sld)
{
char strTmp[256] = {0};
int nIndex = Sld->GetSlideIndex(); //當前第幾頁
int ncount = 0; //本頁總共有幾個物件,物件ID從1開始,包括所有物件
MSPPT::Shapes* pShapes = NULL;
Sld->get_Shapes(&pShapes);
ncount = pShapes->GetCount();
if (pShapes)
{
int i = 0;
BOOL bIsHave = FALSE;
MSPPT::Shape *pItemFrist = NULL;
int nMinIndex = 1;
for (i = 1;i <=ncount;i++)
{
MSPPT::Shape *pItem1 = NULL;
pShapes->raw_Item(_variant_t((long)i),&pItem1);
Office::MsoShapeType shapeType ;
pItem1->get_Type(&shapeType);
if (shapeType != msoPlaceholder &&
shapeType != msoAutoShape &&
shapeType != msoTextBox &&
shapeType != msoFreeform )
{
//PPT頁面中物件型別不為上述型別的時候,執行下面的一些函式的時候造成ppt內部崩潰,其他變數需要進一步測試
continue;
}
pShapes->raw_Item(_variant_t((long)i),&pItemFrist);
MSPPT::TextFrame *pTextframe = NULL;
pItemFrist->get_TextFrame(&pTextframe);
if (pTextframe)
{
MSPPT::TextRange* pRange = NULL;
pTextframe->get_TextRange(&pRange);
char szText[255];
BSTR bstrText = NULL;
pRange->get_Text(&bstrText); //bstrText就是ppt當前頁的各個可讀取物件的文字內容
}
}
}
return TRUE;
}
//非全屏模式下獲取ppt當前頁內容只是函式傳入變數不同而已,其他都一樣
struct SlideRange *Sldrange=(struct SlideRange *)lpStru;
GetTitleNameWithSlideRange(Sldrange);