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. How can I make the "__stdcall" function to be local?

How can I make the "__stdcall" function to be local?

Scheduled Pinned Locked Moved C / C++ / MFC
question
2 Posts 2 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.
  • J Offline
    J Offline
    jame
    wrote on last edited by
    #1

    Hi, In my application, I need to call ::EnumChildWindows(m_hWnd, SetButtonState, (LPARAM)(Info)); How can make the following function to be local: BOOL __stdcall SetButtonState(HWND hwnd, LPARAM lparam) to be someclass' member function like: BOOL __stdcall CMyApp::SetButtonState(HWND hwnd, LPARAM lparam) -----> this is wrong! Some code sample will be much appreciated!!! Thank you very much!

    U 1 Reply Last reply
    0
    • J jame

      Hi, In my application, I need to call ::EnumChildWindows(m_hWnd, SetButtonState, (LPARAM)(Info)); How can make the following function to be local: BOOL __stdcall SetButtonState(HWND hwnd, LPARAM lparam) to be someclass' member function like: BOOL __stdcall CMyApp::SetButtonState(HWND hwnd, LPARAM lparam) -----> this is wrong! Some code sample will be much appreciated!!! Thank you very much!

      U Offline
      U Offline
      User 1472
      wrote on last edited by
      #2

      You don't. You can't pass a non-static member function because the parameter list doesn't match (remember in C++ all non-static member functions receive a hidden first parameter, the "this" pointer). What you can do is declare write your callback like this: BOOl __stdcall SetButtonState (HWND hwnd, LPARAM lparam) { CMyApp* app = (CMyApp*)lparam; ASSERT (app != NULL); app->SetButtonState (hwnd, lparam); } Then call EnumChildWindows with the global SetButtonState, like this: ::EnumChildWindows (m_hWnd, ::SetButtonState, (LPARAM)&myApp); The global SetButtonState just redirects each call back to the object that you specified in the call to EnumChildWindows You could also make the global SetButtonState a static member of your class. Cheers, Eric Tetz

      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