# win32 edit box, fixed pitch font

## Recommended Posts

wforl    169
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
SiCrane    11839
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
Mike nl    390
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);