|
did u call AfxSocketInit?
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
yes, I called AfxSocketInit()
the problem is why CSocket works ok,but CAsyncSocket not?
thanks
|
|
|
|
|
GetLastError() will tell ya
|
|
|
|
|
thanks for your reply,
the error code is 10035
but i want to know what's the difference between CAsyncSocket and CSocket.
can you plz told me about that?
many many thanks
|
|
|
|
|
CSocket does work blocking (with background processing of Windows messages), CAsyncSocket does not block. That's why you get error 10035 "A non-blocking socket operation could not be completed immediately".
You should read example code to study CAsnycSocket's concept. In your case you would override OnConnect() handler.
|
|
|
|
|
Many thanks dear Moak , thanks for your kind advice,
and now the problem is gone.
|
|
|
|
|
Many thanks dear Moak , thanks for your kind advice,
and now the problem has gone.
but i am still not very clear why CSocket could do that?
Is not CSocket some kind of async socket?
|
|
|
|
|
I wrote a MFC ActiveX control and i want to define some mnemonic keys for it, but my OnGetControlInfo implementation doesn't get called by the Test Container.
Do you know why?
rechi
|
|
|
|
|
hi,
I want to make an program that reads the content of a listbox from a different source. The reason is, if there are a 1000 records requested over a network it only has to load the records that are shown. Causing that the user doesn't have to wait for the downloading of all the 1000 records.
the way i'm doing it now is by filling the listbox with empty records:
<br />
for (int i = 0; (!(i > Db.GetCount())); i++)<br />
{<br />
m_MyListBox.InsertString(i, "");<br />
}<br />
Then, Wenn the user wants to see a different part of the listbox i update the data:
<br />
int cur, max;<br />
<br />
cur = m_MyListBox.GetScrollPos(SB_VERT);<br />
max = Db.GetCount();<br />
<br />
if (!(cur + 5 > max))<br />
{<br />
max = cur + 5;<br />
}<br />
<br />
for (int i = cur; (!(i > max)); i++)<br />
{<br />
m_MyListBox.DeleteString(i);<br />
m_MyListBox.InsertString(i, Db.GetItem(i));<br />
}<br />
Now, I want to run this function wenn the Scrollbar is moved, but i dont know witch message to catch. Anyone have the solution?
I hope my explaining of the problem is correct, my english isn't that great...
[]D [] []D []
|
|
|
|
|
Consider LVN_BEGINSCROLL and LVN_ENDSCROLL.
Kuphryn
|
|
|
|
|
Hi,
I have set up a global windows hook for WH_GETMESSAGE and it works. I receive messages for each thread. But I dont seem to be getting WM_NOTIFY message for some reason.
I then tried using WH_CALLWNDPROC which works. I see WM_NOTIFY messages. The problem with CALLWNDPROC is that you cannot change the messages but WH_GETMESSAGE can.
Does anybody know a way I can make WH_GETMESSAGE see WM_NOTIFY messages.
Thanks
Ceri
|
|
|
|
|
How to get individual objects stored in CObArray object after
calling serialize function for deserialization.(A novice)
LoVe FoR aLL HaTrEd FoR NoNe
|
|
|
|
|
loop on the size (int GetSize( ) const;) and use CObject* GetAt( int nIndex ) const;
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
I have fallen across the problem .In the SDI with splittered-window program,my custom classes derived from CPropertyViewPage can not switch each other.
thanks for your help!
;P
CProperView CProperViewPage
|
|
|
|
|
Hi there,
this is not such a very concrete question, but anyway:
How do you make software with different language support??
I mean, when you have to make your output present in different languages like french, english, german... (not chinese or sth.)
I'm currently using different resources and stringtables, but it's like, um, circuitous, err, like a lot of work, especially when you have to do it afterwards...
So, how do you do it ?
Thanx!
Olli!
Olli
Make it idiot proof and someone will make a better idiot......
|
|
|
|
|
|
Thank you Roger, think this helps...
Olli
Make it idiot proof and someone will make a better idiot......
|
|
|
|
|
If you look under the books in the Visual C++ MSDN Library you will find "Developing International Software for Windows 95 and WinNT" and you may be happy to know that Microsoft press had planed releas a newer edition of this book some time this year.
Thanks for reminding me I am off to see if it has been released yet, so I can order it.
Trust in the code Luke. Yea right!
|
|
|
|
|
Thank you John. Think it will help.
Olli
Make it idiot proof and someone will make a better idiot......
|
|
|
|
|
dear all,
i've written a small piece of code ( a hidden window) which detects windows shutdown and then logs the timestamp in a file. i'm using the following code in the message loop-
while(GetMessage(&Msg, hwnd, 0, 0) > 0)
{
if (flg_shutdown == 1)
{
flg_shutdown = 0;
Run(); //logs time stamp in a file
ShutDown(); // shutsdown the system using ExitWindowsEx(...)
}
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
now my wm_queryendsession handler is as follows
case WM_QUERYENDSESSION:
{
if (lParam & ENDSESSION_LOGOFF)
flg_type = 1; //logoff
else
flg_type = 2; //shut down
flg_shutdown = 1;
return false; // don't shutdown now. shutdown after Run() is executed
}
break;
the problem is that when i logoff/shutdown nothing happens until i do something with the window (move cursor over it or click on it or resize it).
when i do so, everything works fine.
what could be the problem. i even tried the following message loop
while(GetMessage(&Msg, hwnd, 0, 0) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
if (flg_shutdown == 1)
{
flg_shutdown = 0;
Run(); //logs time stamp in a file
ShutDown(); // shutsdown the system using ExitWindowsEx(...)
}
}
but same problem.
can someone help me out.
Thanx and Regards
|
|
|
|
|
WM_QUERYENDSESSION is sent which means that it is not seen by the message loop. The code in the message loop will be executed the next time a message is posted to your window.
Maybe you should move your code to the message handler.
regards Oliver
|
|
|
|
|
thanx for ur concern.
i am executing the code when wm_queryendsession returns 0 (i.e. logoff or shutdown is aborted)
if i try to run the code (starting an application for file write operation) in the messagehandler itself, i cannot execute the application because windows is shutting down.
i also tried to send a message(wm_lbuttonup) in the loop, but still i can't make it work
|
|
|
|
|
The problem is that the message loop does not get called when a message is sent to your handler. If you cannot perform your task in the message handler you have to make sure that the message loop is triggered without any user interaction.
Maybe you coud post a message to your window, e.g.
PostMessage(hYourWindow, WM_NULL, NULL, NULL);
This will trigger the message loop some time after your handler has finished.
regards Oliver
|
|
|
|
|
I have a MFC (server) application that works with sockets.
It should do the following:
1. Waits for an incomming client connection request (only 1).
2. Accept that connection request.
3. Send something to the client.
4. Receive something from the client.
5. Close the accepted connection.
6. ... go to 1. (wait for incomming client connection request)
Only 1 client can send something to the server.
So, I tried to imeplement it like this:
WSAStartup(...);
server = socket(...);
bind(server, ...);
listen(server, ...);
client = accept(server, ...);
send(client, ...);
recv(client, ...);
closesocket(client);
...
So... my question!
This code runs in a own thread and should never ends (only when the user terminates the app).
After ther closesocket(client); when I want to re-listen to some incomming
connection request, have I to call only client = accept(server,...); or
listen(server,...); client = accept(server,...); ?
What's the wright way:
WSAStartup(...);
server = socket(...);
bind(server, ...);
place <code>while (TRUE) {</code> here ???
listen(server, ...);
or place <code>while (TRUE) {</code> here ???
client = accept(server, ...);
send(client, ...);
recv(client, ...);
closesocket(client);
<code>}
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
The second place, between listen and accept .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|