无边框窗体缩放时抖动

PG_12138 PG_12138 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
刚接触win32, 写了一个简单的无边框窗体。但当在窗体左上角对窗体进行缩放时,窗体的右边界和下边界会不断抖动。在右上角和左下角缩放时有相同的问题。在右下角缩放时是正常的。请问怎么解决?
代码如下
#if defined(UNICODE) && !defined(_UNICODE)
#define _UNICODE
#elif defined(_UNICODE) && !defined(UNICODE)
#define UNICODE
#endif

#include <tchar.h>
#include <windows.h>

/* Declare Windows procedure */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

/* Make the class name into a global variable */
TCHAR szClassName[ ] = _T("CodeBlocksWindowsApp");

int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nCmdShow)
{
HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */

/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);

/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use Windows's default colour as the background of the window */
wincl.hbrBackground = (HBRUSH) COLOR_GRAYTEXT;

/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
return 0;

/* The class is registered, let's create the program*/
hwnd = CreateWindowEx (
0, /* Extended possibilites for variation */
szClassName, /* Classname */
_T("Code::Blocks Template Windows App"), /* Title Text */
WS_POPUP, /* default window */
200, /* Windows decides the position */
200, /* where the window ends up on the screen */
640, /* The programs width */
480, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);

/* Make the window visible on the screen */
ShowWindow (hwnd, nCmdShow);

/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}

/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
}


/* This function is called by the Windows function DispatchMessage() */

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
POINT pt;
RECT rcClient;

switch (message) /* handle the messages */
{

case WM_NCHITTEST:

pt.x = LOWORD(lParam);
pt.y = HIWORD(lParam);
ScreenToClient(hwnd,&pt);
GetClientRect(hwnd, &rcClient);

if (pt.x<rcClient.left+5&&pt.y<rcClient.top+5)//×óÉϽÇ
{
return HTTOPLEFT;
}
if (pt.x>rcClient.right-5 && pt.y<rcClient.top+5)//ÓÒÉϽÇ
{
return HTTOPRIGHT;
}
if (pt.x<rcClient.left+5 && pt.y>rcClient.bottom-5)//×óϽÇ
{
return HTBOTTOMLEFT;
}
if (pt.x>rcClient.right-5 && pt.y>rcClient.bottom-5)//ÓÒϽÇ
{
return HTBOTTOMRIGHT;
}
if (pt.y<rcClient.top+10)
{
return HTCAPTION;
}
break;

case WM_DESTROY:
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}

return 0;
}
...全文

相关推荐

flex 苹果鱼眼效果及win7窗体效果

NULL 博文链接:https://wwww2.iteye.com/blog/1581549

weixin_38669628

Winform布局自适应:从原理到实践,打造智能窗体缩放方案

在桌面应用开发中,界面布局自适应是提升用户体验的关键技术,尤其在多分辨率、多显示器环境下。其核心原理是通过计算容器尺寸变化的比例因子,动态调整内部控件的位置、大小和字体等属性,实现视觉一致性。这项技术的工程价值在于将开发者从繁琐的手动坐标计算中解放出来,通过声明式配置实现自动化响应,大幅提升开发效率和代码可维护性。在Winform开发场景中,面对复杂的数据录入界面或监控大屏,传统的Anchor、Dock属性或TableLayoutPanel常难以满足非线性、按比例缩放的需求。本文聚焦于**Winform布局

congjukun0600

FrameLessWinApi(Qt无边框窗口调用winAPI实现缩放功能).zip

Qt无边框窗口可以使用重载鼠标的方法去实现窗口缩放功能,但是会存在窗口抖动效果,但调用系统的API接口,可以在窗口缩放的时候避免出现窗口抖动情况,但是唯一缺点是不支持跨平台

离歌漠

易语言源码易语言透明窗口上加组件例程

易语言源码易语言透明窗口上加组件例程

codemami

OpenEL GS滤镜处理(缩放滤镜、灵魂出窍滤镜、抖动滤镜、闪白滤镜、毛刺滤镜、幻觉滤镜).zip

详细地介绍了缩放滤镜、灵魂出窍滤镜、抖动滤镜、闪白滤镜、毛刺滤镜、幻觉滤镜实现原理和实现流程,并详细的注释说明的代码逻辑。

╰つ栺尖篴夢ゞ
评论 5
收藏 已收藏
分享
返回顶部
PG_12138
界面 15,976 成员 115,866 内容