in the below code i set a timer...but when i unload the timer keeps
going...whats wrong??
Jaime
// PropTimer.cpp : Initialization functions
#include "StdAfx.h"
#include "StdArx.h"
#include "resource.h"
#include "aced.h"
#include "adslib.h"
#include "time.h"
#include "windows.h"
#include "acutads.h"
#include "adsdef.h"
#include "acedads.h"
class AsdkCommandReactor;
HINSTANCE _hdllInstance =NULL ;
AsdkCommandReactor* cmdr = NULL;
// This command registers an ARX command.
void AddCommand(const char* cmdGroup, const char* cmdInt, const char*
cmdLoc,
const int cmdFlags, const AcRxFunctionPtr
cmdProc, const int idLocal = -1);
// NOTE: DO NOT edit the following lines.
//{{AFX_ARX_MSG
void InitApplication();
void UnloadApplication();
//}}AFX_ARX_MSG
// NOTE: DO NOT edit the following lines.
//{{AFX_ARX_ADDIN_FUNCS
//}}AFX_ARX_ADDIN_FUNCS
////////////////////////////////////////////////////////////////////////////
/
// DLL Entry Point
extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID
/*lpReserved*/)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
_hdllInstance = hInstance;
} else if (dwReason == DLL_PROCESS_DETACH) {
}
return TRUE; // ok
}
class AsdkCommandReactor : public AcEditorReactor {
public:
virtual void commandWillStart(const char * cmdStr);
virtual void commandEnded(const char* cmdStr);
};
void AsdkCommandReactor::commandWillStart(const char* cmdStr)
{
if (strcmp(cmdStr,"PROPERTIES") == 0 )
{
acutPrintf("\nPROPERTIES IS OPEN\n");
}
}
VOID CALLBACK MyTimerProc(
HWND hWnd, // handle of CWnd that called SetTimer
UINT nMsg, // WM_TIMER
UINT nIDEvent, // timer identification
DWORD dwTime // system time
)
{
struct resbuf *Result = NULL,*cmdlist;
cmdlist = acutBuildList(RTSTR,"PROPERTIESCLOSE",RTNONE);
acedInvoke(cmdlist, &Result);
acutRelRb(cmdlist);
acutPrintf("Hello %s",nMsg);
}
UINT IDT;
void AsdkCommandReactor::commandEnded(const char* cmdStr)
{
if (strcmp(cmdStr,"PROPERTIES") == 0 )
{
acutPrintf("\nClose Properties Next");
UINT uResult;
uResult = SetTimer(NULL,IDT,5000,(TIMERPROC) MyTimerProc);
if (uResult == 0)
{
acutPrintf("\nNo Timer Is Available.");
}
}
}
////////////////////////////////////////////////////////////////////////////
/
// ObjectARX EntryPoint
extern "C" AcRx::AppRetCode
acrxEntryPoint(AcRx::AppMsgCode msg, void* pkt)
{
switch (msg) {
case AcRx::kInitAppMsg:
// Comment out the following line if your
// application should be locked into memory
acrxDynamicLinker->unlockApplication(pkt);
acrxDynamicLinker->registerAppMDIAware(pkt);
InitApplication();
break;
case AcRx::kUnloadAppMsg:
UnloadApplication();
break;
}
return AcRx::kRetOK;
}
// Init this application. Register your
// commands, reactors...
void InitApplication()
{
// NOTE: DO NOT edit the following lines.
//{{AFX_ARX_INIT
//}}AFX_ARX_INIT
// TODO: add your initialization functions
acutPrintf("\nProgram Loaded\n");
cmdr = new AsdkCommandReactor();
acedEditor->addReactor(cmdr);
}
// Unload this application. Unregister all objects
// registered in InitApplication.
void UnloadApplication()
{
// NOTE: DO NOT edit the following lines.
//{{AFX_ARX_EXIT
//}}AFX_ARX_EXIT
// TODO: clean up your application
acutPrintf("\nProgram Unloaded\n");
acedEditor->removeReactor(cmdr);
delete cmdr;
KillTimer(NULL, IDT);
}
// This functions registers an ARX command.
// It can be used to read the localized command name
// from a string table stored in the resources.
void AddCommand(const char* cmdGroup, const char* cmdInt, const char*
cmdLoc,
const int cmdFlags, const AcRxFunctionPtr
cmdProc, const int idLocal)
{
char cmdLocRes[65];
// If idLocal is not -1, it's treated as an ID for
// a string stored in the resources.
if (idLocal != -1) {
// Load strings from the string table and register the
command.
::LoadString(_hdllInstance, idLocal, cmdLocRes, 64);
acedRegCmds->addCommand(cmdGroup, cmdInt, cmdLocRes,
cmdFlags, cmdProc);
} else
// idLocal is -1, so the 'hard coded'
// localized function name is used.
acedRegCmds->addCommand(cmdGroup, cmdInt, cmdLoc, cmdFlags,
cmdProc);
}