ControlStyles on a Runtime Created Form

JCreationsInc

Active member
Joined
May 2, 2003
Messages
42
Location
San Jose Ca (Silicon Valley)
Hello people of the metal box on my computer.

I am creating a application that will easily allow me to create skins for my future applications. Well in this application, there is a feature that allows you to preview your progress, creating a window and drawing the skin to the window from the paint event.

Well now to the nitty gritty, I need to set the created windows ControlStyles:

Code:
        Window.SetStyle(ControlStyles.AllPaintingInWmPaint, True)
        Window.SetStyle(ControlStyles.UserPaint, True)
        Window.SetStyle(ControlStyles.DoubleBuffer, True)

When I try to do it from my skin drawing procedure it wont compile due to the "SetStyle" function being protected. So what I was wondering is there another way of setting the ControlStyles?:confused:
 
You can do it only in the form itself. So maybe you could edit the constuctor of the form that shows the skin or put in Load event, but you have to do it in the form itself, cant do it from another class.
 
Sounds good..

I will try the load event, I was just reading a artical on msdn that mentions the same thing along with the function updatestyles. Thank you for your help. I will post the results of my escapdes for the world to see.
 
SUCCESS!

Success! Thanks here is what I got..

Code:
    Public Sub CreateWindow()
        Dim TestFrm As New Form()
        AddHandler TestFrm.Load, AddressOf TestFrm_Load
        TestFrm.ShowDialog()
    End Sub

    Public Sub TestFrm_Load(ByVal sender As Object, ByVal e As System.EventArgs)

        Set the value of the double-buffering style bits to true.
        Me.SetStyle(ControlStyles.DoubleBuffer Or _
        ControlStyles.UserPaint Or _
        ControlStyles.AllPaintingInWmPaint, True)
        Me.UpdateStyles()

    End Sub
 
What you are doing is setting those flags for the form you have the code in, not the one that shows skins. :)
You have to edit the class of the form that shows the skin.
:)
 
Back
Top