c++ HWND Win32 array problem

ok so heres something that keeps happening to me and I can't figure out why it does this but I have a list of controls within an array to make the code easier to manage.

For example:

HWND Windows_Edit[5];

which will actually allow 6 hwnds (in this case all edit controls) within Windows_Edit

and then I assigned them eg:
Windows_Edit[0]= CreateWindowEx(...);
Windows_Edit[1]= CreateWindowEx(...);
Windows_Edit[2]= CreateWindowEx(...);



and so on but within my code the controls for Windows_Edit[0] and Windows_Edit[1] display correctly but when I add Windows_Edit[2]= CreateWindowEx(...); it will actually interfear with Windows_Edit[0]


Yet when I print out each Windows_Edit they all have different HWNDS but the text that I used for Windows_Edit[2] will change the text of the control of Windows_Edit[0] to the same thing so if I have an edit control Windows_Edit[0] that displays "Edit0" and Windows_Edit[2] as Edit2, Windows_Edit[0] will display Edit 2 instead as well its as if im redeclareing Windows_Edit[0] as Windows_Edit[2].



Does anyone know why this is happening?

Thanks
Hi,

I am not familiar with HWND type. But why not a class then creating five objects? just asking and good luck.
show the whole code
To answer your question it would be necessary to see how you are placing text strings into the edit controls and further, how you are retrieving the text.

Also, I would have to add that storing the HWNDs of an array of edit controls isn't necessary. The operative parameter of the CreateWindowEx() call that needs to be stored is the HMENU parameter, which, in the case of a child window control such as an edit control, is known as the control's 'Control ID'. In other words, one would do something such as this....

#define IDC_EDIT_CONTROLS 2000

Then, one would simply cast the entity like so ...

(HMENU)(IDC_EDIT_CONTROLS + i)

...within the for loop which creates the edit controls.

To obtain the HWND of each edit control element within the array which Windows would keep track of, one would use the function GetDlgItem(). That function retrieves the HWND given the control's parent, and the Control ID of the control.

Last edited on
Here is part of the code, password is PWS-1990


http://hostcode.sourceforge.net/view/3399


Now the problem is with LCDCM_CheckBox[index] hwnd array. So far LCDCM_CheckBox[0]-LCDCM_CheckBox[2] but as soon as I declare LCDCM_CheckBox[3], LCDCM_CheckBox[0] text gets switch to LCDCM_CheckBox[3] as if I redeclared LCDCM_CheckBox[0] as LCDCM_CheckBox[3]


Thank you and if you need more please let me know. Now I know that there are mistakes as well as ones I most likely over looked
ok I dont know what happened but I turned my computer back one, recompiled the project and now it works. I havent changed anything within the code so now my question is could there be a cross-memory problem?
Topic archived. No new replies allowed.