Windows Develop Bookmark and Share   
 index > Windows Forms General > HOW TO: attach PreProcessMessage to windows form or control
 

HOW TO: attach PreProcessMessage to windows form or control

Hi all,

I wanna know how to attach PreProcessMessage to windows form or control.

Thanks,

WIROL

wirol  Thursday, March 29, 2007 2:10 PM
How about override the WndProc ? You can capture the mouse event by filtering the msg, e.g. WM_LBUTTONDOWN WM_RBUTTONDOWN etc...
Zhi-Xin Ye  Tuesday, April 03, 2007 8:50 AM
Paste this code into your form or control:

public override bool PreProcessMessage(ref Message msg) {
if (msg.Msg == something) {
// Do something
// ...
// Return true if you've processed the message
msg.Result = (IntPtr)1;
return true;
}
return base.PreProcessMessage(ref msg);
}

nobugz  Thursday, March 29, 2007 2:56 PM

Hi,

This way u can override the PreProcessMessage


public override bool PreProcessMessage(ref Message msg)
{
/*if (somecodition)
{
//do processing
//return Boolean;
}*/

return base.PreProcessMessage(ref msg);
}



FYI:A sample is shown at

http://msdn2.microsoft.com/en-us/library/ms171537(vs.80).aspx

Thanx,

Ch.T.Gopi Kumar.

TilakGopi  Thursday, March 29, 2007 3:02 PM

Hi TilakGopi,

Thanks. Your Microsoft example solve my problems. I need to set the security permission.

But the main thing I want is I want to handle Mouse Event. I don't wanna use MouseClick Event or like that.

I need to Handle the mouse event and I can't pass this mouse event to other controls. I need to consume it.

PreProcessMessage doesn't handle for mouse event.

Thanks

WIROL

wirol  Friday, March 30, 2007 1:38 AM
How about override the WndProc ? You can capture the mouse event by filtering the msg, e.g. WM_LBUTTONDOWN WM_RBUTTONDOWN etc...
Zhi-Xin Ye  Tuesday, April 03, 2007 8:50 AM

You can use google to search for other answers

Custom Search

More Threads

• How to save inkPicture control to bmp file
• Redirecting WIndowns key and hot keys like alt+tab to ActiveX RDP Client
• from CSV to ListView in C#
• how to add RichTextBox in Toolbox?
• ToolStripControlHost DataGridView
• How to identify SHIFT KEY HELD (Pessed Down) and 2 mouse left Clicks
• Accessing ListView in other thread
• Acitvex vc++ - hosting Word visually within a WinForm application
• How can we scroll between cell of a DataGridView Through Enter Key Press
• Simple SQL Question - Issue with brackets in INSERT String