I have a function that displays the change font dialog box. It changes the font but not the font color interestingly MSDN tells you exactly how to do it but it doesn't work.![]()
Here is the MSDN link.
http://msdn.microsoft.com/library/de...boxlibrary.asp
Here is my code.
font.h
font.cppCode:#ifndef FONT_H #define FONT_H class CFont { public: CFont(); ~CFont(); bool Change(HWND hParentWindow, HDC hDC, int iEditControlID); HFONT g_hFont; private: CHOOSEFONT m_cf; LOGFONT m_lf; HFONT m_hFontPrevious; COLORREF m_rgbCurrent, m_rgbPrevious; }; #endif // FONT_H
Code:#include <windows.h> #include "font.h" CFont::CFont() { } CFont::~CFont() { } bool CFont::Change(HWND hParentWindow, HDC hDC, int iEditControlID) { ZeroMemory(&m_cf, sizeof(m_cf)); hDC = GetDC(hParentWindow); m_cf.lStructSize = sizeof(m_cf); m_cf.hwndOwner = hParentWindow; m_cf.lpLogFont = &m_lf; m_cf.rgbColors = m_rgbCurrent; m_cf.Flags = CF_SCREENFONTS | CF_EFFECTS; if(!ChooseFont(&m_cf)) { return false; } g_hFont = CreateFontIndirect(m_cf.lpLogFont); m_hFontPrevious = (HFONT)SelectObject(hDC, g_hFont); m_rgbCurrent = m_cf.rgbColors; m_rgbPrevious = SetTextColor(hDC, m_rgbCurrent); SendDlgItemMessage(hParentWindow, iEditControlID, WM_SETFONT, (WPARAM)g_hFont, MAKELPARAM(TRUE, 0)); return true && g_hFont; }



LinkBack URL
About LinkBacks




The only problem is when I handle the WM_CTLCOLOREDIT message my program ignores my manifest file.