Thread: the handle is invalid

  1. #1
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    838

    the handle is invalid

    i am getting this message intermittently during runtime with a new control i developed. the control is pretty straightforward. i don't understand what's causing this at all.

    i haven't come across this before. i know it's something from windows, but from googling, this appears to happen in such a broad variety of situations that i can't find anything that's actually helping me narrow down the possible causes, let alone a solution.

    please help.
    Last edited by m37h0d; 07-08-2008 at 07:24 PM.

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    If you expect us to figure it out from that description, you're probably dreaming.

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    Do you know how to use your debugger?

  4. #4
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    838
    i know that's not a lot of information, but i don't have anything more myself. i can't isolate it to a particular line, only somewhere in the control...

    and yes, i tried stepping through it over and over again, but i could never get it to occur when i was doing that.

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    Can't you break execution when the error occurs? What debugger are you using?

  6. #6
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    838
    i use borland C++ builder.

    anyway, i changed the control to use different (non-COM) subcomponents and now the error isn't happening anymore.

    i'd still like to know a lot more about using the debugger tools more effectively, and how to ensure that i obtain handles safely and allocating on the stack/heap/etc...

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Practice using the debugger on a program you know works.

    Add known "errors" to your program, say stepping off the end of an array, and use the debugger to "find" the problem.

    Like anything else, actual practical experience is how you learn this stuff. And trying to learn it in the middle of a crisis doesn't help.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  8. #8
    Registered User
    Join Date
    Jul 2003
    Posts
    110
    Quote Originally Posted by Salem View Post
    Like anything else, actual practical experience is how you learn this stuff. And trying to learn it in the middle of a crisis doesn't help.
    Amen! However, being in the middle of a crisis tends to focus my concentration like nothing else.

  9. #9
    Registered User
    Join Date
    May 2008
    Location
    Paris
    Posts
    248
    Coffee, whoie, coffee...

  10. #10
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    838
    ok, well it's not as resolved as i thought.

    the problem here is that when this error occurs, the debugger doesn't resolve to any line. it just brings me to wherever i was in the IDE, but doesn't highlight any line or anything.

  11. #11
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Did you compile the program with debugging information enabled?
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  12. #12
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    838
    yes.

  13. #13
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    Look in the call stack, is there anything there? Can you find some part of your code and go to that?

  14. #14
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    838
    never used that before. i'll give it a try!

    thanks! i'm totally open to any and all suggestions. i have a rather nice system message system worked out now, i'd hate to replace it with a stupid, featureless memo.



    the only thing that sticks out is that i did the following:
    Code:
    __fastcall systemMessage::systemMessage(TSystemMessageScreen *Owner,String msg) :
            TPanel(Owner),
            owner(Owner),
            memo(new TLabel(this))
    {
    //...etc.
    }
    is it unsafe to invoke the this pointer in a constructor list like this?
    Last edited by m37h0d; 07-09-2008 at 07:45 PM.

  15. #15
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    >> is it unsafe to invoke the this pointer in a constructor list like this?
    Potentially. If the systemMessage object is used in the TLabel constructor (or indirectly in the memo constructor) then it would be a problem.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do you resolve this error?
    By -EquinoX- in forum C Programming
    Replies: 32
    Last Post: 11-05-2008, 04:35 PM
  2. Invalid Handle Error
    By smarta_982002 in forum Windows Programming
    Replies: 2
    Last Post: 03-24-2008, 10:48 AM
  3. Getting other processes class names
    By Hawkin in forum Windows Programming
    Replies: 3
    Last Post: 03-20-2008, 04:02 PM
  4. Direct3D problem
    By cboard_member in forum Game Programming
    Replies: 10
    Last Post: 04-09-2006, 03:36 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM