<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comments on: Working with non-standard DPI displays	</title>
	<atom:link href="https://undocumentedmatlab.com/articles/working-with-non-standard-dpi-displays/feed" rel="self" type="application/rss+xml" />
	<link>https://undocumentedmatlab.com/articles/working-with-non-standard-dpi-displays?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=working-with-non-standard-dpi-displays</link>
	<description>Professional Matlab consulting, development and training</description>
	<lastBuildDate>Tue, 29 Nov 2016 19:28:44 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.3</generator>
	<item>
		<title>
		By: Yaroslav		</title>
		<link>https://undocumentedmatlab.com/articles/working-with-non-standard-dpi-displays#comment-394702</link>

		<dc:creator><![CDATA[Yaroslav]]></dc:creator>
		<pubDate>Tue, 29 Nov 2016 19:28:44 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=6736#comment-394702</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/working-with-non-standard-dpi-displays#comment-394553&quot;&gt;Yaroslav&lt;/a&gt;.

Hi @Marco,

Thank you for your comment. Unfortunately, your solution tells me only how many monitors I &lt;i&gt;can have&lt;/i&gt;. What I need is to know how many monitors I &lt;i&gt;currently have&lt;/i&gt;.

To be more precise, &lt;code&gt;MonitorPositions&lt;/code&gt; tells me how many monitors I &lt;i&gt;had&lt;/i&gt; at the time of Matlab&#039;s startup. It does not change if I attach a monitor after startup. This is the behaviour in my Windows 8.1 laptop.

I can do a little trick to circumvent this problem. By using the &lt;code&gt;PointerLocation&lt;/code&gt;, I can check on which monitor the pointer is. For example 
&lt;pre lang=&quot;matlab&quot;&gt;
% get root handle
hRoot = groot;
% check if (a) there are at least two monitors
%          (b) pointer&#039;s x location is larger than 2nd monitor&#039;s x0 position
if     size(hRoot.MonitorPositions,1) &gt;= 2 ...
    &amp;&amp; hRoot.PointerLocation(1) &gt; hRoot.MonitorPositions(2,1)
    % put figure on the second monitor
else
    % put figure on the first monitor
end
&lt;/pre&gt;
However, as you can see, it assumes you have control over the cursor&#039;s position during execution. I wish there was an option to tell how many &lt;i&gt;active&lt;/i&gt; monitors are there.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/working-with-non-standard-dpi-displays#comment-394553">Yaroslav</a>.</p>
<p>Hi @Marco,</p>
<p>Thank you for your comment. Unfortunately, your solution tells me only how many monitors I <i>can have</i>. What I need is to know how many monitors I <i>currently have</i>.</p>
<p>To be more precise, <code>MonitorPositions</code> tells me how many monitors I <i>had</i> at the time of Matlab&#8217;s startup. It does not change if I attach a monitor after startup. This is the behaviour in my Windows 8.1 laptop.</p>
<p>I can do a little trick to circumvent this problem. By using the <code>PointerLocation</code>, I can check on which monitor the pointer is. For example </p>
<pre lang="matlab">
% get root handle
hRoot = groot;
% check if (a) there are at least two monitors
%          (b) pointer's x location is larger than 2nd monitor's x0 position
if     size(hRoot.MonitorPositions,1) >= 2 ...
    &#038;& hRoot.PointerLocation(1) > hRoot.MonitorPositions(2,1)
    % put figure on the second monitor
else
    % put figure on the first monitor
end
</pre>
<p>However, as you can see, it assumes you have control over the cursor&#8217;s position during execution. I wish there was an option to tell how many <i>active</i> monitors are there.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: marco		</title>
		<link>https://undocumentedmatlab.com/articles/working-with-non-standard-dpi-displays#comment-394677</link>

		<dc:creator><![CDATA[marco]]></dc:creator>
		<pubDate>Tue, 29 Nov 2016 14:12:53 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=6736#comment-394677</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/working-with-non-standard-dpi-displays#comment-394553&quot;&gt;Yaroslav&lt;/a&gt;.

