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. Help!!! How to write single Event Handler for 100 buttons

Help!!! How to write single Event Handler for 100 buttons

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
3 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.
  • V Offline
    V Offline
    VikramDelhi i
    wrote on last edited by
    #1

    Hi, I am working on a small periodic table for my college friends. The idea of the application is that there will be a button for each element, placed in the same style as that of Modern periodic table. Now I have 2 options to implement this. -> I must place more than 100 buttons on the Dialog and write event handler for each button. -> or place buttons and write single event handler for all button. What should I choose? Or suggest anything else I can implement. Also, if I implement 2nd option, how I can detect which button is clicked

    D U 2 Replies Last reply
    0
    • V VikramDelhi i

      Hi, I am working on a small periodic table for my college friends. The idea of the application is that there will be a button for each element, placed in the same style as that of Modern periodic table. Now I have 2 options to implement this. -> I must place more than 100 buttons on the Dialog and write event handler for each button. -> or place buttons and write single event handler for all button. What should I choose? Or suggest anything else I can implement. Also, if I implement 2nd option, how I can detect which button is clicked

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Check out ON_NOTIFY_RANGE().


      "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

      1 Reply Last reply
      0
      • V VikramDelhi i

        Hi, I am working on a small periodic table for my college friends. The idea of the application is that there will be a button for each element, placed in the same style as that of Modern periodic table. Now I have 2 options to implement this. -> I must place more than 100 buttons on the Dialog and write event handler for each button. -> or place buttons and write single event handler for all button. What should I choose? Or suggest anything else I can implement. Also, if I implement 2nd option, how I can detect which button is clicked

        U Offline
        U Offline
        User 307386
        wrote on last edited by
        #3

        ...Or check ON_COMMAND_RANGE, just make sure your buttons have subsequent IDs. Your handler will look like: void MyApp::OnButton(UINT nID) { int nIdx = nID-IDC_BUTTON1; // handle button by order index } Igor Green http://www.grigsoft.com Compare It! + Synchronize It! : Files and folders comparison never was easier!

        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