回复: 仿win7窗体自动顶部最大化左侧右侧半屏效果
#16 回 圣域天子 的帖子 [stlcours 04-18 18:07]
圣域天子:你好象不理解我提出的需求是什么。
(2017-04-18 16:12)
我觉得我明白。而且用WINAPI实现过。我的意思是,有了遮罩,你可以随心所欲的实现各种效果,因为背景你都可以作假了,还有什么不能做的。
#17 [return 04-18 20:20]
#18 [619304288 04-24 09:01]
#include "HMainWindow.h"
#include
#ifdef Q_OS_WIN
#include
#include
#ifndef GET_X_LPARAM
#define GET_X_LPARAM(lParam)((int)(short)LOWORD(lParam))
#endif
#ifndef GET_Y_LPARAM
#define GET_Y_LPARAM(lParam)((int)(short)HIWORD(lParam))
#endif
#endif
HMainWindow::HMainWindow(QWidget *parent) : QMainWindow(parent)
{
setObjectName("HFramer");
setWindowTitle("HFramer");
setWidgetBorderless(this);
}
void HMainWindow::setWidgetBorderless(const QWidget *widget)
{
setWindowFlags( Qt::WindowMinimizeButtonHint | Qt::FramelessWindowHint);
#ifdef Q_OS_WIN
HWND hwnd = reinterpret_cast(widget->winId());
DWORD style = GetWindowLong(hwnd, GWL_STYLE);
SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME | WS_CAPTION);
#endif
}
bool HMainWindow::nativeEvent(const QByteArray &eventType, void *message, long *result)
{
#ifdef Q_OS_WIN
if (eventType != "windows_generic_MSG")
return false;
MSG* msg = static_cast(message);
QWidget* widget = QWidget::find(reinterpret_cast(msg->hwnd));
if (!widget)
return false;
switch (msg->message) {
case WM_NCCALCSIZE: {
*result = 0;
return true;
}
case WM_NCHITTEST: {
const LONG borderWidth = 9;
RECT wi ..
#19 回 kimtaikee 的帖子 [圣域天子 04-24 14:11]
kimtaikee:圣域是需要的这个效果吧?仅供示意,没有完善。 (2017-04-17 16:14)
也不是系统级的 ... ...
其实在 tdesktop 中有成功实现的,不过我看了一天多都没找到它是怎么实现的。
前面两位都是高手。
而我是吹毛求疵的完美主义者~~~