<?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[Combo Box Subclassen]]></title><description><![CDATA[<p>hallo Leute,</p>
<p>ich bastel mir gerade eine eigen Kommandozeile.<br />
Dabei habe ich die Ausgabe in einem RichEdit und die Eingabe macht man in eine Combo Box Control.</p>
<p>jetzt wollte ich, dass wenn in der Combo Box [Enter] gedrückt wird, der Befehl ausgeführt wird,<br />
also habe ich eine NewComboProc geschrieben und per SetWindowLongPtr die alte überschrieben.</p>
<p>funktioniert auch alles soweit...</p>
<p>jetzt wollte ich die WM_KEYDOWN abfangen und auf VK_RETURN reagieren und TADA, da läuft nichts.</p>
<p>seltsamer Weise empfängt die Funktion keine WM_KEYDOWN Nachricht.<br />
noch schlimmer: scheinbar empfängt sie auch keine WM_SYSKEYDOWN, WM_INPUT, WM_CHAR und was sonst noch für Tastatureingaben zur verfügung steht.</p>
<p>jetzt ist die Frage: wie kann ich auf die Enter-Taste reagieren?<br />
verwendet die Combo-Box intern andere Nachrichten?</p>
<p>schonmal danke</p>
<p>MfG DrakoXP</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/189347/combo-box-subclassen</link><generator>RSS for Node</generator><lastBuildDate>Thu, 02 Jul 2026 17:52:01 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/189347.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 11 Aug 2007 17:47:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Combo Box Subclassen on Sat, 11 Aug 2007 17:47:39 GMT]]></title><description><![CDATA[<p>hallo Leute,</p>
<p>ich bastel mir gerade eine eigen Kommandozeile.<br />
Dabei habe ich die Ausgabe in einem RichEdit und die Eingabe macht man in eine Combo Box Control.</p>
<p>jetzt wollte ich, dass wenn in der Combo Box [Enter] gedrückt wird, der Befehl ausgeführt wird,<br />
also habe ich eine NewComboProc geschrieben und per SetWindowLongPtr die alte überschrieben.</p>
<p>funktioniert auch alles soweit...</p>
<p>jetzt wollte ich die WM_KEYDOWN abfangen und auf VK_RETURN reagieren und TADA, da läuft nichts.</p>
<p>seltsamer Weise empfängt die Funktion keine WM_KEYDOWN Nachricht.<br />
noch schlimmer: scheinbar empfängt sie auch keine WM_SYSKEYDOWN, WM_INPUT, WM_CHAR und was sonst noch für Tastatureingaben zur verfügung steht.</p>
<p>jetzt ist die Frage: wie kann ich auf die Enter-Taste reagieren?<br />
verwendet die Combo-Box intern andere Nachrichten?</p>
<p>schonmal danke</p>
<p>MfG DrakoXP</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1342858</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1342858</guid><dc:creator><![CDATA[DrakoXP]]></dc:creator><pubDate>Sat, 11 Aug 2007 17:47:39 GMT</pubDate></item><item><title><![CDATA[Reply to Combo Box Subclassen on Sat, 11 Aug 2007 18:01:29 GMT]]></title><description><![CDATA[<p>Hmm, aber deine Combo-Box hat da auch den Keyboard-Fokus? (Prüf mal mit GetFocus() - Ich hab die Erfahrung gemacht das ein lustiges Cursors-Blinken nicht unbedingt auch keyboard-fokus heist ;/)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1342870</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1342870</guid><dc:creator><![CDATA[geeky]]></dc:creator><pubDate>Sat, 11 Aug 2007 18:01:29 GMT</pubDate></item><item><title><![CDATA[Reply to Combo Box Subclassen on Sat, 11 Aug 2007 18:40:19 GMT]]></title><description><![CDATA[<p>ich habe die Entertaste gedrückt, direkt als ich den Befehl eingegeben habe,<br />
also folglich muss die Combobox den Focus haben.</p>
<p>tollerweise erhält die Combo nicht mal bei normalen Tasten ala &quot;A&quot; eine WM_KEYDOWN-Nachricht <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>
]]></description><link>https://www.c-plusplus.net/forum/post/1342888</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1342888</guid><dc:creator><![CDATA[DrakoXP]]></dc:creator><pubDate>Sat, 11 Aug 2007 18:40:19 GMT</pubDate></item><item><title><![CDATA[Reply to Combo Box Subclassen on Sat, 11 Aug 2007 20:50:09 GMT]]></title><description><![CDATA[<p>Hatte mal ein ähnliches Problem. Sollte eigentlich mit 'abfragen' der Message <a href="http://msdn2.microsoft.com/en-us/library/ms645425.aspx" rel="nofollow">WM_GETDLGCODE</a> und Rückgabe des entsprechenden Wertes funktionieren.</p>
<blockquote>
<p>The WM_GETDLGCODE message is sent to the window procedure associated with a control. By default, the system handles all keyboard input to the control; the system interprets certain types of keyboard input as dialog box navigation keys. To override this default behavior, the control can respond to the WM_GETDLGCODE message to indicate the types of input it wants to process itself.</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/1342942</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1342942</guid><dc:creator><![CDATA[Analog Bit]]></dc:creator><pubDate>Sat, 11 Aug 2007 20:50:09 GMT</pubDate></item><item><title><![CDATA[Reply to Combo Box Subclassen on Sat, 11 Aug 2007 21:25:49 GMT]]></title><description><![CDATA[<p>DrakoXP schrieb:</p>
<blockquote>
<p>funktioniert auch alles soweit...<br />
jetzt wollte ich die WM_KEYDOWN abfangen und auf VK_RETURN reagieren und TADA, da läuft nichts.<br />
seltsamer Weise empfängt die Funktion keine WM_KEYDOWN Nachricht.</p>
</blockquote>
<p>Hast Du auch das Edit-Child der Combobox gesubclassed ?</p>
<pre><code class="language-cpp">POINT pt;
 pt.x = 1;
 pt.y = 1;

HWND hComboBox = CreateWindow         (&quot;COMBOBOX&quot;,...);
HWND hEdit     = ChildWindowFromPoint (hComboBox,  pt); // hEdit subclassen !
</code></pre>
<p><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>
]]></description><link>https://www.c-plusplus.net/forum/post/1342955</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1342955</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sat, 11 Aug 2007 21:25:49 GMT</pubDate></item><item><title><![CDATA[Reply to Combo Box Subclassen on Sat, 11 Aug 2007 22:28:25 GMT]]></title><description><![CDATA[<p>@merker: ups^^, nee xD<br />
muss ich mal ausprobieren, thx</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1342987</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1342987</guid><dc:creator><![CDATA[DrakoXP]]></dc:creator><pubDate>Sat, 11 Aug 2007 22:28:25 GMT</pubDate></item><item><title><![CDATA[Reply to Combo Box Subclassen on Sat, 11 Aug 2007 22:39:34 GMT]]></title><description><![CDATA[<p>hm, ich mach irgendwas falsch <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="😞"
    /><br />
ich empfange immer noch keine WM_KEYDOWN <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>
<p>ich kann ja mal den Code posten...<br />
vllt findet ihr ja was</p>
<pre><code class="language-cpp">// XP-Themes
#if defined _M_IX86 
#pragma comment(linker,&quot;/manifestdependency:\&quot;type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\&quot;&quot;) 
#elif defined _M_IA64 
#pragma comment(linker,&quot;/manifestdependency:\&quot;type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\&quot;&quot;) 
#elif defined _M_X64 
#pragma comment(linker,&quot;/manifestdependency:\&quot;type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\&quot;&quot;) 
#else 
#pragma comment(linker,&quot;/manifestdependency:\&quot;type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\&quot;&quot;) 
#endif

// Microsoft Common Controls
#pragma comment(lib, &quot;comctl32.lib&quot;)

// Windows Application Programming Interface
#ifdef STRICT
#undef STRICT
#endif
#include &lt;windows.h&gt;

// Microsoft Common Controls
#include &lt;commctrl.h&gt;

// Rich Edit Control
#include &lt;richedit.h&gt;

// Shell Objects
#include &lt;shlobj.h&gt;

// Resource IDs
#include &quot;resource.h&quot;

// Hauptfensterklasse
const wchar_t szWindowClass[] = L&quot;1B1C5E88_3712_4E9F_9BB4_83B81E99078D&quot;;

// Programm Instanz
HINSTANCE g_hInstance;

// Das Rich Edit
HWND g_hRichEdit;

// Die Combo-Box
HWND g_hInputCombo;

// kann beendet werden?
bool g_bCanExit;

// Der Prompt
wchar_t g_szPrompt[1024];

// Aktuelles Verzeichnis
wchar_t g_szCurrentDir[MAX_PATH];

// Die alte Fensterprozedur der Combo Box
WNDPROC g_pOldEditProc;

// Fehlermeldung
void ErrorMessage(const wchar_t* szMessage)
{
	DWORD dwError = GetLastError();
	wchar_t szError[1024];
	FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwError, 0x0407, szError, 1024, NULL);
	wchar_t szBuffer[4096];
	wsprintf(szBuffer, L&quot;Fehler: %s\nFehlercode: %d\nBeschreibung: %s&quot;, szMessage, dwError, szError);
	MessageBox(GetDesktopWindow(), szBuffer, L&quot;Fehler!&quot;, MB_OK|MB_ICONERROR);
}

// Konsolenbefehl ausführen
int DoCommand(int argc, wchar_t** argv)
{
	return 0;
}

// Gesubclassede Combo Box
LRESULT CALLBACK NewEditProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg)
	{
	case WM_KEYDOWN:
		{
			switch (wParam)
			{
			case VK_RETURN:
				{
					wchar_t szInput[1024];
					ComboBox_GetCueBannerText(g_hInputCombo, szInput, 1024);
					LRESULT result = SendMessage(g_hInputCombo, CB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)szInput);
					if (result == CB_ERR)
						SendMessage(g_hInputCombo, CB_INSERTSTRING, (WPARAM)0, (LPARAM)szInput);
					int iArgc;
					wchar_t** szArgv = CommandLineToArgvW(szInput, &amp;iArgc);
					int ret = DoCommand(iArgc, szArgv);
					LocalFree(szArgv);
					return ret;
				} break;
			default:
				return CallWindowProc(g_pOldEditProc, hWnd, msg, wParam, lParam);
			}
			return 0;
		} break;
	}
	return CallWindowProc(g_pOldEditProc, hWnd, msg, wParam, lParam);
}

// Die Window-Procedure des Hauptfensters
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg)
	{
	case WM_CREATE:
		{
			wchar_t szRichInitText[4096];
			wsprintf(szRichInitText, L&quot;Microsoft Windows XP [Version 5.1.2600]\n(C) Copyright 1985-2001 Microsoft Corp.\n\n%s&quot;, g_szPrompt);
			g_hRichEdit = CreateWindowEx(0, RICHEDIT_CLASS, szRichInitText, WS_BORDER|WS_VSCROLL|WS_HSCROLL|WS_CHILD|WS_VISIBLE|ES_AUTOHSCROLL|ES_AUTOVSCROLL|ES_MULTILINE|ES_READONLY, 10, 10, 50, 50, hWnd, (HMENU)IDC_RICHEDIT, g_hInstance, NULL);
			if (IsWindow(g_hRichEdit) == FALSE)
			{

				DestroyWindow(hWnd);
				ErrorMessage(L&quot;Ausgabefenster konnte nicht erstellt werden!&quot;);
				return 0;
			}
			SendMessage(g_hRichEdit, EM_SETBKGNDCOLOR, FALSE, RGB(0, 0, 0));
			CHARFORMAT cf = { 0 };
			cf.bCharSet = ANSI_CHARSET;
			cf.bPitchAndFamily = FF_DONTCARE;
			cf.cbSize = sizeof(CHARFORMAT);
			cf.crTextColor = RGB(0, 255, 0);
			cf.dwEffects = 0;
			cf.dwMask = CFM_CHARSET|CFM_COLOR|CFM_FACE;
			wsprintf(cf.szFaceName, L&quot;%s&quot;, L&quot;Courier New&quot;);
			SendMessage(g_hRichEdit, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&amp;cf);
			g_hInputCombo = CreateWindowEx(0, L&quot;COMBOBOX&quot;, L&quot;&quot;, WS_VISIBLE|WS_BORDER|WS_CHILD|CBS_DROPDOWN|CBS_NOINTEGRALHEIGHT|CBS_HASSTRINGS, 10, 70, 50, 50, hWnd, (HMENU)IDC_INPUTCOMBO, g_hInstance, NULL);
			if (IsWindow(g_hInputCombo) == FALSE)
			{

				DestroyWindow(hWnd);
				ErrorMessage(L&quot;Eingabefenster konnte nicht erstellt werden!&quot;);
				return 0;
			}
			POINT pt = { 1, 1 };
			HWND hEdit = ChildWindowFromPoint(g_hInputCombo, pt);
			g_pOldEditProc = (WNDPROC)SetWindowLongPtr(hEdit, GWLP_WNDPROC, (LONG)NewEditProc);
			return 0;
		} break;
	case WM_CLOSE:
		{
			DestroyWindow(hWnd);
			return 0;
		} break;
	case WM_DESTROY:
		{
			PostQuitMessage(0);
			return 0;
		} break;
	case WM_SIZE:
		{
			int width = LOWORD(lParam);
			int height = HIWORD(lParam);
			MoveWindow(g_hRichEdit, 10, 10, width - 20, height - 50, TRUE);
			MoveWindow(g_hInputCombo, 10, height - 30, width - 20, 20, TRUE);
			return 0;
		} break;
	}
	return DefWindowProc(hWnd, msg, wParam, lParam);
}

