<?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[Window Title in ListBox anzeigen]]></title><description><![CDATA[<p>Hallo, ich möchte von allen auf dem Computer ausgeführten Programmen die Fenster Titel in einer List Box anzeigen. Das Problem ist, das in der Listbox nur der Fenstertitel meines Programms angezeigt wird, also TaskView1. Wenn ich aber die Variable pcWinTitle(die die Fensternamen enthält) mit einer MessageBox ausgebe, zeigt er mir alle Fensternamen an, so wie es sein soll.<br />
Hier ist schonmal mein Code:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &quot;taskviewer.h&quot;
#include &quot;resource.h&quot;
HWND hDialog;
BOOL CALLBACK DialogProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM   lParam);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR  lpCmdLine, int nCmdShow)
{
	MSG msg;
	hDialog = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_MAINDLG), NULL, DialogProc);
	ShowWindow(hDialog, nCmdShow);
	UpdateWindow(hDialog);
	while (GetMessage(&amp;msg, NULL, 0, 0))
	{

				TranslateMessage(&amp;msg);
				DispatchMessage(&amp;msg);		

	}
	return msg.wParam;
}

	BOOL CALLBACK EnumWindowProc(HWND hwnd,LPARAM lParam)
	{
		char pcWinTitle[256];
		if(!GetWindow(hwnd, GW_OWNER))
		{
			GetWindowText(hwnd, pcWinTitle, 255);
			AddTasks(hwnd, pcWinTitle); // Hier zeigt er nur TaksView1 an.
            MessageBox(NULL, pcWinTitle, &quot;Test&quot;, MB_OK); // Hier zeigt er alle Titel an.
		}
		return true;
	}

BOOL CALLBACK DialogProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {

	case WM_INITDIALOG:
		{
			EnumWindows((WNDENUMPROC)EnumWindowProc, 0);
			return 0;
		}
    case WM_COMMAND:
        switch (LOWORD(wParam))
        {
        case IDOK:
        case IDCANCEL:
            DestroyWindow (hwndDlg);
            return (TRUE);

        default:
            break;
        }
        return (FALSE);

    case WM_CLOSE:
		PostQuitMessage(0);
    case WM_DESTROY:
        EndDialog (hwndDlg, 0);
        return (TRUE);
    }
    return (FALSE);
}

BOOL AddTasks(HWND hwndDlg, char pcWinTitle[256])
{	
	int index = SendDlgItemMessage(hwndDlg, IDC_TASKLIST, LB_ADDSTRING, 0, (LPARAM)pcWinTitle); // Fügt Tasks in die ListBox
	return TRUE;
}
</code></pre>
<p>Wisst ihr woran das Problem liegt? Ich benutze zum ersten mal eine Listbox mit der WinAPI.</p>
<p>MFG MrBigBrain</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/161113/window-title-in-listbox-anzeigen</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Jul 2026 13:52:32 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/161113.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 03 Oct 2006 13:53:01 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Window Title in ListBox anzeigen on Tue, 03 Oct 2006 13:53:01 GMT]]></title><description><![CDATA[<p>Hallo, ich möchte von allen auf dem Computer ausgeführten Programmen die Fenster Titel in einer List Box anzeigen. Das Problem ist, das in der Listbox nur der Fenstertitel meines Programms angezeigt wird, also TaskView1. Wenn ich aber die Variable pcWinTitle(die die Fensternamen enthält) mit einer MessageBox ausgebe, zeigt er mir alle Fensternamen an, so wie es sein soll.<br />
Hier ist schonmal mein Code:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &quot;taskviewer.h&quot;
#include &quot;resource.h&quot;
HWND hDialog;
BOOL CALLBACK DialogProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM   lParam);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR  lpCmdLine, int nCmdShow)
{
	MSG msg;
	hDialog = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_MAINDLG), NULL, DialogProc);
	ShowWindow(hDialog, nCmdShow);
	UpdateWindow(hDialog);
	while (GetMessage(&amp;msg, NULL, 0, 0))
	{

				TranslateMessage(&amp;msg);
				DispatchMessage(&amp;msg);		

	}
	return msg.wParam;
}

	BOOL CALLBACK EnumWindowProc(HWND hwnd,LPARAM lParam)
	{
		char pcWinTitle[256];
		if(!GetWindow(hwnd, GW_OWNER))
		{
			GetWindowText(hwnd, pcWinTitle, 255);
			AddTasks(hwnd, pcWinTitle); // Hier zeigt er nur TaksView1 an.
            MessageBox(NULL, pcWinTitle, &quot;Test&quot;, MB_OK); // Hier zeigt er alle Titel an.
		}
		return true;
	}

