Home > Software engineering >  MFC RichEdit how to set the text in the middle?
MFC RichEdit how to set the text in the middle?

Time:03-29

To see someone post is so write:
 
CEdit edit;
CRect rc;
Edit. GetClientRect (& amp; Rc);
The CDC * pDC=edit. GetDC ();
CSize sz=pDC - & gt; GetTextExtent (" ABC ");
CRect the rect (0, 0, rec. Width (), sz. Cy);
The rect. OffsetRect (rec) CenterPoint () - the rect. CenterPoint ());
Edit. SetRect (& amp; The rect);

But I need to keep the center with StreamOut function format into an RTF file, this is not only change the display format, did not change the file format?

CodePudding user response:

The RTF file should be able to save the center of the type of information?

CodePudding user response:

DWORD dwStyle=: : GetWindowLong (edit GetSafeHwnd (), GWL_STYLE);
DwStyle & amp;=~ ES_LEFT;
DwStyle |=ES_CENTER;
: : SetWindowLong (edit GetSafeHwnd (), GWL_STYLE, dwStyle);

CodePudding user response:

reference rabbit party at large on the second floor response:
DWORD dwStyle=: : GetWindowLong (edit) GetSafeHwnd (), GWL_STYLE);
DwStyle & amp;=~ ES_LEFT;
DwStyle |=ES_CENTER;
: : SetWindowLong (edit GetSafeHwnd (), GWL_STYLE, dwStyle);

This will put the text in the control center, excuse me, can only put a few lines of center, like the word?
  • Related