Click here to Skip to main content
15,888,351 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralI test it, you are right! Pin
realfly21-Mar-02 20:29
realfly21-Mar-02 20:29 
GeneralRe: I test it, you are right! Pin
Nish Nishant21-Mar-02 20:52
sitebuilderNish Nishant21-Mar-02 20:52 
GeneralDirectSound Audio(urgent help!) Pin
Peksi21-Mar-02 16:53
Peksi21-Mar-02 16:53 
GeneralAllocate large memory space using calloc Pin
21-Mar-02 15:03
suss21-Mar-02 15:03 
GeneralRe: Allocate large memory space using calloc Pin
Nguyen Binh21-Mar-02 17:28
Nguyen Binh21-Mar-02 17:28 
GeneralRe: Allocate large memory space using calloc Pin
22-Mar-02 18:16
suss22-Mar-02 18:16 
GeneralRe: Allocate large memory space using calloc Pin
22-Mar-02 18:16
suss22-Mar-02 18:16 
GeneralCalculation display in Edit Boxes Pin
joeperris21-Mar-02 14:32
joeperris21-Mar-02 14:32 
Hi,

heres the main code for my Dialog Box called EPGAnalysis:
It has 3 edit boxes (IDC_EDIT1,2 and 3).
I want to include the calculation below the code and the three calucation variables should be displayed on the edit boxes:

The code is:

// EpgAnalysis.cpp : implementation file
//

#include "stdafx.h"
#include "Snors.h"
#include "EpgAnalysis.h"
#include <iostream.h>
#include <iomanip.h>

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CEpgAnalysis dialog


CEpgAnalysis::CEpgAnalysis(CWnd* pParent /*=NULL*/)
: CDialog(CEpgAnalysis::IDD, pParent)
{
//{{AFX_DATA_INIT(CEpgAnalysis)
m_edit1 = 0.0f;
m_edit2 = 0.0f;
m_edit3 = 0.0f;
//}}AFX_DATA_INIT
}


void CEpgAnalysis::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CEpgAnalysis)
DDX_Text(pDX, IDC_EDIT1, m_edit1);
DDX_Text(pDX, IDC_EDIT2, m_edit2);
DDX_Text(pDX, IDC_EDIT3, m_edit3);
//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CEpgAnalysis, CDialog)
//{{AFX_MSG_MAP(CEpgAnalysis)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CEpgAnalysis message handlers




What I want to do is add this code which calculates the percentages:




////////Calculation//////////////
/////////////////////////////////

