Click here to Skip to main content
15,905,504 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralChange exe file in project Pin
Mazdak6-Mar-04 6:20
Mazdak6-Mar-04 6:20 
GeneralRe: Change exe file in project Pin
Prakash Nadar6-Mar-04 6:31
Prakash Nadar6-Mar-04 6:31 
GeneralRe: Change exe file in project Pin
Mazdak6-Mar-04 7:30
Mazdak6-Mar-04 7:30 
GeneralRe: Change exe file in project Pin
Joe Woodbury6-Mar-04 11:45
professionalJoe Woodbury6-Mar-04 11:45 
GeneralRe: Change exe file in project Pin
Mazdak6-Mar-04 20:00
Mazdak6-Mar-04 20:00 
Generalminimize to system tray Pin
Otty6-Mar-04 6:02
Otty6-Mar-04 6:02 
GeneralRe: minimize to system tray Pin
tn_dang22-Apr-04 3:21
tn_dang22-Apr-04 3:21 
GeneralHelp I can't figure out how to update my edit box in visual c++ mfc Pin
MeterMan6-Mar-04 5:59
MeterMan6-Mar-04 5:59 
I have a worker thread i created in a dialog box. I want to run a thread till i either press the stop button or it finds a winnner. that part works fine. But i have an edit box called number of players with an int variable of m_win; I put inside the tread m_win=counter; UpdateData(FALSE); and the program will compile and run but as soon as it hits UpdateData(False); i get an assert error in reference to wincore.cpp 884. I read the information online about it and basically its saying either its a bug in vc++ or i'm coding it wrong. I think i'm coding it wrong cause i installed all the service packs. could someone please take the time and shed some light on this for me. If updatedata(false) can not be used how can i update my data? I know i can make a button that updates it but defeats the point.
thanks,
tony
D'Oh! | :doh:
////////////////cpp file for the dialog box////////////////
UINT CCash3mfcDlg::StartThread(LPVOID param)
{





THREADSTRUCT* ts = (THREADSTRUCT*)param;
ts->_this->run();

//here is the time-consuming process which interacts with your dialog


return 1;

}



void CCash3mfcDlg::Ongobutton()
{

THREADSTRUCT *_param = new THREADSTRUCT;
_param->_this = this;

AfxBeginThread (StartThread, _param);
UpdateData(TRUE);




}

int CCash3mfcDlg::run()
{




counter = 0;
bool win=false;

stop=false;
int random1,random2,random3;
m_processstatus.SetRange (1, 1000);
while (stop==false&&win==false)
{

m_win=counter;
Sleep(50);
random1 = rand()%5;
random2 = rand()%5;
random3 = rand()%5;
switch (random1)
{
case 0:
m_ball1.SetIcon(m_h0);

break;
case 1:
m_ball1.SetIcon(m_h1);
break;
case 2:
m_ball1.SetIcon(m_h2);
break;
case 3:
m_ball1.SetIcon(m_h3);
break;
case 4:
m_ball1.SetIcon(m_h4);
break;
}

switch (random2)
{
case 0:
m_ball2.SetIcon(m_h0);
break;
case 1:
m_ball2.SetIcon(m_h1);
break;
case 2:
m_ball2.SetIcon(m_h2);
break;
case 3:
m_ball2.SetIcon(m_h3);
break;
case 4:
m_ball2.SetIcon(m_h4);
break;
}

switch (random3)
{
case 0:
m_ball3.SetIcon(m_h0);
break;
case 1:
m_ball3.SetIcon(m_h1);
break;
case 2:
m_ball3.SetIcon(m_h2);
break;
case 3:
m_ball3.SetIcon(m_h3);
break;
case 4:
m_ball3.SetIcon(m_h4);
break;
}


if (m_ticket1==random1&&m_ticket2==random2&&m_ticket3==random3)
{
win=true;

}






m_processstatus.StepIt ();
counter++;



}
m_ticket3=1;
m_processstatus.SetPos(0);


//AfxEndThread(0);
CWnd::MessageBox("THREAD IS DONE");




return 0;
}

void CCash3mfcDlg::Onstopbutton()
{



stop=true;


}

//HEADER FILE FOR DIALOG BOX///////////////
// cash3 mfcDlg.h : header file
//

#if !defined(AFX_CASH3MFCDLG_H__B03A0082_F3ED_448F_A5AC_56734A264BF3__INCLUDED_)
#define AFX_CASH3MFCDLG_H__B03A0082_F3ED_448F_A5AC_56734A264BF3__INCLUDED_




#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000


