<?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[OWNERDRAW (Button)]]></title><description><![CDATA[<p>Hi!<br />
Ich habe schon in der FAQ gelesen und die Suchfunktion benutzt, falls ich das jetzt denkt. <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="😃"
    /></p>
<p>Folgendes. Ich würde meine Buttons jetzt gerne komplett selber zeichnen, also OWNERDRAW verwenden. So weit bin ich gekommen:</p>
<pre><code class="language-cpp">case WM_CREATE:
        {
            hButton = CreateWindowEx(NULL, &quot;button&quot;, &quot;BUTTON1&quot;, WS_VISIBLE | WS_CHILD | BS_OWNERDRAW, 100, 100, 300, 50, hWnd, (HMENU)IDC_BUTTON, hInst, NULL);
            return true;
        }
        case WM_DRAWITEM:
        {
            LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam;
            HBRUSH hBrush = NULL;
            switch(dis-&gt;CtlID)
            {
                case IDC_BUTTON:
                {
                    SetTextColor(dis-&gt;hDC, RGB(0, 0, 255));
                    TextOut(dis-&gt;hDC, 20, 20, &quot;Mein Ownerdraw Button&quot;, strlen(&quot;Mein Ownerdraw Button&quot;));
                    break;
                }
                break;
            }
            DeleteObject(hBrush);
            break;
        }
</code></pre>
<p>Der Button sieht noch unmöglich aus, es ist eine einfache graue Fläche mit einem blauen Text darin. Wenn man darauf klickt, kann ich zwar einfach den Klick abfragen, aber der Button &quot;vertieft&quot; sich nicht solange man mit der Maus darauf klickt...</p>
<p>Mein Fragen:<br />
Wie bekommt man es hin, dass es ein PUSHBUTTON wird?<br />
Wenn man noch darüber hinausgeht, wie schafft man solche Buttons, die erst garkein Rand haben, und wenn man mit der Maus darüberfährt kommt ein Rand darum heraus?<br />
Achja noch GANZ wichtig, darum geht es mir: wie bekomme ich ein Bild auf den Button per OWNERDRAW? Kann ich in den DC beliebig zeichen, ein Bild links hinsetzen, und rechts Text hinschreiben? Ist möglich oder?</p>
<p>Tja ein paar Fragen. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /><br />
Aber ich denke es geht in Ordnung und Ihr wisst Antwort?<br />
Würde mich freuen...<br />
Jetzt aber Schluss...<br />
bye</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/15245/ownerdraw-button</link><generator>RSS for Node</generator><lastBuildDate>Mon, 27 Apr 2026 12:51:49 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/15245.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 02 Nov 2002 00:52:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to OWNERDRAW (Button) on Sat, 02 Nov 2002 00:52:00 GMT]]></title><description><![CDATA[<p>Hi!<br />
Ich habe schon in der FAQ gelesen und die Suchfunktion benutzt, falls ich das jetzt denkt. <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="😃"
    /></p>
<p>Folgendes. Ich würde meine Buttons jetzt gerne komplett selber zeichnen, also OWNERDRAW verwenden. So weit bin ich gekommen:</p>
<pre><code class="language-cpp">case WM_CREATE:
        {
            hButton = CreateWindowEx(NULL, &quot;button&quot;, &quot;BUTTON1&quot;, WS_VISIBLE | WS_CHILD | BS_OWNERDRAW, 100, 100, 300, 50, hWnd, (HMENU)IDC_BUTTON, hInst, NULL);
            return true;
        }
        case WM_DRAWITEM:
        {
            LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam;
            HBRUSH hBrush = NULL;
            switch(dis-&gt;CtlID)
            {
                case IDC_BUTTON:
                {
                    SetTextColor(dis-&gt;hDC, RGB(0, 0, 255));
                    TextOut(dis-&gt;hDC, 20, 20, &quot;Mein Ownerdraw Button&quot;, strlen(&quot;Mein Ownerdraw Button&quot;));
                    break;
                }
                break;
            }
            DeleteObject(hBrush);
            break;
        }
</code></pre>
<p>Der Button sieht noch unmöglich aus, es ist eine einfache graue Fläche mit einem blauen Text darin. Wenn man darauf klickt, kann ich zwar einfach den Klick abfragen, aber der Button &quot;vertieft&quot; sich nicht solange man mit der Maus darauf klickt...</p>
<p>Mein Fragen:<br />
Wie bekommt man es hin, dass es ein PUSHBUTTON wird?<br />
Wenn man noch darüber hinausgeht, wie schafft man solche Buttons, die erst garkein Rand haben, und wenn man mit der Maus darüberfährt kommt ein Rand darum heraus?<br />
Achja noch GANZ wichtig, darum geht es mir: wie bekomme ich ein Bild auf den Button per OWNERDRAW? Kann ich in den DC beliebig zeichen, ein Bild links hinsetzen, und rechts Text hinschreiben? Ist möglich oder?</p>
<p>Tja ein paar Fragen. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /><br />
Aber ich denke es geht in Ordnung und Ihr wisst Antwort?<br />
Würde mich freuen...<br />
Jetzt aber Schluss...<br />
bye</p>
]]></description><link>https://www.c-plusplus.net/forum/post/82414</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/82414</guid><dc:creator><![CDATA[ChrisK]]></dc:creator><pubDate>Sat, 02 Nov 2002 00:52:00 GMT</pubDate></item><item><title><![CDATA[Reply to OWNERDRAW (Button) on Sat, 02 Nov 2002 09:49:00 GMT]]></title><description><![CDATA[<p>Du musst noch den Zustand des Buttons bestimmen bevor du es malst.<br />
Dann nimmst du einfach zwei Grafiken normal und eingedrückt.</p>
<pre><code class="language-cpp">case WM_CREATE:
        {
            hButton = CreateWindowEx(NULL, &quot;button&quot;, &quot;BUTTON1&quot;, WS_VISIBLE | WS_CHILD | BS_OWNERDRAW, 100, 100, 300, 50, hWnd, (HMENU)IDC_BUTTON, hInst, NULL);
            return true;
        }
        case WM_DRAWITEM:
        {
            LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam;
            HBRUSH hBrush = NULL;
            switch(dis-&gt;CtlID)
            {
                case IDC_BUTTON:
                {
                    switch(LPDRAWITEMSTRUCT-&gt;itemState)
                    {
                       case ODS_DEFAULT:
                    SetTextColor(dis-&gt;hDC, RGB(0, 0, 255));
                    TextOut(dis-&gt;hDC, 20, 20, &quot;Mein Ownerdraw Button&quot;, strlen(&quot;Mein Ownerdraw Button&quot;));
                       break;
                       case ODS_SELECTED
                       //
                       break;
                    }
                    break;
                }
                break;
            }
            DeleteObject(hBrush);
            break;
        }
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/82415</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/82415</guid><dc:creator><![CDATA[stealth]]></dc:creator><pubDate>Sat, 02 Nov 2002 09:49:00 GMT</pubDate></item><item><title><![CDATA[Reply to OWNERDRAW (Button) on Sat, 02 Nov 2002 11:53:00 GMT]]></title><description><![CDATA[<p>Also irgendwie funzt das dann garnix mehr.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/82416</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/82416</guid><dc:creator><![CDATA[ChrisK]]></dc:creator><pubDate>Sat, 02 Nov 2002 11:53:00 GMT</pubDate></item><item><title><![CDATA[Reply to OWNERDRAW (Button) on Sat, 02 Nov 2002 13:05:00 GMT]]></title><description><![CDATA[<p>Naja, anstatt:</p>
<pre><code class="language-cpp">switch(LPDRAWITEMSTRUCT-&gt;itemState)
</code></pre>
<p>muss es natürlich heißen:</p>
<pre><code class="language-cpp">switch(dis-&gt;itemState)
</code></pre>
<p>Unter ODS_DEFAULT malst du dann den Button wie er &quot;normal&quot; aussehen soll und unter ODS_SELECTED wie er &quot;gedrückt&quot; aussehen soll.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/82417</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/82417</guid><dc:creator><![CDATA[macphistox2002]]></dc:creator><pubDate>Sat, 02 Nov 2002 13:05:00 GMT</pubDate></item><item><title><![CDATA[Reply to OWNERDRAW (Button) on Sat, 02 Nov 2002 13:11:00 GMT]]></title><description><![CDATA[<blockquote>
<p>Also irgendwie funzt das dann garnix mehr.</p>
</blockquote>
<p>Aha. Jetzt weiß ich genau bescheid. Prima Problembeschreibung. Hut ab.</p>
<p>Nochmal: In der DRAWITEMSTRUCT gibt es Member namens 'itemState'. Daran siehst Du, ob der Button nun gedrückt ist oder nicht. Und erzähle bitte nicht, daß der Artikel in den FAQs das nicht berücksichtigt.</p>
<p>Allerdings hat geeky die Buttons komplett selbst gezeichnet. Einfacher wird es, wenn man die Funktion DrawFrameControl() für sich entdeckt hat.</p>
<p>BTW: Wenn Ihr das unter XP laufen lassen und auch die Controls der Version 6 verwenden wollt, ist alles wieder ganz anders ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/82418</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/82418</guid><dc:creator><![CDATA[-King-]]></dc:creator><pubDate>Sat, 02 Nov 2002 13:11:00 GMT</pubDate></item><item><title><![CDATA[Reply to OWNERDRAW (Button) on Sat, 02 Nov 2002 13:23:00 GMT]]></title><description><![CDATA[<p>-King-, du bist der King! Jetzt hab ich das auch mal gecheckt! <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="😃"
    /></p>
<p>thx thx thx!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/82419</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/82419</guid><dc:creator><![CDATA[MagiC Creator]]></dc:creator><pubDate>Sat, 02 Nov 2002 13:23:00 GMT</pubDate></item><item><title><![CDATA[Reply to OWNERDRAW (Button) on Sat, 02 Nov 2002 13:40:00 GMT]]></title><description><![CDATA[<blockquote>
<p>Also irgendwie funzt das dann garnix mehr.</p>
<p>Aha. Jetzt weiß ich genau bescheid. Prima Problembeschreibung. Hut ab.</p>
</blockquote>
<p>MUAHAHAHAHAHAHAHAHAHAHAHAHHAHA!! Das musste mal sein. Sorry.<br />
Ne also es lag nicht daran dass ich mein Problem nicht beschreiben konnte sondern weil 'stealth' das falsch erklärt hat. Man darf die States nicht mit case abfragen.</p>
<pre><code class="language-cpp">if(dis-&gt;itemState &amp; ODS_FOCUS)
                    {
                        SetTextColor(dis-&gt;hDC, RGB(0, 0, 255));
                        TextOut(dis-&gt;hDC, 20, 20, &quot;Mein Ownerdraw Button&quot;, strlen(&quot;Mein Ownerdraw Button&quot;));
                    }
                    if(dis-&gt;itemState &amp; ODS_SELECTED)
                    {
                        SetTextColor(dis-&gt;hDC, RGB(0, 0, 255));
                        TextOut(dis-&gt;hDC, 21, 21, &quot;Mein Ownerdraw Button&quot;, strlen(&quot;Mein Ownerdraw Button&quot;));
                    }
</code></pre>
<p>Geht bei mir wunderbar. Das ganze was ich bis jetzt getan hab ist den Button (den Rand) ganz selbst zu zeichnen:</p>
<pre><code class="language-cpp">LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch(message)
    {
        case WM_CREATE:
        {
            hButton = CreateWindowEx(NULL, &quot;button&quot;, &quot;BUTTON1&quot;, WS_VISIBLE | WS_CHILD | BS_NOTIFY | BS_OWNERDRAW, 100, 100, 300, 50, hWnd, (HMENU)IDC_BUTTON, hInst, NULL);
            return true;
        }
        case WM_DRAWITEM:
        {
            LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam;
            HPEN hPen1 = NULL;
            HPEN hPen2 = NULL;
            HPEN hPen3 = NULL;
            HPEN hPen4 = NULL;
            switch(dis-&gt;CtlID)
            {
                case IDC_BUTTON:
                {
                    //Rectangle(dis-&gt;hDC, dis-&gt;rcItem.left, dis-&gt;rcItem.top, dis-&gt;rcItem.right, dis-&gt;rcItem.bottom);

                    SetTextColor(dis-&gt;hDC, RGB(0, 0, 255));
                    TextOut(dis-&gt;hDC, 20, 20, &quot;Mein Ownerdraw Button&quot;, strlen(&quot;Mein Ownerdraw Button&quot;));
                    hPen1 = CreatePen(PS_SOLID, 0, RGB(255, 255, 255));
                    hPen2 = CreatePen(PS_SOLID, 0, RGB(230, 230, 230));
                    hPen3 = CreatePen(PS_SOLID, 0, RGB(170, 170, 170));
                    hPen4 = CreatePen(PS_SOLID, 0, RGB(110, 110, 110));

                    SelectObject(dis-&gt;hDC, (HPEN)hPen1);
                    MoveToEx(dis-&gt;hDC, dis-&gt;rcItem.left,  dis-&gt;rcItem.top, (LPPOINT)NULL);
                    LineTo  (dis-&gt;hDC, dis-&gt;rcItem.right - 1, dis-&gt;rcItem.top);
                    MoveToEx(dis-&gt;hDC, dis-&gt;rcItem.left,  dis-&gt;rcItem.top, (LPPOINT)NULL);
                    LineTo  (dis-&gt;hDC, dis-&gt;rcItem.left,  dis-&gt;rcItem.bottom - 1);

                    SelectObject(dis-&gt;hDC, (HPEN)hPen2);
                    MoveToEx(dis-&gt;hDC, dis-&gt;rcItem.left + 1,  dis-&gt;rcItem.top + 1, (LPPOINT)NULL);
                    LineTo  (dis-&gt;hDC, dis-&gt;rcItem.right - 2, dis-&gt;rcItem.top + 1);
                    MoveToEx(dis-&gt;hDC, dis-&gt;rcItem.left + 1,  dis-&gt;rcItem.top + 1, (LPPOINT)NULL);
                    LineTo  (dis-&gt;hDC, dis-&gt;rcItem.left + 1,  dis-&gt;rcItem.bottom - 2);

                    SelectObject(dis-&gt;hDC, (HPEN)hPen3);
                    MoveToEx(dis-&gt;hDC, dis-&gt;rcItem.left + 1,  dis-&gt;rcItem.bottom - 2, (LPPOINT)NULL);
                    LineTo  (dis-&gt;hDC, dis-&gt;rcItem.right - 1, dis-&gt;rcItem.bottom - 2);
                    MoveToEx(dis-&gt;hDC, dis-&gt;rcItem.right - 2,  dis-&gt;rcItem.bottom - 2, (LPPOINT)NULL);
                    LineTo  (dis-&gt;hDC, dis-&gt;rcItem.right - 2,  dis-&gt;rcItem.top);

                    SelectObject(dis-&gt;hDC, (HPEN)hPen4);
                    MoveToEx(dis-&gt;hDC, dis-&gt;rcItem.left - 1,  dis-&gt;rcItem.bottom - 1, (LPPOINT)NULL);
                    LineTo  (dis-&gt;hDC, dis-&gt;rcItem.right - 1, dis-&gt;rcItem.bottom - 1);
                    MoveToEx(dis-&gt;hDC, dis-&gt;rcItem.right - 1,  dis-&gt;rcItem.bottom - 1, (LPPOINT)NULL);
                    LineTo  (dis-&gt;hDC, dis-&gt;rcItem.right - 1,  dis-&gt;rcItem.top - 1);

                    if(dis-&gt;itemState &amp; ODS_CHECKED)
                    {
                        SetTextColor(dis-&gt;hDC, RGB(0, 0, 255));
                        TextOut(dis-&gt;hDC, 20, 20, &quot;ODS_CHECKED&quot;, strlen(&quot;ODS_CHECKED&quot;));
                    }
                    if(dis-&gt;itemState &amp; ODS_COMBOBOXEDIT)
                        MessageBox(hWnd, &quot;ODS_COMBOBOXEDIT&quot;, &quot;Notification&quot;, 0);
                    if(dis-&gt;itemState &amp; ODS_DEFAULT)
                        MessageBox(hWnd, &quot;ODS_DEFAULT&quot;, &quot;Notification&quot;, 0);
                    if(dis-&gt;itemState &amp; ODS_DEFAULT)
                        MessageBox(hWnd, &quot;ODS_DISABLED&quot;, &quot;Notification&quot;, 0);
                    if(dis-&gt;itemState &amp; ODS_DISABLED)
                        MessageBox(hWnd, &quot;ODS_FOCUS&quot;, &quot;Notification&quot;, 0);
                    if(dis-&gt;itemState &amp; ODS_FOCUS)
                    {
                        SetTextColor(dis-&gt;hDC, RGB(0, 0, 255));
                        TextOut(dis-&gt;hDC, 20, 20, &quot;Mein Ownerdraw Button&quot;, strlen(&quot;Mein Ownerdraw Button&quot;));
                    }
                    if(dis-&gt;itemState &amp; ODS_GRAYED)
                    {
                        SetTextColor(dis-&gt;hDC, RGB(0, 0, 255));
                        TextOut(dis-&gt;hDC, 20, 20, &quot;ODS_GRAYED&quot;, strlen(&quot;ODS_GRAYED&quot;));
                    }
                    if(dis-&gt;itemState &amp; ODS_INACTIVE)
                        MessageBox(hWnd, &quot;ODS_INACTIVE&quot;, &quot;Notification&quot;, 0);
                    if(dis-&gt;itemState &amp; ODS_SELECTED)
                    {
                        SetTextColor(dis-&gt;hDC, RGB(0, 0, 255));
                        TextOut(dis-&gt;hDC, 21, 21, &quot;Mein Ownerdraw Button&quot;, strlen(&quot;Mein Ownerdraw Button&quot;));
                    }
                    break;
                }
                break;
            }
            DeleteObject(hPen1);
            DeleteObject(hPen2);
            DeleteObject(hPen3);
            DeleteObject(hPen4);
            break;
        }
        case WM_DESTROY:
        {
            PostQuitMessage(0);
            break;
        }
        break;
    }
    return DefWindowProc (hWnd, message, wParam, lParam);
}
</code></pre>
<p>Greez Chris|K</p>
]]></description><link>https://www.c-plusplus.net/forum/post/82420</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/82420</guid><dc:creator><![CDATA[ChrisK]]></dc:creator><pubDate>Sat, 02 Nov 2002 13:40:00 GMT</pubDate></item><item><title><![CDATA[Reply to OWNERDRAW (Button) on Fri, 18 Jan 2008 13:26:22 GMT]]></title><description><![CDATA[<p>Diese States sind ja alle ganz schön, aber es gibt keinen über den ich erfahre, dass die Maus über meinem Button ist.</p>
<p>Wie kann man das anders machen?</p>
<p>Ich hab schon versucht über WM_MOUSEMOVE des Parent-Fensters die Maus-Koordinaten mit den Feld-Koordinaten meiner Buttons abzugleichen, aber wie ich feststellen musste, erhält mein Parent-Fenster die Nachricht WM_MOUSEMOVE nicht mehr sobald ich auf einen meiner Buttons fahre. Dann ist halt ein anderes Fenster aktiv.</p>
<p>Ich quäle mich jetzt schon seit gestern Vormittag damit und wäre hocherfreut, wenn mir mal jemand die Augen öffnen könnte.</p>
<p>lg Max</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1438992</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1438992</guid><dc:creator><![CDATA[MaDsTyLe]]></dc:creator><pubDate>Fri, 18 Jan 2008 13:26:22 GMT</pubDate></item><item><title><![CDATA[Reply to OWNERDRAW (Button) on Fri, 18 Jan 2008 13:38:58 GMT]]></title><description><![CDATA[<p>TrackMouseEvent</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1439012</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1439012</guid><dc:creator><![CDATA[hmmmmmmmm]]></dc:creator><pubDate>Fri, 18 Jan 2008 13:38:58 GMT</pubDate></item><item><title><![CDATA[Reply to OWNERDRAW (Button) on Fri, 18 Jan 2008 14:14:22 GMT]]></title><description><![CDATA[<p>Danke!</p>
<p>lg Max</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1439061</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1439061</guid><dc:creator><![CDATA[MaDsTyLe]]></dc:creator><pubDate>Fri, 18 Jan 2008 14:14:22 GMT</pubDate></item></channel></rss>