Skip to content

Adding a new file type

Kevin Routley edited this page Aug 29, 2021 · 1 revision

These are the steps required to add a new file "type" (e.g. EPUB, MOBI, etc).

There are two features provided by the CBXShell: the file icon, and the file tooltip. Steps for each are described; the two features don't have to be implemented together.

CBXManager

The CBXManager controls the activation / deactivation of support for the file type. Under the current model, skipping these changes means CBXShell will not be invoked for the filetype! The primary intent of the CBXManager is to control the registry keys which modify the invocation of the CBXShell.

  1. Add a new checkbox control id to resource.h. E.g. IDC_CB_EPUB.
  2. Add the following #defines and code to RegManager.h:
    1. A CBX_xxxTH_KEY: the registry key based on the extension. E.g. CBX_EPUBTH_KEY.
    2. A cbx type, E.g. CBX_EPUB.
    3. In GetTHKeyName add a case for your new cbx type.
    4. For tooltip support, add a CBX_xxxIH_KEY.
    5. For tooltip support, add a case to GetIHKeyName for your new cbx type.
  3. Add support for your new file type to the dialog.
    1. Add a checkbox to the main dialog IDD_MAINDLG in CBXManager.rc, using the id added in step 1 above. Adjust sizes and positions of the dialog and controls as necessary.
    2. Add a Button_SetCheck call to CMainDlg::InitUI [MainDlg.cpp]
    3. Replicate a "thumbnail handlers" block in OnApplyImpl for the new type.
    4. Add the control id from step 1 to CMainDlg::OnAppHelp.

CBXShell

As of this writing, all the code for supporting the various file types exists in cbxArchive.h.

  1. Add a new #define for the type (e.g. CBXTYPE_EPUB).
  2. In OnExtract add a new case using the #define from step 1. This case invokes the code to get the thumbnail.
  3. Add any required file extension check(s) to GetCBXType.
  4. For tooltip support, add a new case to OnGetInfoTip. This case invokes the code to get the tooltip text.
  5. Write the code to get the thumbnail and/or tooltip text as required for steps 2 and 4.