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. .NET (Core and Framework)
  4. Where's the HWND in Form?

Where's the HWND in Form?

Scheduled Pinned Locked Moved .NET (Core and Framework)
c++comquestion
8 Posts 4 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.
  • S Offline
    S Offline
    Swinefeaster
    wrote on last edited by
    #1

    How do you get an HWND handle inside a Form object in C++, VC2005 ? Thanks swine [b]yte your digital photos with [ae]phid [p]hotokeeper - www.aephid.com.

    C 1 Reply Last reply
    0
    • S Swinefeaster

      How do you get an HWND handle inside a Form object in C++, VC2005 ? Thanks swine [b]yte your digital photos with [ae]phid [p]hotokeeper - www.aephid.com.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      It's the .Handle property, I believe. Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

      S 1 Reply Last reply
      0
      • C Christian Graus

        It's the .Handle property, I believe. Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

        S Offline
        S Offline
        Swinefeaster
        wrote on last edited by
        #3

        Is it a HWND type? I get a compiler error saying: Error 3 error C2440: 'type cast' : cannot convert from 'System::IntPtr' to 'HWND' My code is: HWND h = (HWND)Handle; [b]yte your digital photos with [ae]phid [p]hotokeeper - www.aephid.com.

        C J 2 Replies Last reply
        0
        • S Swinefeaster

          Is it a HWND type? I get a compiler error saying: Error 3 error C2440: 'type cast' : cannot convert from 'System::IntPtr' to 'HWND' My code is: HWND h = (HWND)Handle; [b]yte your digital photos with [ae]phid [p]hotokeeper - www.aephid.com.

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          I'm not sure how to do that conversion, but I've passed the Handle in from C# when I make pinvoked API calls and it's worked fine. Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

          S 1 Reply Last reply
          0
          • C Christian Graus

            I'm not sure how to do that conversion, but I've passed the Handle in from C# when I make pinvoked API calls and it's worked fine. Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

            S Offline
            S Offline
            Swinefeaster
            wrote on last edited by
            #5

            That's great but here it doesn't work. :confused: [b]yte your digital photos with [ae]phid [p]hotokeeper - www.aephid.com.

            G 1 Reply Last reply
            0
            • S Swinefeaster

              That's great but here it doesn't work. :confused: [b]yte your digital photos with [ae]phid [p]hotokeeper - www.aephid.com.

              G Offline
              G Offline
              Guffa
              wrote on last edited by
              #6

              To verify that the Handle property really contains a HWND: MSDN quote: "Syntax public IntPtr Handle { get; } Property Value An IntPtr that contains the window handle (HWND) of the control. Remarks The value of the Handle property is a Windows HWND. If the handle has not yet been created, referencing this property will force the handle to be created." --- b { font-weight: normal; }

              1 Reply Last reply
              0
              • S Swinefeaster

                Is it a HWND type? I get a compiler error saying: Error 3 error C2440: 'type cast' : cannot convert from 'System::IntPtr' to 'HWND' My code is: HWND h = (HWND)Handle; [b]yte your digital photos with [ae]phid [p]hotokeeper - www.aephid.com.

                J Offline
                J Offline
                Joel Lucsy
                wrote on last edited by
                #7

                If form was your form object, try: (HWND)form.Handle.ToPointer()

                S 1 Reply Last reply
                0
                • J Joel Lucsy

                  If form was your form object, try: (HWND)form.Handle.ToPointer()

                  S Offline
                  S Offline
                  Swinefeaster
                  wrote on last edited by
                  #8

                  Excellent! That's exactly what I needed. Thanks :) :) [b]yte your digital photos with [ae]phid [p]hotokeeper - www.aephid.com.

                  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