If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
It's unclear to me what you're trying to achieve. Where do you want to access the Frame pointer? Inside ProcessEvent(), you could just use "this", if that's what you mean.
However, it's very unusual to override wxWindow::ProcessEvent(), especially for a beginner. Is there a special reason for you to do that, or did you just not know how else to receive and process events?
wxFrame* frame = new wxFrame(NULL, wxID_ANY, "Test", wxDefaultPosition, wxSize(600, 400));
^^^that is what I want to do, after the class constructor creates the frame, of course.
@doublemax
I'm just pulling stuff from various tutorials and examples trying to learn/absorb how the gui works. All I'm trying to accomplish with that particular code is to create an EVT_SIZE event, and that snipped of code was the first I came across that worked for me
m_frame = new wxFrame(NULL, wxID_ANY, "Test", wxDefaultPosition, wxSize(600, 400));
All I'm trying to accomplish with that particular code is to create an EVT_SIZE event, and that snipped of code was the first I came across that worked for me
class Frame : public wxFrame {
public:
Frame() : wxFrame(nullptr, wxID_ANY, "Frame and events")
{
m_panel = new wxPanel(this);
// other samples might use a static event table, both methods are ok
Bind(wxEVT_SIZE, &Frame::Onsize, this);
}
private:
void OnSize (wxSizeEvent &event)
{
wxLogDebug("onsize: %d %d", event.GetSize().x, event.GetSize().y );
// call event.Skip() if you want event processing to continue
// for size events this is important, because e.g. the
// wxSizer layout algorithm depends on it
event.Skip();
}
wxPanel *m_panel;
};
So please correct if/when I'm wrong, but in the original code I provided, the constructor defines/creates the Frame? My issue is that when I initiate the constructor from a different class, I can't seem to figure out how to store the pointer--the constructor doesn't seem to return this information.
Interestingly, I tried your suggested code for the event binding, and it threw up some errors. The errors look similar to those I've seen when trying to bind events previously:
E0304 no instance of overloaded function "Examples::Frame::Bind" matches the argument list wxTexter2 C:\Visual Projects\wxTexter2\Application.cpp 160
E0135 class "Examples::Frame" has no member "Onsize" wxTexter2 C:\Visual Projects\wxTexter2\Application.cpp 160
C2039 'Onsize': is not a member of 'Examples::Frame' wxTexter2 C:\Visual Projects\wxTexter2\Application.cpp 160
C2065 'Onsize': undeclared identifier wxTexter2 C:\Visual Projects\wxTexter2\Application.cpp 160
[update]
I'm not sure what I was doing incorrectly, but I tried your binding code and this time it worked Probably an inattention to detail.
That worked, thanks a million! I appreciate the help
@ONEEYEMAN
Possibly? Originally I was interested in wxLua--it's actually how I discovered wx. But I've been looking for an excuse to learn any/more c++ and wxLua doesn't seem to be as well documented or have as much community support?
Idk. I could easily be wrong, those are just my assumptions based on minimal research.
@doublemax,
He needs to learn C++ first .
@OP:
wxWidgets is an advanced library. It will be very hard to learn and understand wxWidgets and C++ at one shot.
I suggest to try and sign up for some C++ classes in local college and then when you have a grip on the language come back to wxWidgets.
It will be easier and more appropriate.
In the meantime - maybe something like wxPython (python is also a scripting language) will suffice?
Unfortunately the university I am attending does not offer any c++ classes. I just checked. I would definitely have considered taking a c++ class to fulfill elective credit, if that were an option. My university has very little to offer in so much as programming classes, sadly.
What you say is very logical, but I will continue my current project with c++ and wxWidgets. I can be very patient and persistent when I want to be, and have personally found that "small bites" is the best method in terms of taking on complex and more subtle projects.
Hi,
I wish you all the best.
C++ itself is not a simple language. It takes time and patience to master and it will be very hard to do it on your own.
Please consider the possibility of going to another school to learn it. I can assure you - it will be much easier in the long run. And it comes from experience.
In the meantime I suggest to take a look at the sample code for wxWidgets. You can find it by downloading the sources and then looking at the wxWidgets/sample directory.
A lot of stuff can be found (aqnd solved) juist by running the samples and then check the code to see how it works.
But I still want to encourage you to get a proper education of the language. Things will have much more sense then.
Thank you.
P.S.: Out of curiosity - you are offered JAVASUCKS, right?
I have downloaded a fair amount of sample code and examples, which will be helpful no doubt.
Unfortunately my University's coding classes (c++ or java) have many prerequisites, and I do not have many electives left. This may not sound like an issue to you, but it is to me. I'm going to school for law, and cannot simply derail my current degree path for this project.
I have found an interesting c# wxWidgets wrapper called ObjectListView, in which I was able yesterday to design my entire project UI with its graphical design components. This just leaves me with coding the back end which should be relatively simple (I hope).
The only downside is that the documentation for it is relatively sparse, and I'm not sure how active its community support is. I think once I wrap my head around events (just like doublemax explained to me here) I should be on home stretch.
Is there subforum on this site where ObjectListView would be considered an appropriate topic?