1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
#include "main.h"
#include <new.h>
int PASCAL WinMain
(HINSTANCE hInst, HINSTANCE hPrevInst, char * cmdParam, int cmdShow)
{
if (!strlen (cmdParam))
{
MessageBox (0, "Please, specify folder to watch", "Folder Watcher", MB_ICONEXCLAMATION | MB_OK);
return 0;
}
char className [] = "Folder Watcher";
_set_new_handler(&NewHandler); // this is the variable it said was undeclared
BOOL isError = FALSE;
try
{
WindowClass winClass (WndProc, className, hInst);
winClass.Register ();
Window win (cmdParam, className, hInst);
// Add "About ..." to the system menu
HMENU hSysMenu = GetSystemMenu (win, FALSE);
AppendMenu (hSysMenu, MF_SEPARATOR, 0, NULL);
AppendMenu (hSysMenu, MF_STRING, IDM_ABOUT, "About ...");
// Disable Restore item
EnableMenuItem (hSysMenu, 0, MF_BYPOSITION | MF_GRAYED);
win.Show (SW_SHOWMINNOACTIVE);
}
catch ( WinException e )
{
e.Display ();
isError = TRUE;
}
catch (...)
{
MessageBox (0, "Unknown", "Exception", MB_ICONEXCLAMATION | MB_OK);
isError = TRUE;
}
if (isError)
return 0;
// The main message loop
MSG msg;
int status;
while ((status = GetMessage (&msg, 0, 0, 0)) != 0)
{
if (status == -1)
return -1;
TranslateMessage (&msg);
DispatchMessage (&msg);
}
return msg.wParam;
}
|