|
You can create an event where-ever you like, so long as the object defines the event, or you're writing or wrapping the object in order to cause it to fire. For example, if you write a class that encapsulates a hash table, you can define an event that your class will fire, but I don't believe that hash tables define such an event.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
<br />
private: System::Void menuOpenFile_Click(System::Object * sender, System::EventArgs * e)<br />
{<br />
StreamReader* InputStream;<br />
OpenFileDialog* openFileDialog1 = new OpenFileDialog();<br />
<br />
openFileDialog1->InitialDirectory = S"c:\\" ;<br />
openFileDialog1->Filter = S"txt files (*.txt)|*.txt|All files (*.*)|*.*" ;<br />
openFileDialog1->FilterIndex = 2 ;<br />
openFileDialog1->RestoreDirectory = true ;<br />
<br />
if(openFileDialog1->ShowDialog() == DialogResult::OK)<br />
{<br />
if((InputStream = openFileDialog1->OpenFile())!= 0)<br />
{<br />
txtBoxSource->Clear();<br />
<br />
<br />
<br />
String* lineOfText = InputStream->ReadLine();<br />
<br />
while(lineOfText != NULL)<br />
{<br />
txtBoxSource->Text = <br />
String::Concat(txtBoxSource->Text, lineOfText, S"\r\n");<br />
<br />
lineOfText = InputStream->ReadLine();<br />
<br />
}<br />
<br />
<br />
InputStream->Close();<br />
}<br />
}<br />
}<br />
<br />
This program invoke a open file dialog. Now when I select a file
in the open file dialog, how do I read it? I used StreadReader,
but I got an error saying that it can't convert from System::IO.Stream
to System::IO.StreamReader.
I want to read the file and put it to the text box named txtBoxSource.
Thanks
-----------------------------
C++ without virtual functions is not OO. Programming with classes but without dynamic binding is called "object based", but not "object oriented".
|
|
|
|
|
Hai Alex,
you can solve the problem with this help of FileStram class
FileStream* fs;
StreamReader* InputStream;
OpenFileDialog* openFileDialog1 = new OpenFileDialog();
if(openFileDialog1->ShowDialog() == DialogResult::OK)
{
fs=new FileStream(openFileDialog->FileName,FileMode::Open);
InputStream=new StreamReder(fs);
//Then done your reading using InputStream
}
NB: please include using namespace System::IO;
|
|
|
|
|
|
If you can't do these questions, then either your teacher is useless, you're really dumb, or you spent the classes trying to look up the skirt of the girl sitting next to you. To establish which of these is the problem, ask some of your fellow students, and if all are lost, talk to the school about it. Otherwise, try paying attention in class.
Also try paying attention online - this is the Managed C++ board, not the C++ board.
If you're still stuck, try having a go, and asking more specific questions than 'please do my homework because I can't be bothered'.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
hi,
i am pulry into c# for the last one and half years. Now i want to learn Managed C++. Which book is good enough to achive my intesion.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
hi,
if u know c++ and C# ( i mean CLR ,CTS ).It's Very easy to learn MC++.so u don't have to spend much time on it.u just go on coding in c++ and use classes which u used in c#.
There's lots articles submitted here.so go through it.
to start with select vc.net and then project type managed c++ application.so u are ready to code in c++.
i prefer wrox series for MC++.
by
baijumax;P
|
|
|
|
|
Hello,
I'm having trouble trying to use an access declaration. i.e I'm trying to manually change the access level of an inherited member (previously public) to protected. How do I do this in MC++?
void
|
|
|
|
|
During a design of my project there is no errors appear and then an unkown error apprear without any logical reasons or code error.
the following link has the picture of the message appear.
http://www.arabmoheet.com/Error.JPG[^]
thanks.
Waleed Eissa
|
|
|
|
|
hi...
can anyone help me wiritng c++ program that should compile and run on unix
the program does the following
1. Forks 3 child processes in parallel
2. child 1 prints : Hi, nice to see you!
child 2 prints : the weather is nice today!
child 3 prints : have fun !
3. waits on each child to finish
4. prints "see you later
thanks
aravind
|
|
|
|
|
Alright i have to write this code that is supposed to calculate the gardes of 10 students and output the highest average abd the student Identification number of the person with the highest average.I am stuck and so is my whole class so please help this is what i ahve so far.Please someone save my life
// This is the main project file for VC++ application project
// generated using an Application Wizard.
#include "stdafx.h"
#using <mscorlib.dll>
#include <tchar.h>
using namespace System;
char grade(int id, int t1, int t2);//function prototype
// This is the entry point for this application
int _tmain(void)
{
//declaration
char grade;
int t1,t2,tot,avg,max,high_avg_id,id,i;
max=0;
//Processing phase
for (i=1;i<=10;i++)
{
Console::WriteLine(S"Please enter your Student Id: ");
id = Int32::Parse(Console::Readline());
Console::WriteLine(S"Please enter Test one score: ");
t1 = Int32::Parse(Console::ReadLine());
Console::WriteLine(S"Please enter Test two score: ");
t2 = Int32::Parse(Console::ReadLine());
tot = t1 + t2;
avg = tot/2;
if (max < avg)
{
max = avg;
high_avg_id = id;
}
if (avg >= 90)
grade = 'A';
else
if (avg >= 80)
grade = 'B';
else
if (avg >= 70)
grade = 'C';
else
if (avg >= 60)
grade = 'D';
else
grade = 'F';
}
return 0
}
char grade
|
|
|
|
|
// Written By Baiju Max
//EMail:- Baijumax@gmail.com,baijumax@yahoo.com
hi man,
enjoy coding .see below solution for u r problem.
#include "stdafx.h"
#using <mscorlib.dll>
#include <tchar.h>
using namespace System;
int _tmain(void)
{
int nMark1(0),nMark2(0),nStudentID(0),nCurrentStudentID(0);
float flAvg(0),flMaxAvg(0);
String* strGrade = new String("No Grade");
//Read The Input From The User
for ( int iIndex = 0 ; iIndex < 2 ; iIndex ++ )
{
Console::Write(S"Pl's Enter The Student ID:");
nCurrentStudentID = Int32::Parse(Console::ReadLine());
Console::Write(S"Enter The Test One Score:") ;
nMark1 = Int32::Parse(Console::ReadLine());
Console::Write(S"Enter The Test One Score:") ;
nMark2 = Int32::Parse(Console::ReadLine());
//Now Caculate Avg
flAvg = (float) (nMark1 + nMark2 )/ 2 ;
if( flMaxAvg < flAvg )
{
flMaxAvg = flAvg;
nStudentID = nCurrentStudentID;
// Now Calculate The Grade
if ( flMaxAvg >= 50 && flMaxAvg < 60 ) //D- Grade 50-59
{ strGrade = "D" ;}
else if ( flMaxAvg >= 60 && flMaxAvg < 70 ) // C- Grade 60-69
{ strGrade = "C" ;}
else if ( flMaxAvg >= 70 && flMaxAvg < 80 ) // B- Grade 70-79
{ strGrade = "B" ;}
else if ( flMaxAvg >= 80 && flMaxAvg < 90 ) // A- Grade 80-89
{ strGrade = "A" ;}
else if ( flMaxAvg >= 90 && flMaxAvg <= 100 ) // S- Grade 90-100
{ strGrade = "A" ;}
else { strGrade = "F" ; }
}
}
Console::Write(S"Student ID Is:" );
Console::Write(nStudentID.ToString());
Console::Write(S"Highest Avg is:");
Console::Write( flMaxAvg.ToString());
Console::Write(S" Grade:");
Console::Write(strGrade);
Console::ReadLine();
return 0;
}
by
baijumax
|
|
|
|
|
your code gave me an error:LNK2019 unresolved external symbol_main refferenced in function_main CRT startup
fatal error LNK1120: 1 unresolved external
|
|
|
|
|
Hi,
I believe problem with your project file. do one thing
start vc.net then select managed c++ Application.
it will create main method;
cut and paste the code inside sample codes main.
by
baijumax;P
|
|
|
|
|
Hey thanks but i was able to resolve the issue.It was a very simple one at that and was totally my mistake.I for got to #include tchar.h
|
|
|
|
|
Don't do peoples homework for them, it doesn't help them in the long run. Also, u and r are letters, they are not words.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
hi,
Sorry About That.I accept your comment.
by
baijumax
|
|
|
|
|
the following text is:
Note that code is instantiated only for member functions that are called. For class templates, member functions are instantiated only when they are used. This, of course, saves time and space. It has the additional benefit that you can instantiate a class even for those types that cannot perform all the operations of all the member functions, as long as these member functions are not called. As an example, consider a class in which some member functions use the operator < to sort elements. If you refrain from calling these member functions, you can instantiate the class template for types for which operator < is not defined.
what it means?please tell me,thx.
|
|
|
|
|
What bit don't you understand ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I'm using C++ and new to winsock. i'm trying to create a program that sends emails with attachments. FIRST, with WINSOCK, how do i SEND EMAILS and ATTACHMENTS over a server that allowes annoymous emails (eg hotmailmailserver), what information needs to be sent and received, ANY HELP would be nice thanX
yee
|
|
|
|
|
Hi there,
I've created a cli app that allows a user to control windows services. Just a quick question - while trying to "break" the app i noticed that if i performed a pause command on a service that couldnt be paused - the app would just hang. I guess my question is, Is there a way to query the service to find out what control commands it can accept? Any sample code on this would be greatly apprecaited.
Thanks
|
|
|
|
|
i am trying to open this file it won't open, my file name is outdate and i have name and lastname in it. it can't open it that i be able to read throw it.
# include <fstream>
# include <iostream>
# include <fstream>
main()
{
char age;
char name;
const char outfile[20] = "outdata.txt";
ifstream in;
in.open("outdata.txt");
if (!in)
cout << " error in opening: " << endl;
else
cin.get(name);
}
|
|
|
|
|
Is the file in the same folder as your exe ? Also, I can't see your #includes, but the lack of any reference to namespaces makes me thing you've included iostream.h. Don't, this is not valid C++. Use iostream instead ( no .h ). This means you'll need to scope namespace std.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hi,
My purpose is:
- Write a service
- This service must create thread on every process (on every WindowStation)
Problem is:
CreateRemoteThread in MSDN wrote:
Terminal Services isolates each terminal session by design. Therefore,
CreateRemoteThread fails if the target process is in a different session
than the calling process.
If have many users is loging then have many session. I want to
CreateRemoteThread of every session.
My solution is:
- The first, find window station of the process which I must create thread
on it (use WTSEnumerateProcesses)
- The second, use SetProcessWindowStation to assign a window station to the
calling process (is my service). Result my service will operation on the
window station which I must create thread on a process on it.
- Then, use CreateRemoteThread to create thread. Now, CreateRemoteThread is
successful.
Is this solution true ?
Thank in advance.
PTM.
n4_t1
|
|
|
|
|
if somebody could give me this pseudocode"algorith that accepts a positive integer nad then reverses and prints the order of its digits e.g. if input is 9038, the output is 8309"
|
|
|
|