# win32 edit box, fixed pitch font

This topic is 3568 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

How do i set up a fixed pitch font for an edit box? im using somthing like SendMessage(GetDlgItem(hwnd,IDC_EDIT_LOADED_OBJECTS_INFO), WM_SETFONT,(WPARAM)CreateFont (0, 0, 0, 0, 0, 0, 0, 0,ANSI_CHARSET, 0, 0, CLEARTYPE_QUALITY, FIXED_PITCH, NULL), 0); atm, which works, but even with messing with the values, im still not getting the font i would like, basically i just want the font thats used normally, but with a fixed pitch, is this possible?

##### Share on other sites
Let me see if I understand what you're asking. Do you want to take an edit box that is currently using a non-fixed width font like Arial, and then make it use Arial letters, but with a fixed width for each letter?

##### Share on other sites
You can use GetStockObject to get the few common things, such as the standard fixed-pitch font.

But it sounds like you want the DEFAULT_GUI_FONT, but with fixed pitch. I looked around on MSDN, and GetObject sounds like it might help.

So something like this might work:
LOGFONT lf;GetObject(GetStockObject(DEFAULT_GUI_FONT), sizeof(LOGFONT), &lf);lf.lfPitchAndFamily = (lf.lfPitchAndFamily & ~3) | FIXED_PITCH;HFONT hFont = CreateFontIndirect(&lf);SendMessage(GetDlgItem(hwnd, IDC_EDIT_LOADED_OBJECTS_INFO), WM_SETFONT, (WPARAM)hFont, 0);

• 10
• 17
• 9
• 14
• 41
• ### Forum Statistics

• Total Topics
631067
• Total Posts
2997737
×