HWND variables and for loops

Hello again.

I have a question in regards to how HWND variables and for loops are handled.

Say I have the following code:
1
2
3
4
5
HWND handles[4];

for(int i = 0; i < 4; i++){
    handles[i] = CreateWindowW( ...insert parameters here... );
}


For some reaon, this does not work.

1
2
3
4
5
6
HWND handles[4];

handles[0] = CreateWindowW( ..insert yet again more parameters...);
handles[1] = CreateWindowW( ..insert yet again more parameters...);

...


However, this does. What is the difference and why does it not work for the first one? Aren't they fundamentally the same?
Last edited on
There is no difference and both should work, however one thing in your first example looks wrong, that is the:
for(int i = 0; i < handles.size(); i++)

handles is an array not a class instance, how do you call size() method? it doesn't exist for plain arrays.
Last edited on
Oh sorry. I guess I was remembering it wrong. I meant std::size(handles). I will edit my question to cut the confusion. (Mainly because the loop that used it in my program used a string array to determine a length that was appropiate for the loop; I am very sorry for that ;-; )
Last edited on
What does "not work" mean? You have to tell us. Be specific, or post a minimum example that actually reproduces your issue.
Last edited on
@Ganado First example doesn't display the windows, but the second one does.
There isn't enough information to answer your question.
Ok I just retested my program, and I think it may have had to with some ShowWindowW functions meant to hide the windows when they were not in use. Sorry about wasting any time, but I am now able to eliminate ~600 lines of code because of this.
:)
Glad I could help! (I'm kidding, of course :)
Topic archived. No new replies allowed.