Results 1 to 13 of 13

Thread: 2 forms moving together

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2005
    Posts
    19

    Question 2 forms moving together

    Hello guys,

    I would like to know, what should I do, to make 2 forms (that are not mdichild) to move together when I move on of them?

    For example: Form A is beside Form B. If I move Form A, Form B will move together keeping itself beside Form A.

    Thanks for your time,

    Kaitem

  2. #2
    eltiT resU motsuC Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: 2 forms moving together

    use a timer... set its interval to 10

    Form2.left = form1.left+form1.width
    form2.top = form1.top
    Doevents:doevents:doevents

    isnt the best solutions but it works
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3
    Frenzied Member wiz126's Avatar
    Join Date
    Jul 2005
    Location
    Mars,Milky Way... Chit Chat Posts: 5,733
    Posts
    1,080

    Re: 2 forms moving together

    I added the lost and got focus because if you want to be able to move any of the forms and the other to move then you need to disable the timer.
    In form1
    VB Code:
    1. Private Sub Form_GotFocus()
    2.     Timer1.Enabled = True
    3. End Sub
    4.  
    5. Private Sub Form_Load()
    6.     Form2.Show
    7.     Timer1.Interval = 1
    8.     Timer1.Enabled = True
    9. End Sub
    10.  
    11. Private Sub Form_LostFocus()
    12.     Timer1.Enabled = False
    13. End Sub
    14.  
    15. Private Sub Timer1_Timer()
    16.     Form2.Left = Me.Left - Me.Width
    17.     Form2.Top = Me.Top
    18. End Sub
    In form 2:
    VB Code:
    1. Private Sub Form_GotFocus()
    2.     Timer1.Enabled = True
    3. End Sub
    4.  
    5. Private Sub Form_Load()
    6.     Timer1.Interval = 1
    7.     Timer1.Enabled = True
    8. End Sub
    9.  
    10. Private Sub Form_LostFocus()
    11.     Timer1.Enabled = False
    12. End Sub
    13.  
    14. Private Sub Timer1_Timer()
    15.     Form1.Left = Me.Left + Me.Width
    16.     Form1.Top = Me.Top
    17. End Sub
    Last edited by wiz126; Mar 15th, 2006 at 03:01 PM.
    1) If your post has been adequately answered please click in your post on "Mark Thread Resolved".
    2) If someone has been useful to you please show your respect by rating their posts.
    3) Please use [highlight="VB"] 'your code goes in here [/highlight] tags when posting code.
    4) Before posting your question, make sure you checked this links:
    MICROSOFT MSDN -- VB FORUMS SEARCH

    5)Support Classic VB - A PETITION TO MICROSOFT

    ___________________________________________________________________________________
    THINGS TO KNOW ABOUT VB: || VB Examples/Demos
    What are Classes?
    || -
    Where to place a sub/function?(global) || Webbrowser control

  4. #4

  5. #5
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: 2 forms moving together

    Check this Link by K E Peterson.

    EDIT: i am too lazy. i can never do things on time!!
    Last edited by Harsh Gupta; Mar 15th, 2006 at 03:17 PM.
    Show Appreciation. Rate Posts.

  6. #6
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: 2 forms moving together

    Quote Originally Posted by bushmobile View Post
    Check out this excellent example:

    FormPair by Karl E. Peterson
    this link is broken, does anyone have this project to attach again?
    [ ... active on skype and discord ... ] ,[always strive to achieve your dreams] , [always try,dont stop,never say never]

  7. #7
    Hyperactive Member
    Join Date
    Nov 2011
    Posts
    498

    Re: 2 forms moving together

    heres the link but the download does not work

    https://classicvb.net/samples/FormPair/

  8. #8
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,106

    Re: 2 forms moving together

    From Wayback Machine:

    Archived description page:
    https://web.archive.org/web/20050415...sp?id=FormPair

    Direct link to archived zip file:
    https://web.archive.org/web/20051025...e/FormPair.zip

  9. #9

  10. #10
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: 2 forms moving together

    Quote Originally Posted by k_zeon View Post
    heres the link but the download does not work

    https://classicvb.net/samples/FormPair/
    yes,thats why i asked about links.i was looking for the best way to keep two forms together, I found this link, and of course it was broken, it was downloaded in post 8.



    [ ... active on skype and discord ... ] ,[always strive to achieve your dreams] , [always try,dont stop,never say never]

  11. #11
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: 2 forms moving together

    Quote Originally Posted by The trick View Post
    You need to process WM_WINDOWPOSCHANGING:
    That we have multiple controls in a single project, in each of which windowproc is used, won't there be a problem?


    For example, Label Plus has used this mode and we want to add some controls similar to it or have our own separate coding, is there a class that can manage this mode in the best way?
    [ ... active on skype and discord ... ] ,[always strive to achieve your dreams] , [always try,dont stop,never say never]

  12. #12
    Hyperactive Member
    Join Date
    Nov 2011
    Posts
    498

    Re: 2 forms moving together

    Quote Originally Posted by Black_Storm View Post
    That we have multiple controls in a single project, in each of which windowproc is used, won't there be a problem?


    For example, Label Plus has used this mode and we want to add some controls similar to it or have our own separate coding, is there a class that can manage this mode in the best way?
    would be great if you could post a working example. tks

  13. #13
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: 2 forms moving together

    I asked a question and I think there is a class for this question, I don't have a lot of experience using this mode and I just want to know if this kind of problem might work better with a professional or advanced class.


    Like you, I am waiting to see if there is a class example
    [ ... active on skype and discord ... ] ,[always strive to achieve your dreams] , [always try,dont stop,never say never]

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