mellor
asked on
Creation of MFC controls at run time: How to allocate resource ID's?
Hi,
I may be missing something, I don't pretend to be an expert,
but I have to create a dialog box with controls that can only
be created at run time.
I have to give these controls a resource ID but the number I
require varies. It seems that I could just create a block
of them via 'view' 'ID's' in the PWB but that seems to me to
be a 'hack'. If I just start at resource 1 and increment
will they get confused with other ID's already created in
resource.h?
Yours
confused
Allan
I may be missing something, I don't pretend to be an expert,
but I have to create a dialog box with controls that can only
be created at run time.
I have to give these controls a resource ID but the number I
require varies. It seems that I could just create a block
of them via 'view' 'ID's' in the PWB but that seems to me to
be a 'hack'. If I just start at resource 1 and increment
will they get confused with other ID's already created in
resource.h?
Yours
confused
Allan
You can also allocate a block of control IDs by adding one new control ID, then closing the resource file and opening the resource.h file then changing the value after _APS_NEXT_CONTROL_VALUE. Close resource.h, reopen the resource editor, and add the "last" control for marking the end of the block you just reserved.
I use 0xE000 to 0xF000
As long as all the IDs are unique within the dialog there is no problem.
ASKER
Dear aphillips,
Could you expand on your comment.
How does one check that one is only
working with items 'within the dialog'
Yours
Allan
Could you expand on your comment.
How does one check that one is only
working with items 'within the dialog'
Yours
Allan
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks very much.
You learn somthing new every day.
Yours
Allan
You learn somthing new every day.
Yours
Allan
You can also add your own resource ID using function View - Resource Symbols. To be 100% correct, add some number of consequent IDs:
ID_MYCONTROL1
ID_MYCONTROL2
...
and use first of them as start value:
for ( int i = 0; i < ..., i++ )
{
... Create(ID_MYCONTROL1 + i, ...)
}