Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Form position

Form position

Scheduled Pinned Locked Moved Visual Basic
question
15 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Yulianto

    Is there a way to reset the position of a child form in the parent/main form? I'm using VB6.


    Work hard, Work effectively.

    P Offline
    P Offline
    panalprasad
    wrote on last edited by
    #2

    Please the move function

    Y 1 Reply Last reply
    0
    • P panalprasad

      Please the move function

      Y Offline
      Y Offline
      Yulianto
      wrote on last edited by
      #3

      You mean using the move function? I don't want to use that. I want to reset the form position.


      Work hard, Work effectively.

      T 1 Reply Last reply
      0
      • Y Yulianto

        You mean using the move function? I don't want to use that. I want to reset the form position.


        Work hard, Work effectively.

        T Offline
        T Offline
        toxcct
        wrote on last edited by
        #4

        to reset to where ???? the initial place ? i think you'll have to store those values first to recall them then...


        TOXCCT >>> GEII power
        [toxcct][VisualCalc]

        Y 1 Reply Last reply
        0
        • T toxcct

          to reset to where ???? the initial place ? i think you'll have to store those values first to recall them then...


          TOXCCT >>> GEII power
          [toxcct][VisualCalc]

          Y Offline
          Y Offline
          Yulianto
          wrote on last edited by
          #5

          Open first form position ( 0,0) open second form (100,100) third form (200,200) close all form open fourth form, it will be (300,300), but I want it to be reset, into (0,0). Got it?


          Work hard, Work effectively.

          D 1 Reply Last reply
          0
          • Y Yulianto

            Open first form position ( 0,0) open second form (100,100) third form (200,200) close all form open fourth form, it will be (300,300), but I want it to be reset, into (0,0). Got it?


            Work hard, Work effectively.

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #6

            Have you looked at the Top and Left properties of your child form? RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

            Y 1 Reply Last reply
            0
            • D Dave Kreskowiak

              Have you looked at the Top and Left properties of your child form? RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

              Y Offline
              Y Offline
              Yulianto
              wrote on last edited by
              #7

              Dave Kreskowiak wrote: Have you looked at the Top and Left properties of your child form? Yes, what do I have to do with it? The form position it self,when it's opened. I think the parent form must be the one, which calculate the position automatically, like the cascade. How to reset the child position remembered by the parent form?


              Work hard, Work effectively.

              D 1 Reply Last reply
              0
              • Y Yulianto

                Dave Kreskowiak wrote: Have you looked at the Top and Left properties of your child form? Yes, what do I have to do with it? The form position it self,when it's opened. I think the parent form must be the one, which calculate the position automatically, like the cascade. How to reset the child position remembered by the parent form?


                Work hard, Work effectively.

                D Offline
                D Offline
                Dave Kreskowiak
                wrote on last edited by
                #8

                The parent form doesn't remember anything about the child form, other than it exists. Windows picks the default position of the form unless you set the properties of it before you show it.

                Dim newChildForm As New Form2()
                ... other MDI setup stuff
                newChildForm.Top = whatever
                newChildForm.Left = whatever
                newChildForm.Show()

                RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                Y 1 Reply Last reply
                0
                • D Dave Kreskowiak

                  The parent form doesn't remember anything about the child form, other than it exists. Windows picks the default position of the form unless you set the properties of it before you show it.

                  Dim newChildForm As New Form2()
                  ... other MDI setup stuff
                  newChildForm.Top = whatever
                  newChildForm.Left = whatever
                  newChildForm.Show()

                  RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                  Y Offline
                  Y Offline
                  Yulianto
                  wrote on last edited by
                  #9

                  I'm using VB6 Dave. Like I said before, when I open a form the position will be (0,0), when another from is opened, position will be (100,100), just like the cascade. When I close those two form , and open a new one, the position will be (200,200) not (0,0) (which I want it to be). I gave up, I think there's no way for that. :doh: Maybe the only solution is to manually position the form like you said.


                  Work hard, Work effectively.

                  D 1 Reply Last reply
                  0
                  • Y Yulianto

                    I'm using VB6 Dave. Like I said before, when I open a form the position will be (0,0), when another from is opened, position will be (100,100), just like the cascade. When I close those two form , and open a new one, the position will be (200,200) not (0,0) (which I want it to be). I gave up, I think there's no way for that. :doh: Maybe the only solution is to manually position the form like you said.


                    Work hard, Work effectively.

                    D Offline
                    D Offline
                    Dave Kreskowiak
                    wrote on last edited by
                    #10

                    So...? Nothing changes! All you do is create an instance of your child for, set its position to what you want, then show it. What's problem? RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                    Y 1 Reply Last reply
                    0
                    • D Dave Kreskowiak

                      So...? Nothing changes! All you do is create an instance of your child for, set its position to what you want, then show it. What's problem? RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                      Y Offline
                      Y Offline
                      Yulianto
                      wrote on last edited by
                      #11

                      What I want? Form 1 open (0,0) Form 2 open (100,100) form 3 open (200,200) form 2 close form 4 open (100,100) <- this is want I want, but the application automatically sets the position to (300,300).


                      Work hard, Work effectively.

                      D 1 Reply Last reply
                      0
                      • Y Yulianto

                        What I want? Form 1 open (0,0) Form 2 open (100,100) form 3 open (200,200) form 2 close form 4 open (100,100) <- this is want I want, but the application automatically sets the position to (300,300).


                        Work hard, Work effectively.

                        D Offline
                        D Offline
                        Dave Kreskowiak
                        wrote on last edited by
                        #12

                        What part of "just set the Top and Left properties of the child form before you show it" don't you understand????

                        Dim newChildForm As New Form2
                        ... other MDI setup stuff
                        newChildForm.Top = 100
                        newChildForm.Left = 100
                        newChildForm.Show()

                        RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                        Y 1 Reply Last reply
                        0
                        • D Dave Kreskowiak

                          What part of "just set the Top and Left properties of the child form before you show it" don't you understand????

                          Dim newChildForm As New Form2
                          ... other MDI setup stuff
                          newChildForm.Top = 100
                          newChildForm.Left = 100
                          newChildForm.Show()

                          RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                          Y Offline
                          Y Offline
                          Yulianto
                          wrote on last edited by
                          #13

                          I understand the Top and Left properties. What I don't understand is the calculation of position, when it is (100,100), when it is (200,200), when (400,400). In other words, what is the position will I put the form. I want the form to be showed like cascade.


                          Work hard, Work effectively.

                          D 1 Reply Last reply
                          0
                          • Y Yulianto

                            I understand the Top and Left properties. What I don't understand is the calculation of position, when it is (100,100), when it is (200,200), when (400,400). In other words, what is the position will I put the form. I want the form to be showed like cascade.


                            Work hard, Work effectively.

                            D Offline
                            D Offline
                            Dave Kreskowiak
                            wrote on last edited by
                            #14

                            You'll have to remember the positions of all the child forms, keeping them in an array. Create an array and initialize each element to -1, -1. When you want to add a new child form, you'll have to search through the collection looking for a free "slot", which is represented by -1, 1. Calculating the child form positions isn't hard since each is a constant offset from the previous position. So, if your free "slot" is in array index 2, you just need to multiply that by the X and Y (Top and Left) offsets to get the position of the form. In your example, by 100. Put that position in the array at that index. When a form is closed, you'll have to reset that position in the array to -1, -1. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                            Y 1 Reply Last reply
                            0
                            • D Dave Kreskowiak

                              You'll have to remember the positions of all the child forms, keeping them in an array. Create an array and initialize each element to -1, -1. When you want to add a new child form, you'll have to search through the collection looking for a free "slot", which is represented by -1, 1. Calculating the child form positions isn't hard since each is a constant offset from the previous position. So, if your free "slot" is in array index 2, you just need to multiply that by the X and Y (Top and Left) offsets to get the position of the form. In your example, by 100. Put that position in the array at that index. When a form is closed, you'll have to reset that position in the array to -1, -1. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                              Y Offline
                              Y Offline
                              Yulianto
                              wrote on last edited by
                              #15

                              Yeah, I know I can do it. I was just hoping there's a simpler way. :doh:Thank you Dave.


                              Work hard, Work effectively.

                              1 Reply Last reply
                              0
                              Reply
                              • Reply as topic
                              Log in to reply
                              • Oldest to Newest
                              • Newest to Oldest
                              • Most Votes


                              • Login

                              • Don't have an account? Register

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • World
                              • Users
                              • Groups