c++ - 如何设置 Win32 richedit 的上/下边距

标签 c++ windows winapi controls

我们可以使用EM_SETMARGINS设置 RichEdit 控件的左/右页边距的消息。但我不知道如何设置上/下边距。有人知道吗?谢谢。

最佳答案

使用 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函数获取当前矩形和InflateRect操作矩形/边距尺寸的函数。

关于c++ - 如何设置 Win32 richedit 的上/下边距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39197843/

相关文章:

c - 如何开始编写图形 Windows 程序?

c++ - 如何检测 C++ 中对超出范围的堆栈变量的引用?

c++ - 对本地方法使用 EXPECT_CALL

node.js - 为 Bamboo build设置环境变量

windows - 使用二进制补丁时更新已安装的程序版本?

c++ - 如何从 C/C++ 不带控制台窗口执行批处理文件?

c++ - GetProcessId 失败,错误 6 : The handle is invalid

c++ - mysql C++ 从所有列中选择所有行

c++ - 如何在编译时连接静态字符串?

c++ - Win32 C++ 控制台清屏不闪烁