Sign in to follow this  
wforl

win32 edit box, fixed pitch font

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 this post


Link to post
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 this post


Link to post
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);

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this