Blame view

SunVoteARSPPT/Forms/FrmReceive.cs 3 KB
20c0108c   wutaian   xx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
  using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Windows.Forms;
  using System.Runtime.InteropServices;
  using GeneralLib;
  
  
  
  namespace SunVoteARSPPT
  {
      public partial class FrmReceive : Form
      {
          public FrmReceive()
          {
              InitializeComponent();
          }
  
          const int WM_COPYDATA = 0x004A;
  
          protected override void DefWndProc(ref System.Windows.Forms.Message m)
          {
              switch (m.Msg)
              {
                  case WM_COPYDATA:
                      COPYDATASTRUCT mystr = new COPYDATASTRUCT();
                      Type mytype = mystr.GetType();
                      mystr = (COPYDATASTRUCT)m.GetLParam(mytype);
  
                      string[] ary = mystr.lpData.Split(new char[] { ',' });
                      bool isCatch = false;
                      if (ary.Length >= 3)
                      {
                          SendKeyCodePar par = new SendKeyCodePar();
                          par.KeyCode = ConvertOper.Convert(ary[0]).ToInt;
                          par.KeyChr = ary[1];
                          par.Shift = ConvertOper.Convert(ary[2]).ToInt;
                          par.Catch = isCatch;
  
                          if (Globals.SunVoteARSAddIn.frmVoteBar.frmVoteDetail!=null)
                          {
                              if (Globals.SunVoteARSAddIn.frmVoteBar.Visible)
                              {
                                  Globals.SunVoteARSAddIn.frmVoteBar.Select();
                                  Globals.SunVoteARSAddIn.frmVoteBar.Activate();
                              }
                          }
  
                          tmrRun.Tag = par;
                          tmrRun.Interval = 1;
                          tmrRun.Enabled = true;
                      }
  
                      break;
                  default:
                      base.DefWndProc(ref m);
                      break;
              }
          }
  
          private void FrmReceive_Load(object sender, EventArgs e)
          {
              this.Hide();
              this.ShowInTaskbar = false;
              FrmVoteBar.ActivateSlideShowWindow();
              //tmrRun.Enabled = true;
          }
  
          private void tmrRun_Tick(object sender, EventArgs e)
          {
              tmrRun.Enabled = false;
  
              if (tmrRun.Tag == null)
                  return;
  
              SendKeyCodePar par = tmrRun.Tag as SendKeyCodePar;
              
              if (Globals.SunVoteARSAddIn.frmVoteBar != null)
              {                
                  Globals.SunVoteARSAddIn.frmVoteBar.HotKey_KeyDownEvent(par.KeyCode, par.KeyChr, par.Shift, out par.Catch);                
              }
          }
  
          private void FrmReceive_FormClosing(object sender, FormClosingEventArgs e)
          {
              tmrRun.Enabled = false;
          }
      }
  
      public class SendKeyCodePar
      {
          public int KeyCode = 0;
          public string KeyChr = "";
          public int Shift = 0;
          public bool Catch = false;
      }
  }