renew?
-
Hi I am writing an application where the user can enter multiple occurences of an edit control or a combo-box. I keep adding new Edit controls whenever the user fills the previous one. On order to allocate these edit controls, I use the "new" operator. However, when I need to add a new CEdit control, I would need something like a "renew" operator (much like the realloc routine). Does anyone know how to do this? I could of course allocate a completely new set of Edit controls, and then copy the properties of the already used ones, but this seems like a rather clumsy way of doing things! Thanks in advance. William
-
Hi I am writing an application where the user can enter multiple occurences of an edit control or a combo-box. I keep adding new Edit controls whenever the user fills the previous one. On order to allocate these edit controls, I use the "new" operator. However, when I need to add a new CEdit control, I would need something like a "renew" operator (much like the realloc routine). Does anyone know how to do this? I could of course allocate a completely new set of Edit controls, and then copy the properties of the already used ones, but this seems like a rather clumsy way of doing things! Thanks in advance. William
- If you are talking about C++ syntax, there is the method called "placement new" for you to new the objects at the specified address (in this case, the address of previous newed objects). 2) After new, you should "create" the edit controls to create the windows ...
Maxwell Chen
-
Hi I am writing an application where the user can enter multiple occurences of an edit control or a combo-box. I keep adding new Edit controls whenever the user fills the previous one. On order to allocate these edit controls, I use the "new" operator. However, when I need to add a new CEdit control, I would need something like a "renew" operator (much like the realloc routine). Does anyone know how to do this? I could of course allocate a completely new set of Edit controls, and then copy the properties of the already used ones, but this seems like a rather clumsy way of doing things! Thanks in advance. William
Why don't you use one of MFC's or STL's containers? They will grow/shrink without having to worry about memory management.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb