I've got a program where the number of possible buttons is known at compile time (a const, and may not always be true anyway), but the buttons themselves are created at run-time and placed on a CDialogBar. I can create all the buttons, but I cannot figure out how to attach functions to clicking the buttons. Since they're created at run-time, there's no way to use the Class Wizard to create a message map. This seems like it should have a trivial answer but darned if I can figure it out. I've tried subclassing, but couldn't even get a clean compile using

OldProc=(WNDPROC)SetWindowLong<font colo