zoukankan      html  css  js  c++  java
  • Qt 实现在隐藏标题栏情况下,窗口的缩放(未成功)

    呃,这是一个悲剧的版本,在这版本中,我按照网上大神的说法,试了一下,但是没有效果,不知道出错在了那里,和昨天一样,也是,没有理想的效果,这里贴上代码,记录一下

    资料连接:放评论

    需要包含头文件

    #include <windows.h>

    代码

    bool Widget::nativeEvent(const QByteArray &eventType, void *message, long *result)
    {
        Q_UNUSED(eventType);
        if (this->isMaximized())
        {
            return false;
        }
    
        const int HIT_BORDER = 5;
        const MSG *msg=static_cast<MSG*>(message);
        if(msg->message == WM_NCHITTEST) {
            int xPos = ((int)(short)LOWORD(msg->lParam)) - this->frameGeometry().x();
            int yPos = ((int)(short)HIWORD(msg->lParam)) - this->frameGeometry().y();
            if(this->childAt(xPos,yPos) == 0) {
                *result = HTCAPTION;
            } else {
                return false;
            }
            if(xPos > 0 && xPos < HIT_BORDER) {
                *result = HTLEFT;
            }
            if(xPos > (this->width() - HIT_BORDER) && xPos < (this->width() - 0)) {
                *result = HTRIGHT;
            }
            if(yPos > 0 && yPos < HIT_BORDER) {
                *result = HTTOP;
            }
            if(yPos > (this->height() - HIT_BORDER) && yPos < (this->height() - 0)) {
                *result = HTBOTTOM;
            }
            if(xPos > 0 && xPos < HIT_BORDER && yPos > 0 && yPos < HIT_BORDER) {
                *result = HTTOPLEFT;
            }
            if(xPos > (this->width() - HIT_BORDER) && xPos < (this->width() - 0) && yPos > 0 && yPos < HIT_BORDER) {
                *result = HTTOPRIGHT;
            }
            if(xPos > 0 && xPos < HIT_BORDER && yPos > (this->height() - HIT_BORDER) && yPos < (this->height() - 0)) {
                *result = HTBOTTOMLEFT;
            }
            if(xPos > (this->width() - HIT_BORDER) && xPos < (this->width() - 0) && yPos > (this->height() - HIT_BORDER) && yPos < (this->height() - 0)) {
                *result = HTBOTTOMRIGHT;
            }
            return true;
        }
        return false;
    
    }



  • 相关阅读:
    Java线程同步synchronized的理解
    MySQL基础操作(二)
    MySQL基础操作(一)
    MySQL备份--xtrabackup与mysqldump工具使用
    MySQL主从复制以及在本地环境搭建
    生活在长大——第一次冲刺小任务
    现代软件工程之敏捷开发
    入门github
    我的编程人生
    Java线程
  • 原文地址:https://www.cnblogs.com/DreamDog/p/9160061.html
Copyright © 2011-2022 走看看