Click here to Skip to main content
15,887,449 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
My first problem is, I want the E:\GG\dosya3.pdf file in the relevant directory to be displayed on multiple screens (secondary screen) when the button is pressed. It appears on the primary screen. There is no display on the secondary screen.

My second problem is that I want to get an image on the primary screen when a button is pressed, on the second screen when a button is pressed, and on both screens (primary and secondary) when a button is pressed. I would be happy if you help.

What I have tried:

C#
private void button8_Click(object sender, EventArgs e)
{
	Process p = new Process();
	p.EnableRaisingEvents = true;
	p.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
	p.StartInfo.CreateNoWindow = true;
	p.StartInfo.FileName = @"C:\Program Files (x86)\Foxit Software\
        Foxit PDF Reader\FoxitPDFReader.exe";
	p.StartInfo.Arguments = @"E:\GG\dosya3.pdf";
	p.StartInfo.UseShellExecute = false;
	p.Start();
	p.WaitForInputIdle();
	Rectangle secondmonitor = Screen.AllScreens[1].WorkingArea;
	SetWindowPos(p.MainWindowHandle, 0,
                 secondmonitor.Left, secondmonitor.Top,
                 secondmonitor.Width, secondmonitor.Height, 0);
}
Posted
Updated 4-Feb-24 0:55am
v2

 
Share this answer
 
Comments
Member 16193030 4-Feb-24 8:35am    
Thank you
If I copy'n'paste your code into my app (after changing the app to Notepad as I don't have your PDF reader installed)and use the debugger, it's immediately obvious that the call to WaitForInputIdle does not return until Notepad is closed. So the code never tries to move it.

If I replace that call with Thread.Sleep, it then tries to move it, but the MainWindowHandle is a zero - indicating the process does not have a window, or it is hidden - this happens when an app opens a sub process to do each display while keeping a "common" code hidden.

I'd use the debugger and see what the PDF reader process is actually giving you: you may have to find another way to get access to the window handle in order to move it - but I can't do that for you!
 
Share this answer
 
Comments
Member 16193030 4-Feb-24 8:34am    
Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900