• 周报_2012第11周(2012/03/112012/03/17)


    项目:X保密项目

    2012.03.12

    // Win XP 需要判断取消操作.    By lishupeng@360.cn 2012/03/12 11:49.
        if (FileOp.fAnyOperationsAborted)
        {
            bRet = FALSE;
        }

    const int gcn_SEC_DELAY = 100;    // 等待 HTTP Download 下载线程处理网络数据。
                                    // By lishuepng@360.cn 2012/03/12 16:37

    if (Report(STAT_*))
                {
                    ShowWindow(SW_HIDE);
                    Delay(gcn_SEC_DELAY);
                    PostMessage(WM_CLOSE);
                    //TerminateProcess(GetCurrentProcess(),0);

                    //PostQuitMessage(-1);
                    //TerminateProcess(GetCurrentProcess(),0);
                }

    2012.03.13

    \BackUp\import.fg 配置文件 –> \AppData\Roaming\360Desktop

    2012.03.14

    // DRAWENTIRE时窗口句柄为空。 RedrawWindow时窗口句柄有效。
                //m_wndMenu = ::WindowFromDC(lpDIS->hDC);
                //::GetWindowRect(m_wndMenu, &rectTmp);

    if (ODA_SELECT == lpDIS->itemAction)
    {
        // 菜单高度超过屏幕高度时,菜单项位置会变化,每次选中时需要保存菜单项位置。
        m_wndMenu = ::WindowFromDC(lpDIS->hDC);
       
        // 获取菜单的裁剪区域
        ::GetClipBox(lpDIS->hDC, &rectTmp);
       
        // 判断菜单是否被裁剪,如果被裁剪则计算顶端偏移位置。(20像素为菜单顶端和底端箭头按钮的高度)
        int nTopOffset = rectTmp.top ? 20 - rectTmp.top : 0;
       
        ::GetWindowRect(m_wndMenu, &rectTmp);
        // 系统内置 V:3 像素边框
        rectTmp.top    = rectTmp.top + lpDIS->rcItem.top + gcn_COLOR_MARGIN_TOP + 3 + nTopOffset;
        rectTmp.bottom = rectTmp.top + bmpInfo.bmHeight;
        // 系统内置 H:4 像素边框
        rectTmp.left += 4;
        m_vecIconRect.clear();
        for (int i = 0; i < s_nColorMenuItemCnt; ++i)
        {
            rectTmp.left = rectTmp.left + gcn_COLOR_MARGIN_H;               
            rectTmp.right = rectTmp.left + bmpInfo.bmWidth;               
            m_vecIconRect.push_back(rectTmp);
        }

        // 鼠标进入热区后截获环境菜单的窗口过程。    Added by Li Shupeng 2012\02\29 22:13.
        if (s_pCurMenuProc == NULL)
        {
            this->PostMessageW(UDM_CONTEXTMENU_HOOK, WPARAM(m_wndMenu), NULL);
        }
    }

    LRESULT CFolderView::OnMeasureItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& b_ret)
    {   
        int nIDCtl = (UINT)wParam;
        LPMEASUREITEMSTRUCT lpDrawItemStruct = (LPMEASUREITEMSTRUCT)lParam;

        // Windows XP 下判断控件类型: 菜单项 TEXT_BKCOLOR_COMMAND_IDBASE(区别 Notepad++ 的自绘菜单项)
        if (ODT_MENU == lpDrawItemStruct->CtlType && TEXT_BKCOLOR_COMMAND_IDBASE == lpDrawItemStruct->itemID)


    }

    LRESULT CFolderView::OnDrawItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& b_ret)
    {
        int nCtrlID = (UINT)wParam;
        LPDRAWITEMSTRUCT lpDIS = (LPDRAWITEMSTRUCT)lParam;   

        // Windows XP 下判断控件类型: 菜单项 TEXT_BKCOLOR_COMMAND_IDBASE(区别 Notepad++ 的自绘菜单项)
        if (ODT_MENU == lpDIS->CtlType && TEXT_BKCOLOR_COMMAND_IDBASE == lpDIS->itemID)


    }

    2012.03.15

    调查截图操作异常:全屏的截图进程启动之后,再激活后台进程窗口,截图进程的窗口过程将不会再接收到键盘消息。

    解决方案:创建线程监控激活的进程窗口。

    virtual BOOL PreTranslateMessage(MSG* pMsg)
    {
        if(pMsg->message==WM_KEYDOWN)
        {
            HWND hWndLiveWriter = ::FindWindowW(_T("WindowsForms10.Window.8.app.0.33c0d9d"), NULL);
            switch ((int)pMsg->wParam)
            {
            case VK_ESCAPE:
                Report(STAT_ESC);
                ShowWindow(SW_HIDE);
                Delay(gcn_SEC_DELAY);
                PostMessage(WM_CLOSE);
                return TRUE;
            case VK_SHIFT:               
                if (hWndLiveWriter)
                {
                    ::ShowWindow(hWndLiveWriter, SW_SHOW);
                }
                break;
            case VK_CONTROL:               
                if (hWndLiveWriter)
                {
                    ::SetForegroundWindow(m_hWnd);
                }
                break;
            }
        }

        if( CFrameWindowImpl<CMainFram>::PreTranslateMessage(pMsg) )
        {
            return TRUE;
        }
        else
        {
            return FALSE;
        }
    }

    DWORD dwThreadId = 0;
    g_hThreadActive = CreateThread(
        NULL,                   // default security attributes
        0,                      // use default stack size 
        MonitorActiveThread,    // thread function name
        wndMain.m_hWnd,         // argument to thread function
        CREATE_SUSPENDED,       // use default creation flags
        &dwThreadId);            // returns the thread identifier
    if (g_hThreadActive)
    {
        ResumeThread(g_hThreadActive);
    }


     

    if (g_hThreadActive)
    {
        TerminateThread(g_hThreadActive, 0);
        CloseHandle(g_hThreadActive);
        g_hThreadActive = NULL;
    }

    DWORD WINAPI MonitorActiveThread( LPVOID lpParam )
    {
        while (true)
        {
            HWND hWndMainfrm = (HWND)lpParam;
            if (hWndMainfrm == NULL)
            {
                break;
            }
            HWND hWndForeground = ::GetForegroundWindow();
            if (hWndForeground && (hWndMainfrm != hWndForeground))
            {
                ::SetForegroundWindow(hWndMainfrm);
            }               
        }

        return 0;
    }

  • 相关阅读:
    Java POI Word 写文档
    安装SQL Server Management Studio遇到的29506错误
    DataSet中的relation
    如何在Eclipse中配置Tomcat
    button与submit
    redis应用场景
    机器学习实战-KNN(K-近邻算法)详解
    python中的random扩展
    php函数实现文章列表显示的几秒前,几分钟前,几天前等方法
    HTML5的Video标签的属性,方法和事件汇总
  • 原文地址:https://www.cnblogs.com/DancingFish/p/2391554.html
Copyright © 2020-2023  润新知