I have declared and defined a struct in a header file, i.e.,...
1 2 3 4 5 6 7 8 9 10 11 12 13
|
struct MYSTRUCT {
char* szChar;
HFONT hFont;
:
MYSTRUCT ms[]= {
"aaa", hCourNew;
"bbb", hCourNew;
"ccc", hCourNew;
"ddd", hArial;
"ddd", hArial;
...etc.,
};
|
Now I actually load the fonts in WM_CREATE, so that the font assignments in the structure don't actually work because the structure assignment occurs BEFORE the fonts are loaded in WM_CREATE.
I do not want to put this cumbersome assignment within my function. At present, I'm simply iterating through the structure and reassigning the fonts to the hFont member.
But I am wondering if there is a better way. I have several requirements, though...
1. I do not want to pass an int to a function, i.e,, I want to determine the size of the struct array dynamically.
2. I do not want to mimic the structure by doing something like MYSTRUCT ms2, or what-have-you.
IOW, I want to get my structure definition to recognize my loaded fonts without having to go back and iterate through it to assign the loaded fonts.
I thought I would try passing the structure by reference, or by a return value, but in most cases I can't get it to compile, and on the rare occassions it does compile, the program crashes.
I hope I'm being clear. If not, please let me know and I'll try again.