Home   Index   About
Ultimate Pack


Custom Search
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;

}


Last news from Greatis Software

Nostalgia .Net     Nostalgia .Net     .Net is powerful, but not all-powerful, so sometimes we need to use Win32 API for our .Net applications. It's simple enough with Platform Invoke if you have Win32 skill, but we do not always have time to dig the ancient documentation, declare the special types that are compatible with Win32, find the values of the Win32's constants and so on. Nostalgia .Net offers several simple-to-use classes, and components that will allow you to forget about the headache of Win32 and just use the power of Win32 in your application the same way as you use the native. Net classes.  More »

Recommended software for developers

Ultimate Pack for Delphi and C++ Builder     Ultimate Pack     Component pack for Delphi and C++ Builder that contains runtime form designer, runtime object inspector, print suite and much more for the very special price.  More »

Form Designer .Net     Form Designer .Net     Unique runtime form design solution that allows to edit any form in .Net WinForms application at runtime with full source codes for only 300 euro!  More »

Print Suite .Net     Print Suite .Net     Print Suite .Net is a set of components for easy printing texts, images and grids from your WinForms applications. Full C# source codes are available  More »

Gradient Controls .Net     Gradient Controls .Net     Gradient Controls .Net offers controls with gradient background feature. Labels, panels and so on... Full C# source codes are available  More »

iGrid     Greatis iGrid     iGrid plots drawing grid right over your desktop, so you can use it everywhere, with any drawing application without any special plugins for different graphic editors.  More »


All the contacts and projects

Dmitry Vasiliev (just.dmitry)

Related Links

Software for Visual Studio .NET developers
Software for Delphi and C++ Builder developers
Software for Visual Basic 6 developers
Delphi Tips&Tricks
MegaDetailed.NET

More Online Helps

Win32 Programmer's Reference
Win32 Multimedia Programmer's Reference
OLE Programmer's Reference
Microsoft Windows Pen API Programmer's Reference
Microsoft Windows Sockets 2 Reference
Microsoft Windows Telephony API (TAPI) Programmer's Reference
Unix Manual Pages

Free Tech Secrets ;) Copyright © 2008-2012 Free Tech Secrets ;) greatis just4fun network just4fun