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. Its about duplicate ID given to controls

Its about duplicate ID given to controls

Scheduled Pinned Locked Moved C / C++ / MFC
questiontutorial
5 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 want to understand that if we give a same ID to a CWnd derive window while creating it, Would it be erronous. If yes then how ? Also I want to understand let me frame my question with an example I create a EditBox whose parent is my view class lets say the id of this editbox is 1001. Now I create a Modeless Dialog which has also got a EditBox with the same ID that is 1001. So are these two CWnd going to clash in some way or the other ? Please throw some light on this. Abhishek Narula "Learn to appreciate others ... World would appreciate you"

    C 1 Reply Last reply
    0
    • A Abhishek Narula

      I want to understand that if we give a same ID to a CWnd derive window while creating it, Would it be erronous. If yes then how ? Also I want to understand let me frame my question with an example I create a EditBox whose parent is my view class lets say the id of this editbox is 1001. Now I create a Modeless Dialog which has also got a EditBox with the same ID that is 1001. So are these two CWnd going to clash in some way or the other ? Please throw some light on this. Abhishek Narula "Learn to appreciate others ... World would appreciate you"

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Abhishek Narula wrote: I want to understand that if we give a same ID to a CWnd derive window while creating it, Would it be erronous. Of course. Abhishek Narula wrote: If yes then how ? Those ID's are used to map messages, I believe. Imagine two controls in one dialog both with the same ID. They are used to interact with your code - your variable name is mapped to an ID. Now imagine if two were both the same ID. They obviously won't clash, or at least they are unlikely to. If two different dialogs have an edit box named IDC_EDIT, they will both have the same ID and not clash. Christian I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002 Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002

      A 1 Reply Last reply
      0
      • C Christian Graus

        Abhishek Narula wrote: I want to understand that if we give a same ID to a CWnd derive window while creating it, Would it be erronous. Of course. Abhishek Narula wrote: If yes then how ? Those ID's are used to map messages, I believe. Imagine two controls in one dialog both with the same ID. They are used to interact with your code - your variable name is mapped to an ID. Now imagine if two were both the same ID. They obviously won't clash, or at least they are unlikely to. If two different dialogs have an edit box named IDC_EDIT, they will both have the same ID and not clash. Christian I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002 Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002

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

        Is there a limit to these IDs ? except for the range of UINT, is there any reserver range or something ?? why does Resource.h has got various IDS starting from different values. what is the significance of these ranges !! Abhishek Narula "Learn to appreciate others ... World would appreciate you"

        C J 2 Replies Last reply
        0
        • A Abhishek Narula

          Is there a limit to these IDs ? except for the range of UINT, is there any reserver range or something ?? why does Resource.h has got various IDS starting from different values. what is the significance of these ranges !! Abhishek Narula "Learn to appreciate others ... World would appreciate you"

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          Abhishek Narula wrote: what is the significance of these ranges !! Just to group like things together. Christian I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002 Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002

          1 Reply Last reply
          0
          • A Abhishek Narula

            Is there a limit to these IDs ? except for the range of UINT, is there any reserver range or something ?? why does Resource.h has got various IDS starting from different values. what is the significance of these ranges !! Abhishek Narula "Learn to appreciate others ... World would appreciate you"

            J Offline
            J Offline
            jbarton
            wrote on last edited by
            #5

            There are defined limits for the various ID ranges in resource.h. Microsoft describes these ranges in technical note 35. From TN035: --------------------------------------------------------------------------------------------------------- _APS_NEXT_RESOURCE_VALUE is the next symbol value that will be used for a dialog resource, menu resource, and so on. The valid range for resource symbol values is 1 to 0x6FFF. _APS_NEXT_COMMAND_VALUE is the next symbol value that will be used for a command identification. The valid range for command symbol values is 0x8000 to 0xDFFF. _APS_NEXT_CONTROL_VALUE is the next symbol value that will be used for a dialog control. The valid range for dialog control symbol values is 8 to 0xDFFF. --------------------------------------------------------------------------------------------------------- It is best to keep your resource #defines within these ranges, as some things may break if you use values outside these ranges. Certain MFC data types are written assuming that the resource id values fit within a 16 bit unsigned int. For instance, the CString object allows a string to be loaded from the resources during its construction by passing its resource id to the constructor, but only works if HIWORD(id) is 0. In order to load a string this way, you use the following form of the constructor: CString string( LPCTSTR(RESOURCE_ID) ); This constructor distinguishes between a resource id and a pointer to an existing character buffer by looking at the hiword of the LPCTSTR pointer. If the hiword is 0, a string is loaded from the resources. If the hiword is not 0, a string is copied from an existing buffer. Best regards, John

            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