|
Maybe a dumb question again, but what happens when you debug-run through
DWORD CALLBACK CAutoRichEditCtrl::CBStreamOut(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
{
CString sThisWrite;
sThisWrite.GetBufferSetLength(cb);
CStringW *psBuffer = (CStringW *)dwCookie;
for (int i=0;i<cb;i++) {
sThisWrite.SetAt(i,*(pbBuff+i));
}
*psBuffer += sThisWrite;
*pcb = sThisWrite.GetLength();
sThisWrite.ReleaseBuffer();
return 0;
}
Where does it go wrong ?
~RaGE();
|
|
|
|
|
Hello Everybody
I am getting the user input using "stdin" from a seperate thread running in application "ABC". The problem I am facing is that when the application "ABC" is finished and user didnt enter any input than a deadlock is created between stdin and fflush. because "stdin" is still running in the thread and "fflush" is called by OS when it is terminating the program even I am terminating the threads explicitly. I am facing the same problem on AIX.
Any body have any idea that how can i remove deadlock.
Secondly How can I get the control back from "stdin" or how can i call "stdin" in non blocking mode.
Thanx in advance for your help and suggestions
Best Regards
Moin
|
|
|
|
|
Hello everyone,
I am currently in the progress of enhancing a software which my predecessor designed.
One of the caveats the software has: If there is an error, the software calls a "setErrorMessage"-Function to publish the error to the user. The same is true for warning messages, only that warning messages are collected until the called function either finished or hits an error.
Thats pretty ok for me, I dont think I would have chosen another approach.
Well, what makes this a bad design is that the setters are - each and every time - called with the text for the warning message as an argument.
There are SEVERAL messages that just get repeated all over the software, most notably a "nothing to process"-message, which is set in about 52 different locations, with different spelling, different capitalization, different wording... you name it, its probably in there.
So, I want to replace this with an error lookup table, passing a single number and setting the corresponding error message.
I have, so far, thought of several approaches to do this.
Common ground: I would be overloading "setErrorMessage(const std::string& msg)" with another function "setErrorMessage(const int msgID)" in order to maintain compatibility (there are client-made libs using this functionality).
What I am having a hard time with is selecting a fast and reliable way to store the messages and their IDs.
Any help, ideas, suggestions? Everything is welcome
Cheers,
Sebastian
--
Contra vim mortem non est medicamen in hortem.
|
|
|
|
|
Sebastian Schneider wrote: What I am having a hard time with is selecting a fast and reliable way to store the messages and their IDs.
What's wrong with the string table?
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
Sebastian Schneider wrote: What I am having a hard time with is selecting a fast and reliable way to store the messages and their IDs.
What about the string table in the resource file ?
[Edit] Nevermind, your question was on the last line on my browser and David's answer was on the next page as I answered, so I did not see it. At least, we answered the same ... :-> [/Edit]
~RaGE();
|
|
|
|
|
If you used the Message Tables instead of the string table in the resourcs, then you could use the message compiler, have unique message/error identifiers, and even use FormatMessage API to format your errrors. They could go to the Windows Event Viewer too.
Another advantage of this is your error strings are in a separate DLL (they should be) and it is easier to localize your applciaiton's error strings - just trade out a DLL - no code changes required or rebuild of your main product.
Marriage slows down your coding, a baby slows it down even more!
|
|
|
|
|
And its so easy. I just totally forgot. Its been such a long time since I had to deal with any errors in my software... *cough*
Cheers
Sebastian
Cheers,
Sebastian
--
Contra vim mortem non est medicamen in hortem.
|
|
|
|
|
Hi Friends,
I have developed a dialog based MFC programm. I want to read a text file which contains some encrypted characters....File may be long or may be short.
My problem is I don't know how to read that whole file as right now I use fread() functions to read file in which it terminates when it gets some character even if there are still more data in file. Also I tried to read it using a character by character reading by fgetc(). Still I encounter the same problem.
Is there a way to read whole file till the end of file. And all characters are read. Any function or any example ?
Thankx in advance.
Mahesh
|
|
|
|
|
Amarelia wrote: I use fread() functions to read file in which it terminates when it gets some character even if there are still more data in file
fread() reads a specified number of bytes, and doesn't look at the characters at all:
// read 100 bytes
FILE *fp = fopen(filename, "rb");
BYTE buf[100];
int read = fread(buf, 1, 100, fp);
fclose(fp);
if you want to read the whole file, just keep calling fread(..) until it returns 0 (no bytes read).
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
i think you problem may come from you write in a buffer not large enough.
do this :
1. get the number of characters in the file to be exctracted.
2. allocate your buffer with that number of bytes.
3. read() the totality of the file ; it will never overflow the buffer (considering the memory is correctly allocated)
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VisualCalc 3.0]
|
|
|
|
|
Amarelia wrote: ...it terminates when it gets some character...
Is it encountering an EOF character? If so, you need to open the file as binary, not text.
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
Hello,
Can anyone send me a link to a c++ sample that is able to track all pages sent to a local or network printer from a machine (running Windows XP)?
Thank you,
Regards,
Dan.
|
|
|
|
|
Start here.
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
|
I think micutzu would benefit more from this suggestion.
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
Thank you very much for your comments. I will read both articles and I hope it will help me.
Best Regards,
micutzu.
|
|
|
|
|
In MDI,I want a child window with some text from Main window menu list and also from tool bar?
|
|
|
|
|
|
i run in a very strange c++ compiler problem.
until now i used the definition 'id' which gave me the right value ( = 0x00006964 ).
because i compile under window, mac and linux and the mac gcc compiler complains about wrong 4-byte-characters i added '\0\0id' to the definition which should give in my opinion the same result. but the vc++ and intel c++ compiler generates other values.
'id' = 0x00006964
'\0\0id' = 0x64690000
' id' = 0x20206964
'\40\40id' = 0x64692020
the most interesting things are the last 2 lines. what is the difference between a space written as space or as a esc-character? ... why does the compiler generates swapped values?
that doesn't makes sense to me ... any hints would be great ...
thanks
tilo
|
|
|
|
|
|
it's not the byteorder why i'm surprised. i'm confused because the 3rd line gives another byteorder than the 4th line with the same compiler and machine ...
tilo
|
|
|
|
|
|
e.g.
#define ANY_ID_1 'id' // gives the warning under gcc mac
#define ANY_ID_2 ' id' // gives the same byteorder like 'id'
#define ANY_ID_3 '\0\0id' // has the wrong byteorder
i use the defines as longs ...
cheers
tilo
|
|
|
|
|
the compiler is probably treating '\40\40id' as a numeric literal (which causes the machine's byte-order rules for numerics to get involved).
it probably sees ' id' as a string literal (even though you shouldn't put multiple characters inside single quotes), and ends up doing something like:
char *p = " id";
long f = *(long*)p;
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
hmmm ... strange things happens ...
i tried this one here ...
char *p = "\0\0id";
long f = *(long*)p;
if running this code f results in 0x64690000 ... that's exactly the same what the compiler generates with the constant '\0\0id' .. and that's swapped compared to 'id' which results in 0x00006964 ?!?!?!?!
this is one of the days where i don't understand compilers ... i want that the compiler generates the same constant when i write 'id' and '\0\0id' because this is obviously the same (for me!)
cheers
tilo
|
|
|
|