|
Then use the debugger to see what happens (e.g. by setting a break point somewhere after the output file has been selected using the CFileDialog ). You might also check if file.Open was successful. But if that fails calling file.WriteString should throw an execption.
|
|
|
|
|
I'll check it!Thank you very mush for your help!!
|
|
|
|
|
Hi all,
How can I give data in a dialog box dynamically? In a previous project I used edit boxes (e.g for 3 conductors) and gave those data separately for each conductor but now I have to give them dynamically and I don't have standard number of conductors and I can't use edit box again. Could you please give me an idea or a good link describing step by step how to create a table in a dialog box dynamically?
Thanks for your time!!
|
|
|
|
|
|
Thanks for your answer! Actually a want to edit the data. I think list box is for displaying data.. :/
|
|
|
|
|
lolici wrote: Actually a want to edit the data. Pity you did not make that clear in your question.
So what exactly are you trying to achieve with this dialog? Please edit your question and add some proper detail, if possible with some code showing where the problem is.
|
|
|
|
|
I have created a dialog box in which I insert data about conductors (resistivity, permeability, diameter etc (electric power systems )) in edit boxes but I have done it only for 3 conductors. I have to insert-edit the number of conductors and then edit their characteristics. But I can't use again edit boxes because this is static. I want something like a dynamic table which will have rows=number of conductors and columns about is characteristic (resistivity, permeability, diameter)and edit them in dialog box. I don't know how to upload my executable to male clear what I have done but here is a part of my code for the static case of three conductors I want another dynamic way to edit data :/
void CInputView::OnLinefeaturesFeatures()
{
CInputDoc* pDoc = GetDocument();
CFeaturesDialog DialogWindow;
DialogWindow.m_DialogCon = m_NumCond;
DialogWindow.m_DialogLayers = m_Layers;
DialogWindow.m_DialogPermeability = m_AirPermeability;
DialogWindow.m_DialogAirConductivity = m_AirConductivity;
DialogWindow.m_DialogAirPermittivity = m_AirPermittivity;
DialogWindow.m_DialogEarthPermeability1 = m_EarthPermeability1;
DialogWindow.m_DialogEarthConductivity1 = m_EarthConductivity1;
DialogWindow.m_DialogEarthPermittivity1 = m_EarthPermittivity;
DialogWindow.m_DialogDepth = m_depth;
DialogWindow.m_DialogEarthPermeability2 = m_EarthPermeability2;
DialogWindow.m_DialogEarthConductivity2 = m_EarthConductivity2;
DialogWindow.m_DialogEarthPermittivity2 = m_EarthPermittivity2;
DialogWindow.m_Dialogfrequency = m_frequency;
if (DialogWindow.DoModal() == IDOK)
{
m_NumCond = DialogWindow.m_DialogCon;
m_Layers = DialogWindow.m_DialogLayers;
m_AirPermeability = DialogWindow.m_DialogPermeability;
m_AirConductivity = DialogWindow.m_DialogAirConductivity;
m_AirPermittivity = DialogWindow.m_DialogAirPermittivity;
m_EarthPermeability1 = DialogWindow.m_DialogEarthPermeability1;
m_EarthConductivity1 = DialogWindow.m_DialogEarthConductivity1;
m_EarthPermittivity = DialogWindow.m_DialogEarthPermittivity1;
m_depth = DialogWindow.m_DialogDepth;
m_EarthPermeability2 = DialogWindow.m_DialogEarthPermeability2;
m_EarthConductivity2 = DialogWindow.m_DialogEarthConductivity2;
m_EarthPermittivity2 = DialogWindow.m_DialogEarthPermittivity2;
m_frequency = DialogWindow.m_Dialogfrequency;
}
}
|
|
|
|
|
A dialog does not seem the optimum choice for this. I would suggest switching to a CListView which allows much greater flexibility.
|
|
|
|
|
Can I edit data in a list view? Could you give me an example please or propose me a good tutorial for this case? cause I am new in programming.. :/
|
|
|
|
|
|
lolici wrote: Can I edit data in a list view?
Off course you can, advantage of using List View over Listbox is that you can create columns and ability of in place editing. Here is one such article ListCtrl Operations[^]
|
|
|
|
|
Good Morning Sir,
can we use std::string for handling names like chinese letters, japanese letters? I mean we can use them for string comparison like "some chinese stuff"=="some chinese stuff" will it work?? Thank you sir for your time excuse my english
|
|
|
|
|
You would need to use std::wstring[^] which handles Unicode characters.
|
|
|
|
|
so sir, using wide strings are the only way? some libraries takes character arrays as their arguments so can we convert these chinese fonts to character array as char* and pass as the arguments?
|
|
|
|
|
It depends what encoding you use for the Chinese characters. If it is Unicode then you need wstring, but if it's UTF8 then you will need to create a new type based on basic_string. Look at the samples in the link I gave you.
|
|
|
|
|
Thank you for your solution sir but the wide character is something like this,
L"F:\\dupelicateFinder\\New folder\\New folder\\检查.jpg"
so I am converting it to the string by the above method described by you,
"F:\\dupelicateFinder\\New folder\\New folder\\检查.jpg"
I've have already found a way to convert the std::string to char* using strcppy so finally I get this,
"F:\\dupelicateFinder\\New folder\\New folder\\检查.jpg"
the same thing as of string, but I have a function( from 3rd party library) which takes char* as an argument so, I have char* value as F:\\dupelicateFinder\\New folder\\New folder\\检查.jpg
but the function shows returns -1(file not found) since the unicode fonts didn't changed from 检查.jpg to 检查.jpg so how to open the file using that function
I have checked the work flow of this function using Debugger by creating the break-points and checked the values using Immediate window.
Below is my code:
template<typename duplicates>
std::string Duplicates<duplicates>::compute_hash(duplicates file_loc)
{
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
std::string narrow_target = converter.to_bytes(file_loc);
char *cstr = new char[narrow_target.length() + 1];
strcpy(cstr, narrow_target.c_str());
std::string hash = CALL_MD5_Function(cstr);
delete[] cstr;
std::cout << hash;
return hash;
}
|
|
|
|
|
As you have discovered, converting the Unicode string to ASCII does not work.
|
|
|
|
|
The function name CALL_MD5_Function indicates that it is calculating an MD5 hash sum. But that algorithm is a binary operation and usually requires passing a byte array and a length. With C/C++ char* pointers are often used to pass byte arrays (using uint8_t* would be better). So a char* is not always an indication for a string type.
You are calculating the hash for file names which use different encodings on different platforms (e.g. UTF-16LE on Windows and UTF-8 on Linux). In such cases you have to know (or define) which encoding has to be used for calculations of the hash sum. Then you have to convert the file name strings to that encoding before calculating the hash sum. If it is used only on a single platform, just cast the wide string pointer and pass the length in bytes (the length is missing in your function call; I assume it is just a wrapper to the real function passing strlen ).
Finally, why do you want to get the MD5 sum of file names?
It is usually calculated for file content which is just binary.
|
|
|
|
|
No, sir the function will get the MD5 of the file itself, not for the names of the files. I am on a windows platform and this function is not going to be used for *nix platforms. so what shall I do sir
|
|
|
|
|
Use a wide string version of that function.
If you have the sources, change the file name parameter to be a wide string and call the wide string version of the used file open function.
|
|
|
|
|
Thank you for your kind help sir, I have modified the function and now it is working! Thank you once again for your time!
|
|
|
|
|
Thank you so much sir for your kind help, I finally found a way. Thank you once again for your time sir.
|
|
|
|
|
You can when using the appropriate char types and encodings.
Use std::string<char> (std::string is a typedef for this) for ANSI and multi byte encodings like UTF-8.
Use std::string<wchar_t> (std::wstring ) for wide character Unicode strings. Note that this is platform dependant. With Windows, wchar_t is char16_t while it might be char32_t on other platforms.
|
|
|
|
|
so sir, using wide strings are the only way? some libraries takes character arrays as their arguments so can we convert these chinese fonts to character array as char* and pass as the arguments?
|
|
|
|
|
It depends on your project settings (Unicode or ANSI / multi byte), the used encoding / code page if not a Unicode project, and what the library supports. If you have a Unicode build (recommended), there is probably also a Unicode version for the library.
If the library does not use the same encoding as your project you have to convert the strings.
|
|
|
|