[英]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.