Dynamically creating controls in MFC (Collection question)
Posted
by ProgramWriter
on Stack Overflow
See other posts from Stack Overflow
or by ProgramWriter
Published on 2010-04-02T08:59:53Z
Indexed on
2010/04/02
9:03 UTC
Read the original article
Hit count: 415
Hello all,
I have some custom control inside of which i should create radiobuttons or checkboxes. The count of child controls is available only at runtime (it loads some file from which it gets this count). So i need to create variable number of controls. Which collection i should use for this purpose?
Solution 1: simply use std::vector (or CArray) - not suitable because i want use MFC (CButton). Of course i can Attach() and later Detach() handle to window each time i need this window, but it will give big overhead.
Solution 2: use std::vector or CArray or CList or... In this case i take care about making 'new' and appropriate 'delete' when control is unneeded. I am forgetful :)
MFC handle map contains pointer to CButton and i can't use simple CArray, because it will move my objects each time when his size will grow.
... and the question is: Which collection i should use for containing variable count of MFC control classes?
© Stack Overflow or respective owner