Hi arcticir,
I overlooked your last post, sorry!
just me wrote:arcticir wrote:AND, How to achieve this effect,edit Margins, This picture is AHK edit. I want to replace it Class RichEdit.
If you used
EM_SETMARGINS it will work for RichEdit controls, too.
EM_SETMARGINS is actually working:
Code: Select all
...
EM_SETMARGINS(RE2.HWND, 60, 60) ; will set the left and right margin to 60 pixel
WinSet, Redraw, , % "ahk_id " . RE2.HWND
...
; ----------------------------------------------------------------------------------------------------------------------
EM_SETMARGINS(Hwnd, Left := "", Right := "") {
; EM_SETMARGINS = 0x00D3 -> http://msdn.microsoft.com/en-us/library/bb761649(v=vs.85).aspx
Set := 0 + (Left <> "") + ((Right <> "") * 2)
Margins := (Left <> "" ? Left & 0xFFFF : 0) + (Right <> "" ? (Right & 0xFFFF) << 16 : 0)
Return DllCall("User32.dll\SendMessage", "Ptr", HWND, "UInt", 0x00D3, "Ptr", Set, "Ptr", Margins, "Ptr")
}
Alternatively you can change the control's formatting rectangle with
EM_SETRECT. With it you can set top and bottom margins, too:
Code: Select all
...
EM_GETRECT(RE2.HWND, L, T, R, B)
EM_SETRECT(RE2.HWND, 60, 60, R - 60, B - 60) ; will set all margings to 60 pixel.
WinSet, Redraw, , % "ahk_id " . RE2.HWND
...
; ----------------------------------------------------------------------------------------------------------------------
EM_GETRECT(HWND, ByRef Left, ByRef Top, ByRef Right, ByRef Bottom) {
; EM_GETRECT = 0x00B2 -> http://msdn.microsoft.com/en-us/library/bb761596(v=vs.85).aspx
VarSetCapacity(RC, 16, 0)
DllCall("User32.dll\SendMessage", "Ptr", HWND, "UInt", 0x00B2, "Ptr", 0, "Ptr", &RC, "Ptr")
Left := NumGet(RC, 0, "Int"), Top := NumGet(RC, 4, "Int")
Right := NumGet(RC, 8, "Int"), Bottom := NumGet(RC, 12, "Int")
Return True
}
EM_SETRECT(HWND, Left, Top, Right, Bottom) {
; EM_SETRECT = 0x00B3 -> http://msdn.microsoft.com/en-us/library/bb761657(v=vs.85).aspx
VarSetCapacity(RC, 16, 0)
NumPut(Left, RC, 0, "Int"), NumPut(Top, RC, 4, "Int")
NumPut(Right, RC, 8, "Int"), NumPut(Bottom, RC, 12, "Int")
DllCall("User32.dll\SendMessage", "Ptr", HWND, "UInt", 0x00B3, "Ptr", 0, "Ptr", &RC, "Ptr")
Return True
}
In either case you have to switch to the
Word-wrap view to see the effect. And, if you use
EM_SETRECT, you should restore the original formatting rectangle before you switch to the
Wrap as printed view.