int main()
{

// initialise and increment the counter for the Alveolar Region

// declare the float variable to store a decimal percentage for the Alveolar Region
float Alveolarpercentage;



// declare an array to store the values of the 14 squares in the alveolar region and
// increment the counter for each active box detected.
// 1 signifies an active box, 0 signifies an inactive box
// the first 6 values represent the first line of the Alveolar region and the next
// 8 represent the second line of the Alveolar Region

int electrodeA[]= {1,1,1,1,0,1,1,0,0,0,0,0,0,1};
int Alveolarcount=0;
for (int a=0; a<14; a++){
//increment the count if an active box is detected
if (electrodeA[a] == 1){
Alveolarcount++;
}
}

// initialise the and increment the counter for the Velar Region

// declare the float variable to store a decimal percentage for the Velar Region
float Velarpercentage;



// declare an array to store the values of the 24 squares in the Velar region and
// increment the counter for each active box detected.
// 1 signifies an active box, 0 signifies an inactive box
// the first 8 values represent the first line of the Velar region, the next
// 8 represent the second and the last 8 represent the third line.

int electrodeV[]= {1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1};
int Velarcount=0;
for (int v=0; v<24; v++){
// increment the count if an active box is detected
if (electrodeV[v] == 1){
Velarcount++;
}
}

// initialise the and increment the counter for the Palatal Region

//declare the float variable to store a decimal percentage for the Palatal region
float Palatalpercentage;



// declare an array to store the values of the 24 squares in the Palatal region and
// increment the counter for each active box detected.
// 1 signifies an active box, 0 signifies an inactive box
// the first 8 values represent the first line of the Palatal region, the next
// 8 represent the second and the last 8 represent the third line.

int electrodeP[]= {1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1};
int Palatalcount=0;
for (int p=0; p<24; p++){
// increment the count if an active box is detected
if (electrodeP[p] == 1){
Palatalcount++;
}
}

// calculate and display the percentage contact for each region

//The Alveolar Percentage Contact
Alveolarpercentage = static_cast < float > (Alveolarcount) / 14 * 100;
//cout << "Alveolar Percentage Contact = "<<setprecision(2)
<<="" setiosflags(="" ios::fixed="" |ios::showpoint="" )
="" alveolarpercentage="" <<"%"="" <<endl;

="" the="" velar="" percentage="" contact
velarpercentage="static_cast" <="" float=""> (Velarcount) / 24 * 100;
//cout << "Velar Percentage Contact = "<<setprecision(2)
<<="" setiosflags(="" ios::fixed="" |ios::showpoint="" )
="" velarpercentage="" <<"%"="" <<endl;


="" the="" alveolar="" percentage="" contact
palatalpercentage="static_cast" <="" float=""> (Palatalcount) / 24 * 100;
//cout << "Palatal Percentage Contact = "<
GeneralRe: Calculation display in Edit Boxes Pin
l a u r e n21-Mar-02 21:07
l a u r e n21-Mar-02 21:07 
GeneralRe: Calculation display in Edit Boxes Pin
joeperris22-Mar-02 2:22
joeperris22-Mar-02 2:22 
GeneralWindows programming not using MFC. Pin
nay21-Mar-02 13:59
nay21-Mar-02 13:59 
GeneralRe: Windows programming not using MFC. Pin
Nish Nishant21-Mar-02 14:07
sitebuilderNish Nishant21-Mar-02 14:07 
GeneralRe: Windows programming not using MFC. Pin
nay21-Mar-02 14:04
nay21-Mar-02 14:04 
GeneralRe: Windows programming not using MFC. Pin
Jon Sagara21-Mar-02 14:04
Jon Sagara21-Mar-02 14:04 
QuestionHow to extract string from where mouse has pointed to? Pin
Li-kai Liu (Angus)21-Mar-02 13:14
Li-kai Liu (Angus)21-Mar-02 13:14 
AnswerRe: How to extract string from where mouse has pointed to? Pin
Christian Graus21-Mar-02 13:34
protectorChristian Graus21-Mar-02 13:34 
GeneralRe: How to extract string from where mouse has pointed to? Pin
Li-kai Liu (Angus)21-Mar-02 13:55
Li-kai Liu (Angus)21-Mar-02 13:55 
GeneralRe: How to extract string from where mouse has pointed to? Pin
Christian Graus21-Mar-02 14:14
protectorChristian Graus21-Mar-02 14:14 
GeneralRe: How to extract string from where mouse has pointed to? Pin
Michael Dunn21-Mar-02 17:10
sitebuilderMichael Dunn21-Mar-02 17:10 
GeneralRe: How to extract string from where mouse has pointed to? Pin
Li-kai Liu (Angus)21-Mar-02 18:28
Li-kai Liu (Angus)21-Mar-02 18:28 
AnswerRe: How to extract string from where mouse has pointed to? Pin
moliate21-Mar-02 14:43
moliate21-Mar-02 14:43 
GeneralRe: How to extract string from where mouse has pointed to? Pin
Christian Graus21-Mar-02 15:14
protectorChristian Graus21-Mar-02 15:14 
GeneralRe: How to extract string from where mouse has pointed to? Pin
Li-kai Liu (Angus)21-Mar-02 15:38
Li-kai Liu (Angus)21-Mar-02 15:38 
GeneralRe: How to extract string from where mouse has pointed to? Pin
moliate21-Mar-02 16:23
moliate21-Mar-02 16:23 
GeneralRe: How to extract string from where mouse has pointed to? Pin
Li-kai Liu (Angus)21-Mar-02 17:52
Li-kai Liu (Angus)21-Mar-02 17:52 

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.