Пример #1
0
INT_PTR CALLBACK DefDialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	CDialog* pThis = NULL;
	CDialog* pThat = NULL;
	switch(uMsg)
	{
	case WM_INITDIALOG:
		pThis=(CDialog*)lParam;		//获取对象指针
		if( NULL != pThis)
		{
			pThis->Attach(hWnd);	//设置HWND和对象之间的关系
			SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)pThis);	//将对象指针保存到窗口hWnd用户数据空间
		}
		break;
	default:
		break;
	}
	pThat = (CDialog*)GetWindowLongPtr(hWnd, GWLP_USERDATA);	//从窗口句柄hWnd得到对象指针,因为之前有SetWindowLongPtr()
	if(NULL != pThat)
	{
		return ( pThat->HandleMessage(uMsg,wParam, lParam) );
	}

	return (INT_PTR)FALSE;
}
Пример #2
0
static INT_PTR APIENTRY DialogProcedure(HWND dialogHWND, UINT message, WPARAM wParam, LPARAM lParam)
{
  CWindow tempDialog(dialogHWND);
  if (message == WM_INITDIALOG)
    tempDialog.SetUserDataLongPtr(lParam);
  CDialog *dialog = (CDialog *)(tempDialog.GetUserDataLongPtr());
  if (dialog == NULL)
    return FALSE;
  if (message == WM_INITDIALOG)
    dialog->Attach(dialogHWND);
  try { return BoolToBOOL(dialog->OnMessage(message, wParam, lParam)); }
  catch(...) { return TRUE; }
}
Пример #3
0
static INT_PTR APIENTRY DialogProcedure(HWND dialogHWND, UINT message, 
    WPARAM wParam, LPARAM lParam)
{
  CWindow dialogTmp(dialogHWND);
  if (message == WM_INITDIALOG)
    dialogTmp.SetUserDataLongPtr(lParam);
  CDialog *dialog = (CDialog *)(dialogTmp.GetUserDataLongPtr());
  if (dialog == NULL)
    return FALSE;
  if (message == WM_INITDIALOG)
    dialog->Attach(dialogHWND);

  return BoolToBOOL(dialog->OnMessage(message, wParam, lParam));
}