刘华世的官方博客

C++语言 如QQ般隐藏的窗体

复制代码
BOOL CBeginDlg::OnInitDialog()
{
    SetTimer(1, 100, NULL); //触发定时器

}

void CBeginDlg::OnTimer(UINT_PTR nIDEvent)
{
    // TODO: 在此添加消息处理程序代码和/或调用默认值
    //MessageBox(L"hello");
    CRect rc;
    CRect rect;
    GetWindowRect(&rect);
    rc.CopyRect(&rect);
    CPoint pOint;
    GetCursorPos(&pOint);
    CString s;
    s.Format(L"%d,%d", pOint.x, pOint.y);
    SetWindowTextW(s);
    if(rect.top<0 && PtInRect(rect, pOint)) //当鼠标在窗体内时
    {
        rect.top = 0;
        MoveWindow(rect.left, rect.top, rc.Width(), rc.Height());

    }
    else if(rect.top>-3 && rect.top < 3 && !PtInRect(rect, pOint)) //当鼠标在屏幕上边框时
    {
        rect.top = 3-rect.Height();
        MoveWindow(rect.left, rect.top, rc.Width(), rc.Height());

    }


    CDialog::OnTimer(nIDEvent);
}
复制代码
posted @   pythonschool  阅读(280)  评论(0编辑  收藏  举报
编辑推荐:
· ASP.NET Core 模型验证消息的本地化新姿势
· 对象命名为何需要避免'-er'和'-or'后缀
· SQL Server如何跟踪自动统计信息更新?
· AI与.NET技术实操系列:使用Catalyst进行自然语言处理
· 分享一个我遇到过的“量子力学”级别的BUG。
阅读排行:
· C# 中比较实用的关键字,基础高频面试题!
· .NET 10 Preview 2 增强了 Blazor 和.NET MAUI
· 为什么AI教师难以实现
· 如何让低于1B参数的小型语言模型实现 100% 的准确率
· AI Agent爆火后,MCP协议为什么如此重要!
刘华世的官方博客
点击右上角即可分享
微信分享提示