久远的C++Builder 2010 发送消息【发送特殊字符】
久远的C++Builder 2010 发送消息【发送特殊字符】
//--------------------------------------------------------------------------- #include <vcl.h> #include <math.h> #pragma hdrstop #include "Unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; wchar_t a[] = L"❥❣♂♀✲☀☼☾☽◐◑☺☻☎☏✿❀"; WCHAR b[2]; int i=0; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::btn1Click(TObject *Sender) { } //--------------------------------------------------------------------------- void __fastcall TForm1::tmr1Timer(TObject *Sender) { b[0]=a[i]; b[1]='\0'; SendMessageW(edt1->Handle,WM_SETTEXT,0,(int)((wchar_t *)&b)); //SendMessageW(edt1->Handle,WM_SETTEXT,0,(int)&b);也可以。 if (i==lstrlenW(a)-1) { i=0; }else i++; } //---------------------------------------------------------------------------
忘记了,搞了多久,结果C++Builder 2010
SendMessage 默认是 SendMessageA
------------------------------------------------------------------------------
设置当前项目的默认TCHAR定义,以后就用TCHAR定义Unicode
Project->Options