<?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[Programmfehler]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe einen Dialog erstellt und ein Listenfeld hinzugefügt, welches<br />
Dateien akzeptiert.(Ich habe den Haken im Resourceneditor gesetzt)</p>
<p>Doch leider wird das Listenfeld nur grau dargestellet und aktzeptiert keine Dateien. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
<p>Hier der code:</p>
<pre><code class="language-cpp">#include &quot;resource.h&quot;
#include &lt;windows.h&gt;
#include &lt;tchar.h&gt;
#include &quot;resource.h&quot;

WNDPROC wndpList;

//Deklaration der WndProc Funktion und der Funktion fürs Fenster
LRESULT CALLBACK WndProc (HWND,UINT,WPARAM,LPARAM);
BOOL CALLBACK MainDlg (HWND,UINT,WPARAM,LPARAM);
//Fenster handles
HINSTANCE hInstMain;
HWND hwndMain;

int WINAPI WinMain (HINSTANCE hInstance,HINSTANCE hPrevInstance,PSTR szCmdLine,int iCmdShow)
{
	static TCHAR szAppName[]=TEXT(&quot;Dialog&quot;);
	HWND hwnd;
	MSG msg;
	RECT rect;
	WNDCLASS wndclass;

	hInstMain=hInstance;

	wndclass.style=0;
	wndclass.lpfnWndProc=WndProc;
	wndclass.cbClsExtra=0;
	wndclass.cbWndExtra=0;
	wndclass.hInstance=hInstance;
	wndclass.hIcon=LoadIcon(hInstance,&quot;pIcon&quot;);
	wndclass.hCursor=NULL;
	wndclass.hbrBackground=NULL;
	wndclass.lpszMenuName=NULL;
	wndclass.lpszClassName=szAppName;

	if(!RegisterClass(&amp;wndclass))
	{
		MessageBox(NULL,TEXT(&quot;Programm works with UNICODE!WinNT is required!&quot;),szAppName,MB_ICONERROR);
		return 0;
	}

	hwnd=CreateWindowEx(NULL,szAppName,TEXT(&quot;Test&quot;),
						WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_BORDER ,
						320,250,
						CW_USEDEFAULT,CW_USEDEFAULT,
						NULL,NULL,hInstance,NULL);

	hwndMain=CreateDialog(hInstance,szAppName,hwnd,MainDlg);
	GetWindowRect(hwndMain,&amp;rect);
	AdjustWindowRect(&amp;rect,WS_EX_TOOLWINDOW|WS_BORDER,TRUE|WS_EX_ACCEPTFILES );
	SetWindowPos(hwnd,NULL,0,0,rect.right-rect.left,rect.bottom-rect.top,SWP_NOMOVE);
	ShowWindow(hwndMain,SW_SHOW);
	ShowWindow(hwnd,iCmdShow);
	UpdateWindow(hwnd);

	while(GetMessage(&amp;msg,NULL,0,0))
	{
		if(hwndMain==0||!IsDialogMessage(hwndMain,&amp;msg))
		{
			TranslateMessage(&amp;msg);
			DispatchMessage(&amp;msg);
		}
	}
	return msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
	switch(message)
	{case WM_CREATE:
		return 0;
	case WM_SETFOCUS:
		SetFocus(hwndMain);
		return 0;
	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;
	case WM_DROPFILES:
	return(SendMessage(GetParent(hwnd), message, wParam, lParam));
        default:
            break;

	}
	return DefWindowProc(hwnd,message,wParam,lParam);
}
//Der Code fürs Hauptfenster
BOOL CALLBACK MainDlg (HWND hMain,UINT message,WPARAM wParam,LPARAM lParam)
{

	switch(message)
	{	

	case WM_INITDIALOG:
			wndpList = (WNDPROC)SetWindowLongPtr(GetDlgItem(hMain, IDC_LIST1), GWLP_WNDPROC, (LONG_PTR)WndProc);
     break;

	case WM_DROPFILES:
            {
              INT_PTR nCnt, nIndex, nSize;
              LPTSTR  pszFileName;
              HDROP   hDrop;

                hDrop = (HDROP)wParam;
                nCnt  = DragQueryFile(hDrop, (UINT)-1, NULL, 0); // Anzahl der Dateien ermitteln

                for(nIndex = 0; nIndex &lt; nCnt; ++nIndex)
                {
                    // Länge des Dateinamens ermitteln
                    if(0 == (nSize = DragQueryFile(hDrop, nIndex, NULL, 0)))
                        continue;

                    pszFileName = new TCHAR[++nSize];

                    if(DragQueryFile(hDrop, nIndex, pszFileName, nSize))
                    {
                        // Den String nur dann hinzufügen, wenn er noch nicht vorhanden ist
                        if(0 &gt; SendDlgItemMessage(hMain, IDC_LIST1, LB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)pszFileName))
                            SendDlgItemMessage(hMain, IDC_LIST1, LB_ADDSTRING, 0, (LPARAM)pszFileName);
                    }

                    delete [] pszFileName;
                }
            }
           break;

		   //Sollte klar sein
	case WM_COMMAND:
		switch (LOWORD(wParam))
		{
		case IDC_CANCEL:
			//bei beenden des progs socket destroyen

			DestroyWindow(GetParent(hMain));
			return 0;
		}

		break;

	}
