CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2007
    Posts
    5

    MFC IDs question!!

    probably something really simple but i'm new to MFC and was just wondering if there is any way to easily deal with ID's

    for instance, i'm creating an audio mixer in a dialog application which therefore needs to contain instances of the same group of buttons, executing the same functions, but on different files.

    eg. play1, stop1, play2, stop2, etc.

    is there any way to create or access the ID's for the buttons so that instead of specifying each ID individually when needed, a for loop or simelar could be used to specify which set of buttons (ie which channel number) should be referred to?

    thanks in advance

  2. #2
    Join Date
    Mar 2001
    Posts
    2,529

    Re: MFC IDs question!!

    I have put resource IDs in 2-D tables before. Each row can correspond to a group. Very easy to do.
    ahoodin
    To keep the plot moving, that's why.

  3. #3
    Join Date
    Mar 2003
    Location
    The Netherlands
    Posts
    586

    Re: MFC IDs question!!

    One possibility is to put all ID's of buttons in an array:

    Code:
    UINT aButtons[10] = { IDC_BUTTON1, IDC_BUTTON2, ....};
    or create a struct/class

    Code:
    class CMyClass
    {
      UINT m_id;
      int m_iChannelNr;
      virtual void MyFunction();
    };
    and put these class objects in an array. If necessary derive from your base class and use a different implementation for MyFunction() in the derived classes.
    Hope this helps.
    Time is fun when you're having flies

  4. #4
    Join Date
    Mar 2007
    Posts
    5

    Re: MFC IDs question!!

    thanks, i figured a class or array would be the answer.. how would this allow me to dynamically control the number of channels without having to manually enter the ID's into the array - is there some way that it can be done automatically? say for instance if the user wanted to add another channel to the mixer? i might be being stupid here!

    thanks in advance

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured