如何将PPT放在一个窗体中播放

kingxie403 2014-03-21 10:40:28
我用的是TOleContainer控件。。。但是搞不出来,不知各位有什么好的方法。帮忙解决一下,谢谢。
PPT不是全屏播放的,放在一个窗体中。。。。。。。
...全文
919 28 打赏 收藏 转发到动态 举报
写回复
用AI写文章
28 条回复
切换为时间正序
请发表友善的回复…
发表回复
DaveBobo 2016-04-18
  • 打赏
  • 举报
回复
楼主能否共享一下这个demo?
阿小步 2016-01-18
  • 打赏
  • 举报
回复
我这里有mfc的demo,需要的话可以联系我,很简单,q511163624
linguizhou 2014-11-23
  • 打赏
  • 举报
回复
@kingxie403问题怎么搞定了呀?求指教!
kingxie403 2014-03-31
  • 打赏
  • 举报
回复
结贴了,我已经搞定这个问题了,用的是OA的ocx插件。。。相关文件之后我会共享
许文君 2014-03-27
  • 打赏
  • 举报
回复
很少有自动操作PPT的需求,有这个需求的也都是录屏的,因此可能比较难得到回答,可以看下这个示例是否有用 http://www.codeproject.com/Articles/2506/Automating-MS-Office-applications
赵4老师 2014-03-26
  • 打赏
  • 举报
