如何设置 Win32 窗口非客户区的大小(本机) [英] How to set the size of the Non-client area of a Win32 window (native)

查看:56
本文介绍了如何设置 Win32 窗口非客户区的大小(本机)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何设置 Win32 窗口(本机)的非客户区大小.

How to set the size of the Non-client area of a Win32 window (native).

我想要的是使 CAPTION/TITLE 栏更粗.

What I want is to make the CAPTION/TITLE bar THICKER.

我已经阅读并被告知我应该处理 WM_NCCALCSIZE,但我在文档中找不到任何明确的内容.

I've read and been told that I should handle WM_NCCALCSIZE but I can't find nothing clear on the documentation.

来自 MSDN:

WM_NCCALCSIZE 通知

WM_NCCALCSIZE 消息在必须计算窗口客户区的大小和位置时发送.通过处理此消息,应用程序可以在窗口的大小或位置发生变化时控制窗口客户区的内容.

The WM_NCCALCSIZE message is sent when the size and position of a window's client area must be calculated. By processing this message, an application can control the content of the window's client area when the size or position of the window changes.

窗口通过其 WindowProc 函数接收此消息.

A window receives this message through its WindowProc function.

wParam如果 wParam 为 TRUE,则它指定应用程序应指示客户区的哪一部分包含有效信息.系统将有效信息复制到新客户区域内的指定区域.如果 wParam 为 FALSE,则应用程序不需要指明客户区的有效部分.

wParam If wParam is TRUE, it specifies that the application should indicate which part of the client area contains valid information. The system copies the valid information to the specified area within the new client area. If wParam is FALSE, the application does not need to indicate the valid part of the client area.

lParam如果 wParam 为 TRUE,lParam 指向一个 NCCALCSIZE_PARAMS 结构,该结构包含应用程序可以用来计算客户端矩形的新大小和位置的信息.如果 wParam 为 FALSE,则 lParam 指向一个 RECT 结构.进入时,该结构包含为窗口建议的窗口矩形.退出时,该结构应包含相应窗口客户区的屏幕坐标.

lParam If wParam is TRUE, lParam points to an NCCALCSIZE_PARAMS structure that contains information an application can use to calculate the new size and position of the client rectangle. If wParam is FALSE, lParam points to a RECT structure. On entry, the structure contains the proposed window rectangle for the window. On exit, the structure should contain the screen coordinates of the corresponding window client area.

推荐答案

您可以通过处理 WM_NCCALCSIZE 消息来设置非客户区的大小.但是不要这样做,除非您打算通过处理 WM_NCPAINT

you set the size of the non-client area by handling the WM_NCCALCSIZE message. But don't do this unless you plan to do all of the non-client drawing as well by handling WM_NCPAINT

这里有两个代码片段,一个处理 WM_NCCALCSIZE 并提供一个简单的 n 像素边框,另一个在 DefWindowProc 完成默认处理后添加一些额外的像素.

here are two code fragments, one that handles WM_NCCALCSIZE and provides a simple n pixel border, and another than adds some extra pixels after DefWindowProc has done the default handling.

case WM_NCCALCSIZE:
  {
  lRet = 0;
  const int cxBorder = 2;
  const int cyBorder = 2;
  InflateRect((LPRECT)lParam, -cxBorder, -cyBorder);
  }

case WM_NCCALCSIZE: 
  {
  LPNCCALCSIZE_PARAMS pncc = (LPNCCALCSIZE_PARAMS)lParam;
  //pncc->rgrc[0] is the new rectangle
  //pncc->rgrc[1] is the old rectangle
  //pncc->rgrc[2] is the client rectangle

  lRet = DefWindowProc (hwnd, WM_NCCALCSIZE, wParam, lParam);
  pncc->rgrc[0].top += ExtraCaptionHeight;
  }

通过将 WM_NCCALCSIZE 传递给 DefWindowProc 并查看前后 NCCALCSIZEPARAM 的值,您可以学到很多东西.

You can learn a lot by passing WM_NCCALCSIZE to DefWindowProc and looking at the values of the NCCALCSIZEPARAM before and after.

这篇关于如何设置 Win32 窗口非客户区的大小(本机)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