Re: PreTranslateMessage gets called wrongly (after view destroyed)

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Corey Cooper (CoreyC_at_InnovativeDesign.com)
Date: 06/23/04

  • Next message: Corey Cooper: "Switching Accelerators?"
    Date: Wed, 23 Jun 2004 13:48:05 -0700
    
    

    Have you tried destroying your controls in the OnDestroy() override, and
    leave the destructor to actual memory deallocation of items that need it? As
    I understand it, deleting the controls only sends messages asking them to
    destroy themselves, so that should be done within the MFC destruction
    process, leaving the CPP destruction process to actually release memory as
    nessisary for things that need it like memory allocated with new.

    C.

    "Kieren Gracie" <KierenGracie@discussions.microsoft.com> wrote in message
    news:940824EB-BD95-4464-AC1C-3D9DCAF24536@microsoft.com...
    > More more info - if I don't delete the controls I created in the
    destructor, then I don't see the ASSERT failure but of course I then get a
    memory leak.
    >
    > So the order of stuff is -
    >
    > Destroy view
    > View destructor gets called
    > - in view destructor, delete control
    > PreTranslateMessage gets called in the class which has been destroyed,
    oops, ASSERT failure when I call IsChild
    >
    > But if I don't delete the control, PreTranslateMessage doesn't get called
    after the object is destroyed.
    >
    > Anyone?


  • Next message: Corey Cooper: "Switching Accelerators?"

    Relevant Pages

    • Re: Multiple destructors?
      ... and it seemed to me that destroying a file object might be a ... > Destroy would just destroy the list, ... For it is the destructor called by Free. ... Actually, on checking, all virtual methods in TObject are in the ...
      (comp.lang.pascal.delphi.misc)
    • Re: Regarding DestroyWindow and CEdit dervied class
      ... I don't know what you mean by "a pointer containing" because a pointer can't point to more ... You can't call destroy and delete ... If you are creating edit controls and destroying them only to re-create new edit controls ... dead pointers from the array (typically, if you are destroying everything in the array, it ...
      (microsoft.public.vc.mfc)
    • Re: Runtime Error 216?
      ... >> Does the finalization exception occur when the database can't ... > Only when the database can't be opened, ... > inherited Destroy method of, or why there is a problem with this attempt to ... You could count the number of controls where destroying works. ...
      (borland.public.delphi.language.objectpascal)
    • Re: Access Subform Shows Deleted Form
      ... but showing something that has supposedly been ... The commands are there to make it possible to create or destroy forms ... controls is not an option; there are too many possible permutations. ... John Nurick ...
      (microsoft.public.access.forms)
    • Re: Fun with CStatic destructor
      ... I'm not doing anything special when I destroy the CStatics - I'm using ... The odd code in OnOKis because of the self-validating controls. ... Basically, if you pressed Return, they didn't validate until after the ... of windows that weren't there. ...
      (microsoft.public.vc.mfc)