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

📄 property.cpp

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

#include "stdafx.h"
#include "zddesk.h"
#include "frame.h"
#include "property.h"

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

/////////////////////////////////////////////////////////////////////////////
// CZDDeskProperties dialog


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

   // Save the frame pointer
   m_pFrame = pFrame;
}

// Binds the class data members to the dialog's controls
void CZDDeskProperties::DoDataExchange(CDataExchange* pDX)
{
   CDialog::DoDataExchange(pDX);
   //{{AFX_DATA_MAP(CZDDeskProperties)
   DDX_Control(pDX, IDC_SPIN, m_Spin);
   DDX_Control(pDX, IDC_DESKCOUNT, m_DeskCount);
   //}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CZDDeskProperties, CDialog)
   //{{AFX_MSG_MAP(CZDDeskProperties) 
   //}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CZDDeskProperties message handlers

// Handles dialog initialization -- Loads the desk name fields and sets the spin
// control to the number of configured desks
BOOL CZDDeskProperties::OnInitDialog() 
{
   // Call the base class
   CDialog::OnInitDialog();

   // Set the current number of desks and set the spin control range: 2 - MAX_DESKS
   m_Spin.SetPos(m_pFrame->m_nDeskCount);
   m_Spin.SetRange(2,CZDDeskFrame::MAX_DESKS);

   CEdit *pEdit;
   for(int i = 0; i < CZDDeskFrame::MAX_DESKS; i++)
   {
      // Load the edit control with the desk name
      SetDlgItemText(IDC_NAME1+i,m_pFrame->m_arrStrDeskName[i]);
      pEdit = (CEdit *) GetDlgItem(IDC_NAME1+i);

      // Limit the desk name
      if(pEdit)
         pEdit->LimitText(CZDDeskFrame::MAX_NAME);
   }
   
   return TRUE;  // return TRUE unless you set the focus to a control
                 // EXCEPTION: OCX Property Pages should return FALSE
}

// Handles the OK button -- does some error checking for the number of
// desks then saves the number and desktop names
void CZDDeskProperties::OnOK() 
{
   // Get the number of desks
   int nNewDeskCount = m_Spin.GetPos();

   // Reducing the number of desks...
   if(nNewDeskCount < m_pFrame->m_nDeskCount)
   {
      // Can't remove the current desk
      if(nNewDeskCount <= m_pFrame->m_nCurrDesk)
      {
         // Display an error message
         AfxMessageBox(IDS_DESK_CANTREMOVE,MB_ICONWARNING|MB_OK);
         return;
      }

      // Get the number of glued windows
      int nGluedCount = m_pFrame->GetGluedCount();

      // Make sure that the desktops getting zapped are empty
      for(int i = nNewDeskCount; i < m_pFrame->m_nDeskCount; i++)
      {
         // Are there other windows on the desk besides glued ones???
         // If so, you can't remove the desk
         if(m_pFrame->GetWindowCount(i) > nGluedCount)
         {
            // Display an error message
            AfxMessageBox(IDS_DESK_NOTEMPTY,MB_ICONWARNING|MB_OK);
            return;
         }
      }      
   }

   // Set the desk count
   m_pFrame->m_nDeskCount = nNewDeskCount;

   // Get the titles
   for(int i = 0; i < CZDDeskFrame::MAX_DESKS; i++)
   {
      GetDlgItemText(IDC_NAME1+i,
                     m_pFrame->m_arrStrDeskName[i].GetBuffer(CZDDeskFrame::MAX_NAME+1),
                     CZDDeskFrame::MAX_NAME+1);
   }

   // Set the tooltip title for the current desktop, just in case we renamed
   // it in the properties dialog
   m_pFrame->SetCurrentToolTip();

   // Call the base class now, everything looks okay
   CDialog::OnOK();
}



⌨️ 快捷键说明

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