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#
  4. Somewhat new to C#...

Somewhat new to C#...

Scheduled Pinned Locked Moved C#
questioncsharpc++help
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
    JeremyLM
    wrote on last edited by
    #1

    but a long time C/C++ programmer. I've ran in to a bit of a spot that I just can't seem to get a grasp on. I have a callback in a C++ unmanaged DLL that I've written: LRESULT CALLBACK eventListener(HWND hWnd, UINT msg, WPARAM wP, LPARAM lP) { switch(msg) { case WM_PAINT: { PAINTSTRUCT ps; HDC hDc = BeginPaint(GetFocus(), &ps); if(g_currVideo != NULL) { const VideoFrame& currFrame = g_frames[g_currentFrame].frame; BITMAPINFO bi; ZeroMemory(&bi, sizeof(bi)); bi.bmiHeader.biSize = sizeof(bi); bi.bmiHeader.biWidth = currFrame.getWidth(); bi.bmiHeader.biHeight = currFrame.getHeight(); bi.bmiHeader.biPlanes = 1; bi.bmiHeader.biBitCount = 24; SetDIBitsToDevice(hDc, 0, 0, currFrame.getWidth(), currFrame.getHeight(), 0, 0, 0, currFrame.getHeight(), currFrame.getData(), &bi, DIB_RGB_COLORS); } EndPaint(GetFocus(), &ps); return 0; }break; ... } In C++, I would have no problem calling this, however, I am lost when it comes to doing it in C#. The DLL in question relies on the callback to load and play back frames and samples of an uncommon video format. In C#, I'm able to get it as far as loading that first frame and audio sample, however, without the callback, that's as far as I can go. My question is how would I implement use of this callback this in C#?

    C 1 Reply Last reply
    0
    • J JeremyLM

      but a long time C/C++ programmer. I've ran in to a bit of a spot that I just can't seem to get a grasp on. I have a callback in a C++ unmanaged DLL that I've written: LRESULT CALLBACK eventListener(HWND hWnd, UINT msg, WPARAM wP, LPARAM lP) { switch(msg) { case WM_PAINT: { PAINTSTRUCT ps; HDC hDc = BeginPaint(GetFocus(), &ps); if(g_currVideo != NULL) { const VideoFrame& currFrame = g_frames[g_currentFrame].frame; BITMAPINFO bi; ZeroMemory(&bi, sizeof(bi)); bi.bmiHeader.biSize = sizeof(bi); bi.bmiHeader.biWidth = currFrame.getWidth(); bi.bmiHeader.biHeight = currFrame.getHeight(); bi.bmiHeader.biPlanes = 1; bi.bmiHeader.biBitCount = 24; SetDIBitsToDevice(hDc, 0, 0, currFrame.getWidth(), currFrame.getHeight(), 0, 0, 0, currFrame.getHeight(), currFrame.getData(), &bi, DIB_RGB_COLORS); } EndPaint(GetFocus(), &ps); return 0; }break; ... } In C++, I would have no problem calling this, however, I am lost when it comes to doing it in C#. The DLL in question relies on the callback to load and play back frames and samples of an uncommon video format. In C#, I'm able to get it as far as loading that first frame and audio sample, however, without the callback, that's as far as I can go. My question is how would I implement use of this callback this in C#?

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      In C#, a callback is called a delegate. If you google delegates in C#, you'll find heaps of info on how they work.

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

      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