0
votes

I have an MFC app that embeds a Scintilla text edit control. I want to customize the Scintilla control to display some custom controls next to the vertical scrollbar. Essentially, I want to render some controls in the orange area below, where the green area represent the scroll bars:

Desired client area

I tried overriding the WM_NCCALCSIZE message of the Scintilla window and subtracting an offset from the right side of the client rectangle. 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:

Scrollbar offset from client offset

I'm not sure if this behavior is caused by Scintilla or Windows. Is there a way I can adjust the client area and preserve the positions of the scroll bars?

1
"I'm not sure if this behavior is caused by Scintilla or Windows" - Windows: files.rsdn.ru/42164/nccalcsize.pngkero
You could add your custom controls on the left side and save you a lot of trouble ;-).rodrigo
Haha, I wish it were that easy ;)flashk
The bahaviour of WM_NCCALSIZE is correct. As itis the intention of the message it will add a border AROUND your control not inside of it!Elmue

1 Answers

0
votes

I found a Scintilla specific solution. 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.