dcsimg
Results 1 to 27 of 27

Thread: How join 2 forms and move together like winamp?

  1. #1

    Thread Starter
    Member engowen's Avatar
    Join Date
    Feb 2001
    Posts
    41

    Question

    Hi, I managed to join 2 forms side by side, but 1 Form object do not have move event. So, when i move my from around, the other form won't move along.

    Any idea? Thanks.

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,092
    This question has been asked at least 680 billion times...Just do a search on "winamp", or "docking forms"
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3

    Thread Starter
    Member engowen's Avatar
    Join Date
    Feb 2001
    Posts
    41

    thx

    sorry, i'm just a newcomer

  4. #4
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,092
    eh, I didn't mean it as being nasty or whatever, actually ,I just didn't feel like typing it out...
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  5. #5
    Guest

    Past Posts

    Shouldn't there be a list of the most asked questions then instead of doing a search



    Just a thought

  6. #6
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,092

    I dunno...

    I just live here, I didn't build the place...
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  7. #7

    Thread Starter
    Member engowen's Avatar
    Join Date
    Feb 2001
    Posts
    41

    NO problem

    I think this kinda popular topic, which already an answer for it should be an article for it.

  8. #8
    Guest
    Top 100 posts List would do

  9. #9
    Addicted Member substring's Avatar
    Join Date
    Feb 2001
    Posts
    148

    Smile

    engowen,

    If I understand your question correctly, you can calculate the bottom of form 1 and set that as the top of form 2, assuming you want form 2 to stay below form 1.

    Hope this helps.

    substring.

  10. #10

    Thread Starter
    Member engowen's Avatar
    Join Date
    Feb 2001
    Posts
    41

    Thumbs down i think it is impossible...

    substring: your answer is ok when loading/showing a form. But it didn't move along form2 when i moved form1.

    i studied the sample mciplayer downloaded from vbaccelerator and damn, there are no title bar involve there. it rely on mouse_down event click on the form/image.

    event on title bar for each form cannot be trapped, therefore i can't use that Mouse_Move method. Of course, I can have an artificial title bar, which mean an image that look likes the titlebar in order to trap mouse down and subsequently move 2 forms. Dun think I like that idea.

    Another way is to use a timer to updated the position. But, that is not a friendly way.

    Some of the samples are on MDI form, but that's not what i want.

    Why isn't there any Move event for form?

    Any one had done this before?

  11. #11
    Hyperactive Member dsy5's Avatar
    Join Date
    Jul 2000
    Location
    Lockport, NY
    Posts
    362
    I believe Kedamen has some code on his web site. See this link.
    Donald Sy - VB (ab)user

  12. #12

    Thread Starter
    Member engowen's Avatar
    Join Date
    Feb 2001
    Posts
    41
    dsy5: The link not working

  13. #13
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    look at my signature
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  14. #14
    Addicted Member g.mie's Avatar
    Join Date
    Jan 2001
    Location
    EarTh
    Posts
    134

    Angry DON'T SAY LIKE THAT

    don't say like that,crptcblade. engowenis new here. engowen come in here to learn. just teach him/her. if u don't know the answer or don't want to answer, just shutdown your mouth.

    tq

  15. #15
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,092

    Cool Okay, okay...

    Calm yourself g.mie...I didn't mean to sound like anything, nor did I mean to say that engowen meant to sound like anything, I was just suggesting that he/she try to search for the code. That's all, no harm intended, but if some was caused...I apologize.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  16. #16

    Thread Starter
    Member engowen's Avatar
    Join Date
    Feb 2001
    Posts
    41

    Thumbs down

    g.mie: is alright. i should live by the rules. i understand how annoying posting the same question that ppl around the forum tried to answer b4.

    kedaman: thx for the link. u'd a great job sample there. However, still can't accomplish what i want. i realized titlebar/controlbox cannot be trapped, that's my problem.

  17. #17
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Might be done if you subclass the form for WM_MOVE instead, i didn't bother with that since i made this especially to simulate winamp docking..
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  18. #18

    Thread Starter
    Member engowen's Avatar
    Join Date
    Feb 2001
    Posts
    41

    Angry

    that's a way, use Form_Paint, depending on how dirty the form is.

  19. #19
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Form_Paint won't fire on movement, except if you move it so that parts of it become visible
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  20. #20
    Addicted Member g.mie's Avatar
    Join Date
    Jan 2001
    Location
    EarTh
    Posts
    134

    :)

    crptcblade:

    apologize accepted

    i'm sorry too

  21. #21
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,092

    cool

    we don't have to make out or anything now do we??
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  22. #22

    Thread Starter
    Member engowen's Avatar
    Join Date
    Feb 2001
    Posts
    41

    Thumbs up Guys, I'd it

    Code for you as reference. Code modified from Megatron, using WM_MOVE



    '***Code for Module ***

    'for some reason, SecondForm.Visible won't work in this module, so replace with SecondFormShow


    'Declaration for WindProc (5-FEB-01)
    Public FirstForm As Form
    Public SecondForm As Form
    Public FirstFormOnLeft As Boolean
    Public SecondFormShow As Boolean

    Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    Declare Function SetWindowLong& Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long)
    Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Const GWL_WNDPROC = (-4)
    Const WM_MOVE = &H3
    Const WM_EXITSIZEMOVE = &H232

    Global WndProcOld As Long
    'End Declaration

    Public Sub Show2Forms()
    If FirstFormOnLeft Then
    SecondForm.Left = FirstForm.Left + FirstForm.Width
    SecondForm.Top = FirstForm.Top
    Else
    SecondForm.Left = FirstForm.Left - SecondForm.Width
    SecondForm.Top = FirstForm.Top
    End If
    End Sub


    Public Function WindProc(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Dim Result
    'If wMsg = WM_MOVE And SecondForm.Visible Then
    If wMsg = WM_MOVE And SecondFormShow Then
    Show2Forms
    End If
    WindProc = CallWindowProc(WndProcOld&, hwnd&, wMsg&, wParam&, lParam&)
    End Function

    Sub SubClassWnd(hwnd As Long)
    WndProcOld& = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf WindProc)
    End Sub

    Sub UnSubclassWnd(hwnd As Long)
    SetWindowLong hwnd, GWL_WNDPROC, WndProcOld&
    WndProcOld& = 0
    End Sub




    '*** COde for Form1 ***

    Private Sub Form_Activate()
    Set FirstForm = Me
    Set SecondForm = form2
    FirstFormOnLeft = True
    End Sub

    Private Sub Form_Load()
    Set FirstForm = Me
    Set SecondForm = form2
    FirstFormOnLeft = True
    ' SecondFormShow = False
    SubClassWnd Me.hwnd
    End Sub

    Private Sub Form_Resize()
    If form2.Visible Then
    form2.Left = Me.Left
    form2.Top = Me.Top
    End If
    End Sub

    Private Sub Form_Unload(Cancel As Integer)
    If form2.Visible Then
    Unload form2
    End If
    UnSubclassWnd Me.hwnd
    End Sub


    '*** Code for Form2 ***


    Private Sub Form_Activate()
    Set FirstForm = Me
    Set SecondForm = Form1
    FirstFormOnLeft = False
    End Sub

    Private Sub Form_Load()
    Set FirstForm = Me
    Set SecondForm = Form1
    FirstFormOnLeft = False
    SubClassWnd Me.hwnd
    End Sub



    That's all. Hey, where is my indention? Hope u won't mind.

  23. #23
    Hyperactive Member theman32x's Avatar
    Join Date
    May 2000
    Location
    New Jersey, USA
    Posts
    305
    someone put this code:

    Private Sub Form_Load()
    Form2.Show
    End Sub

    Private Sub Timer1_Timer()
    Form2.Left = Form1.Left + Form1.Width
    Form2.Top = Form1.Top
    End Sub

    the timer should be set to a small interval so it keeps up with the movement of form1

  24. #24

    Thread Starter
    Member engowen's Avatar
    Join Date
    Feb 2001
    Posts
    41
    theman32x: Using Timer is definately not an option. In order to change Form2's position as realtime, the interval of the Timer must be 1 second below. But, if your ultimate goal for the project is NOT just a simple sample of showing how to join 2 form, then this cannot be use.

    As for correction:
    **************
    Private Sub Form_Load()
    Set FirstForm = Me
    Set SecondForm = form2
    FirstFormOnLeft = True
    ' SecondFormShow = False
    SubClassWnd Me.hwnd
    End Sub
    ***************

    Take out ' from SecondFormShow = False
    It take a baby step for you to be here, nothing is impossible.

    v(^o^)v

  25. #25
    Hyperactive Member dsy5's Avatar
    Join Date
    Jul 2000
    Location
    Lockport, NY
    Posts
    362
    Sorry about the link Kedaman, et al ... I spelled it wrong. Guess you shouldn't
    have taken the postscript that said 'don't spell my name wrong' off your posts!
    Donald Sy - VB (ab)user

  26. #26
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    Engowen, with some tags you can make your code look nice.

    [code]
    Dim X As Integer
    'Code goes here
    [/code]

    Will appear as:
    Code:
    Dim X As Integer
    'Code goes here
    Have fun!
    Oetje
    oetje@home.nl
    93606776
    Visual Basic 6, Windows 2000

    Never pet a burning dog

  27. #27
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    I guess i have to put it back then
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width