// Unicode main function
int wmain(int argc, wchar_t** argv)
{
	WNDCLASSEX wce;
	wce.cbClsExtra = 0;
	wce.cbSize = sizeof(WNDCLASSEX);
	wce.cbWndExtra = 0;
	wce.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);
	wce.hCursor = LoadCursor(NULL, IDC_ARROW);
	HICON hIcon = LoadIcon(NULL, IDI_WINLOGO);
	wce.hIcon = hIcon;
	wce.hIconSm = hIcon;
	wce.hInstance = g_hInstance;
	wce.lpfnWndProc = WndProc;
	wce.lpszClassName = szWindowClass;
	wce.lpszMenuName = NULL;
	wce.style = CS_VREDRAW|CS_HREDRAW|CS_BYTEALIGNCLIENT|CS_BYTEALIGNWINDOW|CS_OWNDC|CS_DBLCLKS;
	RegisterClassEx(&amp;wce);
	HWND hWnd = CreateWindowEx(0, szWindowClass, L&quot;Console&quot;, WS_OVERLAPPEDWINDOW, (GetSystemMetrics(SM_CXSCREEN) - 800) / 2, (GetSystemMetrics(SM_CYSCREEN) - 600) / 2, 800, 600, GetDesktopWindow(), NULL, g_hInstance, NULL);
	if (IsWindow(hWnd) == FALSE)
	{
		ErrorMessage(L&quot;Hauptfenster konnte nicht erstellt werden!&quot;);
		return 0;
	}
	ShowWindow(hWnd, SW_SHOW);
	UpdateWindow(hWnd);
	MSG msg;
	while (GetMessage(&amp;msg, NULL, 0, 0))
	{
		TranslateMessage(&amp;msg);
		DispatchMessage(&amp;msg);
	}
	return (int)(msg.wParam);
}

