|
You could do something like the following...
class CFtpClass
{
....
public:
class CNotifyClass
{
public:
BOOL TellMeSomethingIDontKnow (DWORD dwFwibble) = 0;
};
BOOL RegisterNotification (CFtpClass::CNotifyClass *pNotify);
BOOL UnRegisterNotification (CFtpClass::CNotifyClass *pNotify);
....
};
class CMyDialog : public CDialog, CFtpClass::CNotifyClass
{
....
BOOL TellMeSomethingIDontKnow (DWORD dwFwibble);
}
BOOL CMyDialog::CMyDialog (....)
{
....
m_pFtp->RegisterNotification (this);
....
}
This may look suspiciously like INotifySink, for a good reason.
Or just have the Ftp class have a function to which you send a HWND of a dialog, and a message to
post when relevant. This means the dialog can go up in puff of smoke without risking crashing the
FTP class.
Did this help?
Iain.
|
|
|
|
|
YES !!!
Im gonna try something like this now.
Many thanks Iain.
|
|
|
|
|
Ian thanks again.
All works fine if i do it that way in a single thread.
But if i try run it in a thread started by AfxBeginThread the virtual function that is overloaded in the dialog class causes an execption tying to call UpdateDate(FALSE) to update the dialog class.
Any ideas ?
TIA.
|
|
|
|
|
HI
Folks i want to ask about setting Focus on a dialog box.
suppose i have set focus priority of dialog as follows
prority # 1 = combo 1
prority # 2 = combo 2
prority # 3 = button 1
prority # 4 = ok button
what i want is to
"setFocus to combo 1 when i press button 1"
on the form. i have tried setFocus() but it does not work.
Tell me how to do it ?
Thanx in Advance
|
|
|
|
|
Show us the code in the BN_CLICKED handler for "button 1."
jinbabaj wrote:
i have tried setFocus() but it does not work.
What is the return value?
|
|
|
|
|
in the press handle function of the button 1 you have to put code like this:
SetFocus( GetDlgItem( hDlg, IDC_COMBO1 ) );
Don't try it, just do it!
|
|
|
|
|
You can have problems calling SetFocus() when you click on button or some other control is getting focus. The way to resolve this is to use pTargetControl->PostMessage( WM_SETFOCUS, ... ).
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Anyone have any experience with printing Gdiplus::Image bitmaps? I can print ellipses and other objects no problem, but when it comes to printing bitmaps, they come out approx 10 times too big.
I'm using a Graphics.SetTransform() call to try to coax them to the correct size, but it is always off when printed, but correct in the view or in print preview.
Any help would be muchly appreciated.
Thanks,
swine
[b]yte your digital photos with [ae]phid [p]hotokeeper - www.aephid.com.
|
|
|
|
|
Looking for a VC++ source code to create a Client & Server using TCP protocol (Microsoft Winsock).
If I want to know the socket state in VB, I just gonna use a timer and look at the winsock.state.
This is an exemple in VB6 with winsock
[code]
Private Sub Timer1_Timer()
If Winsock1.State = sckClosed Then
Winsock1.Connect 'Connect to the host
ElseIf Winsock1.State = sckConnected Then
Winsock1.SendData Time ' Send the current time
ElseIf Winsock1.State = sckClosing Then
Winsock1.Close ' Close the connection
End If
End Sub
[/code]
Now someone told me in VC++ you can only know the state of your socket after transmitting.I mean to know if the socket is closed you need to transmit a packet.
I would like to verify the socket state in VC++ without to transmit any data.It is possible ?
Anyway I'm looking after some good source code to start my investigation.
Johnny
|
|
|
|
|
>> to know if the socket is closed you need to transmit a packet.
I think even a recv() will return an error which can indicate the socket is closed.
>> I'm looking after some good source code to start my investigation.
www.sockets.com
"No matter where you go, there your are..." - Buckaoo Banzi
-pete
|
|
|
|
|
you may try recv with buffer len 0, dunno if this doesnt cause an error, but just try it!
Don't try it, just do it!
|
|
|
|
|
1) The program are not listening and receving.
2) If the socket is closed the program should try to reconnect to the host every sec until the connection is open.
3) Mutiply this program by 1000 trying to reconnect to the host.
I don't want to have 1000 program sending a packet every sec to verify if the connection is close or open.What wrong with VC++ ?
In VB you can do
if winsock.state = closed then
'winsock.connect
endif
I don't need to do
// Check if the connection is still open
if (Send ( Msg) < 0)
{
//If socket closed then connect to the host
connect;
}
Against this is only about sending (Not listening and receving).
|
|
|
|
|
nothing is wrong with vc++, im sure vb makes it in a similar way... and recv with packet size 0 shouldnt send anything!
Don't try it, just do it!
|
|
|
|
|
Alexander ,
If I'm following what you said. You mean
when the server is closing the socket , the client is receiving an empty packet.So the function recv will return a code saying that we just got disconnected.
Going to be something like this on the client side
Error = Recv (Msg)
if (error == Disconnected )
{
// Start the pool every sec to request a connection to
// the server
}
|
|
|
|
|
Almost. recv() will return like Zero or maybe -1, can't remember. Then you use WSAGetLastError() to get the error number.
"No matter where you go, there your are..." - Buckaoo Banzi
-pete
|
|
|
|
|
palbano wrote:
www.sockets.com
Sadly, none of the links to download examples are live.
Steve S
|
|
|
|
|
Wow, your right! I sent an email. Hopefully it is temporary. That site has been around since 1995 or so. It would be a shame if it disolved.
"No matter where you go, there your are..." - Buckaoo Banzi
-pete
|
|
|
|
|
This is exactly what i was looking for
int socket = -1;
//****************************************************************
// ManageSocket
// Call this function every sec
//****************************************************************
void ManageSocket ()
{
fd_set ready;
struct timeval to;
//Check if the connection is active
if (socket > 0 )
{
FD_ZERO(&ready);
FD_SET(socket, &ready);
to.tv_sec = 0;
to.tv_usec = 1;
select(socket + 1, &ready, 0, 0, &to)
if (FD_ISSET(sock, &ready)) //If socket ready
{
//Packet with a size of zero = Connection closed
if ( recv ( sock , buf , 1024 , 0) == 0)
{
//Closing the socket
close(socket);
socket = -1;
}
}
}
// When Connection is inactive client will try to reconnect every sec
else if (Socket < 0)
{
//Reconnect to the host
}
}
|
|
|
|
|
Hi,
I would like to know how to get a pointer to my CView class from CMainFrame class?
Ehsan Behboudi
|
|
|
|
|
See CFrameWnd::GetActiveView().
Cheers,
swine
[b]yte your digital photos with [ae]phid [p]hotokeeper - www.aephid.com.
|
|
|
|
|
i used it and i got an wierd error,
I had to include my CView header file, in my case it is:
#include "CMotionControllerView.h"
and i got 3 error all had to do with the GetDocument() in CView class !!!!!
Ehsan Behboudi
|
|
|
|
|
You'll probably need to forward declare your CDocument derived class in the CMotionControllerView.h file.
Michael
'War is at best barbarism...Its glory is all moonshine. It is only those who have neither fired a shot nor heard the shrieks and groans of the wounded who cry aloud for blood, more vengeance, more desolation. War is hell.' - General William Sherman, 1879
|
|
|
|
|
ok well that doesn't tell me much... you need to be more descriptive if you want help. what exact errors, etc?
perhaps you didn't do the casting correctly...?
[b]yte your digital photos with [ae]phid [p]hotokeeper - www.aephid.com.
|
|
|
|
|
CFrameWnd::GetActiveView() ?
~RaGE();
|
|
|
|
|
It's all in msdn
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|