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 / November 2004

Tip: Looking for answers? Try searching our database.

Steal winforms drawing code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Adrin - 20 Nov 2004 22:51 GMT
I'm building a couple of designers and I would like to use the same drawing
that winforms classes use.
I managed to do this:

class ButtonComponent
{
}

class ButtonComponentDesigner
{
 Button b = new Button();
// b is synced with the ButtonComponent that we should design
}

When painting in the designer I want to draw using the logic from b. OnPaint
is protected so I had to inherit Button in my own class to access it. So
what I did was:

class FakeButton : Button
{
 public void DoFakePaint(PaintEventArgs e)
 {
    base.OnPaint(e);
 }
}

So now the designer becomes:

class ButtonComponentDesigner
{
 FakeButton b = new FakeButton();
// sync b like above with ButtonComponent

// when drawing just call b.DoFakePaint() and it works
}

This is all very good and it works but I have problems with the other
winforms controls: CheckedListBox, ComboBox, ListBox, PictureBox, TextBox -
they don't draw using this method.

Button, CheckBox, GroupBox, Label, LinkLabel all work perfectly.

Is it possible to steal the drawing form the more complicated controls?...
That's all I need, just for them to look the same, and doing it by hand
doesn't appeal to me.

Thanks.
Adrin - 20 Nov 2004 23:05 GMT
One more thing... xxxComponent already has a base class so i can't inherit
from Button directly. Also it is not a Control that can be placed on a form.
It's more like a bussines object. Still, I want to be able to make a
designer for these components as fast as possible, without changing anything
inside them (xxxComponents represent the model in a MVC architecture).

> I'm building a couple of designers and I would like to use the same
> drawing that winforms classes use.
[quoted text clipped - 43 lines]
>
> Thanks.

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.