0

In my MFC dialog based application I want to align the text vertically in edit control. My Edit control is not using WS_BORDER style.

The link How can we vertically align text in edit box? gives solution for my problem and it is working for me.

That link is handling ON_WM_NCCALCSIZE() and ON_WM_NCPAINT() messages.I would like to know can I meet my requirement by overriding only onPaint() without overriding ON_WM_NCCALCSIZE() and ON_WM_NCPAINT() messages?

user369287
  • 692
  • 8
  • 28
  • 1
    Overriding `OnPaint()` isn't enough because edit control also draws outside of `WM_PAINT` under certain conditions. Is there a situation where you cannot use the solution of the linked question? Otherwise this question will propably be closed as a dupe. – zett42 Sep 06 '18 at 10:27
  • My superior asked me to check with OnPaint(). – user369287 Sep 06 '18 at 12:01
  • I suggest to ask for clarification by commenting the upvoted answer of the other question. That's certainly what I would do as this answer definitely lacks explanation (it's practically a code-only answer with non-trivial code which doesn't speak for itself). As it currently stands, the current question is not distinct enough for not being a dupe. – zett42 Sep 06 '18 at 14:32
  • 2
    Possible duplicate of [How can we vertically align text in edit box?](https://stackoverflow.com/questions/867207/how-can-we-vertically-align-text-in-edit-box) – zett42 Sep 06 '18 at 14:32
  • @user369287 tell your superiour that you have found a better solution than overriding OnPaint. – Jabberwocky Sep 06 '18 at 16:07
  • @zett42-My Edit control is not using WS_BORDER style so is it necessary to override the messages ON_WM_NCCALCSIZE() and ON_WM_NCPAINT(). – user369287 Sep 07 '18 at 06:18
  • 1
    Yes I think so, because the non-client area (calculated by `WM_NCCALCSIZE`) is what centers the text vertically in this solution. Whether the control has `WS_BORDER` or not doesn't matter. – zett42 Sep 09 '18 at 12:18

0 Answers0