使用 WinAPI 在 WPF 应用程序中调整 Powerpoint Viewer 的大小
我正在尝试将 PowerPoint Viewer 2007 嵌入到我的 WPF 应用程序中。我设法使用 Process 来启动指定文件的查看器,并使用 SetParent 和此类 WinAPI 命令将其放入我的应用程序窗口中。但我的应用程序窗口中的幻灯片总是被部分截断,因为我的应用程序窗口不是全屏,不幸的是 PowerPoint Viewer 总是全屏启动。知道如何调整幻灯片大小,使其在我的窗口中完美显示吗?
到目前为止,这是我的代码。
Process proc = Process.Start(new ProcessStartInfo(){ FileName = "C:\\Program Files\\Microsoft Office\\Office12\\PptView.exe", Arguments="/S" + "\"" + "C:\\Test.ppt" + "\"", WindowStyle=ProcessWindowStyle.Minimized});
System.Threading.Thread.Sleep(1000);
SetParent(proc.MainWindowHandle, myWindowHandle);
SendMessage(proc.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
SetWindowPos(proc.MainWindowHandle, (IntPtr)0, 0, 0, 800, 600, SWP_FRAMECHANGED);
InvalidateRect(myWindowHandle, IntPtr.Zero, false);
希望有人能帮忙。多谢...
I am trying to embed PowerPoint Viewer 2007 in my WPF application. I managed to use a Process to start up the viewer with a file specified and put it in my application window with SetParent and such WinAPI commands. But the slideshow in my application window is always chopped off partially because my application window is not full screen and unfortunately PowerPoint Viewer always starts up fullscreen. Any idea how I can resize the slideshow so that it appears nicely in my window?
So far, here is my code.
Process proc = Process.Start(new ProcessStartInfo(){ FileName = "C:\\Program Files\\Microsoft Office\\Office12\\PptView.exe", Arguments="/S" + "\"" + "C:\\Test.ppt" + "\"", WindowStyle=ProcessWindowStyle.Minimized});
System.Threading.Thread.Sleep(1000);
SetParent(proc.MainWindowHandle, myWindowHandle);
SendMessage(proc.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
SetWindowPos(proc.MainWindowHandle, (IntPtr)0, 0, 0, 800, 600, SWP_FRAMECHANGED);
InvalidateRect(myWindowHandle, IntPtr.Zero, false);
Hope someone can help. Thanks a lot...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为什么不尝试 MoveWindow(proc.MainWindowHandle, 0, 0, 800, 600, true); ?我在做类似的事情时遇到了问题,但使用的是 Word。 SetWindowPos 没有将屏幕定位在我想要的位置。
Why don't you try MoveWindow(proc.MainWindowHandle, 0, 0, 800, 600, true);? I had issues doing something similar to this, but with Word. SetWindowPos didn't position the screen where I wanted it.
我已成功将 PowerPoint Viewer 嵌入到我的 C++ 应用程序中,但存在以下差异:
/S
参数,仅传递 .pptx 文件路径。PPTFrameClass
->MDIClient
->mdiClass
->paneClassDC
paneClassDC
子窗口设置为我的子窗口,并隐藏主窗口I'm successfully embedding PowerPoint Viewer into my C++ application with following differences:
/S
argument, only the .pptx file path.PPTFrameClass
->MDIClient
->mdiClass
->paneClassDC
paneClassDC
child window as my child, and hide the main window