|
|
It sounds like what you want is live display of file contents in real time. Technically that is impossible but in practice if you back off your requirements a little you may be able to get it to work.
There are two basic approaches:-
1 A loop which reads the file, displays the contents and pauses for a short time then goes round again. Depending on the size of the file and complexity of the display you may be able to get several updates per second or an update every few seconds. Either way your processor usage is liekly to be 90%+ and unhappiness may result.
2 Read the file once and display it. Then register for File Change Notifications from the operating system and when you get one that relates to the file you're interested in re-read and re-display it. This is more code and less portable but probably a better way to go.
If data integrity is an issue you're going to need to lock the file while reading it, unlock it when you're finished and perhaps carefully synchronise your usage. Other tricks like reading large blocks at a time from the file that match the native file block sizes, temporarily boosting the priority of the reader thread etc could be used to improve the overall effectiveness but in the end this is not a job which fits comfortably with the machine architectures we have inherited from the days of batch processing and single threaded operation.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
You can read file update its values and then return this new values to file but answer to your question is no.
|
|
|
|
|
hello,
I remember reading once that a CString object has a maximum amount of characters it can hold, I just can't seem to find how much that is.
Does anybody know how much that count is? If you have a URL with that info that would also be neat.
Greetings,
Davy
|
|
|
|
|
sure, check it's index type... you'll figure out how far it can go (so, how many TCHARs a CString can hold)
|
|
|
|
|
From memory 32767. Two things to note-
The best way to confirm this is to look at the CString source.
The other thing that doing this will confirm for you is that if you're going anywhere near needing to know what the limit is you shouldn't be using CStrings. A preallocated 32K or 64K character buffer will likely be serveral times faster, depending on what you're doing with it of course, and the Win32 API and MSVCRT have a vast array of string functions that operate directly on character arrays. Good luck.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
are you sticking to Windows 3.1 with MFC 3 ??
and suggest to use std::string rather than allocating a 32K buffer ! WTF !!!
|
|
|
|
|
std::string is fine if you don't care how the code you're using works. To most developers it's still unreadable gibberish with inadequate usage documentation of precisely the 'how much can it hold' type that the OP is interested in. I code on everything from Windows 3.11 to Vista and on CE in what is still, essentially, MFC 3, have written my own replacement CString class and have written a commercial inline parser generator which uses preallocated 64K text buffers, simple, reliable, consistent, fast and easy to understand. So yes if someone is struggling with determining a size limit from the CString code and dealing with 32K+ lumps of text data then I think simple buffers are good advice. KISS was the first and last thing my C++ lecturers ever taught me.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Thanks for the reply.
The required space is luckily not really near the 32K. It's just that I have a bug with some rather big strings 9+K not passing over a socket connection and I just wanted to make sure that the CString was not the cause of it.
Greetings,
Davy
|
|
|
|
|
GDavy wrote: It's just that I have a bug with some rather big strings 9+K not passing over a socket connection
String length isn't the problem, but what's going on with your sockets?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Matthew Faithfull wrote: From memory 32767.
Sounds like you need a memory update.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
My 250TB is just fine. If only I could find the runtime to re-index it
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
because of implementation: MAX_INT - 1 = 2^32 - 1
Greetings from Germany
|
|
|
|
|
Can you say why do you need to max length of CString,please?
|
|
|
|
|
hi, everyone! i add my own button in windows explorer (windows vista), but i want to put on my button bmp picture, but vista style glass blur my bmp picture. how can i avoid it? how can i control relationship between parent & child windows in case of glass?
I use dwmapi , but it doesn't help me.
Thanks for any help.
|
|
|
|
|
I have exceptions being thrown from two locations within my code, both of them are predefined tree view macros.
TreeView_GetItemRect()<br />
TreeView_GetItem()
If I change the first macro to it's SendMessage() equivlent, the exception is no longer thrown, but as for the second macro I just cannot get it working as it should.
Has anybody come across this before? Google has been of little help to me.
Waldermort
|
|
|
|
|
Go to your compiler debug setting and turn on, "break on 1st exception" for all exceptions type.
Run the program again from the debugger and cause the exception to get thrown.
As soon as the exception is thrown, your code will break and you will be able to tell from the call-stack who is throwing the exception! Inspect the code and figure out why this is happening... are you doing something wrong? did you fail to init something? etc, etc.
You will need to do some work, hope this helps!
---
Yours Truly, The One and Only!
web: devmentor.org
Design, Code, Test, Debug
|
|
|
|
|
It was a bug in my own code ( no surprises there ). I wasn't correctly checking the hWndFrom member within the WM_NOTIFY handler which ended up causing the code to do a custom draw on the incorrect window.
Waldermort
|
|
|
|
|
Always feels good to find the bug
---
Yours Truly, The One and Only!
web: devmentor.org
Design, Code, Test, Debug
|
|
|
|
|
How are you calling them?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
The problem was due to casting the LPNMHDR into a control specific struct without first checking which control sent the message. A novice mistake which I am highly embarassed about
Waldermort
|
|
|
|
|
Thats to little to understand your problem. Most common problem of treeview issue are that the handles or other parameters are invalid.
Greetings from Germany
|
|
|
|
|
Hi friends,
I have a query regarding Menu.
My project is a Dialog Based Application. It contains a menu which contains 7 fields (top level menu like File, Edit, View, Favorites etc). Each toplevel field doesn't have any menu items or sub-menus. I want to disable some of them at run-time based on an event like pressing a button control etc.
Please help me.....
Thanks in advance
Sairam
|
|
|
|
|
Try GetMenu()->EnableMenuItem( 1, MF_GRAYED | MF_BYPOSITION );
- NS -
|
|
|
|
|
I am not sure, but in View/Doc programms. The menu depends on the active window. If the active window doesn't have a function of the menu in it, then the menu option is grayed automatically.
In the worst case, you can design more than one menu, and switch between them according to the actual window.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|