|
|
I suppose you need TCHAR * to const char * conversion. Have a look at [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
crazy_sam wrote: I searchd a lot
I don't think so: I provided you with a link to an excellent article where everything is very well explained.
|
|
|
|
|
I am reading some text content from a .TXT file which I want to display in a Dialog control. I am reading the text using the following Code:
CFile *LogFile =new CFile;
LogFile->Open( GlbFileName, CFile::modeRead | CFile::shareDenyNone, NULL );
CArchive Archive(LogFile,CArchive::load);
oLogFileDisp.Serialize(Archive);
Archive.Close();
LogFile->Close();
m_LogfileContent.ResetContent(); //ListBox Control
for(int i=0;i<mLogFileDataArr.GetSize();i++)
{
CString strOneLine;
strOneLine=mLogFileDataArr[i];
m_LogfileContent.AddString(strOneLine); //ListBox Control
}
//ListBox Control
m_LogfileContent.SendMessage(WM_VSCROLL,MAKELPARAM(SB_BOTTOM,0),NULL);
The sample text content is as follows:
16:48:07 ALARM AIC201 FLUE GAS O2 3.00 10.00 20.51 High
16:48:07 ALARM FIC201 AIR MASTER 272.00 1000.00 0.00 Low
16:48:07 ALARM FIC311 PRM AIR MIL-A 26.00 100.00 0.00 Low
16:48:07 ALARM FIC312 PRM AIR MIL-B 26.00 100.00 0.00 Low
16:48:07 ALARM FIC313 PRM AIR MIL-C 26.00 100.00 0.00 Low
16:48:07 ALARM FIC314 PRM AIR MIL-D 26.00 100.00 0.00 Low
16:48:07 ALARM LIC101 CONDSR HOTWEL 600.00 1400.00 -95.84 Low
16:48:07 ALARM LIC102 DEAER STR TNK 1200.00 2800.00 -250.00 Low
16:48:07 ALARM LIC111 LP HTR 1 LVL 80.00 220.00 -50.00 Low
16:48:07 ALARM LIC112 LP HTR 2 LVL 80.00 220.00 -46.20 Low
16:48:07 ALARM LIC113 LP HTR 3 LVL 80.00 220.00 -46.18 Low
The Problem is the allignment of the numerical values are as straight as they appear above. They appear as follows:
16:48:07 ALARM AIC201 FLUE GAS O2 3.00 10.00 20.51 High
16:48:07 ALARM FIC201 AIR MASTER 272.00 000.00 0.00 Low
16:48:07 ALARM FIC311 PRM AIR MIL-A 26.00 100.00 0.00 Low
16:48:07 ALARM FIC312 PRM AIR MIL-B 26.00 100.00 0.00 Low
16:48:07 ALARM FIC313 PRM AIR MIL-C 26.00 100.00 0.00 Low
16:48:07 ALARM FIC314 PRM AIR MIL-D 26.00 100.00 0.00 Low
16:48:07 ALARM LIC101 CONDSR HOTWEL 600.00 1400.00 -95.84 Low
16:48:07 ALARM LIC102 DEAER STR TNK 1200.00 2800.00 -250.00 Low
16:48:07 ALARM LIC111 LP HTR 1 LVL 80.00 220.00 -50.00 Low
Please suggest me some ways of displaying them properly in a window. If anybody has some code samples provide me.
|
|
|
|
|
Well to format numbers you may use CString::Format method. Anyway your major problem is parsing the line to extract the numbers.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I have already read the complete contents of the file, one line at a time from the file using CArchive::ReadString() function and Serialize() function and stored it line by line in CArray variable.
Now I am trying to retreive one line at a time from the CArray variable and add it to the List box control. The content gets added, but the allignment in the file is straight as shown above, but the allignment in the control is not straight.
Note: The content in the file are written by an application after formatting each line.
|
|
|
|
|
Do you mean the text in the file is properly aligned while it is misaligned in the ListBox control?
If the answer is yes, then you probably should choose a fixed-width font (like Courier or Lucida Console ) for your list box.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Yes you are right. The text in the file is properly aligned while it is misaligned in the ListBox control. I will try the fixed width font like courier.
Thanks
|
|
|
|
|
manohar_balu wrote: The content gets added, but the allignment in the file is straight...
Do you mean mono-spaced? Is it because you are using Notepad to view the file?
If you don't want to change fonts, you could try using an eight-column list control.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
I use a listbox in my dialog,but the lisbox does not accept the cursor so i can not click inside it how can make a listbox active that accept an input text in visualstudio 2005? i treid with the listbox property but no success, thanks.
|
|
|
|
|
Are you looking for something like this - Editable ListBox Tutorial[^]
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
no i am looking for listbox control
|
|
|
|
|
susanne1 wrote: no i am looking for listbox control
The sample I mentioned is using customized ListBox (Derived from CListBox itself). Did you check it?
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
yes but the problem is when i open the dialog i can not put the cursor in the listbox, is the code you sent can solve this problem? thanks
|
|
|
|
|
Can you give more details on the required behavior?
You can use SetFocus to the desired function in the OnInitDialog function and if you finally return FALSE; then the control you Set focus will get the input focus.
then map WM_SETFOCUS message of the desired control (Listbox) and add the required to necessary for your behavior(put edit box on some default item and activate the editbox and set focus to it).
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
|
i am looking for listbox control
|
|
|
|
|
Is it read-only or disabled?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
itis disabled i can not do anything with it.In the property i could not find any possibilty to make it active, should i write the activation code in the OnInitdialog()?
|
|
|
|
|
susanne1 wrote: should i write the activation code in the OnInitdialog()?
No. Do that at design time.
What version of VS are you using?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
|
What do you mean the listbox does not accept the cursor? Is it disabled? Have you checked the properties? ("Disabled" property should be set to false)
Have you checked the code to see if it is being disabled from there?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Hi all,
I have made a report style list control. it consist of 3 columns Name,Parent and Self.
Problem is i have to sort my list control on basis of two different columns at different stages.....
i.e firstly i want to sort my list control according to Self Column and then perform some calculation and after that i have to sort it according to Parent column....
I want to sort it internally i.e not by clicking onto headers of list control....
How can i do this...
Thanks in advance....
|
|
|
|
|
If you're using MFC, you can use the SortItems method of the CListCtrl class.
«_Superman_»
|
|
|
|
|
Use CListCtrl::SortItems or ListView_SortItems
- ns ami -
|
|
|
|