<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Problem mit MSDN Beispiel: Positioning Objects on a Multiple Display Setup]]></title><description><![CDATA[<p>Hallo ich habe folgenden Code,<br />
in meine Testapplication eingebaut.<br />
Bin leider noch kein Vollprofi, vielleicht könnt ihr mir helfen. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":-("
      alt="😞"
    /></p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &quot;multimon.h&quot;    

#define MONITOR_CENTER     0x0001        // center rect to monitor
#define MONITOR_CLIP     0x0000        // clip rect to monitor
#define MONITOR_WORKAREA 0x0002        // use monitor work area
#define MONITOR_AREA     0x0000        // use monitor entire area

//
//  ClipOrCenterRectToMonitor
//
//  The most common problem apps have when running on a
//  multimonitor system is that they &quot;clip&quot; or &quot;pin&quot; windows
//  based on the SM_CXSCREEN and SM_CYSCREEN system metrics.
//  Because of app compatibility reasons these system metrics
//  return the size of the primary monitor.
//
//  This shows how you use the multi-monitor functions
//  to do the same thing.
//
void ClipOrCenterRectToMonitor(LPRECT prc, UINT flags)
{
    HMONITOR hMonitor;
    MONITORINFO mi;
    RECT        rc;
    int         w = prc-&gt;right  - prc-&gt;left;
    int         h = prc-&gt;bottom - prc-&gt;top;

    //
    // get the nearest monitor to the passed rect.
    //
    hMonitor = MonitorFromRect(prc, MONITOR_DEFAULTTONEAREST);

    //
    // get the work area or entire monitor rect.
    //
    mi.cbSize = sizeof(mi);
    GetMonitorInfo(hMonitor, &amp;mi);

    if (flags &amp; MONITOR_WORKAREA)
        rc = mi.rcWork;
    else
        rc = mi.rcMonitor;

    //
    // center or clip the passed rect to the monitor rect
    //
    if (flags &amp; MONITOR_CENTER)
    {
        prc-&gt;left   = rc.left + (rc.right  - rc.left - w) / 2;
        prc-&gt;top    = rc.top  + (rc.bottom - rc.top  - h) / 2;
        prc-&gt;right  = prc-&gt;left + w;
        prc-&gt;bottom = prc-&gt;top  + h;
    }
    else
    {
        prc-&gt;left   = max(rc.left, min(rc.right-w,  prc-&gt;left));
        prc-&gt;top    = max(rc.top,  min(rc.bottom-h, prc-&gt;top));
        prc-&gt;right  = prc-&gt;left + w;
        prc-&gt;bottom = prc-&gt;top  + h;
    }
}

void ClipOrCenterWindowToMonitor(HWND hwnd, UINT flags)
{
    RECT rc;
    GetWindowRect(hwnd, &amp;rc);
    ClipOrCenterRectToMonitor(&amp;rc, flags);
    SetWindowPos(hwnd, NULL, rc.left, rc.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
}
</code></pre>
<p>und möchte ihn bei mir implementieren, leider bekomme ich immer diese Fehlermeldungen:</p>
<pre><code>diagtestDlg.obj : error LNK2001: unresolved external symbol _xGetMonitorInfo@8
diagtestDlg.obj : error LNK2001: unresolved external symbol _xMonitorFromRect@8
Debug/diagtest.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/140681/problem-mit-msdn-beispiel-positioning-objects-on-a-multiple-display-setup</link><generator>RSS for Node</generator><lastBuildDate>Mon, 13 Jul 2026 14:44:38 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/140681.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 16 Mar 2006 14:56:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem mit MSDN Beispiel: Positioning Objects on a Multiple Display Setup on Fri, 17 Mar 2006 14:18:30 GMT]]></title><description><![CDATA[<p>Hallo ich habe folgenden Code,<br />
in meine Testapplication eingebaut.<br />
Bin leider noch kein Vollprofi, vielleicht könnt ihr mir helfen. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":-("
      alt="😞"
    /></p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &quot;multimon.h&quot;    

#define MONITOR_CENTER     0x0001        // center rect to monitor
#define MONITOR_CLIP     0x0000        // clip rect to monitor
#define MONITOR_WORKAREA 0x0002        // use monitor work area
#define MONITOR_AREA     0x0000        // use monitor entire area

//
//  ClipOrCenterRectToMonitor
//
//  The most common problem apps have when running on a
//  multimonitor system is that they &quot;clip&quot; or &quot;pin&quot; windows
//  based on the SM_CXSCREEN and SM_CYSCREEN system metrics.
//  Because of app compatibility reasons these system metrics
//  return the size of the primary monitor.
//
//  This shows how you use the multi-monitor functions
//  to do the same thing.
//
void ClipOrCenterRectToMonitor(LPRECT prc, UINT flags)
{
    HMONITOR hMonitor;
    MONITORINFO mi;
    RECT        rc;
    int         w = prc-&gt;right  - prc-&gt;left;
    int         h = prc-&gt;bottom - prc-&gt;top;

    //
    // get the nearest monitor to the passed rect.
    //
    hMonitor = MonitorFromRect(prc, MONITOR_DEFAULTTONEAREST);

    //
    // get the work area or entire monitor rect.
    //
    mi.cbSize = sizeof(mi);
    GetMonitorInfo(hMonitor, &amp;mi);

    if (flags &amp; MONITOR_WORKAREA)
        rc = mi.rcWork;
    else
        rc = mi.rcMonitor;

    //
    // center or clip the passed rect to the monitor rect
    //
    if (flags &amp; MONITOR_CENTER)
    {
        prc-&gt;left   = rc.left + (rc.right  - rc.left - w) / 2;
        prc-&gt;top    = rc.top  + (rc.bottom - rc.top  - h) / 2;
        prc-&gt;right  = prc-&gt;left + w;
        prc-&gt;bottom = prc-&gt;top  + h;
    }
    else
    {
        prc-&gt;left   = max(rc.left, min(rc.right-w,  prc-&gt;left));
        prc-&gt;top    = max(rc.top,  min(rc.bottom-h, prc-&gt;top));
        prc-&gt;right  = prc-&gt;left + w;
        prc-&gt;bottom = prc-&gt;top  + h;
    }
}

void ClipOrCenterWindowToMonitor(HWND hwnd, UINT flags)
{
    RECT rc;
    GetWindowRect(hwnd, &amp;rc);
    ClipOrCenterRectToMonitor(&amp;rc, flags);
    SetWindowPos(hwnd, NULL, rc.left, rc.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
}
</code></pre>
<p>und möchte ihn bei mir implementieren, leider bekomme ich immer diese Fehlermeldungen:</p>
<pre><code>diagtestDlg.obj : error LNK2001: unresolved external symbol _xGetMonitorInfo@8
diagtestDlg.obj : error LNK2001: unresolved external symbol _xMonitorFromRect@8
Debug/diagtest.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1017605</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1017605</guid><dc:creator><![CDATA[Dedidadoho]]></dc:creator><pubDate>Fri, 17 Mar 2006 14:18:30 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit MSDN Beispiel: Positioning Objects on a Multiple Display Setup on Thu, 16 Mar 2006 15:13:34 GMT]]></title><description><![CDATA[<p>OK, ich war ein volldepp.<br />
Kann mir vielleicht jmd helfen wie ich einen HAndle auf den Monitor setze ?</p>
<p>HMONITOR hMonitor, // handle to display monitor ?</p>
<p>Danke schonmal Patrick</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1017623</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1017623</guid><dc:creator><![CDATA[Dedidado2]]></dc:creator><pubDate>Thu, 16 Mar 2006 15:13:34 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit MSDN Beispiel: Positioning Objects on a Multiple Display Setup on Fri, 17 Mar 2006 14:07:56 GMT]]></title><description><![CDATA[<p>Schau mal in der Hilfe nach EnumDisplayMonitors(), dort gibt es ein Beispiel, wie man eine Aufzählung der vorhandenen Monitore bekommt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1018332</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1018332</guid><dc:creator><![CDATA[jencas]]></dc:creator><pubDate>Fri, 17 Mar 2006 14:07:56 GMT</pubDate></item></channel></rss>