I have a class with a structure inside it. I use the structure to create objects that contains coordinates and a HBITMAP which is loaded from the resource.
Then in my class I have function that displays the object on the screen:
void DrawIcon(HDC hdc, struct icon* icon);
What it does is that it draws the bitmap from the structure. But it doesn't seem to work.
My structure is defined in private along with the structure variables.
I know my code for displaying bitmaps is working, because I tested it outside the class.
I also tried to debug the class function and I do get all of the data from the pointer (the x- and y-coordinates are valid).
Wow, this problem right here is why Inheritence is a good thing. Your 'icon' struct should be defined outside of your 'flow_control' class, which should then inherit the attributes from 'icon'. If you don't want icon to be an object that can exist outside of that class then you can do stuff like make the constructor for icon private.
Speaking of private data, "MUSIC", "VIDEO" and "SETTINGS" are all private, I do not see their "BMP" data members initialized to anything as 'flow_control' does not appear to have a constructor, and there does not appear to be a public function to change that. I'm wondering why you even have a second constructor for 'icon' since a.) it's in the private scope and b.) 'flow_control' does not have a constructor of its own.
Now that I think about it, I'm getting the impression that you forgot to include another class\struct that you are using to tie all of this together, is that the case?
I didn't include my constructor in the previous post but I do have one and it does initialize the objects with a valid HBITMAP.
I moved the structure outside of the class but it doesn't seem to do any difference.
I solved the problem. I took my structure outside the class and declared it public with the class. Then I had some problems with my constructor also, since I didn't initialize my HBITMAP correctly.
Everything works fine now.