Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Generating Control ID

Generating Control ID

Scheduled Pinned Locked Moved C / C++ / MFC
questiondata-structureshelp
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Abhishek Narula
    wrote on last edited by
    #1

    I ll be having a array of controls all of whose parent is same . now since these controls are created at runtime I cannot assign a Id to it at programing time. How do I generate a uniqe Id each time I create a new CWnd derive control ? I wish I could rate Gurus the way its on Codeguru . in any case any help would be appreciated. Abhishek Narula "Learn to appreciate others ... World would appreciate you"

    T 1 Reply Last reply
    0
    • A Abhishek Narula

      I ll be having a array of controls all of whose parent is same . now since these controls are created at runtime I cannot assign a Id to it at programing time. How do I generate a uniqe Id each time I create a new CWnd derive control ? I wish I could rate Gurus the way its on Codeguru . in any case any help would be appreciated. Abhishek Narula "Learn to appreciate others ... World would appreciate you"

      T Offline
      T Offline
      Tomasz Sowinski
      wrote on last edited by
      #2

      Start with some value and increment it each time you're adding a control. If you have a mixed situation - your controls and controls created by some other code, you may use EnumChildWindows. For each HWND returned, check the id with GetWindowLong(hwnd, GWL_ID). Calculate max existing ID, add 1 and create control. Abhishek Narula wrote: wish I could rate Gurus the way its on Codeguru . in any case any help would be appreciated. Stop brown-nosing. ;) Tomasz Sowinski -- http://www.shooltz.com

      A J 2 Replies Last reply
      0
      • T Tomasz Sowinski

        Start with some value and increment it each time you're adding a control. If you have a mixed situation - your controls and controls created by some other code, you may use EnumChildWindows. For each HWND returned, check the id with GetWindowLong(hwnd, GWL_ID). Calculate max existing ID, add 1 and create control. Abhishek Narula wrote: wish I could rate Gurus the way its on Codeguru . in any case any help would be appreciated. Stop brown-nosing. ;) Tomasz Sowinski -- http://www.shooltz.com

        A Offline
        A Offline
        Abhishek Narula
        wrote on last edited by
        #3

        What is the definition of some value ?? can I start with any arbitrary value ?? Abhishek Narula "Learn to appreciate others ... World would appreciate you"

        T 1 Reply Last reply
        0
        • A Abhishek Narula

          What is the definition of some value ?? can I start with any arbitrary value ?? Abhishek Narula "Learn to appreciate others ... World would appreciate you"

          T Offline
          T Offline
          Tomasz Sowinski
          wrote on last edited by
          #4

          Abhishek Narula wrote: can I start with any arbitrary value ?? Yes, if parent window contains only children created by your code. Tomasz Sowinski -- http://www.shooltz.com

          A 1 Reply Last reply
          0
          • T Tomasz Sowinski

            Abhishek Narula wrote: can I start with any arbitrary value ?? Yes, if parent window contains only children created by your code. Tomasz Sowinski -- http://www.shooltz.com

            A Offline
            A Offline
            Abhishek Narula
            wrote on last edited by
            #5

            No there would be so many other things like so many input dialogs etc .. Can also explain what is WM_USER constant ? and can we some how use this ? Abhishek Narula "Learn to appreciate others ... World would appreciate you"

            T 1 Reply Last reply
            0
            • A Abhishek Narula

              No there would be so many other things like so many input dialogs etc .. Can also explain what is WM_USER constant ? and can we some how use this ? Abhishek Narula "Learn to appreciate others ... World would appreciate you"

              T Offline
              T Offline
              Tomasz Sowinski
              wrote on last edited by
              #6

              Abhishek Narula wrote: No there would be so many other things like so many input dialogs etc .. So you have to use EnumChildWindows/GetWindowLong to enumerate all existing children IDs. Calculate the max value, add 1, and use as start ID. Abhishek Narula wrote: Can also explain what is WM_USER constant ? and can we some how use this ? No, WM_USER is not about control IDs. It's about messages. Tomasz Sowinski -- http://www.shooltz.com

              1 Reply Last reply
              0
              • J Jon Hulatt

                We like it this way: we can give bad advice and not be held accountable for it!!!! Sorry to dissapoint you all with my lack of a witty or poignant signature.

                T Offline
                T Offline
                Tomasz Sowinski
                wrote on last edited by
                #7

                Should I contact my lawyer? :-D Tomasz Sowinski -- http://www.shooltz.com

                1 Reply Last reply
                0
                • T Tomasz Sowinski

                  Start with some value and increment it each time you're adding a control. If you have a mixed situation - your controls and controls created by some other code, you may use EnumChildWindows. For each HWND returned, check the id with GetWindowLong(hwnd, GWL_ID). Calculate max existing ID, add 1 and create control. Abhishek Narula wrote: wish I could rate Gurus the way its on Codeguru . in any case any help would be appreciated. Stop brown-nosing. ;) Tomasz Sowinski -- http://www.shooltz.com

                  J Offline
                  J Offline
                  Jon Hulatt
                  wrote on last edited by
                  #8

                  We like it this way: we can give bad advice and not be held accountable for it!!!! Sorry to dissapoint you all with my lack of a witty or poignant signature.

                  T 1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups