|
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
|
|
|
|
|
Hello everyone!
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.
Here's a code snippet:
#pragma once
#include "afxcmn.h"
class CCalibrationDialog : public CDialog
{
DECLARE_DYNAMIC(CCalibrationDialog)
public:
CCalibrationDialog(CWnd* pParent = NULL);
virtual ~CCalibrationDialog();
enum { IDD = IDD_DIALOG_CALIBRATION };
CProgressCtrl m_ProgressCtrl;
.
.
.
protected:
virtual void DoDataExchange(CDataExchange* pDX);
virtual BOOL OnInitDialog();
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedButtonCalPrg();
};
void CCalibrationDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_PROGRESS_CAL, m_ProgressCtrl);
}
BOOL CCalibrationDialog::OnInitDialog()
{
m_ProgressCtrl.SetRange(0,100);
m_ProgressCtrl.SetStep(10);
return true;
}
.
.
.
void CCalibrationDialog::OnBnClickedButtonCalPrg()
{
m_ProgressCtrl.StepIt();
}
Any ideas?
Thanks a lot for any feedback!
Ody Z.
|
|
|
|
|
Asserts where?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
_AFXCMN_INLINE void CProgressCtrl::SetRange(short nLower, short nUpper)
{ ASSERT(::IsWindow(m_hWnd)); ::SendMessage(m_hWnd, PBM_SETRANGE, 0, MAKELPARAM(nLower, nUpper)); }
Thanks for the response! Do you have any idea what may be wrong?
|
|
|
|
|
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.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I'm sorry but I didn't quite understood what you said... I agree that apparently the HWND of the m_ProgressCtrl is NULL, but isn't that supposed to be fixed by DoDataExchange() ?
Which, by the way, is never executed, at least a breakpoint at the line: DDX_Control(pDX, IDC_PROGRESS_CAL, m_ProgressCtrl); is never accessed when I debug...
Cheers!
|
|
|
|
|
Odysseas Z wrote: Which, by the way, is never executed
It's been a while and I forget, but maybe you need to call the base class OnInitDialog() from your OnInitDIalog override?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Why the solution always has to be so obvious? It worked!
Thanks a lot!
Best Regards!!!
Ody Z.
|
|
|
|
|
Odysseas Z wrote: Why the solution always has to be so obvious?
If it wasn't so obvious we would have seen it right away!
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
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..
Cheers
Vaclav
|
|
|
|
|
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 .
|
|
|
|
|
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.
Thanks for your help, back to coding.
|
|
|
|
|
Hi Developers,
I am using SHA160 algo to generate hash key of a file. I need to store & get it from a table. I am taking hash key in CString variable and try to store it in a TEXT field.
First of all this value is not getting store.
When I execute any query based on that hash key like
CString sTemp;
sTemp.Format(_T( "Select * From MEDIA_MAT Where RemedyID = '%d' And HashKey = '%s' And ID <> %d"), m_strTable, m_lngParentID, strHashValue, *m_lngID );
if( !rsAccessMedia.IsEOF() )
At the last line application get break, It can continue but hash key is not getting stored.
Pls help me out.
Thanks.
Amrit Agrawal
|
|
|
|
|
Hi,
Your CString.Format() has 3 type fields but your passing 4 arguments.
Best Wishes,
-David Delaune
|
|
|
|
|
Format() is a variable parameter function, interface and the Printf() similar: void Format( LPCTSTR lpszFormat, ... ); You can reference MSDN
|
|
|
|
|
Hi,
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.
-David Delaune
|
|
|
|
|
Are you from the United States?
|
|
|
|
|
Are you from the moon?
The best things in life are not things.
|
|
|
|
|
so ?
Watched code never compiles.
|
|
|
|
|
Hi All,
Where can I get the source code of
Begining ATL 3 COM programming
|
|
|
|
|
If there is no URL mentioned in the book then a Google search is probably your best bet. I notice that this book is more than 10 years old so it may well no longer be available.
The best things in life are not things.
|
|
|
|
|
Hi all,
i have an Dialog box here i am having 4 EditBoxes.
all editboxes have some values i want on button click event on this dialog box open a url page that also have 4 editbox(input box).
now page display the values of dialog editbox into the page Input boxes.
please help me how can i do this.
thanks in advance.
|
|
|
|
|
|
Hi all,
i have an problem to convert a CString value in const std::string.
CString result="";
CString str="test";
const std::string s = str;
std::string s1 = fun1(s);
result=s1.c_str();
please help me for this.
thanks in advance.
|
|
|
|