十年網(wǎng)站開發(fā)經(jīng)驗(yàn) + 多家企業(yè)客戶 + 靠譜的建站團(tuán)隊(duì)
量身定制 + 運(yùn)營維護(hù)+專業(yè)推廣+無憂售后,網(wǎng)站問題一站解決
做一個(gè)TextBox,放在窗體外,Anchor設(shè)成Top, Right,不要設(shè)置Visible屬性和Enabled屬性,要輸入的時(shí)候就TextBox1.Focus(),在TextBox1的TextChange事件里面畫圖
創(chuàng)新互聯(lián)云計(jì)算的互聯(lián)網(wǎng)服務(wù)提供商,擁有超過13年的服務(wù)器租用、四川電信機(jī)房托管、云服務(wù)器、雅安服務(wù)器托管、網(wǎng)站系統(tǒng)開發(fā)經(jīng)驗(yàn),已先后獲得國家工業(yè)和信息化部頒發(fā)的互聯(lián)網(wǎng)數(shù)據(jù)中心業(yè)務(wù)許可證。專業(yè)提供云主機(jī)、雅安服務(wù)器托管、域名注冊、VPS主機(jī)、云服務(wù)器、香港云服務(wù)器、免備案服務(wù)器等。
不好的地方在于每一次輸入都要先清空,你可以在圖片框的背景哪里設(shè)置圖片,在Image里面繪制文字
It3241的辦法比我的更慢就是了
你是用輸入法的吧,這個(gè)是.Net Framework的Bug吧,用輸入法的步驟如下:
1、首先保證文本框有焦點(diǎn)
2、按下2次Ctrl+空格
3、切換到自己要用的輸入法
這樣一般都可以了
Private Sub TextBox1_KeyPress1(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If e.KeyChar = "A" And e.KeyChar = "Z" Or e.KeyChar = "a" And e.KeyChar = "z" Then
e.Handled = False
Else
MessageBox.Show ("只能輸入字母!")
e.Handled = True
Exit Sub
End If
End Sub
public string hz2py(string hz) //獲得漢字的區(qū)位碼
{
byte[] sarr = System.Text.Encoding.Default.GetBytes(hz);
int len = sarr.Length;
if (len1)
{
byte[] array = new byte[2];
array = System.Text.Encoding.Default.GetBytes(hz);
int i1 = (short)(array[0] - '\0');
int i2 = (short)(array[1] - '\0');
//unicode解碼方式下的漢字碼
// array = System.Text.Encoding.Unicode.GetBytes(hz);
// int i1 = (short)(array[0] - '\0');
// int i2 = (short)(array[1] - '\0');
// int t1 = Convert.ToInt32(i1,16);
// int t2 = Convert.ToInt32(i2,16);
int tmp=i1*256+i2;
string getpychar="*";//找不到拼音碼的用*補(bǔ)位
if(tmp=45217tmp=45252){getpychar= "A";}
else if(tmp=45253tmp=45760){getpychar= "B";}
else if(tmp=47761tmp=46317){getpychar= "C";}
else if(tmp=46318tmp=46825){getpychar= "D";}
else if(tmp=46826tmp=47009){getpychar= "E";}
else if(tmp=47010tmp=47296){getpychar= "F";}
else if(tmp=47297tmp=47613){getpychar= "G";}
else if(tmp=47614tmp=48118){getpychar= "H";}
else if(tmp=48119tmp=49061){getpychar= "J";}
else if(tmp=49062tmp=49323){getpychar= "K";}
else if(tmp=49324tmp=49895){getpychar= "L";}
else if(tmp=49896tmp=50370){getpychar= "M";}
else if(tmp=50371tmp=50613){getpychar= "N";}
else if(tmp=50614tmp=50621){getpychar= "O";}
else if(tmp=50622tmp=50905){getpychar= "P";}
else if(tmp=50906tmp=51386){getpychar= "Q";}
else if(tmp=51387tmp=51445){getpychar= "R";}
else if(tmp=51446tmp=52217){getpychar= "S";}
else if(tmp=52218tmp=52697){getpychar= "T";}
else if(tmp=52698tmp=52979){getpychar= "W";}
else if(tmp=52980tmp=53640){getpychar= "X";}
else if(tmp=53689tmp=54480){getpychar= "Y";}
else if(tmp=54481tmp=55289){getpychar= "Z";}
return getpychar;
}
else
{
return hz;
}
}
public string transpy(string strhz) //把漢字字符串轉(zhuǎn)換成拼音碼
{
string strtemp="";
int strlen=strhz.Length;
for (int i=0;i=strlen-1;i++)
{
strtemp+=hz2py(strhz.Substring(i,1));
}
return strtemp;
}
create table tabpy(id int identity,b_begin varbinary(2),b_end varbinary(2),word varchar(2))
insert tabpy select 0xB0A1, 0xB0C4,'A'
union all select 0xB0C5, 0xB2C0,'B'
union all select 0xB2C1, 0xB4ED,'C'
union all select 0xB4EE, 0xB6E9,'D'
union all select 0xB6EA, 0xB7A1,'E'
union all select 0xB7A2, 0xB8C0,'F'
union all select 0xB8C1, 0xB9FD,'G'
union all select 0xB9FE, 0xBBF6,'H'
union all select 0xBBF7, 0xBFA5,'J'
union all select 0xBFA6, 0xC0AB,'K'
union all select 0xC0AC, 0xC2E7,'L'
union all select 0xC2E8, 0xC4C2,'M'
union all select 0xC4C3, 0xC5B5,'N'
union all select 0xC5B6, 0xC5BD,'O'
union all select 0xC5BE, 0xC6D9,'P'
union all select 0xC6DA, 0xC8BA,'Q'
union all select 0xC8BB, 0xC8F5,'R'
union all select 0xC8F6, 0xCBF9,'S'
union all select 0xCBFA, 0xCDD9,'T'
union all select 0xCDDA, 0xCEF3,'W'
union all select 0xCEF4, 0xD1B8,'X'
union all select 0xD1B9, 0xD4D0,'Y'
union all select 0xD4D1, 0xD7F9,'Z'
函數(shù):
create function getfirstpy(@a varchar(200))
returns varchar(100)
as
begin
declare @i int,@j int,@result varchar(100)
set @result=''
set @i=len(@a)
set @j=1
while @j=@i
begin
select @result=@result+word from tabpy where cast(substring(@a,@j,1) as varbinary(2)) between b_begin and b_end
set @j=@j+1
end
return @result
end
Private Function py(mystr As String) As String '獲得漢字的拼音簡碼
On Error Resume Next
If Asc(mystr) 0 Then
If Asc(Left(mystr, 1)) Asc("啊") Then
py = "0"
Exit Function
End If
If Asc(Left(mystr, 1)) = Asc("啊") And Asc(Left(mystr, 1)) Asc("芭") Then
py = "A"
Exit Function
End If
If Asc(Left(mystr, 1)) = Asc("芭") And Asc(Left(mystr, 1)) Asc("擦") Then
py = "B"
Exit Function
End If
If Asc(Left(mystr, 1)) = Asc("擦") And Asc(Left(mystr, 1)) Asc("搭") Then
py = "C"
Exit Function
End If
If Asc(Left(mystr, 1)) = Asc("搭") And Asc(Left(mystr, 1)) Asc("蛾") Then
py = "D"
Exit Function
End If
If Asc(Left(mystr, 1)) = Asc("蛾") And Asc(Left(mystr, 1)) Asc("發(fā)") Then
py = "E"
Exit Function
End If
If Asc(Left(mystr, 1)) = Asc("發(fā)") And Asc(Left(mystr, 1)) Asc("噶") Then
py = "F"
Exit Function
End If
If Asc(Left(mystr, 1)) = Asc("噶") And Asc(Left(mystr, 1)) Asc("哈") Then
py = "G"
Exit Function
End If
If Asc(Left(mystr, 1)) = Asc("哈") And Asc(Left(mystr, 1)) Asc("擊") Then
py = "H"
Exit Function
End If
If Asc(Left(mystr, 1)) = Asc("擊") And Asc(Left(mystr, 1)) Asc("喀") Then
py = "J"
Exit Function
End If
If Asc(Left(mystr, 1)) = Asc("喀") And Asc(Left(mystr, 1)) Asc("垃") Then
py = "K"
Exit Function
End If
If Asc(Left(mystr, 1)) = Asc("垃") And Asc(Left(mystr, 1)) Asc("媽") Then
py = "L"
Exit Function
End If
If Asc(Left(mystr, 1)) = Asc("媽") And Asc(Left(mystr, 1)) Asc("拿") Then
py = "M"
Exit Function
End If
If Asc(Left(mystr, 1)) = Asc("拿") And Asc(Left(mystr, 1)) Asc("哦") Then
py = "N"
Exit Function
End If
If Asc(Left(mystr, 1)) = Asc("哦") And Asc(Left(mystr, 1)) Asc("啪") Then
py = "O"
Exit Function
End If
If Asc(Left(mystr, 1)) = Asc("啪") And Asc(Left(mystr, 1)) Asc("期") Then
py = "P"
Exit Function
End If
If Asc(Left(mystr, 1)) = Asc("期") And Asc(Left(mystr, 1)) Asc("然") Then
py = "Q"
Exit Function
End If
If Asc(Left(mystr, 1)) = Asc("然") And Asc(Left(mystr, 1)) Asc("撒") Then
py = "R"
Exit Function
End If
If Asc(Left(mystr, 1)) = Asc("撒") And Asc(Left(mystr, 1)) Asc("塌") Then
py = "S"
Exit Function
End If
If Asc(Left(mystr, 1)) = Asc("塌") And Asc(Left(mystr, 1)) Asc("挖") Then
py = "T"
Exit Function
End If
If Asc(Left(mystr, 1)) = Asc("挖") And Asc(Left(mystr, 1)) Asc("昔") Then
py = "W"
Exit Function
End If
If Asc(Left(mystr, 1)) = Asc("昔") And Asc(Left(mystr, 1)) Asc("壓") Then
py = "X"
Exit Function
End If
If Asc(Left(mystr, 1)) = Asc("壓") And Asc(Left(mystr, 1)) Asc("匝") Then
py = "Y"
Exit Function
End If
If Asc(Left(mystr, 1)) = Asc("匝") Then
py = "Z"
Exit Function
End If
Else
If UCase(mystr) = "Z" And UCase(mystr) = "A" Then
py = UCase(Left(mystr, 1))
Else
py = mystr
End If
End If
End Function
Private Sub Command1_Click()
MsgBox py(Text1.Text)
End Sub