Set font size in Win32 API EDIT Window

i have recently been attempting to write a small text editor application, and the main problem i found was migrating notepad settings over to my application, the font for 10pt was stored as 100.

obviously, i needed to divide by 10, but when i did this, the font came out so small it was unreadable.

after some digging, i found the following works perfectly.

int m_height = -MulDiv(g_point_size/10, GetDeviceCaps(m_dc, LOGPIXELSY), 72);

once you have done this, just SendMessage to the EDIT you want to set the font size of, and bingo, we have a correct font size

Write a comment