// Program Entry Point
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmdShow)
{
	SHGetFolderPath(NULL, CSIDL_DESKTOPDIRECTORY, NULL, SHGFP_TYPE_CURRENT, g_szCurrentDir);
	SetCurrentDirectory(g_szCurrentDir);
	wsprintf(g_szPrompt, L&quot;%s: &quot;, g_szCurrentDir);
	g_bCanExit = true;
	g_hInstance = hInstance;
	InitCommonControls();
	HMODULE hRichLib = LoadLibrary(L&quot;riched20.dll&quot;);
	if (hRichLib == INVALID_HANDLE_VALUE)
	{
		ErrorMessage(L&quot;Riched20.dll konnte nicht geladen werden!&quot;);
		return 0;
	}
	wchar_t* pCmdLine = GetCommandLine();
	int iArgc;
	wchar_t** szArgv = CommandLineToArgvW(pCmdLine, &amp;iArgc);
	int ret = wmain(iArgc, szArgv);
	LocalFree((HLOCAL)szArgv);
	FreeLibrary(hRichLib);
	return ret;
}
</code></pre>
<p>...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1342989</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1342989</guid><dc:creator><![CDATA[DrakoXP]]></dc:creator><pubDate>Sat, 11 Aug 2007 22:39:34 GMT</pubDate></item><item><title><![CDATA[Reply to Combo Box Subclassen on Sat, 11 Aug 2007 23:25:06 GMT]]></title><description><![CDATA[<p>Könnte ev. sein, dass ChildWindowFromPoint () das Edit-Child nicht gefunden hat, weil z.B. der Rand von der ComboBox sehr &quot;dick&quot; ist.<br />
Probier mal pt zu vergrössern :</p>
<pre><code class="language-cpp">// POINT pt = { 1, 1 };
 POINT pt = { 4, 4 }; // oder ev. grösser
</code></pre>
<p><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>
]]></description><link>https://www.c-plusplus.net/forum/post/1342999</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1342999</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sat, 11 Aug 2007 23:25:06 GMT</pubDate></item><item><title><![CDATA[Reply to Combo Box Subclassen on Sat, 11 Aug 2007 23:41:17 GMT]]></title><description><![CDATA[<p>jippieh <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /> klappt, thx an alle, die sich beteiligt haben</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1343003</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1343003</guid><dc:creator><![CDATA[DrakoXP]]></dc:creator><pubDate>Sat, 11 Aug 2007 23:41:17 GMT</pubDate></item></channel></rss>