回复
如果是我,我可能用 VBA for PowerPoint 或者 CreateDesktop The CreateDesktop function creates a new desktop on the window station associated with the calling process. It returns a handle that can be used to access the new desktop. The calling process must have an associated window station, either assigned by the system at process creation time or set by SetProcessWindowStation. A desktop is a secure object contained within a window station object. A desktop has a logical display surface and contains windows, menus, and hooks. HDESK CreateDesktop( LPCTSTR lpszDesktop, // name of the new desktop LPCTSTR lpszDevice, // reserved; must be NULL. LPDEVMODE pDevMode, // reserved; must be NULL DWORD dwFlags, // flags to control interaction with other // applications DWORD dwDesiredAccess, // specifies access of returned handle LPSECURITY_ATTRIBUTES lpsa // specifies security attributes of // the desktop ); 通读一下MSDN中的ms-help://MS.VSCC.v90/MS.MSDNQTR.v90.chs/powerpntdev2007/content/HV10099330.htm Welcome to the Microsoft Office PowerPoint 2007 Developer Reference This reference contains conceptual overviews, programming tasks, samples, and references to guide you in developing solutions based on PowerPoint. Publish date of this reference: October 2006 (version 2007) This documentation is accessible from the following locations: From the product. To view the developer reference from inside your installed version of PowerPoint, click Help. In the Search box, click PowerPoint Developer Reference. October 2006 (version 2007) is included with the product. From the Microsoft Download Center. To download the latest version of the Developer Reference for offline viewing, and to update local copies for use with the product, visit the Microsoft Download Center. From the MSDN Library. To view the most recent version in the MSDN Library, click items in the table of contents control, displayed in the navigation pane of your browser. This documentation contains the following sections: What's New Provides a list of new members by object and in alphabetical order. Concepts Provides important concepts for developing custom PowerPoint solutions. Reference Provides reference materials for the PowerPoint object model. Related Links Microsoft Office Developer Center Accessibility Features in the Microsoft Office System Document Conventions in Office Developer Documentation Microsoft.com Privacy Statement 也许有帮助。
kingxie403 2014-03-26
  • 打赏
  • 举报
回复
引用 19 楼 xuddk727 的回复:
没看明白你是什么需求,请先简单描述下,比如是外部控制PPT或者什么其他需求
就是将PPT程序放在一个窗口内播放,幻灯片播放时外部调控上下页,而不是全屏播放
许文君 2014-03-26
  • 打赏
  • 举报
回复
没看明白你是什么需求,请先简单描述下,比如是外部控制PPT或者什么其他需求
kingxie403 2014-03-26
  • 打赏
  • 举报
回复
看来此贴是结不了啊。。。。
kingxie403 2014-03-26
  • 打赏
  • 举报
回复
唉,C++都不怎么熟,VBA就更难了
derekrose 2014-03-25
  • 打赏
  • 举报
回复
delphi??..
黑泡泡选手 2014-03-24
  • 打赏
  • 举报
回复
引用 13 楼 kingxie403 的回复:
这个app是??

COleDispatchDriver app = NULL; // app is the PowerPoint _Application object
COleDispatchDriver Presentation = NULL;
kingxie403 2014-03-24
  • 打赏
  • 举报
回复
这个app是??
江湖的传说 2014-03-24
  • 打赏
  • 举报
回复
引用 9 楼 kingxie403 的回复:
[quote=引用 7 楼 u013702063 的回复:] 报什么错 ?
那个代码 你试过吗?没报错吗? [/quote] 木有试过 是不是缺少组件 ?重新安装下 Visual Basic for Applications ERROR: [EOleException]: Unspecified error.
黑泡泡选手 2014-03-24
  • 打赏
  • 举报
回复
上面的使用例子有错误,应该改为:

if (Init())
{
    New( GetSafeHwnd() );

    Open(_T("D:\\1.ppt"));

    Exit();
}
黑泡泡选手 2014-03-24
  • 打赏
  • 举报
回复

BOOL Init()
{
	// Start PowerPoint and get Application object...
	return app.CreateDispatch(_T("Powerpoint.Application"));
}

void New(HWND hParent)
{
	// Make PowerPoint visible and display a message
	long nNewValue = TRUE;
	static BYTE parms[] = VTS_I4 ;
	app.InvokeHelper(0x7ee, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, nNewValue);
	TRACE("PowerPoint is Running!\n");

	if (NULL == hParent)
		return;

	CString result;
	app.InvokeHelper(0x7d9, DISPATCH_PROPERTYGET, VT_BSTR, (void *)&result, NULL);

	hPPTWnd = ::FindWindow(NULL, result);
	if (NULL == hPPTWnd)
		return;

	SetWindowLong(hPPTWnd, GWL_STYLE, GetWindowLong(hPPTWnd, GWL_STYLE)-WS_POPUP+WS_CHILD-WS_CAPTION-WS_BORDER-WS_THICKFRAME);
	::SetParent(hPPTWnd, hParent);		
}

void Open(LPCTSTR sFileName)
{
	app.InvokeHelper(0x7d1, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&Presentations, NULL);

	long ReadOnly = 0;
	long Untitled = 0;
	long WithWindow = 1;

	CString strFileName;
	strFileName.Format(_T("%s"), sFileName);

	static BYTE parms[] = VTS_BSTR VTS_I4 VTS_I4 VTS_I4 ;
	Presentations.InvokeHelper(0x7d5, DISPATCH_METHOD, VT_DISPATCH, (void*)&Presentation, parms, strFileName, ReadOnly, Untitled, WithWindow);
}

LPCTSTR GetCaption()
{
	CString result;
	app.InvokeHelper(0x7d9, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
	return result;
}

void Move(float left, float top, float width, float height)
{
	static BYTE parms[] = VTS_R4 ;
	// left
	app.InvokeHelper(0x7e9, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, left);

	// top
	app.InvokeHelper(0x7ea, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, top);

	// width
	app.InvokeHelper(0x7eb, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, width);

	// height
	app.InvokeHelper(0x7ec, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, height);
}

void Exit()
{
	app.InvokeHelper(0x7e5, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);

	Presentations.ReleaseDispatch();
	Presentation.ReleaseDispatch();
	app.ReleaseDispatch();
}

// 使用例子:
CoInitialize(NULL);

if (Init())
{
	New( GetSafeHwnd() );
}

Open(_T("D:\\1.ppt"));

Exit();
kingxie403 2014-03-24
  • 打赏
  • 举报
回复
引用 7 楼 u013702063 的回复:
报什么错 ?
那个代码 你试过吗?没报错吗?
kingxie403 2014-03-24
  • 打赏
  • 举报
回复
江湖的传说 2014-03-24
  • 打赏
  • 举报
回复
报什么错 ?
kingxie403 2014-03-24
  • 打赏
  • 举报
回复
贴上我写的代码 各位看看哪有问题
void __fastcall TForm3::Button1Click(TObject *Sender) {
	Variant vPowerPoint;
	try {
		vPowerPoint = CreateOleObject("PowerPoint.Application");
	}
	catch (...) {
		ShowMessage("Error...");
	}

	// 使 Powerpoint 界面可视
	vPowerPoint.OlePropertySet("Visible", true);

	// 打开一个剪辑
	String strPptFile = "C:\\Users\\Administrator\\Desktop\\test\\xxf.ppt";
	// 换成你的PPT文件名
	vPowerPoint.OlePropertyGet("Presentations").OleFunction("Open",
		strPptFile.c_str(), false, false, true);
	// 得到幻灯片总数

	int nSlidecounts = vPowerPoint.OlePropertyGet("ActivePresentation")
		.OlePropertyGet("Slides").OlePropertyGet("Count");

	// 放映这个剪辑
	vPowerPoint.OlePropertyGet("ActivePresentation").OlePropertyGet
		("SlideShowSettings").OleFunction("Run");

		//放映下一张幻灯片
	 Variant vSlideShowWin =  vPowerPoint.OlePropertyGet("ActivePresentation").OlePropertyGet("SlideShowWindow");
	  vSlideShowWin.OlePropertyGet("View").OleFunction("Next");

	   //跳到第二页

	   vSlideShowWin.OlePropertyGet("View").OleFunction("GoToSlide",2);
	   //返回上一页
		vSlideShowWin.OlePropertyGet("View").OleFunction("Previous");
		//跳到最后一页
		vSlideShowWin.OlePropertyGet("View").OleFunction("Last");
		vPowerPoint.OleProcedure("Quit");
		vPowerPoint = Unassigned;

}
加载更多回复(8)
5.1 用户需求 普通V带传动是工程使用比较广泛的一种机械传动,主要用于两轴之间距离较远的动力传递。普通V带传动的参数化设计程序涉及到参数选择、 设计计算以及数表和线图处理等问题。 通过本章的学习,一方面, 可提高机械设计数表与线图的处理能力; 另一方面,对计算机辅助机械设计软件的开发全过程也可有初步的了解。 普通V带为无头环形橡胶带,由伸张层(顶胶)、强力层(抗拉体)、 压缩层(底胶)和包布层(胶帆布)组成。 计算机辅助机械设计V带轮设计全文共147页,当前为第1页。 普通V带是标准件,按截面尺寸从小到大分为Y、Z、A、 B、 C、D、E七种型号。需要用户提供的原始数据一般为:传动用途、传递功率、主动轮转速、从动轮转速或传动比、原动机种类、工作机载荷性质、传动位置要求、外廓尺寸等。 用户的需求一般包括:确定普通V带型号,带的基准长度、 根数,传动心距,带轮材料、基准直径、结构型式及尺寸, 计算带的初拉力、 初拉力增量、 作用在轴上的压力,张紧装置, 绘制带轮零件工作图等。 通常,用户提供的原始数据是计算机程序的主要输入参数, 用户的需求是计算机程序的主要输出参数。普通V带传动参数化设计程序的主要输入/输出参数见表5-1。 计算机辅助机械设计V带轮设计全文共147页,当前为第2页。 5.2 系统结构设计 5.2.1 普通V带传动的手工设计过程 1. 普通V带传动的手工设计过程 普通V带传动的手工设计过程一般如图5-1所示。 计算机辅助机械设计V带轮设计全文共147页,当前为第3页。 图5-1 普通V带传动的手工设计过程 计算机辅助机械设计V带轮设计全文共147页,当前为第4页。 2. 普通V带传动手工设计方法与步骤 机械设计软件的最基本功能之一是代替手工设计。因此, 手工设计步骤与设计依据或公式,是软件功能结构与算法设计的基本依据, 计算机求解问题的过程基本是仿照手工设计的步骤与方法进行的。很难想象,软件开发人员在不了解手工设计方法与步骤的情况下,能够独立开发出一套有实用价值的软件。 因此,回顾手工设计的方法与步骤是软件设计之初必须进行的一项基础工作。下面列出普通V带传动手工设计的方法与步骤(见表5-2),以便于读者回顾机械设计的方法与步骤,也有助于阅读理解本章附录列出的普通V带传动设计源程序,有利于机械设计软件开发思路的逐步形成。 计算机辅助机械设计V带轮设计全文共147页,当前为第5页。 【例5-1】 设计由电动机驱动的旋转式水泵所用的普通V带传动。 电动机型号为Y160M-4,其额定功率P=11 kW,转速n1=1460 r/min,水泵轴转速n2=400 r/min,轴间距约为1500 mm,每天工作8小时。 设计过程见表5-3。 计算机辅助机械设计V带轮设计全文共147页,当前为第6页。 5.2.2 软件结构设计 软件结构指软件的各功能模块及其相互间的调用关系。 所谓功能模块,就是实现一定功能的若干语句或函数序列。 比如,VB 6.0应用软件, sub过程(包括事件sub和一般sub过程)、function函数、 独立的bas模块、form窗体都是一个功能模块。bas模块和form模块一般可以包括多个sub和function模块, 是多个sub和function模块的集合。同样,在VF 6.0, procedure、 function都是功能模块。 在VL一个用户自定义函数就是一个功能模块。 计算机辅助机械设计V带轮设计全文共147页,当前为第7页。 开发机械设计软件时,为了处理问题方便,通常把处理某一个数表、 某一个图形的语句或函数序列放在一个模块,而接受用户输入的语句、 输出设计结果的语句或函数等,常放在对象的事件过程。 各种语言都有各自的模块调用方法。比如VB 6.0,用call语句实现sub过程之间的相互调用。但值得注意的是,在可视化语言, 用户只能激发对象, 引发对象的事件过程,比如鼠标单击命令按钮, 引发该命令按钮的click事件过程。 设计软件结构,就是划分程序的功能模块,确定相互之间的调用关系。 如同写文章要先列文章的提纲一样,设计软件要先设计软件的结构。 计算机辅助机械设计V带轮设计全文共147页,当前为第8页。 普通V带传动程序可设置以下功能模块: (1) 原始参数输入主模块(主窗体frmbelt.frm): 它包括主要参数接收模块(接收功率、 转速、 传动比), 工况情况接收模块(接收载荷情况、 启动情况、 每天工作时间)。 这两个模块接收的数据来自原始参数输入窗口, 见图5-2。 计算机辅助机械设计V带轮设计全文共147页,当前为第9页。 图5-2 普通V带传动设计的原始数据输入窗口 计算机辅助机械设计V带轮设计全文共147页,当前为第10页。 (2) 间数据处理主模块(窗

64,636

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