|
ya thank you, it didnt work for me, i would like to assign source array to new array.
eg:
assinging BYTE sourcearray[212] to BYTE destarray[1024],,,,
as am pieces of bytes in source array, like 108 bytes for the first time and again 104 bytes for the second time.
-- modified at 11:57 Friday 3rd March, 2006
|
|
|
|
|
chaitanya22 wrote: i would like to assign source array to new array.
eg:
assinging BYTE sourcearray[212] to BYTE destarray[1024],,,,
Use:
memcpy(destarray, sourcearray, 108 * sizeof(BYTE));
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Its an array of Bytes, like i owuld like like to assign source array of bytes to destination array, as am getting chunks of bytes in the source array, so that i would be having all bytes without break.
|
|
|
|
|
memcpy() is the function to use. What about it is not working?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
yes, its working, but again am getting the breaks in the data as like in source array. I would like to have continous stream of data.
|
|
|
|
|
Hello all,
Here is my code:
void CMSMCitationView::OnMsmformattingJustifytext()
{
//Call the PARAFORMAT2 Structure to mod the paragraph
// format
PARAFORMAT2 pf;
// Modify the paragraph format so that the text
//is justified.
pf.cbSize = sizeof(PARAFORMAT2);
pf.dwMask = PFM_ALIGNMENT;
pf.wAlignment = PFA_JUSTIFY;
CRichEditView::SetParaFormat(pf);
// Verify the settings.
#ifdef _DEBUG
CRichEditView::GetParaFormatSelection();
ASSERT(pf.dwMask&PFM_ALIGNMENT);
ASSERT(pf.wAlignment == PFA_JUSTIFY);
#endif
}
Here is more info about this:
Code compiles and links. When Menu Item (Justify Text) is selected, nothing happens. When other values are used in place of PFA_JUSTIFY, such as PFA_CENTER, center text is the result. Documentation says that if Rich Edit 3.0 is not installed, value PFA_JUSTIFY will align with the left margin. This is my result with PFA_JUSTIFY. I am running Win XP Pro with all the updates installed. Should have at least Rich Edit 3.0.dll already installed. Question is why won't PFA_JUSTIFY do it's thing? How do I determine if at least the RichEdit 3.0.dll is installed?
Thanks for your inputs,
Sveige
RRL
|
|
|
|
|
sveige wrote: How do I determine if at least the RichEdit 3.0.dll is installed?
From lebans.com...
Version DLL
1.0 Riched32.dll
2.0 Riched20.dll
3.0 Riched20.dll
4.1 Msftedit.dll
Windows XP SP1 Includes Rich Edit 4.1, Rich Edit 3.0, and a Rich Edit 1.0 emulator.
Windows XP Includes Rich Edit 3.0 with a Rich Edit 1.0 emulator.
Windows Me Includes Rich Edit 1.0 and 3.0.
Windows 2000 Includes Rich Edit 3.0 with a Rich Edit 1.0 emulator.
Windows NT 4.0 Includes Rich Edit 1.0 and 2.0.
Windows 98 Includes Rich Edit 1.0 and 2.0.
Windows 95 Includes only Rich Edit 1.0. However, Riched20.dll is compatible with Windows 95 and may be installed by an application that requires it.
Jeremy Falcon
|
|
|
|
|
What are the common causes for stack overflows? I have a very simple loop
for (long i=0; i<rec.size(); i++) {
add_list_item(i, 0,0,rec[i].text);
} which calls the function
void cDisplay::add_list_item(long iLin, long iCol, int iSub,char* text)
{
LVITEM lvi;
RECT rect;
GetClientRect(hList, &rect);
memset(&lvi, 0, sizeof(lvi));
lvi.mask = LVIF_TEXT;
lvi.state = 0;
lvi.stateMask = 0;
lvi.pszText = text;
lvi.iItem = iLin;
lvi.iSubItem = iCol;
switch(iSub)
{
case 0:
SendMessage((HWND) hList,(UINT) LVM_INSERTITEM, (WPARAM) 0, (LPARAM) &lvi);
break;
case 1:
SendMessage((HWND) hList,(UINT) LVM_SETITEM, (WPARAM) 0, (LPARAM) &lvi);
break;
}
ListView_SetColumnWidth(hList,iCol,LVSCW_AUTOSIZE_USEHEADER);
InvalidateRect(hList, &rect, TRUE) ;
}
All this does is populate a list-view with some 150 lines. Problem is, on the 32nd call to SendMessage the program crashes due to a sack overflow. I can't see where this is being caused or for what reasons.
But if I call
add_list_item(0, 0,0,rec[i].text);<pre> from the loop, ie put the item on the first line, it runs without a problem. But this is not what I want.
|
|
|
|
|
At the point the program crashes, look at the call stack (within the IDE) to get a better idea of where the problem is.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
I know this probably means nothing, but this is the top end of the call stack
USER32! 77d61ee3()
USER32! 77d43a68()
USER32! 77d43b37()
USER32! 77d4546b()
USER32! 77d5a3aa()
USER32! 77d5a4f0()
USER32! 77d43a68()
USER32! 77d43b37()
USER32! 77d4546b()
USER32! 77d45f69()
cDisplay::get_student_id(std::vector<_RECORD,std::allocator<_RECORD> > & {...}) line 510 + 24 bytes
cParse::display_student_record() line 633 + 18 bytes
DlgProc(HWND__ * 0x001c0698, unsigned int 78, unsigned int 1000, long 210508) line 103
which suggets to me that the problem is within USER32. But then again I may be wrong. Any ideas?
|
|
|
|
|
This does not even show that add_list_item() is being called at the time of the stack overflow. It's almost like the code is having trouble accessing one of the vector items. What if you print out the contents of the vector like:
for (long i = 0; i < rec.size(); i++)
{
OutputDebugString(rec[i].text);
OutputDebugString("\r\n");
} The second thing to try is adding the items outside of the for loop like:
add_list_item(0, 0,0,rec[0].text);
add_list_item(1, 0,0,rec[1].text);
...
add_list_item(33, 0,0,rec[33].text); Try also removing the calls to ListView_SetColumnWidth() and InvalidateRect() . What happens if you did something like:
for (long i = 32; i < rec.size(); i++)
add_list_item(i - 32, 0, 0, rec[i].text); which starts with the 33rd item in the vector.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
When taking everything out of the loop the 32nd call to add_list_item causes a stack overflow. All of the items in the vector are present and correct, and changing the value of i makes no difference.
When stepping through the code it enters the add_list_item function, all the variables and memory are exactly the same as the previous calls, nothing changes, but as soon as it sends the LVM_INSERTITEM message, it causes a stack overflow.
|
|
|
|
|
waldermort wrote: When taking everything out of the loop the 32nd call to add_list_item causes a stack overflow.
So, is it because the list view already has 31 other items in it, or is there something special about the 32nd item. Can you isolate these two?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Sorry maybe I phrased that a little wrong, I should have said that everything up to the 32nd item is displayed, theron after I start getting the "stack overflow" errors. I have tried breaking out of the loop if i is 32, starting the loop from the 32nd item. Nn matter what I do, only on the 32nd call to add_list_item the program crashes.
|
|
|
|
|
Just an update. I have changed my code slightly so that now the loop is reversed and all the inserting to the listbox is added at position 0. This draws the list exactly as it should, but when scrolling through the list (using the direction keys), the program crashes again "stack overflow". At this point I am pretty sure that the problem lies within user32.dll and not my code.
Is it possible to update this dll without having to update the whole system or go through the whole windows update pollava? Mine is version 5.1.2600.1106, I am curious to know if the problem exists in later versions. If this is the case I would probably have to change my code to check for the verion and update it, how would one do this?
|
|
|
|
|
Ok, what happens to rec after the list view has been populated? Is it a global variable that hangs around, or is it local to some function that gets destroyed after it's been used?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
rec is a vector of some 150 structs each of which contain approx members of type char pointers. Before this function is called the vector is populated within another class and is never destroyed nor are the contents changed in any way.
Infact the add_list_item function is the only function in the program which has access to this vector.
|
|
|
|
|
Hi!
I am new to structures and I get how they work, sort of. And I have a question.
Let's say I've got this structure:
<br />
struct person<br />
{ string name;<br />
int eye_colour;<br />
float height;<br />
};<br />
<br />
person friend,mother;<br />
person spouse;<br />
Note that eye color is defined by a number. 1 is brown, 2 is blue, 3 is green and a NULL value is
an unknown eye color, or whatever you like.
So how can I make my program create a new person, which is user-inputted?
Something like this: ?
<br />
cin.get(newpersonname, 15)<br />
cin.ignore(16,'\n')<br />
create.person (newpersonname)<br />
And how would that work for structures within structures?
I'm kinda confused on this
thanks!
Peter
|
|
|
|
|
You cannot do that. What you have to do is read to several different members of your struct and supply them to your structure.
You can eventually go for operator overloading but I don't think in this case it is really appropriate.
|
|
|
|
|
Thank for the responses, guys, but everyone seems
to be worried about the eye color, which was
merely an example.
But if it's truly impossible to create "fields" or
"members" or whatever you call the things
like friend and mother and spouse in my
example, then my program is going to end
in tears, I'm afraid...
Well, thank, anyways!
|
|
|
|
|
Peter Charlesworth wrote: and a NULL value is
an unknown eye color, or whatever you like.
I would recommend using -1 instead of a NULL because NULL makes no sense with int ; or better, use an enum .
to answer your question try something like :
person mother;
mother.name = "Mom";
mother.eye_colour = 1;
mother.height = 1.34;
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Thank for your answer but I was asking if it were possible
to create a new person whilst the program is running.
For instance, the user wishes to create a new person,
co-worker for instance, which uses the person structure.
Is it possible to create a new one without defining
it in the source code?
Thanks anyways!
|
|
|
|
|
struct person {
string name;
typedef enum {
BROWN = 1,
BLUE = 2,
GREEN = 3
} eyeColors_t;
eyeColors_t eye_colour;
float height;
friend istream& operator >> (const istream&, const person&);
};
istream& operator >> (istream& is, const person& p) {
is >> name >> eye_colour >> height;
return is;
}
|
|
|
|
|
Hmmm... that piece of code has given me an idea...
Thanks, V2.0 !
|
|
|
|
|
Define a constructor for your struct that takes name, eye_color and height as parameters (and has default values for all of them).
struct person
{
string name;
int eye_colour;
float height;
person(const string& n = "" , int e = -1 , float h = 0.0F);
};
person::person(const string& n, int e, float h)
: name(n), eye_color(e), height(h)
{}
Now you can create new instances of person easily:
person* spouse;
string newpersonname;
cin.get(newpersonname, 15);
cin.ignore(16,'\n');
spouse = new person(newpersonname);
|
|
|
|
|