<?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[Funktion nicht nutzbar?]]></title><description><![CDATA[<blockquote>
<p>main.cpp|28|error: invalid conversion from `HWND__*' to `int'|<br />
main.cpp||In function <code>int main()':| main.cpp|40|error:</code>toClipboard' cannot be used as a function|<br />
main.cpp|100|error: expected constructor, destructor, or type conversion before '(' token|<br />
||=== Build finished: 3 errors, 0 warnings ===|</p>
</blockquote>
<p>Diese Fehler bekomme ich. Das Problem ist, dass ich weder weiß was sie bedeuten, noch wie ich sie behebe. Könnt ihr mir helfen?</p>
<pre><code class="language-cpp">#include &lt;Windows.h&gt;
#include &lt;Tchar.h&gt;
#include &lt;vector&gt;
#include &lt;Iostream&gt;
#include &lt;winuser.h&gt;
#include &lt;winable.h&gt;

using namespace std;

HWND myWindowHandler;
HWND wnd;
HWND CWnd;
struct Window
{
    basic_string&lt;TCHAR&gt; title;
    HWND handle;
};
vector&lt;Window&gt; windows;

HWND select_window (void);
int toClipboard(CWnd);

int main() {
    myWindowHandler = select_window();
    // Fenster in Originalgröße anzeigen
    ShowWindow(myWindowHandler, SW_RESTORE);
    // Fenster in den Vordergrund holenc
    SetForegroundWindow(myWindowHandler);
    // Tastaturfokus auf Fenster setzen
    SetFocus(myWindowHandler);
    // dc                   // wnd
    toClipboard(myWindowHandler);

    return 0;
}

// Callback fr EnumWindows. Wird aufgerufen fr jedes Fenster
BOOL CALLBACK EnumWindowsProc (::HWND hwnd, ::LPARAM lParam)
{
    // Kein Fenster
    if (!IsWindow (hwnd))
        return (TRUE);

    // nur sichtbare Fenster auflisten
    if (!IsWindowVisible (hwnd))
        return (TRUE);

    // Fensterberschrift ermitteln
    TCHAR title[256];
    if (!GetWindowText (hwnd, title, sizeof (title) / sizeof (title[0])))
        return (TRUE);

    // neues Fenster hinzufgen...
    Window wnd;
    wnd.handle      = hwnd;
    wnd.title       = title;
    windows.push_back (wnd);

    return (TRUE);
}

// Listet Fenster auf und regelt Auswahl eines Fensters
HWND select_window (void)
{
    // Alle Fenster auflisten
    EnumWindows (EnumWindowsProc, 0);

    // Liste aller Fenster ausgeben.
    vector&lt;Window&gt;::iterator window_it = windows.begin ();
    for (int i = 0; window_it != windows.end (); ++ window_it, ++ i)
        _tprintf (_T (&quot;%d : %s\n&quot;), i, window_it-&gt;title.c_str ());

    // Auswahl des Fensters &amp; Prüfung, ob Auswahl im Gültigskeitsbereich liegt
    unsigned int choice = 0;
    do
    {
        cout &lt;&lt; &quot;\nAuf welches Fenster soll aufgeschaltet werden: \n&quot;;
        cin &gt;&gt; choice;
    } while (choice &lt; 0 || choice &gt;= windows.size ());

    // ausgewählte Fensterhandle zurckgeben
    return (windows[choice].handle);
}

toClipboard(CWnd * wnd) {
    CDC dc;
    HDC hdc = ::GetDC(myWindowHandler);
    dc.Attach(hdc);
    CDC memDC;
    memDC.CreateCompatibleDC(&amp;dc);
    CBitmap bm;
    CRect r;
    wnd-&gt;GetClientRect(&amp;r);
    CString s;
    wnd-&gt;GetWindowText(s);
    CSize sz(r.Width(), r.Height());
    bm.CreateCompatibleBitmap(&amp;dc, sz.cx, sz.cy);
    CBitmap * oldbm = memDC.SelectObject(&amp;bm);
    memDC.BitBlt(0, 0, sz.cx, sz.cy, &amp;dc, 0, 0, SRCCOPY);
    wnd-&gt;GetParent()-&gt;OpenClipboard();
    ::EmptyClipboard();
    ::SetClipboardData(CF_BITMAP, bm.m_hObject);
    CloseClipboard();

    memDC.SelectObject(oldbm);
    bm.Detach();  // make sure bitmap not deleted with CBitmap object

}
</code></pre>
<p>hochachtungsvoll, stoa</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/230432/funktion-nicht-nutzbar</link><generator>RSS for Node</generator><lastBuildDate>Thu, 09 Apr 2026 23:35:46 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/230432.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 26 Dec 2008 19:19:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Funktion nicht nutzbar? on Fri, 26 Dec 2008 19:19:34 GMT]]></title><description><![CDATA[<blockquote>
<p>main.cpp|28|error: invalid conversion from `HWND__*' to `int'|<br />
main.cpp||In function <code>int main()':| main.cpp|40|error:</code>toClipboard' cannot be used as a function|<br />
main.cpp|100|error: expected constructor, destructor, or type conversion before '(' token|<br />
||=== Build finished: 3 errors, 0 warnings ===|</p>
</blockquote>
<p>Diese Fehler bekomme ich. Das Problem ist, dass ich weder weiß was sie bedeuten, noch wie ich sie behebe. Könnt ihr mir helfen?</p>
<pre><code class="language-cpp">#include &lt;Windows.h&gt;
#include &lt;Tchar.h&gt;
#include &lt;vector&gt;
#include &lt;Iostream&gt;
#include &lt;winuser.h&gt;
#include &lt;winable.h&gt;

using namespace std;

HWND myWindowHandler;
HWND wnd;
HWND CWnd;
struct Window
{
    basic_string&lt;TCHAR&gt; title;
    HWND handle;
};
vector&lt;Window&gt; windows;

HWND select_window (void);
int toClipboard(CWnd);

int main() {
    myWindowHandler = select_window();
    // Fenster in Originalgröße anzeigen
    ShowWindow(myWindowHandler, SW_RESTORE);
    // Fenster in den Vordergrund holenc
    SetForegroundWindow(myWindowHandler);
    // Tastaturfokus auf Fenster setzen
    SetFocus(myWindowHandler);
    // dc                   // wnd
    toClipboard(myWindowHandler);

    return 0;
}

// Callback fr EnumWindows. Wird aufgerufen fr jedes Fenster
BOOL CALLBACK EnumWindowsProc (::HWND hwnd, ::LPARAM lParam)
{
    // Kein Fenster
    if (!IsWindow (hwnd))
        return (TRUE);

    // nur sichtbare Fenster auflisten
    if (!IsWindowVisible (hwnd))
        return (TRUE);

    // Fensterberschrift ermitteln
    TCHAR title[256];
    if (!GetWindowText (hwnd, title, sizeof (title) / sizeof (title[0])))
        return (TRUE);

    // neues Fenster hinzufgen...
    Window wnd;
    wnd.handle      = hwnd;
    wnd.title       = title;
    windows.push_back (wnd);

    return (TRUE);
}

// Listet Fenster auf und regelt Auswahl eines Fensters
HWND select_window (void)
{
    // Alle Fenster auflisten
    EnumWindows (EnumWindowsProc, 0);

    // Liste aller Fenster ausgeben.
    vector&lt;Window&gt;::iterator window_it = windows.begin ();
    for (int i = 0; window_it != windows.end (); ++ window_it, ++ i)
        _tprintf (_T (&quot;%d : %s\n&quot;), i, window_it-&gt;title.c_str ());

    // Auswahl des Fensters &amp; Prüfung, ob Auswahl im Gültigskeitsbereich liegt
    unsigned int choice = 0;
    do
    {
        cout &lt;&lt; &quot;\nAuf welches Fenster soll aufgeschaltet werden: \n&quot;;
        cin &gt;&gt; choice;
    } while (choice &lt; 0 || choice &gt;= windows.size ());

    // ausgewählte Fensterhandle zurckgeben
    return (windows[choice].handle);
}

toClipboard(CWnd * wnd) {
    CDC dc;
    HDC hdc = ::GetDC(myWindowHandler);
    dc.Attach(hdc);
    CDC memDC;
    memDC.CreateCompatibleDC(&amp;dc);
    CBitmap bm;
    CRect r;
    wnd-&gt;GetClientRect(&amp;r);
    CString s;
    wnd-&gt;GetWindowText(s);
    CSize sz(r.Width(), r.Height());
    bm.CreateCompatibleBitmap(&amp;dc, sz.cx, sz.cy);
    CBitmap * oldbm = memDC.SelectObject(&amp;bm);
    memDC.BitBlt(0, 0, sz.cx, sz.cy, &amp;dc, 0, 0, SRCCOPY);
    wnd-&gt;GetParent()-&gt;OpenClipboard();
    ::EmptyClipboard();
    ::SetClipboardData(CF_BITMAP, bm.m_hObject);
    CloseClipboard();

    memDC.SelectObject(oldbm);
    bm.Detach();  // make sure bitmap not deleted with CBitmap object

}
</code></pre>
<p>hochachtungsvoll, stoa</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1635857</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1635857</guid><dc:creator><![CDATA[stoa]]></dc:creator><pubDate>Fri, 26 Dec 2008 19:19:34 GMT</pubDate></item><item><title><![CDATA[Reply to Funktion nicht nutzbar? on Fri, 26 Dec 2008 20:41:41 GMT]]></title><description><![CDATA[<p>In Zeile 28 deklarierst du den Prototypen für deine Funktion <code>toClipboard ()</code> , benutzt aber als <strong>Datentyp</strong> für den Parameter CWnd, welches du aber in Zeile 13 als <strong>Variable</strong> des Typs HWND definiert hast. Folglich deklariert er die Funktion nicht richtig und diese kann in Zeile 40 auch nicht aufgerufen werden. In Zeile 100 hast du wieder das selbe Problem wie in Zeile 28.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1635888</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1635888</guid><dc:creator><![CDATA[devkid]]></dc:creator><pubDate>Fri, 26 Dec 2008 20:41:41 GMT</pubDate></item><item><title><![CDATA[Reply to Funktion nicht nutzbar? on Fri, 26 Dec 2008 20:48:29 GMT]]></title><description><![CDATA[<p>du übergibst an die funktion toClipboard ein HWND es wird aber ein CWnd verlangt.</p>
<p>versuch es mal mit CWnd::Attach</p>
<pre><code>CWnd wnd;
wnd.Attach(myWindowHandler);

toClipboard(wnd);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1635891</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1635891</guid><dc:creator><![CDATA[*rT*f*Ct]]></dc:creator><pubDate>Fri, 26 Dec 2008 20:48:29 GMT</pubDate></item></channel></rss>