/////////////////////////////////////////////////////////////////////////////
// CCash3mfcDlg dialog

class CCash3mfcDlg : public CDialog
{
// Construction
public:
CCash3mfcDlg(CWnd* pParent = NULL); // standard constructor


static UINT StartThread (LPVOID param); //controlling function header
typedef struct THREADSTRUCT //structure for passing to the controlling function
{
CCash3mfcDlg* _this;
} THREADSTRUCT;




// Dialog Data
//{{AFX_DATA(CCash3mfcDlg)
enum { IDD = IDD_CASH3MFC_DIALOG };
CEdit m_winupdate;
CStatic m_ball1;
CProgressCtrl m_processstatus;
CStatic m_ball3;
CStatic m_ball2;
int m_ticket1;
int m_ticket2;
int m_ticket3;
bool stop;
int m_draws;
int m_win;
int counter;

//}}AFX_DATA

// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CCash3mfcDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL

// Implementation





protected:
HICON m_hIcon;
///////////////////added by me///////////////////
HICON m_h0;//ball zero icon
HICON m_h1;//ball one icon
HICON m_h2;//ball two icon
HICON m_h3;//ball three icon
HICON m_h4;//ball four icon
/////////////////////////////////////////////////
// Generated message map functions
//{{AFX_MSG(CCash3mfcDlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnDestroy();
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void Ongobutton();
afx_msg int run();
afx_msg void Onstopbutton();
afx_msg void Update();


//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_CASH3MFCDLG_H__B03A0082_F3ED_448F_A5AC_56734A264BF3__INCLUDED_)



GeneralRe: Help I can't figure out how to update my edit box in visual c++ mfc Pin
Michael Dunn6-Mar-04 6:04
sitebuilderMichael Dunn6-Mar-04 6:04 
GeneralRe: Help I can't figure out how to update my edit box in visual c++ mfc Pin
Prakash Nadar6-Mar-04 6:29
Prakash Nadar6-Mar-04 6:29 
GeneralRe: Help I can't figure out how to update my edit box in visual c++ mfc Pin
Michael Dunn6-Mar-04 6:57
sitebuilderMichael Dunn6-Mar-04 6:57 
GeneralRe: Help I can't figure out how to update my edit box in visual c++ mfc Pin
Prakash Nadar6-Mar-04 7:03
Prakash Nadar6-Mar-04 7:03 
GeneralRe: Help I can't figure out how to update my edit box in visual c++ mfc Pin
MeterMan6-Mar-04 7:11
MeterMan6-Mar-04 7:11 
GeneralRe: Help I can't figure out how to update my edit box in visual c++ mfc Pin
Prakash Nadar6-Mar-04 7:26
Prakash Nadar6-Mar-04 7:26 
GeneralRe: Help I can't figure out how to update my edit box in visual c++ mfc Pin
MeterMan6-Mar-04 8:45
MeterMan6-Mar-04 8:45 
GeneralRe: Help I can't figure out how to update my edit box in visual c++ mfc Pin
Prakash Nadar6-Mar-04 14:46
Prakash Nadar6-Mar-04 14:46 
GeneralRe: Help I can't figure out how to update my edit box in visual c++ mfc Pin
MeterMan6-Mar-04 17:50
MeterMan6-Mar-04 17:50 
GeneralRe: Help I can't figure out how to update my edit box in visual c++ mfc Pin
Prakash Nadar6-Mar-04 20:28
Prakash Nadar6-Mar-04 20:28 
GeneralRe: Help I can't figure out how to update my edit box in visual c++ mfc Pin
MeterMan6-Mar-04 20:57
MeterMan6-Mar-04 20:57 
GeneralRe: Help I can't figure out how to update my edit box in visual c++ mfc Pin
MeterMan6-Mar-04 7:03
MeterMan6-Mar-04 7:03 
GeneralRe: Help I can't figure out how to update my edit box in visual c++ mfc Pin
Michael Dunn6-Mar-04 8:30
sitebuilderMichael Dunn6-Mar-04 8:30 
GeneralRe: Help I can't figure out how to update my edit box in visual c++ mfc Pin
MeterMan6-Mar-04 9:27
MeterMan6-Mar-04 9:27 
GeneralVC .NET 2003 Serial Port Comms Pin
shultas6-Mar-04 5:39
shultas6-Mar-04 5:39 
GeneralRe: VC .NET 2003 Serial Port Comms Pin
bishbosh027-Mar-04 8:45
bishbosh027-Mar-04 8:45 
Generaliterator Pin
nss6-Mar-04 4:41
nss6-Mar-04 4:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.