In multi-row mode, the cedit class provides the void cedit: setrectnp (lpcrect lprect) function. This function is used to adjust the text editing area. You can use this function to set up the upper, lower, and lower margins, the void setmargins (uint nleft, uint nright) function can only set left and right margins.
Crect rc = crect (0, 0, 0 );
Edit. getclientrect (& rc );
RC. deflaterect (10, 10, 10 );
Edit. setrectnp (& rc );
This Code sets the upper, lower, and left margin values to 10.
The level is limited. Currently, the single-line mode has not been found to center the text in the text box vertically. Therefore, the multi-line text box is used to simulate a single row and set the vertical center.
Crect rc = crect (0, 0, 0 );
Edit. getclientrect (& rc );
CDC * PDC = edit1.getdc ();
Textmetric TM;
PDC-> gettextmetrics (& TM );
Int nfontheight = TM. tmheight + TM. tmexternalleading;
Int nmargin = (RC. Height ()-nfontheight)/2;
RC. deflaterect (0, nmargin );
Edit. setrectnp (& rc );
Set the attribute of the text box to es_multiline | es_autohscroll and the attribute cannot be es_autovscroll | es_wantreturn.