MFC CFontDialog - Getting font color

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

sgrm123

Guest
Hi,

I am launching MFC CFontDialog from my dialog.

1604573.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.


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...
 

Similar threads

S
Replies
0
Views
218
sgrm123
S
S
Replies
0
Views
210
sgrm123
S
S
Replies
0
Views
219
sgrm123
S
Back
Top