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

kingxie403 2014-03-21 10:40:28
我用的是TOleContainer控件。。。但是搞不出来,不知各位有什么好的方法。帮忙解决一下,谢谢。
PPT不是全屏播放的,放在一个窗体中。。。。。。。
...全文
922 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)

64,660

社区成员

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

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