zoukankan      html  css  js  c++  java
  • wince定时拍照功能(转)

    转自:http://blog.csdn.net/xyz_lmn/archive/2010/02/26/5329308.aspx 

      CameraCaptureDialog 后必须手动按“确定”然后“退出”,才能拍照, 怎样使用 CameraCaptureDialog 实现自动、定时拍照呢?可以使用System.Windows.Forms.Timer 、SendMessage方法实现,Timer方法必须在主线程中。

    实现代码:

     public partial class Form1 : Form
        {
            /*
            [DllImport("CoreDll")]
            public static extern IntPtr FindWindow(
                              string lpClassName,  // class name
                              string lpWindowName  // window name
                              );
            */
            [DllImport("CoreDll")]
            public static extern IntPtr SendMessage(
                  IntPtr hWnd,      // handle to destination window
                  uint Msg,     // message
                  uint wParam,  // first message parameter
                  uint lParam   // second message parameter
                  );

            [DllImport("CoreDll")]
            public static extern IntPtr GetForegroundWindow();

            System.Threading.Timer tmr;

            public Form1()
            {
                InitializeComponent();

            }

            private void menuItem2_Click(object sender, EventArgs e)
            {
                Application.Exit();
            }

            private void menuItem1_Click(object sender, EventArgs e)
            {

                CameraCaptureDialog ccd = new CameraCaptureDialog();
                ccd.Mode = CameraCaptureMode.Still;

                object someState = new object();
                TimerCallback tmrClbck = new TimerCallback(this.atTimer1);
                tmr = new System.Threading.Timer(tmrClbck, someState, 10* 1000, -1);
                
                if (ccd.ShowDialog() == DialogResult.OK)
                {
                    pictureBox1.Image = new Bitmap(ccd.FileName);
                    //MessageBox.Show("OK");
                }
            }


            private void atTimer1(object state)
            {
                Debug.WriteLine("Timer 1 On");
                IntPtr hwnd = GetForegroundWindow();
                SendMessage(hwnd, 0x100, 0x0d, 0xf20001);

                object someState = new object();
                TimerCallback tmrClbck = new TimerCallback(this.atTimer2);
                tmr = new System.Threading.Timer(tmrClbck, someState, 2 * 1000, -1);
                //tmr.Dispose();
            }

            private void atTimer2(object state)
            {
                Debug.WriteLine("Timer 2 On");
                IntPtr hwnd = GetForegroundWindow();
                SendMessage(hwnd, 0x101, 0x1b, 0xc0310001);
                tmr.Dispose();
            }
        }

    程序中发送的 message,不同的 device 不同,需要用 Remote Spy 去抓

    http://www.christec.co.nz/blog/archives/208 

  • 相关阅读:
    Linux shell脚本基础学习详细介绍(完整版)二
    python读取单个文件操作
    【转载】HTTP 缓存的四种风味与缓存策略
    【转载】HTTP 响应头与状态码
    【转载】HTTP 请求头与请求体
    【转载】HTTP 基础与变迁
    3-2 从单词中获取单词出现的频率信息,并把他们写进对应的列表里
    170925_2 Python socket 创建UDP的服务器端和客户端
    170925_1 Python socket 创建TCP的服务器端和客户端
    2-2 列表推导同 filter 和 map 的比较
  • 原文地址:https://www.cnblogs.com/zhuzhu_/p/2049611.html
Copyright © 2011-2022 走看看