简体   繁体   English

WM_NCCALCSIZE,自定义客户区和滚动条

[英]WM_NCCALCSIZE, custom client area, and scroll bars

I have an MFC app that embeds a Scintilla text edit control. 我有一个嵌入Scintilla文本编辑控件的MFC应用程序。 I want to customize the Scintilla control to display some custom controls next to the vertical scrollbar. 我想自定义Scintilla控件以在垂直滚动条旁边显示一些自定义控件。 Essentially, I want to render some controls in the orange area below, where the green area represent the scroll bars: 本质上,我想在下面的橙色区域中渲染一些控件,其中绿色区域代表滚动条:

所需客户区

I tried overriding the WM_NCCALCSIZE message of the Scintilla window and subtracting an offset from the right side of the client rectangle. 我尝试覆盖Scintilla窗口的WM_NCCALCSIZE消息,并从客户端矩形的右侧减去偏移量。 Here is the code: 这是代码:

void CScintillaCtrl::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpncsp)
{
    CWnd::OnNcCalcSize(bCalcValidRects, lpncsp);
    lpncsp->rgrc[0].right -= 100;
}

However, this causes the vertical and horizontal scroll bars to reposition themselves to account for the smaller client width, as shown below: 但是,这会导致垂直和水平滚动条重新定位以适应较小的客户端宽度,如下所示:

滚动条与客户端的偏移量

I'm not sure if this behavior is caused by Scintilla or Windows. 我不确定这种现象是由Scintilla还是Windows引起的。 Is there a way I can adjust the client area and preserve the positions of the scroll bars? 有什么方法可以调整工作区并保留滚动条的位置?

I found a Scintilla specific solution. 我找到了Scintilla特定的解决方案。 I can use the SCI_SETMARGINRIGHT command to add a margin to the right side of the client area, and then render my controls inside that. 我可以使用SCI_SETMARGINRIGHT命令在客户区的右侧添加边距,然后在其中渲染控件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 wm_nccalcsize,win7 aero和opengl-创建自定义窗口框架 - wm_nccalcsize, win7 aero and opengl - creating custom window frame 为什么处理 WM_NCCALCSIZE 会导致我的窗口跳转? - Why does handling WM_NCCALCSIZE cause my window to jump? 如何处理WM_NCCALCSIZE并制作类似chrome的界面? - How do I handle WM_NCCALCSIZE and make chrome-like interface? 在拦截 WM_NCCALCSIZE 时将 LPNCCALCSIZE_PARAMS 重新解释为 LPRECT 是否安全? - Is it safe to reinterpret_cast LPNCCALCSIZE_PARAMS to LPRECT when intercepting WM_NCCALCSIZE? 将 WM_NCCALCSIZE 计算的 RECT 存储在 class 成员 RECT 变量中并稍后在 WM_NCPAINT 中使用它是否安全? - is it safe to store the calculated RECT from a WM_NCCALCSIZE in a class member RECT variable and use it later in WM_NCPAINT? 没有客户区时,我应该收到WM_NCPAINT吗? - Should I receive WM_NCPAINT when there is no client area? 如何在窗口的非客户区检测 WM_LBUTTONUP 消息? - How to detect WM_LBUTTONUP messages while in the non client area of a window? 在 win32 中,在调用 WM_PAINT 之间保留绘制的客户区 - Preserve painted client area between calls to WM_PAINT in win32 WinAPI滚动条帮助 - Help with WinAPI scroll bars 更改平面滚动条的颜色(FlatSB_SetScrollProp 函数中的自定义调色板) - Change colors of flat scroll bars (custom palette in FlatSB_SetScrollProp function)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM