zoukankan      html  css  js  c++  java
  • 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;

    }

  • 相关阅读:
    Java实现 蓝桥杯 生命游戏
    Java实现 蓝桥杯 生命游戏
    Java实现UVA10131越大越聪明(蓝桥杯每周一题)
    Linux 静态库&动态库调用
    linux下c++开发环境安装(eclipse+cdt)
    怎样在Windows和Linux下写相同的代码
    教会你如何编写makefile文件
    Linux编译多个不同目录下的文件以及静态库、动态库的使用
    Fedora 17 下安装codeblocks
    Fedora 下安装codeblocks
  • 原文地址:https://www.cnblogs.com/boobuy/p/2864772.html
Copyright © 2011-2022 走看看