home *** CD-ROM | disk | FTP | other *** search
/ Troubleshooting Netware Systems / CSTRIAL0196.BIN / attach / msj / v10n04 / multilin.exe / MAINFRM.CPP < prev    next >
C/C++ Source or Header  |  1995-04-01  |  4KB  |  188 lines

  1. // mainfrm.cpp : implementation of the CMainFrame class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "global.h"
  6.  
  7. //my includes
  8. #include "dateform.h"
  9. #include "timeform.h"
  10. #include "settings.h"
  11. #include "translat.h"
  12. #include "numbform.h"
  13. #include "langlist.h"
  14.  
  15. #include "mainfrm.h"
  16.  
  17. #ifdef _DEBUG
  18. #undef THIS_FILE
  19. static char BASED_CODE THIS_FILE[] = __FILE__;
  20. #endif
  21.  
  22. /////////////////////////////////////////////////////////////////////////////
  23. // CMainFrame
  24.  
  25. IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
  26.  
  27. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  28.     //{{AFX_MSG_MAP(CMainFrame)
  29.     ON_WM_CREATE()
  30.     ON_COMMAND(ID_LANGUAGE_TRANSLATION, OnLanguageTranslation)
  31.     ON_COMMAND(ID_LOCALE_CURRENCY, OnLocaleCurrency)
  32.     ON_COMMAND(ID_LOCALE_DATE, OnLocaleDate)
  33.     ON_COMMAND(ID_LOCALE_LIST, OnLocaleList)
  34.     ON_COMMAND(ID_LOCALE_NUMBER, OnLocaleNumber)
  35.     ON_COMMAND(ID_LOCALE_TIME, OnLocaleTime)
  36.     ON_COMMAND(ID_LANGUAGE_SYSTEM, OnLanguageSystem)
  37.     //}}AFX_MSG_MAP
  38. END_MESSAGE_MAP()
  39.  
  40. /////////////////////////////////////////////////////////////////////////////
  41. // arrays of IDs used to initialize control bars
  42.  
  43. static UINT BASED_CODE indicators[] =
  44. {
  45.     ID_SEPARATOR,           // status line indicator
  46.     ID_INDICATOR_CAPS,
  47.     ID_INDICATOR_NUM,
  48.     ID_INDICATOR_SCRL,
  49. };
  50.  
  51. /////////////////////////////////////////////////////////////////////////////
  52. // CMainFrame construction/destruction
  53.  
  54. CMainFrame::CMainFrame()
  55. {
  56.     // TODO: add member initialization code here
  57.     
  58. }
  59.  
  60. CMainFrame::~CMainFrame()
  61. {
  62. }
  63.  
  64. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  65. {
  66.     if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  67.         return -1;
  68.  
  69.     if (!m_wndStatusBar.Create(this) ||
  70.         !m_wndStatusBar.SetIndicators(indicators,
  71.           sizeof(indicators)/sizeof(UINT)))
  72.     {
  73.         TRACE0("Failed to create status bar\n");
  74.         return -1;      // fail to create
  75.     }
  76.  
  77.     return 0;
  78. }
  79.  
  80. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  81. {
  82.     cs.style = WS_OVERLAPPED | WS_CAPTION | FWS_ADDTOTITLE
  83.         | WS_SYSMENU | WS_MINIMIZEBOX;
  84.  
  85.     return CFrameWnd::PreCreateWindow(cs);
  86. }
  87.  
  88. /////////////////////////////////////////////////////////////////////////////
  89. // CMainFrame diagnostics
  90.  
  91. #ifdef _DEBUG
  92. void CMainFrame::AssertValid() const
  93. {
  94.     CFrameWnd::AssertValid();
  95. }
  96.  
  97. void CMainFrame::Dump(CDumpContext& dc) const
  98. {
  99.     CFrameWnd::Dump(dc);
  100. }
  101.  
  102. #endif //_DEBUG
  103.  
  104. /////////////////////////////////////////////////////////////////////////////
  105. // CMainFrame message handlers
  106.  
  107. void CMainFrame::OnLanguageTranslation() 
  108. {
  109.     // TODO: Add your command handler code here
  110.     CTranslations translations;
  111.     translations.DoModal();    
  112. }
  113.  
  114. void CMainFrame::OnLocaleCurrency() 
  115. {
  116.     // TODO: Add your command handler code here
  117.     
  118. }
  119.  
  120. void CMainFrame::OnLocaleDate() 
  121. {
  122.     // TODO: Add your command handler code here
  123.     CDateFormat dateformat;
  124.     dateformat.DoModal();
  125. }
  126.  
  127. void CMainFrame::OnLocaleList() 
  128. {
  129.     // TODO: Add your command handler code here
  130.     CLanglist langlist;
  131.     if( IDOK==langlist.DoModal())
  132.     {
  133.         //IDOK means we selected a new set of resources and
  134.         // now we need to reload the MenuBar to get the new
  135.         // language reflected on the menu
  136.  
  137.         // Create the new menu and try to load it
  138.         CMenu menu;
  139.         if( menu.LoadMenu(IDR_MAINFRAME))
  140.         {    
  141.             CMenu *pMenu = GetMenu();
  142.  
  143.             if( pMenu && m_hMenuDefault != pMenu->m_hMenu )
  144.             {
  145.                 // Destroy the no longer used menu unless it's the default
  146.                 // menu as MFC insists on restoring that at close
  147.                 pMenu->DestroyMenu();
  148.             }
  149.             
  150.             // Set the frame to the new menu and detach it from
  151.             // the local variable
  152.             SetMenu(&menu);
  153.             menu.Detach();
  154.         }
  155.         // Exercise: Add invalidation of client window
  156.     }
  157.  
  158. }
  159.  
  160. // prototype, we hope
  161. void Test();
  162. int GetNumberFormat(LCID lcid, DWORD dwFlags, LPCTSTR lpValue,     LPCTSTR lpFormat, LPTSTR lpNumber, UINT cchNumber);
  163.  
  164. void CMainFrame::OnLocaleNumber() 
  165. {
  166.     // TODO: Add your command handler code here
  167.     CNumbFormat numberformat;
  168.     numberformat.DoModal();
  169. }
  170.  
  171. void CMainFrame::OnLocaleTime() 
  172. {
  173.     // TODO: Add your command handler code here
  174.     CTimeFormat timeformat;
  175.     timeformat.DoModal();
  176. }
  177.  
  178. void CMainFrame::OnLanguageSystem() 
  179. {
  180.     // TODO: Add your command handler code here
  181.     CSettings *cs = new CSettings;
  182.     if( cs)         
  183.     {
  184.         cs->DoModal();
  185.     }
  186.     delete cs;
  187. }
  188.