Click here to Skip to main content
15,915,093 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHELP: split up source file into segments automatically.... Pin
andrewwan198014-Oct-07 23:46
andrewwan198014-Oct-07 23:46 
QuestionAbout DLL and Threads Pin
Nelek14-Oct-07 23:45
protectorNelek14-Oct-07 23:45 
AnswerRe: About DLL and Threads Pin
Matthew Faithfull14-Oct-07 23:58
Matthew Faithfull14-Oct-07 23:58 
GeneralRe: About DLL and Threads [SOLVED] Pin
Nelek15-Oct-07 4:00
protectorNelek15-Oct-07 4:00 
QuestionFolder Permissions Pin
narayanagvs14-Oct-07 23:15
narayanagvs14-Oct-07 23:15 
AnswerRe: Folder Permissions Pin
David Crow15-Oct-07 4:06
David Crow15-Oct-07 4:06 
GeneralRe: Folder Permissions Pin
narayanagvs15-Oct-07 4:19
narayanagvs15-Oct-07 4:19 
Questionhow to terminate continuous running program by clicking button on MFC dialog based window in C++ Pin
Thinn Nwe Han14-Oct-07 23:09
Thinn Nwe Han14-Oct-07 23:09 
hi,
I am a beginner in C++. now I was writing the MFC( dialog based)program for the RFID interfacing. My existing program is upon clicking the start button, it will send the command to the reader and receive the response from it by using serial commnunication within for loop and serial port will disconnect by clicking stop button at the end of 'for' loop. If I click the stop button while program running half way, the program will hang. So, I wanted to implement it that upon clicking start button, my program will start interfacing with reader continuously until I clicked the stop button.So, how can i do it and can support me the sample source code for this similar program?

thanks,
Thinn

This is a part of my existing program



void CTry2Dlg::OnStart()
{
// TODO: Add your control notification handler code here


// ***

char c[40],bcch;
int bcc,ent=0;
int h=0,count=0;


com = new Tserial();
com->connect("COM2", 9600, spEVEN);

char command[15] = {0x02,0x30,0x30,0x52,0x44,0x4D,0x54,0x41,0x41,0x30,0x30,0x30,0x31,0x03};// multi



bcc=com->bcc(command); // obtain BCC
bcch=bcc;


for(int n=0;n<10;n++)
{

GetTime();
for(int i=0;i<15;i++) // send command
{
if(i==14)
{
com->sendChar(bcch);

}
else
{
com->sendChar(command[i]);

}
}
GetDlgItem(IDC_Status)->SetWindowText(command);
GetDlgItem(IDC_Status)->UpdateWindow();
// Sleep(100);

count=0;


do // read response frame
{

h=0;

c[h] = com->getChar();


while(c[h]!=0x03) // to detect ETX of reponse frame
{

h++;
c[h] = com->getChar();
}

// if(c[h]==0x03)
// {
count++;


// }

c[h] = com->getChar(); // BCC

if(c[6]==0x37 && c[7] ==0x32) // check for end of detection
{
ent=1; // endofTx
// if(count>1)
// {
count--;



// }

}
else // more to come ...
{
ent=0;
//cout<<endl<<"uid =="" ";
char="" temp[16];

for(int="" k="8;k<24;k++)
{
temp[k-8]=c[k];

}


CString" appendtext;
getdlgitem(idc_tag)-="">GetWindowText(appendText);
appendText += temp;
appendText += "\r\n";
GetDlgItem(IDC_Tag)->SetWindowText(appendText);
GetDlgItem(IDC_Tag)->UpdateWindow();
}



}while(ent==0); // reading
CString text;
text.Format("%d", count);
GetDlgItem(IDC_Counter)->SetWindowText(text);
GetDlgItem(IDC_Counter)->UpdateWindow();


Sleep(2000);
Clear();//clear the edit boxes
}

}

void CTry2Dlg::OnCancel()
{
// TODO: Add extra cleanup here

CDialog::OnCancel();

}

void CTry2Dlg::OnStop()
{
com->disconnect();
CString text=" ";
GetDlgItem(IDC_Counter)->SetWindowText(text);
GetDlgItem(IDC_Counter)->UpdateWindow();

GetDlgItem(IDC_Tag)->SetWindowText(text);
GetDlgItem(IDC_Tag)->UpdateWindow();

GetDlgItem(IDC_Status)->SetWindowText(text);
GetDlgItem(IDC_Status)->UpdateWindow();
}

--

AnswerRe: how to terminate continuous running program by clicking button on MFC dialog based window in C++ Pin
chandu00415-Oct-07 0:41
chandu00415-Oct-07 0:41 
GeneralRe: how to terminate continuous running program by clicking button on MFC dialog based window in C++ Pin
Thinn Nwe Han15-Oct-07 16:02
Thinn Nwe Han15-Oct-07 16:02 
QuestionRe: how to terminate continuous running program by clicking button on MFC dialog based window in C++ Pin
David Crow15-Oct-07 4:09
David Crow15-Oct-07 4:09 
AnswerRe: how to terminate continuous running program by clicking button on MFC dialog based window in C++ Pin
Thinn Nwe Han15-Oct-07 15:58
Thinn Nwe Han15-Oct-07 15:58 
GeneralRe: how to terminate continuous running program by clicking button on MFC dialog based window in C++ Pin
David Crow15-Oct-07 16:04
David Crow15-Oct-07 16:04 
QuestionButtons Pin
mcsherry14-Oct-07 23:02
mcsherry14-Oct-07 23:02 
AnswerRe: Buttons [modified] Pin
Roger Broomfield14-Oct-07 23:17
Roger Broomfield14-Oct-07 23:17 
GeneralRe: Buttons Pin
mcsherry14-Oct-07 23:46
mcsherry14-Oct-07 23:46 
GeneralRe: Buttons Pin
Roger Broomfield14-Oct-07 23:58
Roger Broomfield14-Oct-07 23:58 
GeneralRe: Buttons Pin
mcsherry15-Oct-07 0:21
mcsherry15-Oct-07 0:21 
GeneralRe: Buttons Pin
David Crow15-Oct-07 4:12
David Crow15-Oct-07 4:12 
Questionerror : class redifinition Pin
srvsah14-Oct-07 21:55
srvsah14-Oct-07 21:55 
AnswerRe: error : class redifinition Pin
Nelek14-Oct-07 22:16
protectorNelek14-Oct-07 22:16 
AnswerRe: error : class redifinition Pin
toxcct15-Oct-07 0:17
toxcct15-Oct-07 0:17 
AnswerRe: error : class redifinition Pin
Cedric Moonen15-Oct-07 0:18
Cedric Moonen15-Oct-07 0:18 
AnswerRe: error : class redifinition Pin
ThatsAlok15-Oct-07 1:50
ThatsAlok15-Oct-07 1:50 
AnswerRe: error : class redifinition Pin
David Crow15-Oct-07 4:15
David Crow15-Oct-07 4:15 

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.