|
Overriding PreTranslateMessage() is not the best way to do it. Read reply by Roger Stoltz, below.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
yeah. got to read that point, didn't know about this earlier
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Yeah. Didn't know about that fact earlier.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
See this[^] thread is helpfuls?
|
|
|
|
|
Y_Kaushik wrote: Problem is that when i press enter key or Press Esc Key form is closed.
Please any one told me How I avoid It.
Read this article[^] and look no further.
Why PreTranslateMessage() should be avoided can also be read in the article.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Handle OnCancel() if you dont want to close dialog and Comment CDialog::OnCancel because Enter and Esc cause OnCommand with ID as IDCANCEL.
|
|
|
|
|
Y_Kaushik wrote: Problem is that when i press enter key or Press Esc Key form is closed.
Please any one told me How I avoid It.
See here.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi,
I have a very strange problem concerning the sockets I use in my applications.
I have written a Server application which accepts client connections. Therefore I have created a listen socket. In the OnAccept event of that listen socket I accept the incoming connection by creating a new socket and calling its accept member. Nothing strange here and everything works well.
I'm also using ado to connect to a SQL database to write log-ins and the like. But in a single customer case the SQL server is placed on a different PC. This normally doesn't give me much trouble, but sometimes under heavy network load the database-connection to this PC is lost. In that case I close the connection and create a new one. To simulate this I have setup a test PC with SQL on and I remove this PC from the network, not my development PC. After the reconnect the PC, the connection is restored and the database can be used again
But now for the strange part. In some cases, 1 out of 5-6 test, I can't accept any new clients. Using the netstat command i can see that the port is still open. It even accept new incoming request (upto 5) but I never get in the OnAccept function so I can't accept new Clients. How come that even though the TPC-IP protocol of the machine sees the new incoming request I don't get notified any more.
Any help on this matter will be highly appreciated.
codito ergo sum
|
|
|
|
|
BadKarma wrote: I accept the incoming connection by creating a new socket and calling its accept member......In some cases, 1 out of 5-6 test, I can't accept any new clients
You call Accept() on the listening socket instance and provides a reference to the new socket as argument, right?
If not, that's what you should do. I don't know what happens if you do it the other way around.
A listening socket has a queue with pending connection requests. If I remember correctly the size of the queue is configurable by hacking registry values, but I think the default value is 5 and that's what puzzles me since you say that it's 1 out of 5-6 attempts that fails.
Are we dealing with multithreading issues here as well?
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Thanks for the response.
Roger Stoltz wrote: You call Accept() on the listening socket instance and provides a reference to the new socket as argument, right?
Yes, I do it like you mentioned.
CClientSocket* pNewSocket = new CClientSocket(this);
if(!pNewSocket)
{
WriteError(ecNotEnoughMemory, "cannot_create_new_socket", "AcceptNewClient");
return;
}
if(m_pListenSocket->Accept(*pNewSocket))
{
...
}
This code is called when I fall in the OnAccept from the Listen socket. The problem is that i don't fall in the function anymore. But if I check the Socket is still (with other tools) listening and even puts incoming request in the pending queue. And indeed after 5 clients trying to connect (they hang) the sixth client gets a connection refused.
Could it be that the message handling pump is 'broken'. And if so can i check for it in order to make a new listensocket?
Yes it's a multithreaded application (about 13 threads)
codito ergo sum
|
|
|
|
|
BadKarma wrote: Roger Stoltz wrote: You call Accept() on the listening socket instance and provides a reference to the new socket as argument, right?
Yes, I do it like you mentioned.
Ok. Just wanted to make sure since it could be interpreted the other way around.
BadKarma wrote: Could it be that the message handling pump is 'broken'.
What do you mean by "broken"?
Every thread that creates a socket has to be a UI-thread, i.e. it has got to have a message pump. This means you must have a CWinThread derivative where the socket is a member of the class.
If you create sockets in worker threads that don't have message pumps, Chaos and Mayhem will follow.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Roger Stoltz wrote: What do you mean by "broken"?
Every thread that creates a socket has to be a UI-thread, i.e. it has got to have a message pump. This means you must have a CWinThread derivative where the socket is a member of the class.
If you create sockets in worker threads that don't have message pumps, Chaos and Mayhem will follow.
Yep I have a CWinThread derived class CConnectionManager which creates a CListenSocket object.
CListenSocket has override the OnAccept function to accept an incoming Client. But doesn't the listen socket creates a dummy window so it can receive the message sent. Otherwise how would one make a difference between message for the thread and those for the listen socket.
I have checked and the thread message pump is still working. So maybe the Handle to identify the listen socket has gotten invalid. Is there a way to check if the listen socket can still receive mesagges.
I have another CWinthread derivative that also manages a Listen socken on another port and this keeps on working, sometimes . Sometimes all listen sockets keep on working, other times its only the Client Listen socket which fails, yet another time its the ohter listen socket which fails. And if i'm very lucky (NOT) both the listen sockets are being kidnapped by somekind of Gremlin. AArrgh !!
I'm getting crazy with this issue. I mean the network of another pc fails. Resulting in a database connection loss. But my listen socket go down
codito ergo sum
|
|
|
|
|
Hmm, at least you haven't made the most common mistakes.
More seriously though...
When I find myself in situations like yours, I try to revert to basics.
What happens if you create a mockup with only one thread...?
See if you find anything in this article[^] that might help you.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Can't recall that I have seen such a behaviour in my networking applications. I wonder if you can go single threaded (from your postings it sounds that you are using an event based socket class with multiple threads)?
/M
|
|
|
|
|
What I am thinking is NOT kid sister safe. In fact, I'm about to just throw the dang laptop right through the window...
I have an embedded VC++ 4.0 project. FWIW, evc++ is very, very close to VS6. Let's assume it is for the moment. I go into the bitmap editor to change a bitmap (you think?). I save the changes, pull back up the bitmap, no changes!!!!
Why? I have no error messages, it claims to have saved the file? What am I missing?
Charlie Gilley
Will program for food...
Whoever said children were cheaper by the dozen... lied.
Overheard in a cubicle: "A project is just a bug under development."
Seeking to rise above the intelligence of a one eared rabbit...
|
|
|
|
|
Have you tried to modify it from MSPaint??? I had some problems with a bitmap and I solved them from paint.
Another thing you can do is to open your bitmap, copy it and paste it to another bitmap resource, go to your resources folder, change name of the old bitmap, edit the new resource (the pasted one) and set the name to the old name (so you don't need to change code in your programm).
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
Hi all:
I have a dialog containing several edit boxes, the problem I'm facing is that the dialog doesn't repond to tak key, but the edit control itself can receive the key message. I've correctly set up the tab order.
|
|
|
|
|
Process IsDialogMessage API
|
|
|
|
|
Because you have controls on the forum and they get focus.
|
|
|
|
|
WhiteSky wrote: Because you have controls on the forum and they get focus.
Too much of CP?
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
hi,
i have an application which generates a signature for a file. the problem i am facing is when i run it, it gives the error :
User breakpoint called from code at 0X77fcb940
and in the output window i get the following error:
HEAP[UsageInstanceTool.exe]: Invalid Address specified to RtlFreeHeap( 3c0000, 818d58 )
I am testing the application in Release mode. There seems to be no problem in debug mode.
I have no idea what the problem is since i am new to VC++ programming.
waiting for help!
- Moonis
|
|
|
|
|
Moonis Ahmed wrote: HEAP[UsageInstanceTool.exe]: Invalid Address specified to RtlFreeHeap( 3c0000, 818d58 )
It seems like you're freeing an uninitialized pointer.
Always initialize pointers by assigning NULL at declaration. That way you'll be able to test whether the pointer is valid or not.
Also read this article[^].
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Hi,
This looks like a memory overrun, probably on a buffer somewhere. In Debug VC++ pads out every allocation of memory you make with some extra bytes which can be used to see if you've overun the end of an array somewhere. It should report this but it doesn't always especially if you leak, i.e. don't delete, the whole array. In Release these extra bytes are missing and the same overrun will damage real data or code and you may see different behaviour. This is all a bit general but I dont know what your code looks like;)
To be a bit more specific RTLFreeHeap is a built in Windows function that gets called when you call delete in your code. The 'Invalid Address' error means that it's trying to delete a pointer that was not the result of a new, could be uninitialised, or more often one that has already been deleted, or points at deleted memory. Check for duplicate delete calls and buffer overruns, remember if you're new to C++ that confusingly the lest element of int array[10]; is array[9] because the first element is array[0] .
The best way to pick up memory issues like this in a small app is to run only parts of it, e.g start up and shutdown code only initially and keep adding more small sections back in until the problem appears in Release. You'll soon spot it.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
I give the following advice about once a month; it often helps me track down the nastier heap errors:
Try enabling the page heap[^] for your process. Follow these steps:
1. Download and install WinDBG[^].
2. Select “Start”->“All Programs”->“Debugging Tools for Windows”->“Global Flags”.
3. Select the “Image File” tab.
4. In the “Image: (TAB to refresh)” edit control enter the name of your app then press TAB. Just the name with the extension; not the full path.
5. Tick the following:
- “Enable page heap”
- “Enable heap tail checking”
- “Enable heap free checking”
- “Enable heap parameter checking”
- “Enable heap validation on call”
- “Create user mode stack trace database”
6. Press “Apply”.
7. Debug your application. Any debugger will do but with WinDBG you have access to the stack traces of allocations via the !heap –p –a command, for example. When a heap problem is detected a breakpoint will be generated.
8. When done un-tick all the options you ticked, press “Apply” then dismiss GFlags. This step is important as if it’s skipped all applications named as entered in step 4 will run with the page heap enabled.
Note that when using the page heap your application will run much slower than normal and consume way more memory. It’s good to have a beefy machine to do such tests; and such tests should be ran regularly on all applications you develop as part of regular testing activities. If I find a part of my application that’s too slow with the page heap enabled I optimize the memory allocation in that region.
Steve
|
|
|
|
|
hye,
i want to stream video from my client pc to server pc...
can anybody tell the proper method of doing so....
any useful articles??????
NT
|
|
|
|