Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

260 lines
6.2 KiB

  1. // ChildFrm.cpp : implementation of the CChildFrame class
  2. //
  3. #include "stdinc.h"
  4. #include "host.h"
  5. #include "ChildFrm.h"
  6. #include "HostDoc.h"
  7. #include "SettingsDlg.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CChildFrame
  15. IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd)
  16. BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd)
  17. //{{AFX_MSG_MAP(CChildFrame)
  18. ON_COMMAND(ID_SETTINGS, OnSettings)
  19. ON_COMMAND(ID_DATASOURCE1, OnDataSource1)
  20. ON_COMMAND(ID_DATASOURCE2, OnDataSource2)
  21. ON_COMMAND(ID_DATASOURCE3, OnDataSource3)
  22. ON_UPDATE_COMMAND_UI(ID_DATASOURCE1, OnUpdateDataSource1)
  23. ON_UPDATE_COMMAND_UI(ID_DATASOURCE2, OnUpdateDataSource2)
  24. ON_UPDATE_COMMAND_UI(ID_DATASOURCE3, OnUpdateDataSource3)
  25. ON_COMMAND(ID_GDIPLUS, OnGdiPlus)
  26. ON_UPDATE_COMMAND_UI(ID_GDIPLUS, OnUpdateGdiPlus)
  27. ON_COMMAND(ID_COMCTRL, OnComCtrl)
  28. ON_UPDATE_COMMAND_UI(ID_COMCTRL, OnUpdateComCtrl)
  29. ON_COMMAND(ID_PRIVATE_ASSEMBLY, OnPrivateAssembly)
  30. ON_UPDATE_COMMAND_UI(ID_PRIVATE_ASSEMBLY, OnUpdatePrivateAssembly)
  31. //}}AFX_MSG_MAP
  32. END_MESSAGE_MAP()
  33. /////////////////////////////////////////////////////////////////////////////
  34. // CChildFrame construction/destruction
  35. CChildFrame::CChildFrame()
  36. {
  37. m_nDataSource = 0;
  38. m_nUIObject = 0;
  39. }
  40. CChildFrame::~CChildFrame()
  41. {
  42. }
  43. BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
  44. {
  45. // TODO: Modify the Window class or styles here by modifying
  46. // the CREATESTRUCT cs
  47. if( !CMDIChildWnd::PreCreateWindow(cs) )
  48. return FALSE;
  49. return TRUE;
  50. }
  51. /////////////////////////////////////////////////////////////////////////////
  52. // CChildFrame diagnostics
  53. #ifdef _DEBUG
  54. void CChildFrame::AssertValid() const
  55. {
  56. CMDIChildWnd::AssertValid();
  57. }
  58. void CChildFrame::Dump(CDumpContext& dc) const
  59. {
  60. CMDIChildWnd::Dump(dc);
  61. }
  62. #endif //_DEBUG
  63. /////////////////////////////////////////////////////////////////////////////
  64. // CChildFrame message handlers
  65. void CChildFrame::OnSettings()
  66. {
  67. CHostDoc * pDoc = (CHostDoc *) GetActiveDocument();
  68. // TODO: Add your command handler code here
  69. CSettingsDlg dlg;
  70. dlg.m_sPath = pDoc->m_sPath;
  71. dlg.m_sDBName = pDoc->m_sDBName;
  72. dlg.m_sDBQuery = pDoc->m_sDBQuery;
  73. if (dlg.DoModal() == IDOK)
  74. {
  75. pDoc->m_sPath = dlg.m_sPath;
  76. pDoc->m_sDBName = dlg.m_sDBName;
  77. pDoc->m_sDBQuery = dlg.m_sDBQuery;
  78. }
  79. }
  80. ///////////////////////////////////////////////////////////////////////////
  81. void CChildFrame::OnDataSource1()
  82. {
  83. m_nDataSource = 1;
  84. Action();
  85. }
  86. ///////////////////////////////////////////////////////////////////////////
  87. void CChildFrame::OnDataSource2()
  88. {
  89. m_nDataSource = 2;
  90. Action();
  91. }
  92. ///////////////////////////////////////////////////////////////////////////
  93. void CChildFrame::OnDataSource3()
  94. {
  95. m_nDataSource = 3;
  96. Action();
  97. }
  98. ///////////////////////////////////////////////////////////////////////////
  99. void CChildFrame::OnGdiPlus()
  100. {
  101. m_nUIObject = 1;
  102. Action();
  103. }
  104. ///////////////////////////////////////////////////////////////////////////
  105. void CChildFrame::OnComCtrl()
  106. {
  107. m_nUIObject = 2;
  108. Action();
  109. }
  110. ///////////////////////////////////////////////////////////////////////////
  111. void CChildFrame::OnPrivateAssembly()
  112. {
  113. m_nUIObject = 3;
  114. Action();
  115. }
  116. ///////////////////////////////////////////////////////////////////////////
  117. void CChildFrame::OnUpdateDataSource1(CCmdUI* pCmdUI)
  118. {
  119. pCmdUI->SetCheck( FALSE );
  120. CHostDoc * pDoc = (CHostDoc *) GetActiveDocument();
  121. BOOL bShow = (pDoc->m_sPath.GetLength() > 0);
  122. pCmdUI->Enable( bShow );
  123. if ( bShow )
  124. {
  125. pCmdUI->SetCheck(m_nDataSource == 1);
  126. }
  127. }
  128. ///////////////////////////////////////////////////////////////////////////
  129. void CChildFrame::OnUpdateDataSource2(CCmdUI* pCmdUI)
  130. {
  131. pCmdUI->SetCheck( FALSE );
  132. CHostDoc * pDoc = (CHostDoc *) GetActiveDocument();
  133. BOOL bShow = ((pDoc->m_sDBName.GetLength() > 0) && (pDoc->m_sDBQuery.GetLength() > 0));
  134. pCmdUI->Enable( bShow );
  135. if ( bShow )
  136. {
  137. pCmdUI->SetCheck(m_nDataSource == 2);
  138. }
  139. }
  140. ///////////////////////////////////////////////////////////////////////////
  141. void CChildFrame::OnUpdateDataSource3(CCmdUI* pCmdUI)
  142. {
  143. pCmdUI->SetCheck( FALSE );
  144. pCmdUI->Enable( FALSE );
  145. // pCmdUI->SetCheck(m_nDataSource == 3);
  146. }
  147. ///////////////////////////////////////////////////////////////////////////
  148. void CChildFrame::OnUpdateGdiPlus(CCmdUI* pCmdUI)
  149. {
  150. pCmdUI->SetCheck( FALSE );
  151. CHostDoc * pDoc = (CHostDoc *) GetActiveDocument();
  152. BOOL bShow = ((pDoc->m_sPath.GetLength() > 0)
  153. || ((pDoc->m_sDBName.GetLength() > 0) && (pDoc->m_sDBQuery.GetLength() > 0)));
  154. pCmdUI->Enable( bShow );
  155. if ( bShow)
  156. {
  157. pCmdUI->SetCheck(m_nUIObject == 1);
  158. }
  159. }
  160. ///////////////////////////////////////////////////////////////////////////
  161. void CChildFrame::OnUpdateComCtrl(CCmdUI* pCmdUI)
  162. {
  163. pCmdUI->SetCheck( FALSE );
  164. CHostDoc * pDoc = (CHostDoc *) GetActiveDocument();
  165. BOOL bShow = ((pDoc->m_sPath.GetLength() > 0)
  166. || ((pDoc->m_sDBName.GetLength() > 0) && (pDoc->m_sDBQuery.GetLength() > 0)));
  167. pCmdUI->Enable( bShow );
  168. if ( bShow)
  169. {
  170. pCmdUI->SetCheck(m_nUIObject == 2);
  171. }
  172. }
  173. ///////////////////////////////////////////////////////////////////////////
  174. void CChildFrame::OnUpdatePrivateAssembly(CCmdUI* pCmdUI)
  175. {
  176. pCmdUI->SetCheck( FALSE );
  177. CHostDoc * pDoc = (CHostDoc *) GetActiveDocument();
  178. BOOL bShow = ((pDoc->m_sPath.GetLength() > 0)
  179. || ((pDoc->m_sDBName.GetLength() > 0) && (pDoc->m_sDBQuery.GetLength() > 0)));
  180. pCmdUI->Enable( bShow );
  181. if ( bShow)
  182. {
  183. pCmdUI->SetCheck(m_nUIObject == 3);
  184. }
  185. }
  186. ///////////////////////////////////////////////////////////////////////////
  187. void CChildFrame::Action()
  188. {
  189. CString sQuery;
  190. sQuery.Empty();
  191. // Get Application and current document pointers
  192. CHostApp * pApp = (CHostApp *) AfxGetApp();
  193. CHostDoc * pDoc = (CHostDoc *) GetActiveDocument();
  194. switch ( m_nDataSource )
  195. {
  196. case 1:
  197. sQuery = pDoc->m_sPath;
  198. break;
  199. case 2:
  200. sQuery.Format(L"%s;|%s", pDoc->m_sDBName, pDoc->m_sDBQuery);
  201. break;
  202. case 3:
  203. break;
  204. default:
  205. sQuery = pDoc->m_sPath;
  206. break;
  207. }
  208. pApp->m_host.DSQuery(m_nDataSource, m_nUIObject, sQuery, this->GetSafeHwnd());
  209. }