开发者

Cannot get a proper Vista / 7 theme for toolbar with wxWidgets

I cannot get a proper theme for toolbars in Vista / 7 with wxWidgets (c++). For some unknown reason, I get gray bar now (as you can see here). I want it to get this look instead. I've linked against comctl32.lib (=> 5.82) and UXTHEME is on. Here's the code:


#include <wx/wx.h>

class TestAppFrame: public wxFrame
{
        public:
                TestAppFrame(wxWindow *parent,
                             wxWindowID id = wxID_ANY,
                             const wxString &title = wxT("Test"),
                             const wxPoint &position = wxDefaultPosition,
                             const wxSize &size = wxSize(373, 206),
                             long style = wxDEFAULT_FRAME_STYLE | wxTAB_TRAVERSAL)
                : wxFrame(parent, id, title, position, size, style)
                {
                        wxToolBar *tb = CreateToolBar(wxNO_BORDER | wxHORIZONTAL | wxTB_FLAT);

                        tb->Realize();

                        SetToolBar(tb);
                }
};

class TestApp: public wxApp
{
        public:
                bool OnInit()
                {
                        if (!wxApp::OnInit())
                                return false;

                   开发者_开发技巧     wxInitAllImageHandlers();

                        TestAppFrame *frame = new TestAppFrame(NULL);

                        frame->Show(true);

                        return true;
                }
};

IMPLEMENT_APP(TestApp)

What am I doing wrong here?

Best regards,

nhaa123


The gradient rebar-like background is actually inappropriate for toolbars under Vista/7, if you look at any native applications using toolbars and not rebars or ribbons (which are, admittedly, a bit hard to find nowadays) you can see that they have the same grey background so we decided that this was the correct thing to do.

You should be able to paint the background of the toolbar on your own in EVT_ERASE_BACKGROUND event but by default wx tries to behave conforming to the platform standards and in this case this means not using any gradients.


You want to use wxAUIToolbar. It has the look you described and is compatible with wxToolbar, so you can use it anywhere you would use a wxToolbar.

I would point you to the documentation, except there is none. (I have an open question about that myself)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