return 0;
}
</code></pre>
<p>Was ist falsch?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/49650/programmfehler</link><generator>RSS for Node</generator><lastBuildDate>Sat, 12 Sep 2026 11:15:06 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/49650.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 22 Sep 2003 09:31:44 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Programmfehler on Mon, 22 Sep 2003 09:31:44 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe einen Dialog erstellt und ein Listenfeld hinzugefügt, welches<br />
Dateien akzeptiert.(Ich habe den Haken im Resourceneditor gesetzt)</p>
<p>Doch leider wird das Listenfeld nur grau dargestellet und aktzeptiert keine Dateien. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
<p>Hier der code:</p>
<pre><code class="language-cpp">#include &quot;resource.h&quot;
#include &lt;windows.h&gt;
#include &lt;tchar.h&gt;
#include &quot;resource.h&quot;

WNDPROC wndpList;

//Deklaration der WndProc Funktion und der Funktion fürs Fenster
LRESULT CALLBACK WndProc (HWND,UINT,WPARAM,LPARAM);
BOOL CALLBACK MainDlg (HWND,UINT,WPARAM,LPARAM);
//Fenster handles
HINSTANCE hInstMain;
HWND hwndMain;

int WINAPI WinMain (HINSTANCE hInstance,HINSTANCE hPrevInstance,PSTR szCmdLine,int iCmdShow)
{
	static TCHAR szAppName[]=TEXT(&quot;Dialog&quot;);
	HWND hwnd;
	MSG msg;
	RECT rect;
	WNDCLASS wndclass;

	hInstMain=hInstance;

	wndclass.style=0;
	wndclass.lpfnWndProc=WndProc;
	wndclass.cbClsExtra=0;
	wndclass.cbWndExtra=0;
	wndclass.hInstance=hInstance;
	wndclass.hIcon=LoadIcon(hInstance,&quot;pIcon&quot;);
	wndclass.hCursor=NULL;
	wndclass.hbrBackground=NULL;
	wndclass.lpszMenuName=NULL;
	wndclass.lpszClassName=szAppName;

	if(!RegisterClass(&amp;wndclass))
	{
		MessageBox(NULL,TEXT(&quot;Programm works with UNICODE!WinNT is required!&quot;),szAppName,MB_ICONERROR);
		return 0;
	}

	hwnd=CreateWindowEx(NULL,szAppName,TEXT(&quot;Test&quot;),
						WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_BORDER ,
						320,250,
						CW_USEDEFAULT,CW_USEDEFAULT,
						NULL,NULL,hInstance,NULL);

	hwndMain=CreateDialog(hInstance,szAppName,hwnd,MainDlg);
	GetWindowRect(hwndMain,&amp;rect);
	AdjustWindowRect(&amp;rect,WS_EX_TOOLWINDOW|WS_BORDER,TRUE|WS_EX_ACCEPTFILES );
	SetWindowPos(hwnd,NULL,0,0,rect.right-rect.left,rect.bottom-rect.top,SWP_NOMOVE);
	ShowWindow(hwndMain,SW_SHOW);
	ShowWindow(hwnd,iCmdShow);
	UpdateWindow(hwnd);

	while(GetMessage(&amp;msg,NULL,0,0))
	{
		if(hwndMain==0||!IsDialogMessage(hwndMain,&amp;msg))
		{
			TranslateMessage(&amp;msg);
			DispatchMessage(&amp;msg);
		}
	}
	return msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
	switch(message)
	{case WM_CREATE:
		return 0;
	case WM_SETFOCUS:
		SetFocus(hwndMain);
		return 0;
	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;
	case WM_DROPFILES:
	return(SendMessage(GetParent(hwnd), message, wParam, lParam));
        default:
            break;

	}
	return DefWindowProc(hwnd,message,wParam,lParam);
}
//Der Code fürs Hauptfenster
BOOL CALLBACK MainDlg (HWND hMain,UINT message,WPARAM wParam,LPARAM lParam)
{

	switch(message)
	{	

	case WM_INITDIALOG:
			wndpList = (WNDPROC)SetWindowLongPtr(GetDlgItem(hMain, IDC_LIST1), GWLP_WNDPROC, (LONG_PTR)WndProc);
     break;

	case WM_DROPFILES:
            {
              INT_PTR nCnt, nIndex, nSize;
              LPTSTR  pszFileName;
              HDROP   hDrop;

                hDrop = (HDROP)wParam;
                nCnt  = DragQueryFile(hDrop, (UINT)-1, NULL, 0); // Anzahl der Dateien ermitteln

                for(nIndex = 0; nIndex &lt; nCnt; ++nIndex)
                {
                    // Länge des Dateinamens ermitteln
                    if(0 == (nSize = DragQueryFile(hDrop, nIndex, NULL, 0)))
                        continue;

                    pszFileName = new TCHAR[++nSize];

                    if(DragQueryFile(hDrop, nIndex, pszFileName, nSize))
                    {
                        // Den String nur dann hinzufügen, wenn er noch nicht vorhanden ist
                        if(0 &gt; SendDlgItemMessage(hMain, IDC_LIST1, LB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)pszFileName))
                            SendDlgItemMessage(hMain, IDC_LIST1, LB_ADDSTRING, 0, (LPARAM)pszFileName);
                    }

                    delete [] pszFileName;
                }
            }
           break;

		   //Sollte klar sein
	case WM_COMMAND:
		switch (LOWORD(wParam))
		{
		case IDC_CANCEL:
			//bei beenden des progs socket destroyen

			DestroyWindow(GetParent(hMain));
			return 0;
		}

		break;

	}