Hi,
maybe this can be helpful:
&lt;pre lang=&quot;matlab&quot;&gt;
&gt;&gt; monitorPos = get(0,&#039;MonitorPositions&#039;)
monitorPos =
           1           1        1600         900
        1601           1        3200         900
&lt;/pre&gt;

then you can play with &#039;pixels&#039; positions]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/working-with-non-standard-dpi-displays#comment-394553">Yaroslav</a>.</p>
<p>Hi,<br />
maybe this can be helpful:</p>
<pre lang="matlab">
>> monitorPos = get(0,'MonitorPositions')
monitorPos =
           1           1        1600         900
        1601           1        3200         900
</pre>
<p>then you can play with &#8216;pixels&#8217; positions</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yaroslav		</title>
		<link>https://undocumentedmatlab.com/articles/working-with-non-standard-dpi-displays#comment-394553</link>

		<dc:creator><![CDATA[Yaroslav]]></dc:creator>
		<pubDate>Mon, 28 Nov 2016 08:59:12 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=6736#comment-394553</guid>

					<description><![CDATA[Hi Yair,

Suppose I have two monitors. How can I tell a figure to appear on the &lt;i&gt;secondary one&lt;/i&gt;, if it exists? I can do something like&lt;pre lang=&quot;matlab&quot;&gt;hFig = figure(&#039;Units&#039;,&#039;normalized&#039;,&#039;Position&#039;,[1.10 0.10 0.80 0.70]);&lt;/pre&gt; but it doesn&#039;t tell me whether the second screen exists or not (if not, it will effectively hide the figure).

Best regards]]></description>
			<content:encoded><![CDATA[<p>Hi Yair,</p>
<p>Suppose I have two monitors. How can I tell a figure to appear on the <i>secondary one</i>, if it exists? I can do something like</p>
<pre lang="matlab">hFig = figure('Units','normalized','Position',[1.10 0.10 0.80 0.70]);</pre>
<p> but it doesn&#8217;t tell me whether the second screen exists or not (if not, it will effectively hide the figure).</p>
<p>Best regards</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Matthias Kirchhoff		</title>
		<link>https://undocumentedmatlab.com/articles/working-with-non-standard-dpi-displays#comment-394173</link>

		<dc:creator><![CDATA[Matthias Kirchhoff]]></dc:creator>
		<pubDate>Thu, 24 Nov 2016 14:09:11 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=6736#comment-394173</guid>

					<description><![CDATA[As for me the solution using &lt;code&gt;java.awt.Toolkit.getDefaultToolkit.getScreenSize&lt;/code&gt; does not work correctly when using more than one monitor.
Better use:
&lt;pre lang=&quot;matlab&quot;&gt;
ge = javaObjectEDT(java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment());
gs = ge.getScreenDevices();
jmonitorposition = [];
if ~isempty(gs)
  for iRun_ = 1:size(gs,1)
     dm = gs(iRun_).getDisplayMode();
     jmonitorposition(iRun_,:) = [1 1 dm.getWidth dm.getHeight];
  end
end
&lt;/pre&gt;
Best regards
Matthias]]></description>
			<content:encoded><![CDATA[<p>As for me the solution using <code>java.awt.Toolkit.getDefaultToolkit.getScreenSize</code> does not work correctly when using more than one monitor.<br />
Better use:</p>
<pre lang="matlab">
ge = javaObjectEDT(java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment());
gs = ge.getScreenDevices();
jmonitorposition = [];
if ~isempty(gs)
  for iRun_ = 1:size(gs,1)
     dm = gs(iRun_).getDisplayMode();
     jmonitorposition(iRun_,:) = [1 1 dm.getWidth dm.getHeight];
  end
end
</pre>
<p>Best regards<br />
Matthias</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/working-with-non-standard-dpi-displays#comment-393560</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Thu, 17 Nov 2016 12:47:37 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=6736#comment-393560</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/working-with-non-standard-dpi-displays#comment-393555&quot;&gt;Thomas Pieper&lt;/a&gt;.

@Thomas - the problem with your .NET solution is that it only works on Windows; the Java-based solution in my post works on all Matlab platforms, including Mac and Linux.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/working-with-non-standard-dpi-displays#comment-393555">Thomas Pieper</a>.</p>
<p>@Thomas &#8211; the problem with your .NET solution is that it only works on Windows; the Java-based solution in my post works on all Matlab platforms, including Mac and Linux.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Thomas Pieper		</title>
		<link>https://undocumentedmatlab.com/articles/working-with-non-standard-dpi-displays#comment-393555</link>

		<dc:creator><![CDATA[Thomas Pieper]]></dc:creator>
		<pubDate>Thu, 17 Nov 2016 12:17:13 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=6736#comment-393555</guid>

					<description><![CDATA[If you feel more as a Microsoft family member you might want to use .NET commands. Try
&lt;pre lang=&quot;matlab&quot;&gt;
NET.addAssembly(&#039;System.Windows.Forms&#039;);
System.Windows.Forms.Screen.PrimaryScreen.Bounds
&lt;/pre&gt;
or
&lt;pre lang=&quot;matlab&quot;&gt;System.Windows.Forms.SystemInformation.PrimaryMonitorSize&lt;/pre&gt;

and you get something like
&lt;pre lang=&quot;matlab&quot;&gt;
ans = 

  System.Drawing.Rectangle
  Package: System.Drawing

  Properties:
    Location: [1x1 System.Drawing.Point]
        Size: [1x1 System.Drawing.Size]
           X: 0
           Y: 0
       Width: 1920
      Height: 1080
        Left: 0
         Top: 0
       Right: 1920
      Bottom: 1080
     IsEmpty: 0
       Empty: [1x1 System.Drawing.Rectangle]
&lt;/pre&gt;

Greetings,

Thomas]]></description>
			<content:encoded><![CDATA[<p>If you feel more as a Microsoft family member you might want to use .NET commands. Try</p>
<pre lang="matlab">
NET.addAssembly('System.Windows.Forms');
System.Windows.Forms.Screen.PrimaryScreen.Bounds
</pre>
<p>or</p>
<pre lang="matlab">System.Windows.Forms.SystemInformation.PrimaryMonitorSize</pre>
<p>and you get something like</p>
<pre lang="matlab">
ans = 

  System.Drawing.Rectangle
  Package: System.Drawing

  Properties:
    Location: [1x1 System.Drawing.Point]
        Size: [1x1 System.Drawing.Size]
           X: 0
           Y: 0
       Width: 1920
      Height: 1080
        Left: 0
         Top: 0
       Right: 1920
      Bottom: 1080
     IsEmpty: 0
       Empty: [1x1 System.Drawing.Rectangle]
</pre>
<p>Greetings,</p>
<p>Thomas</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
