wxStaticBitmap 没有名为 "SetScaleMode()" 的成员

wxStaticBitmap has no member named "SetScaleMode()"

本文关键字:成员 SetScaleMode wxStaticBitmap      更新时间:2023-10-16

对不起这个问题(可能很愚蠢),但是我很困惑:我尝试使用文档中所述的SetScaleMode()在WXWIDGETS v3.0.2中缩放位图。尽管我的编译器(CCC遵循C 11)表示'class wxStaticBitmap' has no member named 'SetScaleMode'|'Scale_AspectFit' was not declared in this scope|,但我使用了Incluble语句。也许我忽略了一些东西,下面是我的(缩短)代码:

#include <wx/msgdlg.h>
#include <wx/thread.h>
#include <wx/event.h>
#include <wx/statbmp.h>
//(*InternalHeaders(WindowsDgpsGUIFrame)
#include <wx/bitmap.h>
#include <wx/icon.h>
#include <wx/intl.h>
#include <wx/image.h>
#include <wx/string.h>
//*)

//wxTextFile file;

//helper functions
enum wxbuildinfoformat {
    short_f, long_f };
wxString wxbuildinfo(wxbuildinfoformat format)
{
    wxString wxbuild(wxVERSION_STRING);
    if (format == long_f )
    {
#if defined(__WXMSW__)
        wxbuild << _T("-Windows");
#elif defined(__UNIX__)
        wxbuild << _T("-Linux");
#endif
#if wxUSE_UNICODE
        wxbuild << _T("-Unicode build");
#else
        wxbuild << _T("-ANSI build");
#endif // wxUSE_UNICODE
    }
    return wxbuild;
}

//(*IdInit(WindowsDgpsGUIFrame)
const long WindowsDgpsGUIFrame::ID_STATICBITMAP1 = wxNewId();
const long WindowsDgpsGUIFrame::ID_PANEL1 = wxNewId();

BEGIN_EVENT_TABLE(WindowsDgpsGUIFrame,wxFrame)
    //(*EventTable(WindowsDgpsGUIFrame)
    //*)
END_EVENT_TABLE()

WindowsDgpsGUIFrame::WindowsDgpsGUIFrame(wxWindow* parent,wxWindowID id)
{
    //(*Initialize(WindowsDgpsGUIFrame)
    wxBoxSizer* pBitmapBoxSizer;
    wxBoxSizer* pPanelBoxSizer;
    Create(parent, wxID_ANY, _("SensoRun"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE|wxMAXIMIZE_BOX, _T("wxID_ANY"));
    SetForegroundColour(wxColour(187,0,0));
    SetBackgroundColour(wxColour(128,128,128));
    {
        wxIcon FrameIcon;
        FrameIcon.CopyFromBitmap(wxBitmap(wxImage(_T(".\resources\sd.ico"))));
        SetIcon(FrameIcon);
    }
    pPanel = new wxPanel(this, ID_PANEL1, wxPoint(280,352), wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL1"));
    pPanelBoxSizer = new wxBoxSizer(wxVERTICAL);
    pBitmapBoxSizer = new wxBoxSizer(wxVERTICAL);
    StaticDirectionBitmap = new wxStaticBitmap(pPanel, ID_STATICBITMAP1, wxBitmap(wxImage(_T(".\resources\kein_pfeil.png"))), wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER, _T("ID_STATICBITMAP1"));
    pBitmapBoxSizer->Add(StaticDirectionBitmap, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
    pPanelBoxSizer->Add(pBitmapBoxSizer, 1, wxALL|wxEXPAND|wxFIXED_MINSIZE|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
    StaticDirectionBitmap->SetScaleMode(Scale_AspectFit);
}

(我希望我没有在此片段中删除一些重要的内容,我想让它更容易阅读)

您可以肯定地在链接到的文档中看到, wxStaticBitmap::SetScaleMode()在使用 Since 3.1.0,而当您使用" wxwidgets v3.0.2"时。因此,只需升级到正确的版本。