Help! - Control

  • Thread starter Thread starter littlemenace
  • Start date Start date
L

littlemenace

Hi, I have made a custom control that looks like a vista basic window
(dont ask why :D). I added
"<Designer("System.Windows.Forms.Design.ParentControlDesigner,System.Design",
GetType(IDesigner))> _" onto the top of the class declaration.

I can easily drag my control onto the window and resize it in design
time - and when I debug the application it works fine.

But when I add a control to the container the runtime the control goes
back to its default shape and doesnt fit in the form.

This is how it looks at design time and runtime:
http://img175.imageshack.us/img175/3663/designtq5.jpg

All the images in the window control are anchored and seem fine at
designtime but go back to their default position at runtime.
 
[...]
I can easily drag my control onto the window and resize it in design
time - and when I debug the application it works fine.
But when I add a control to the container the runtime the control goes
back to its default shape and doesnt fit in the form. [...]

Whatever is going on, I think it's unlikely you'll get much in the way of 
useful advice until you create and post a concise-but-complete code sample  
that reliably demonstrates the problem.  Since your question appears to 
depend also on specific user actions, you will need to be very specific  
about those as well.

Please note: "concise-but-complete" means both things.  It should be a  
self-contained, compilable piece of code.  And it should also including 
_nothing_ that is not directly related to or necessary for reproducing  
your problem.

Pete

Here is a link to my VB project.

http://www.savefile.com/files/1703943

The VB file is compiled and the DLL is in the release directory - I am
sure you know how to add it into the toolbox :D

Thanks, rob
 
Here is a link to my VB project. [...]

Please post the code here.  Assuming you've distilled your project downto  
a true "concise-but-complete" sample, it won't be very long at all.  And  
one of the biggest values of this forum is that it's archived  
indefinitely, whereas the link you provided definitely won't be.  If  
someone else has the same question, and we rely only on a temporary web  
link to complete the question, it will make this thread that much less  
useful to them when they find it.

Pete

Well, I cant really as it is in the form of a control and lots and
lots of images - there is no code; is all anchoring and patching
together.
 
[...]
Well, I cant really as it is in the form of a control and lots and
lots of images - there is no code; is all anchoring and patching
together.

If it's .NET, it's code.

In any case, all I can do is provide suggestions to you for getting your  
question answered.  If you truly believe it's not possible to post a  
concise-but-complete code sample that demonstrates your problem, then I  
can only recommend that you not set your hopes too high for having the  
question answered.

It's not unusual to find people who are willing to help those who can  
express their question in a concise, direct, useful way.  But there are 
not many people who are willing to spend their own time doing all the work  
that the person asking the question should have done.  Right now, you are  
hoping for and relying on the latter.

Pete

Right, basically here I have a simple control with around 12 images
all anchored in their correct positions, if you really want the code
it is here:

Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Windows.Forms

<Designer("System.Windows.Forms.Design.ParentControlDesigner,System.Design",
GetType(IDesigner))> _
Public Class Vista_Basic_Window



End Class

As you can see, there is no code - all I am basing this control off is
images - as you can see here: http://img292.imageshack.us/img292/1695/helpog8.jpg

I really hope I dont come accross as ignorant or needy - belive it or
not I am normally an experienced programmer - I just cant figure out
why the images on the control do not retain their anchor information
at runtime.

Thanks a lot, Rob
 
[...]
As you can see, there is no code

The Designer generates code on your behalf.  You haven't posted any of  
that code.  Nor have you posted the full context in which that code is  
used.

Answering your question without that information is impossible.

It's possible that no one will be able to answer your question even with  
that information.  But without it, failure is practically guaranteed.

Pete

Ok, basically the problem i am having is the fact that anchor settings
dont seem to apply at runtime - in designer all the images move to the
right when the control is resized - due to the way they are anchored:
but at runtime the images on my control go back to their default
position, as you can see here http://img175.imageshack.us/img175/3663/designtq5.jpg.
 
Peter Duniho said:
[...]
As you can see, there is no code

The Designer generates code on your behalf. You haven't posted any of
that code. Nor have you posted the full context in which that code is
used.

Which is in a separate file which is automatically hidden by Visual Studio.

You'll have to expand the file list for your control_whatever.vb to find the
..Designer.vb file

Can you simplify it to just one or two images? Like perhaps the minimize
and maximize buttons aren't essential if the behavior still happens with the
close X.
 
