This is hardly elegant, but one way to store a pointer. The basic idea is to have a static pointer set to NULL within the dialog callback, make a "dummy" call from within the constructor (or another function) of the object to initialize it, and finally set it to NULL when we're done so that another object can safely reuse the pointer. Yes, it's an ugly hack, but Windows doesn't give us many options, true ?
Code:
Propsheetpage::Propsheetpage(){
dialog_callback(0, this, 0);
}
friend UINT CALLBACK dialog_callback( HWND hwnd, UINT uMsg, LPPROPSHEETPAGE ppsp){
static Propsheetpage * p = NULL;
if(!p){
p = (Propsheetpage *)uMsg;
return 0;
}
switch(uMsg){
case PSPCB_CREATE: return p->OnCreate(); break;
case PSPCB_RELEASE: return p->OnDestroy(); p = NULL; break;
}
return 0;
}