   Trying to put a Windows API dialog in a separate class
  I'm writing an app that has quite a few different dialogs it can show. To keep the main class tidy I want to try and separate the functionality into a separate class and I've been having varied luck with moving different parts out.I've already established that I can't separate the DialogProc into a separate class (or can I? Several hours of searching Google seems to say no) but what about passing it as a function pointer to the dialog class?What I want to have is all the dialog's functionality in the dialog class with the DialogProc just calling the class's member functions, which then do the actual work. This includes creating the Dialog in the first place, for which I need to pass it a pointer to the DialogProc in the main class. The way I'm trying at the moment is to pass this pointer to the constructor but I'm having trouble doing this.I have a 'bare-minimum' class just to see if the concept will compile, but I get Error1error C2664: 'DialogBase::DialogBase(BOOL (__cdecl *)(HWND,UINT,WPARAM,LPARAM))' : cannot convert parameter 1 from 'BOOL (__stdcall *)(HWND,UINT,WPARAM,LPARAM)' to 'BOOL (__cdecl *)(HWND,UINT,WPARAM,LPARAM)'c:\users\chris\documents\visual studio 2008\projects\mandelbrot\mandelbrot\main.cpp40 when I try to compile.My dialog class is:#ifndef DIALOGBASE_H#define DIALOGBASE_H#include <windows.h>class DialogBase{public:DialogBase(BOOL (*DlgProc)(HWND, UINT, WPARAM, LPARAM));void showDialog();void hideDialog();HWND m_hDialog;};#endif#include "DialogBase.h"#include <windows.h>DialogBase::DialogBase(BOOL (*DlgProc)(HWND, UINT, WPARAM, LPARAM)){// nothing here yet, just testing the concept will compile}The declaration of the DialogProc I have is BOOL CALLBACK ColourPickerProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);and I create the Dilaog Object with DialogBase colPckr(&ColourPickerProc);
  I haven't tested this code, but something like this?class CEditDlg{public:INT_PTR CreateDlg(HINSTANCE hInst, HWND parent){return DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_YOURDLG), parent, dlgProc, (LPARAM)this);}INT_PTR ClassDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam){switch (message){case WM_INITDIALOG:{return (INT_PTR)TRUE;}case WM_COMMAND:if(LOWORD(wParam) == IDCANCEL || LOWORD(wParam) == IDOK){EndDialog(hDlg, LOWORD(wParam));return (INT_PTR)TRUE;}break;}return (INT_PTR)FALSE;}static INT_PTR CALLBACK dlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam){UNREFERENCED_PARAMETER(lParam);switch (message){   case WM_INITDIALOG:   {   CEditDlg *pEdit = (CEditDlg *) lParam;   SetDialogData(hDlg, pEdit);   return pEdit->ClassDlgProc(hDlg, message, wParam, lParam);   }   default:   {   CEditDlg *pEdit = (CEditDlg *)  GetDialogData(hDlg);   return pEdit->ClassDlgProc(hDlg, message, wParam, lParam);   }}return (INT_PTR)FALSE;}static void SetDialogData(const HWND hDlg, const LPVOID pVoid){SetWindowLongPtr(hDlg, DWL_USER, (LONG) pVoid);}static LPVOID GetDialogData(const HWND hDlg){return (LPVOID) GetWindowLongPtr(hDlg, DWL_USER);}};