2016-08-29 2 views

답변

2

사용 EM_GETRECT/EM_SETRECT 메시지 조합은 모든 여백을 수정 :

 RECT rc; 
     // Get the current control rectangle 
     SendMessage(hWndRichEdit, EM_GETRECT, 0, (LPARAM)&rc); 
     rc.left += 20; // increase the left margin 
     rc.top += 20; // increase the top margin 
     rc.right -= 20; // decrease the right margin 
     rc.bottom -= 20; // decrease the bottom margin (rectangle) 
     // Set the rectangle 
     SendMessage(hWndRichEdit, EM_SETRECT, 0, (LPARAM)&rc); 

결과 컨트롤이 네 마진이 있습니다

RichEdit control with 20px margins

업데이트 :로 Barmak ShemiraniIInspectable 당 아래의 주석은 GetClientRect 함수를 사용하여 현재 r을 얻을 수 있습니다. ectangle 및 InflateRect 함수는 사각형/여백 차원을 조작합니다.

+0

아마도 'EM_GETRECT' 대신'GetClientRect'를 사용하고 싶을 것입니다. 왜냐하면'EM_GETRECT'는 현재 마진을 반환하기 때문입니다. 예를 들어 왼쪽/위쪽 여백은 1과 1로 반환 될 수 있습니다. GetClientRect는 항상 0과 0을 반환하지만 –

+0

거의 알려지지 않은 Windows API는 여러 가지 [rectangle 함수] (https://msdn.microsoft.com/)를 제공합니다. en-us/library/dd162901.aspx). 이 답변의 코드는 [InflateRect] (https://msdn.microsoft.com/en-us/library/dd144994.aspx)를 활용하도록 변경할 수 있습니다. 예를 들면 다음과 같습니다. InflateRect (rc, -20, -20);'. – IInspectable

관련 문제