<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Center non-modal window on display in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Center-non-modal-window-on-display/m-p/903491#M106246</link>
    <description>&lt;P&gt;you can use &lt;FONT face="courier new,courier"&gt;text&lt;/FONT&gt; as &lt;FONT face="courier new,courier"&gt;Read function()&lt;/FONT&gt; and split the string by using&lt;FONT face="courier new,courier"&gt; words()&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;powershell_code ="
Add-Type -AssemblyName System.Windows.Forms
$primary = [System.Windows.Forms.Screen]::PrimaryScreen
Write-Output $primary.Bounds.Width
Write-Output $primary.Bounds.Height
";
        

result = Run Program(
	Executable( "powershell.exe" ),
	Options( {"-Command", powershell_code} ),
	Read Function( "text" )
);
        
{w, h} = Transform Each( {str}, Words( result, "\!n\!r" ), Num( str ) );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_0-1758750202886.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/83404iC8FD5E324955B387/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hogi_0-1758750202886.png" alt="hogi_0-1758750202886.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 24 Sep 2025 21:43:33 GMT</pubDate>
    <dc:creator>hogi</dc:creator>
    <dc:date>2025-09-24T21:43:33Z</dc:date>
    <item>
      <title>Center non-modal window on display</title>
      <link>https://community.jmp.com/t5/Discussions/Center-non-modal-window-on-display/m-p/486740#M73058</link>
      <description>&lt;P&gt;Hi, I am trying to find the fastest way to move a window to the center of the users display.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Modal windows automatically are centered on the screen, so I know that JMP is somehow able to tell where to put a window, but I have only found some relatively slow workarounds to doing this with non-modal windows. Below is the jsl script I am currently using to determine the screen size and center a new window.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Is there a faster way? Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;win2 = NewWindow("Test Window");
winSize = win2  &amp;lt;&amp;lt; GetWindowSize();
win2  &amp;lt;&amp;lt; ShowWindow(0);

testwin = NewWindow("test", &amp;lt;&amp;lt; ShowWindow(0));
testwin &amp;lt;&amp;lt; Maximize Window(1);
dispsize = testwin &amp;lt;&amp;lt; Get Window Size;
testwin &amp;lt;&amp;lt; CloseWindow();


