程序A中有个StautsBar,里面有个CheckButton,我想通过程序B来修改这个CheckButton的Checked属性,应该怎么做?
如果用SendMessage,那么相关消息和常数是什么?

解决方案 »

  1.   

    可以用sendmessage,你必须规定好一个公用的消息号
      

  2.   

    http://baike.baidu.com/view/1080187.htm很详细了
      

  3.   

    using System;
    using System.Diagnostics;
    using System.Runtime.InteropServices;
    using System.Text;
    using System.Collections.Generic;namespace Text
    {
        public class Program
        {
            [DllImport("user32.dll", CharSet = CharSet.Auto)]
            static extern Boolean SendMessage(IntPtr hWnd, UInt32 Msg, Boolean wParam, UInt32 lParam);        private const UInt32 BM_GETCHECK = 0x00F0;
            private const UInt32 BM_SETCHECK = 0x00F1;        static void Main(string[] args)
            {
                IntPtr h = new IntPtr(句柄自己取);
                Boolean bChecked = SendMessage(h, BM_GETCHECK, false, 0);
                Boolean bNewChecked = !bChecked;
                SendMessage(h, BM_SETCHECK, bNewChecked, 0);            Console.ReadKey();
            }
        }
    }
      

  4.   

    这个句柄需要CheckBox的句柄的吧?
    请问楼上,这些消息,你从哪里找来的,有这方面资料吗?