S
sgrm123
Guest
Hi,
I am launching MFC CFontDialog from my dialog.
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.
As this link suggests MFC CFontDialog by adding flag CF_ENABLEHOOK and calling SendMessage(hWnd, WM_CHOOSEFONT_GETLOGFONT, 0, (LPARAM)&lf); in hook procedure I am able to get font details but the logfont does not have font color details. How to get it?
UINT_PTR CALLBACK FontHook(HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
{
switch (uiMsg)
{
case WM_COMMAND:
if (HIWORD(wParam) == CBN_SELCHANGE || HIWORD(wParam) == BN_CLICKED)
{
::SetTimer(hWnd,NULL,50,NULL);
}
break;
case WM_TIMER:
{
int n=LOWORD(wParam);
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);
}
::KillTimer(hWnd,NULL);
}
break;
}
return 0;
}
Thanks
Continue reading...
I am launching MFC CFontDialog from my dialog.
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.
As this link suggests MFC CFontDialog by adding flag CF_ENABLEHOOK and calling SendMessage(hWnd, WM_CHOOSEFONT_GETLOGFONT, 0, (LPARAM)&lf); in hook procedure I am able to get font details but the logfont does not have font color details. How to get it?
UINT_PTR CALLBACK FontHook(HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
{
switch (uiMsg)
{
case WM_COMMAND:
if (HIWORD(wParam) == CBN_SELCHANGE || HIWORD(wParam) == BN_CLICKED)
{
::SetTimer(hWnd,NULL,50,NULL);
}
break;
case WM_TIMER:
{
int n=LOWORD(wParam);
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);
}
::KillTimer(hWnd,NULL);
}
break;
}
return 0;
}
Thanks
Continue reading...