|
can you give me an example?
how can i give the txt-file a name...etc..???
(the txt does not exist)
thanks a lot.
lucky
|
|
|
|
|
CString MyCString = "The Text";
CStdioFile csf("FileName.txt",
CFile::modeCreate | CFile::modeWrite | CFile::shareDenyNone);
csf.WriteString(MyCString);
Be sure to look up CStdioFile in MSDN.
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
Great!!!!!!!!!!!!!
thank you very much. After it I searched exactly.
lucky
|
|
|
|
|
If you want to use standard C++, the easiest way is this:
#include<iostream>
#include<fstream>
std::ofstream out("c:\myfile.txt");
out << myCString.GetBuffer();
myCString.ReleaseBuffer(0);
Something like that. An iostream inserter for CString is easy to write, I believe I did one in my inserters article. After that, you could just do out << myCString; Actually, that might work anyhow, but I suspect not.
Of course, iostreams adds about 40k to your final .exe, so if you don't care about using standard C++, you can use the MFC classes, which I'm afraid I am not very familiar with.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
my complete program is written in MFC and i think it is better the MFC classes to be used.
do you know links to articles to this topic?
thank you very much.
lucky
|
|
|
|
|
Lucky2002 wrote:
my complete program is written in MFC and i think it is better the MFC classes to be used.
Why ? Do you think they will work better ? The standard C++ classes almost always are better than the MFC alternatives, as well as working outside MFC ( i.e. the reason the MFC offers you a bare bones, no-where near as good alternative is to tie you to MFC and to Windows in general ).
Lucky2002 wrote:
do you know links to articles to this topic?
www://msdn.microsoft.com[^]
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Do you think they will work better ?
i do not think in this way.
i think your idea is very good and i will try it tomorrow.
thank you for the answer.
lucky
|
|
|
|
|
Christian Graus wrote:
Actually, that might work anyhow, but I suspect not.
You are correct, it asserts, that was the first thing I tried. However as you said something like this will work:
#inclide <iostream>
#include <fstream>
using namespace std;
std::ofstream of;
CString m_str;
m_str = "Writing this text";
of.open("test.txt", ios::out);
of << m_str.GetBuffer(sizeof(m_str));
m_str.ReleaseBuffer(0);
of.close();
Nick Parker
|
|
|
|
|
Just to clean this code up a little.....
#include <iostream>
#include <fstream>
std::ofstream of ("test.txt");
CString m_str("Some string");
of << m_str.GetBuffer(m_str.GetLength());
m_str.ReleaseBuffer(0);
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Christian Graus wrote:
Just to clean this code up a little.....
Christian Graus wrote:
And why did you use all of namespace std and then scope it explicitly as well ???
Again, . I was just typing something up quickly, thanks for pointing out some corrections.
Christian Graus wrote:
// you can close it if you like, but being a C++ class, it will do it itself when it goes out of scope.
I do this just out of practice, no other reason because it doesn't hurt.
Nick Parker
|
|
|
|
|
Nick Parker wrote:
I do this just out of practice, no other reason because it doesn't hurt.
You're not wrong. I am in the habit of NOT doing it when I write something quick and dirty. Guess what you need to do to file objects in C# ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
thank you very much, too.
lucky
|
|
|
|
|
thank you very much!!!
lucky
|
|
|
|
|
thanks
|
|
|
|
|
Yes - you hit compile
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
then i get an exe - machine code. not assembly code...
|
|
|
|
|
You can trace into a release build, I believe, and see the assembler. Otherwise, the answer is no.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
I'm using Visual studio .Net now, but I'm pretty sure this is also available in VC6. Under project settings for C/C++ there is an output file section where you can specify to have it output an assembly source listing when building your project.
- Anatari
|
|
|
|
|
Hello,
I have a pop-up menu open when the user right clicks the status bar.. I would like to display the pop-up menu only if the right button up is right over the status bar text (not just anywhere on the status bar).. How could I go about capturing the text area as a CPoint?
Thanks,
Rob
|
|
|
|
|
I write these below program to draw a rectangle which have black frame. In the rectangle have 4 red points and I draw the line between 2 point. So I get the result as this picture
http://www.geocities.com/ooosawaddee3/pic/PointPicture.jpg
In the picture the red point is very small and the line between point is not exactly straight. I want the larger red point and straight line. Do you know how to do that?
pDC->SetMapMode(MM_TEXT);<br />
<br />
pDC->FillSolidRect(origin.x, origin.y, 2000, 2000, RGB(255,255,255));<br />
<br />
int cx = 5;<br />
int cy = 5; <br />
<br />
CPen pen, pen2;<br />
pen.CreatePen(PS_SOLID,2, RGB(0,0,0));<br />
<br />
pDC->SelectObject(&pen);<br />
<br />
pDC->Rectangle(cx,cy,(cx +256), (cy + 192));<br />
pDC->SetPixel(45,10, RGB(255,0,0));<br />
pDC->SetPixel(47,9, RGB(255,0,0));<br />
pDC->SetPixel(79,45, RGB(255,0,0));<br />
pDC->SetPixel(46,120, RGB(255,0,0));<br />
<br />
pen2.CreatePen(PS_SOLID,1, RGB(0,0,255));<br />
<br />
pDC->SelectObject(&pen2);<br />
pDC->MoveTo(45,10);<br />
pDC->LineTo(79,45);
|
|
|
|
|
The image link is 404.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
ooosawaddee3 wrote:
pDC->SelectObject(&pen2);
pDC->MoveTo(45,10);
pDC->LineTo(79,45);
This won't draw a straight line, for a straight line, either the x or y needs to stay the same.
Your rectangle is straight - it has to be.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
hi, just want to capture WM_KEYDOWN for my editbox. yes, it doesnt support WM_KEYDOWN...
so, i guess the only way for this to work is to subclass a editbox control, inherit from both editbox and dialog class?
is this feasible? is there better alternative?
thanks a bunch.
norm
|
|
|
|
|
Hi..
1. Subclass CEdit class. Say CMyEdit.
2. Now map the message WM_GETDLGCODE (OnGetDlgCode())
3. Return DLGC_WANTALLKEYS for the mapped function.
4. Now u will get the key down messages.
Regards,
Rejeesh
|
|
|
|
|
class TaskInfoBase {
....
virtual void setSize(int) = 0;
};
class NewTaskInfo : public TaskInfoBase {
NewTaskInfo() { InitializeCriticalSection(&m_cs); }
~NewTaskInfo() { DeleteCriticalSection(&m_cs); }
void setSize(int);
static CRITICAL_SECTION m_cs;
};
class NewTask : public NewTaskInfo, pubic NewTaskBase {
};
class HttpDownload : public DownData , public CHttpDown {
public:
HttpDownload():NewTaskInfo() {}
void write();
NewTask *m_pTask;
};
//******************************************************************************
// Implement
CRITICAL_SECTION NewTaskInfo::m_cs;
void NewTaskInfo::setSize(int i)
{
EnterCriticalSection(&m_cs); // Exception here .
m_nSize = i;
LeaveCriticalSection(&m_cs);
}
void HttpDown::write()
{
....
m_pTask->setSize(20002); // Enter NewTaskInfo::setSize();
}
|
|
|
|
|