Who can write these codes in C#?
the codes:
//////////////////////////////////////////////////////////////
//
// Includes
//
//////////////////////////////////////////////////////////////
#define _AFX_NOFORCE_LIBS // we do not want to link to MFC DLLs or libs
#ifdef _DEBUG
#define WAS_DEBUG
#undef _DEBUG
#endif
#include "afxwin.h" // need this because rxmfcapi.h needs windows header.
#ifdef WAS_DEBUG
#undef WAS_DEBUG
#define _DEBUG
#endif
#include "aced.h"
#include "adslib.h"
#include "rxmfcapi.h"
//////////////////////////////////////////////////////////////
//
// Standard C Test function
//
//////////////////////////////////////////////////////////////
void mouse(); // ARX callbacks
void unmouse(); // ARX callbacks
BOOL filterMouse(MSG *pMsg); // hook function for trace mouse wheel
// preventing from inserting the same hook twice.
static BOOL mouseDone = FALSE;
//////////////////////////////////////////////////////////////
//
// Rx interface
//
//////////////////////////////////////////////////////////////
void initApp()
{
acedRegCmds->addCommand( "Mwheel", // Group name
"mwheel", // Global function name
"mwheel", // Local function name
ACRX_CMD_MODAL, // Type
&mouse ); // Function pointer
acedRegCmds->addCommand( "Mwheel", // Group name
"unmwheel", // Global function name
"unmwheel", // Local function name
ACRX_CMD_MODAL, // Type
&unmouse ); // Function pointer
acutPrintf( ".OK!\n" );
}
void unloadApp()
{
// Remove the command group because we are unloading
//
acedRegCmds->removeGroup( "Mwheel" );
// Removing all hooks
if (mouseDone == TRUE)
acedRemoveFilterWinMsg(filterMouse);
}
//////////////////////////////////////////////////////////////
//
// Entry point
//
//////////////////////////////////////////////////////////////
extern "C" AcRx::AppRetCode acrxEntryPoint( AcRx::AppMsgCode msg, void* pkt)
{
switch( msg )
{
case AcRx::kInitAppMsg:
initApp();
acrxUnlockApplication(pkt);
acrxDynamicLinker->registerAppMDIAware(pkt);
break;
case AcRx::kUnloadAppMsg:
unloadApp();
break;
default:
break;
}
return AcRx::kRetOK;
}
BOOL filterMouse(MSG *pMsg)
{
static long ptx=0;
static long pty=0;
static short zdt=0;
struct resbuf rb;
if (pMsg->message == WM_MOUSEWHEEL) //鼠标滚轮消息
{
if (LOWORD(pMsg->wParam) == MK_CONTROL)
{
return FALSE; // continue
}
else
{
// acutPrintf("Mouse Wheel!");
zdt=(short)HIWORD(pMsg->wParam);
// acutPrintf("%d\n",zdt);
rb.restype = RTSHORT;
rb.resval.rint = zdt;
acedSetVar("USERI5", &rb);
ptx = LOWORD(pMsg->lParam);
if (zdt == 120)
pty = HIWORD(pMsg->lParam)-1;
if (zdt == -120)
pty = HIWORD(pMsg->lParam)+1;
SetCursorPos(ptx,pty);
return TRUE; // continue
}
}
if (pMsg->message == WM_MBUTTONDOWN) //鼠标中键按下消息
{
rb.restype = RTSHORT;
rb.resval.rint = 100;
acedSetVar("USERI4", &rb);
return FALSE; // continue
}
if (pMsg->message == WM_MBUTTONUP) //鼠标中键抬起消息
{
rb.restype = RTSHORT;
rb.resval.rint = 0;
acedSetVar("USERI4", &rb);
return FALSE; // continue
}
return FALSE; // continue
}
///////////////////////
void mouse()
{
if (mouseDone == TRUE) // already has the hook?
return ;
acutPrintf( "mouseing...\n" );
if (acedRegisterFilterWinMsg(filterMouse) == FALSE) //添加acadhook
{
acutPrintf("Can't register Windows Msg hook - VH - mouse\n");
return ;
}
else
{
mouseDone = TRUE;
return ;
}
}
void unmouse()
{
if (mouseDone == TRUE)
{
acedRemoveFilterWinMsg(filterMouse); //卸载acadhook
mouseDone = FALSE;
}
if (mouseDone2 == TRUE)
{
acedRemoveFilterWinMsg(filterMouse2);
mouseDone2 = FALSE;
}
}