MFC CFontDialog

  • Thread starter Thread starter sgrm123
  • Start date Start date
S

sgrm123

Guest
Hi,

I am launching MFC CFontDialog from my MFC dialog.

1604528.png

Whenever there is change in font I need to draw text in ownerdraw button(preview button) in the dialog.
When I click ok button in the CFontDialog only I am able to get the modified font details and able to update the font of text in my preview button. I want to draw the preview button text whenever user changes font in the CFontDialog before clicking the ok button.

I posted this question in the link MFC CFontDialog

This post suggested me to try this, to Enable CF_ENABLEHOOK and capture font dialog's control's multiple events

UINT_PTR CALLBACK FontHook(HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
{
switch (uiMsg)
{
case WM_COMMAND:
if (HIWORD(wParam) == CBN_SELCHANGE)
{
HWND hOwner = GetWindow(hWnd, GW_OWNER);
if (hOwner)
{
LOGFONT lf;
SendMessage(hWnd, WM_CHOOSEFONT_GETLOGFONT, 0, (LPARAM)&lf);
SendMessage(hOwner, WM_PREVIEWFONT, 0, (LPARAM)&lf);
}
}
break;
}
return 0;
}


When I select/change font, the hook procedure captures CBN_SELCHANGE but the call to SendMessage(hWnd, WM_CHOOSEFONT_GETLOGFONT, 0, (LPARAM)&lf); shows the previously selected item only, not recently selected item.

Please help me to resolve this problem.

Continue reading...
 
Back
Top