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. Using postmessage to interoperate?

Using postmessage to interoperate?

Scheduled Pinned Locked Moved C#
c++helpquestion
3 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.
  • M Offline
    M Offline
    mcgahanfl
    wrote on last edited by
    #1

    What I would really like to do is tell the parent control to send a button click to a child control. In C++ it would be this pParent->SendMessage( WM_COMMAND, MAKEWPARAM(ID_Of_CHILD, BN_CLICKED) ); Can you help me with this syntax or point me towards reading material? Below is my best effort. Thanks. using System.Runtime.InteropServices; public class Form1 : System.Windows.Forms.Form { [DllImport("user32.dll")] protected static extern int PostMessage( IntPtr wnd, uint Msg, IntPtr wParam, IntPtr lParam); . . . private void button1_Click(object sender, System.EventArgs e) { * #define BN_CLICKED 0 #define BN_PAINT 1 #define BN_HILITE 2 #define BN_UNHILITE 3 #define BN_DISABLE 4 #define BN_DOUBLECLICKED 5 */ const uint WM_COMMAND = 0x0111; const uint BN_CLICKED = 0x0000; PostMessage((IntPtr)BusinessRules.Handle, WM_COMMAND, (IntPtr)BN_CLICKED, (IntPtr)IntPtr.Zero); } private void BusinessRules_Click(object sender, System.EventArgs e) { System.Windows.Forms.MessageBox.Show("I was clicked"); }

    J 1 Reply Last reply
    0
    • M mcgahanfl

      What I would really like to do is tell the parent control to send a button click to a child control. In C++ it would be this pParent->SendMessage( WM_COMMAND, MAKEWPARAM(ID_Of_CHILD, BN_CLICKED) ); Can you help me with this syntax or point me towards reading material? Below is my best effort. Thanks. using System.Runtime.InteropServices; public class Form1 : System.Windows.Forms.Form { [DllImport("user32.dll")] protected static extern int PostMessage( IntPtr wnd, uint Msg, IntPtr wParam, IntPtr lParam); . . . private void button1_Click(object sender, System.EventArgs e) { * #define BN_CLICKED 0 #define BN_PAINT 1 #define BN_HILITE 2 #define BN_UNHILITE 3 #define BN_DISABLE 4 #define BN_DOUBLECLICKED 5 */ const uint WM_COMMAND = 0x0111; const uint BN_CLICKED = 0x0000; PostMessage((IntPtr)BusinessRules.Handle, WM_COMMAND, (IntPtr)BN_CLICKED, (IntPtr)IntPtr.Zero); } private void BusinessRules_Click(object sender, System.EventArgs e) { System.Windows.Forms.MessageBox.Show("I was clicked"); }

      J Offline
      J Offline
      Julian Bucknall MSFT
      wrote on last edited by
      #2

      Unless I'm missing something, just call PerformClick():

      private void button1_Click(object sender, System.EventArgs e) {
      BusinessRules.PerformClick();
      }

      Cheers, Julian Program Manager, C# This posting is provided "AS IS" with no warranties, and confers no rights.

      M 1 Reply Last reply
      0
      • J Julian Bucknall MSFT

        Unless I'm missing something, just call PerformClick():

        private void button1_Click(object sender, System.EventArgs e) {
        BusinessRules.PerformClick();
        }

        Cheers, Julian Program Manager, C# This posting is provided "AS IS" with no warranties, and confers no rights.

        M Offline
        M Offline
        mcgahanfl
        wrote on last edited by
        #3

        Thank you. The PerformClick is akin to SendMessage(). It takes place immediately. I was hoping for a PostMessage()type behavior. Any ideas? thanks

        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