標點符號輔助輸入工具 C# | 2005/06/24 22:48:08



標點符號輔助輸入工具
在文書作業下,假若要輸入標點符號時,我們可以藉由標點符號小鍵盤輔助輸入,而在一些大型程式會提供特殊符號輸入的功能,但只能在自身程式執行而不能讓其它程式使用,若要在其它程式輸入其它的符號時該怎麼辦?
以下是使用C#所撰寫的標點符號輔助輸入工具程式碼....


 


標點符號輔助輸入工具程式碼:
using System;
using System.Windows.Forms;
 
namespace Symbols
{
 public class Form1 : Form
 {
  public Form1()
  {   
   this.AutoScaleBaseSize = new System.Drawing.Size(5, 15);
   this.ClientSize = new System.Drawing.Size(400, 90);
   this.Name = "Form1";
   this.Text = "Symbols .NET";
   this.FormBorderStyle = FormBorderStyle.FixedSingle;
   this.StartPosition =FormStartPosition.CenterScreen;
   this.MaximizeBox=false;
   this.Opacity = 0.9;
   this.TopMost = true;
   this.Load += new System.EventHandler(this.Form1_Load);
  }
 
 
  private Button[,] btn = new Button[10,3]; 
 
  private string[,] str = new string[3,10]{
      {"‧",",",";",":","、","。","?","﹗","(",")"},
      {"「","」","『","』","☆","★","◎","○","⊙","◆"},
      {"◇","▼","▲","▽","△","□","※","@","→","←"}};
                                          
                                        
  private void Form1_Load(object sender, System.EventArgs e)
  {
   for (int j = 0; j <= 2; j++)
    for (int i = 0; i <= 9; i++) 
    {
       btn[i,j] = new Button();
       btn[i,j].Name = "btn" + (i+(10*j)).ToString();
       btn[i,j].Text = str[j,i];
       btn[i,j].Width=40;
       btn[i,j].Height=30;   
       btn[i,j].Top  =  30*j;  
       btn[i,j].Left  = i * 40;  
       btn[i,j].Click += new System.EventHandler(this.btn_Click); 
       Controls.Add(btn[i,j]);       
    }   
  }
 
  private const int WS_EX_NOACTIVATE = 0x8000000;
  protected override CreateParams CreateParams
  {
   get
   {
    CreateParams p = base.CreateParams;
    if (!(base.DesignMode))
    {
     p.ExStyle = p.ExStyle | (WS_EX_NOACTIVATE);
    }
    return p;
   }
  }


  private void btn_Click(object sender, System.EventArgs e)
  {
   SendKeys.Send((((Button)(sender))).Text);
  }
 
  [STAThread]
  public static void Main(string[] args)
  {
     Application.Run(new Form1());
  }
       
 }
}


若網友們有增加更多符號或修改介面後,記得分享一下心得喔。^_^


應用下載點:

Apple 老爹 發表在 痞客邦 PIXNET 留言(0) 人氣()