Existential question!

  • Thread starter Thread starter Anil Gupte
  • Start date Start date
A

Anil Gupte

As in "Who am I?" or better "Who am Me?"

When I use:
Dim X0 As Integer = ActiveForm.Location.X

Dim Y0 As Integer = ActiveForm.Location.Y

Dim strTest As String = ActiveForm.Name

Dim SIX0 = X0 + 560

Dim SIY0 = Y0 - 30

The strTest variable contains the name of the container form (the
MDIParent). However, when I do this:

Dim X0 As Integer = Me.Location.X

Dim Y0 As Integer = Me.Location.Y

Dim strTest As String = Me.Name

Dim SIX0 = X0 + 560

Dim SIY0 = Y0 - 30

I get the name of the form within the container (called FormMain). More
important the locations seem to be all messed up. When I use Me.Location,
the 0,0 point is not the topleft of the form, I have to use the negative
value to try to position some test at the top.

Any advice?

Thanx,
 
I forgot to add, my FormMain (dimmed as frmMain) refuses to fill up the
Container i.e. the MDIParent until I switch to another form and then come
back. In the Container form I do have:
Private Sub FormContainer_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

frmMain.MdiParent = Me

frmSliceInfo.MdiParent = Me

frmSliceInfo.Dock = DockStyle.Fill

frmMain.Dock = DockStyle.Fill

frmMain.Show()

End Sub

and I have also set the Dock property in the properties window of all the
forms to "None".
 
Anil,

Me is the same as in the C languages "this".

It means all the variables (objects values) that are in the object from the
class itself.

me.textBox1 is the same as textbox1.

It is easy however if you don't remember a name to type first me.

It is also easy to tell to another object which object is the sender,

The problem is that you are not telling what kind of form you are using, it
can by instance be a MDI, a showdialog or something used as a usercontrol
inside your control container.

Cor
 
I am sorry, I did not understand your response. First of all why does it
(fmrMain) not fill up the container form? The other form (frmSliceInfo)
does, and all the parameters are the same. Also, why is Me not the same as
ActiveForm?
 
Thre is one difference: frmMain is shown during the load event of the
mdiform. Try loading frmMain after the mdi form is fully loaded.

Me is the instance you are currently in (if frmMaincode, me means
frmmain, in frmSliceInfo code, me means frmSliceInfo).
ActiveForm is the activeform of the project.

So to see the difference:

'code in frmSliceInfo, which is active
frmMain.mySub 'calls a routine in frmMain


'code in frmMain:
Public Sub mySub()
'When called from above
'Me is frmMain
'ActiveForm is frmSliceInfo

'When called when frmMain is active
'Me is still frmMain
'ActiveForm is now also frmMain
End Sub
 
How do I load frmMain after the MDI container is loaded? There is no other
event I can call as far as I know. I may have fixed the problem though by
adding the line:
frmMain.Size = Me.Size

to the Private Sub FormContainer_Load event

Thanx for the input.
 
Or use frmMain.windowstate = FormWindowState.Maximized instead of the
dock property - It seems this is what you want after all.
 
Back
Top