|
Hi all
How can i write Special character in CSV File(like ,)?
Please help me
|
|
|
|
|
Hi,
You may use the separator parameter of a std::ostream_iterator , for instance:
#include <iostream>
#include <iterator>
int main()
{
int vals[] = {1, 2, 3 ,4, 5};
std::copy_n(vals, 5, std::ostream_iterator<int>(std::cout, ","));
}
cheers,
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
Thanks for reply
I use like this
CStdioFile test;
CString itemtext="ABC,123";
CString itemtextm="1";
if (test.Open"C:\\Test.csv"CFile::modeCreate | CFile::modeWrite | CFile::modeNoTruncate))
{
test.Seek(0,CFile::end);
test.WriteString("Name");
test.WriteString(",");
test.WriteString("Class");
test.WriteString("\n");
.WriteString(itemtext);
test.WriteString(",");
test.WriteString(itemtextm);
test.WriteString("\n");
test.Close();
}
Now problem is that itemtext comes with two column.I want to Write this(itemtext)in Single Column. Please help me
|
|
|
|
|
With your code the output should be Name,Class\nABC,123,1\n. What output do you want with the same input?
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
As far as I understood, he wants the string "ABC,123" be considered as one column in the CSV file. But this has nothing to do with C++, rather with the CSV syntax in which he has put double quotes around the field.
|
|
|
|
|
I am not very good at guess games
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
Well, spending a lot of time in the programming forums improves that a lot...
|
|
|
|
|
This has nothing to do with C++ but rather to the CSV format. If you google for the format specification (see here[^] for instance) you can see that:
Fields with embedded commas must be enclosed within double-quote characters.
|
|
|
|
|
|
How is the correct way to subclassing my CHeaderCtrl class into my CListCtrl ?
Let say I have CListCtrlEx , ( public of CListCtrl ) , and I have a CHeaderCtrlEx class ( public of CHeaderCtrl ) and I need to subclassing into CListCtrlEx ... how it's correct way to do it ?
I tell you for what I need subclassing : I want to improve my CListCtrlEx class to CHeaderCtrlEx class from here[^] and saw there , that CHeaderCtrlEx is subclassing into CListCtrlEx ...
|
|
|
|
|
For a dialog it could be performed as following :
BOOL CYourDialog::OnInitDialog()
{
BOOL bResult = CDialog::OnInitDialog();
CHeaderCtrl* pcOriginalHeader(m_cListCtrl.GetHeaderCtrl());
if (pcOriginalHeader->GetSafeHwnd()) {
m_cHeader.SubclassWindow(pcOriginalHeader->GetSafeHwnd());
}
return bResult;
}
They sought it with thimbles, they sought it with care;
They pursued it with forks and hope;
They threatened its life with a railway-share;
They charmed it with smiles and soap.
|
|
|
|
|
And what if I create the list control dinamicaly ( with Create ) ?
int CTestList3View::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if(CListView::OnCreate(lpCreateStruct) == -1)return -1;
DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_TABSTOP | LVS_REPORT;
BOOL bResult = m_List1.Create(dwStyle,CRect(0,0,0,0),this,IDC_LIST1);
return (bResult ? 0 : -1);
}
|
|
|
|
|
Then - place the subclassing lines previos to the 'return' line...
They sought it with thimbles, they sought it with care;
They pursued it with forks and hope;
They threatened its life with a railway-share;
They charmed it with smiles and soap.
|
|
|
|
|
It goes with PreSubclassWindow() right after Create() !
Thanks for solution ! Thanks all of you !
|
|
|
|
|
|
I use App Wizard to create a new MFC ActiveX Control. On the "Control Settings" page, I select SysListView32 for "Create control based on:". But now, I don't know how to add new column and item to the list view. I try to get the handle by using GetSafeHwnd() and then send LVM_INSERTCOLUMN message but nothing happens.
modified on Thursday, December 16, 2010 4:09 AM
|
|
|
|
|
Assuming the handle is correct, this approach seems okay. Maybe the LVCOLUMN wasn't filled correctly?
Try something like this:
LVCOLUMN col;
col.mask = LVCF_TEXT|LVCF_WIDTH|LVCF_FMT;
col.pszText = "Name";
col.cx = 200;
col.fmt = LVCFMT_LEFT;
SendMessage(hwndList,LVM_INSERTCOLUMN,0,(int)&col);
modified 13-Sep-18 21:01pm.
|
|
|
|
|
Thanks, I tried your code but nothing displayed. Can anybody show me step by step to add new columns and items? I use VS2005!
|
|
|
|
|
--------------------------------------------------------------------------------
Hi ALL
I created a new dialog resouce. Now I want to remove it from the project. How to do this.
Thanks
|
|
|
|
|
Just select that dialog (IID_DIALOG1)in Resource view and press the delete button. Thats it....
|
|
|
|
|
Hi,
I have to Store CMap Object with "Key Name" as CString and "Key Value"
as CArray Object.is it possible?
|
|
|
|
|
|
Hi all,
I have made a application in which i have a list control. Suppose that list control has 5 items when i press a button a thread is started using AfxBeginThread. Inside that thread i have made a for loop. That for loop pick up items from list and do some processings say a,b,c. These processing use functions of some other classes to get their result. I have a made a second button, by clicking on that second button i stop my thread using ::TerminateThread(obj,NULL);. My problem is when i click on second button my thread doesn't stop say if it is doing processing b first it will finish doing b then c then it will stop. I tried using ::TerminateThread(obj->m_hThread, NULL); but it also creates problem after some time i.e if i start and stop my processing for 3 times it will not start the process third time.
I don't know what to do?
Can anybody help me in this?
Thanks in advance
|
|
|
|
|
1. Show us the relevant code.
2. Never use TerminateThread() .
It was ever thus, the Neophiles will always rush out and get 'The Latest Thing' at a high price and with all the inherent faults - Dalek Dave.
|
|
|
|
|
As Rajesh said, never never use the TerminateThread function, unless you perfectly know what you are doing. Here[^] is an excellent article about threads, a bit long but it is definitively something to read if you want to start using threads.
Taken from the article:
Three functions immediately present themselves for purposes of pausing or shutting down a thread: the SuspendThread and ResumeThread methods (and their underlying API calls, ::SuspendThread and ::ResumeThread) and ::TerminateThread. Assume, for all practical purposes, except in some very limited contexts, these functions do not exist. Using them will almost always get you in trouble.
|
|
|
|