|
Eranga Thennakoon wrote: But the following part is not clear, when I do it it wont print any value to the file. Just print an annoying character.
You missed my point entirely.
You need some way to determine how long the string is.
You can't just call strlen() on an uninitialized char array.
If the string is the entire file use chandu004's suggestion -
you can read it all in one shot.
Otherwise, you're going to need to learn about "strings"
(char arrays), files, etc. before you'll understand any of this.
I gave one example that writes the string length so you know how much
to read later. Your CFile is in binary mode - I wrote binary data.
The "annoying character" was never meant to be a readable character.
If everything in the file needs to be text, you need to deal with that.
Whether you use endlines, carriage-return/linefeeed pairs, or some other
escape character to separate your strings is up to you.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I have more than 50 Edit boexs in a form and I want to access them in a loop rather than accessing one by one, Is there any way by which I can do it?
Thanks,
Anand.
|
|
|
|
|
Each editbox has an ID if you set these ids for example of 100 to 150 on the resource.h you can use of a loop.
|
|
|
|
|
Yeah right, but the project has more than 50 forms and i have to do this for all forms, already the resource IDs are tightly bound ... more , it is not reliable to .. So i was thinking if some generic loop by which we can access all the controls on form and then screen out the other controls.
Thanks,
Anand.
|
|
|
|
|
Anand Todkar wrote: Yeah right, but the project has more than 50 forms
Do all the forms have a common main dialog?
|
|
|
|
|
Anand Todkar wrote: ...already the resource IDs are tightly bound ... more , it is not reliable to...
What exactly do you mean by this? Why can't you just open the project's resource.h file (or whatever you have named it) and renumber the controls such that they are sequential?
"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
|
|
|
|
|
Yeah David, you are right, i done the changes in Resource file and accessed the Controls in a loop.
Thanks for your help.
Thanks,
Anand.
|
|
|
|
|
You mean something like that,
#define IDC_ONE 1000<br />
#define IDC_TWO 1001
So, there can I use any number. I mean there is no restrictions on predefined events?
I appreciate your help all the time...
Eranga
|
|
|
|
|
Not any number,numbers must unique.
|
|
|
|
|
Ya, its' true. What I mean that there is any numbers couldn't I use, may be those numbers are already use somewhere in the application.
I appreciate your help all the time...
Eranga
|
|
|
|
|
Anand Todkar wrote: Is there any way by which I can do it?
Set the taborder of all EditBox in a sequence. Now take the handle of EditBox in the top of zorder and call the GetWindow() with GW_HWNDNEXT. This will return the handle to the 2nd EditBox. now pass the 2nd EditBox handle to get third list and so on.
Another option is to set the id value of the EditBox in a sequence. Now call the GetDlgItem() function in a for loop with the index starting from the id of first EditBox to the last one.
|
|
|
|
|
Naveen.R wrote: Set the taborder of all EditBox in a sequence. Now take the handle of EditBox in the top of zorder and call the GetWindow() with GW_HWNDNEXT. This will return the handle to the 2nd EditBox. now pass the 2nd EditBox handle to get third list and so on.
This sounds good, let me try this way, as the Taborder is not going to change.
Thanks naveen
Thanks,
Anand.
|
|
|
|
|
Hi,
I made it very easy with an Array from pointers to the control. In my case, it was:
CMyColorComboBox* m_aComboBoxes [MAX];
then, in the constructor of the Dialog... I wrote the access to them.
m_aComboBoxes[0] = &m_cmcbbVisIn1;
m_aComboBoxes[1] = &m_cmcbbVisIn2;
m_aComboBoxes[2] = &m_cmcbbVisIn3;
m_aComboBoxes[3] = &m_cmcbbVisIn4;
and then I use loops to access, write, delete data from them.
for (int i = 0; i < MAX; i++)
m_aComboBoxes [MAX]->ResetContent ();
I have done it in that way because I had the member variables from class wizard. But you can use the idea as well without having any variable and using GetDlgItem (ID). If you use the GetDlgItem ... then you must use OnInitDialog or on InitialUpdate. Because if you use the constructor to give the pointers... then you will have an assertion because the window doesn't exist when trying to access.
Hope it helps
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Hi All,
I am using list class in my project(MFC Application). I have made list like .....
typedef std::list<rect> rectlist; // Here list is of type RECT
in one header file. And during my project execution I am storing rectangles in the list.
And now,When I use list iterator in another class like below....( I have already included its header file in using class)
rectlist::iterator i;
And i use this iterator like below in any other function......
for (i = rects.begin(); i != rects.end(); i++)
{
CaptureScreen(*i, m_mainbuff); // Error is here
}
I got error msg like ...
list iterator not dereferencable
at runtime in debug assertion Failed Box.
Thanks in Advance...
Ashish
-- modified at 1:10 Tuesday 16th October, 2007
|
|
|
|
|
it may because of using *i in argument.
solution is try to give appropriate argument in function calling then copy it in to original list.
or it may required type casting..
give me the prototype of CartureScreen( ) function.
|
|
|
|
|
Prototype of CaptureScreen()...
void CaptureScreen(RECT &UpdateArea, BYTE *scrBuff);
i have just used this ....
<br />
rectlist::iterator i;<br />
<br />
for (i = rects.begin(); i != rects.end(); i++)<br />
{<br />
CaptureScreen(*i, m_mainbuff);<br />
}<br />
<br />
But in my case it does not go into loop even if condition is true. And if I make..
i == rects.end()
then it goes into the loop but their values are different.And if it goes into loop then it gives error as I explained above.And if I make it like....
<br />
CaptureScreen((RECT &)i, m_mainbuff);<br />
<br />
then it does not give error.But when for is incremented then again it gives error like....
list iterator is not incremental
That's all the case....
Thanks Hiru.
|
|
|
|
|
what about with...
rectlist::iterator i;
for (i = rects.begin(); i != rects.end(); i++)
{
CaptureScreen(&i, m_mainbuff);
}
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Yes, i also think this is true ans..
hiru
|
|
|
|
|
I have little much found that I am not getting perfect list which I have stored.
here I am fetch the rectangles list from below....
<br />
rectlist rectsToScan;<br />
m_region.Rectangles(rectsToScan);<br />
<br />
m_region is the object of the RTMPRegion class in which i storing rectangles in to the list.
But when I fetch by above then I Test like below.....
<br />
<br />
rectlist ::iterator i;<br />
for(i = rectsToScan.begin();i==rectsToScan.end();i++)<br />
CaptureScreen(*i, m_mainbuff);<br />
Then in the value of i any junk value comes.Here i is RECT ,so in left,right,top,bottom values are junk values.
|
|
|
|
|
It gives me the error using ....
CaptureScreen(&i, m_mainbuff);
Error like...
error C2664: 'RTMPDesk::CaptureScreen' : cannot convert parameter 1 from 'std::list<_Ty>::_Iterator<_Secure_validation> *__w64 ' to 'RECT &'
My Function deff...
void CaptureScreen(RECT &UpdateArea, BYTE *scrBuff);
thanks.
|
|
|
|
|
Try this
CaptureScreen( i ,m_mainbuff );
|
|
|
|
|
Thanks Hiru,,
Just before your message comes I found little solution and that is like that I did not get exect values from the list thats why it gave me error.At right now I am not getting error.
I am using same as
CaptureScreen(*i,m_Mainbuff);
If there will be some problem then i will contact U.
Thanks for your valuable time.Thank u v much.
Ashu
|
|
|
|
|
Since i is an iterator, you must use the dereference operator.
"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
|
|
|
|
|
Nelek wrote: CaptureScreen(&i, m_mainbuff);
Since i is an iterator, you must use the dereference operator.
"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
|
|
|
|
|
Hi,
I attach one static library project(project2) to my main project. My main exe is console application which i'm buiding in .net 2003.
When i call a function of sttic library project(project2) i got following error
error C3861: 'FunctionName': identifier not found, even with argument-dependent lookup
To solve this i have tried to include stdio.h in static library project(project2).
My main project is using one more function of another static library project (project1)and there is no error in calling that function.
If i dont call the function of sttic library project(project2) then there is no error.
please suggest how to solve it
Manoj Kumar Chauhan
|
|
|
|