|
Use ::VirtualAlloc()/ VirtualFree() instead.
Nguyen Binh.
|
|
|
|
|
It works Thanks!
|
|
|
|
|
It works Thanks!
|
|
|
|
|
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 = "<
|
|
|
|
|
in the dialog box put 3 cedit controls for the edit boxes
put a calc button on the dialog box
when they click it check for valid values and do the calc
or...
you could catch the 'lose focus' event of the boxes and do the validation and calcs as they do stuff
hope this helps
---
"all's fair in love and war but in love there is no geneva convention"
|
|
|
|
|
Lauren,
Thank you very very much!!! you have just saved my life! I love you!!!
|
|
|
|
|
Just for the heck of it I wanted to do a windows program (one with a window and all) without using MFC. I have my WinMain and WndProc all set up and the window displays great. BUT... how can I add controls? I've tried creating a CButton but it requires a handle to a Cwnd. but I don't have that I just have a HANDLE. So how do I create controls and such? Anyone got a good link?
nay
|
|
|
|
|
You can create controls using CreateWindowEx
Do not use stuff like CButton and CWnd. Those are MFC classes.
For a button call CreateWindowEx and use "Button" as the lpClassName parameter
Nish
Chris,
Can I have a Johnny Bravo icon please?
Please, please, please........
|
|
|
|
|
Thank you very much Nish.
nay
|
|
|
|
|
|
Hi,
I found some translation software can extract string
from where the mouse points to and translate the word
on the fly. I was wondering how can this be done and
is there any Win32 API can archieve this function. A
brief explanation will be appreciate
Thank you very much
Angus Liu
|
|
|
|
|
This SO needs to make the FAQ, I know I've answered it 15 times.
The two ways to do this are using WindowFromPoint and GetWindowTest ( advantages: can find text that is obscured, disadvantages, will not work with text in bitmaps, is complex in other ways ( what word am I over in a sentence, etc. )). Second, write some OCR software. Advantages - works with everything, disadvantages - you have to write some OCR software.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
Hi Christian,
Thank you for your quick response.
I've not been awared that I'm asking a common question
like this. But I'm a causal visitor of this site and
didn't roll back to find out where your other 14 answers
appear. Anyway, Thanks a lot for your 15th answer
Angus Liu
|
|
|
|
|
That's cool - it's not that I'd expect you to read the rest of the site, only that it would make a good inclusion to the FAQ ( which I would hope people read ), because it is asked so often.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
|
Thanks! I read that However, I still think there is a
way out other than using the OCR technique...
I got an English-Chinese translation software here called
Dreye 2002. Well, the name of the program isn't important.
It does the trick of extracting the word in the sentence
from where your mouse's pointed at. I don't think it involves
OCR because it can't read text in the bitmap. Another reason
is that recognition of Chinese character is so complicated that
can't be always 100% correct. But this program can read chinese
character with no errors and translate it into English on the
fly, and vice versa. It looks to me that it can read any piece
of text drawn by Windows, including text in RichEdit control,
WebBrowser Control, Menu, Title Bar of a window, etc. virtually
every piece of text so long as it is not in bitmap format.
I've looked up in MSDN for the solution. My attempt wasn't very
successful. That's why I come up with this question
Anyway, it's so nice to have so many experts around and tries to
answer my question. Thank you all!
Angus Liu
|
|
|
|
|
Just an addition to CG:s answer:
GetWindowText will not work on passwords on some versions of Windows (NT+ ?) if used from outside process. Use dll-injection to get your code inside the process...
GetWindowText will not work in a WebBrowserCtrl. Use elementFromPoint/get_innerText in this case...
/moliate
|
|
|
|
|
Cool - my answer is designed to show how big a task it is ( and therefore beyond the scope of some thing that could be answered here in one go ). You've made me realise it's even worse than I thought. I guess OCR is the only viable option.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
Cheers, Moliate.
You explained my worries about retrieving a string from
WebBrowser Control. But doesn't getting innerText return
all text that an element has? Say, I have a piece of text
"Hello! World" inside a pair of tag. And, my mouse
is hovering over the word "World". Any more specified
function can return the word "World" instead of "Hello!
World"? Or, even more fussy, tells me my mouse is over the
character 'W'.?
Well, Sorry about my nagging questions:P
Angus Liu
|
|
|
|
|
ykliu wrote:
But doesn't getting innerText return
all text that an element has?
Unfortionally, it does.... (similar to GetWindowText)
I really don't know how to get a specific word or character. A possible (but probably not the best) solution would be to make a copy of the element and gradually update the text so it removes one word after another. At the same time reduce the mouse coordinates by the difference between the original elements lower right corner, and the copys lower right. When the mouse goes out of the bounding box, you have the word pointed at... (hopefully)
/moliate
|
|
|
|
|
That's all right, your explanation has been very
helpful. I really appreciate it
Angus Liu
|
|
|
|
|
Dear Friends
I made one c file in which i am reading an input .bmp file and after certain modification i am writting it in an output .bmp file.
But due to plain C code response is not proper. So want to display output file by getting CDC/HDC so i can see the output directly just after build.
What i have to do.
I am new to VC++. Will anyone please give me a complete project file details from which i can understand it and do certain modification. time is less and so need it urgently. Please Help me.
Thanking you in advance.
Vinay
|
|
|
|
|
Use ::LoadImage to load the file you've just written from disk, then select it into a HDC. Use GetDC(NULL) to get the DC of the screen and you can BitBlt your new bitmap direct to the screen.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|
u mean to say by LoadImage i can directly load the my previously built .cpp or input bitmap file. Will you please give me some example code for doing this. It will be agreat help to me.
Thanking you in advance
Binay
|
|
|
|
|
jas - I need to load up the msdn. It's msdn.microsoft.com for your future reference.
HBITMAP MyBitmap = ::LoadImage(
MyhInst, // Assuming you're not using MFC, you'll need to store your instance handle and put it in here, or try NULL
"c:\mybitmap.bmp", // I presume you have this in a variable already....
IMAGE_BITMAP,
0, // These can be set to the x and y values desired if you wish.
0,
LR_CREATEDIBSECTION | LR_LOADFROMFILE);
this will load the bitmap file from disk into a HBITMAP. Now you can create a DC, select it in, and draw it onto the screen.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm thinking of getting married for companionship and so I have someone to cook and clean." - Martin Marvinski, 6/3/2002
|
|
|
|
|