Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Design Time / August 2004

Tip: Looking for answers? Try searching our database.

Newbie questions

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dave Sours - 16 Aug 2004 21:56 GMT
I am just getting started in trying to create a custom Windows form control
in VB .NET.  The premise is fairly simple.  It's a "shape control" that
assumes the shape of its Background Image.  The user specifies a Mask Color
and that color is rendered transparent, thus making the control the shape of
the image (in theory, anyway).  I had a version of this working with VB6,
but now want to get my feet wet with .NET.

The problem is, I can't get the design-time behavior I need.  When the user
places the control on a form or changes the background image, I want the
control to resize itself to the image.

Do I need to create an instance of the ControlDesigner class to do this, or
is there a simpler way?  In either case, how would I do it?

If there is sample code or a decent article that covers these issues, please
point me to them.  I don't want to waste your time explaining this stuff for
the umpteenth time.  The Microsoft materials I've found don't seem to cover
this specific area.  I'm sure there must be something out there, but I'm not
finding it.

TIA,

Dave
Dave Sours - 16 Aug 2004 23:04 GMT
OK, I'm making progress, I think.

It seems pretty clear that I do need a designer, and I'm trying to implement
one based on the example in the Help for ControlDesigner class.
Unfortunately, I don't see an event for my designer that relates to placing
the control on the form.  I'm also not getting any event handlers in my
designer to trigger.

I'm obviously missing something.  Here's a code snippet:

<DesignerAttribute(GetType(ShapeControlDesigner))> _
Public Class ShapeControl
Inherits System.Windows.Forms.UserControl
End Class

Public Class ShapeControlDesigner
Inherits System.Windows.Forms.Design.ControlDesigner

Public Sub New()
End Sub

' Sets a value and refreshes the control's display when the
' mouse position enters the area of the control.
Protected Overrides Sub OnMouseEnter()
   ControlSize()
End Sub

Private Sub ControlSize()
   If Not Me.Control.BackgroundImage Is Nothing Then
       MyBase.Control.Size = MyBase.Control.BackgroundImage.Size
       Me.Control.Size = MyBase.Control.BackgroundImage.Size
       Me.Control.Refresh()
   End If
End Sub

End Class

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.