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. How to correectly catch WM_COPYDATA ?

How to correectly catch WM_COPYDATA ?

Scheduled Pinned Locked Moved C#
helpcsharpc++tutorialquestion
7 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.
  • G Offline
    G Offline
    gapfulgence
    wrote on last edited by
    #1

    Hi, I'm struggling with a problem. I want to catch a 'WM_COPYDATA' event that occurs in a C# application. I send a data from a C++ application. The bridge is correctly done I think. So, sometimes it works, usually when my C# application is active. But most of the time, it doesn't work, because when trying to catch the appropriate WM_COPYDATA message in WndProc overrided method of my C# application, the program stays catching a couple of other messages like: WM_WINDOWPOSCHANGED, WM_ACTIVATEAPP, WM_NCACTIVATE, WM_ACTIVATE and so on. Doing so, it almost never catch the WM_COPYDATA message that I sent from my C++ application. Can you help me please ? Thanks. P.S.: I catch messages in my C# application like this: protected override void WndProc(ref Message m) { string g = m.ToString(); if (m.Msg == WM_COPYDATA) { // instructions. } } p.f. Goudjo-Ako Bringing our energy together !

    p.f. Goudjo-Ako Bringing our energy together !

    K 1 Reply Last reply
    0
    • G gapfulgence

      Hi, I'm struggling with a problem. I want to catch a 'WM_COPYDATA' event that occurs in a C# application. I send a data from a C++ application. The bridge is correctly done I think. So, sometimes it works, usually when my C# application is active. But most of the time, it doesn't work, because when trying to catch the appropriate WM_COPYDATA message in WndProc overrided method of my C# application, the program stays catching a couple of other messages like: WM_WINDOWPOSCHANGED, WM_ACTIVATEAPP, WM_NCACTIVATE, WM_ACTIVATE and so on. Doing so, it almost never catch the WM_COPYDATA message that I sent from my C++ application. Can you help me please ? Thanks. P.S.: I catch messages in my C# application like this: protected override void WndProc(ref Message m) { string g = m.ToString(); if (m.Msg == WM_COPYDATA) { // instructions. } } p.f. Goudjo-Ako Bringing our energy together !

      p.f. Goudjo-Ako Bringing our energy together !

      K Offline
      K Offline
      kubben
      wrote on last edited by
      #2

      You really need to add:

      else //Let the normal windows messaging process it.
      {
      base.DefWndProc(ref m);
      }

      So that other windows messages get handled properly. I don't know if this will fix your issue or not. I am not sure if your C# app will receive the message if it is not active. Ben

      G 1 Reply Last reply
      0
      • K kubben

        You really need to add:

        else //Let the normal windows messaging process it.
        {
        base.DefWndProc(ref m);
        }

        So that other windows messages get handled properly. I don't know if this will fix your issue or not. I am not sure if your C# app will receive the message if it is not active. Ben

        G Offline
        G Offline
        gapfulgence
        wrote on last edited by
        #3

        I already had: base.WndProc(ref m); Isn't it supposed to do the same thing ? I tried what u asked me, but my c# application doesn't receive any information back. thx.

        p.f. Goudjo-Ako Bringing our energy together !

        K 1 Reply Last reply
        0
        • G gapfulgence

          I already had: base.WndProc(ref m); Isn't it supposed to do the same thing ? I tried what u asked me, but my c# application doesn't receive any information back. thx.

          p.f. Goudjo-Ako Bringing our energy together !

          K Offline
          K Offline
          kubben
          wrote on last edited by
          #4

          It is the same thing, I guess you didn't post that code in your previous post. Ben

          G 1 Reply Last reply
          0
          • K kubben

            It is the same thing, I guess you didn't post that code in your previous post. Ben

            G Offline
            G Offline
            gapfulgence
            wrote on last edited by
            #5

            Yes, I didn't post it. I also tried to use PostMessage instead of SendMessage. But I don't get appropriate results. Any idea ? Thx.

            p.f. Goudjo-Ako Bringing our energy together !

            K 1 Reply Last reply
            0
            • G gapfulgence

              Yes, I didn't post it. I also tried to use PostMessage instead of SendMessage. But I don't get appropriate results. Any idea ? Thx.

              p.f. Goudjo-Ako Bringing our energy together !

              K Offline
              K Offline
              kubben
              wrote on last edited by
              #6

              Have you looked at this article at all: http://www.codeproject.com/csharp/wm_copydata_use.asp[^] It seems this is doing what you want to do. Ben

              G 1 Reply Last reply
              0
              • K kubben

                Have you looked at this article at all: http://www.codeproject.com/csharp/wm_copydata_use.asp[^] It seems this is doing what you want to do. Ben

                G Offline
                G Offline
                gapfulgence
                wrote on last edited by
                #7

                thanks.

                p.f. Goudjo-Ako Bringing our energy together !

                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