hello, I am reading a file in chunks of 512 bytes(i am reading 2 such blocks).I am calling SetTimer function.And in corresponding OnTimer function I am writing code for displaying the file data on a graph control placed in my dialog box.I am calling the KillTimer function after the 2 chunks of data are displayed as graphs. But when i close the dialog or press OK/Cancel button the dialog MFC application error box appears which asks "whether to send the error report to microsoft".Why is this coming?First i thought maybe the KillTimer function isnt properly called but that is not the case since when i debugged the program i got the result that Killtimer is properly called. Its after i close the .EXE or press OK to close the dialog then the MFC error box appears. please please help fast.. p.s.-as i degugged the program an unexpected exception occurs after i press OK or Close button
sayu wrote: > please please help fast.. > p.s.-as i degugged the program an unexpected exception occurs after i press > OK or Close button You should track the bug starting from this exception. The debugger will stop the execution on the place where this exception occurred, exactly on the instruction that cannot be executed. If you can't find the bug post here several lines before and after the code that's causing the exception.
sayu wrote: > hello, > I am reading a file in chunks of 512 bytes(i am reading 2 such > blocks).I am calling SetTimer function.And in corresponding OnTimer function > I am writing code for displaying the file data on a graph control placed in > my dialog box.I am calling the KillTimer function after the 2 chunks of data > are displayed as graphs. > But when i close the dialog or press OK/Cancel button the dialog MFC > application error box appears which asks "whether to send the error report to > microsoft".Why is this coming?First i thought maybe the KillTimer function > isnt properly called but that is not the case since when i debugged the > program i got the result that Killtimer is properly called. > Its after i close the .EXE or press OK to close the dialog then the MFC > error box appears. > > please please help fast.. > p.s.-as i degugged the program an unexpected exception occurs after i press > OK or Close button The timer functions are unlikely to be the cause of your problem. Most likely you have a bug somewhere else in your program. Try posting a minimal example that reproduces the behaviour (the key here is minimal - for one you may spot the problem yourself, if not the smaller the better to be easily digestible by others who may be able to help). Regards, Hugh
This is my OnTimer() code CDialogDlg::OnTimer() { UpdateData(TRUE); var_x=0; static int i=0; static int j=512; m_ctrl.ClearGraph();//each time before plotting graph earlier graph on screen erased// for(;i<j;i++) { m_ctrl.SetElementLineColor(2000); m_ctrl.PlotXY(var_x,(double)buff[i],0);//plotting 512 bytes of data var_x=var_x+(46.875/1000); } j=j+512;//increment j so that in next SetTimer loopnext chunk of 512 bytes plotted;i.e.from 512-1023bytes// if(j>1024) { r=KillTimer(s);//If 1024 chunks are plotted i Wish to end call to SetTimer;hence calling KillTimer()// } UpdateData(FALSE); } I degugged the program by palcing breakpoint on KillTimer function.Both the graphs are plotted successfully an dthen plotting stops(that means KillTimer is called).Now as i press OK/CANCEL/Close button to close the dialog it gives message that unhandled exception occcured in dialog.exe please help "Mihajlo Cvetanović" wrote: > sayu wrote: > > please please help fast.. > > p.s.-as i degugged the program an unexpected exception occurs after i press > > OK or Close button > > You should track the bug starting from this exception. The debugger will > stop the execution on the place where this exception occurred, exactly > on the instruction that cannot be executed. If you can't find the bug > post here several lines before and after the code that's causing the > exception. >
sayu wrote: > This is my OnTimer() code > CDialogDlg::OnTimer() > { > UpdateData(TRUE); > > var_x=0; > static int i=0; > static int j=512; > > m_ctrl.ClearGraph();//each time before plotting graph earlier graph on > screen erased// > > for(;i<j;i++) > { > > m_ctrl.SetElementLineColor(2000); > m_ctrl.PlotXY(var_x,(double)buff[i],0);//plotting 512 bytes of data > var_x=var_x+(46.875/1000); > > } > j=j+512;//increment j so that in next SetTimer loopnext chunk of 512 bytes > plotted;i.e.from 512-1023bytes// > > if(j>1024) > { > r=KillTimer(s);//If 1024 chunks are plotted i Wish to end call to > SetTimer;hence calling KillTimer()// > } > UpdateData(FALSE); > > } > > I degugged the program by palcing breakpoint on KillTimer function.Both the > graphs are plotted successfully an dthen plotting stops(that means KillTimer > is called).Now as i press OK/CANCEL/Close button to close the dialog it gives > message that unhandled exception occcured in dialog.exe > > please help > > "Mihajlo Cvetanovic" wrote: > > > sayu wrote: > > > please please help fast.. > > > p.s.-as i degugged the program an unexpected exception occurs after i press > > > OK or Close button > > > > You should track the bug starting from this exception. The debugger will > > stop the execution on the place where this exception occurred, exactly > > on the instruction that cannot be executed. If you can't find the bug > > post here several lines before and after the code that's causing the > > exception. > > One quick point - try not to use UpdateData the way you are, instead use control variables and SetWindowText, GetWindowText etc. In terms of the error you're encountering I can't see anything that would cause this and so the advice in my first reply still stands - start cutting out bits of code until you get a minimal example that reproduces this bug then if you still can't solve it yourself post it here. For example, what happens if you comment out all of the timer stuff completely? Regards, Hugh
There's not enough information to reach a conclusion (especially: where did exception occurred). Maybe answers to these questions may help. What is the size of buff array? Will the exception occur even if you don't set the timer? Shouldn't if(j>1024) be actually if(j>=1024) to kill the timer? Can you enter the code where the exception occurs?
Well first thing is the positon of KillTimer function ok in the code? Results seen on debugging( I am giving u actual steps f what happened)- 1)If breakpoint at SetTimer() function As I press F5,first and second graph appear as per time in SetTimer function. Dialog waits for user to press key. As I press OK/Cancel message of “unhandled Exception” is shown execution control goes to CWnd::DestroyWindow() function. I am showing here some lines in the function:- #ifdef _AFX_NO_OCC_SUPPORT BOOL bResult = ::DestroyWindow(m_hWnd); #else //_AFX_NO_OCC_SUPPORT BOOL bResult; if (m_pCtrlSite == NULL) bResult = ::DestroyWindow(m_hWnd); else bResult = m_pCtrlSite->DestroyControl(); //execution stops at this point// #endif //_AFX_NO_OCC_SUPPORT // Note that 'this' may have been deleted at this point, // (but only if pWnd != NULL) if (pWnd != NULL) { // Should have been detached by OnNcDestroy #ifdef _DEBUG ASSERT(pMap->LookupPermanent(hWndOrig) == NULL); #endif } else { #ifdef _DEBUG ASSERT(m_hWnd == hWndOrig); #endif // Detach after DestroyWindow called just in case Detach(); } return bResult; 2)If breakpoint is set at KillTimer() function As I press F5 first graph appears in dialog and then the dialog disappeares.Again I press F5 ,this time second graph appears on dialog and dialog box waits for key to be pressed..As I press OK/Cancel same error of unhandled exception occurs and control again goes to Cwnd::DestroyWindow() function as given in above code.Execution also stops as same point above Please help "hughgray@hotmail.co.uk" wrote: > sayu wrote: > > hello, > > I am reading a file in chunks of 512 bytes(i am reading 2 such > > blocks).I am calling SetTimer function.And in corresponding OnTimer function > > I am writing code for displaying the file data on a graph control placed in > > my dialog box.I am calling the KillTimer function after the 2 chunks of data > > are displayed as graphs. > > But when i close the dialog or press OK/Cancel button the dialog MFC > > application error box appears which asks "whether to send the error report to > > microsoft".Why is this coming?First i thought maybe the KillTimer function > > isnt properly called but that is not the case since when i debugged the > > program i got the result that Killtimer is properly called. > > Its after i close the .EXE or press OK to close the dialog then the MFC > > error box appears. > > > > please please help fast.. > > p.s.-as i degugged the program an unexpected exception occurs after i press > > OK or Close button > > The timer functions are unlikely to be the cause of your problem. Most > likely you have a bug somewhere else in your program. Try posting a > minimal example that reproduces the behaviour (the key here is minimal > - for one you may spot the problem yourself, if not the smaller the > better to be easily digestible by others who may be able to help). > > Regards, > > Hugh > >
my answers to Mihajlo's questions: 1)Size of buff array is 1024 since i am storing 1024 bytes of data. 2)when i displayed 1 set of data(512 bytes) in OnInitdialog() function(not using SetTimer and Ontimer) then there is no problem.so logic is ok 3)no,i think j>1024 is ok coz after i display first graph i increment j by 512 which makes j=1024;so if we putj>=1024 then KillTimer will be called before second graph display Please see my code.It outputs the graph successfully.I am only having problem in closing application provided in my second message I am also now giving the exception code "hughgray@hotmail.co.uk" wrote: > sayu wrote: > > hello, > > I am reading a file in chunks of 512 bytes(i am reading 2 such > > blocks).I am calling SetTimer function.And in corresponding OnTimer function > > I am writing code for displaying the file data on a graph control placed in > > my dialog box.I am calling the KillTimer function after the 2 chunks of data > > are displayed as graphs. > > But when i close the dialog or press OK/Cancel button the dialog MFC > > application error box appears which asks "whether to send the error report to > > microsoft".Why is this coming?First i thought maybe the KillTimer function > > isnt properly called but that is not the case since when i debugged the > > program i got the result that Killtimer is properly called. > > Its after i close the .EXE or press OK to close the dialog then the MFC > > error box appears. > > > > please please help fast.. > > p.s.-as i degugged the program an unexpected exception occurs after i press > > OK or Close button > > The timer functions are unlikely to be the cause of your problem. Most > likely you have a bug somewhere else in your program. Try posting a > minimal example that reproduces the behaviour (the key here is minimal > - for one you may spot the problem yourself, if not the smaller the > better to be easily digestible by others who may be able to help). > > Regards, > > Hugh > >
sayu wrote: > Well first thing is the positon of KillTimer function ok in the code? > > Results seen on debugging( I am giving u actual steps f what happened)- > 1)If breakpoint at SetTimer() function > > As I press F5,first and second graph appear as per time in SetTimer > function. Dialog waits for user to press key. As I press OK/Cancel message of > "unhandled Exception" is shown execution control goes to > CWnd::DestroyWindow() function. > I am showing here some lines in the function:- > #ifdef _AFX_NO_OCC_SUPPORT > BOOL bResult = ::DestroyWindow(m_hWnd); > #else //_AFX_NO_OCC_SUPPORT > BOOL bResult; > if (m_pCtrlSite == NULL) > bResult = ::DestroyWindow(m_hWnd); > else > bResult = m_pCtrlSite->DestroyControl(); //execution stops at this point// > #endif //_AFX_NO_OCC_SUPPORT > > // Note that 'this' may have been deleted at this point, > // (but only if pWnd != NULL) > if (pWnd != NULL) > { > // Should have been detached by OnNcDestroy > #ifdef _DEBUG > ASSERT(pMap->LookupPermanent(hWndOrig) == NULL); > #endif > } > else > { > #ifdef _DEBUG > ASSERT(m_hWnd == hWndOrig); > #endif > // Detach after DestroyWindow called just in case > Detach(); > } > return bResult; > > 2)If breakpoint is set at KillTimer() function > > As I press F5 first graph appears in dialog and then the dialog > disappeares.Again I press F5 ,this time second graph appears on dialog and > dialog box waits for key to be pressed..As I press OK/Cancel same error of > unhandled exception occurs and control again goes to Cwnd::DestroyWindow() > function as given in above code.Execution also stops as same point above > > Please help > > > > > > > > > > > > > > "hughgray@hotmail.co.uk" wrote: > > > sayu wrote: > > > hello, > > > I am reading a file in chunks of 512 bytes(i am reading 2 such > > > blocks).I am calling SetTimer function.And in corresponding OnTimer function > > > I am writing code for displaying the file data on a graph control placed in > > > my dialog box.I am calling the KillTimer function after the 2 chunks of data > > > are displayed as graphs. > > > But when i close the dialog or press OK/Cancel button the dialog MFC > > > application error box appears which asks "whether to send the error report to > > > microsoft".Why is this coming?First i thought maybe the KillTimer function > > > isnt properly called but that is not the case since when i debugged the > > > program i got the result that Killtimer is properly called. > > > Its after i close the .EXE or press OK to close the dialog then the MFC > > > error box appears. > > > > > > please please help fast.. > > > p.s.-as i degugged the program an unexpected exception occurs after i press > > > OK or Close button > > > > The timer functions are unlikely to be the cause of your problem. Most > > likely you have a bug somewhere else in your program. Try posting a > > minimal example that reproduces the behaviour (the key here is minimal > > - for one you may spot the problem yourself, if not the smaller the > > better to be easily digestible by others who may be able to help). > > > > Regards, > > > > Hugh > > > > It's still difficult to try and determine what the problem is. However, you say that execution stops on - m_pCtrlSite->DestroyControl() - which may indicate that the problem is related to the ActiveX graphing control you are using. I would suggest creating a new empty project and then insert this control onto the main dialog. Run the project and make sure there's no crash. Then add in small bits of functionality to clear the graph, display a little data etc. Make sure there's no crash. It could be that you have to call some kind of cleanup function on the graph before closing the dialog. Again, there is not enough information to be sure here. It might also be worth a check over the documentation for the control just to make sure you haven't missed anything else. Is it a well known graphing control you are using? Are there any support resources available for it? If so you could try that avenue as well. Hugh
sayu wrote: > 2)when i displayed 1 set of data(512 bytes) in OnInitdialog() function(not > using SetTimer and Ontimer) then there is no problem.so logic is ok What happens if you display both sets in OnInitDialog? What happens if you display only one set in OnTimer? When exception occurs what are the values of "this" and m_pCtrlSite? Maybe CWnd::DestroyWindow is somehow called twice...
I am using NTGraph control which i have downloaded from website codeproject.com.there is not much document available for it.And at first i was displaying a chunk of data(512 bytes) in OnInitDialog() without using SetTimer and Ontimer functions().That was working fine and application was closing without error.Only after i want to display more than one sets of data in OnTimer the problem occurs. I am also giving you the link to code for u to see(from where i downloaded) LINK- http://www.codeproject.com/miscctrl/ntgraph_activex.asp "hughgray@hotmail.co.uk" wrote: > sayu wrote: > > Well first thing is the positon of KillTimer function ok in the code? > > > > Results seen on debugging( I am giving u actual steps f what happened)- > > 1)If breakpoint at SetTimer() function > > > > As I press F5,first and second graph appear as per time in SetTimer > > function. Dialog waits for user to press key. As I press OK/Cancel message of > > "unhandled Exception" is shown execution control goes to > > CWnd::DestroyWindow() function. > > I am showing here some lines in the function:- > > #ifdef _AFX_NO_OCC_SUPPORT > > BOOL bResult = ::DestroyWindow(m_hWnd); > > #else //_AFX_NO_OCC_SUPPORT > > BOOL bResult; > > if (m_pCtrlSite == NULL) > > bResult = ::DestroyWindow(m_hWnd); > > else > > bResult = m_pCtrlSite->DestroyControl(); //execution stops at this point// > > #endif //_AFX_NO_OCC_SUPPORT > > > > // Note that 'this' may have been deleted at this point, > > // (but only if pWnd != NULL) > > if (pWnd != NULL) > > { > > // Should have been detached by OnNcDestroy > > #ifdef _DEBUG > > ASSERT(pMap->LookupPermanent(hWndOrig) == NULL); > > #endif > > } > > else > > { > > #ifdef _DEBUG > > ASSERT(m_hWnd == hWndOrig); > > #endif > > // Detach after DestroyWindow called just in case > > Detach(); > > } > > return bResult; > > > > 2)If breakpoint is set at KillTimer() function > > > > As I press F5 first graph appears in dialog and then the dialog > > disappeares.Again I press F5 ,this time second graph appears on dialog and > > dialog box waits for key to be pressed..As I press OK/Cancel same error of > > unhandled exception occurs and control again goes to Cwnd::DestroyWindow() > > function as given in above code.Execution also stops as same point above > > > > Please help > > > > > > > > > > > > > > > > > > > > > > > > > > > > "hughgray@hotmail.co.uk" wrote: > > > > > sayu wrote: > > > > hello, > > > > I am reading a file in chunks of 512 bytes(i am reading 2 such > > > > blocks).I am calling SetTimer function.And in corresponding OnTimer function > > > > I am writing code for displaying the file data on a graph control placed in > > > > my dialog box.I am calling the KillTimer function after the 2 chunks of data > > > > are displayed as graphs. > > > > But when i close the dialog or press OK/Cancel button the dialog MFC > > > > application error box appears which asks "whether to send the error report to > > > > microsoft".Why is this coming?First i thought maybe the KillTimer function > > > > isnt properly called but that is not the case since when i debugged the > > > > program i got the result that Killtimer is properly called. > > > > Its after i close the .EXE or press OK to close the dialog then the MFC > > > > error box appears. > > > > > > > > please please help fast.. > > > > p.s.-as i degugged the program an unexpected exception occurs after i press > > > > OK or Close button > > > > > > The timer functions are unlikely to be the cause of your problem. Most > > > likely you have a bug somewhere else in your program. Try posting a > > > minimal example that reproduces the behaviour (the key here is minimal > > > - for one you may spot the problem yourself, if not the smaller the > > > better to be easily digestible by others who may be able to help). > > > > > > Regards, > > > > > > Hugh > > > > > > > > It's still difficult to try and determine what the problem is. However, > you say that execution stops on - > > m_pCtrlSite->DestroyControl() > > - which may indicate that the problem is related to the ActiveX > graphing control you are using. I would suggest creating a new empty > project and then insert this control onto the main dialog. Run the > project and make sure there's no crash. Then add in small bits of > functionality to clear the graph, display a little data etc. Make sure > there's no crash. It could be that you have to call some kind of > cleanup function on the graph before closing the dialog. Again, there > is not enough information to be sure here. > > It might also be worth a check over the documentation for the control > just to make sure you haven't missed anything else. > > Is it a well known graphing control you are using? Are there any > support resources available for it? If so you could try that avenue as > well. > > Hugh > >
sayu wrote: > I am using NTGraph control which i have downloaded from website > codeproject.com.there is not much document available for it.And at first i > was displaying a chunk of data(512 bytes) in OnInitDialog() without using > SetTimer and Ontimer functions().That was working fine and application was > closing without error.Only after i want to display more than one sets of data > in OnTimer the problem occurs. > I am also giving you the link to code for u to see(from where i downloaded) > LINK- http://www.codeproject.com/miscctrl/ntgraph_activex.asp > > "hughgray@hotmail.co.uk" wrote: > > > sayu wrote: > > > Well first thing is the positon of KillTimer function ok in the code? > > > > > > Results seen on debugging( I am giving u actual steps f what happened)- > > > 1)If breakpoint at SetTimer() function > > > > > > As I press F5,first and second graph appear as per time in SetTimer > > > function. Dialog waits for user to press key. As I press OK/Cancel message of > > > "unhandled Exception" is shown execution control goes to > > > CWnd::DestroyWindow() function. > > > I am showing here some lines in the function:- > > > #ifdef _AFX_NO_OCC_SUPPORT > > > BOOL bResult = ::DestroyWindow(m_hWnd); > > > #else //_AFX_NO_OCC_SUPPORT > > > BOOL bResult; > > > if (m_pCtrlSite == NULL) > > > bResult = ::DestroyWindow(m_hWnd); > > > else > > > bResult = m_pCtrlSite->DestroyControl(); //execution stops at this point// > > > #endif //_AFX_NO_OCC_SUPPORT > > > > > > // Note that 'this' may have been deleted at this point, > > > // (but only if pWnd != NULL) > > > if (pWnd != NULL) > > > { > > > // Should have been detached by OnNcDestroy > > > #ifdef _DEBUG > > > ASSERT(pMap->LookupPermanent(hWndOrig) == NULL); > > > #endif > > > } > > > else > > > { > > > #ifdef _DEBUG > > > ASSERT(m_hWnd == hWndOrig); > > > #endif > > > // Detach after DestroyWindow called just in case > > > Detach(); > > > } > > > return bResult; > > > > > > 2)If breakpoint is set at KillTimer() function > > > > > > As I press F5 first graph appears in dialog and then the dialog > > > disappeares.Again I press F5 ,this time second graph appears on dialog and > > > dialog box waits for key to be pressed..As I press OK/Cancel same error of > > > unhandled exception occurs and control again goes to Cwnd::DestroyWindow() > > > function as given in above code.Execution also stops as same point above > > > > > > Please help > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > "hughgray@hotmail.co.uk" wrote: > > > > > > > sayu wrote: > > > > > hello, > > > > > I am reading a file in chunks of 512 bytes(i am reading 2 such > > > > > blocks).I am calling SetTimer function.And in corresponding OnTimer function > > > > > I am writing code for displaying the file data on a graph control placed in > > > > > my dialog box.I am calling the KillTimer function after the 2 chunks of data > > > > > are displayed as graphs. > > > > > But when i close the dialog or press OK/Cancel button the dialog MFC > > > > > application error box appears which asks "whether to send the error report to > > > > > microsoft".Why is this coming?First i thought maybe the KillTimer function > > > > > isnt properly called but that is not the case since when i debugged the > > > > > program i got the result that Killtimer is properly called. > > > > > Its after i close the .EXE or press OK to close the dialog then the MFC > > > > > error box appears. > > > > > > > > > > please please help fast.. > > > > > p.s.-as i degugged the program an unexpected exception occurs after i press > > > > > OK or Close button > > > > > > > > The timer functions are unlikely to be the cause of your problem. Most > > > > likely you have a bug somewhere else in your program. Try posting a > > > > minimal example that reproduces the behaviour (the key here is minimal > > > > - for one you may spot the problem yourself, if not the smaller the > > > > better to be easily digestible by others who may be able to help). > > > > > > > > Regards, > > > > > > > > Hugh > > > > > > > > > > > > It's still difficult to try and determine what the problem is. However, > > you say that execution stops on - > > > > m_pCtrlSite->DestroyControl() > > > > - which may indicate that the problem is related to the ActiveX > > graphing control you are using. I would suggest creating a new empty > > project and then insert this control onto the main dialog. Run the > > project and make sure there's no crash. Then add in small bits of > > functionality to clear the graph, display a little data etc. Make sure > > there's no crash. It could be that you have to call some kind of > > cleanup function on the graph before closing the dialog. Again, there > > is not enough information to be sure here. > > > > It might also be worth a check over the documentation for the control > > just to make sure you haven't missed anything else. > > > > Is it a well known graphing control you are using? Are there any > > support resources available for it? If so you could try that avenue as > > well. > > > > Hugh > > > > Well I can't vouch for this control but I'll take a look at it when I get some time. Chances are that the problem could be somewhere else in your code anyway. I would keep experimenting with removing bits of your code to see if you can narrow things down. Regards, Hugh
hughgray@hotmail.co.uk wrote: > sayu wrote: > > I am using NTGraph control which i have downloaded from website > > codeproject.com.there is not much document available for it.And at first i > > was displaying a chunk of data(512 bytes) in OnInitDialog() without using > > SetTimer and Ontimer functions().That was working fine and application was > > closing without error.Only after i want to display more than one sets of data > > in OnTimer the problem occurs. > > I am also giving you the link to code for u to see(from where i downloaded) > > LINK- http://www.codeproject.com/miscctrl/ntgraph_activex.asp > > > > "hughgray@hotmail.co.uk" wrote: > > > > > sayu wrote: > > > > Well first thing is the positon of KillTimer function ok in the code? > > > > > > > > Results seen on debugging( I am giving u actual steps f what happened)- > > > > 1)If breakpoint at SetTimer() function > > > > > > > > As I press F5,first and second graph appear as per time in SetTimer > > > > function. Dialog waits for user to press key. As I press OK/Cancel message of > > > > "unhandled Exception" is shown execution control goes to > > > > CWnd::DestroyWindow() function. > > > > I am showing here some lines in the function:- > > > > #ifdef _AFX_NO_OCC_SUPPORT > > > > BOOL bResult = ::DestroyWindow(m_hWnd); > > > > #else //_AFX_NO_OCC_SUPPORT > > > > BOOL bResult; > > > > if (m_pCtrlSite == NULL) > > > > bResult = ::DestroyWindow(m_hWnd); > > > > else > > > > bResult = m_pCtrlSite->DestroyControl(); //execution stops at this point// > > > > #endif //_AFX_NO_OCC_SUPPORT > > > > > > > > // Note that 'this' may have been deleted at this point, > > > > // (but only if pWnd != NULL) > > > > if (pWnd != NULL) > > > > { > > > > // Should have been detached by OnNcDestroy > > > > #ifdef _DEBUG > > > > ASSERT(pMap->LookupPermanent(hWndOrig) == NULL); > > > > #endif > > > > } > > > > else > > > > { > > > > #ifdef _DEBUG > > > > ASSERT(m_hWnd == hWndOrig); > > > > #endif > > > > // Detach after DestroyWindow called just in case > > > > Detach(); > > > > } > > > > return bResult; > > > > > > > > 2)If breakpoint is set at KillTimer() function > > > > > > > > As I press F5 first graph appears in dialog and then the dialog > > > > disappeares.Again I press F5 ,this time second graph appears on dialog and > > > > dialog box waits for key to be pressed..As I press OK/Cancel same error of > > > > unhandled exception occurs and control again goes to Cwnd::DestroyWindow() > > > > function as given in above code.Execution also stops as same point above > > > > > > > > Please help > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > "hughgray@hotmail.co.uk" wrote: > > > > > > > > > sayu wrote: > > > > > > hello, > > > > > > I am reading a file in chunks of 512 bytes(i am reading 2 such > > > > > > blocks).I am calling SetTimer function.And in corresponding OnTimer function > > > > > > I am writing code for displaying the file data on a graph control placed in > > > > > > my dialog box.I am calling the KillTimer function after the 2 chunks of data > > > > > > are displayed as graphs. > > > > > > But when i close the dialog or press OK/Cancel button the dialog MFC > > > > > > application error box appears which asks "whether to send the error report to > > > > > > microsoft".Why is this coming?First i thought maybe the KillTimer function > > > > > > isnt properly called but that is not the case since when i debugged the > > > > > > program i got the result that Killtimer is properly called. > > > > > > Its after i close the .EXE or press OK to close the dialog then the MFC > > > > > > error box appears. > > > > > > > > > > > > please please help fast.. > > > > > > p.s.-as i degugged the program an unexpected exception occurs after i press > > > > > > OK or Close button > > > > > > > > > > The timer functions are unlikely to be the cause of your problem. Most > > > > > likely you have a bug somewhere else in your program. Try posting a > > > > > minimal example that reproduces the behaviour (the key here is minimal > > > > > - for one you may spot the problem yourself, if not the smaller the > > > > > better to be easily digestible by others who may be able to help). > > > > > > > > > > Regards, > > > > > > > > > > Hugh > > > > > > > > > > > > > > > > It's still difficult to try and determine what the problem is. However, > > > you say that execution stops on - > > > > > > m_pCtrlSite->DestroyControl() > > > > > > - which may indicate that the problem is related to the ActiveX > > > graphing control you are using. I would suggest creating a new empty > > > project and then insert this control onto the main dialog. Run the > > > project and make sure there's no crash. Then add in small bits of > > > functionality to clear the graph, display a little data etc. Make sure > > > there's no crash. It could be that you have to call some kind of > > > cleanup function on the graph before closing the dialog. Again, there > > > is not enough information to be sure here. > > > > > > It might also be worth a check over the documentation for the control > > > just to make sure you haven't missed anything else. > > > > > > Is it a well known graphing control you are using? Are there any > > > support resources available for it? If so you could try that avenue as > > > well. > > > > > > Hugh > > > > > > > > Well I can't vouch for this control but I'll take a look at it when I > get some time. Chances are that the problem could be somewhere else in > your code anyway. I would keep experimenting with removing bits of your > code to see if you can narrow things down. > > Regards, > > Hugh Right I've had a quick look at this. I have a simple application working and I have pasted your OnTimer code in. I have made a couple of minor modifications to get it to compile on my machine. Here it is - void CGraphTestDlg::OnTimer(UINT nIDEvent) { UpdateData(TRUE); double var_x=0; static int i=0; static int j=512; m_GraphCtrl.ClearGraph(); for(;i<j;i++) { m_GraphCtrl.SetElementLineColor(2000); m_GraphCtrl.PlotXY(var_x,(double)buff[i],0); var_x=var_x+(46.875/1000); } j=j+512; if(j>1024) { KillTimer(1); } UpdateData(FALSE); CDialog::OnTimer(nIDEvent); } I have declared buff as - double buff[1024]; in the dialog class and initialized every element to 0.2 in OnInitDialog. I then call SetTimer(1, 1000, NULL). I didn't change any of the properties of the graph control in the dialog. When executing all this I get no error when clicking Ok or Cancel. Looks like your problem is most likely elsewhere in code we haven't seen. Regards, Hugh
I am working on your points but it will be of help if you please go through the code of the control whenever you have time.I have given the link to the control in my earlier message.please tell me if you find some problem in the control. thanks and reply "Mihajlo Cvetanović" wrote: > sayu wrote: > > 2)when i displayed 1 set of data(512 bytes) in OnInitdialog() function(not > > using SetTimer and Ontimer) then there is no problem.so logic is ok > > What happens if you display both sets in OnInitDialog? > What happens if you display only one set in OnTimer? > When exception occurs what are the values of "this" and m_pCtrlSite? > Maybe CWnd::DestroyWindow is somehow called twice... >
sayu wrote: > I am working on your points but it will be of help if you please go through > the code of the control whenever you have time.I have given the link to the > control in my earlier message.please tell me if you find some problem in the > control. > thanks and reply > > "Mihajlo Cvetanovic" wrote: > > > sayu wrote: > > > 2)when i displayed 1 set of data(512 bytes) in OnInitdialog() function(not > > > using SetTimer and Ontimer) then there is no problem.so logic is ok > > > > What happens if you display both sets in OnInitDialog? > > What happens if you display only one set in OnTimer? > > When exception occurs what are the values of "this" and m_pCtrlSite? > > Maybe CWnd::DestroyWindow is somehow called twice... > > I've already done this with no errors. See my other reply. No point in two of us doing it. Hugh
sayu wrote: > I am working on your points but it will be of help if you please go through > the code of the control whenever you have time.I have given the link to the > control in my earlier message.please tell me if you find some problem in the > control. Because of the rating 4.79 and the fact that the last change was in August 2003 (and the fact that the exception occurs in your code) my strong belief is that the bug isn't in the control.
hello, So r u plotting a graph with y axis values as 0.2.Coz in my code buff[1024] stores y axis values read from a file(which i am reading in OnInitDialog()).The i plot data from 0 to 511 bytes in array.Incremnts j;so that in next SetTimer loop the plot loop works for plotting next 512 values and then if j>1024 it calls killtimer(). I am thinking of overloading DestroyWindow() function in my class and call killtimer there.I tried but it isnt working.Please ur suggestion on this..... "hughgray@hotmail.co.uk" wrote: > sayu wrote: > > I am working on your points but it will be of help if you please go through > > the code of the control whenever you have time.I have given the link to the > > control in my earlier message.please tell me if you find some problem in the > > control. > > thanks and reply > > > > "Mihajlo Cvetanovic" wrote: > > > > > sayu wrote: > > > > 2)when i displayed 1 set of data(512 bytes) in OnInitdialog() function(not > > > > using SetTimer and Ontimer) then there is no problem.so logic is ok > > > > > > What happens if you display both sets in OnInitDialog? > > > What happens if you display only one set in OnTimer? > > > When exception occurs what are the values of "this" and m_pCtrlSite? > > > Maybe CWnd::DestroyWindow is somehow called twice... > > > > > I've already done this with no errors. See my other reply. No point in > two of us doing it. > > Hugh > >
sayu wrote: > hello, > So r u plotting a graph with y axis values as 0.2.Coz in my code > buff[1024] stores y axis values read from a file(which i am reading in > OnInitDialog()).The i plot data from 0 to 511 bytes in array.Incremnts j;so > that in next SetTimer loop the plot loop works for plotting next 512 values > and then if j>1024 it calls killtimer(). > I am thinking of overloading DestroyWindow() function in my class and call > killtimer there.I tried but it isnt working.Please ur suggestion on this..... > > > "hughgray@hotmail.co.uk" wrote: > > > sayu wrote: > > > I am working on your points but it will be of help if you please go through > > > the code of the control whenever you have time.I have given the link to the > > > control in my earlier message.please tell me if you find some problem in the > > > control. > > > thanks and reply > > > > > > "Mihajlo Cvetanovic" wrote: > > > > > > > sayu wrote: > > > > > 2)when i displayed 1 set of data(512 bytes) in OnInitdialog() function(not > > > > > using SetTimer and Ontimer) then there is no problem.so logic is ok > > > > > > > > What happens if you display both sets in OnInitDialog? > > > > What happens if you display only one set in OnTimer? > > > > When exception occurs what are the values of "this" and m_pCtrlSite? > > > > Maybe CWnd::DestroyWindow is somehow called twice... > > > > > > > > I've already done this with no errors. See my other reply. No point in > > two of us doing it. > > > > Hugh > > > > The chances of the y values or the timer stuff having anything to do with your crash are very slim. Try setting all the y values to 0.2 and see if it makes a difference. Try cutting out bits of functionality until the problem goes away. Are you allocating any dynamic memory? What is the call stack when the exception occurs? These are all questions you should be asking yourself. As I've already demonstrated the code you originally posted is most likely not the problem. Good luck, Hugh
hello guys, my problem is solved.Finally tired of all the debugging I created a new project and inserted the same code in that.It worked allright!!!!!:) But thinking about it i decided what could have went wrong with Killtimer or for that matterCWnd::OnDestroy() and Destoryctrl() in that .Whether some function might have accidently got deleted or some file.When i posted a query in my program to find function DestroyCtrl() it gave me message,"cannot find string".i think these are standard windows functions and are only linked while compiling and build.So can u people guess what the problem might have been...It will be useful for me in future.... and thanks a lot for your guidence and help "hughgray@hotmail.co.uk" wrote: > sayu wrote: > > I am working on your points but it will be of help if you please go through > > the code of the control whenever you have time.I have given the link to the > > control in my earlier message.please tell me if you find some problem in the > > control. > > thanks and reply > > > > "Mihajlo Cvetanovic" wrote: > > > > > sayu wrote: > > > > 2)when i displayed 1 set of data(512 bytes) in OnInitdialog() function(not > > > > using SetTimer and Ontimer) then there is no problem.so logic is ok > > > > > > What happens if you display both sets in OnInitDialog? > > > What happens if you display only one set in OnTimer? > > > When exception occurs what are the values of "this" and m_pCtrlSite? > > > Maybe CWnd::DestroyWindow is somehow called twice... > > > > > I've already done this with no errors. See my other reply. No point in > two of us doing it. > > Hugh > >
sayu wrote: > while compiling and build.So can u people guess what the problem might have > been...It will be useful for me in future.... I guess the bug is in the code that is different in old and new project :-) There is not enough information to give you more detailed answer.
sayu wrote: > hello guys, > my problem is solved.Finally tired of all the debugging I > created a new project and inserted the same code in that.It worked > allright!!!!!:) > But thinking about it i decided what could have went wrong with Killtimer or > for that matterCWnd::OnDestroy() and Destoryctrl() in that .Whether some > function might have accidently got deleted or some file.When i posted a query > in my program to find function DestroyCtrl() it gave me message,"cannot find > string".i think these are standard windows functions and are only linked > while compiling and build.So can u people guess what the problem might have > been...It will be useful for me in future.... > and thanks a lot for your guidence and help > > > "hughgray@hotmail.co.uk" wrote: > > > sayu wrote: > > > I am working on your points but it will be of help if you please go through > > > the code of the control whenever you have time.I have given the link to the > > > control in my earlier message.please tell me if you find some problem in the > > > control. > > > thanks and reply > > > > > > "Mihajlo Cvetanovic" wrote: > > > > > > > sayu wrote: > > > > > 2)when i displayed 1 set of data(512 bytes) in OnInitdialog() function(not > > > > > using SetTimer and Ontimer) then there is no problem.so logic is ok > > > > > > > > What happens if you display both sets in OnInitDialog? > > > > What happens if you display only one set in OnTimer? > > > > When exception occurs what are the values of "this" and m_pCtrlSite? > > > > Maybe CWnd::DestroyWindow is somehow called twice... > > > > > > > > I've already done this with no errors. See my other reply. No point in > > two of us doing it. > > > > Hugh > > > > Glad you managed to fix it. Hugh