How do I know the name of the font face of an edit control (not richedit) ?
Thanks!
How do I know the name of the font face of an edit control (not richedit) ?
Thanks!
* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.
GetTextFace - you can get the edit control's device context with GetDC but don't forget to ReleaseDC when done with it.
CProgramming FAQ
Caution: this person may be a carrier of the misinformation virus.
I don't think that will work as the edit control uses a common (shared) device context. GetDC documentation says:
I learnt this the hard way when coding this.For class and private DCs, GetDC leaves the previously assigned attributes unchanged. However, for common DCs, GetDC assigns default attributes to the DC each time it is retrieved. For example, the default font is System, which is a bitmap font. Because of this, the handle for a common DC returned by GetDC does not tell you what font, color, or brush was used when the window was drawn.
Another approach that may work would be:
- Call WM_GETFONT to get a font handle.
- If that returns NULL, call GetStockObject with SYSTEM_FONT to get a font handle.
- Call GetObject to get the LOGFONT data for the font, which includes the font name.
ok:
Working! ThanksCode:font = (HFONT)SendMessage(hEdit, WM_GETFONT, 0, 0); GetObject(font, sizeof(LOGFONT), &lf); wsprintf(x, "Tamaño: %i\nTipo: %s", lf.lfHeight, lf.lfFaceName); MessageBox(hWnd, x, "Tetas", 64);
* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.