|
-
Jan 12th, 2000, 03:13 AM
#1
Thread Starter
Lively Member
I have a form with a command button which makes another form pop up:
Private Sub Command1_Click()
Form2.Show
End Sub
Does anyone know the code I can use so that form2 will be aligned with the bottom right hand corner of form1? ie: Form2 will appear on top of form1, with the bottom right corner coordinates exactly on top of that of form1?
Thanks for any help!
-
Jan 12th, 2000, 03:25 AM
#2
Hyperactive Member
Well, there's a couple ways to do this. You can set the location of where the form appears by setting it's location to manual and then manually placing it where you want it to appear. You could also figure it out using the values in the Left, Top, Hieght and Width properties of the 2 forms. Hope it helps.
-
Jan 12th, 2000, 03:33 AM
#3
form2.left = form1.left + form1.width
form2.top = form1.top + form1.height
That should give you the bottom right hand corner
------------------
Boothman
There is a war out there and it is about who controls the information, it's all about the information.
-
Jan 12th, 2000, 03:33 AM
#4
New Member
To make form2 appear exactly on top op form1
form2.show
form2.Left = form1.left
form2.top = form1.left
to make form2 appear in front of form1
form2.show
form2.left = form1.left
To make form2 apear at the bottom right cornor of form1
form2.show
form2.left=form1.left + form1.width
form2.top = form1.top + form1.height
--
This should give you a pretty good idea of how to assign a position to a form
Thomas
-
Jan 12th, 2000, 03:56 AM
#5
Thread Starter
Lively Member
Okay, perhaps I didn't make myself completely clear. I want Form2 to appear on TOP of form 1: The bottom right corner should be aligned with the bottom right corner of Form1, and it should be on top of form1.
I played around with your code above. The closest I got was:
Private Sub Command1_Click()
Form2.Show
Form2.Left = Form1.Left
Form2.Top = Form1.Left
End Sub
by Thomas. (thanks!)
The above code makes form2 align with the top left corner of form1. I thought I could simply replace 'Left' with 'Right', and I would get what I'm looking for, but I got an error. Does anyone know how to do what I want?
Thanks again!
-
Jan 12th, 2000, 04:32 AM
#6
form2.left = (form1.left + form1.width) - form2.width
form2.top = (form1.top + form1.height) - form2.height)
Sorry about the first answer. Did not quite understand. This should work though.
------------------
Boothman
There is a war out there and it is about who controls the information, it's all about the information.
-
Jan 12th, 2000, 04:40 AM
#7
Thread Starter
Lively Member
Thanks Boothman, it now works fine.
-
Jan 12th, 2000, 06:47 PM
#8
Thread Starter
Lively Member
Does anybody know why this happens?
With the code below it works fine:
Private Sub Command1_Click()
form2.Show
form2.left = (form1.left + form1.width) - form2.width
form2.top = (form1.top + form1.height) - form2.height
End Sub
form2 loads in the bottom right corner of form1, as planned.
But I have to have form1 as a mdichild form. If I set form1 as a mdichild form, form2 no longer loads in the same position - it loads somewhere totally different. Does anybody know why and how this can be resolved?
My objective is to make form2 load in the bottom right corner of form1.
In any case, thanks for your help.
-
Jan 12th, 2000, 07:28 PM
#9
Registered User
Make the form2 too a mdichild. That's the easiest way.
Hmm...after thinking a while, I think that's THE ONLY way to get it to right position. There may be a API call (I don't know much at API) that can get the position of MDIform's greyarea's x and y position.
If this is not clear, here's a ASCII pic on what I mean, x and y pos what I mean is marked with small x
-----------------------------------
| | MDIform1 |_|O|X|
-----------------------------------
| File Options Help |
-----------------------------------
| x.............................. |
| ................--------------. |
| ................| | form1 |X|. |
| ................--------------. |
-----------------------------------
Just hope that this is not too confusing 
COPY THAT ASCII PIC TO CLIPBOARD AND OPEN AT NOTEPAD! Makes it much clearer.
Vesa Piittinen
[This message has been edited by Merry VIP (edited 01-13-2000).]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|