Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Make a form 'Follow' another


crackmunky
 Share

Recommended Posts

Heya guys,

              I made a seperate form for my chat window and made it transparent, Ive set it so by default it is allways ontop of the frmMirage but nothing else. I want it to be able to follow the frmMirage if it is moved, i tried this -

```
    TxtChatForm.Left = frmMirage.Left
    TxtChatForm.Top = frmMirage.Top
TxtChatForm.Hide
TxtChatForm.Show
```
to no avail, here is an image of what it looks like right now -

[![](http://img4.imageshack.us/img4/9316/errorwxb.jpg)](http://img4.imageshack.us/my.php?image=errorwxb.jpg)

So to say again I want to get it to FOLLOW frmMirage. Any help is appreciated.
Link to comment
Share on other sites

@V-Rage:

> use the game loop

Ahh thankyou for that one, I saw that I placed it slightly above the main loop.
```
    If ChatX = 0 Then ChatX = frmMirage.Top
    If ChatY = 0 Then ChatY = frmMirage.Left

    If Not frmMirage.Left = ChatX Then
            TxtChatForm.Left = frmMirage.Left
            ChatX = 0
            End If

    If Not frmMirage.Top = ChatY Then
            TxtChatForm.Top = frmMirage.Top
            ChatY = 0
            End If
```
Im very new to VB but I just wrote the above peice of code and it seems to be working.
Link to comment
Share on other sites

Glad to see you learnt some logical negation from me, but it shouldn't be used in this context.

Make a new sub and call it in your GameLoop, preferebly within a 25 tick timer.

```
If (frmCredits.Left = frmMainMenu.Left) And (frmCredits.Top = frmMainMenu.Top) Then Exit Sub
frmCredits.Left = frmMainMenu.Left
frmCredits.Top = frmMainMenu.Top
```
Re-name frmCredits to your chat form, obviously. And frmMainMenu to frmMirage.
Link to comment
Share on other sites

@Robin:

> Glad to see you learnt some logical negation from me, but it shouldn't be used in this context.
>
> Make a new sub and call it in your GameLoop, preferebly within a 25 tick timer.
>
> ```
> If (frmCredits.Left = frmMainMenu.Left) And (frmCredits.Top = frmMainMenu.Top) Then Exit Sub
> frmCredits.Left = frmMainMenu.Left
> frmCredits.Top = frmMainMenu.Top
> ```
> Re-name frmCredits to your chat form, obviously. And frmMainMenu to frmMirage.

Ahh I see, the method you used is much more efficent. Thankyou for that, slowly learning.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...