[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 546
  • Last Modified:

Disabling checkboxes in CFontDialog

Is there a way to disable the underline checkbox in the CFontFialog without removing the strikeout and the color chooser?

 
0
davidmorand
Asked:
davidmorand
  • 2
1 Solution
 
abancroftCommented:
Use Spy++ to get the control id of the check box.

Then create your own dialof class derived from CFontDialog. Add a WM_INITDIALOG handler and in it call:
GetDlgItem(<checkbox id>)->EnableWindow(FALSE);

You could use the same technique to hide the check box as well.
0
 
mikeblasCommented:
Please don't use Spy++ to find the ID.

Instead, please use the DLGS.H system header file, which contains the identifiers of the controls in the common dialogs, exactly for this purpose.

The ID of the Underline checkbox is "chx2".  Remember, along with disabling it, to make it unchecked!

#include <dlgs.h>

BOOL CYourFontDialog::OnInitDialog()
{
   CFontDialog::OnInitDialog();

   CButton* pWnd = (CButton*) GetDlgItem(chx2);
   ASSERT(pWnd != NULL);
   pWnd->EnableWindow(FALSE);
   pWnd->SetCheck(0);
}


..B ekiM
0
 
abancroftCommented:
Good tip - I didn't know about DLGS.H.
0
 
davidmorandAuthor Commented:
Thanks a lot, it was really helpful!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now