BOOL CALLBACK DialogProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {

	case WM_INITDIALOG:
		{
			EnumWindows((WNDENUMPROC)EnumWindowProc, 0);
			return 0;
		}
    case WM_COMMAND:
        switch (LOWORD(wParam))
        {
        case IDOK:
        case IDCANCEL:
            DestroyWindow (hwndDlg);
            return (TRUE);

        default:
            break;
        }
        return (FALSE);

    case WM_CLOSE:
		PostQuitMessage(0);
    case WM_DESTROY:
        EndDialog (hwndDlg, 0);
        return (TRUE);
    }
    return (FALSE);
}

BOOL AddTasks(HWND hwndDlg, char pcWinTitle[256])
{	
	int index = SendDlgItemMessage(hwndDlg, IDC_TASKLIST, LB_ADDSTRING, 0, (LPARAM)pcWinTitle); // Fügt Tasks in die ListBox
	return TRUE;
}
</code></pre>
<p>Wisst ihr woran das Problem liegt? Ich benutze zum ersten mal eine Listbox mit der WinAPI.</p>
<p>MFG MrBigBrain</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1148676</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1148676</guid><dc:creator><![CDATA[MrBigBrain20]]></dc:creator><pubDate>Tue, 03 Oct 2006 13:53:01 GMT</pubDate></item><item><title><![CDATA[Reply to Window Title in ListBox anzeigen on Tue, 03 Oct 2006 14:01:18 GMT]]></title><description><![CDATA[<ol>
<li></li>
</ol>
<p>Deine WinMain ist flasch und sollte so aussehen:</p>
<pre><code class="language-cpp">int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, char* pszCmdLine, int iCmdShow)
{
    return (DialogBox(hInst, MAKEINTRESOURCE(DLG_RESOURCE_ID), NULL, DlgProc));
}
</code></pre>
<p>(Das wird aber noch nicht dein Problem lösen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> . Siehe dazu 2.)</p>
<ol start="2">
<li></li>
</ol>
<p>GetWindowText kann den Titel von Fenstern nicht prozessübergreifend ermitteln.<br />
Du kannst altenativ SendMessage und WM_GETTEXT bzw. WM_GETTEXTLENGTH (für<br />
dynamische Allokation) verwenden <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> .</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1148684</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1148684</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Tue, 03 Oct 2006 14:01:18 GMT</pubDate></item><item><title><![CDATA[Reply to Window Title in ListBox anzeigen on Tue, 03 Oct 2006 14:52:49 GMT]]></title><description><![CDATA[<p>Hallo, ich verstehe nicht was du meinst, ich habe jetzt 100 Möglichkeiten ausprobiert, aber ich bekomme nur TaskViewer1, oder 100 mal TaskViewer1 in der List Box zu gesicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1148715</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1148715</guid><dc:creator><![CDATA[MrBigBrain20]]></dc:creator><pubDate>Tue, 03 Oct 2006 14:52:49 GMT</pubDate></item><item><title><![CDATA[Reply to Window Title in ListBox anzeigen on Tue, 03 Oct 2006 15:02:12 GMT]]></title><description><![CDATA[<p>Mir fällt auch grad auf das du immer der Funktion AddTasks einen falschen Handle übergibst, guck dir mal deine<br />
EnumWindowProc nochmal an.</p>
<p>PS: WAS verstehst du denn nicht ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1148726</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1148726</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Tue, 03 Oct 2006 15:02:12 GMT</pubDate></item><item><title><![CDATA[Reply to Window Title in ListBox anzeigen on Tue, 03 Oct 2006 15:31:29 GMT]]></title><description><![CDATA[<p>Ich verstehe nicht warum es immer noch nicht funktioniert. Das ist meine EnumWindowProc:</p>
<pre><code class="language-cpp">BOOL CALLBACK EnumWindowProc(HWND hwnd,LPARAM lParam)
{
	char pcWinTitle[256];
	if(!GetWindow(hwnd, GW_OWNER))
	{
		//GetWindowText(hwnd, pcWinTitle, 255);
		//AddTasks(hwnd, pcWinTitle); // Hier zeigt er nur TaksView1 an.
		SendMessage(hwnd, WM_GETTEXT, (WPARAM)sizeof(pcWinTitle), (LPARAM)pcWinTitle);
		//MessageBox(hwnd, pcWinTitle, &quot;Test&quot;, MB_OK); // Hier zeigt er alle Titel an.
		AddTasks(hwnd, pcWinTitle);
		//AddTasks(hwnd, pcWinTitle);
	}
	return true;
}
</code></pre>
<p>und das meine AddTasks:</p>
<pre><code class="language-cpp">int index = SendDlgItemMessage(hwnd, IDC_TASKLIST, LB_ADDSTRING, 0, (LPARAM)pcWinTitle); // Fügt Tasks in die ListBox
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1148736</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1148736</guid><dc:creator><![CDATA[MrBigBrain20]]></dc:creator><pubDate>Tue, 03 Oct 2006 15:31:29 GMT</pubDate></item><item><title><![CDATA[Reply to Window Title in ListBox anzeigen on Tue, 03 Oct 2006 15:44:48 GMT]]></title><description><![CDATA[<p>Probier mal das:</p>
<pre><code class="language-cpp">#include &lt;Windows.h&gt;
#include &quot;Resource.h&quot;

HWND hlbxDest;

BOOL CALLBACK DialogProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam);

int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, char* pszCmdLine, int iCmdShow)
{
	return (DialogBox(hInst, MAKEINTRESOURCE(IDD_MAINDLG), NULL, DialogProc));
}

BOOL CALLBACK EnumWindowProc(HWND hwnd, LPARAM lParam)
{
	UINT uiLength = SendMessage(hwnd, WM_GETTEXTLENGTH, 0, 0L);
	PTCHAR pszWndText = new TCHAR[uiLength + 1];
	SendMessage(hwnd, WM_GETTEXT, uiLength + 1, (LPARAM)pszWndText);
	SendMessage(hlbxDest, LB_ADDSTRING, 0, (LPARAM)pszWndText);
	delete [] pszWndText;
	return (TRUE);
}

BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uiMessage, WPARAM wParam, LPARAM lParam)
{
    switch(uiMessage)
    {

	case WM_INITDIALOG:
		hlbxDest = GetDlgItem(hwndDlg, IDC_TASKLIST);
		EnumWindows((WNDENUMPROC)EnumWindowProc, 0);
		return TRUE;
    case WM_COMMAND:
        switch(LOWORD(wParam))
        {
        	case IDOK:
        	case IDCANCEL:
            	    SendMessage(hwndDlg, WM_CLOSE, 0, 0L);
            	    return (TRUE);
        }
        return (FALSE);

    case WM_CLOSE:
    case WM_DESTROY:
        EndDialog (hwndDlg, 0);
        return (TRUE);
    }
    return (FALSE);
}
</code></pre>
<p>WICHTIG: Sowohl PostQuitMessage als auch DestroyWindow haben in einer DialogProc nichts zu suchen. Vllt guckst du dir nochmal ein Tut an.</p>
<p>PS: Hab den Code nicht getestet .</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1148742</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1148742</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Tue, 03 Oct 2006 15:44:48 GMT</pubDate></item><item><title><![CDATA[Reply to Window Title in ListBox anzeigen on Tue, 03 Oct 2006 15:51:15 GMT]]></title><description><![CDATA[<p>Danke, es funktioniert. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>MFG MrBigBrain</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1148747</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1148747</guid><dc:creator><![CDATA[MrBigBrain20]]></dc:creator><pubDate>Tue, 03 Oct 2006 15:51:15 GMT</pubDate></item></channel></rss>