[...]
As you can see, there is no code
The Designer generates code on your behalf.  You haven't posted any of
that code.  Nor have you posted the full context in which that code is
used.

Which is in a separate file which is automatically hidden by Visual Studio.

You'll have to expand the file list for your control_whatever.vb to find the
.Designer.vb file

Can you simplify it to just one or two images?  Like perhaps the minimize
and maximize buttons aren't essential if the behavior still happens with the
close X.




Answering your question without that information is impossible.
It's possible that no one will be able to answer your question even with
that information.  But without it, failure is practically guaranteed.
Pete- Hide quoted text -

- Show quoted text -

Well, the same thing is happening with every control - the anchoring
doesnt seem to be applying for any control I make - I can resize the
control in the designer and its looks fine but as soon as I go into
runtime and there is a button or somthing in the containing control it
seems to loose its anchoring settings.

I belive the code pasted under nearth this text is what you are
looking for.

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Vista_Basic_Window
Inherits System.Windows.Forms.UserControl

'UserControl overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form
Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.img_Border_Left_Top_Corner = New
System.Windows.Forms.PictureBox
Me.img_Border_Right_Top_Corner = New
System.Windows.Forms.PictureBox
Me.img_Border_Minimize = New System.Windows.Forms.PictureBox
Me.img_Border_Maximize = New System.Windows.Forms.PictureBox
Me.img_Border_Close = New System.Windows.Forms.PictureBox
Me.img_Border_Titlebar = New System.Windows.Forms.PictureBox
Me.img_Border_Left_Top = New System.Windows.Forms.PictureBox
Me.img_Border_Left_Bottom = New
System.Windows.Forms.PictureBox
Me.img_Border_Right_Corner = New
System.Windows.Forms.PictureBox
Me.img_Border_Right_Top = New System.Windows.Forms.PictureBox
CType(Me.img_Border_Left_Top_Corner,
System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.img_Border_Right_Top_Corner,
System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.img_Border_Minimize,
System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.img_Border_Maximize,
System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.img_Border_Close,
System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.img_Border_Titlebar,
System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.img_Border_Left_Top,
System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.img_Border_Left_Bottom,
System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.img_Border_Right_Corner,
System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.img_Border_Right_Top,
System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'img_Border_Left_Top_Corner
'
Me.img_Border_Left_Top_Corner.BackgroundImage =
Global.Vista_Basic_Window_Shell.My.Resources.Resources.Border_Left_Top
Me.img_Border_Left_Top_Corner.Location = New
System.Drawing.Point(0, 0)
Me.img_Border_Left_Top_Corner.Name =
"img_Border_Left_Top_Corner"
Me.img_Border_Left_Top_Corner.Size = New
System.Drawing.Size(8, 28)
Me.img_Border_Left_Top_Corner.SizeMode =
System.Windows.Forms.PictureBoxSizeMode.AutoSize
Me.img_Border_Left_Top_Corner.TabIndex = 20
Me.img_Border_Left_Top_Corner.TabStop = False
'
'img_Border_Right_Top_Corner
'
Me.img_Border_Right_Top_Corner.Anchor =
CType((System.Windows.Forms.AnchorStyles.Top Or
System.Windows.Forms.AnchorStyles.Right),
System.Windows.Forms.AnchorStyles)
Me.img_Border_Right_Top_Corner.BackgroundImage =
Global.Vista_Basic_Window_Shell.My.Resources.Resources.Border_Right_Top
Me.img_Border_Right_Top_Corner.Location = New
System.Drawing.Point(514, 0)
Me.img_Border_Right_Top_Corner.Name =
"img_Border_Right_Top_Corner"
Me.img_Border_Right_Top_Corner.Size = New
System.Drawing.Size(8, 28)
Me.img_Border_Right_Top_Corner.SizeMode =
System.Windows.Forms.PictureBoxSizeMode.AutoSize
Me.img_Border_Right_Top_Corner.TabIndex = 19
Me.img_Border_Right_Top_Corner.TabStop = False
'
'img_Border_Minimize
'
Me.img_Border_Minimize.Anchor =
CType((System.Windows.Forms.AnchorStyles.Top Or
System.Windows.Forms.AnchorStyles.Right),
System.Windows.Forms.AnchorStyles)
Me.img_Border_Minimize.Image =
Global.Vista_Basic_Window_Shell.My.Resources.Resources.Border_Minimize_Mouse_Off
Me.img_Border_Minimize.Location = New
System.Drawing.Point(423, 9)
Me.img_Border_Minimize.Name = "img_Border_Minimize"
Me.img_Border_Minimize.Size = New System.Drawing.Size(28, 15)
Me.img_Border_Minimize.SizeMode =
System.Windows.Forms.PictureBoxSizeMode.AutoSize
Me.img_Border_Minimize.TabIndex = 18
Me.img_Border_Minimize.TabStop = False
'
'img_Border_Maximize
'
Me.img_Border_Maximize.Anchor =
CType((System.Windows.Forms.AnchorStyles.Top Or
System.Windows.Forms.AnchorStyles.Right),
System.Windows.Forms.AnchorStyles)
Me.img_Border_Maximize.Image =
Global.Vista_Basic_Window_Shell.My.Resources.Resources.Border_Maximize_Mouse_Off
Me.img_Border_Maximize.Location = New
System.Drawing.Point(453, 9)
Me.img_Border_Maximize.Name = "img_Border_Maximize"
Me.img_Border_Maximize.Size = New System.Drawing.Size(28, 15)
Me.img_Border_Maximize.SizeMode =
System.Windows.Forms.PictureBoxSizeMode.AutoSize
Me.img_Border_Maximize.TabIndex = 17
Me.img_Border_Maximize.TabStop = False
'
'img_Border_Close
'
Me.img_Border_Close.Anchor =
CType((System.Windows.Forms.AnchorStyles.Top Or
System.Windows.Forms.AnchorStyles.Right),
System.Windows.Forms.AnchorStyles)
Me.img_Border_Close.Image =
Global.Vista_Basic_Window_Shell.My.Resources.Resources.Border_Close_Mouse_Off
Me.img_Border_Close.Location = New System.Drawing.Point(483,
9)
Me.img_Border_Close.Name = "img_Border_Close"
Me.img_Border_Close.Size = New System.Drawing.Size(28, 15)
Me.img_Border_Close.SizeMode =
System.Windows.Forms.PictureBoxSizeMode.AutoSize
Me.img_Border_Close.TabIndex = 16
Me.img_Border_Close.TabStop = False
'
'img_Border_Titlebar
'
Me.img_Border_Titlebar.Anchor =
CType(((System.Windows.Forms.AnchorStyles.Top Or
System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right),
System.Windows.Forms.AnchorStyles)
Me.img_Border_Titlebar.BackgroundImage =
Global.Vista_Basic_Window_Shell.My.Resources.Resources.Border_Top_Tile
Me.img_Border_Titlebar.Location = New System.Drawing.Point(8,
0)
Me.img_Border_Titlebar.Name = "img_Border_Titlebar"
Me.img_Border_Titlebar.Size = New System.Drawing.Size(506, 28)
Me.img_Border_Titlebar.TabIndex = 15
Me.img_Border_Titlebar.TabStop = False
'
'img_Border_Left_Top
'
Me.img_Border_Left_Top.Anchor =
CType(((System.Windows.Forms.AnchorStyles.Top Or
System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left),
System.Windows.Forms.AnchorStyles)
Me.img_Border_Left_Top.BackgroundImage =
Global.Vista_Basic_Window_Shell.My.Resources.Resources.Border_Left_Side_Tile
Me.img_Border_Left_Top.Image =
Global.Vista_Basic_Window_Shell.My.Resources.Resources.Border_Left_Side_Top
Me.img_Border_Left_Top.Location = New System.Drawing.Point(0,
27)
Me.img_Border_Left_Top.Name = "img_Border_Left_Top"
Me.img_Border_Left_Top.Size = New System.Drawing.Size(8, 287)
Me.img_Border_Left_Top.TabIndex = 14
Me.img_Border_Left_Top.TabStop = False
'
'img_Border_Left_Bottom
'
Me.img_Border_Left_Bottom.Anchor =
CType(((System.Windows.Forms.AnchorStyles.Bottom Or
System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right),
System.Windows.Forms.AnchorStyles)
Me.img_Border_Left_Bottom.BackgroundImage =
Global.Vista_Basic_Window_Shell.My.Resources.Resources.Border_Bottom_Tile
Me.img_Border_Left_Bottom.Image =
Global.Vista_Basic_Window_Shell.My.Resources.Resources.Border_Left_Bottom_Corner
Me.img_Border_Left_Bottom.Location = New
System.Drawing.Point(0, 314)
Me.img_Border_Left_Bottom.Name = "img_Border_Left_Bottom"
Me.img_Border_Left_Bottom.Size = New System.Drawing.Size(514,
8)
Me.img_Border_Left_Bottom.TabIndex = 13
Me.img_Border_Left_Bottom.TabStop = False
'
'img_Border_Right_Corner
'
Me.img_Border_Right_Corner.Anchor =
CType((System.Windows.Forms.AnchorStyles.Bottom Or
System.Windows.Forms.AnchorStyles.Right),
System.Windows.Forms.AnchorStyles)
Me.img_Border_Right_Corner.BackgroundImage =
Global.Vista_Basic_Window_Shell.My.Resources.Resources.Border_Right_Bottom_Corner
Me.img_Border_Right_Corner.Location = New
System.Drawing.Point(514, 314)
Me.img_Border_Right_Corner.Name = "img_Border_Right_Corner"
Me.img_Border_Right_Corner.Size = New System.Drawing.Size(8,
8)
Me.img_Border_Right_Corner.TabIndex = 12
Me.img_Border_Right_Corner.TabStop = False
'
'img_Border_Right_Top
'
Me.img_Border_Right_Top.Anchor =
CType(((System.Windows.Forms.AnchorStyles.Top Or
System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Right),
System.Windows.Forms.AnchorStyles)
Me.img_Border_Right_Top.BackgroundImage =
Global.Vista_Basic_Window_Shell.My.Resources.Resources.Border_Right_Side_Tile
Me.img_Border_Right_Top.Image =
Global.Vista_Basic_Window_Shell.My.Resources.Resources.Border_Right_Side_Top
Me.img_Border_Right_Top.Location = New
System.Drawing.Point(514, 27)
Me.img_Border_Right_Top.Name = "img_Border_Right_Top"
Me.img_Border_Right_Top.Size = New System.Drawing.Size(8, 287)
Me.img_Border_Right_Top.TabIndex = 11
Me.img_Border_Right_Top.TabStop = False
'
'Vista_Basic_Window
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.Controls.Add(Me.img_Border_Left_Top_Corner)
Me.Controls.Add(Me.img_Border_Right_Top_Corner)
Me.Controls.Add(Me.img_Border_Minimize)
Me.Controls.Add(Me.img_Border_Maximize)
Me.Controls.Add(Me.img_Border_Close)
Me.Controls.Add(Me.img_Border_Titlebar)
Me.Controls.Add(Me.img_Border_Left_Top)
Me.Controls.Add(Me.img_Border_Left_Bottom)
Me.Controls.Add(Me.img_Border_Right_Corner)
Me.Controls.Add(Me.img_Border_Right_Top)
Me.Margin = New System.Windows.Forms.Padding(8, 28, 8, 8)
Me.Name = "Vista_Basic_Window"
Me.Size = New System.Drawing.Size(522, 322)
CType(Me.img_Border_Left_Top_Corner,
System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.img_Border_Right_Top_Corner,
System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.img_Border_Minimize,
System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.img_Border_Maximize,
System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.img_Border_Close,
System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.img_Border_Titlebar,
System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.img_Border_Left_Top,
System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.img_Border_Left_Bottom,
System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.img_Border_Right_Corner,
System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.img_Border_Right_Top,
System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
Me.PerformLayout()

End Sub
Friend WithEvents img_Border_Left_Top_Corner As
System.Windows.Forms.PictureBox
Friend WithEvents img_Border_Right_Top_Corner As
System.Windows.Forms.PictureBox
Friend WithEvents img_Border_Minimize As
System.Windows.Forms.PictureBox
Friend WithEvents img_Border_Maximize As
System.Windows.Forms.PictureBox
Friend WithEvents img_Border_Close As
System.Windows.Forms.PictureBox
Friend WithEvents img_Border_Titlebar As
System.Windows.Forms.PictureBox
Friend WithEvents img_Border_Left_Top As
System.Windows.Forms.PictureBox
Friend WithEvents img_Border_Left_Bottom As
System.Windows.Forms.PictureBox
Friend WithEvents img_Border_Right_Corner As
System.Windows.Forms.PictureBox
Friend WithEvents img_Border_Right_Top As
System.Windows.Forms.PictureBox

End Class


Thanks a lot, Rob
 
Back
Top