Arx无模态窗口类定义

Arx无模态窗口类定义,单例模式

1、主窗体类定义
class CDlgScanDwg : public CAcUiDialog  //主窗体
{
...
    CDlgPrintPigeOut *m_pDlgPigeOut;   //子窗体指针,如果有子窗体的话
    static CDlgScanDwg* GetIntanse();
    static CDlgScanDwg*  m_pSigleton;  //单例模式指针


2、主窗体事件处理.cpp

void CDlgScanDwg::OnClose()
{
    if (m_pDlgPigeOut->GetSafeHwnd())
   {
    m_pDlgPigeOut->DestroyWindow();
    m_pDlgPigeOut = NULL;
   }
   CAcUiDialog::OnClose();
   this->DestroyWindow();
}

void CDlgScanDwg::OnCancel()
{
   if (m_pDlgPigeOut->GetSafeHwnd())
   {
    m_pDlgPigeOut->DestroyWindow();
    m_pDlgPigeOut = NULL;
   }
   CAcUiDialog::OnCancel();
   this->DestroyWindow();
}


void CDlgScanDwg::PostNcDestroy()
{
 CAcUiDialog::PostNcDestroy();
 delete this;
 m_pSigleton = NULL;
}


CDlgScanDwg* CDlgScanDwg::m_pSigleton = NULL;// 初始化指针

CDlgScanDwg* CDlgScanDwg::GetIntanse()
{
 if(!m_pSigleton->GetSafeHwnd())
 {
  m_pSigleton = new CDlgScanDwg();
  m_pSigleton->Create(CDlgScanDwg::IDD,acedGetAcadFrame());
 }
 return m_pSigleton;
}

3、调用方法
CDlgScanDwg *pDlg = CDlgScanDwg::GetIntanse();
 if (pDlg->GetSafeHwnd())
{
  pDlg->ShowWindow(SW_RESTORE);
}

 

你可能感兴趣的:(null,delete,Class)