导航:首页 > 文件教程 > 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头文件相关的资料

热点内容
兰博玩游戏路径怎么选择正确文件 浏览:972
淘宝直通车恢复老版本 浏览:510
播放草莓的图片我都文件 浏览:55
微信大文件打不开 浏览:767
家装合同准备哪些文件 浏览:296
应用bat合并excel文件 浏览:984
迅雷影音文件夹 浏览:109
makefile的文件路径 浏览:392
计算机程序文件名扩展名为 浏览:982
网络游戏推广策划案 浏览:609
替换所有文件内容的代码 浏览:960
不是常用数据模型有哪些 浏览:426
aspcms版本号 浏览:835
安卓怎么用数据流量下载软件 浏览:553
大众手动空调数据流通道号是多少 浏览:303
手机qq令牌 浏览:737
cg原画上色教程 浏览:993
婚介服务中心app怎么做 浏览:43
日本苹果66g多少钱 浏览:93
个性的文件夹名称 浏览:697

友情链接