|
What do you mean exactly by "continuously" ?
Do you mean you want to read the complete file ?
|
|
|
|
|
yep!
In fact I wanna plot a range of x- and y-coordinates onto a graph while reading them in a txt file.
So I used "continuously".
|
|
|
|
|
The Read function returns the number of bytes read. When there's nothing more to read (because you reached the end of the file), the function will return 0.
|
|
|
|
|
|
What's wrong with:
while( file.Read( &str, 3 ) == 3 )
{
}
That will terminate the loop if it can't read 3 bytes from the file.
Cheers,
Ash
modified on Monday, September 6, 2010 12:17 PM
|
|
|
|
|
Aescleal wrote: What's wrong with: while...
The concept is OK, some details are all wrong.
|
|
|
|
|
Don't know what you're taking about!
(Thanks!)
Ash
|
|
|
|
|
No problem.
|
|
|
|
|
Hi
Best solution is listen events and read file after the file has changed.
If you read file continously, you waste CPU time.
If you want to see code sample how to do this, see:
https://gurux.svn.sourceforge.net/svnroot/gurux/GXCom/GXMedias/GuruxFile
GuruxFile is ATL component that listens selected file or folder and notifies when file changed.
Happy coding,
Mikko
http://www.gurux.org
|
|
|
|
|
char str[4];
try
{
CFile file;
....
while( file.Read( &str, 3 ) )
{
}
file.Close();
}
catch(CFileException e)
{
}
|
|
|
|
|
you have got a couple mistakes on the line
file.Read( &str, 3 );
First of all str by itself is provides a pointer, so there is no need to put the ampersand in front of it.
Secondly, you are reading 3 bytes, but your buffer is only 3 bytes. You will have no room for the terminating zero character, although one may be supplied by the file itself.
The code should be:
file.Read( str, 2 );
str[ 2 ] = '\0';
Refer to MSDN for further information
http://msdn.microsoft.com/en-us/library/ctka0kks%28v=VS.80%29.aspx[^]
|
|
|
|
|
Hi,
can anybody point me in a good direction on how this template works? I have not had any luck with the microsoft and boost documentations on this.
I thought it may be used to detect class interface members as in Interface Detection[^], at least that is what I take from the name.
Many thanks!
|
|
|
|
|
Use it to determine if the template parameter is a pointer to a member function. I think the microsoft documentation[^] is rather clear on this. It also gives a few examples.
|
|
|
|
|
Have a look at the source code. It gets a bit convoluted but you can trace through the implementation if you dig enough.
Cheers,
Ash
|
|
|
|
|
Hello !
I debug along time.but isn't success!
it isn't output "Call GetPixel Failed !", but isn't goto the other judgment.
the code like this:
class CTestDlg : public CDialog
{
public:
public:
void TextOutPut(CString str,
HFONT hNew,
HFONT &hOld,
SIZE &szt)
{
CClientDC dc(this);
GetWindowRect(&rt);
dc.SetBkColor(RGB(255,255,255));
dc.SetTextColor(RGB(0,0,0));
dc.SetMapMode(MM_TEXT);
hOld = (HFONT)::SelectObject(dc,hNew);
dc.TextOut(0,0,str);
GetTextExtentPoint32(dc,str,str.GetLength(),&szt);
COLORREF cr;
POINT pt;
for (int i=0; i<szt.cy; i++)
{
for (int j=0; j<szt.cx; j++)
{
pt.x = j;
pt.y = i;
cr = dc.GetPixel(pt);
if( -1 == cr )
{
TRACE("Call GetPixel Failed !\r\n");
}
else if( RGB(255,255,255) == cr )
{
CString str;
str.Format("cur pix position: x=%d y=%d is white.",j,i);
TRACE(str);
}
else if( RGB(0,0,0) == cr )
{
CString str;
str.Format("cur pix position: x=%d y=%d is black.",j,i);
TRACE(str);
}
}
}
}
};
I think this maybe the GetPixel 's parents is wrong.
How to solve this problem ?
Thanks for your reply !
Best regards !
|
|
|
|
|
What is the cr value?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
COLORREF cr
maybe the cr is other color's RGB value.
but I call this functions,so it doesn't be other value,isn't it ?
dc.SetBkColor(RGB(255,255,255));
dc.SetTextColor(RGB(0,0,0));
|
|
|
|
|
Why don't you use the debugger to see what's cr value, at runtime?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
netstat -o -b returns all active connections with PID which is valuable for terminating those consuming network traffic as downloading some updates without user will.
However I've noticed once there is data download happen from internet and yet netstat returns no active connections.
Is there any other functionality that misses something?
Чесноков
|
|
|
|
|
As it is a system administration issue I suppose you'll get better help at the proper forum.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi all,
when i compile my program i get this error
C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\oleacc.h(53) : error C2872: 'IAccessible' : ambiguous symbol
could be 'C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\afxwin.h(1336) : IAccessible'
or 'e:\Program\debug\mso.tlh(2072) : Office::IAccessible'
How can i resolve this
Thanks in advance
|
|
|
|
|
I'm guessing you're automating MS-Office.
If so, use Office::IAccessible .
Otherwise use ::IAccessible .
|
|
|
|
|
this is because IAccessible is declared in both mso.tlh and afxwin.h.
If you want to use IAccessible from mso.tlh, use it as Office::IAccessible.
Or if you need to use IAccessible from afxwin.h, as it doesn't belongs to any namespace there, you have to modify the IAccessible from mso.tlh. You may use,
rename("IAccessible", "msoIAccessible") soon after the #import "....\mso.tlh" statement.
|
|
|
|
|
Hello everybody,
First, thanks in advance to reply my question.
I have (2) threads in my program (MFC) and when I run my program, all operations which I purposed work fine. But the problem is GUI is blocked up, means I cannot click any buttons in the Dialog Box.
Please help if anybody familiar with this issue.
Any helps are appreciated!
BS Mashhur!
|
|
|
|
|
if you're doing work in the main thread and not allowing windows messages to be processed then yes it will lock up and you won't be able to interact with the GUI.
one way to avoid that is to do all your work in the second worker thread and just use the main thread to respond to user inputs and update the UI.
another option is to, while you're doing whatever work you're doing, periodically call the below function.
void RunMessagePump()
{
MSG m;
while (PeekMessage(&m,PM_REMOVE))
{
TranslateMessage(&m);
DispatchMessage(&m);
}
}
So if you're in a tight loop and you call this often your app will remain responsive. The thing to watch out for there though is re-entrance, i.e. the user clicking a button, then while the operation is taking place clicking it again.
|
|
|
|