获取窗口创建成功返回执行

#include <stdio.h>

int main(int argc, char *argv[])
{
    printf("Hello, world\n");
    
    return 0;
}

//
// 注入钩子,截获系统消息。
        hHook = ::SetWindowsHookEx(WH_CALLWNDPROC, (HOOKPROC)WindowProc, hInstance, GetCurrentThreadId());

//
LRESULT CALLBACK WindowProc(int nCode, WPARAM wParam, LPARAM lParam);

LRESULT CALLBACK WindowProc(int nCode, WPARAM wParam, LPARAM lParam)//
{
    CWPSTRUCT* pMsg = (CWPSTRUCT*)(lParam);
    if (pMsg->message == WM_CREATE)
    {
        HWND hWnd = ::FindWindow(NULL, L"ScreenWings");
        if (hWnd)
        {
            CRect rc; 
            ::GetWindowRect(hWnd, &rc); //获取窗口矩形(大小)

            CPoint ptVertex[4]; //多边形顶点数组,形状为平行四边形
            ptVertex[0].x = 0 ;  
            ptVertex[0].y = 90;
            ptVertex[1].x = 1;
            ptVertex[1].y = 90;
            ptVertex[2].x = 1;
            ptVertex[2].y = 89;
            ptVertex[3].x = 0;
            ptVertex[3].y = 89;

            CRgn m_rgn;   //定义窗口显示区域
            m_rgn.CreatePolygonRgn(ptVertex, 4, ALTERNATE);//根据顶点数组创建窗口的显示区域

            ::SetWindowRgn(hWnd, m_rgn, TRUE);//添加到当前窗口

            //ShowInTaskbar(pMsg->hwnd, FALSE);
        }
    }
    else if (pMsg->message == WM_WINDOWPOSCHANGING)
    {
        if (pMsg->hwnd)
        {
            WCHAR szClassName[256];
            ::GetClassName(pMsg->hwnd, szClassName, 256);
            CString strClassName = szClassName;
            if (strClassName == L"WindowsForms10.Window.8.app.0.141b42a_r41_ad1")
            {
                OnTrayNotify(FindTrayWnd());
                OnTrayNotify(FindNotifyIconOverflowWindow());
            }
        }
    }

    return CallNextHookEx(hHook, nCode, wParam, lParam);
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值