tags:

views:

47

answers:

1

I have created an application that looks like a news ticker. It suppose to run on a machine which has PPT slide show running on it always. I have set this.TopMost = true

So the ticker application overlaps the PPT. But I want that the ticker application as well as the ppt are seen together. This is possible only if I can cascade the applications.

Can someone please help?

A: 

Don't use TopMost = true, instead set window boundary for both applications. The trick is only how to set windows rectangle for PPT application.

using System;
using System.Runtime.InteropServices;
using System.Diagnostics;

[StructLayout(LayoutKind.Sequential)]
struct RECT
{
    public int left;
    public int top;
    public int right;
    public int bottom;
}

class WindowHelper
{
    [DllImport("user32.dll")]
    static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth,
    int nHeight, bool bRepaint);

    static void SetWindowRect()
    {
        Process p = new Process();
        p.StartInfo.FileName = "PPT.exe";
        p.Start();
        p.WaitForInputIdle();
        IntPtr hWnd = p.MainWindowHandle;
        int width = 300;
        int height = 600;
        // you can use Screen.PrimaryScreen.WorkingArea to set proper size
        MoveWindow(hWnd, 0, 0, width, height, true);
    }
}
volody
Actually for Power point slide show this does not seem to work. It works fine if you are tring to resize an Excel sheet. Since my application does not start the PPT process what I did is this. I try to get the handle to Powerpoint application using Process[] p = Process.GetProcessesByName("POWERPNT")Then as you have explained. I also tried to get the rect of the application but I got lot of negative values. For that I did [DllImport("user32.dll")]internal static extern bool GetWindowRect(IntPtr hWnd, ref RECT rct)Any idea why its not working for power point slide show??
Anand
It could be because power point application in slide show mode does not have a visible window title bar, can you configure that
volody
Thanks a ton. It worked. I had to select an option "Browsed by an Individual(Window)" in the slide show setup window and it worked.
Anand