CFontsDialog::CFontsDialog(LPLOGFONT lplfInitial, DWORD dwFlags, CDC* pdcPrinter, CWnd* pParentWnd, int iType) : CFontDialog(lplfInitial, dwFlags, pdcPrinter, pParentWnd), m_iType(iType) { m_cf.Flags |= CF_ENABLETEMPLATE | CF_ENABLEHOOK | CF_APPLY; m_cf.Flags &= ~(CF_EFFECTS | CF_SHOWHELP); m_cf.hInstance = AfxGetResourceHandle(); m_cf.lpTemplateName = MAKEINTRESOURCE(IDD_PWFONTDIALOG); m_cf.hwndOwner = m_hWnd; m_cf.lpfnHook = CFHookProc; pwfd_self = this; m_sampletext.LoadString(IDS_SAMPLETEXT); UINT uiID(0); switch (iType) { case PWFONT: uiID = IDS_PSWDFONT; break; case TLFONT: uiID = IDS_TREEFONT; break; case VKFONT: uiID = IDS_VKBDFONT; // Set up default font, which is NONE memcpy(&m_dfltVKBDFont, lplfInitial, sizeof(LOGFONT)); SecureZeroMemory(m_dfltVKBDFont.lfFaceName, sizeof(m_dfltVKBDFont.lfFaceName)); break; default: ASSERT(0); } m_title.LoadString(uiID); m_bReset = false; }
// Handle the tooltip messages. Returns true to mean message was handled. BOOL MyGraph::OnNeedText(UINT /*uiId*/, NMHDR* pNMHDR, LRESULT* pResult) { _ASSERTE(pNMHDR && "Bad parameter passed"); _ASSERTE(pResult && "Bad parameter passed"); bool bReturn(false); UINT_PTR uiID(pNMHDR->idFrom); // Notification in NT from automatically created tooltip. if (0U != uiID) { bReturn = true; // Need to handle both ANSI and UNICODE versions of the message. TOOLTIPTEXTA* pTTTA = reinterpret_cast<TOOLTIPTEXTA*> (pNMHDR); ASSERT_POINTER(pTTTA, TOOLTIPTEXTA); TOOLTIPTEXTW* pTTTW = reinterpret_cast<TOOLTIPTEXTW*> (pNMHDR); ASSERT_POINTER(pTTTW, TOOLTIPTEXTW); CString sTipText(GetTipText()); #ifndef _UNICODE if (TTN_NEEDTEXTA == pNMHDR->code) { lstrcpyn(pTTTA->szText, sTipText, _countof(pTTTA->szText)); } else { _mbstowcsz(pTTTW->szText, sTipText, _countof(pTTTA->szText)); } #else if (pNMHDR->code == TTN_NEEDTEXTA) { _wcstombsz(pTTTA->szText, sTipText, _countof(pTTTA->szText)); } else { lstrcpyn(pTTTW->szText, sTipText, _countof(pTTTA->szText)); } #endif *pResult = 0; } return bReturn; }
CFontsDialog::CFontsDialog(LPLOGFONT lplfInitial, DWORD dwFlags, CDC* pdcPrinter, CWnd* pParentWnd, FontType iType) : CFontDialog(lplfInitial, dwFlags, pdcPrinter, pParentWnd), m_iType(iType) { m_cf.Flags |= CF_ENABLETEMPLATE | CF_ENABLEHOOK; m_cf.Flags &= ~(CF_EFFECTS | CF_SHOWHELP); m_cf.hInstance = AfxGetResourceHandle(); m_cf.lpTemplateName = MAKEINTRESOURCE(IDD_PWFONTDIALOG); m_cf.hwndOwner = m_hWnd; m_cf.lpfnHook = CFHookProc; pwfd_self = this; m_sampletext.LoadString(IDS_SAMPLETEXT); UINT uiID(0); switch (iType) { case PASSWORDFONT: uiID = IDS_PSWDFONT; break; case TREELISTFONT: uiID = IDS_TREEFONT; break; case ADDEDITFONT: uiID = IDS_ADDEDITFONT; break; case NOTESFONT: uiID = IDS_NOTESFONT; break; case VKEYBOARDFONT: uiID = IDS_VKBDFONT; // Set up default font, which is NONE memcpy(&m_dfltVKBDFont, lplfInitial, sizeof(LOGFONT)); SecureZeroMemory(m_dfltVKBDFont.lfFaceName, sizeof(m_dfltVKBDFont.lfFaceName)); break; // NO "default" statement to generate compiler error if enum missing } m_title.LoadString(uiID); m_bReset = false; }