|
Due to the fact that CFile does not have a read line implementation you will need to read one character at a time from the stream and look for '\r' once you find that character you have found the end of the line.
Remember on Windows a Line is delimited by \r\n
so after you find a \r you need to skip the next character in the buffer.
Something like this
CFile x;
//Load your File for processing
CString y;
char temp[1];
ZeroMemory(temp, sizeof(temp));
for(int i = 0; i < x.GetLength(); i++);
{
x.Read(temp, 1);
if (x != '\r')
y += temp;
else
{
x.Read(temp, 1); //Skip the next character it should be \n;
//Do something with your new line
}
}
Forever Developing
|
|
|
|
|
We have an application on Solaris and Windows that uses the fopen family of calls to perform file I/O operations. However it was discovered that fopen has a limit of 255 open file handles for a process. We therefore need to replace fopen with C++ fstreams to circumvent this problem. However the MSDN reveals that a fstream object internally uses a basic_filebuf object for stream buffering which in turn uses the fopen family of calls for file I/O. We therefore wrote a test program to validate this fact. Surprisingly however the test program, which uses fstream objects to open files does NOT fail at the limit of 255 but instead goes on to open more than 2000 files. This apparently contradicts with what MSDN says about fstream objects internally using fopen family of calls for file manipulation. Can someone provide me some pointers in this regard?
|
|
|
|
|
What is it that you are wanting to know? If you needed more than 255 files opened simultaneously and your test application proved that more than 2,000 files could be, isn't your problem solved?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I can not directly answer your question, but I have a suggestion.
You can load the visual studio and the source code to the C runtime library and maybe see what the basic_filebuf calls are doing. The fopen calls eventually use the CreateFile API, but because of using the pseudo file handles, you run into the problem with a file open limitation. Maybe the other calls using the basic_filebuf do something different to avoid the limitation. After examining the source code, you can assure yourself that the MSDN is indeed wrong.
|
|
|
|
|
What OS are you on? The MSDN infomation may give you the maximum number for a windows 9X machine. MSDN seems to always state the lowest common denomionator when giving information.
The only way to know if your solution is viable is to try it out on all the OS's it will be deployed on. Noting Service Pack Level and Version of IE installed.
Best of Luck
Forever Developing
|
|
|
|
|
int _setmaxstdio(int newmax) is your friend . On .NET 2003 fopen defaults to 512 simultaneously open files which can be increased to 2,048 using this method. fopen() etc. are low-level C routines that C++ fstream is built on top of, therefore it probably just sets the default to the upper limit when it initialises 'for maximum simplicity'.
Hope that helps ya,
Al.
"When I left you I was but the learner, now I am the master" - Darth Vader
|
|
|
|
|
Thanks guys for reply.
Thank you Alan Chambers for giving right pointer.
|
|
|
|
|
Hello to all.
I'm a "Last-becomers" in VC++.
During my first try using MFC and VC++ ,I found this linker error.
------------------------------------------------------------------------
Linking...
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
---------------------------------------------------------------------
What must I do to solve this problem?
My program isn't an application created by the MFC wizard.
It is small and i post it for let you know the caos that I had create.
-----------------------------------------------------------------------
MyFirst.h
class CMyFirst : public CWinApp
{
public:
virtual BOOL InitInstance();
};
//the window
class CMyMainWnd : public CFrameWnd
{
public:
CMyMainWnd();
protected:
afx_msg void OnPaint();
DECLARE_MESSAGE_MAP();
};
-------------------------------------------------------------------------
MyFirst.cpp
------------------------------------------------------------------------
#include<afxwin.h>
#include"myFirst.h"
CMyFirst first;
BOOL CMyFirst::InitInstance()
{
m_pMainWnd = new CMyMainWnd();
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return true;
}
BEGIN_MESSAGE_MAP(CMyMainWnd,CFrameWnd)
ON_WM_PAINT()
END_MESSAGE_MAP()
CMyMainWnd::CMyMainWnd()
{
Create(NULL, _T("My beautiful application"));
}
void CMyMainWnd::OnPaint()
{
CPaintDC *dc=new CPaintDC(this);
CRect *rect=new CRect();
GetClientRect(rect);
dc->TextOut(30,30, CString (_T("La prima scemenza stucchevole")));
delete dc;
}
----------------------------------------------------------------------
I'm waiting for responses...
Thanks a LOT..
Jenie_net
|
|
|
|
|
I am not sure which IDE you are using but you need to include nafxcwd.lib in your linker settings. Unresolved external sysmbols come from the linker not being able to find the implementation of the function in the header file.
I am using MSVS 2003. So I go to Project on the file menu then Properties. I then select linker from the listview. Then under general there is an Option for additional Library Directories. Add the path to nafxcwd.lib. This should fix it.
Best of Luck
Forever Developing
|
|
|
|
|
Micheal Dunn has done a nice job giving answers to FAQ's. Read the C++ forum FAQ[^] and you'll find your answer..
Multiply it by infinity and take it beyond eternity and you'll still have no idea about what I'm talking about.
|
|
|
|
|
Looks like your linking multi-threaded libraries to a single-threaded app to me...
|
|
|
|
|
Hello Techies,
I had a splitter window. And I want to set the size of the each splitter window at the initialization only. I want to know the widht and heigth of each splitter window. I am not able to get any code. pLease help regarding the above matter.
Thank you,
Neelesh J Jain
|
|
|
|
|
Since CView is derived from CWnd and your views are derived from CView simply try the GetWindowRect() member of your view class.
MS
|
|
|
|
|
I had already used the GetWindowRect() function, But I need to get the Width so that I can display one splitter of 1/4 of the application window and remaining 3/4 for another splitter.
Neelesh Jain
|
|
|
|
|
OK !
Assuming rightPane and leftPane are your two view classes in the splitterWnd:
RECT rectAppl;<br />
long heightAppl=0;<br />
long widthAppl=0;<br />
<br />
AfxGetMainWnd()->GetClientRect(&rectAppl);<br />
<br />
heightAppl=rectAppl.bottom-rectAppl.top;<br />
widthAppl=rectAppl.right-rectAppl.left;<br />
<br />
rightPane.SetWindowPos(&wndBottom, 0, 0, widthAppl/4, heightAppl, SWP_NOMOVE|SWP_NOZORDER);<br />
leftPane.SetWindowPos(&wndBottom, 0, 0, (widthAppl/4)*3, heightAppl, SWP_NOMOVE|SWP_NOZORDER);
I think thats what you want to do.
MS
|
|
|
|
|
I use mouse wheel to zoom in/out on my CScrollView. But now on windows xp (previously i used w2k without problems), i get OnVScroll() messages instead of OnMouseWheel(). I cant find a way to catch the wheel and overrule the scrolling behaviour. What the...??
When the scrollbars are off, I get mousewheel messages
When the scrollbars are on, I get vscroll messages
I want to always reveive mouse wheel!
Thanks
|
|
|
|
|
Hi,
Need help in changing the picture buttons of the Control Box i.e. I want to change the "X" (for close) in the Control box to a different image. The Same Applies for "the Square" restore and the "-" for the minimize.
A related issue would be how to change the color of the caption bar?
I am a new developer using Visual studio .net
thx
Kolpia
|
|
|
|
|
|
Ok this is killing me
i dont know much about Msg in the MFC
how to do a hitTest Msg and while the mouse down
mouseX = WindowX && mouseY = WindowY
|
|
|
|
|
What do you want to do ???
MS
|
|
|
|
|
Are you talking about the GetMessagePos() function?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
i want to send MSG in the MFC
like the hit test MSG
blah::OnBlah()
like OnPaint()
|
|
|
|
|
ANDYFA wrote:
i want to send MSG in the MFC
Do you mean SendMessage() ?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
|
Ok, what exactly did you want to know about message maps in MFC, aside from the framework using them to connect messages and commands to their handler functions.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|