home *** CD-ROM | disk | FTP | other *** search
/ Solo Programadores 22 / SOLO_22.iso / disk22 / visualcc / mfcedito.cpp
Encoding:
C/C++ Source or Header  |  1996-04-29  |  4.8 KB  |  191 lines

  1. // MFCEditor.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "MFCEditor.h"
  6.  
  7. #include "MainFrm.h"
  8. #include "MFCEditorDoc.h"
  9. #include "MFCEditorView.h"
  10.  
  11. #ifdef _DEBUG
  12. #define new DEBUG_NEW
  13. #undef THIS_FILE
  14. static char THIS_FILE[] = __FILE__;
  15. #endif
  16.  
  17. /////////////////////////////////////////////////////////////////////////////
  18. // CMFCEditorApp
  19.  
  20. BEGIN_MESSAGE_MAP(CMFCEditorApp, CWinApp)
  21.     //{{AFX_MSG_MAP(CMFCEditorApp)
  22.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  23.         // NOTE - the ClassWizard will add and remove mapping macros here.
  24.         //    DO NOT EDIT what you see in these blocks of generated code!
  25.     //}}AFX_MSG_MAP
  26.     // Standard file based document commands
  27.     ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  28.     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  29.     // Standard print setup command
  30.     ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  31. END_MESSAGE_MAP()
  32.  
  33. /////////////////////////////////////////////////////////////////////////////
  34. // CMFCEditorApp construction
  35.  
  36. CMFCEditorApp::CMFCEditorApp()
  37. {
  38.     // TODO: add construction code here,
  39.     // Place all significant initialization in InitInstance
  40.  
  41.     Antes = CTime::GetCurrentTime();
  42. }
  43.  
  44. /////////////////////////////////////////////////////////////////////////////
  45. // The one and only CMFCEditorApp object
  46.  
  47. CMFCEditorApp theApp;
  48.  
  49. /////////////////////////////////////////////////////////////////////////////
  50. // CMFCEditorApp initialization
  51.  
  52. BOOL CMFCEditorApp::InitInstance()
  53. {
  54.     // Standard initialization
  55.     // If you are not using these features and wish to reduce the size
  56.     //  of your final executable, you should remove from the following
  57.     //  the specific initialization routines you do not need.
  58.  
  59. #ifdef _AFXDLL
  60.     Enable3dControls();            // Call this when using MFC in a shared DLL
  61. #else
  62.     Enable3dControlsStatic();    // Call this when linking to MFC statically
  63. #endif
  64.  
  65.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  66.  
  67.     // Register the application's document templates.  Document templates
  68.     //  serve as the connection between documents, frame windows and views.
  69.  
  70.     CSingleDocTemplate* pDocTemplate;
  71.     pDocTemplate = new CSingleDocTemplate(
  72.         IDR_MAINFRAME,
  73.         RUNTIME_CLASS(CMFCEditorDoc),
  74.         RUNTIME_CLASS(CMainFrame),       // main SDI frame window
  75.         RUNTIME_CLASS(CMFCEditorView));
  76.     AddDocTemplate(pDocTemplate);
  77.  
  78.     // Parse command line for standard shell commands, DDE, file open
  79.     CCommandLineInfo cmdInfo;
  80.     ParseCommandLine(cmdInfo);
  81.  
  82.     // Dispatch commands specified on the command line
  83.     if (!ProcessShellCommand(cmdInfo))
  84.         return FALSE;
  85.  
  86.     // Establecer el color de las ventanas de dißlogo
  87.  
  88.     SetDialogBkColor(RGB(255,255,0),RGB(255,0,0));
  89.  
  90.     return TRUE;
  91. }
  92.  
  93. /////////////////////////////////////////////////////////////////////////////
  94. // CAboutDlg dialog used for App About
  95.  
  96. class CAboutDlg : public CDialog
  97. {
  98. public:
  99.     CAboutDlg();
  100.  
  101. // Dialog Data
  102.     //{{AFX_DATA(CAboutDlg)
  103.     enum { IDD = IDD_ABOUTBOX };
  104.     //}}AFX_DATA
  105.  
  106.     // ClassWizard generated virtual function overrides
  107.     //{{AFX_VIRTUAL(CAboutDlg)
  108.     protected:
  109.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  110.     //}}AFX_VIRTUAL
  111.  
  112. // Implementation
  113. protected:
  114.     //{{AFX_MSG(CAboutDlg)
  115.         // No message handlers
  116.     //}}AFX_MSG
  117.     DECLARE_MESSAGE_MAP()
  118. };
  119.  
  120. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  121. {
  122.     //{{AFX_DATA_INIT(CAboutDlg)
  123.     //}}AFX_DATA_INIT
  124. }
  125.  
  126. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  127. {
  128.     CDialog::DoDataExchange(pDX);
  129.     //{{AFX_DATA_MAP(CAboutDlg)
  130.     //}}AFX_DATA_MAP
  131. }
  132.  
  133. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  134.     //{{AFX_MSG_MAP(CAboutDlg)
  135.         // No message handlers
  136.     //}}AFX_MSG_MAP
  137. END_MESSAGE_MAP()
  138.  
  139. // App command to run the dialog
  140. void CMFCEditorApp::OnAppAbout()
  141. {
  142.     CAboutDlg aboutDlg;
  143.     aboutDlg.DoModal();
  144. }
  145.  
  146. /////////////////////////////////////////////////////////////////////////////
  147. // CMFCEditorApp commands
  148.  
  149. BOOL CMFCEditorApp::OnIdle(LONG lCount) 
  150. {
  151.     // TODO: Add your specialized code here and/or call the base class
  152.     
  153.     CTime Ahora;
  154.     CTimeSpan Diferencia;
  155.  
  156.     Ahora = CTime::GetCurrentTime();
  157.     Diferencia = Ahora - Antes;
  158.     
  159.     if(Diferencia.GetTotalSeconds() >= 3)
  160.     {
  161.         Antes = Ahora;
  162.         MessageBeep((UINT)-1);
  163.     }
  164.  
  165.     CWinApp::OnIdle(lCount);
  166.     return TRUE;
  167. }
  168.  
  169. BOOL CMFCEditorApp::ProcessMessageFilter(int code, LPMSG lpMsg) 
  170. {
  171.     // TODO: Add your specialized code here and/or call the base class
  172.  
  173.     if(lpMsg->message == WM_LBUTTONDOWN)
  174.         MessageBeep((UINT)-1);
  175.     
  176.     return CWinApp::ProcessMessageFilter(code, lpMsg);
  177. }
  178.  
  179. int CMFCEditorApp::Run() 
  180. {
  181.     // TODO: Add your specialized code here and/or call the base class
  182.     int Retorno;
  183.  
  184.     AfxMessageBox("El bucle de mensajes va a comenzar");
  185.     Retorno = CWinApp::Run();
  186.     AfxMessageBox("El bucle de mensajes ha finalizado"); 
  187.  
  188.     return Retorno;
  189. }
  190.  
  191.