|
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.
|
|
|
|
|
Using Visual Studio 2002 and i can't find a "Callers Graph" view like the one that is in VC6. Am i a dope or did they leave it out?
-pete
|
|
|
|
|
it's not called "Callers Graph"!!!
it's called "Call Stack"!!!
have a look at the help files, maybe this term helps...
Don't try it, just do it!
|
|
|
|
|
Thanks Alexander, but it's not the same thing. In VC6 there was both a "Callers Graph" and a "Call Graph" that could be viewed starting from a function. They are not actually graphs but rather a tree control. It was part of the "Browser" functionality. Definitely not the "Call Stack" which is the current running context of course. Quite handy actually, it is very sad if it was left out of VC7 "Browser".
P.S. Are you always that easily exited? All those exclamation characters just seem to fly off your keyboard
"No matter where you go, there your are..." - Buckaoo Banzi
-pete
|
|
|
|
|
Hi all
I wrote a simple win32 dll (non MFC) and tried to invoke its functions using run-time Loading (LoadLibrary). When I call GetProcAddress() function it returns me always NULL.
I checked in Dependency Walker tool this dll add saw that in some reason to all exported symbols were added some gibrish. for instance: function Foo() is writen like this: ?Foo@@YAHHH@Z. So when i give GetProcAddress() function name it never finds it
strange...
Have any ideas why? and how can i sole this?
b.w.: I'm using VC6 and win XP
thanks.
|
|
|
|