karim
asked on
Idle Processing in a dialogbox
Hello,
I am developing a Windows NT application which has only one dialog box. It does lot of background processing and provides a feedback to user through the dialog box. There is no interaction required from the user. As soon as the application is started, it brings up this dialog box and starts processing. So I created a dialog based application usin MFC, but once the "DoModal()" function is called for this dialog box class, then how do I do the idle processing after that??
I am developing a Windows NT application which has only one dialog box. It does lot of background processing and provides a feedback to user through the dialog box. There is no interaction required from the user. As soon as the application is started, it brings up this dialog box and starts processing. So I created a dialog based application usin MFC, but once the "DoModal()" function is called for this dialog box class, then how do I do the idle processing after that??
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry about the indentation in the above answer, the editor took out the extra spacing.
ASKER
Thank you very much for providing a reply. I tried the second method u proposed and I got following two errors at compile time:
error C2556: 'StartProcessing' : overloaded functions only differ by return type
error C2371: 'StartProcessing' : redefinition; different basic types
Now I don't know why would it think that I am trying to over load this function. The parent class "CDialog" does not have any function called "StartProcessing". Following is the listing of CSettlementDlg class definition from the .h file. I opologize for the indentation in advance:
// SettlementDlg.h : header file
//
// define a user defined msg
#define WM_STARTPROCESSING WM_USER + 501
////////////////////////// ////////// ////////// ////////// ////////// ////////// /
// CSettlementDlg dialog
class CSettlementDlg : public CDialog
{
// Construction
public:
CSettlementDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CSettlementDl g)
enum { IDD = IDD_SETTLEMENT_DIALOG };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CSettlemen tDlg)
protected:
virtual void DoDataExchange(CDataExchan ge* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
HICON m_hIcon;
// Generated message map functions
//{{AFX_MSG(CSettlementDlg )
virtual BOOL OnInitDialog();
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg LONG StartProcessing (UINT wParam, LONG lParam);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
Well and also in my .cpp file I have:
.
.
.
BEGIN_MESSAGE_MAP(CSettlem entDlg, CDialog)
//{{AFX_MSG_MAP(CSettlemen tDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_MESSAGE (WM_STARTPROCESSING, StartProcessing)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
.
.
.
CSettlementDlg::StartProce ssing (UINT wParam, LONG lParam)
{
return 1L;
}
So if you can spot a problem in this please let me know. Thanks very much for your help
error C2556: 'StartProcessing' : overloaded functions only differ by return type
error C2371: 'StartProcessing' : redefinition; different basic types
Now I don't know why would it think that I am trying to over load this function. The parent class "CDialog" does not have any function called "StartProcessing". Following is the listing of CSettlementDlg class definition from the .h file. I opologize for the indentation in advance:
// SettlementDlg.h : header file
//
// define a user defined msg
#define WM_STARTPROCESSING WM_USER + 501
//////////////////////////
// CSettlementDlg dialog
class CSettlementDlg : public CDialog
{
// Construction
public:
CSettlementDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CSettlementDl
enum { IDD = IDD_SETTLEMENT_DIALOG };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CSettlemen
protected:
virtual void DoDataExchange(CDataExchan
//}}AFX_VIRTUAL
// Implementation
protected:
HICON m_hIcon;
// Generated message map functions
//{{AFX_MSG(CSettlementDlg
virtual BOOL OnInitDialog();
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg LONG StartProcessing (UINT wParam, LONG lParam);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
Well and also in my .cpp file I have:
.
.
.
BEGIN_MESSAGE_MAP(CSettlem
//{{AFX_MSG_MAP(CSettlemen
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_MESSAGE (WM_STARTPROCESSING, StartProcessing)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
.
.
.
CSettlementDlg::StartProce
{
return 1L;
}
So if you can spot a problem in this please let me know. Thanks very much for your help
Yes, that's a common error - I get it all the time when I change the return type of a function in either the .H or .CPP file, but not in the other.
What's happening in your case is that you have StartProcessing() defined as returning a LONG in your header file, but you don't have a return type in your .CPP file. I'm not sure if it assumes you want to return int or void, but it will assume one of those, and so it thinks the function it's compiling is an overloaded function (same name but different parameters or return types). By the rules of C++, you cannot have two functions with the same name, that vary only in their return type. That's why you're getting those errors.
Your function should look like this:
LONG CSettlementDlg::StartProce ssing (UINT wParam, LONG lParam)
{
return 1L;
}
Hope that helps!
Bill.
What's happening in your case is that you have StartProcessing() defined as returning a LONG in your header file, but you don't have a return type in your .CPP file. I'm not sure if it assumes you want to return int or void, but it will assume one of those, and so it thinks the function it's compiling is an overloaded function (same name but different parameters or return types). By the rules of C++, you cannot have two functions with the same name, that vary only in their return type. That's why you're getting those errors.
Your function should look like this:
LONG CSettlementDlg::StartProce
{
return 1L;
}
Hope that helps!
Bill.