 |
 |

01-23-2004, 01:40 PM
|
|
Centurion
|
|
Join Date: Jan 2004
Posts: 106
|
|
calling window problem...! Help!
|
hey, i am creating a chat program, and i have programmed my program so that when you double click on an online user, it while on an im window by setting IMWindow1 = new IMWindow so it will open multiple times with the same form, now this is working fine, but when the user recieves a message i cannot find a way to direct the incoming message to the text box located on the right im window. I have also created a form that contains a listbox and everytime an im is opened or closed it is added or removed from the list, this is for me the be able to make my program keep track of the imwindows and not open multiples of the same users.
the code for when the user opens an im to a person themselves is...
Code:
Private Sub tContacts_DblClick()
Dim sContact As Integer
Dim IMWindow1 As IMWindow
Dim i As Integer
sContact = tContacts.SelectedItem.Index
For i = 0 To CurrentIMWindows.List.ListCount - 1
If CurrentIMWindows.List.List(i) = tContacts.Nodes.Item(sContact) Then
Exit Sub
End If
Next i
Set IMWindow1 = New IMWindow
CurrentIMWindows.List.AddItem (tContacts.Nodes.Item(sContact))
IMWindow1.Visible = True
IMWindow1.Caption = tContacts.Nodes.Item(sContact)
IMWindow1.Contact.Caption = tContacts.Nodes.Item(sContact)
End Sub
so... what i need to be able to do is use the following code when text is recieved and make it react like...
Code:
Dim i As Integer
Dim strSourceUser As String
strSourceUser = strIncomingUser.Text
For i = 0 To CurrentIMWindows.List.ListCount - 1
If CurrentIMWindows.List.List(i) = strSourceUser Then
'Here is where i need the code to say
'(IMWindow1 Matching Criteria).Visible = true
'(IMWindow1 Matching Criteria).txtMsgLog.Text = (IMWindow1 Matching Criteria).txtMsgLog & ": " & strMessage
End If
Next i
...thats what i need, and i know some one can do it cause i've asked some questions i thought were impossible and then someone gives a really simple peice of code that i knew but didn't think about, so thanks in advance for your help!
|
|

01-23-2004, 01:47 PM
|
 |
MetaCenturion
Retired Moderator * Guru *
|
|
Join Date: Aug 2001
Location: California, USA
Posts: 16,583
|
|
You'll probably want to make a Collection.
In this collection, you can store references to a form, and supply a key so that you can reference a form by a string property.
You can define the collection in a module...
then, when you want to make a new form.
Code:
Dim NewForm As IMWindowForm
Set NewForm = New IMWindowForm
IMCollection.Add NewForm, UserOnThisForm
'Then do what you want with the form
|
|

01-23-2004, 01:58 PM
|
|
Centurion
|
|
Join Date: Jan 2004
Posts: 106
|
|
Quote: Originally Posted by Iceplug You'll probably want to make a Collection.
In this collection, you can store references to a form, and supply a key so that you can reference a form by a string property.
You can define the collection in a module...
then, when you want to make a new form.
Code:
Dim NewForm As IMWindowForm
Set NewForm = New IMWindowForm
IMCollection.Add NewForm, UserOnThisForm
'Then do what you want with the form
hey, if i have Set IMWindow1 = New IMWindow already then what i'm asking is how can how can i address the newly opened form with out using IMWindow1.blah because that would effect all of the forms created as new imwindows wouldn't it? i can already identify which form has the incoming users name on it as the caption, but i need to be able to address it and change the text on it only, please give coding examples, they help me understand, thanks for your help.
|
|

01-23-2004, 02:15 PM
|
 |
MetaCenturion
Retired Moderator * Guru *
|
|
Join Date: Aug 2001
Location: California, USA
Posts: 16,583
|
|
Oh...
to access a window that you've added to the IMCollection, you'd do something like this...
Code:
Dim CurrentForm As IMWindowForm
Set CurrentForm = IMCollection(SomeUserName)
CurrentForm.ZOrder 0
'ZOrder just moves it to the front.
So, you can just change the properties on the form by using the CurrentForm variable
Also, if you use IMWindow1.blah, it should only affect that instance of IMWindow1.
If you used IMWindow, nothing happens since you are creating instances.
The only way to affect all of the forms would be with a loop. 
|
|

01-23-2004, 03:43 PM
|
|
Centurion
|
|
Join Date: Jan 2004
Posts: 106
|
|
Quote: Originally Posted by Iceplug Oh...
to access a window that you've added to the IMCollection, you'd do something like this...
Code:
Dim CurrentForm As IMWindowForm
Set CurrentForm = IMCollection(SomeUserName)
CurrentForm.ZOrder 0
'ZOrder just moves it to the front.
So, you can just change the properties on the form by using the CurrentForm variable
Also, if you use IMWindow1.blah, it should only affect that instance of IMWindow1.
If you used IMWindow, nothing happens since you are creating instances.
The only way to affect all of the forms would be with a loop. 
i have one morequestion, is there anyway that i can substitue the variable IMWindow1 with the users user name and then i could just tell it to for instance do this... (user name).setfocus
|
|

01-23-2004, 05:09 PM
|
|
Centurion
|
|
Join Date: Jan 2004
Posts: 106
|
|
help!
|
does that current form this only work with the form that is on top or what? cause if i have like 3 forms open that are IMWindow1 windows how will it work? i'm not understanding how to addthis to my code. thanks in advanced!
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|