Results 1 to 9 of 9

Thread: making form appear in a particular position

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 1999
    Location
    France
    Posts
    90

    Post

    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!


  2. #2
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Post

    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.

  3. #3
    Guest

    Post

    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.

  4. #4
    New Member
    Join Date
    Jan 2000
    Posts
    2

    Post

    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


  5. #5

    Thread Starter
    Lively Member
    Join Date
    Feb 1999
    Location
    France
    Posts
    90

    Post

    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!

  6. #6
    Guest

    Post

    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.

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Feb 1999
    Location
    France
    Posts
    90

    Post

    Thanks Boothman, it now works fine.

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Feb 1999
    Location
    France
    Posts
    90

    Post

    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.

  9. #9
    Registered User
    Join Date
    Jan 2000
    Location
    Otanmäki, Finland
    Posts
    7

    Post

    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
  •  



Click Here to Expand Forum to Full Width