Hi, hope you can help...
using tcpip, but would love to know how to use the call backs in fire fly so i can have add in callbacks for the accepting sending and recv of tcpip connections
Hi,
I don't know much about tcp/ip (maybe Roger can answer your specific questions better than me). However, anything that you can do in a regular PowerBASIC application, you can also do in FireFly. For example, you can handle ALL messages directly through the CUSTOM message handler for the FORM that you are working in. In the CUSTOM message you can set up a Select Case to deal with all of the individual messages separately (ie. WM_SIZE, WM_COMMAND, WM_NOTIFY, wtc...).
So, if you know what messages you want to intercept then please post them here and we can help as best that we can.
well it might be a custom type thing all i know is on the help to use tcp ip you have to add some way to receve notifications
i may be babbling but heres the code i can use in ultra edit because i have hard coded the GUI...
%TCP_ACCEPT = %WM_USER + 4093
Host Addr "127.0.0.1" To ip&
Tcp Open Server Addr IP& Port 7 As #portnum
TCP NOTIFY #portnum, ACCEPT TO hDlg AS %TCP_ACCEPT
then in the callback ...
CALLBACK FUNCTION ShowDIALOG1Proc()
SELECT CASE CBMSG
case %TCP_ACCEPT
hEcho = FREEFILE
TCP ACCEPT portnum AS HECHO
TCP NOTIFY hEcho, RECV CLOSE TO hDlg AS %TCP_ECHO
CONTROL SET TEXT hdlg,%IDC_LABEL1, "CONNECTED"
i can recieve the interuppts
hope this makes sense
Paul
Yup, the custom is the way to go. Within it you can process every message. At first it only processed certain ones, but a while back for the very reason you are I talked him into moving the call and the way it is used so you can make your own case structure in it just as you most likely do in PB.
And of course changing:
CBCTL= LOWRD(wParam)
CBCTLMSG= HIWRD(wParam)
Maybe put your code before your callback in WM_CREATE or however you want to do it, I put %TCP_ACCEPT = %WM_USER + 4093 in the general section by itself outside functions, etc. Then in CUSTOM for your form:
SELECT CASE wMsg
CASE %TCP_ACCEPT
hEcho = FREEFILE
TCP ACCEPT portnum AS HECHO
TCP NOTIFY hEcho, RECV CLOSE TO hDlg AS %TCP_ECHO
FF_Control_SetText(HWND_FORM_LABEL1, "CONNECTED")
CASE Else
' Do whatever
END SELECT
slap me with the biggest wettest fish if im seeming stupid, but ..
are you saying not to use the firefly gui builder, i have to do it custom ?
ie build a form from code (and hide it) so i can use its call backs?
I don't think Roger is saying that at all - there's a CUSTOM message for all forms in FireFly, and it is called if none of the other messages handle the call.
If you look in the code editor window you will see the "normal" message is WM_COMMAND for a form. The dropdown combobox on the top right has a CUSTOM message at the bottom. Select that and you should be in business.
Andrew
I had a cunning idea that might be the case,
so no need to create another hidden form for handling the callbacks just use the custom,
i didnt realise that all custom code would be executed if non of the code can handle it.
SORRY TO HARP ON..
but i cant seem to make it work :-(
tell me can i have these call back messages if this is the client?
and lastly where do i pass the notify message to???
Tcp Notify #portnum, Recv To "this here" As %TCP_ECHO
as hWndControl or any simular i cant get it working
thnanks Paul;.
I'd have to see more code than just a message loop processor to see what everything is doing, but at some point you need to Send something to the server to get a reply back if this is a client. And then you process the reply in the message you setup Notify to send to.
"this here" = the HWND of your form/window.
thanks for replying you must be a patient man
ok... summery of what i have been ttrying to do
%TCP_ECHO =%WM_USER + 4095
'say on form create or or a button to connect....
portnum = FreeFile
Tcp Open Port 7 At "127.0.0.1" As #portnum
Tcp Notify #portnum, Recv To hWndForm As %TCP_ECHO
'then the custom call backs chatted about earilier
Function FORM1_CUSTOM ( _
hWndForm As Dword, _ ' handle of Form
wMsg As Long, _ ' type of message
wParam As Dword, _ ' first message parameter
lParam As Long _ ' second message parameter
) As Long
If wMsg = %TCP_ECHO Then
MsgBox "Celebrate the thing works"
tcp recv, 1024, buffer
end if
End Function
so why doesnt it work am i mising something,? i have tryed compaing the wparam and the lparam to check to see if these are the callbacks i should be checking. or is it when i try and add the callback to my form ? i havnt changed the name of my form so should be default form1?
Port 7 is an Echo port number. Never really used it, but if I were to guess
it echos back what you send it. Or, if it is your own server for something then either way you most likely still need to send it something unless just opening the port tells the server to reply with something.