zoukankan      html  css  js  c++  java
  • WTL在Win8.1系统WM_DROPFILES无法响应的解决办法

    由于UAC的限制,WM_DROPFILES只能由权限较低的APP拖拽到权限较高的APP,反之如果从权限较高的APP拖拽到低权限的APP上,WM_DROPFILES不会被发送到低权限的APP消息队列。所以,WM_DROPFILES会有时候变得不能响应。

    解决的办法,使用ChangeWindowMessageFilter注册WM_DROPFILES这个MEESSAGE。

    ChangeWindowMessageFilter是Vista以后的一个API,WinXP下并没有。

    这个API在User32.dll中,使用时LoadLibrary,GetProcAddress得到函数地址就能使用。

    1、在你的程序中添加以下函数:

    //register global messages for vista win7 win8.1
    typedef BOOL(WINAPI *_ChangeWindowMessageFilter)(UINT message, DWORD dwFlag);.
    BOOL AllowMeesageForVistaAbove(UINT uMessageID, BOOL bAllow)
    {
        BOOL bResult = FALSE;
        HMODULE hUserMod = NULL;
        //vista and later
        hUserMod = LoadLibrary(_T("user32.dll"));
        if( NULL == hUserMod )
        {
            return FALSE;
        }
       
        _ChangeWindowMessageFilter pChangeWindowMessageFilter =
            (_ChangeWindowMessageFilter)GetProcAddress( hUserMod, "ChangeWindowMessageFilter");
        if( NULL == pChangeWindowMessageFilter )
        {
            return FALSE;
        }
        bResult = pChangeWindowMessageFilter( uMessageID, bAllow ? 1 : 2 );//MSGFLT_ADD: 1, MSGFLT_REMOVE: 2
       
        if( NULL != hUserMod )
        {
            FreeLibrary( hUserMod );
        }
    
        return bResult;
    } 
    2、头文件定义以下宏 :

    #define MSGFLT_ADD 1
    
    #define MSGFLT_REMOVE 2

    3、在OnInitDialog中添加函数调用:

    AllowMeesageForVistaAbove(SPI_SETANIMATION, MSGFLT_ADD);
    
    //allow drop files
    AllowMeesageForVistaAbove(WM_DROPFILES, MSGFLT_ADD);



  • 相关阅读:
    ueditor单独调用图片上传
    百度Ueditor多图片上传控件
    linux基础之vim编辑器
    linux基础之进阶命令二
    linux基础之基础命令一
    Python基础之PyCharm快捷键大全
    IT菜鸟之VTP应用项目
    IT菜鸟之总结(Du teacher)
    IT菜鸟之DHCP
    IT菜鸟之路由器基础配置(静态、动态、默认路由)
  • 原文地址:https://www.cnblogs.com/ggzone/p/4052444.html
Copyright © 2011-2022 走看看