Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a Win32 API windows program that displays a txt file that contains a French document. I can click on a word and the program will read a dictionary file, open an edit window and display the English definition, type, and tense. After several requests the program stops displaying the results. In fact, any mouse clicks appear to have no results (including clicking the tool bar and the scroll bar). A right mouse button click should cause a MessageBox to appear but does not.
In tracing my program I see that the program is behaving as though it is working but no windows pop up nor does any displayed text appear.
I reuse the edit window and simply resize it and move it around, (rather than deleting it and recreating it for each definition), so I tried creating it when needed and deleting it when done, but no change.
I also create a global font on startup and apply it when needed so I tried it without the font but again no change.
When I compile with CodeBlocks the program stops displaying after about 45 requests. When I compile with DevCpp the problem occurs after about 20 requests. I’ve also monitored the GlobalMemoryStatus but there appears to be lots of memory so I can’t put it down to a memory leak. It’s almost as if I’ve run out of some windows structure but I don’t know what?
The program is ~1300 lines so I don’t know if there is a subset that might illustrate the cause but will post selected code blocks if I know what might help.
Anyone have any suggestions?

What I have tried:

removing unneeded fonts, reuse of dialogs, unneeded brushes, different compilers.
Posted
Updated 4-Nov-16 18:52pm
Comments
Richard MacCutchan 30-Oct-16 4:27am    
The problem could be caused by any one of a number of problems, but the only way to find out is to do some debugging. It is impossible for anyone here to guess what your code is doing.

First: if you create a system resource, like a file or a font handle you must free it after use. For a HFONT you must call DeleteObject.

The tool Process Explorer from Microsoft could help you to find the problem. As I read your text I guess, that maybe some files wont be closed and you end up with to many file handles or some blocking file API.

If it isnt so easy than is Richard completly right, that you will have to work with the debugger. At first you must understand the workflow of the program and add some logging messages, and maybe it helps to switch out some code pathes to find the bug.
 
Share this answer
 
Comments
Member 12823218 30-Oct-16 20:14pm    
Thanks for the tip about Process Explorer, this is the sort of thing I needed. I've run it a couple of times but there is so much information I'm not sure what is going on (YET). There appears to be a lot of handles including a host of <unknown type=""> handles. (don't know if that's the problem) but I continue to explore. Doesn't appear that I've left any of my files open but there a host of Event handles so I'll check to make sure I've handled events properly in my callback procedure. Any other tips are appreciated.
Again, thanks for all the help
Steve King
I found an HBRUSH that was defined and returned from a WM_CTLCOLORDLG but never selected , {SelectObject(hdc, ywBrush)} nor deleted {DeleteObject(ywBrush)}. A careful reading of WM_CTLCOLORDLG indicated I needed to delete that object when no longer needed. I made the HBRUSH a global variable (mea culpa) and the problem went away. Thanks for all the help
Steve King
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900