導航:首頁 > 文件教程 > colevariant頭文件

colevariant頭文件

發布時間:2023-06-15 01:28:13

⑴ ColeVariant需要引用那個頭文件mfc問題

ColeVariant需要引用 #include <afxdisp.h>

細節如下:

  1. COleVariant類是對VARIANT結構的封裝。

  2. VARIANT 結構包含兩部分。其一是 VARTYPE 型的成員變數vt;其二是個聯合類型,這個聯合包含了VC常用的幾乎所有類型。因為聯合用的是相同的存儲空間,因此對聯合的內容的解釋依賴於 vt。

  3. COleVariant本質上是一個枚舉,用同一種類型來表達不同的子類型。如同boost中的variant。

⑵ 為什麼我用VC控制powerpoint 總是不成功啊

手頭沒有頭文件,不知道為什麼,不過這兒有另一篇,看看是不是你office版本問題:
This article was previously published under Q222960
SUMMARY
This article describes how to automate Microsoft PowerPoint by using Visual C++ 5.0 or Visual C++ 6.0 with The Microsoft Foundation Classes (MFC).
MORE INFORMATION
By using automation in PowerPoint, you can programmatically print, display slides, and do most of the things you can do interactively. Follow these steps to build and run the automation example:
1. Create a new dialog-based MFC EXE project.
2. Add a button to your dialog box and a BN_CLICKED-handler for it.
3. Open ClassWizard (Ctrl+W), click the Automation tab, click Add Class, and select From a type library.
4. Go to the directory where you installed Office (for example, C:\Program Files\Microsoft Office\Office) and choose Msppt8.olb. The PowerPoint object library for PowerPoint 2000 is named Msppt9.olb. The PowerPoint object library for PowerPoint 2002 is Msppt.olb, and it is located, by default, in the c:\Program Files\Microsoft Office\Office10 folder. The PowerPoint object library for Microsoft Office PowerPoint 2003 is Msppt.olb, and it is located, by default, in the c:\Program Files\Microsoft Office\Office11 folder
5. Select all the classes it finds, and click OK to get back to your project. ClassWizard has generated some automation "wrapper classes" from the PowerPoint type library and created the files Msppt8.h and Msppt8.cpp.
6. Add the following code to your button handler:// Start PowerPoint.
_Application app;
COleException e;
if(!app.CreateDispatch("Powerpoint.Application", &e)) {
CString str;
str.Format("CreateDispatch() failed w/err 0x%08lx", e.m_sc),
AfxMessageBox(str, MB_SETFOREGROUND);
return;
}

// Make it visible.
app.SetVisible(TRUE);

// Get Presentations collection and add a new presentation.
Presentations presSet(app.GetPresentations());
_Presentation pres(presSet.Add(TRUE));

// Get Slides collection and add a new slide.
Slides slideSet(pres.GetSlides());
_Slide slide1(slideSet.Add(1, 2));

// Add text to slide, by navigating the slide as follows:
// slide1.shapes(#).TextFrame.TextRange.Text
{
Shapes shapes(slide1.GetShapes());
Shape shape(shapes.Item(COleVariant((long)1)));
TextFrame textFrame(shape.GetTextFrame());
TextRange textRange(textFrame.GetTextRange());
textRange.SetText("My first slide");
}
{
Shapes shapes(slide1.GetShapes());
Shape shape(shapes.Item(COleVariant((long)2)));
TextFrame textFrame(shape.GetTextFrame());
TextRange textRange(textFrame.GetTextRange());
textRange.SetText("Automating PowerPoint is easy\r\n"
"Using Visual C++ is powerful!");
}

// Add another slide with a chart.
_Slide slide2(slideSet.Add(2, 5));

// Add text to slide as before.
{
Shapes shapes(slide2.GetShapes());
Shape shape(shapes.Item(COleVariant((long)1)));
TextFrame textFrame(shape.GetTextFrame());
TextRange textRange(textFrame.GetTextRange());
textRange.SetText("Slide 2's topic");
}
{
Shapes shapes(slide2.GetShapes());
Shape shape(shapes.Item(COleVariant((long)2)));
TextFrame textFrame(shape.GetTextFrame());
TextRange textRange(textFrame.GetTextRange());
textRange.SetText("You can create and use charts "
"in your PowerPoint slides!");
}

