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 / C++ / MFC
  4. Converting HWnd to CWnd

Converting HWnd to CWnd

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 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.
  • W Offline
    W Offline
    whatever89
    wrote on last edited by
    #1

    Hi, how can i get a handle to my current window class?, i mean from within the class, if its possible at all. and is there any way to convert between both HWnd and CWnd , f.e a function that takes a handle and returns a pointer ? thanks

    V N W 3 Replies Last reply
    0
    • W whatever89

      Hi, how can i get a handle to my current window class?, i mean from within the class, if its possible at all. and is there any way to convert between both HWnd and CWnd , f.e a function that takes a handle and returns a pointer ? thanks

      V Offline
      V Offline
      Vinaya
      wrote on last edited by
      #2

      CWnd::FromHandle() [^] Vini

      1 Reply Last reply
      0
      • W whatever89

        Hi, how can i get a handle to my current window class?, i mean from within the class, if its possible at all. and is there any way to convert between both HWnd and CWnd , f.e a function that takes a handle and returns a pointer ? thanks

        N Offline
        N Offline
        Nibu babu thomas
        wrote on last edited by
        #3

        saadani wrote:

        is there any way to convert between both HWnd and CWnd , f.e a function that takes a handle and returns a pointer ?

        HWND to CWnd * CWnd *pWnd = CWnd::FromHandle(aHwnd); CWnd to HWND HWND aHwnd = pWnd->GetSafeHwnd();

        saadani wrote:

        how can i get a handle to my current window class?, i mean from within the class

        HWND hWnd = this->GetSafeHwnd();


        Nibu thomas Software Developer

        1 Reply Last reply
        0
        • W whatever89

          Hi, how can i get a handle to my current window class?, i mean from within the class, if its possible at all. and is there any way to convert between both HWnd and CWnd , f.e a function that takes a handle and returns a pointer ? thanks

          W Offline
          W Offline
          walter76
          wrote on last edited by
          #4

          From the Documentation of the CWnd-Class: CWnd::m_hWnd Remarks The handle of the Windows window attached to this CWnd. The m_hWnd data member is a public variable of type HWND. CWnd::GetSafeHwnd HWND GetSafeHwnd( ) const; Return Value Returns the window handle for a window. Returns NULL if the CWnd is not attached to a window or if it is used with a NULL CWnd pointer. Hope this helps you out. Walter

          W 1 Reply Last reply
          0
          • W walter76

            From the Documentation of the CWnd-Class: CWnd::m_hWnd Remarks The handle of the Windows window attached to this CWnd. The m_hWnd data member is a public variable of type HWND. CWnd::GetSafeHwnd HWND GetSafeHwnd( ) const; Return Value Returns the window handle for a window. Returns NULL if the CWnd is not attached to a window or if it is used with a NULL CWnd pointer. Hope this helps you out. Walter

            W Offline
            W Offline
            whatever89
            wrote on last edited by
            #5

            thanks a lot

            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