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