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. Help GWLP_USERDATA

Help GWLP_USERDATA

Scheduled Pinned Locked Moved C / C++ / MFC
c++helptutorial
3 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.
  • V Offline
    V Offline
    vishalgpt
    wrote on last edited by
    #1

    SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR) content);
    content = (Content *) GetWindowLongPtr(hWnd, GWLP_USERDATA);

    the above code works in window created using CreateWindow, but the same code fails when used with DialogBox. Is there any alternative to this. I want to store Pointer to a structure. using Win32 C++. please guide.

    Regards, Vishal

    P L 2 Replies Last reply
    0
    • V vishalgpt

      SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR) content);
      content = (Content *) GetWindowLongPtr(hWnd, GWLP_USERDATA);

      the above code works in window created using CreateWindow, but the same code fails when used with DialogBox. Is there any alternative to this. I want to store Pointer to a structure. using Win32 C++. please guide.

      Regards, Vishal

      P Offline
      P Offline
      pasztorpisti
      wrote on last edited by
      #2

      Long ago I used SetProp()[^], GetProp()[^], and RemoveProp()[^]. Try them, they might work. EDIT: On the page of SetProp() read the comments at the bottom of the page, contains important info!

      1 Reply Last reply
      0
      • V vishalgpt

        SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR) content);
        content = (Content *) GetWindowLongPtr(hWnd, GWLP_USERDATA);

        the above code works in window created using CreateWindow, but the same code fails when used with DialogBox. Is there any alternative to this. I want to store Pointer to a structure. using Win32 C++. please guide.

        Regards, Vishal

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        You can try using DWLP_USER as described here[^].

        One of these days I'm going to think of a really clever signature.

        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