|
In addition to what has already been mentioned:
max is not declared.
Missing <stdio.h> .
"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
|
|
|
|
|
DavidCrow wrote: max is not declared.
Sorry!I forgot to add the original
#define max (1*1024*1024)
DavidCrow wrote: Missing <stdio.h>
It counts, Thanks!
-- modified at 9:15 Tuesday 14th March, 2006
|
|
|
|
|
LiYS wrote: char tmp[max];
worst thing to do , i.e. allocating 1mb of memory on the stack. That is why it overflowed.
-Prakash
|
|
|
|
|
BOOL CPerformanceGraph::ReadFromFile()
{
CFile fp;
CPtrList tempList;
CString szFileName= "c:\\PerfGraph.txt";
if(!fp.Open(szFileName,CFile::modeRead))
{
MessageBox( "Unable to open file for Performance Graph Configuration");
return FALSE;
}
pGraphList.RemoveAll();
CPerfGraph *oPerfGraph = new CPerfGraph();
while(fp.Read( oPerfGraph, sizeof( class CPerfGraph )))
{
//for checking
int n;
n=oPerfGraph->No_of_Points;
char temp[10];
strcpy(temp,oPerfGraph->Id);
strcpy(temp,oPerfGraph->TagX);
//end of checking
tempList.AddTail(oPerfGraph);
}
POSITION Pos = tempList.GetHeadPosition();
while(Pos)
{
CPerfGraph *oTemp=(CPerfGraph *)tempList.GetAt(Pos); //for checking
CString mTagX = oTemp->TagX;
CString mTagY = oTemp->TagY;
//end of checking
tempList.GetNext(Pos);
}
fp.Close();
return TRUE;
}
This is my coding...Im reading datas from File and put it into CPtrList.But It doesn't get adding properly.
I have two set of values as graph1 and graph 2.
But it adds only the last Graph2 value.
How can i get the Graph 1 value.
I think im using the correct way to add the file data in to List.
Kindly give me solution...
|
|
|
|
|
BOOL CPerformanceGraph::ReadFromFile()
{
CFile fp;
CPtrList tempList;
CString szFileName= "c:\\PerfGraph.txt";
if(!fp.Open(szFileName,CFile::modeRead))
{
MessageBox( "Unable to open file for Performance Graph Configuration");
return FALSE;
}
pGraphList.RemoveAll();
CPerfGraph *oPerfGraph = new CPerfGraph();
while(fp.Read( oPerfGraph, sizeof( class CPerfGraph )))
{
int n;
n=oPerfGraph->No_of_Points;
char temp[10];
strcpy(temp,oPerfGraph->Id);
strcpy(temp,oPerfGraph->TagX);
tempList.AddTail(oPerfGraph);
oPerfGraph = new CPerfGraph();
}
if (oPerfGraph != NULL) delete OPerfGraph;
POSITION Pos = tempList.GetHeadPosition();
while(Pos)
{
CPerfGraph *oTemp=(CPerfGraph *)tempList.GetNext(Pos);
CString mTagX = oTemp->TagX;
CString mTagY = oTemp->TagY;
}
fp.Close();
return TRUE;
} Check out the two bold lines of code. After you add an entry to the list, you need to allocate a new one for the next entry. The second line, outside the read loop, deletes the last entry. The loop terminates on a failed read, which means the last allocated entry isn't needed. Minor style note when using the CPtrList class: the GetNext function retrieve the entry in the list at the position value, and advances the position value, in one step.
Software Zen: delete this;
|
|
|
|
|
Anu_Bala wrote: CPerfGraph *oPerfGraph = new CPerfGraph();
This will need to be inside of the while loop.
Anu_Bala wrote: strcpy(temp,oPerfGraph->Id);
strcpy(temp,oPerfGraph->TagX);
The second call to strcpy() will overwrite the first. Perhaps you meant to use strcat() instead.
Anu_Bala wrote: fp.Close();
It's a good idea to close the file as soon as you are done with it.
"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
|
|
|
|
|
Hi All,
I need to implement Drag and drop of files between my namespace extension and windows desktop folders. When the user drags a file from a desktop folder and drops it on a folder in my namespace, I need to show the user a dialog box for user I/P. On the drop event when I do DoModal(), the dialog box just appears momentarily and disappears.
Can anyone please indicate where the problem could be?
Thanks and Regards,
Anil
-- modified at 7:10 Tuesday 14th March, 2006
|
|
|
|
|
A drag-drop operation is run by a modal message loop (possibly cross-process) inside OLE32. I imagine that trying to start another modal UI loop is causing the problem.
In your OnDrop() handler, collect whatever data is necessary and store it somewhere. Post yourself a window message and do your UI in the message handler.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
Hi Michael,
I tried this approach.... but its crashing there too.
Any other suggestions?
Thanks and Regards,
Anil
|
|
|
|
|
i am using SQL Server.
may i know how to acess data base In LAN?
can i acess data base from a public IP of remote system?
if so how to do?
thanks in advance.
JAYARAJ
|
|
|
|
|
In MFC wizard I have created a dialog form with two EditBoxs(IDC_EDIT1 and IDC_EDIT2). m_var1 and m_var2 are type unsigned integer. The type of the two edit boxes are of unsigned integer data type . The names of the member variables are m_var1 and m_var2. Their is a Button on the Dialog form
Kindly observe the code given
void CMFC_7Dlg::OnButton1()
{
// TODO: Add your control notification handler code here
UINT abc = m_var1;
m_var2 = abc;
UpdateData(FALSE);
}
the problem is that when click the button1, the value entered in IDC_EDIT1 is not assigned to the temporary variable abc. When I debug the code, the value assigned to abc is zero. For example if enter a unsigned value 23 , the value is not assinged to the variable abc.
Kindly observe the code which is given below
void CMFC_7Dlg::OnButton1()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_var2 = m_var1;
UpdateData(TRUE);
}
In the above code, the value enter in IDC_EDIT1 is not transferred to IDC_EDIT2 even though m_var1 and m_var2 are both unsigned integer data type.
Kindly observe the code which is given below
void CMFC_7Dlg::OnButton1()
{
m_var2 = m_var1;
}
In the above given code, the direct assinged of m_var1 to m_var2 is not possible. When I debug the program , only zero is assinged to m_var2.
My question is why the value enter the IDC_EDIT1 is not shown in IDC_EDIT2?
Can any one please help me in this matter.
-- modified at 6:01 Tuesday 14th March, 2006
|
|
|
|
|
Actual way is
void CMFC_7Dlg::OnButton1()
{
UpdateData(TRUE);
m_var2 = m_var1;
UpdateData(FALSE);
}
nave
|
|
|
|
|
phijophlip wrote: void CMFC_7Dlg::OnButton1()
{
// TODO: Add your control notification handler code here
UINT abc = m_var1;
m_var2 = abc;
UpdateData(FALSE);
}
UpdateData(TRUE);
UINT abc = m_var1;
m_var2 = abc; phijophlip wrote: void CMFC_7Dlg::OnButton1()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_var2 = m_var1;
UpdateData(TRUE);
}
UpdateData(TRUE);
m_var2 = m_var1;
UpdateData(FALSE); Nibu thomas
Software Developer
|
|
|
|
|
If I understand you correctly, you would like the value contained in the EDIT_1 to be shown in the EDIT_2 control, on pressing BUTTON_1 ?
try the following...
void CMFC_7Dlg::OnButton1(){
// Force DDX- DDV to do it´s stuff
// Save and Validate (TRUE) parameter
// **********************************
UpdateData(TRUE);
// Set the values as required
// **************************
m_var2 = m_var1;
// Force DDX - DDV to do it´s stuff
// Read values from member variables,
// and display them (FALSE) parameter
// **********************************
UpdateData(FALSE);
}
alternativly you could do the following
void CMFC_7Dlg::OnButton1(){
// Force DDX- DDV to do it´s stuff
// Save and Validate (TRUE) parameter
// **********************************
UpdateData(TRUE);
// Set the values as required
// **************************
m_var2 = m_var1;
// Update the UI to show the change
// ********************************
SetDlgItemInt(IDC_EDIT_2, m_var2, FALSE);
}
regards
Phil
bum... and I thought I´d got rid of all the bugs
|
|
|
|
|
If I understand you correctly you need to eneter Edit1 value to Edit2 value
void CAnswerView::OnBnClickedButton2()
{
CString str;
m_Edit.GetWindowText(str);
m_Edit2.SetWindowText(str);
//int Index=atoi(str);
}
I tesed this code and work Now this code is good or bad?
|
|
|
|
|
WhiteSky wrote: I tesed this code and work Now this code is good or bad?
It is the only way that will not end in blood, sweat and tears, IMHO.
NEVER EVER call UpdateData() yourself, but use control-variables and Get/SetWindowText.
The value-variables are for shielding the inner workings of a dialog from the outside.
INSIDE a dialog they only spread confusion.
So far my personal, very dogmatic views.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
-- modified at 9:42 Tuesday 14th March, 2006
UpdateWindow -> UpdateData
|
|
|
|
|
jhwurmbach wrote: NEVER EVER call UpdateWindow()...
Perhaps you meant UpdateData() .
"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
|
|
|
|
|
Yet another example of why UpdateData() should be avoided. It's just too easy to mess up. You'd be better off using GetWindowText() instead.
"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 do not think that UpdateData(x) should be avoided. If used correctly, it is a lot eaiser then GetWindowText/SetWindowText. From the code snippet provided, It is not really clear what the purpose of two variables si, for one value to be retrieved...
just my tuppence..
Phil
bum... and I thought I´d got rid of all the bugs
|
|
|
|
|
Phil.Benson wrote: If used correctly...
That's a mighty big if there. The problem is that most beginners do not use it correctly and end up butchering their code just to get around its caveats. I find it best to avoid altogether. GetWindowText() and SetWindowText are a lot cleaner and you can tell exactly what is going to happen. Using UpdateData() is an all-or-nothing operation.
Consider the situation where you set some member variables, call a dialog's DoModal() method, call UpdateData() , then click the Cancel button. Now the member variables are potentially not in the same state they were prior to calling DoModal() . You should be able to assume that member variables retain their same value before and after if the Cancel button has been clicked. Use of UpdateData() makes this a bad assumption.
"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
|
|
|
|
|
David wrote
"That's a mighty big if there. The problem is that most beginners do not use it correctly..."
Nobody said programming is easy. If it was, we would not get paid as much
As for choosing Cancel, do you manipulate application data directly within the dialog? Or do you wait for the result (IDOK or IDCANCEL) before making any changes resulting from the data being changed within the dialog?
again, just my tuppence
Phil
bum... and I thought I´d got rid of all the bugs
-- modified at 9:43 Tuesday 14th March, 2006
Here on code project, If I can remember correctly it was PJ Ahrens, has written an interesting article about DDX-DDV in the MFC
|
|
|
|
|
I need to integrate Activex control(OCX) object into ATL COM Server DLL project. I created a dialog in my the project and added activex control. After adding the ActiveX control my other parts of the program are not working properly. The COM DLL calls CoCreateInstance() to connect to another component. At this point it hangs. If I remove the ActiveX object from the project everything works fine. Do you guys have any idea?
kars82
|
|
|
|
|
Hi again
i have another simple question
i'm doing the following
string text;
int lenght=text.lenght;
compilation error::
error C2440: 'initializing' : cannot convert from 'unsigned int (__thiscall std::basic_string<char,struct std::char_traits<char="">,class std::allocator<char> >::*' to 'int'
Conversion is a valid standard conversion, which can be performed implicitly or by use of static_cast, C-style cast or function-style cast
Error executing cl.exe.
What is the problem i've seen this in many codes what is wrong with mine
Thanks in advance
|
|
|
|
|
antonaras_marcou wrote: string text;
int lenght=text.lenght;
string text;
int nLength = text.length();
Nibu thomas
Software Developer
|
|
|
|
|
Thanks Nibu thomas
appriciate the help
it's working fine now
|
|
|
|