I know this thread is kinda old. But I wanted to comment on the coding style. I really like the style of code for win32.
Also, this thread was still on the first page. So, I decided to comment. It is really nice win32 code.
I wanted to add this tidbit.
While using maps you want to always use there assigned iterator with them. As the performance will basically double on the container.
You should change this code:
Code:
INT_PTR CALLBACK CMainDlg::DialogProcWrapper(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
// not using iterator
if(Messages.find(message) != Messages.end())
{
// record was found
// map function pointer
return (Instance().*Messages[message])(hDlg, message, wParam, lParam);
}
return 0;
}
To something that more looks like this:
Code:
bool CMainDlg::find_rec( UINT message, PDLGPROC &dlgproc )
{
std::map<UINT, PDLGPROC>::iterator mapMsgProcIt; // standard iterator
it = Messages.find(message);
if( it != Messages.end() )
{
dlgproc = it-second;
return true; // Found
}
return false; // Not Found
}
INT_PTR CALLBACK CMainDlg::DialogProcWrapper(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
PDLGPROC pProc = NULL ;
find_rec( message, pProc );
if( NULL != pProc )
{
return pProc;
}
return 0;
}
The pProc variable may need to be a class variable. This is all untested code.
If not the class variable you may need to put the pointer on the heap to use it.
I seen the map and was like where in the world is the corresponding iterator ? lol...
Its a little nicer and not to mention faster plus reusable now.
-BitHacker