Author Topic: Who can write these codes in C#?  (Read 3837 times)

0 Members and 1 Guest are viewing this topic.

itcad

  • Guest
Who can write these codes in C#?
« on: December 20, 2008, 06:27:08 AM »
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;
  }
}

Draftek

  • Guest
Re: Who can write these codes in C#?
« Reply #1 on: December 21, 2008, 07:34:51 AM »
I can

Maverick®

  • Seagull
  • Posts: 14778
Re: Who can write these codes in C#?
« Reply #2 on: December 21, 2008, 06:26:42 PM »
 :lmao:

itcad

  • Guest
Re: Who can write these codes in C#?
« Reply #3 on: December 21, 2008, 07:52:16 PM »

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Who can write these codes in C#?
« Reply #4 on: December 21, 2008, 08:45:10 PM »
all your codes are belong to us
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

TonyT

  • Guest
Re: Who can write these codes in C#?
« Reply #5 on: December 23, 2008, 09:35:27 AM »
I can

please write your codes.

http://www.caddzone.com/AcadWindowHook.cs

There's no support available for that sample code,
and I can't tell you if it will work in AutoCAD 2004.

uncoolperson

  • Guest
Re: Who can write these codes in C#?
« Reply #6 on: December 23, 2008, 11:08:18 AM »
up-up-down-down-left-right-left-right-b-a-start

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Who can write these codes in C#?
« Reply #7 on: December 23, 2008, 11:09:32 AM »
up-up-down-down-left-right-left-right-b-a-start
Greedy!  No love for the second player??
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.