return 0;
}
</code></pre>
<p>Was ist falsch?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/358047</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/358047</guid><dc:creator><![CDATA[MisterX]]></dc:creator><pubDate>Mon, 22 Sep 2003 09:31:44 GMT</pubDate></item><item><title><![CDATA[Reply to Programmfehler on Mon, 22 Sep 2003 10:46:09 GMT]]></title><description><![CDATA[<p><em>wndpList = (WNDPROC)SetWindowLongPtr(GetDlgItem(hMain, IDC_LIST1), GWLP_WNDPROC, (LONG_PTR)WndProc);</em></p>
<p>muss weg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/358095</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/358095</guid><dc:creator><![CDATA[hi]]></dc:creator><pubDate>Mon, 22 Sep 2003 10:46:09 GMT</pubDate></item><item><title><![CDATA[Reply to Programmfehler on Mon, 22 Sep 2003 12:27:10 GMT]]></title><description><![CDATA[<p>hier das ganze ohne dialogbox:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;

#define ID_LISTBOX		1
#define ID_BUTTON_CLOSE	2

LRESULT CALLBACK WndProc	(HWND, UINT, WPARAM, LPARAM) ;
LRESULT CALLBACK fnListBox	(HWND, UINT, WPARAM, LPARAM) ;

TCHAR	szAppName[] = TEXT (&quot;test&quot;) ;
WNDPROC	fnWndProc ;

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
					PSTR szCmdLine, int iCmdShow){
	HWND			hwnd ;
	MSG				msg ;
	WNDCLASSEX		wndclassex ;
	wndclassex.cbSize			= sizeof (WNDCLASSEX) ;
	wndclassex.style			= CS_HREDRAW | CS_VREDRAW ;
	wndclassex.lpfnWndProc		= WndProc ;
	wndclassex.cbClsExtra		= 0 ;
	wndclassex.cbWndExtra		= 0 ;
	wndclassex.hInstance		= hInstance ;
	wndclassex.hIcon			= LoadIcon (NULL, IDI_APPLICATION) ;
	wndclassex.hCursor			= LoadCursor (NULL, IDC_ARROW) ;
	wndclassex.hbrBackground	= (HBRUSH) (COLOR_BTNFACE + 1) ;
	wndclassex.lpszMenuName		= NULL ;
	wndclassex.lpszClassName	= szAppName ;
	wndclassex.hIconSm			= NULL ;
	RegisterClassEx (&amp;wndclassex) ;
	hwnd = CreateWindowEx (NULL, szAppName, TEXT (&quot;test&quot;),
							WS_OVERLAPPEDWINDOW,
							CW_USEDEFAULT , CW_USEDEFAULT,
							300, 300,
							NULL, NULL, hInstance, NULL) ;
	ShowWindow (hwnd, iCmdShow) ;
	UpdateWindow (hwnd) ;
	while (GetMessage (&amp;msg, NULL, 0, 0)){
		TranslateMessage (&amp;msg) ;
		DispatchMessage (&amp;msg) ;
	}
	return msg.wParam ;
}

LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
	static	HINSTANCE	hInstance ;
	switch (message){
		case WM_CREATE :
			hInstance = ((LPCREATESTRUCT) lParam) -&gt; hInstance ;
			CreateWindowEx (WS_EX_CLIENTEDGE | WS_EX_ACCEPTFILES, &quot;listbox&quot;,
							TEXT (&quot;Ok&quot;), 
							WS_CHILD | WS_VISIBLE | LBS_DISABLENOSCROLL | LBS_STANDARD,
							10, 10,
							270, 220,
							hwnd, (HMENU) ID_LISTBOX, hInstance, NULL) ;
			CreateWindowEx (NULL, &quot;button&quot;,
							TEXT (&quot;Ende&quot;), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
							210, 240,
							75, 25,
							hwnd, (HMENU) ID_BUTTON_CLOSE, hInstance, NULL) ;
			fnWndProc = (WNDPROC) SetWindowLongPtr (GetDlgItem (hwnd, ID_LISTBOX), GWLP_WNDPROC, (LONG_PTR) fnListBox) ;
			return 0 ;
		case WM_COMMAND :
			switch (LOWORD (wParam)){
				case ID_BUTTON_CLOSE :
					SendMessage (hwnd, WM_DESTROY, 0, 0) ;
					break ;
			}
			return 0 ;
 		case WM_DESTROY :
			PostQuitMessage (0) ;
			return 0 ;
	}
	return DefWindowProc (hwnd, message, wParam, lParam) ;
}

LRESULT CALLBACK fnListBox (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
	INT_PTR	nCnt,
			nIndex,
			nSize ;		
	char	*pszFileName = NULL;
	HDROP	hDrop ;
	switch(message){
		case WM_DROPFILES :
			hDrop = (HDROP) wParam ;
			nCnt  = DragQueryFile (hDrop, (UINT)-1, NULL, 0) ;
			for (nIndex = 0; nIndex &lt; nCnt; ++nIndex){
				if (0 == (nSize = DragQueryFile (hDrop, nIndex, NULL, 0))){
					break ;
				}
				pszFileName = (char*) malloc ((sizeof (char) * nSize) + 1) ;
				if (DragQueryFile (hDrop, nIndex, pszFileName, nSize)){
					SendMessage (GetDlgItem (GetParent (hwnd), ID_LISTBOX), LB_ADDSTRING, 0, (long) pszFileName) ;
				}
				free (pszFileName) ;
			}
			break ;
	}
	return (CallWindowProc (fnWndProc, hwnd, message, wParam, lParam)) ;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/358144</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/358144</guid><dc:creator><![CDATA[hi]]></dc:creator><pubDate>Mon, 22 Sep 2003 12:27:10 GMT</pubDate></item><item><title><![CDATA[Reply to Programmfehler on Mon, 22 Sep 2003 13:50:15 GMT]]></title><description><![CDATA[<p>Danke, das Löschen der Zeile hat geholfen !</p>
]]></description><link>https://www.c-plusplus.net/forum/post/358190</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/358190</guid><dc:creator><![CDATA[MisterX]]></dc:creator><pubDate>Mon, 22 Sep 2003 13:50:15 GMT</pubDate></item></channel></rss>