|
See if AfxExtractSubString() is of any help. If not, try strtok() .
|
|
|
|
|
you can do this in vc, too....
define a structure with fixed size and copy the data in it!
structure only means, that the compiler knows, where it can find the data!
Don't try it, just do it!
|
|
|
|
|
Tom Wright wrote:
Being a cobol programmer too, in cobol we can just move it into a structure where the structure is set with all the fields and their fixed lengths. Can I do this in VC also?
I'm not an expert C++ programmer but I wondered if you could use a union and a struct for this? A union allows you to access multiple data formats in a single location. So you would store the data as 1 big string and read it as lots of little ones. I've used unions before in general C programming and they can be really powerfull.
I think you might have to store the data as arrays of characters not strings because on the fixed length. You would declare a structure & union something like this....
struct sData{<br />
char cData[35];<br />
union{<br />
char c1[10];<br />
char c2[20];<br />
char c3[5];<br />
} fields;<br />
};
<br />
struct sData sMyData;
Access the 'full' string like this :-
sMyData.cData
Access the 'field' strings like this :-
sMyData.fields.c1<br />
sMyData.fields.c2<br />
sMyData.fields.c3
It might be worth a look. Good luck,
Ali
|
|
|
|
|
Both ways are very similar to Cobol. For instance (cobol school starting)here is a structure in cobol:
<br />
01 MY-STRING PIC X(009).<br />
<br />
01 MAIN-STRUCTURE.<br />
05 FIELD-1 PIC X.<br />
05 FIELD-2 PIC X(003).<br />
05 FIELD-3 PIC X.<br />
05 FIELD-4 PIC 9(003).<br />
05 FIELD-5 PIC X.<br />
When I reveive a string from a socket connection I can just move that string(MY-STRING)into MAIN-STRUCTURE. Then I can look at each FIELD's to see a break down of the string.
Another way to do it in cobol is like this:
<br />
01 MY-STRING PIC X(009).<br />
<br />
01 MASTER-STURCTURE.<br />
05 MAIN-STRUCTURE.<br />
07 FIELD-1 PIC X.<br />
07 FIELD-2 PIC X(003).<br />
07 FIELD-3 PIC X.<br />
07 FIELD-4 PIC 9(003).<br />
07 FIELD-5 PIC X.<br />
So can I assume that I can setup a structure in VC++ like this and reference it the same way:
struct sData{
char c1[10];
char c2[20];
char c3[5];
} fields;
Right?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
be careful,
first, there is such thing as memory alignment in Windows.
second, there is "host byte order" in case if the second computer is not Win PC.
In general, you should(can) not map structure to a blob of memory that you received over the wire.
|
|
|
|
|
I think you are right and you should be able to write a long string into c1 and read the characters that overflow from c2 and c3. I think that using a union as well as a struct would be the safest way to do it because a union ensures that the data is stored and retreived from the same area. Unions are normally used for things like accessing the individual bytes in a float.
Also be aware that your data will be stored in arrays of chars not CStrings and you can't just use them like CStrings.
Hope you get it working,
Cheers
Ali
|
|
|
|
|
hi,
please help me get over this problem.
I have a listctrl and it needs to display about 15000 items.
But after displaying it, when i close the dialog, it takes a while to close the dialog. Can see the app running when i hit ctrl+alt+del. When i decrease the count , the dialog closes instantly. How can i close the dialog instantly ?
The problem is more evident if i launch this dialog from another dialog, in that case the parent dialog is not redrawn until the child dialog closes completely.
BTW, I dont want to use the virtual list.
Hari Krishnan
|
|
|
|
|
One option would be to review your UI, having a list with 15000 items is useless and not really user friendly.
Have you tried using a owner draw list and keeping the data external to the list itself (not really a virtual list) ?
Maximilien Lincourt
"Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
|
|
|
|
|
Maximilien wrote:
Have you tried using a owner draw list and keeping the data external to the list itself (not really a virtual list) ?
Actually, a virtual list control is one that keeps only a small subset of the data items in memory at any one time. The rest of the data, while not being displayed, is kept in a data structure of some sort. The control uses the LVS_OWNERDATA style.
|
|
|
|
|
hi,
i tried this owner data option, but the check boxes are not shown. The space is empty.
Hari Krishnan
|
|
|
|
|
In the context for which I mentioned the LVS_OWNERDATA style, it had nothing to do with checkboxes. Have you looked at the CCheckListBox class, or a list control with checkbox capability?
|
|
|
|
|
hi,
thanks for ur reply.
But i forgot to mention , the listctrl lists files searched from the disk, and i was only making sure it displays a very large number of entries.
As you can see, i can't review the interface, as i should expect any large number.
BTW, after posting here, i tried the ownerdraw style, but the check boxes are not shown. The check box space is empty.
Hari Krishnan
|
|
|
|
|
use the owner-data option to make freeing memory faster
Don't try it, just do it!
|
|
|
|
|
Then try this:
Override whichever function in your application which will be called before your main window(or frame) closes, for example, "OnCancel()" or "OnOK()" for a dialog based app, etc, then add just one single line of code into the very beginning of tha function body:
<br />
void CMyDlg::OnCancel()
{<br />
m_wndList.LockWindowUpdate();
<br />
}<br />
This should shorten your waiting time by at least 1/2.
|
|
|
|
|
Alright guys I need some help here.
I have incorporated the backgroud color control in my ListCtrl similar to this example:
http://www.codeproject.com/listctrl/lvcustomdraw.asp
I can make row #3 be red, row #54 be orange, row #357 be yellow, etc.
with something like:
if ( (pLVCD->nmcd.dwItemSpec) == 0 )<br />
crBkgnd = RGB(128,128,255);<br />
else<br />
crBkgnd = RGB(0,0,255);
I want the color to not be linked to the row number, I want it linked to the data in the first column of my exercise.
Like a grade sheet: If the value in column is >89, you have an A and you need a green background. If the value in the first column is <70 you have a F and you need a red background. That is all I want it to do. Please help me.
thank you.
I wish I could type better ...
|
|
|
|
|
why don't you just set the color on every single item of the row?
Don't try it, just do it!
|
|
|
|
|
Sorry about that I may have mislead you. I will be setting the whole row to a color, but I want that color to be associated with the value in the first column.
I wish I could type better ...
|
|
|
|
|
Ok, simple little problem here. I've got an edit box that takes an integer. I want to prevent trouble if a user enters something like
98 89
into one edit box. I've got it set up like:
DDX_Text(pDX, IDC_CH0_EDIT_FS, ch0_edit_fs_tq);
DDV_MinMaxInt(pDX, ch0_edit_fs_tq, 0, 99999999);
which doesn't allow for letters, but a user can still enter a space. Is there a way to fix this before the user hits ok? Or do i have to check the contents of the edit box before i output the value?
*.*
cin >> knowledge;
|
|
|
|
|
You'll need to derived your own class from CEdit, and override OnChar()to only accept numbers.
|
|
|
|
|
One solution is to add an onchange message handler and update the edit control accordingly based on its current content.
Kuphryn
|
|
|
|
|
If you only want positive integers, then set the ES_NUMBER style, causing the control to reject everything except digits.
Hope this helps,
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Is there a protocol issue when Serializing data using Serialize method of MFC C++ over a TCP Socket to a Java App. If not how can this be done?
The model is: A java client connect a server written in C++ and Serialization of a Class or an Object containg data takes place. If you can help me I'll be very happy.
Cheers
Sean V
|
|
|
|
|
Hello, I'd appreciate any help.
Over the last two days I've been experiencing my source code files going missing, while I'm working on a project in the IDE.
I'm using Visual C++ 6with SourceSafe. I don't have SourceSafe Client running, but frequently, while developing in the IDE, when I double-click on a file in the Project Explorer to open it(always an implentation file) I get 'Project file .. does not exists. Do you want to get it from Source control?'
For some strange reason it's just disappeared from my hard -drive. I can restore it from SourceSafe but I've lost of the work I've done since I last checked in.
I always save my files regulary. Can anybody tell me if VC++ keeps temporary copies of files while I'm working on them so I can try to restore something.
|
|
|
|
|
The most common reason of *.h or *.cpp mystically disappearing is the "Norton anti-virus + Windows2000/XP" combo, it deletes your source files permanently from time to time when you are using class-wizard. And no, there is no way to solve this problem even if you tell Norton to ignore *.h and *.cpp.
Either Microsoft or Symantic MUST fix this, but so far neither of them did. The best solution at this moment is completely stay away from Norton anti-virus if you are working on Windows2000/XP.
|
|
|
|
|
Thanks! That is scary. Could be it, although I've been using the win2000/Norton Antivirus/Visual C++ combo for 3 years now. But I will shutit down now.
|
|
|
|