Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: MFC VC++
I am destroying GraphView Window Created By Me On Clear Button,
Code Works Fine In Debug Mode But Crashes In Release Mode.
Please Help
 

 if(IsWindow(objTabCalibrationResult->m_pGraph->m_hWnd))
            objTabCalibrationResult->m_pGraph->DestroyWindow();
Posted 12-Feb-13 21:16pm
Comments
Richard MacCutchan at 13-Feb-13 4:51am
   
This needs a lot more detail; we cannot guess from the above what may be happening.
adityarao31 at 13-Feb-13 9:34am
   
If I remove these two line code works absolutely fine in release mode also
Richard MacCutchan at 13-Feb-13 11:28am
   
Well, there's your solution.
adityarao31 at 13-Feb-13 13:03pm
   
But I require to clear graph
Richard MacCutchan at 13-Feb-13 13:24pm
   
Well you need to provide a lot more details of what you are trying to do and what your code is doing. As it stands we cannot guess what is going on.
Binu MD at 14-Feb-13 0:48am
   
Please give deatils like
1) clear button is placed on parent window or graph window.
2) Why are you try to destroy window instead of clearing.
3) What is your requirement clear window or destroy window.
etc..
adityarao31 at 14-Feb-13 2:22am
   
Clear button is placed on parent button in ehich above code is written.
Requirement of application is to remove total graphview on clear button.
Is there any function like clearwindow?
Binu MD at 14-Feb-13 3:37am
   
You can use Invalidate() or FillRect() functions to clear the graph.
adityarao31 at 14-Feb-13 3:25am
   
Actually i got the problem.In my code some times I require to delete graph,but that tine graph is not existing so I kept condition OF IsWindow,but it seems is window crashes
I dont know how to fix problem? or I have to keep track by boolean variable like
IsGraphExist. Is there any other way I can know If graph view exist.
Binu MD at 14-Feb-13 3:39am
   
One more thing
 
Confirm that IsWindow() is called from the thread, that created the GraphView.
adityarao31 at 14-Feb-13 3:45am
   
Thank you very much for your time and effort

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

My Problem got solved by using IsBadReadPtr Function.I thanks to every one who tried to solve the problem
 
if(!::IsBadReadPtr(m_pGraph,1))
    if(IsWindow(m_pGraph->m_hWnd))
        m_pGraph->DestroyWindow();
}
  Permalink  
Comments
CPallini at 14-Feb-13 4:34am
   
You may find interesting this documentation page:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa366713(v=vs.85).aspx
Richard MacCutchan at 14-Feb-13 4:59am
   
If you just want to clear the client area of the Window, then you should set a flag, or clear all the data of the graph, then use InvalidateWindow(). Then in your paint function you should check if a graph exists and do nothing if there is no data. That will automatically clear the graph from the window.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 5,170
1 DamithSL 4,357
2 Maciej Los 3,750
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,851


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 14 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100