Q1. Why are all these templates? It is confusing!

A1. It is confusing only at first glance. I did not plan on using them until I got into a problem, which was easily solved by using templates. I designed this gui to be used in my project SSR. I designed general class for the dialog, then I was able to add some more buttons for a specific dialogs that I had in this project. Everything was perfect till the moment I decided to have buttons with sound effects! At first I thought: "It is very easy..." and it was. All I had to do is to create a CSndButton class based on CButton class, overload OnMouseEnter() event, so when I hover mouse over the button it plays the sound. Very easy, four lines of code. I just changed all buttons in my dialogs from CButton to CSndButton, compile, run... Cool, it works... except of buttons OK and Cancel in the dialog window... Of course I did not change classes for those, they are inside of the gui itself, I should not do anything with them... Hmm... At first I wanted unregester them and create new buttons in my dialogs... too much work and it is stupid. Then I wanted to create different base class for the dialog with my sound buttons... but it is also not smart. And then EVRIKA!!!... And here we go, we are using templates. It does solve this issue very nicely. If you want to use your classes based on the button classes, all you need it is a proper instantiation of the template! Wrap it with your typedef and you may forget that there are any templates.

Q2. Platform independence? But tested only on Win32?

A2. It was original idea of the design, and I was able to compile it under Linux 9.0. But for the moment I do not have time and resources to test it under any other system. Feel welcome to help me with it, I will really appreciate it.

Quick Links:

 Screen Shots
 Source Code
 Want to help?



Useful links:

sjcomp Logo

Last modified: