Little request for catapult

By TheKid

Paladin (832)

TheKid의 아바타

22-11-2018, 10:10

I have a request for the next release of catapult for windows.
When you are working with 2 screens (monitors), can you make the openmsx dialog open on the same screen as where the
catapult dialog is situated? (start position = center parent).

Currently the openmsx dialog is always openend on the primary screen which is very anoying.

Thanx in advange,

The Kid

Login or 등록 to post comments

By Manuel

Ascended (15824)

Manuel의 아바타

22-11-2018, 22:51

That sounds like a good idea, but I don't know how to do that...

By Pencioner

Paladin (993)

Pencioner의 아바타

22-11-2018, 23:15

not sure about win7 or win10 but for winXP you has no control on which screen dialogs will appear iirc

By Meits

Scribe (5651)

Meits의 아바타

23-11-2018, 00:14

i'm not sure it always starts on the main screen. I've seen it pop up on any of 'em.

By TheKid

Paladin (832)

TheKid의 아바타

23-11-2018, 08:21

I don't know in which language catapult is written, but in c# there are ways.
To indentify on which screen you what to show openmsx, you can "ask" catapult on which screen it is shown. Knowing that, you can use that info the open *or move" the openmsx dialog to that same screen.

https://stackoverflow.com/questions/3750113/launch-an-applic...

By Manuel

Ascended (15824)

Manuel의 아바타

23-11-2018, 09:35

As you can see in the source code, it's written in C++. As none of the developers is on Windows, please submit a patch.

The code where openMSX is launched for Windows is here: https://github.com/openMSX/wxcatapult/blob/master/src/openMS...

By TheKid

Paladin (832)

TheKid의 아바타

23-11-2018, 11:32

Okay, Well I am a C# developer and not a c++ developer. I have made a test program and managed to open the openmsx console app dialog on the same screen as my testprogram dialog is on. But the console app opens the openmsx dialog, and that one is being displayed on the primary screen.

So there are 2 things that need to be done
1) Let the openmsx dialog open on the same screen the openmsx console app dialog is on
2) Change the way catapult calls upon openmsx, so the openmsx console app dialog opens on the same screen as catapult is.

Next week I will discus this with a collegue who knows c++, maybe he can help.
To be continued.

By Manuel

Ascended (15824)

Manuel의 아바타

23-11-2018, 12:45

Okay, please keep us posted.

By TheKid

Paladin (832)

TheKid의 아바타

26-11-2018, 12:31

Unfortunately my collegue could not help me further.
As far as I can see there are 2 approaches.
1) Handle on which screen openmsx.exe is openend in openmsx itself. (maybe an extra command line argument)
2) Change Catapult to open openmsx.exe on the same screen

Maybe someone else reading this with knowledge of c++ can help solve this.

I have tried to solve option 2. The C# code I have sofar. Problem is when starting a process, a dos prompt (console app) is opened to start openmsx.exe. The dos prompt is opened at the correct screen, but openmsx.exe isn't.

Put these both these lines at the start of the class:

[DllImport("user32.dll", EntryPoint = "SetWindowPos")]
Public static extern IntPtr SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int Y, int cx, int cy, int wFlags);

In the code of the Start button put this:

//start openmsx.exe (or process)

Process openmsxproc = Process.Start(@"d:\OpenMSX\openmsx.exe");
if (openmsxproc == null) return;
IntPtr handle = openmsxproc.MainWindowHandle;

// Get the handle of the process openmsx.exe

Process[] processes = Process.GetProcesses();
foreach (Process process in processes)
{
Debug.Print("Process Name: {0} ", process.ProcessName);
if (process.ProcessName != "openmsx") continue;
handle = process.MainWindowHandle;
break;
}

try
{
// use the openmsx handle to specify where it needs to be shown
// For top,left,width,height I use 'this' (meaning the catapult dialog

SetWindowPos(handle, 0, this.Left, this.Top, this.Width, this.Height, 0);

// another approach is to use the screen properties, but you still need 'this'
// Screen screen = Screen.FromControl(this);
// Rectangle monitor = screen.WorkingArea;
// SetWindowPos(handle, 0, monitor.Left, monitor.Top, monitor.Width, monitor.Height, 0);

}
catch (Exception ex)
{
Debug.Print(ex.Message);
}

By FiXato

Scribe (1520)

FiXato의 아바타

26-11-2018, 16:37

By TheKid

Paladin (832)

TheKid의 아바타

26-11-2018, 19:02

Nice trick FIXato, but not quite what I was looking for Smile