devxlogo

Processing a Native Window Message Inside a Non-visual Class

Processing a Native Window Message Inside a Non-visual Class

Say you have a dynamic library and you want to treat a native window message inside any non-visual class in that library.

Derive this class from NativeWindow as shown below. After creating the new class from Class1, you can pass the Handle (like IntPtr) of this class to any native function.

public class Class1: NativeWindow{	CreateParams cp = new CreateParams();	public Class1()	{		// Create the actual window		this.CreateHandle(cp);	}	protected override void WndProc(ref Message m)	{		if(m.Msg == WM_...)		{			// Do something here in response to messages			return;		}		base.WndProc(ref m);	}}
See also  Does It Make Sense to Splurge on a Laptop?
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist