dlgcomm.cpp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1998 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10. #include "stdafx.h"
  11. #include <dlgs.h>
  12. #ifdef AFX_AUX_SEG
  13. #pragma code_seg(AFX_AUX_SEG)
  14. #endif
  15. #ifdef _DEBUG
  16. #undef THIS_FILE
  17. static char THIS_FILE[] = __FILE__;
  18. #endif
  19. #define new DEBUG_NEW
  20. AFX_COMDAT UINT _afxMsgLBSELCHANGE = 0;
  21. AFX_COMDAT UINT _afxMsgSHAREVI = 0;
  22. AFX_COMDAT UINT _afxMsgFILEOK = 0;
  23. AFX_COMDAT UINT _afxMsgCOLOROK = 0;
  24. AFX_COMDAT UINT _afxMsgHELP = 0;
  25. AFX_COMDAT UINT _afxMsgSETRGB = 0;
  26. BEGIN_MESSAGE_MAP(CCommonDialog, CDialog)
  27. //{{AFX_MSG_MAP(CCommonDialog)
  28. ON_WM_HELPINFO()
  29. //}}AFX_MSG_MAP
  30. END_MESSAGE_MAP()
  31. UINT CALLBACK
  32. _AfxCommDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  33. {
  34. if (hWnd == NULL)
  35. return 0;
  36. _AFX_THREAD_STATE* pThreadState = _afxThreadState.GetData();
  37. if (pThreadState->m_pAlternateWndInit != NULL)
  38. {
  39. ASSERT_KINDOF(CFileDialog,pThreadState->m_pAlternateWndInit);
  40. pThreadState->m_pAlternateWndInit->SubclassWindow(hWnd);
  41. pThreadState->m_pAlternateWndInit = NULL;
  42. }
  43. ASSERT(pThreadState->m_pAlternateWndInit == NULL);
  44. if (message == WM_INITDIALOG)
  45. {
  46. _afxMsgLBSELCHANGE = ::RegisterWindowMessage(LBSELCHSTRING);
  47. _afxMsgSHAREVI = ::RegisterWindowMessage(SHAREVISTRING);
  48. _afxMsgFILEOK = ::RegisterWindowMessage(FILEOKSTRING);
  49. _afxMsgCOLOROK = ::RegisterWindowMessage(COLOROKSTRING);
  50. _afxMsgHELP = ::RegisterWindowMessage(HELPMSGSTRING);
  51. _afxMsgSETRGB = ::RegisterWindowMessage(SETRGBSTRING);
  52. return (UINT)AfxDlgProc(hWnd, message, wParam, lParam);
  53. }
  54. if (message == _afxMsgHELP ||
  55. (message == WM_COMMAND && LOWORD(wParam) == pshHelp))
  56. {
  57. // just translate the message into the AFX standard help command.
  58. SendMessage(hWnd, WM_COMMAND, ID_HELP, 0);
  59. return 1;
  60. }
  61. if (message < 0xC000)
  62. {
  63. // not a ::RegisterWindowMessage message
  64. return 0;
  65. }
  66. // assume it is already wired up to a permanent one
  67. CDialog* pDlg = (CDialog*)CWnd::FromHandlePermanent(hWnd);
  68. ASSERT(pDlg != NULL);
  69. ASSERT_KINDOF(CDialog, pDlg);
  70. if (pDlg->IsKindOf(RUNTIME_CLASS(CFileDialog)))
  71. {
  72. // If we're exploring then we are not interested in the Registered messages
  73. if (((CFileDialog*)pDlg)->m_ofn.Flags & OFN_EXPLORER)
  74. return 0;
  75. }
  76. // RegisterWindowMessage - does not copy to lastState buffer, so
  77. // CWnd::GetCurrentMessage and CWnd::Default will NOT work
  78. // while in these handlers
  79. // Dispatch special commdlg messages through our virtual callbacks
  80. if (message == _afxMsgSHAREVI)
  81. {
  82. ASSERT_KINDOF(CFileDialog, pDlg);
  83. return ((CFileDialog*)pDlg)->OnShareViolation((LPCTSTR)lParam);
  84. }
  85. else if (message == _afxMsgFILEOK)
  86. {
  87. ASSERT_KINDOF(CFileDialog, pDlg);
  88. if (afxData.bWin4)
  89. ((CFileDialog*)pDlg)->m_pofnTemp = (OPENFILENAME*)lParam;
  90. BOOL bResult = ((CFileDialog*)pDlg)->OnFileNameOK();
  91. ((CFileDialog*)pDlg)->m_pofnTemp = NULL;
  92. return bResult;
  93. }
  94. else if (message == _afxMsgLBSELCHANGE)
  95. {
  96. ASSERT_KINDOF(CFileDialog, pDlg);
  97. ((CFileDialog*)pDlg)->OnLBSelChangedNotify(wParam, LOWORD(lParam),
  98. HIWORD(lParam));
  99. return 0;
  100. }
  101. else if (message == _afxMsgCOLOROK)
  102. {
  103. ASSERT_KINDOF(CColorDialog, pDlg);
  104. return ((CColorDialog*)pDlg)->OnColorOK();
  105. }
  106. else if (message == _afxMsgSETRGB)
  107. {
  108. // nothing to do here, since this is a SendMessage
  109. return 0;
  110. }
  111. return 0;
  112. }
  113. ////////////////////////////////////////////////////////////////////////////
  114. // CCommonDialog - common dialog helper class
  115. void CCommonDialog::OnOK()
  116. {
  117. ASSERT_VALID(this);
  118. if (!UpdateData(TRUE))
  119. {
  120. TRACE0("UpdateData failed during dialog termination.\n");
  121. // the UpdateData routine will set focus to correct item
  122. return;
  123. }
  124. // Common dialogs do not require ::EndDialog
  125. Default();
  126. }
  127. void CCommonDialog::OnCancel()
  128. {
  129. ASSERT_VALID(this);
  130. // Common dialogs do not require ::EndDialog
  131. Default();
  132. }
  133. BOOL CCommonDialog::OnHelpInfo(HELPINFO*)
  134. {
  135. return Default();
  136. }
  137. ////////////////////////////////////////////////////////////////////////////