|
You're welcome
If you feel up to it, do a bit of a speed comparison and let me know which one is quicker . They're probably about the same, but the first one will probably be slightly slower.
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"
|
|
|
|
|
halo,
I have a application which has two list box and my plan is that i must retrieve the data in the list box and somehow save it (perhaps in a integer variable) and if the data in both the liat boxes are same then there must be a error message displayed.. I tried out the following:
void Cdlg3Dlg::OnCamdone()
{
int i=0;
CListBox* m_ptele;
CListBox* m_pls1;
if (m_ptele->GetItemData(i)==m_pls1->GetItemData(i))
{ AfxMessageBox("Both boxes have same data");
}
}
but when i run the program i get the microsoft error box problem:
The xxxxxx application has encountered a problem and needs to close. We are sorry for the inconvenience. If you were in the middle......and so on.
i want to know whether it is the problem with my program..and if it is so can someone help me out.
Thanks,
Deepak Samuel
|
|
|
|
|
read LB_GETITEMDATA in msdn... it's the wrong function u chose!
use GetText member function!
Don't try it, just do it!
|
|
|
|
|
One solution is GetItemText() as the other member has mentioned.
Kuphryn
|
|
|
|
|
Deepak Samuel wrote:
CListBox* m_ptele;
CListBox* m_pls1;
These are uninitialized pointers.
|
|
|
|
|
Hi,
I would like to know if I can add few methods to class Clist.
Ehsan Behboudi
|
|
|
|
|
create a class derived from CList and put your methods there...
Don't try it, just do it!
|
|
|
|
|
i want to share the member variables and function between the various classes.what all methods can i use to achieve it?also, how do i use a friend function ?
Every problem has a solution!
|
|
|
|
|
lol, i think this is a lama question for an it student, if your really one...
describe your situation a bit better... i dont really understand what your problem is
p.s. description for friend function-> see msdn
Don't try it, just do it!
|
|
|
|
|
Actually i am making a program for a cnc machine. I have made various classes and i wished that what all info i entered in the dialog box, should be depicted in view.
Unfortunately, the view is executed even before i enter values in the dialog box.
is there any method by which i cud add a kind of delay to prevent the execution of view until i press ok.
when i wrote the code for OnOk it didn't call the ondraw function from there so i thought i shud use a friend function . i know how to use a friend function but as i am new to VC++ i wanted to know if some special method is used.
I don't have MSDN library so thats where the problem is coming and YES i am an IT student.
Every problem has a solution!
|
|
|
|
|
do u launch the view in a different thread??
normally a DialogBox function is a blocking call
Don't try it, just do it!
|
|
|
|
|
I'm receiving a string of characters over a socket connection. I know that the string is of a number of fields that are a fixed length. How can I break up this string where each fixed length field goes into it's own member variable?
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?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
if your string was called "strings" and it is comprised of integers you could to this...
<br />
int temp0 = strings.at(0);<br />
int temp1 = strings.at(1);<br />
*.*
cin >> knowledge;
|
|
|
|
|
actually my code looks like this:
<br />
char *pBuf = new char[1025];<br />
int iRcvd;<br />
int iBufsize;<br />
<br />
iRcvd = m_sConnectionSocket.Receive(pBuf, iBufsize);<br />
pBuf is my string that I want to parse out into fixed fields. The fields that are in the string being sent (pBuf) are fixed length.
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
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?
|
|
|
|