Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. get invalid handle when called GetWindowLong.

get invalid handle when called GetWindowLong.

Scheduled Pinned Locked Moved C#
help
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    prasadbuddhika
    wrote on last edited by
    #1

    i'm trying to get information about a panel in my application , so i called GetWindowLong passing this.handle in the custom panel class, but i get the error 6 saying invalid handle, this.handle returns "2081229920" value. any idea, thanx in advance.

    L 1 Reply Last reply
    0
    • P prasadbuddhika

      i'm trying to get information about a panel in my application , so i called GetWindowLong passing this.handle in the custom panel class, but i get the error 6 saying invalid handle, this.handle returns "2081229920" value. any idea, thanx in advance.

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Every mature Winforms Control has a Handle property, that is what you should use as a HWND when P/Invoking API functions; and the Handle typically only exists when the Control has been fully created, which I think is when the holding Form is Loaded or Shown. :)

      Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

      Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

      P 1 Reply Last reply
      0
      • L Luc Pattyn

        Every mature Winforms Control has a Handle property, that is what you should use as a HWND when P/Invoking API functions; and the Handle typically only exists when the Control has been fully created, which I think is when the holding Form is Loaded or Shown. :)

        Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

        Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

        P Offline
        P Offline
        prasadbuddhika
        wrote on last edited by
        #3

        thanx, ok actually i made that call in the onpaint method, but when i debug this.handle returned a value. so even though the handle is there it is not enough , is it the reason , means the control is not completely drawn. thanx

        L D 2 Replies Last reply
        0
        • P prasadbuddhika

          thanx, ok actually i made that call in the onpaint method, but when i debug this.handle returned a value. so even though the handle is there it is not enough , is it the reason , means the control is not completely drawn. thanx

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          if you want more help, you'll have to provide a better description of the situation and the problem, and probably show some code. I also am puzzled why you would need handles in an OnPaint handler, I've never seen that. I do know it is wise to keep paint handlers short, simple and swift. :)

          Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

          Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

          1 Reply Last reply
          0
          • P prasadbuddhika

            thanx, ok actually i made that call in the onpaint method, but when i debug this.handle returned a value. so even though the handle is there it is not enough , is it the reason , means the control is not completely drawn. thanx

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #5

            You got A value, not a VALID value. Having a value other than zero does not means it's valid. You can check this with the IsHandleCreated property of your control.

            A guide to posting questions on CodeProject[^]
            Dave Kreskowiak

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups