Link to home
Start Free TrialLog in
Avatar of karim
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??
ASKER CERTIFIED SOLUTION
Avatar of The Master
The Master

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of The Master
The Master

Sorry about the indentation in the above answer, the editor took out the extra spacing.
Avatar of karim

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(CSettlementDlg)
      enum { IDD = IDD_SETTLEMENT_DIALOG };
            // NOTE: the ClassWizard will add data members here
      //}}AFX_DATA

      // ClassWizard generated virtual function overrides
      //{{AFX_VIRTUAL(CSettlementDlg)
      protected:
      virtual void DoDataExchange(CDataExchange* 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(CSettlementDlg, CDialog)
      //{{AFX_MSG_MAP(CSettlementDlg)
      ON_WM_PAINT()
      ON_WM_QUERYDRAGICON()
      ON_MESSAGE (WM_STARTPROCESSING, StartProcessing)
      //}}AFX_MSG_MAP
END_MESSAGE_MAP()

               .
               .
               .

CSettlementDlg::StartProcessing (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
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::StartProcessing (UINT wParam, LONG lParam)
{

return 1L;
}

Hope that helps!

Bill.