使用 WinAPI 在 WPF 应用程序中调整 Powerpoint Viewer 的大小

发布于 2024-12-24 20:21:06 字数 789 浏览 4 评论 0原文

我正在尝试将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

孤独难免 2024-12-31 20:21:06

为什么不尝试 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.

旧街凉风 2024-12-31 20:21:06

我已成功将 PowerPoint Viewer 嵌入到我的 C++ 应用程序中,但存在以下差异:

  • 我不传递 /S 参数,仅传递 .pptx 文件路径。
  • 然后我遍历它的 HWND 树,PPTFrameClass -> MDIClient -> mdiClass -> paneClassDC
  • 我将 paneClassDC 子窗口设置为我的子窗口,并隐藏主窗口
  • 并使用 BeginDeferWindowPos、DeferWindowPos 和 EndDeferWindowPos 调整其大小

I'm successfully embedding PowerPoint Viewer into my C++ application with following differences:

  • I don't pass /S argument, only the .pptx file path.
  • Then I walk its HWND tree, PPTFrameClass -> MDIClient -> mdiClass -> paneClassDC
  • I set the paneClassDC child window as my child, and hide the main window
  • And resize it using BeginDeferWindowPos, DeferWindowPos and EndDeferWindowPos
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文