|
stanlymt wrote: you can use one button as 'default' button and handle the event there.
then I believe his question wrong.. actually that person want currently focused EditBox at the Time of press of enter key
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief And You
|
|
|
|
|
gajendrakashyap wrote: Can you suggest something on obtaining focussed ebox control id number?
when you got pointer to Window you can easily call function GetDlgCtrlID to retrieve it control id
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief And You
|
|
|
|
|
Thanks Alok. Actually i tried that, but misspelt the name of function
I could work from your first clue itself.
Thanks for the help !!
Thanks & regards,
Gajendra
|
|
|
|
|
I have a program that is able to take the numbers out of the .txt if it is just a list of numbers. Problem is, I have a file with Names before the grades. I believe i need to set up another array inside the first one to fill with names. The .txt file will look like:
Name
grade
grade
grade
grade
grade
grade
grade
grade
grade
grade
Name
...
Have 15 Names with 10 grades under each. I guess what i'm trying to do is take the strings out of the file. Is there a way to take the strings(there is a string every 11 lines)
Here is what i have now:
#include
#include
#include
#include
#include
#include
using namespace std;
const int TESTS = 10;
const int STUDENTS = 15;
void displayGrades( int [][TESTS] );
void getGrades( int [][TESTS]);
int main()
{
int data[STUDENTS][TESTS] = {0};
getGrades( data );
cout <<fixed <<setprecision(1);
displaygrades(="" data);
#ifdef="" win32
system("pause");
#endif
return="" 0;
}
void="" getgrades(int="" data[]="" [tests])
{
ifstream="" inputfile;
inputfile.open("gradespring07.txt");
if="" (!inputfile)
{
cout="" <<="" "error="" opening="" file!"="" endl;
exit(="" 1="" );
}
for="" (int="" student="0;" student<="" students="" ;="" student++)
{
for="" test="0;" test
{
inputfile="">> data[student][test];
}
}
}
void displayGrades( int data[][TESTS] )
{
double testTotal = 0.0;
double classTotal = 0.0;
double squared = 0.0;
double var = 0.0;
double sdev = 0.0;
int mxm = data[0][0];
int min = data[0][0];
cout << "\nGrade summary" << endl;
cout << "--------------" << endl;
cout << left << setw(7) << "Student"
<< right << setw(5) << right << "Ex1"
<< setw(7) << "Ex2"
<<setw(6) <<="" "ex3"
<<setw(6)="" "qz1"
<<setw(5)="" "qz2"
<<setw(6)="" "qz3"
<<setw(6)="" "qz4"
<<setw(6)="" "qz5"
<<setw(6)="" "pr1"
<<setw(6)="" "pr2"
<<setw(8)="" <<"averg"="" <<endl;
for="" (="" int="" student="0;" <="" students;="" ++)
{
cout="" left="" <<setw(7)="" +="" 1;
for="" test="0;" tests;="" test++)
{
int="" grade="data[student][test];
cout" right="" <<setw(5)="" <<"="" ";
classtotal="" average="(((data[student][0]+data[student][1]+data[student][2])/3)*0.4)+(((data[student][8]+data[student][9])/2)*0.3)+(((data[student][3]+data[student][4]+data[student][5]+data[student][6]+data[student][7])/5)*0.3);
cout" setw(7)="" endl;
}
cout="" "\n"="" "test="" avg";
for="" (int="" test++)
{
for="" student++)
{
testtotal="" setw(6)="" testtotal="" students;
testtotal="0.0;
}
cout" endl;
cout="" "stan="" dev";
for="" student++)
{
squared="" 2.0);
var="(squared" -="" ((testtotal="" *="" testtotal)="" 15)="" )="" 15;
sdev="sqrt(var);
}
cout" sdev;
sdev="0.0;
}
cout" "max";
for="" student++)
{
if="" (data[student][test]=""> mxm)
{
mxm = data[student][test];
}
}
cout << right <
|
|
|
|
|
So what's your actual problem? Does it fail to compile? Does it crash? Does it just act weird?
Is there a particular part that you know isn't working properly? Have you tried stepping through that part in a debugger?
If you can isolate the particular part that's giving you a problem, let us know, and we might be able to help
|
|
|
|
|
there is no problem with the code that i posted. The problem i am facint is that the posted code will only read a list of integers without a student name. The .txt i need to read from is supposed to have the student name then 10 grades after then another name and another 10 grades. Don't know how to retrieve the name.
Thanks
|
|
|
|
|
I have to use a third part extension dll in my vc2003.net project, but to my despond the dll was built with vc6.0. In the book, they say a extension dll should use in a client application with the same version MFC dll. But I want know if there is a solution?
Thanks a lot!
|
|
|
|
|
Link the client application to the old MFC
|
|
|
|
|
Yes, it works. But, is there another way out?
|
|
|
|
|
I'm not sure how safe it would be. If you can link to the extension DLL and it runs then great.
The behavior, at best, would be undefined for any MFC extended classes that you derive from in
your client app though. Old MFC may allocate stuff the new MFC doesn't free, member variables
could be different, etc. Lots of room for things to go wrong
|
|
|
|
|
plus...
Two different MFC frameworks loaded at the same time, global variables for the two are different,
it goes on and on.
|
|
|
|
|
In MSDN, Write() function of CFile class follow:
virtual void Write( const void* lpBuf, UINT nCount );
throw( CFileException );
Remarks
Writes data from a buffer to the file associated with the CFile object.
Write throws an exception in response to several conditions, including the disk-full condition.
But in fact, when disk full and application try write to disk then an unhandled exception occur.(CFileException didn't catch)
What is cause of this problem?
-----------------
Best Regards,
Le Thanh Cong
|
|
|
|
|
Le Thanh Cong wrote: But in fact, when disk full and application try write to disk then an unhandled exception occur.(CFileException didn't catch)
Looking at the CFile::Write() source code, it only throws CFileException (unless maybe you pass
invalid parameters to the function).
How are you catching the exception? Like this?
try
{
file.Write(...);
}
catch (CFileException *e)
{
e->Delete();
}
|
|
|
|
|
I catched the exception follow:
try
{
file.Write(...);
}
catch (CFileException*)
{
AfxMessageBox("xxx");
}
But message didn't display
-----------------
Best Regards,
Le Thanh Cong
|
|
|
|
|
Then the disk isn't full?
Step into CFile::Write() and see if the ::WriteFile(...) call succeeds.
|
|
|
|
|
Thank you, maybe I found cause of this problem.
In normal conditions, CFileException will be thrown.
But in some special conditions, as multi-thread, communication with devices as USB I/O … then other exception has thrown before that.
-----------------
Best Regards,
Le Thanh Cong
|
|
|
|
|
MFC application will be automatically called InitCommonControls() function, so to enable XP visual style we only need add manifest file to resource. That is right or wrong?
-----------------
Best Regards,
Le Thanh Cong
|
|
|
|
|
Ok, this is my 2nd post about C++/CLI.
The answers for the first took me to the right tools needed to learn C++/CLI.
So, I got everything to start to learn C++/CLI: a book, Visual C++ Express Edition and a lot of energy
But, suddenly, a question comes to me and makes me doubt about all this.
Why write with C++/CLI instead of C# in example, (or any .NET language).??
What else I got with C++/CLI??
I understand why to programm in C++, (using MFC, ATL, STL, WTL....) to get a native exe, but I can't see the differents between C++/CLI and C#, (besides the language it self).
What I could see, (maybe I can be wrong), is that it took a lot of headheaches to Microsoft Team to include C++ into the .NET languages, (that's why, first, we have MC++ and then C++/CLI). In other side two languages like C# and VB NET were born and they expose the NET framework naturally.
So, should I spend my money and time to learn C++/CLI?
Do you understand what I mean? (my english, maybe, is not too good enough).
I really appreciate your help.
Demian.
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my telephone."
-Bjarne Stroustrup, computer science professor, designer of C++
programming language (1950- )
|
|
|
|
|
|
In my humble opinion, one of the most important differences is that you may mix native (ISO/ANSI) C++ code with C++/CLI code in the same source file. No other .NET languages can do that.
Best,
Jun
|
|
|
|
|
C++/CLI is great for people who already know how to program in C++. And, if you have a lot of legacy C++ codes lying around, you can easily use them in C++/CLI. As for me, i use C++/CLI to build mixed mode programs, whereby part of the program (the GUI etc) is built using managed C++, and performance critical parts are programmed using pure C++ (compiled as native code). That amount of flexibility is really powerful.
|
|
|
|
|
Don't you think it should compile?
<br />
int val = 44;<br />
int* a = &val;<br />
int* b = &a;
and here comes error (occurs in the third line of the above code):
error C2440: 'initializing' : cannot convert from 'int **__w64 ' to 'int *'
Unless I use "int **__w64" type how can it possibly need a convertion and what is exactly "int **__w64"?
Thanks in advance
watherby 33
|
|
|
|
|
watherby33 wrote: Don't you think it should compile?
No, it should not compile. You are using different levels of indirection.
int val = 44;
int *a = &val;
int **b = &a;
int ***c = &b;
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
|