⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zddesk.cpp

📁 这是书上的代码
💻 CPP
字号:

#include "stdafx.h"
#include "zddesk.h"

#include "frame.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CZDDeskApp

BEGIN_MESSAGE_MAP(CZDDeskApp, CWinApp)
   //{{AFX_MSG_MAP(CZDDeskApp)
   //}}AFX_MSG_MAP

   // Standard file based document commands
   ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
   ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CZDDeskApp construction

// Constructor
CZDDeskApp::CZDDeskApp()
{
}

/////////////////////////////////////////////////////////////////////////////
// App object

// The one and only application object
CZDDeskApp theApp;


// 通过建立互斥来判断本程序是否已经运行
BOOL CZDDeskApp::AlreadyRunning()
{
   BOOL bFound = FALSE;

   // Try to create a mutex with the app's name
   HANDLE hMutexOneInstance = ::CreateMutex(NULL,TRUE,_T(AfxGetAppName()));

   // Already there...means that we are already running an instance
   if(::GetLastError() == ERROR_ALREADY_EXISTS)
      bFound = TRUE;

   // Release the mutex
   if(hMutexOneInstance)
      ::ReleaseMutex(hMutexOneInstance);

   return(bFound);
}

/////////////////////////////////////////////////////////////////////////////
//初始化函数
BOOL CZDDeskApp::InitInstance()
{
   // Command line info -- used by the splash screen
   CCommandLineInfo cmdInfo;   ParseCommandLine(cmdInfo);
   // 应用程序中只允许一个事例运行
   if(AlreadyRunning())
   {
      AfxMessageBox(IDS_ALREADY_RUNNING,MB_OK|MB_ICONWARNING);
      return(FALSE);
   }

    // Enable 3D controls
   Enable3dControlsStatic();

   // Construct the main window and load its definition
   CZDDeskFrame *pFrame = new CZDDeskFrame();
   if(!pFrame->LoadFrame(IDR_MAINFRAME,WS_OVERLAPPEDWINDOW))
      return(FALSE);

   // 生成框架窗口,然后隐藏 
   // 框架窗口的任只是用对从托盘来的消息进行处理
   m_pMainWnd = pFrame;
   m_pMainWnd->ShowWindow(SW_HIDE);
   m_pMainWnd->UpdateWindow();

   // Load the common control DLL
   ::InitCommonControls();
   
   return(TRUE);
}

/////////////////////////////////////////////////////////////////////////////
// CAbout dialog

// Constructor
CAbout::CAbout(CWnd* pParent /*=NULL*/)
   : CDialog(CAbout::IDD, pParent)
{
   //{{AFX_DATA_INIT(CAbout)
      // NOTE: the ClassWizard will add member initialization here
   //}}AFX_DATA_INIT
}

// Bind data members for dialog controls
void CAbout::DoDataExchange(CDataExchange* pDX)
{
   CDialog::DoDataExchange(pDX);
   //{{AFX_DATA_MAP(CAbout)
      // NOTE: the ClassWizard will add DDX and DDV calls here
   //}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CAbout, CDialog)
   //{{AFX_MSG_MAP(CAbout)
   ON_WM_CTLCOLOR()
   //}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAbout message handlers

// Handles control colors -- overridden to change the background color of the
// dialog to light gray so that the ZDDesk logo will look correct no matter
// what background color we have set
HBRUSH CAbout::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
   // We only care about the dialog's color
   if(nCtlColor == CTLCOLOR_DLG)
   {
      // Set the background color to light gray
      static HBRUSH hbr = ::CreateSolidBrush(RGB(192,192,192));
      return(hbr);
   }  // Call the default handling for the rest
   else return CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -