|
if you have posted your code to my mail id,
then i will get back to you in a couple of hours. keep in touch.
|
|
|
|
|
Eranga Thennakoon wrote: Can you guys help me to solve this.
Sure, which part are you stuck on? What code do you have so far?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Ok, here is my code. Sorry I don't use tags here, it gives a real mess to read the code correctly.
=============================================================================================================
#include <iostream>
#include <fstream>
#include <string>
using namespace std ;
ofstream filedata ;
// Packet content of initial 16 bytes
struct pac_cont
{
unsigned int des_list ;
unsigned int mem_ID ;
unsigned char dm_con ;
unsigned char ser_ID ;
unsigned short act ;
};
void dataExtract(int length, char *buffer)
{
struct pac_cont* p = (struct pac_cont*)buffer;
filedata.open( "RecordData.txt", ios::app ) ;
if(filedata.is_open())
{
filedata << "\t" << static_cast<int>(p->des_list) << "\t\t" << static_cast<int>(p->mem_ID)
<< "\t\t" << static_cast<int>(p->dm_con) << "\t\t" << static_cast<int>(p->ser_ID)
<< "\t\t" << static_cast<int>(p->act) << "\n";
filedata.close() ;
}
else
{
filedata << "Error in opening file RecordData.txt\n" ;
}
}
int main ()
{
ifstream fileopen ;
ofstream filerecord ;
char buffer[5000] ;
unsigned int tmp_len = 0 ; // Length of a stream
int count_mess = 0 ; // Count total message
int ID = 1 ; // Stream ID
// Open the file in binary format
fileopen.open ( "G00046_002_01.srf", ios_base::binary ) ;
// Record the stream length
filerecord.open ( "RecordLength.txt", ios_base::out ) ;
if((fileopen.is_open()) && (filerecord.is_open()))
{
// Headers of the RecordLength.txt file
filerecord << "Stream ID\tLength\t\tDescription\n\n" ;
// Headers of the RecordData.txt file
filedata.open ( "RecordData.txt", ios_base::out ) ;
if(filedata.is_open())
{
filedata << "Destination List\t" << "Member ID\t" << "Data/Message\t"
<< "Service ID\t" << "Activity ID\n\n" ;
filedata.close() ;
}
else
{
cout << "Error in opening file\n" ;
}
while(!fileopen.eof())
{
fileopen.read(buffer, 4); // Dummy read of 4 bytes
fileopen.read(buffer, 4) ; // Read next 4 bytes
tmp_len = *(unsigned int*)buffer ; // Integer value of previous 4 bytes
if(tmp_len <= 5000)
{
filerecord << ID << "\t\t" << tmp_len << "\t\t" << "-\n" ;
if(tmp_len > 16)
{
// Procesing initial 16 bytes
fileopen.read(buffer, 16) ;
dataExtract(16, buffer) ;
// Move the buffer pointer
fileopen.seekg((tmp_len - 16), ios_base::cur) ;
}
else
{
cout << "Stream is in wrong length\n" ;
}
}
else
{
filerecord << ID << "\t\t" << tmp_len << "\t\t" << "Large Size - More than 5000 bytes\n" ;
// Processing intial 16 bytes
fileopen.read(buffer, 16) ;
dataExtract(16, buffer) ;
// Move the buffer pointer
fileopen.seekg((tmp_len - 16), ios_base::cur) ;
}
ID++ ;
count_mess++ ;
}
cout << "Number of streams: " << ( ID - 1 ) << endl ;
cout << "Number of messages: " << ( count_mess - 1 ) << endl ;
fileopen.close() ;
filerecord.close() ;
}
else
{
cout << "Error in opening files" << endl ;
}
cin.get() ;
return 0 ;
}
============================================================================================================
I'll comment it as much as possible. First I read a binary file, and found how many stream of bytes are there. Actually length of those streams are not same.
Basically each stream contain three part, four bytes for part one, four bytes for part two and int value of that four bytes gives the next part bytes. The third part have 16 fixed bytes at the beginning of each. I've extract the data there using dataExtract() function, you can see that. Up to now it is ok.
Now I want to read the bytes in part three except first 16 bytes. There is a message, actually record from a online chat. I want to read it and write to a file. How can I do that.
Thanks.
I appreciate your help all the time...
|
|
|
|
|
What does stepping through each line of code with the debugger reveal?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: debugger reveal
Please can you explain it little more. It is really new for me.
Eranga
I appreciate your help all the time...
|
|
|
|
|
Buiild the project in Debug mode (instead of Release mode). Start it using F5. Use the F10 and F11 buttons to step over and into code respectively.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello again,
I want to make an "uninstall" shortcut in start menu where my software resides. How can i do this while creating setup file.
Hope somebody replies.
Thankz.
|
|
|
|
|
VC6.0 datagrid
I want to drag columns in my datagrid,so I respond to MouseDown and MouseUp Message,as following
void CTableView::OnMouseDownDatagrid(short Button, short Shift, long X, long Y)
{
// TODO: Add your control notification handler code here
col1=m_grid.ColContaining(X);
}
col1 is a member of CTableView.
but it doesn't work well
for example,If I press at column 5,it returns 5 instead of 4;
moreover,
if the position which I press at is in the first half part of columns 1, it returns 0,right!,but if the position is near column 2 in column 1, it returns 1, not expected value 0
I don't knew why
Cheers,
shakaqrj
|
|
|
|
|
can you just repost it with some better clarity?
so far, i have used flexgrid, datagrid should also be more or less same.
or if possible, attatch your application to my mail ID chandu004@yahoo.com
i shall see it.
|
|
|
|
|
Thank you!
I have sent you
|
|
|
|
|
I find this problem depends on resolution.
different resolusion gets different result.
Since I have sent you my application, please try!
Thank you!
|
|
|
|
|
What is the native approach for capturing video via FireWire under Windows? I found a lot of samples, which a using and reusing libraries and tools for these purposes, but I want to start from the very beginning, because I have to access additional commands, which are put into the stream of IEEE 1394 data, among the standard video description. Where can I get basics of IEEE 1394 programming under Windows with VC++?
P.S. Does anyone know any IEEE 1394 sniffer for Windows? There a re a lot of such tools for USB, but I found nothing for FireWire...
|
|
|
|
|
Hey Everyone,
I've got a short array that starts with 1 element (obviously) and it grows if it needs more elements. Untimately the array needs to grow as much as possible to suit the program.... I don't know however, how to return the size of the array.
e.g.
ShortArray[0] = 1;
ShortArray[1] = 5;
Length of the array is 2... Mean there are two elements. How do you return the length?
Thanks for your help in advance.... I appreciate all your input
Cheers,
Michael
|
|
|
|
|
Michael101 wrote: I've got a short array that starts with 1 element
How did you declare the array?
Michael101 wrote: Untimately the array needs to grow as much as possible to suit the program
This means you dynamically allocate the memory?
|
|
|
|
|
register short* PrimeNumber = 0;
That's how I declared the array.... I would change it if I need to though. Yeah I want allocate it more memory during runtime i.e it grows.
Cheers,
Michael
|
|
|
|
|
Michael101 wrote: I would change it if I need to though.
The memory can be allocated like
PrimeNumber = new short[2];// an array having length of 2 is created
So 2 is length of array. Similarly you can put the number of element you want in the array in the place of 2.
|
|
|
|
|
Do you know any methods or functions that return how many elements that are in the array?
Like before
Array[0] = 1;
Array[1] = 2;
There are "Two" elements in this array.
Do you know of anything like that?
Cheers again,
Michael
|
|
|
|
|
Sorry I dont get your question correctly.
Suppose you are allocating a memeory with size 5. Then the length of the array is 5. And whats the confusion in that?
you can get the size of memory that you dynamically allocated using new or malloc using the function _msize() . Is that what you want?
|
|
|
|
|
Use a std::vector and be done with it.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
yep I agree.... Thank you for your help!
Cheers
|
|
|
|
|
Michael101 wrote: ShortArray[0] = 1;
ShortArray[1] = 5;
Length of the array is 2... Mean there are two elements. How do you return the length?
const unsigned int length = sizeof(ShortArray)/sizeof(ShortArray[0]); That is, you divide the amount (in bytes) of your array by the size (in bytes) of one element.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
Hello all,
I'd like to know how to make a Win32 list view control show multiple lines of text beside the icon just like Explorer does:
|||| file_name.txt
|||| Text document
|||| October 10th 2007
I want to be able to control the text on each line and I am having no success, it just wraps a single line of text if it does not fit on one line. No matter what I do - adding columns, putting newlines to the text, setting number of lines with LVM_SETTILEVIEWINFO... nothing helps.
So far I have found only .net examples please, which are useless to me.
Thanks for any pointers.
|
|
|
|
|
Just for a bit of masochistic fun I decided to try and do this using MFC 6, the class CListCtrl of which doesnt include any explicit support for TileView.
1. ensure _WIN32_IE and _WIN32_WINNT are both defined to 0x0501 for the entire project
2. in OnCreate of CMyListView use supported InsertColumn to add 4 columns, then SendMessage(LVM_SETVIEW,,) and SendMessage(LVM_SETTILEVIEWINFO,,) specifying 2 columns
3. for each item added SendMessage(LVM_SETTILEINFO,,) listing the columns I want to see
4. make an application manifest for the exe, I used the myapp.exe.manifest XML file method rather than the resource method
Hey presto multiline TileView using MFC 6, if any one of those steps is omitted then I dont get multiline TileView.
|
|
|
|
|
It seems that I have overlooked the LVM_SETTILEINFO message and thought that LVM_SETTILEVIEWINFO is all that is needed.
Thanks for helping me, you have saved me a lot of time!
|
|
|
|
|
I have a problem I need to solve - preferably elegantly!
I have a series of inputs to my software.
Imagine... If Input A - turn an output on in 5 seconds for 2 second.
If Input B, turn an output on in 3 seconds for 2.5 seconds.
I was thinking of a queue of "on" times, and checkinh if the output should on every (eg 0.1s).
but imagine InputA came on briefly, then 1 second later InputB came on as well. You would have overlapping ON times.
I know I can do this with brute force, have a list of on-off structs, (probably using CPoint), and check every one of them each 0.1s - and get rid of the "expired" ones.
But I'm sure there must be a more elegant solution, probably using STL. It's possible there could be a *lot* of these queued events, so some some of merging of events would be helpful.
Any ideas welcome!
Iain.
|
|
|
|