Text editing box-adjust the text editing area

Source: Internet
Author: User

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.

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.