How to put a background image in a panel in wxWidgets

These days I was working in a program that will use wxWidgets framework.

Basically, the application will have many panels and all of them must have a background image.

In my mind I had 2 options:

  • for each panel I could put a background image in wxPanel plus all the controls that each panel required
  • create a base class derived from wxPanel that would contain the background image and make it the base class for each panel in the application.

The second approach is better because that way I’d eliminate code duplication. That was the path I followed.

How would that work? When a class that inherited from BaseScreen were created, always the paint event of BaseScreen would be called prior to the paint event from the child class.

This way the image would be draw in on top of it the controls from child class would be draw. It would give the effect of having a background image. Continue reading “How to put a background image in a panel in wxWidgets”

How to solve error A call to PInvoke function MyMethod has unbalanced the stack.

Today I upgraded a C# program from .NET 2.0 to .NET 4.0 and started debugging it.

I got the error message when pInvoke called a C++ function in one of my DLLs:

Continue reading “How to solve error A call to PInvoke function MyMethod has unbalanced the stack.”

JNI crash course tutorial – Part 1


JNI is a knowledge anyone developing games with cocos2d-x must have. As I don’t known it enough to feel comfortable with the theme so I started studying it myself.

During my learning process I like to take notes and share what I’m discovering. This post aims to be an introductory text on JNI. I will try to teach you the basics so you can understand how it works and how to integrate your own Java / native code (C/C++).

It is essential when developing games for Android using cocos2d-x.

There are 2 scenarios when it comes to JNI:

  • Java code calling native code (C/C++)
  • Native code (C/C++) calling Java code.

Continue reading “JNI crash course tutorial – Part 1”