|
Hello all
I am writing a Multilingual app, which has to run on
ENG, GERMAN, FRENCH and JAPNEESE os. Now what I have
done is , in one app i made 4 resources and change the
resource accordingly.
But I have one doubt? I heard this can be even achived
by writing 4 resource dll ! I am bit confused now
Which is the better way? I found 4 string table in
one app is the simplest way.
pleas put on your sugg and ideas. thanks
|
|
|
|
|
It really depends on the size of the resources and you future intentions. With resource dll's it is possible to load only the required dll cutting back on memory usage, also if there are any translation problems you only need to redistribute a simgle dll rather than the whole exe. I also find it makes coding a lot easier. When the app starts all it needs to do load the correct dll and store the HINSTANCE, all the resource id's are the same so there's no need mess about with the locale.
If you enumerate the dll's on startup, you can also add further translations without adding code to the main exe.
On the downside, each time you want to change a resource, you have to rebuild them all.
|
|
|
|
|
if you want to change only the strings on the GUI interface for example, no DLL is needed, even though you can use Resource DLLs...
basically, you put all your strings in the Resource String Table. then, you set the language of this string table (in its properties). after that, you copy the string table (and tell VC++ its new target language), and translate the strings into the proper language of the table.
in your application, you have to load the strings (by using CString::Format() or CString::LoadString() for example), and nothing more !
the system will be recognized at the program start, and the correct string table will be used.
|
|
|
|
|
What is the difference between a Device Independent Bitmap and a normal BITMAP? Any specific answers?
---
Hakuna-Matada
It means no worries for the rest of your days...
It's our problem free, Philosophy
<marquee behavior="alternate" scrollamount="5" scrolldelay="50">
|
|
|
|
|
With a DIB, the format of the pixels is independent of a display device. .BMP files are DIBs.
By contrast, a device dependent bitmap is specific to a video device. In theory you could do a bitwise copy to the video buffer and have the bitmap display correction. (In theory; in reality, video devices often use complex layer that precludes actually doing this.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
DIBs have enough information for it to be displayed on any device (printer, screen, etc). That is information such as palettes, RGB/CMYK values, gamma values, etc. A device dependent bitmap *may* be contain enough information to be displayed on another device, but is not required to. The best example of a dependent bitmap is one that uses a palette. Without the palette, the bitmap is at best an array of random bytes for any other use...
--
Mit viel Oktan und frei von Blei, eine Kraftstoff wie Benziiiiiiin!
|
|
|
|
|
hey all,
In my code, the data gets read via USB in a buffer.
i need to save this buffer to a file/ location in my PC (eg., C:/Documents/file1) everytime new data is received.
The file name has to be different everytime new data is read.
how do i do it?
can anyone help with some code snippet or the logic or the functions to be used to achieve this.
Thanks in advance.
|
|
|
|
|
Inorder to make the file name different add curent date and time as suffix for a phrase
say file1_mmddyyyhhmmss
|
|
|
|
|
thanks for the suggestion.
But i need to know how to store the buffer in a file?
|
|
|
|
|
wat is the real problem ?
to read USB or to save the read buffer ?
|
|
|
|
|
i can read usb--no problem in that.
But how do I save the read buffer in to a file of desired location.?
|
|
|
|
|
sorry 4 delay
pBuff = USBReadBuff; // where pBuff and USBReadbuff are char*
CFile TestFile;
CString csFileName = C:\TestFile.txt; // csFileName is the path and name where u want to create the file
TestFile.Open( csFileName, CFile::modeCreate | CFile::modeWrite ))
TestFile.Write( &pBuff, no of bytes )
Is this ok for u
RinuRaj
|
|
|
|
|
thanks very much. I will try now in my program.
Can u also suggest how to have a different file name each time new set of data is received from USB.?
|
|
|
|
|
This is one way. It's based on Rinu_Raj's suggestion (file1_mmddyyyhhmmss)
CString csFileName;
CTime ct = CTime::GetCurrentTime();
csFileName = "file1_" + ct.Format("%m%d%Y%H%M%S");
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
thanks. When I tried the code in my program, it fails giving
:Debug assertion failed in filecore.cpp line238.
which is the CFile::Write() function.
the line is:
ASSERT(m_hFile != (UINT)hFileNull);
how to solve?
|
|
|
|
|
Did you acually open/create the file before trying to write the data?
See this suggestion[^]
Another thing, it's always wise to close a file manually, even if the CFile destructor does it for you....
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
i did exactly this:
CFile TestFile;<br />
CString csFileName = "C:/Documents/TestFile.txt"; TestFile.Open(csFileName,CFile::modeCreate | CFile::modeWrite);<br />
TestFile.Write(&Rx_Buf,3000);
what needs to be done?
|
|
|
|
|
Check the return value from the TestFile.Open call, such as:
<br />
CFile TestFile;<br />
CString csFileName = "C:/Documents/TestFile.txt"; <br />
if(TestFile.Open(csFileName,CFile::modeCreate | CFile::modeWrite)) {<br />
TestFile.Write(&Rx_Buf,3000);<br />
TestFile.Close();<br />
}<br />
else {<br />
}<br />
My guess is that there are no C:/Documents folder.
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
your guess is absolutely correct.
There is no C:/Documents..
I am storing the data values (numbers) in the file. but when I open the file TestFile.txt...i cant read the numbers. its all ASCII i guess.
In what format should I be storing the file as?
|
|
|
|
|
so please read the buffer and convert it in to readable text format then save the files.
RinuRaj
|
|
|
|
|
It depends, partly on the data you got, partly on how you want to represent it in the file.
You say you have "data values (numbers)" in the buffer. What kind of numbers?
How long are they?
One (IMO) good way to get a good grip on data is to do a hex dump of the data, and save the hex dump in the file.
Another way would be to open your saved file with a hex dump program, instead of looking at it with Notepad.
The you will see the values in it.
But I have one question for you. It's about this line of code:
TestFile.Write(&Rx_Buf,3000);
How is Rx_Buf declared? I assume it's an unsigned char[]?
In that case, remove the &-char, like this:
TestFile.Write(Rx_Buf,3000);
Else you will write something very different than your buffer in the file.
Rx_Buf is the same as the address of the first item in the array (Rx_Buf[0]).
So if you write &Rx_Buf, then C/C++ will get the *contents* of Rx_Buf[0] (and possibly following elements in the array), interpret them as an address, and then write the contents of that address to the file. That's not what you want...
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
the values read are 8 bit values (unsigned char). I declare the buffer as unsigned char* Rx_Buf = new unsigned char[3000];
The main purpose of storing the received values in a file is to retreive the file at a later stage and use the data values to plot a graph.
So when Iam reading the file again, I need to have the values as unsigned char for them to be plotted.
Whats the best way I do it?
I changed the &Rx_Buf to TestFile.Write(Rx_Buf,3000);
Thanks very much for that.
|
|
|
|
|
thathvamsi wrote: The main purpose of storing the received values in a file is to retreive the file at a later stage and use the data values to plot a graph.
So when Iam reading the file again, I need to have the values as unsigned char for them to be plotted.
You can do exactly the same thing you do when you write the file (provided you know the size of the buffer written in the file).
Just replace "CFile::modeCreate | CFile::modeWrite" with CFile::modeRead
Like this (not tested)
unsigned char Disp_Buf[3000];
CFile TestFile;
CString csFileName = "C:/Documents/TestFile.txt";
TestFile.Open(csFileName,CFile::modeRead);
TestFile.Read(&Rx_Buf,3000);
testFile.Close();
BUT!!!
Just to be sure, use CFile::typeBinary when you open/create the file.
Else, there is some text conversion (CRLF-combinations) that can mess upp your values.
So, on Create:
TestFile.Open(csFileName,CFile::modeCreate | CFile::modeWrite | CFile::typeBinary);
On Read:
TestFile.Open(csFileName,CFile::modeRead | CFile::typeBinary);
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
i did the same for reading the file.
but I get the "assertion failed" error message in filecore.cpp at
the following line:
ASSERT(AfxIsValidAddress(lpBuf, nCount));
the code that i did is as follows:
unsigned char* Rx_Buf = new unsigned char[3000000];<br />
unsigned char* read = new unsigned char[3000000];<br />
<br />
CFile TestFile;<br />
CString csFileName;<br />
CString csFileName_var;<br />
CTime ct = CTime::GetCurrentTime();<br />
csFileName = "File_" + ct.Format("%m%d%Y%H%M%S");<br />
csFileName_var = csFileName; TestFile.Open(csFileName,CFile::modeCreate|CFile::modeWrite|CFile::typeBinary);<br />
TestFile.Write(Rx_Buf,3000000);<br />
TestFile.Close();<br />
<br />
TestFile.Open(csFileName_var,CFile::modeRead | CFile::typeBinary);<br />
TestFile.Read(&read,3000000);<br />
TestFile.Close();
i delete the two buffers at the end using delete operator.
I tried debugging but in vain. Do u have any suggestions?
|
|
|
|
|
Now you are doing the same mistake as before:
<br />
TestFile.Read(&read,3000000);<br />
Try this instead:
<br />
TestFile.Read(read,3000000);<br />
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|