开发者

Read MainWindowHandle For Process

i tried to read MainWindowHanlde For Acrobat Reader 10 Process so i can SetParent API i tried this

private Process pDocked;
private IntPtr hWndDocked;
pDocked = Process.Start(path, PDFPath);
while (hWndDocked == IntPtr.Zero)
{
    pDocked.WaitForInputIdle(1000);
    pDocked.开发者_C百科Refresh();
    if (pDocked.HasExited)
    {
        return;
    }
    hWndDocked = pDocked.MainWindowHandle;
}

and the result is hWndDocked = 0 even i tried this on acrobat reader 9 and i got the MainWindowHandle but it didn't work on acrobat reader 10

please help And Thanks


I had same issue, and find that when the following properties are true,there is no MainWindowHandle, and if the "main form" have child window, then the MainWindowHandle of process will be the child window handle rather than the expected main window. WEIRD!!! wish I can understand why. but once I find this I solve my problem in another way (in my case I not really need the MainWindowHandle)!

When the following:

public frmMain()
        {
            InitializeComponent();
            this.ShowInTaskbar = false;
            this.ShowIcon = false;
        }

No MainWindowHandle (=0)!!

if you create sub window, in this case the MainWindowHandle of the process will be the handle of frmLogon :

private void frmMain_Load(object sender, EventArgs e)
        {
            frmLogon frm = new frmLogon();
            frm.Show();
        }

Close the frmLogon and the MainWindowHandle of the process back to zero (=0)!!

Hope this info is helpful!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