<?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[GetDlgItem liefert Null handle]]></title><description><![CDATA[<p>hi,</p>
<p>beim aufruf von GetDlgItem bekomm ich ein null handle zurück und ich verstehe nicht so ganz wieso.</p>
<p>ich erstelle mir einen button und geben dem auch eine ID</p>
<pre><code class="language-cpp">#define BUTTO 3245

LRESULT CALLBACK WndProc(HWND hWnd, UINT uiMessage, WPARAM wParam, LPARAM lParam)
{
	static HWND hDia;
	static HWND hBut=NULL;

    switch(uiMessage)
    {
	case WM_CREATE:
			{
				hBut = CreateWindow(TEXT(&quot;button&quot;), TEXT(&quot;Neues&quot;), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON |WS_TABSTOP,
									0, 0, 0, 0, hWnd, (HMENU) BUTTO, hInst, NULL);
				if (hBut != NULL)
					CreateToolTip(BUTTO, hBut, L&quot;ich bin der doofe tooltiptext&quot;);

				MoveWindow(hBut, 30, 49, 200,200, true);

				break;
			}

................................................

BOOL CreateToolTip(int toolID, HWND hDlg, WCHAR* pText)
{

    if (!toolID || !hDlg || !pText)
    {
        return FALSE;
    }
    // Get the window of the tool.
    HWND hwndTool = GetDlgItem(hDlg, toolID); &lt;--- null handle

..........................
}
</code></pre>
<p>was mach ich falsch, hDlg ist gültig, die id passt auch und trotzdem null handle, woran kann das liegen?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/208627/getdlgitem-liefert-null-handle</link><generator>RSS for Node</generator><lastBuildDate>Fri, 24 Apr 2026 21:02:32 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/208627.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 20 Mar 2008 13:31:52 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to GetDlgItem liefert Null handle on Thu, 20 Mar 2008 13:31:52 GMT]]></title><description><![CDATA[<p>hi,</p>
<p>beim aufruf von GetDlgItem bekomm ich ein null handle zurück und ich verstehe nicht so ganz wieso.</p>
<p>ich erstelle mir einen button und geben dem auch eine ID</p>
<pre><code class="language-cpp">#define BUTTO 3245

LRESULT CALLBACK WndProc(HWND hWnd, UINT uiMessage, WPARAM wParam, LPARAM lParam)
{
	static HWND hDia;
	static HWND hBut=NULL;

    switch(uiMessage)
    {
	case WM_CREATE:
			{
				hBut = CreateWindow(TEXT(&quot;button&quot;), TEXT(&quot;Neues&quot;), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON |WS_TABSTOP,
									0, 0, 0, 0, hWnd, (HMENU) BUTTO, hInst, NULL);
				if (hBut != NULL)
					CreateToolTip(BUTTO, hBut, L&quot;ich bin der doofe tooltiptext&quot;);

				MoveWindow(hBut, 30, 49, 200,200, true);

				break;
			}

................................................

BOOL CreateToolTip(int toolID, HWND hDlg, WCHAR* pText)
{

    if (!toolID || !hDlg || !pText)
    {
        return FALSE;
    }
    // Get the window of the tool.
    HWND hwndTool = GetDlgItem(hDlg, toolID); &lt;--- null handle

..........................
}
</code></pre>
<p>was mach ich falsch, hDlg ist gültig, die id passt auch und trotzdem null handle, woran kann das liegen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1477807</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1477807</guid><dc:creator><![CDATA[osbi]]></dc:creator><pubDate>Thu, 20 Mar 2008 13:31:52 GMT</pubDate></item><item><title><![CDATA[Reply to GetDlgItem liefert Null handle on Thu, 20 Mar 2008 13:36:10 GMT]]></title><description><![CDATA[<p>Als Fehlermeldung liefert mir der GetLastError()<br />
&quot;An attempt has been to operate on an impersonation token by a thread that is not currently impersonating a client&quot;</p>
<p>was heist das den jetzt?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1477808</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1477808</guid><dc:creator><![CDATA[osbi]]></dc:creator><pubDate>Thu, 20 Mar 2008 13:36:10 GMT</pubDate></item><item><title><![CDATA[Reply to GetDlgItem liefert Null handle on Thu, 20 Mar 2008 13:56:45 GMT]]></title><description><![CDATA[<p>osbi schrieb:</p>
<blockquote>
<p>hi,</p>
<pre><code class="language-cpp">if (hBut != NULL)
	CreateToolTip(BUTTO, hBut, L&quot;ich bin der doofe tooltiptext&quot;);
................................................

BOOL CreateToolTip(int toolID, HWND hDlg, WCHAR* pText)
{

    if (!toolID || !hDlg || !pText)
    {
        return FALSE;
    }
    // Get the window of the tool.
    HWND hwndTool = GetDlgItem(hDlg, toolID); &lt;--- null handle

..........................
}
</code></pre>
</blockquote>
<p>Hi,<br />
was willst du mit diesem aufruf von GetDlgItem erreichen? Den Handel von dem Button übergibste ja schon <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="😕"
    /><br />
und 2tens ist die Funktion doch nur für Dialoge gedacht wie der Name schon verrät oder nicht?</p>
<blockquote>
<p>The GetDlgItem function retrieves the handle of a control in the specified dialog box.</p>
<p>Return Values</p>
<p>If the function succeeds, the return value is the window handle of the given control.<br />
If the function fails, the return value is NULL, indicating an invalid dialog box handle or a nonexistent control.</p>
</blockquote>
<p>MFG PinguGroup</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1477825</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1477825</guid><dc:creator><![CDATA[PinguGroup]]></dc:creator><pubDate>Thu, 20 Mar 2008 13:56:45 GMT</pubDate></item><item><title><![CDATA[Reply to GetDlgItem liefert Null handle on Sat, 22 Mar 2008 01:02:18 GMT]]></title><description><![CDATA[<p>PinguGroup schrieb:</p>
<blockquote>
<p>und 2tens ist die Funktion doch nur für Dialoge gedacht wie der Name schon verrät oder nicht?</p>
</blockquote>
<p>Oder nicht. Warum sollte man sie nicht auch in Fensteranwendungen benutzen? Hat den Vorteil, dass man keine globalen Varaiblen für die Fensterhandles benötigt. Die IDs sind ja sowieso Konstanten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1478579</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1478579</guid><dc:creator><![CDATA[_Luckie]]></dc:creator><pubDate>Sat, 22 Mar 2008 01:02:18 GMT</pubDate></item></channel></rss>