Results 1 to 8 of 8

Thread: [3.0/LINQ] inheriting forms.

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2006
    Posts
    607

    [3.0/LINQ] inheriting forms.

    I have another form (camera.cs) which inherits from LayeredForm. This works perfectly when compiled, however in design mode it says "Error Creating Window Handle"

    But since camera.cs is all dynamic (ie no controls on it jus stuff being painted on) its perfectly fine. However I want to create another form and put controls on it so I'd like to inherit from this form.

    its a small class (couple of methods) but I think the problem arises becuase it uses GDI to draw the form.

    http://pastebin.com/m33b54bb3

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [3.0/LINQ] inheriting forms.

    Did you use the Inherited Form item template when you added the derived class to your project, or did you use the Windows Form item template and then hook it up yourself?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2006
    Posts
    607

    Re: [3.0/LINQ] inheriting forms.

    I used the inherited form function. (then I tried doing it manually also)

    Both resulted in that error, (however it works when compiled).. so i have no idea whats going on.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [3.0/LINQ] inheriting forms.

    So LayeredForm is the base and Camera is the derived class, correct? You're saying that Canera won't display in the designer? After creating a derived form does it not display in the designer immediately? If it does display, what changes have you made to Camera?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2006
    Posts
    607

    Re: [3.0/LINQ] inheriting forms.

    Quote Originally Posted by jmcilhinney
    So LayeredForm is the base and Camera is the derived class, correct? You're saying that Canera won't display in the designer? After creating a derived form does it not display in the designer immediately? If it does display, what changes have you made to Camera?
    That is correct. Here is a screenshot when I try to pull up "camera" in Design mode.



    However, the layeredForm (base class) loads fine..


  6. #6

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [3.0/LINQ] inheriting forms.

    Have you viewed the call stack?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2006
    Posts
    607

    Re: [3.0/LINQ] inheriting forms.

    Yes I did, which leads me to believe that the error is because I am using GDI to draw the form rather then .net I think. here is the call stack.. or the first couple of lines.


    System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp)
    at System.Windows.Forms.Control.CreateHandle()
    at System.Windows.Forms.Form.CreateHandle()
    at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
    at System.Windows.Forms.Control.CreateControl()
    at System.Windows.Forms.Control.OnVisibleChanged(EventArgs e)
    at System.Windows.Forms.ScrollableControl.OnVisibleChanged(EventArgs e)
    at System.Windows.Forms.Form.OnVisibleChanged(EventArgs e)
    at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
    at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
    at System.Windows.Forms.Control.set_Visible(Boolean value)
    at System.Windows.Forms.Design.DesignerFrame.Initialize(Control view)
    at System.Windows.Forms.Design.DocumentDesigner.Initialize(IComponent component)
    at System.Windows.Forms.Design.FormDocumentDesigner.Initialize
    The only thing I can find related to the call stack is:

    csharp Code:
    1. #region Windows Message Handling
    2.  
    3.     protected override CreateParams CreateParams
    4.     {
    5.         get
    6.         {
    7.             CreateParams cParams = base.CreateParams;
    8.             cParams.ExStyle |= NativeMethods.WS_EX_LAYERED;
    9.             return cParams;
    10.         }
    11.     }
    12.  
    13.     #endregion

    What I dont get is how can it compile and run perfectly fine? I think its because all the painting is done in the camera constructor..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width