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;
    
    }



  • 相关阅读:
    我的git笔记
    我的 Sublime Text 2 笔记
    在Windows系统配置Jekyll
    纯CSS3打造七巧板
    JavaScript原型之路
    基于Grunt构建一个JavaScript库
    How React Works (一)首次渲染
    hadoop2.4 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
    pyinstaller打包python源程序访问hive
    hadoop balance均衡datanode存储不起作用问题分析
  • 原文地址:https://www.cnblogs.com/DreamDog/p/9160061.html
Copyright © 2011-2022 走看看