Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A few VB6 questions
#1
I'm working on a mini p2p chat thingy. It works pretty much except I have a few questions:

1. How would I have the toolbar flash when a new msg comes?
2. How would I have it so the textbox is at the bottom when I send/recieve a msg?
3. How would I have it get through a port without opening it through the router settings? Like how does MSN and AIM do it if all the ports on my router are closed?

thanks >^-^<
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#2
1. There's an API call for that called FlashWindow (I believe that's what it's called). Look on planetsourcecode for an example of it working.
2. Not quite sure what you mean by this...care to rephrase?
3. From what I've read in various router manuals...programs like MSN seem to open and close ports automatically on routers because of some protocol. I have no idea how it works or if that's even the way it works. Might wanna google that one, or wait for Plasma to answer it. Big Grin
I'd knock on wood, but my desk is particle board.
Reply
#3
2. When I recieve a message it adds it to a textbox. But this textbox is always at the top when it recieves the new ones. (Meaning that when I receive a message I have to use the scroll bar to go down and see it.)
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#4
Oh, I see what you mean...well, I haven't used VB6 in awhile but I think I remember how something like that can be done...it's not too difficult and you can do it with one line of code. I think it goes a little like this...

Code:
Text1.StartPos = Len(Text1.Text)
or something along those lines...I don't have a copy of VB6 installed on this machine to check it out...but that should be pretty close, if not completely correct...
I'd knock on wood, but my desk is particle board.
Reply
#5
Cool I found it. It is text.SelStart


Ok 3 more questions
1. How do I have it so when I press enter it submits the message?
2. I found the flash thingy but I can only get it to work when the other is minimized not lostfocus.
3. Still need help with opening the port thing
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#6
To answer question 1:

I dont know much VB6, but in QBasic it would look like

Code:
press$ = INKEY$
IF press$ = CHR$(13) THEN GOTO sendinfo 'chr$ 13 is the enter button


sendinfo:
'the function that sends the info will go here

Hope this helps.
quote="na_th_an"]
Greenday, Spice Girls... Can you tell the difference?
[/quote]
Reply
#7
what a coincidence =P. I am developing a java based chat program Big Grin
Reply
#8
Quote:1. How do I have it so when I press enter it submits the message?
2. I found the flash thingy but I can only get it to work when the other is minimized not lostfocus.
3. Still need help with opening the port thing
1. You can use the KeyPress event on the textbox.
2. Eh?
3. I still don't know either. Big Grin
I'd knock on wood, but my desk is particle board.
Reply
#9
2. I think it's only used for when the window is minimized, at least my WinAmp and MSN and Trillian only flash on the toolbar when minimized.

3. You could ask Microsoft (Peer to peer is in Networking and Directory Services -> Network Communication).
Reply
#10
Oh, when I looked into the remains of my old P2P program I made ages ago, I realized you should use WinSock or similar.

WinSock can handle TCP and UDP. Here's an example of using TCP (Client/Server sided).

On the server:
[syntax="vb"]
'you have a control named server (WinSock control)

Private Sub Form_Load ()
server.LocalPort = 1001
server.Listen
frmClient.Show
End Sub

Private Sub server_ConnectionRequest (ByVal requestID As Long)
If server.State <> sckClosed Then server.Close
server.Accept requestID
End Sub

Private Sub server_DataArrival (Byval BytesTotal As Long)
server.GetData yourstring$ '<-----------
End Sub

'to send data: server.SendData yourstring$
[/syntax]

Now for the client:
[syntax="vb"]
'you have a WinSock control named client

Private Sub Form_Load ()
client.RemoteHost = "RemoteComputerNameOrIP"
client.RemovePort = 1001
End Sub

Private Sub cmdConnectNow_Click ()
client.Connect
End Sub

Private Sub client_DataArrival (ByVal BytesTotal As Long)
client.GetData yourstring$
End Sub

'to send data: client.SendData yourstring$
[/syntax]

You can also do this with multiple connections, in the example only one connection on the server is allowed.

For more info about WinSock or UDP, I refer you to the Microsft MSDN Library.

Hope it helped a bit Wink
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)