// Add a chart where the default one was created.
{
// First get coordinates of old chart.
float cTop, cWidth, cHeight, cLeft;
Shapes shapes(slide2.GetShapes());
Shape shape(shapes.Item(COleVariant((long)3)));
cTop = shape.GetTop();
cWidth = shape.GetWidth();
cHeight = shape.GetHeight();
cLeft = shape.GetLeft();

// Delete original chart.
shape.Delete();

// Now add your own back where old one was.
Shape tmpShape(shapes.AddOLEObject(cLeft, cTop, cWidth, cHeight,
"MSGraph.Chart", "", 0, "", 0, "", 0));
}

// Add another slide, with an Organization chart.
_Slide slide3(slideSet.Add(3, 7));

// Add text to slide as before.
{

Shapes shapes(slide3.GetShapes());
Shape shape(shapes.Item(COleVariant((long)1)));
TextFrame textFrame(shape.GetTextFrame());
TextRange textRange(textFrame.GetTextRange());
textRange.SetText("The rest is only limited by your Imagination");
}
// Add a chart where the default one was created.
{
// First get coordinates of old chart.
float cTop, cWidth, cHeight, cLeft;
Shapes shapes(slide3.GetShapes());
Shape shape(shapes.Item(COleVariant((long)2)));
cTop = shape.GetTop();
cWidth = shape.GetWidth();
cHeight = shape.GetHeight();
cLeft = shape.GetLeft();

// Delete original chart.
shape.Delete();

// Now add your own back where old one was.
// The next line assumes you have the Microsoft OrgChart application
// installed and registered on your computer.
Shape tmpShape(shapes.AddOLEObject(cLeft, cTop, cWidth, cHeight,
"OrgPlusWOPX.4", "", 0, "", 0, "", 0));
}

// Setup slide show properties.
for(int i=1; i<=3; i++) {
_Slide slide(slideSet.Item(COleVariant((long)i)));
SlideShowTransition sst(slide.GetSlideShowTransition());
sst.SetEntryEffect(513); // Random.
sst.SetAdvanceOnTime(TRUE);
sst.SetAdvanceTime(5.0); // 5-seconds per slide.
}
// Prepare and run a slide show.
{
SlideShowSettings sss(pres.GetSlideShowSettings());
sss.SetShowType(3); // Kiosk.
sss.SetLoopUntilStopped(TRUE);
sss.SetRangeType(1); // Show all.
sss.SetAdvanceMode(2); // Use slide timings.
SlideShowWindow ssw(sss.Run()); // Run show.
}

// Sleep so user can watch slide show.
::Sleep(15000);

// Tell PowerPoint to quit.
app.Quit();

7. Add the following lines just before the implementing your button handler:#include "msppt8.h" //msppt9.h for PowerPoint 2000, msppt.h for PowerPoint 2002 and PowerPoint 2003

// Ole initialization class.
class OleInitClass {
public:
OleInitClass() {
OleInitialize(NULL);
}
~OleInitClass() {
OleUninitialize();
}
};
// This global class calls OleInitialize() at
// application startup, and calls OleUninitialize()
// at application exit.
OleInitClass g_OleInitClass;

8. Compile and run.

閱讀全文

與colevariant頭文件相關的資料

熱點內容
dnf蟲鏈怎麼升級 瀏覽:956
將16進制文件讀到數組中 瀏覽:899
caa中怎麼提取框選范圍數據 瀏覽:38
為什麼用數據登不上王者 瀏覽:92
yaffs2根文件系統 瀏覽:477
劍俠情緣微信活動禮包 瀏覽:985
ipad版本我的世界怎麼學賦魔 瀏覽:571
如何做好網站管理 瀏覽:280
湯姆貓是什麼網站 瀏覽:913
失易得數據恢復怎麼把照片 瀏覽:185
電腦只顯示1個網路 瀏覽:607
數控加工與編程專業怎麼樣 瀏覽:4
西安程序員工資 瀏覽:389
表格怎麼添加一行數據 瀏覽:35
旅遊網站開發怎麼選 瀏覽:669
properties文件位置 瀏覽:679
不想學編程可以做什麼 瀏覽:22
手機照片一鍵壓縮成文件 瀏覽:962
女生微信霸氣個性簽名 瀏覽:626
微博如何看別人一個月的數據 瀏覽:14

友情鏈接