• CXFDialog对话框


    对话框

    #include "resource.h"

    class CXFDialog : public CDialog

    {

    public:

           CXFDialog( );

           CXFDialog(LPCTSTR lpszTemplateName, CWnd* pParentWnd = NULL);

           CXFDialog(UINT nIDTemplate, CWnd* pParentWnd = NULL);       // standard constructor

          

           void SetAutoDelete( BOOL bAutoDelete = FALSE );

           void SetTransparent( BOOL bTransparent = TRUE, BYTE byteDeep = 244 );

          

    protected:

           virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

           virtual void PostNcDestroy();

    protected:

           BOOL     m_bAutoDelete;

           BOOL     m_bTransparent;

           BYTE     m_byteDeep;

          

           afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);

           virtual BOOL OnInitDialog();

           virtual void OnOK();

           virtual void OnCancel();

           DECLARE_MESSAGE_MAP()         

    };

    CXFDialog::CXFDialog( )

    {

           m_bAutoDelete      =     FALSE;

           m_bTransparent     =     FALSE;

           m_byteDeep          =     250;

    }

    CXFDialog::CXFDialog(LPCTSTR lpszTemplateName, CWnd* pParent /*=NULL*/)

           : CDialog(lpszTemplateName, pParent)

    {

           m_bAutoDelete      =     FALSE;

           m_bTransparent     =     FALSE;

           m_byteDeep          =     250;

    }

    CXFDialog::CXFDialog(UINT nIDTemplate, CWnd* pParent /*=NULL*/)

           : CDialog(nIDTemplate, pParent)

    {

           m_bAutoDelete      =     FALSE;

           m_bTransparent     =     FALSE;

           m_byteDeep          =     250;

    }

    void CXFDialog::SetAutoDelete( BOOL bAutoDelete )

    {

           m_bAutoDelete      =     bAutoDelete;

    }

    void CXFDialog::SetTransparent( BOOL bTransparent, BYTE byteDeep )

    {

           m_bTransparent     =     bTransparent;

           m_byteDeep          =     byteDeep;

    }

    void CXFDialog::DoDataExchange(CDataExchange* pDX)

    {

           CDialog::DoDataExchange(pDX);

    }

    void CXFDialog::PostNcDestroy()

    {

           CDialog::PostNcDestroy();

           if( m_bAutoDelete && NULL != this )

                  delete this;

    }

    BEGIN_MESSAGE_MAP(CXFDialog, CDialog)

           ON_WM_CTLCOLOR()

    END_MESSAGE_MAP()

    HBRUSH CXFDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)

    {

           return CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

    }

    BOOL CXFDialog::OnInitDialog()

    {

           CDialog::OnInitDialog();

           if( m_bTransparent )

           {

                  SetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE, GetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE)^0x80000);

                  HINSTANCE hInst = LoadLibrary("User32.DLL");

                  if(hInst)

                  {

                         typedef BOOL (WINAPI *TRANSPARENTFUNC)(HWND,COLORREF,BYTE,DWORD);

                         TRANSPARENTFUNC fun  =     NULL;

                         //取得SetLayeredWindowAttributes函数指针    

                         fun  =     (TRANSPARENTFUNC)GetProcAddress( hInst, "SetLayeredWindowAttributes" );

                         if(fun)

                                fun( GetSafeHwnd(), 0, m_byteDeep, 2 );

                         FreeLibrary(hInst);

                  }

           }

          

           return TRUE;

    }

    void CXFDialog::OnOK()

    {

           CDialog::OnOK();

           PostNcDestroy( );

    }

    void CXFDialog::OnCancel()

    {

           CDialog::OnCancel();

           PostNcDestroy( );

    }

    class CMyDlg : public CDialog

    {

    public:

           CMyDlg();

    };

    CMyDlg::CMyDlg() : CDialog(IDD_DIALOG1)

    {

    }

    class CMyWinApp : public CWinApp

    {

    public:

           virtual BOOL InitInstance();

    };

    CMyWinApp theApp;

    BOOL CMyWinApp::InitInstance()

    {

           CXFDialog dlgEx(IDD_DIALOG1);

           dlgEx.SetTransparent(TRUE,135);

    //     dlgEx.OnCtlColor();

           dlgEx.DoModal();

           CMyDlg dlg;

           dlg.DoModal();

           return TRUE;

    }

  • 相关阅读:
    html5-css渐变色
    html5-css综合练习
    html5-css背景
    html5-css边框全
    html5-css边框img
    进程控制(二)与linux下的自有服务
    进程检测与控制(一)
    权限及软件包管理
    linux下文件权限管理
    vim及用户组管理
  • 原文地址:https://www.cnblogs.com/boobuy/p/2864772.html
Copyright © 2020-2023  润新知