win2 &amp;lt;&amp;lt; MoveWindow(dispsize[1]/2 - winsize[1]/2, dispsize[2]/2 - winsize[2]/2);
win2  &amp;lt;&amp;lt; ShowWindow(1);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Jun 2023 16:59:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Center-non-modal-window-on-display/m-p/486740#M73058</guid>
      <dc:creator>mringqui</dc:creator>
      <dc:date>2023-06-09T16:59:09Z</dc:date>
    </item>
    <item>
      <title>Re: Center non-modal window on display</title>
      <link>https://community.jmp.com/t5/Discussions/Center-non-modal-window-on-display/m-p/486770#M73061</link>
      <description>&lt;P&gt;Your method is the method I normally use.&lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2022 15:29:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Center-non-modal-window-on-display/m-p/486770#M73061</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-05-13T15:29:09Z</dc:date>
    </item>
    <item>
      <title>Re: Center non-modal window on display</title>
      <link>https://community.jmp.com/t5/Discussions/Center-non-modal-window-on-display/m-p/486860#M73068</link>
      <description>&lt;P&gt;In my experience the &lt;CODE class=" language-jsl"&gt;&amp;lt;&amp;lt;Get Window Size&lt;/CODE&gt; method is not reliable.&amp;nbsp; The issue is that &lt;CODE class=" language-jsl"&gt;&amp;lt;&amp;lt;Get Window Size&lt;/CODE&gt; does not return physical pixels but logical pixels (affected by Windows display scaling), while &lt;CODE class=" language-jsl"&gt;&amp;lt;&amp;lt;Move Window( x, y )&lt;/CODE&gt; uses physical pixels.&amp;nbsp; Also, JMP in general and &lt;CODE class=" language-jsl"&gt;&amp;lt;&amp;lt;Get Window Size&lt;/CODE&gt; in specific does not update when the Windows display scaling changes (if a user starts JMP on a laptop and later hooks up a monitor, for instance).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I run the following PowerShell script from JMP to get the actual screen resolution and use this info to place windows as appropriate (you'll have to launch powershell with &lt;CODE&gt;-ExecutionPolicy Bypass&lt;/CODE&gt;:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Add-Type @"
using System;
using System.Runtime.InteropServices;
public class PInvoke {
    [DllImport("user32.dll")] public static extern IntPtr GetDC(IntPtr hwnd);
    [DllImport("gdi32.dll")] public static extern int GetDeviceCaps(IntPtr hdc, int nIndex);
}
"@
$hdc = [PInvoke]::GetDC([IntPtr]::Zero)
[PInvoke]::GetDeviceCaps($hdc, 118) # width
[PInvoke]::GetDeviceCaps($hdc, 117) # height&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2022 23:47:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Center-non-modal-window-on-display/m-p/486860#M73068</guid>
      <dc:creator>ErraticAttack</dc:creator>
      <dc:date>2022-05-13T23:47:30Z</dc:date>
    </item>
    <item>
      <title>Re: Center non-modal window on display</title>
      <link>https://community.jmp.com/t5/Discussions/Center-non-modal-window-on-display/m-p/487312#M73107</link>
      <description>&lt;P&gt;This is the kind of hocus pocus I was looking for haha. Thanks Jim and Jordan! I will try out both options and see which is faster and/or more reliable&lt;/P&gt;</description>
      <pubDate>Mon, 16 May 2022 20:17:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Center-non-modal-window-on-display/m-p/487312#M73107</guid>
      <dc:creator>mringqui</dc:creator>
      <dc:date>2022-05-16T20:17:39Z</dc:date>
    </item>
    <item>
      <title>Re: Center non-modal window on display</title>
      <link>https://community.jmp.com/t5/Discussions/Center-non-modal-window-on-display/m-p/903308#M106232</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank&amp;nbsp; you very much for your tip ! It's been years, but it's still relevant: how do you transfer this information from PowerShell to JMP (about screen size) using Run Program?&lt;/P&gt;</description>
      <pubDate>Wed, 24 Sep 2025 10:18:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Center-non-modal-window-on-display/m-p/903308#M106232</guid>
      <dc:creator>SophieCuvillier</dc:creator>
      <dc:date>2025-09-24T10:18:00Z</dc:date>
    </item>
    <item>
      <title>Re: Center non-modal window on display</title>
      <link>https://community.jmp.com/t5/Discussions/Center-non-modal-window-on-display/m-p/903491#M106246</link>
      <description>&lt;P&gt;you can use &lt;FONT face="courier new,courier"&gt;text&lt;/FONT&gt; as &lt;FONT face="courier new,courier"&gt;Read function()&lt;/FONT&gt; and split the string by using&lt;FONT face="courier new,courier"&gt; words()&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;powershell_code ="
Add-Type -AssemblyName System.Windows.Forms
$primary = [System.Windows.Forms.Screen]::PrimaryScreen
Write-Output $primary.Bounds.Width
Write-Output $primary.Bounds.Height
";
        

result = Run Program(
	Executable( "powershell.exe" ),
	Options( {"-Command", powershell_code} ),
	Read Function( "text" )
);
        
{w, h} = Transform Each( {str}, Words( result, "\!n\!r" ), Num( str ) );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_0-1758750202886.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/83404iC8FD5E324955B387/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hogi_0-1758750202886.png" alt="hogi_0-1758750202886.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Sep 2025 21:43:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Center-non-modal-window-on-display/m-p/903491#M106246</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2025-09-24T21:43:33Z</dc:date>
    </item>
  </channel>
</rss>

