Windows Develop Bookmark and Share   
 index > Windows Forms General > Which message handling methods to override?
 

Which message handling methods to override?

Hi. This is a general question, not targeted to solve a specific problem, but rather the help me to design better controls.
I'm trying to get a deeper understanding of how base class controls work. In investigating the System.Windows.Forms.Control class there are a myriad of virtual methods that can be overriden. Here is a partiallist that deal with message handling:
DefWndProc
WndProc
IsInputKey
IsInputChar
ProcessCmdKey
ProcessDialogKey
ProcessDialogChar
OnKeyDown
PreProcessMessage
ProcessKeyEventArgs
ProcessKeyPreview
ProcessMnemonic
I have already read the MS reference for each of these, as well as a couple of books dealing with writing custom controls. I have not been able to find much info on when or whythese methods should (or should not, and if not, why not) be used. Basically, there is a real lack of documentation on the execution flow and passing of messages in .net controls. There is little help for the developer needing to understand the best place to "plug in". Yes, I'veread dozens of articles on choosing between UserControl, deriving from a base class, and Control. They always gloss right over Control.
So now the question.

Can anyone point me to a good source for understanding the .net control architecture?
k.m  Thursday, September 10, 2009 4:29 PM
Hello,

I agree that.NETWinForm control is pretty much a giant wrapper for much of the stuff of win32 control. However, I just think the following article might give you some idea

More than you want to know about Mouse Input
http://blogs.msdn.com/jfoscoding/archive/2005/07/28/444647.aspx

Probably more than you want to know about keyboarding in Windows Forms�
http://blogs.msdn.com/jfoscoding/archive/2005/01/24/359334.aspx

Also, jfo has post a lot valuable stuff about .NET WinForm, I hope you enjoy his blog.

Thanks,
Rong-Chun Zhang
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg@microsoft.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
  • Marked As Answer byk.m Friday, September 11, 2009 3:49 PM
  •  
Rong-Chun Zhang  Friday, September 11, 2009 7:36 AM
You cannot find information for those topics---and many, many others as well---under .NET because they do not fall under .NET. Those technologies existed prior to .NET, and made up the programming platform prior to the release of the Framework.

Win32 and COM Development

Libraries Reference

Those are just the very tips of the tops of the icebergs.

The .NET Framework Class Library is pretty much a giant wrapper for much of the stuff comprising those libraries...with the additional bonus of the CLR.
What is the Common Language Specification?

Hope this helps.

Rudedog =8^D
Mark the best replies as answers. "Fooling computers since 1971."
Rudedog2  Thursday, September 10, 2009 7:03 PM
I appreciate you taking the time to reply, however I believe your responce to be addressing a different topic. My interest is not in the Win32 messages themselves. They are, as you point, out well documented. A more correct analogy is between the .Net framwork and MFC. But, just as MFC is not Win32 and has an architecture to how it internally processes the Win32 messages, and exposes (or hides) certain parts of the processing, the .Net framework has a parallel architecture. Boththe framefork and MFC wrap Win32, but differently.

As an example: ProcesskeyMessage calls ProcessKeyEventArgswhich callsOnKeyDown. All of them are overridable. Is there any good reason to override ProcessKeyEventArgs instead of OnKeyDown? The designers must of had a reason for exposing ProcessKeyEventArgs. What?

Back to the real question at hand - The samples/articles/tutorials/documentation/books that I have been able to find do a very superficialjob of explaining how to create a control by deriving from System.Windows.Forms.Control. Can anyone point me to a source to gain a deeper understanding?


k.m  Thursday, September 10, 2009 8:56 PM
Hello,

I agree that.NETWinForm control is pretty much a giant wrapper for much of the stuff of win32 control. However, I just think the following article might give you some idea

More than you want to know about Mouse Input
http://blogs.msdn.com/jfoscoding/archive/2005/07/28/444647.aspx

Probably more than you want to know about keyboarding in Windows Forms�
http://blogs.msdn.com/jfoscoding/archive/2005/01/24/359334.aspx

Also, jfo has post a lot valuable stuff about .NET WinForm, I hope you enjoy his blog.

Thanks,
Rong-Chun Zhang
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg@microsoft.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
  • Marked As Answer byk.m Friday, September 11, 2009 3:49 PM
  •  
Rong-Chun Zhang  Friday, September 11, 2009 7:36 AM
Rong-Chun,

Now that's what I'm talk'n 'bout. THANK YOU.

There is one more thing that you might be able to help me with. Seems to me there is an official specification for the Windows user interface. I saw it a long time ago but it apparently doesn't have an obvious name like "Windows User Interface Design Specification". It would be the document that describes standard behaviour for standard controls like buttons, textboxes, etc. Any ideas?
k.m  Friday, September 11, 2009 3:49 PM
Thanks for your feedback.

I've searched this on our documentations, unfortunately, I cannot find any User Interface Design Specification for Winform control. I will pay attention on such kind of documentation or MSDN articles. If I get something, I will post back here.

Thanks,
Rong-Chun Zhang
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg@microsoft.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Rong-Chun Zhang  Tuesday, September 15, 2009 10:37 AM

You can use google to search for other answers

Custom Search

More Threads

• OnScreen keyboard
• How to use Crystal Report to load Autocad file (.dxf) ?
• Controls on different Application domain.
• ToolStripControlHost - ToolStripDropDownMenu on costrum draw MenuStrip
• Image Gone on minimize??? I'm using BitBlt
• Panic button
• small icon not displayed, another icon instead...
• second form setting first form field
• Using VB 2008 How does one Move from Field to Field Using Enter Key ?
• Minor System.Drawing.Graphics.DrawRectangle bug