问题描述
各位大侠:我用C#做一个用摄像头拍照的程序,自定义了一些消息,怎么发送到窗口,然后接收并实现这个消息啊?
解决方案
解决方案二:
protectedMessageQueueTransactionTypetransactionType=MessageQueueTransactionType.Automatic;protectedMessageQueuequeue;protectedTimeSpantimeout;publicQueue(stringqueuepath,inttimeoutSeconds){if(!MessageQueue.Exists(queuepath)){MessageQueue.Create(queuepath);}queue=newMessageQueue(queuepath);timeout=TimeSpan.FromSeconds(Convert.ToDouble(timeoutSeconds));queue.DefaultPropertiesToSend.AttachSenderId=false;queue.DefaultPropertiesToSend.UseAuthentication=false;queue.DefaultPropertiesToSend.UseEncryption=false;queue.DefaultPropertiesToSend.AcknowledgeType=AcknowledgeTypes.None;queue.DefaultPropertiesToSend.UseJournalQueue=false;}publicvirtualobjectRecieve(){try{//using(Messagemessage=queue.Receive(timeout,transactionType))using(Messagemessage=queue.Receive(timeout))returnmessage;}catch(MessageQueueExceptionmqex){if(mqex.MessageQueueErrorCode==MessageQueueErrorCode.IOTimeout)thrownewTimeoutException();throw;}}publicvirtualvoidSend(objectmsg){//queue.Send(msg,transactionType);queue.Send(msg);}publicvoidDispose(){queue.Dispose();}
消息?是windows自带的那种的吗不知道是不是你要的
解决方案三:
学习,帮顶了
解决方案四:
解决方案五:
mark
解决方案六:
拿到窗口句柄,SendMessage或者PostMessage处理消息要重写窗口过程WndProc
解决方案七:
用啥做的,能具体点吗?
解决方案八:
舉個例子: 定義:[DllImport("user32.dll",EntryPoint="SendMessageA")]privatestaticexternintSendMessage(IntPtrhwnd,intwMsg,IntPtrwParam,intlParam); 使用:privatevoidSys_Timer_PaintTick(objectsender,EventArgse){if(this._Time_paint!=null){if(_Time_paint.Enabled==true){SendMessage(this.Handle,WM_PAINT,IntPtr.Zero,0);}}}
解决方案九:
摄像头拍照中打开视频的代码(部分):Form1.SendMessage(this.hHwnd,0x435,-1,0);Form1.SendMessage(this.hHwnd,0x434,0x42,0);Form1.SendMessage(this.hHwnd,0x432,-1,0);Form1.SetWindowPos(this.hHwnd,1,0,0,intWidth,intHeight,6);上面的0x435、0x434、0x432是自定义的消息?怎么来的?怎么实现的?
解决方案十:
看看