[DllImport("user32.dll ", CharSet = CharSet.Unicode)]
        public static extern IntPtr PostMessage(IntPtr hwnd, int wMsg, int  wParam, int lParam); 
///这里wmsg指的是什么 ,还有第三和第四参数也不懂,网上搜了好多都没怎么这几个参数究竟要怎么赋值

解决方案 »

  1.   

    希望能详细点.网上搜来的就不要了,我也搜了很多,例如说"wParam和lParam就是指消息的两个参数"
    这样说我哪能理解阿....
      

  2.   

    msg就是消息号,wm_xxx的那个。
    后面是2个参数,由不同的消息定义
      

  3.   

    比如,WM_KEYDOWN里面
    wParam
    Specifies the virtual-key code of the nonsystem key. lParam
    Specifies the repeat count, scan code, extended-key flag, context code, previous key-state flag, and transition-state flag, as shown in the following table. 0-15Specifies the repeat count for the current message. The value is the number of times the keystroke is autorepeated as a result of the user holding down the key. If the keystroke is held long enough, multiple messages are sent. However, the repeat count is not cumulative.16-23Specifies the scan code. The value depends on the OEM.24Specifies whether the key is an extended key, such as the right-hand ALT and CTRL keys that appear on an enhanced 101- or 102-key keyboard. The value is 1 if it is an extended key; otherwise, it is 0.25-28Reserved; do not use.29Specifies the context code. The value is always 0 for a WM_KEYDOWN message.30Specifies the previous key state. The value is 1 if the key is down before the message is sent, or it is zero if the key is up.31Specifies the transition state. The value is always zero for a WM_KEYDOWN message.WM_COMMAND就是
    WM_COMMAND wNotifyCode = HIWORD(wParam); 
        wID = LOWORD(wParam); 
        hwndCtl = (HWND) lParam;wNotifyCode
    Value of the high-order word of wParam. Specifies the notification code if the message is from a control. If the message is from an accelerator, this parameter is 1. If the message is from a menu, this parameter is 0. wID
    Value of the low-order word of wParam. Specifies the identifier of the menu item, control, or accelerator. hwndCtl
    Handle to the control sending the message if the message is from a control. Otherwise, this parameter is NULL. 
      

  4.   

    可见要想回答lz的问题,需要写一本书。所以lz还是自己去查阅msdn吧。
      

  5.   

    IntPtr hwnd, int wMsg, int  wParam, int lParam
    句柄           消息号     信息           信息
    接收消息的窗口句柄 
    自定义的消息号 int型
    自定消息内容 int型
    自定消息内容 int型。
      

  6.   


    [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)] 
    static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam); 
    第一个是你要发送的对象的句柄,该句柄唯一标识了该对象
    第二个是你要发送的消息,例如:WM_CLOSE 表示要关闭
    public const int WM_CLOSE  = unchecked((int)0x10);第三个参数是表示其他的附加信息,例如发送的位置。
    第四个参数也是附加的信息,例如是否按下了Ctrl
    你可以看看这篇文章:
    SendMessage函数完全使用手册http://youhello.itpub.net/post/4630/412209
      

  7.   

    我刚才给出的是SendMessage,它的参数和PostMessage一样的。
    两者的区别是,SendMessage是同步的处理,如果消息不回处理,它就一直等待
    而PostMessage只管发送消息,有没有返回,它都会继续结束。
      

  8.   

    ls...那么,,有个问题...我postmessage到form2句柄上.能够顺利触发事件.
    可是我想postmessage到form2句柄上,再模拟鼠标按下form2上的button.可是这样就不行了...触发不了...
      

  9.   

    楼上的各位朋友是在说  hook?