Creating the Entry-Point Function
File Manager communicates with an extension DLL through the FMExtensionProc callback function. Make sure to export this function by listing it in the EXPORTS statement of your extension's module-definition (.DEF) file. The FMExtensionProc function handles the messages listed in the preceding section by performing the tasks listed in the following table.
Task | Action |
Initializing the extension (FMEVENT_LOAD) | Provides File Manager with the name and handle of the menu and saves the menu-item delta value. |
Initializing the menu (FMEVENT_INITMENU) | Initializes all top-level menu items and the items in any submenus. |
Initializing the toolbar (FMEVENT_TOOLBARLOAD) | Provides File Manager with information about the buttons to add to the toolbar, including the command identifier, Help string identifier, styles, and bitmap identifier. |
Processing menu selections | Carries out commands that the user chooses from the extension's menu. |
Processing file selections (FMEVENT_SELCHANGE) | Queries File Manager for information about the file that the user has selected from the directory window or Search Results window. |
Updating items in the menu (FMEVENT_USER_REFRESH) | Modifies the menu as appropriate when the user chooses File Manager's Refresh command from the Window menu. |
Providing menu item help strings (FMEVENT_HELPSTRING) | Provides File Manager with a help string for a specified command in a specified menu. File Manager displays this string in the area at the bottom left of the window. |
Passing menu item help requests on to WinHelp (FMEVENT_HELPMENUITEM) | Provides WinHelp with the window passed by File Manager and menu item information, |
Quitting the extension DLL (FMEVENT_UNLOAD) | Frees any memory allocated and prepares to exit. |
The FMExtensionProc function is defined as follows.
LONG WINAPI FMExtensionProc(hwnd, wMsg, lParam)
HWND hwnd;
WORD wMsg;
LONG lParam;
The hwnd parameter identifies the File Manager window. An extension should use this window handle to specify the parent window for any dialog box or message box it must display. It should also use this handle to send query messages to File Manager. The uMsg parameter contains one of the File Manager messages listed previously. The lParam parameter contains a message-specific value. The return value from the FMExtensionProc function depends on the value of the uMsg parameter.
The menu added to File Manager may be a hierarchical (cascaded) menu and may contain grayed, disabled, or checked menu items in addition to command items. Menu items should be text only; owner-drawn menus and bitmap menus are not supported. Changing the bitmap for check marks is not supported.
Whenever File Manager calls the FMExtensionProc function, it waits to refresh its directory windows (for changes in the file system) until after the function returns. This allows the extension to perform large numbers of file operations without excessive repainting on the part of File Manager. It is not necessary for the extension to send the FM_REFRESH_WINDOWS message to notify File Manager to repaint its directory windows.