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. Passing a control id

Passing a control id

Scheduled Pinned Locked Moved C / C++ / MFC
questiondatabasehelp
3 Posts 2 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.
  • M Offline
    M Offline
    moobob
    wrote on last edited by
    #1

    I have some code which sets the item data on a list box depending on some data attributes. I have multiple list boxes in my application and always want to set the item data the same way. To do this I need to pass as a parameter the control id of the list box in question. That way I can do a listbox.SetItemData (fieldNum, 1); How do I specify the type of listbox in my code? Here is the prototype and code. void DataImportDlg2::SetMapType(CListBox list, LPCTSTR fieldName, int fieldNum) { DbHelper::InputType inputType; DbHelper dbHelper; // Set the additional data flag which indicates whether // the item is a value mapping type or not. 1 indicates it is, // a 0 means no. inputType = dbHelper.GetItemsInputType (fieldName); if (inputType == DbHelper::A) list.SetItemData (fieldNum, 1); else list.SetItemData (fieldNum, 0); } I make the call like this: SetMapType (m_availFieldList, *iter, index); which gives me a compile error 'cannot convert parameter 1 from 'class CListBox' to 'class CListBox' Any ideas on what type to make the list parameter? Thanks in advance, Bob

    J 1 Reply Last reply
    0
    • M moobob

      I have some code which sets the item data on a list box depending on some data attributes. I have multiple list boxes in my application and always want to set the item data the same way. To do this I need to pass as a parameter the control id of the list box in question. That way I can do a listbox.SetItemData (fieldNum, 1); How do I specify the type of listbox in my code? Here is the prototype and code. void DataImportDlg2::SetMapType(CListBox list, LPCTSTR fieldName, int fieldNum) { DbHelper::InputType inputType; DbHelper dbHelper; // Set the additional data flag which indicates whether // the item is a value mapping type or not. 1 indicates it is, // a 0 means no. inputType = dbHelper.GetItemsInputType (fieldName); if (inputType == DbHelper::A) list.SetItemData (fieldNum, 1); else list.SetItemData (fieldNum, 0); } I make the call like this: SetMapType (m_availFieldList, *iter, index); which gives me a compile error 'cannot convert parameter 1 from 'class CListBox' to 'class CListBox' Any ideas on what type to make the list parameter? Thanks in advance, Bob

      J Offline
      J Offline
      Joaquin M Lopez Munoz
      wrote on last edited by
      #2

      Pass a reference to the list to be updated:

      void DataImportDlg2::SetMapType(CListBox**&** list, // note the extra '&'
      LPCTSTR fieldName,
      int fieldNum)

      Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

      M 1 Reply Last reply
      0
      • J Joaquin M Lopez Munoz

        Pass a reference to the list to be updated:

        void DataImportDlg2::SetMapType(CListBox**&** list, // note the extra '&'
        LPCTSTR fieldName,
        int fieldNum)

        Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

        M Offline
        M Offline
        moobob
        wrote on last edited by
        #3

        That works, except I have to change my argument name from list, since it thinks I'm referencing the STL list. Thanks, Bob

        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