Processing Commands and Messages from File Manager
The following code shows the
FMExtensionProc function for a sample extension DLL. It demonstrates how an extension
processes the menu commands and notification messages sent by File Manager.
HINSTANCE hinst;
HMENU hmenu;
WORD wMenuDelta;
BOOL fMultiple = FALSE;
BOOL fLFN = FALSE;
LONG WINAPI FMExtensionProc(hwnd, wMsg, lParam)
HWND hwnd;
WORD wMsg;
LONG lParam;
{
CHAR szBuf[200];
INT count;
switch (wMsg) {
case FMEVENT_LOAD:
#define lpload ((LPFMS_LOAD) lParam)
/* Save the menu-item delta value. */
wMenuDelta = lpload->wMenuDelta;
/* Fill the FMS_LOAD structure. */
lpload->dwSize = sizeof(FMS_LOAD);
lstrcpy(lpload->szMenuName, "&Extension");
/* Return the handle of the menu. */
hinst = GetModuleHandle("ext.dll");
lpload->hMenu = GetSubMenu(LoadMenu(hinst,
MAKEINTRESOURCE(MYMENU)), 0);
return (LONG)TRUE;
case FMEVENT_UNLOAD:
/* Perform any cleanup procedures here. */
break;
case FMEVENT_INITMENU:
/* Copy the menu handle. */
hmenu = (HMENU) lParam;
/*
* Add check marks to menu items as appropriate.
* Add menu-item delta values to menu-item
* identifiers to specify the menu items to check.
*/
CheckMenuItem(hmenu,
wMenuDelta + IDM_MULTIPLE,
fMultiple ? MF_BYCOMMAND | MF_CHECKED :
MF_BYCOMMAND | MF_UNCHECKED);
CheckMenuItem(hmenu,
wMenuDelta + IDM_LFN,
fLFN ? MF_BYCOMMAND | MF_CHECKED :
MF_BYCOMMAND | MF_UNCHECKED);
break;
case FMEVENT_TOOLBARLOAD:
{
static EXT_BUTTON extbtn[] = {
{1, 0, 0},
};
/* Fill the FMS_TOOLBARLOAD structure. */
#define lptbld ((LPFMS_TOOLBARLOAD) lParam)
lptbld->dwSize = sizeof(FMS_TOOLBARLOAD);
lptbld->lpButtons = (LPEXT_BUTTON) &extbtn;
lptbld->cButtons = 1;
lptbld->cBitmaps = 1;
lptbld->idBitmap = ID_BUTTONBITMAP;
return (LONG)TRUE;
}
case FMEVENT_USER_REFRESH:
MessageBox(hwnd, "User refresh event",
"Hey!", MB_OK);
break;
case FMEVENT_SELCHANGE:
break;
/*
* The following messages are generated when the user
* chooses items from the extension menu.
*/
case FMEVENT_HELPSTRING:
#define lphs ((LPFMS_HELPSTRING)lParam)
if (lphs->idCommand == -1)
lstrcpy(lphs->szHelp, "Help for extension menu");
else
wsprintf(lphs->szHelp, "Help for item %d", lphs->idCommand);
break;
case FMEVENT_HELPMENUITEM:
wsprintf(szBuf, "Help for %d", lParam);
MessageBox(hwnd, szBuf, "WinHelp call", MB_OK);
/*
* Use: WinHelp(hwnd, "ExtHelp.hlp", HELP_CONTEXT, lParam);
*/
break;
case IDM_GETFOCUS:
wsprintf(szBuf, "Focus %d",
(INT) SendMessage(hwnd, FM_GETFOCUS, 0, 0));
MessageBox(hwnd, szBuf, "Focus", MB_OK);
break;
case IDM_GETCOUNT:
count = (INT) SendMessage(hwnd,
fLFN ? FM_GETSELCOUNTLFN : FM_GETSELCOUNT,
0, 0);
wsprintf(szBuf, "%d files selected", count);
MessageBox(hwnd, szBuf, "Selection Count", MB_OK);
break;
case IDM_GETFILE:
{
FMS_GETFILESEL file;
count = (INT) SendMessage(hwnd,
fLFN ? FM_GETSELCOUNTLFN : FM_GETSELCOUNT,
FMFOCUS_DIR,
0);
while (count >= 1) {
/*
* Selection indices are zero-based (0 is
* first).
*/
count--;
SendMessage(hwnd, FM_GETFILESEL, count,
(LONG) (LPFMS_GETFILESEL) &file);
wsprintf(szBuf, "file %s\nSize %ld",
(LPSTR) file.szName, file.dwSize);
MessageBox(hwnd, szBuf, "File Information",
MB_OK);
if (!fMultiple)
break;
}
break;
}
case IDM_GETDRIVE:
{
FMS_GETDRIVEINFO drive;
SendMessage(hwnd, FM_GETDRIVEINFO, 0,
(LONG) (LPFMS_GETDRIVEINFO)&drive);
wsprintf(szBuf,
"%s\nFree %ld\nTotal %ld\nVolume %s\nShare %s",
(LPSTR) drive.szPath, drive.dwFreeSpace,
drive.dwTotalSpace, (LPSTR) drive.szVolume,
(LPSTR) drive.szShare);
MessageBox(hwnd, szBuf, "Drive Info", MB_OK);
break;
}
case IDM_LFN:
MessageBox(hwnd, "IDM_LFN", "Hi", MB_OK);
fLFN = !fLFN;
break;
case IDM_MULTIPLE:
MessageBox(hwnd, "IDM_MULTIPLE", "Hi", MB_OK);
fMultiple = !fMultiple;
break;
case IDM_REFRESH:
case IDM_REFRESHALL:
SendMessage(hwnd, FM_REFRESH_WINDOWS,
wMsg == IDM_REFRESHALL, 0);
break;
case IDM_RELOAD:
PostMessage(hwnd, FM_RELOAD_EXTENSIONS, 0, 0);
break;
}
return 0L;
}
- Software for developers
-
Delphi Components
.Net Components
Software for Android Developers
- More information resources
-
MegaDetailed.Net
Unix Manual Pages
Delphi Examples
- Databases for Amazon shops developers
-
Amazon Categories Database
Browse Nodes Database