.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Acad WndProc ?

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
289 Views, 3 Replies

Acad WndProc ?

Hi,

I am trying to intercept the WM_MOUSEWHEEL and WM_MBUTTONDOWN messages in the ACAD window.

I have found and modified slightly the following code which allows me to intercept it on a form opened from an Acad Command, but how can I do it in the actual Acad Window ?

Any help appreciated,
Thanks
j

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace wm_wheel1
{
public partial class Form1 : Form


{

// Create a delegate for the custom shutdown event.
public delegate void DoSDCheck(object sender, System.EventArgs e);

// Create an event based on the delegate.
public static event DoSDCheck ThisSDCheck;

// Define an event handler for the custom event.
public static void HandleShutdown(object sender, System.EventArgs e)
{
// Display a simple message box.
MessageBox.Show("Tocando la rueda");
}

//public const Int32 WM_QUERYENDSESSION = 0x0011;
//public const Int32 WM_ENDSESSION = 0x0016;
public const Int32 WM_MOUSEWHEEL = 0x20A;
public const Int32 WM_MBUTTONDOWN = 0x207;


// Override the default message processing to add
// the new event.
protected override void WndProc(ref Message ThisMsg)
{
// See which message Windows has passed.
if ((ThisMsg.Msg == WM_MOUSEWHEEL) ||
(ThisMsg.Msg == WM_MBUTTONDOWN))
{
// Fire the event.
ThisSDCheck.Invoke(this, null);


return;
}


base.WndProc(ref ThisMsg);
}



public Form1()
{
InitializeComponent();

// Add the event handler to the event.
ThisSDCheck += new DoSDCheck(HandleShutdown);

}
}
}
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

See the NativeWindow class.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

wrote in message news:5498245@discussion.autodesk.com...
Hi,

I am trying to intercept the WM_MOUSEWHEEL and WM_MBUTTONDOWN messages in the ACAD window.

I have found and modified slightly the following code which allows me to intercept it on a form opened from an Acad Command, but how can I do it in the actual Acad Window ?

Any help appreciated,
Thanks
j

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace wm_wheel1
{
public partial class Form1 : Form


{

// Create a delegate for the custom shutdown event.
public delegate void DoSDCheck(object sender, System.EventArgs e);

// Create an event based on the delegate.
public static event DoSDCheck ThisSDCheck;

// Define an event handler for the custom event.
public static void HandleShutdown(object sender, System.EventArgs e)
{
// Display a simple message box.
MessageBox.Show("Tocando la rueda");
}

//public const Int32 WM_QUERYENDSESSION = 0x0011;
//public const Int32 WM_ENDSESSION = 0x0016;
public const Int32 WM_MOUSEWHEEL = 0x20A;
public const Int32 WM_MBUTTONDOWN = 0x207;


// Override the default message processing to add
// the new event.
protected override void WndProc(ref Message ThisMsg)
{
// See which message Windows has passed.
if ((ThisMsg.Msg == WM_MOUSEWHEEL) ||
(ThisMsg.Msg == WM_MBUTTONDOWN))
{
// Fire the event.
ThisSDCheck.Invoke(this, null);


return;
}


base.WndProc(ref ThisMsg);
}



public Form1()
{
InitializeComponent();

// Add the event handler to the event.
ThisSDCheck += new DoSDCheck(HandleShutdown);

}
}
}
Message 3 of 4
Anonymous
in reply to: Anonymous

See this:

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

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

wrote in message news:5498245@discussion.autodesk.com...
Hi,

I am trying to intercept the WM_MOUSEWHEEL and WM_MBUTTONDOWN messages in the ACAD window.

I have found and modified slightly the following code which allows me to intercept it on a form opened from an Acad Command, but how can I do it in the actual Acad Window ?

Any help appreciated,
Thanks
j

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace wm_wheel1
{
public partial class Form1 : Form


{

// Create a delegate for the custom shutdown event.
public delegate void DoSDCheck(object sender, System.EventArgs e);

// Create an event based on the delegate.
public static event DoSDCheck ThisSDCheck;

// Define an event handler for the custom event.
public static void HandleShutdown(object sender, System.EventArgs e)
{
// Display a simple message box.
MessageBox.Show("Tocando la rueda");
}

//public const Int32 WM_QUERYENDSESSION = 0x0011;
//public const Int32 WM_ENDSESSION = 0x0016;
public const Int32 WM_MOUSEWHEEL = 0x20A;
public const Int32 WM_MBUTTONDOWN = 0x207;


// Override the default message processing to add
// the new event.
protected override void WndProc(ref Message ThisMsg)
{
// See which message Windows has passed.
if ((ThisMsg.Msg == WM_MOUSEWHEEL) ||
(ThisMsg.Msg == WM_MBUTTONDOWN))
{
// Fire the event.
ThisSDCheck.Invoke(this, null);


return;
}


base.WndProc(ref ThisMsg);
}



public Form1()
{
InitializeComponent();

// Add the event handler to the event.
ThisSDCheck += new DoSDCheck(HandleShutdown);

}
}
}
Message 4 of 4
Anonymous
in reply to: Anonymous

Thanks Tony,

Just what I needed and it works great.

j.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost