CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2009
    Location
    India
    Posts
    835

    CStatic control ID

    I'm using CStatic inherited class in my code and creating static text boxes dynamically. Now for assigning unique control ID I'm creating a static control from resource editor and destroying it before calling CStatic::Create() and using its control ID say ID_STATIC_SAMPLE.

    If I do not use this parameter of Create(), the static control is also being created, so what is the use of this unique ID. And any other better way to assign a ID for dynamically created static controls.

  2. #2
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: CStatic control ID

    You need a unique ID if you want to distinguish that instance of the static control in event handlers for example. For example, if you enable SS_NOTIFY on your static control you can react to events such as STN_CLICKED and STN_DBLCLK, and if you want to know exactly which static control was clicked in those event handlers, you need a unique ID.
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  3. #3
    Join Date
    Jul 2009
    Location
    India
    Posts
    835

    Re: CStatic control ID

    Okay. Though in my code these event are not being handled. Still I use unique ID using resource adding method and destroying it before calling CStatic::Create().

    Is there any better way ?
    ◄◄ hypheni ►►

  4. #4
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: CStatic control ID

    If you don't need to handle events on the static control, you might as well use IDC_STATIC for all of them.
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

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