[英]wxStaticBitmap constructor takes wxGDIImage instead of wxBitmap
I'm trying to create a static bitmap but the constructor only accepts wxGDIImages. 我正在尝试创建静态位图,但构造函数仅接受wxGDIImages。 Here is the code from the FormBuilder:
这是FormBuilder中的代码:
wxStaticBitmap* tmtBitmap = new wxStaticBitmap( this, wxID_ANY, wxBitmap( wxT("directory"), wxBITMAP_TYPE_ANY ), wxDefaultPosition, wxDefaultSize, 0 );
Is there any way to convert the wxBitmap to a wxGDIImage? 有什么方法可以将wxBitmap转换为wxGDIImage吗? Or create a wxGDIImage given the directory?
还是创建给定目录的wxGDIImage?
Maybe there is another way to do this. 也许还有另一种方法可以做到这一点。
Thanks. 谢谢。
wxStaticBitmap
does accept wxBitmap
in its constructor ( wx API-Doc ) wxStaticBitmap
确实在其构造函数中接受wxBitmap
( wx API-Doc )
The error message produced by the compiler might be a bit misleading im guessing you see something like this: 编译器产生的错误消息可能会误导您,以为您看到以下内容:
include/wx/msw/statbmp.h:80: note: candidates are: wxStaticBitmap::wxStaticBitmap(const wxStaticBitmap&)
include/wx/msw/statbmp.h:34: note: wxStaticBitmap::wxStaticBitmap(wxWindow*, wxWindowID, const wxGDIImage&, const wxPoint&, const wxSize&, long int, const wxString&)
include/wx/msw/statbmp.h:25: note: wxStaticBitmap::wxStaticBitmap()
Since it is the only thing context depending, there seems to be a problem with your this
pointer, either you are not "inside" a wxWindow
or your compiler can't figure out the static type. 由于这是唯一取决于上下文的东西,因此您的
this
指针似乎存在问题,要么您不在wxWindow
“内部”,要么您的编译器无法确定静态类型。 You can use something like this to verify: (don't do that in productive code) 您可以使用类似这样的方法来验证:(不要在生产性代码中这样做)
wxStaticBitmap* tmtBitmap = new wxStaticBitmap( (wxWindow*)NULL, wxID_ANY, wxBitmap( wxT("directory"), wxBITMAP_TYPE_ANY ), wxDefaultPosition, wxDefaultSize, 0 );
or 要么
wxStaticBitmap* tmtBitmap = new wxStaticBitmap( (wxWindow*)this, wxID_ANY, wxBitmap( wxT("directory"), wxBITMAP_TYPE_ANY ), wxDefaultPosition, wxDefaultSize, 0 );
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.