title: How to create control buttons exactly like Window's (OS) control buttons in wxWidgets?
body: <p>I want to create control buttons (minimize, maximize and close) exaclty like Windows.</p>
  <p>The final goal is to create something like the title bar of Microsoft Word.</p>
  <p><a href="https://i.stack.imgur.com/D7zyF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/D7zyF.png" alt="enter image description here" /></a></p>
  <p>I know how to create a wxButton and also I know how to set an icon for it. However I don't know how to use native OS icons or theme.</p>
  <pre><code>wxButton* closeButton = new wxButton(this, wxID_ANY, &quot;x&quot;); // how to tell that be like OS close button!
  </code></pre>
  <p>In WinAPI, there is a function called <a href="http://msdn.microsoft.com/en-us/library/bb773289%28VS.85%29.aspx" rel="nofollow noreferrer">DrawThemeBackground</a> which I can use with <code>WP_CLOSEBUTTON</code> but I don't know what's the equivalent in wxWidgets.</p>
  <p>Update: With the help of all of you, this is a sample code for drawing native buttons in Windows (not work in other OS). Unfortunately, the result is not what I want. It looks like Win XP icons. It seems that wxNativeRenderer does not work properly. Does anybody have any idea to fix this code? (Yes, I have added &quot;wx.rc&quot; resource file and I don't use any manifest)</p>
  <p><a href="https://i.stack.imgur.com/W7sXG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/W7sXG.png" alt="enter image description here" /></a></p>
  <pre><code>// wxWidgets &quot;Hello World&quot; Program
  // For compilers that support precompilation, includes &quot;wx/wx.h&quot;.
  #include &lt;wx/wxprec.h&gt;
  #ifndef WX_PRECOMP
  #include &lt;wx/wx.h&gt;
  #endif
  #include &lt;wx/renderer.h&gt;
  #include &lt;wx/artprov.h&gt;
  class MyApp: public wxApp
  {
  public:
    virtual bool OnInit();
  };
  
  class MyFrame: public wxFrame
  {
  public:
    MyFrame();
  private:
  };
  wxIMPLEMENT_APP( MyApp );
  bool MyApp::OnInit()
  {
    MyFrame* frame = new MyFrame();
    frame-&gt;Show( true );
    return true;
  }
  
  wxBitmap getButtonBitmap( wxWindow* win, wxTitleBarButton type, const wxColour&amp; bg, int flags = 0 )
  {
    const wxSize sizeBmp = wxArtProvider::GetSizeHint( wxART_BUTTON );
    wxBitmap bmp( sizeBmp );
    wxMemoryDC dc( bmp );
    dc.SetBackground( bg );
    dc.Clear();
    wxRendererNative::Get().DrawTitleBarBitmap( win, dc, sizeBmp, type, flags );
    return bmp;
  }
  
  MyFrame::MyFrame()
    : wxFrame( NULL, wxID_ANY, &quot;Hello World&quot; )
  {
    wxWindow* win = this;
    wxColour color = win-&gt;GetBackgroundColour();
    // minimize button
    wxBitmapButton* minimizeButton = new wxBitmapButton( win, wxID_ANY,
     getButtonBitmap( win, wxTITLEBAR_BUTTON_ICONIZE, color ),
     wxPoint( 0, 0 ), wxDefaultSize, wxBORDER_NONE );
    minimizeButton-&gt;SetBitmapPressed( getButtonBitmap( win, wxTITLEBAR_BUTTON_ICONIZE, color, wxCONTROL_PRESSED ) );
    minimizeButton-&gt;SetBitmapCurrent( getButtonBitmap( win, wxTITLEBAR_BUTTON_ICONIZE, color, wxCONTROL_CURRENT ) );
    // maximize button
    wxBitmapButton* maximizeButton = new wxBitmapButton( win, wxID_ANY,
     getButtonBitmap( win, wxTITLEBAR_BUTTON_MAXIMIZE, color ),
     wxPoint( 30, 0 ), wxDefaultSize, wxBORDER_NONE );
    maximizeButton-&gt;SetBitmapPressed( getButtonBitmap( win, wxTITLEBAR_BUTTON_MAXIMIZE, color, wxCONTROL_PRESSED ) );
    maximizeButton-&gt;SetBitmapCurrent( getButtonBitmap( win, wxTITLEBAR_BUTTON_MAXIMIZE, color, wxCONTROL_CURRENT ) );
    // close Button
    wxBitmapButton* closeButton = new wxBitmapButton( win, wxID_ANY,
     getButtonBitmap( win, wxTITLEBAR_BUTTON_CLOSE, color ),
     wxPoint( 60, 0 ), wxDefaultSize, wxBORDER_NONE );
    closeButton-&gt;SetBitmapPressed( getButtonBitmap( win, wxTITLEBAR_BUTTON_CLOSE, color, wxCONTROL_PRESSED ) );
    closeButton-&gt;SetBitmapCurrent( getButtonBitmap( win, wxTITLEBAR_BUTTON_CLOSE, color, wxCONTROL_CURRENT ) );
  }
  </code></pre>