Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi.

Until now I have been overriding WndProc() to find when the mouse is clicked on a custom control so that I can highlight a soft control located within to edit its properties in the property editor. I got this method from several books on custom controls including one by Richard Weeks.

 

After reading Divil's contribution (excellent) I tried implementing GetHitTest() instead and this works just fine without having to get dirty with win32. It appears to be a much better (native) way to do it.

 

Is this new to .Net2003?

Does anyone know a reason why you would override WndProc when GetHitTest() appears to work fine? Have I missed something?

 

thanks:)

Posted
I really don't know why that someone would prefer WndProc but be carefull about the books your read... some are about the Beta version of .net, where quite a lot of methods weren't implemented or in diferent namespaces...
Software bugs are impossible to detect by anybody except the end user.
  • *Gurus*
Posted

GetHitTest is a better way of doing it that subclassing for messages in the designer. Also, you might try looking at the MouseDragBegin procedure of ControlDesigner that you can override to also provide this soft highlighting feature.

 

If you plan on allowing the user to drag this subcomponent, using the built in OLE drag and drop methods is preferable too. The goal is really to remove all design-time functionality from the control itself and put it in the designer. The thing with GetHitTest is that your logic will still be in the control and not the designer, which actually carries a performance penalty.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...