zoukankan      html  css  js  c++  java
  • DUI-模态对话框的实现

    模态对话框要求自己实现自己的消息循环,当然,建议它还是处于主线程中,所以最好是由它再调用主线程的消息循环函数,此时主线程自身的消息循环函数被阻塞,等待模板对话框的消息循环函数退出

    参考代码如下:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    INT_PTR XX::DoModal(LPCWSTR lpszXmlId, HWND hParent/*=NULL*/bool bShadow/*=false*/, DM::CRect rect/* = NULL*/)
    {
        BOOL bEnableParent = FALSE;
        if(NULL == hParent)
        {
            hParent = GetActiveWnd();
        }
         
        if (hParent && hParent != ::GetDesktopWindow() && ::IsWindowEnabled(hParent))
        {
            ::EnableWindow(hParent, FALSE);
            bEnableParent = TRUE;
        }
     
        if(!DM_CreateWindow(lpszXmlId, rect.left,rect.top,rect.Width(),rect.Height(), hParent, bShadow))
        {
            ::EnableWindow(hParent, TRUE);
            return 0; // 此处失败了
        }
     
        GetClientRect(rect);
        if (!rect.IsRectEmpty())
        {
            CenterWindow();
        }
     
        SendMessage(WM_INITDIALOG);//发送init消息
     
        if(GetExStyle()&WS_EX_TOOLWINDOW)
        {
            ::ShowWindow(m_hWnd,SW_SHOWNOACTIVATE);
        }
        else
        {
            ::ShowWindow(m_hWnd,SW_SHOWNORMAL);
        }
     
         
        ::SetWindowPos(m_hWnd, /*HWND_TOP*/HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW);
             Run(m_hWnd,true);// 消息循环
     
        if (bEnableParent)
        {
            ::EnableWindow(hParent, TRUE);
        }
     
        return m_nRetCode;
    }
     
    void  XX::EndDialog( INT_PTR nResult )
    {
        m_nRetCode = nResult;
        PostMessage(WM_QUIT);
    }

    http://hgy413.com/1635.html

  • 相关阅读:
    九月学习计划与自我成长
    sqlyog无法连接mysql8.0的处理办法
    MySQL详细的攻略和玩法
    输入net start mysql显示MySQL 服务正在启动 . MySQL 服务无法启动。 服务没有报告任何错误。 请键入 NET HELPMSG 3534 以获得更多的帮助。
    MySQL详细安装教程
    2019上半年程序设计年度总结
    PTA12
    C#实现文本文件字符过滤
    C#字符串string和内存流MemoryStream及比特数组byte[]
    C# 流总结
  • 原文地址:https://www.cnblogs.com/findumars/p/6271629.html
Copyright © 2011-2022 走看看