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. SetWindowLong using a class member function?

SetWindowLong using a class member function?

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

    Hi I have the following situation: SetWindowLong(hWnd,GWL_WNDPROC,(LONG)MyOwnWndProc); MyOwnWndProc is a member function of a class I've made. Now I was wondering if it's possible to somehow convert a pointer to the function or something to a LONG. In its current state this won't compile. I've already tried making a class member pointer, and tried to convert that to a LONG, but alas no go. And no, I don't want to use a non-class function. I really need to know if it's possible with a class function. Many thanks in advance, DanglingDude

    J D 2 Replies Last reply
    0
    • H Harco

      Hi I have the following situation: SetWindowLong(hWnd,GWL_WNDPROC,(LONG)MyOwnWndProc); MyOwnWndProc is a member function of a class I've made. Now I was wondering if it's possible to somehow convert a pointer to the function or something to a LONG. In its current state this won't compile. I've already tried making a class member pointer, and tried to convert that to a LONG, but alas no go. And no, I don't want to use a non-class function. I really need to know if it's possible with a class function. Many thanks in advance, DanglingDude

      J Offline
      J Offline
      Jagadeesh VN
      wrote on last edited by
      #2

      Its possible with class member functions. Try this LRESULT CALLBACK YourClass::MyOwnWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { } and then use SetWindowLong(hWnd,GWL_WNDPROC,(LONG)MyOwnWndProc); "A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."

      H 1 Reply Last reply
      0
      • H Harco

        Hi I have the following situation: SetWindowLong(hWnd,GWL_WNDPROC,(LONG)MyOwnWndProc); MyOwnWndProc is a member function of a class I've made. Now I was wondering if it's possible to somehow convert a pointer to the function or something to a LONG. In its current state this won't compile. I've already tried making a class member pointer, and tried to convert that to a LONG, but alas no go. And no, I don't want to use a non-class function. I really need to know if it's possible with a class function. Many thanks in advance, DanglingDude

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        DanglingDude wrote: And no, I don't want to use a non-class function. I really need to know if it's possible with a class function. MyOwnWndProc() would need to be a static member in order for this to work.


        Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

        1 Reply Last reply
        0
        • J Jagadeesh VN

          Its possible with class member functions. Try this LRESULT CALLBACK YourClass::MyOwnWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { } and then use SetWindowLong(hWnd,GWL_WNDPROC,(LONG)MyOwnWndProc); "A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."

          H Offline
          H Offline
          Harco
          wrote on last edited by
          #4

          This is exactly what I have now.. and doesn't work. Are you sure this is supposed to work?

          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