zoukankan      html  css  js  c++  java
  • 判断ActiveX控件是Desgin Mode还是Runtime Mode

    对于MFC

    COleControl::AmbientUserMode

    Determines if the Container is in design mode or user mode.

    BOOL AmbientUserMode( );

    Return Value

    Nonzero if the container is in user mode; otherwise 0 (in design mode). If this property is not supported, this function returns 0.

    Remarks

    For example, a container might set this to FALSE in design mode.

    根据当前ActiveX控件当前所处的模式,修改OnDraw函数:

    BOOL bUserMode = FALSE;
    bUserMode = AmbientUserMode();
    if(bUserMode)
    {
        LPCTSTR pszText = _T("MFC 3.0 : User Mode");
    
        TextOut(di.hdcDraw, 
            (rc.left + rc.right) / 2, 
            (rc.top + rc.bottom) / 2, 
            pszText, 
            lstrlen(pszText));
    }
    else
    {
        LPCTSTR pszText = _T("MFC 3.0 : Design Mode");
        TextOut(di.hdcDraw, 
            (rc.left + rc.right) / 2, 
            (rc.top + rc.bottom) / 2, 
            pszText, 
            lstrlen(pszText));
    }

    对于ATL

    CComControlBase::GetAmbientUserMode

    Retrieves DISPID_AMBIENT_USERMODE, a flag indicating whether the container is in run-mode (TRUE) or design-mode (FALSE).

    HRESULT GetAmbientUserMode(BOOL& bUserMode);

    Parameters

    bUserMode  : 

    The property DISPID_AMBIENT_USERMODE.

    Return Value : 

    One of the standard HRESULT values.

    OnDraw中判断

    BOOL bUserMode = FALSE;
    HRESULT hr = GetAmbientUserMode(bUserMode);
    if(bUserMode)
    {
        LPCTSTR pszText = _T("ATL 3.0 : User Mode");
    
        TextOut(di.hdcDraw, 
            (rc.left + rc.right) / 2, 
            (rc.top + rc.bottom) / 2, 
            pszText, 
            lstrlen(pszText));
    }
    else
    {
        LPCTSTR pszText = _T("ATL 3.0 : Design Mode");
        TextOut(di.hdcDraw, 
            (rc.left + rc.right) / 2, 
            (rc.top + rc.bottom) / 2, 
            pszText, 
            lstrlen(pszText));
    }

        

  • 相关阅读:
    使用SpringSecurityOAuth2默认实现OAuth2授权示例
    Session与Token认证方式的区别
    OAuth协议简介
    MySQL5.7开启binlog日志,及数据恢复简单示例
    MySQL5.X给远程用户授权
    MySQL5.X安装
    MySQL8.0以上创建用户,并授权远程连接
    退役了
    2019牛客国庆day3-G &CF1238E
    luoguP4197:Peaks(Kruskal重构树+主席树)或者(点分树+离线)
  • 原文地址:https://www.cnblogs.com/MakeView660/p/6893687.html
Copyright © 2011-2022 走看看