I compiled a MFC application in debug mode.
When I run the program, most time, it was OK, but in a few times, it occurred following error:
-abort() has been called
(Press Retry to debug the application)
Last night, I left the program running, it also occurred such error.
Now I let the program run for two hours，but the error has not occurred yet.
It seems the error occurred randomly, how can I get rid of the annoying problem .
This is an error probably from CRT... like Richard already mentioned, if you debug, you should be able to see both why the abort() was called and what part of your code triggered it (look through call stack).
Q: What's the best way to eat an elephant?
A: One bite at a time.
Have you tried narrowing down the problem to something a bit more manageable? In other words, if you've got a 1000-line program and something is wrong, rather than look at each line with equal suspicion, remove (irrelevant) lines until the problem goes away. Or, start over and add lines until problem appears. This way you can focus your effort on a much smaller problem.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
I have a CDialog derived class named CCalibrationDialog. As the name shows I want that dialog to control a procedure of a calibration (non-relevant: camera shutter/gain calibration). I would love to be able to show the progress of this procedure with a CProgressCtrl object but I have a little (maybe dumb) problem. I follow every step of this tutorial (http://www.codersource.net/mfc/mfc-tutorials/cprogressctrl.aspx[^]) which seems to show the easiest way to control the progress bar but my program asserts as if the CProgressCtrl is not initialized.
What you showed should be fine. I'm guessing at your call to progressctrl.SetRange() the progress control's HWND is 0/NULL, yes? If so, it sounds like the progress control with a matching ID isn't being found on the dialog form.
Since I needed a way to stop / disable COM port DTR signal I have ventured into unknown territory of multithreading . I am making progress.
Now I need to use same approach to start / stop audio recording.
I am using waveInOpen function with CALLBACK_FUNTION.
Upon receiving the WIM_DATA the callback function will run the worker thread.
However,waveInOpen has an option to use CALLBACK_THREAD and I am unable to find any examples on how it can be used.
Since using callback can be challenging, it is for me, I like the callback function giving me feedback aka – WIM_OPEN.
How can I get that response from CALLBACK_THREAD / worker thread?
I am coding in VC++ / MFC, please do not waste your and mine time suggesting alternative development tools.
Any constructive help will be as always appreciated..
Use can use CreateThread to first create a thread.
The last parameter of CreateThread will give you the identifier of the thread that you pass in the dwCallback parameter of waveInOpen.
In the thread function, you can have a GetMessage loop to retrieve the messages being sent to the thread which are MM_WIM_OPEN, MM_WIM_CLOSE, and MM_WIM_DATA.
«_Superman_» I love work. It gives me something to do between weekends.
Are you saying I need to use user interface thread because I need to intercept the wave messages? Makes sense.
But I think I am making things unnecessary complex,I think I can get away with just using the CALLBACK function.
I can start the recording in the dialog without creating worker thread. I can get an event from "Stop" button ( that is what I am after) while the audio file is updating, however, my waveInStop does not work, not yet.
Thank you for that little golden nugget of Tai Chi wisdom. I'm going back through all of my old code to add some extra arguments to all of the functions accepting variable argument lists. Because the I-Ching uses a set of 64 hexagrams I'll make sure to pass a minimum of six arguments to each function.