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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. How to get a function pointer ?

How to get a function pointer ?

Scheduled Pinned Locked Moved Managed C++/CLI
c++dotnetcomhelptutorial
6 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.
  • K Offline
    K Offline
    Ky Nam
    wrote on last edited by
    #1

    Hi I wrote this code with /clr , EnumChildWindows is C++ Interop BOOL CALLBACK EnumWindowsCallback(HWND hWnd, LPARAM lParam){} EnumChildWindows(hwnd, EnumWindowsCallback, 0); Error error C3867: 'EnumWindowsCallback': function call missing argument list; use '&EnumWindowsCallback' to create a pointer to member How to call EnumChildWindows function not using p/invoke ? Thanks :)

    D K G 3 Replies Last reply
    0
    • K Ky Nam

      Hi I wrote this code with /clr , EnumChildWindows is C++ Interop BOOL CALLBACK EnumWindowsCallback(HWND hWnd, LPARAM lParam){} EnumChildWindows(hwnd, EnumWindowsCallback, 0); Error error C3867: 'EnumWindowsCallback': function call missing argument list; use '&EnumWindowsCallback' to create a pointer to member How to call EnumChildWindows function not using p/invoke ? Thanks :)

      D Offline
      D Offline
      dkaatz
      wrote on last edited by
      #2

      EnumChildWindows(hWnd, (WNDENUMPROC)&enumChildWndCallback, 0); D.

      K 1 Reply Last reply
      0
      • D dkaatz

        EnumChildWindows(hWnd, (WNDENUMPROC)&enumChildWndCallback, 0); D.

        K Offline
        K Offline
        Ky Nam
        wrote on last edited by
        #3

        Thank for your reply , but BOOL CALLBACK EnumWindowsCallback(HWND hWnd, LPARAM lParam){} EnumChildWindows(Handle, (WNDENUMPROC)&EnumWindowsCallback, 0); error C2276: '&' : illegal operation on bound member function expression

        L 1 Reply Last reply
        0
        • K Ky Nam

          Thank for your reply , but BOOL CALLBACK EnumWindowsCallback(HWND hWnd, LPARAM lParam){} EnumChildWindows(Handle, (WNDENUMPROC)&EnumWindowsCallback, 0); error C2276: '&' : illegal operation on bound member function expression

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          Hi, I don't know the details in C++ but here is how I do it in C#; it takes a delegate, and code along these lines where list happened to be an ArrayList:

          public delegate bool LP_EnumWindowsProc(IntPtr hWnd, int lParam);

          // this call fills list with all visible windows
          EnumChildWindows(hWnd, new LP_EnumWindowsProc(CollectVisibleWindows), 0);

          private static bool CollectVisibleWindows(IntPtr hWnd, int lParam) {
          if(IsWindowVisible(hWnd)) list.Add(hWnd);
          return true; // please continue enumeration !
          }

          :)

          Luc Pattyn [Forum Guidelines] [My Articles]


          Sorry for any delays in replying, I currently don't always get e-mail notifications.


          1 Reply Last reply
          0
          • K Ky Nam

            Hi I wrote this code with /clr , EnumChildWindows is C++ Interop BOOL CALLBACK EnumWindowsCallback(HWND hWnd, LPARAM lParam){} EnumChildWindows(hwnd, EnumWindowsCallback, 0); Error error C3867: 'EnumWindowsCallback': function call missing argument list; use '&EnumWindowsCallback' to create a pointer to member How to call EnumChildWindows function not using p/invoke ? Thanks :)

            K Offline
            K Offline
            Ky Nam
            wrote on last edited by
            #5

            I need to write this code in C++/CLI only , VS 2008 , /clr After trying C++ Interop unsuccessfully , I use p/invoke and .NET delegate

            delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);

            [DllImport("user32", CharSet=CharSet::Ansi, SetLastError=true, ExactSpelling=true)] static int EnumChildWindows(IntPtr hWndParent, EnumWindowsProc^ lpEnumFunc, IntPtr lParam){}

            bool CALLBACK EnumWindowsCallback(IntPtr hWnd, IntPtr lParam){}

            void UseIt() //errors
            {
            EnumWindowsProc^ fp = gcnew EnumWindowsProc(EnumWindowsCallback);
            EnumChildWindows(Handle, fp, IntPtr::Zero);
            }

            error C3350: 'EnumWindowsProc' : a delegate constructor expects 2 argument(s) error C3867: 'EnumWindowsCallback': function call missing argument list; use '&EnumWindowsCallback' to create a pointer to member I can't understand

            1 Reply Last reply
            0
            • K Ky Nam

              Hi I wrote this code with /clr , EnumChildWindows is C++ Interop BOOL CALLBACK EnumWindowsCallback(HWND hWnd, LPARAM lParam){} EnumChildWindows(hwnd, EnumWindowsCallback, 0); Error error C3867: 'EnumWindowsCallback': function call missing argument list; use '&EnumWindowsCallback' to create a pointer to member How to call EnumChildWindows function not using p/invoke ? Thanks :)

              G Offline
              G Offline
              George L Jackson
              wrote on last edited by
              #6
              // Delelgate
              delegate bool EnumWindowProc(IntPtr hWnd, Int32 lParam);
               
              // Global callback function
              bool GlobalCallback(IntPtr hWnd, Int32 lParam)
              {
              	// ...
              	
              	return true;
              }
               
              DllImport("User32.DLL")]
              public static extern void EnumWindows(EnumWindowProc callback, Int32 lParam);
               
              // Your code ...
               
              // Using global function syntax for creating delegate
              EnumWindowProc^ ewp += gcnew EnumWindowProc(&GlobalCallback);
               
              // ,,,
               
              // Invoke Delegate
              EnumWindows(ewp, 0);
              

              "We make a living by what we get, we make a life by what we give." --Winston Churchill

              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