开心了~~~~~~~~~呵呵~~~~ 早上做了600个~~~真TMD快啊~~~~ 谢谢knocker,也谢谢KAI
[QUOTE]那个Knocker很小气,[/QUOTE] .H 文件 [QUOTE]//--------------------------------------------------------------------------- #ifndef Unit1H #define Unit1H //--------------------------------------------------------------------------- #include <Classes.hpp> #include <Controls.hpp> #include <StdCtrls.hpp> #include <Forms.hpp> #include <Clipbrd.hpp> #include <Buttons.hpp> //--------------------------------------------------------------------------- class TForm1 : public TForm { __published: // IDE-managed Components TEdit *Edit1; TEdit *Edit2; TEdit *Edit3; TEdit *Edit4; TMemo *Memo1; TSpeedButton *SpeedButton1; TEdit *Edit5; void __fastcall Edit1KeyPress(TObject *Sender, char &Key); void __fastcall Edit2KeyPress(TObject *Sender, char &Key); void __fastcall Edit3KeyPress(TObject *Sender, char &Key); void __fastcall Edit4KeyPress(TObject *Sender, char &Key); void __fastcall SpeedButton1Click(TObject *Sender); void __fastcall Edit5Change(TObject *Sender); private: // User declarations public: // User declarations bool Copy; int Number1Len; int Number2Len; long long Number1; long long Number2; AnsiString temp,NumStr1,NumStr2; __fastcall TForm1(TComponent* Owner); void __fastcall StrtLgIn(tagMSG &Msg, bool &Handled); }; //--------------------------------------------------------------------------- extern PACKAGE TForm1 *Form1; //--------------------------------------------------------------------------- #endif[/QUOTE]
[QUOTE]//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "Unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { Copy = false; ActiveControl=Edit1; RegisterHotKey(Handle,12345678,NULL,121); Application->OnMessage=StrtLgIn; } //--------------------------------------------------------------------------- void __fastcall TForm1::Edit1KeyPress(TObject *Sender, char &Key) { if((Edit1->Text).Length()>=40) { Edit2->SetFocus(); } Copy = false; } //---------------------------------------------------------------------------
void __fastcall TForm1::Edit2KeyPress(TObject *Sender, char &Key) { if((Edit2->Text).Length()>=10) { Edit3->SetFocus(); } Copy = false; } //--------------------------------------------------------------------------- void __fastcall TForm1::Edit3KeyPress(TObject *Sender, char &Key) { if((Edit3->Text).Length()>=10) { Edit4->SetFocus(); } Copy = false; } //--------------------------------------------------------------------------- void __fastcall TForm1::Edit4KeyPress(TObject *Sender, char &Key) { if((Edit4->Text).Length()>=10) { Edit5->SetFocus(); } Copy = false; } //--------------------------------------------------------------------------- void __fastcall TForm1::StrtLgIn(tagMSG &Msg,bool &Handled) {
if (Msg.message==WM_HOTKEY && Msg.wParam==12345678) { POINT MousePoint; GetCursorPos(&MousePoint); HANDLE hWindow = WindowFromPoint(MousePoint); SpeedButton1Click(this); SendMessage(hWindow, WM_PASTE, CF_TEXT,NULL); // PostMessage(hWindow, WM_PASTE, CF_TEXT,NULL); }
}
void __fastcall TForm1::SpeedButton1Click(TObject *Sender) { if(!Copy) { Number1Len = (Edit2->Text).Length(); Number2Len = (Edit4->Text).Length();; try { Number1= (long long )StrToFloat(Edit2->Text); Number2= (long long )StrToFloat(Edit4->Text); } catch(EConvertError &error) { Application->MessageBoxA("输入有误无法转换为数字!\n\r请更正第二或第四栏内容!","警告",MB_OK); Number1=0; Number2=0; Copy = false; return ; } temp= Edit1->Text + Edit2->Text+ Edit3->Text + Edit4->Text +Edit5->Text; Memo1->Clear(); Memo1->Lines->Add(temp); Memo1->SelectAll(); Memo1->CopyToClipboard(); Copy = true; } else { Number1 = Number1 + 1 ; Number2 = Number2 + 1 ; NumStr1 = FloatToStr((float)Number1); NumStr2 = FloatToStr((float)Number2); while( NumStr1.Length()<Number1Len ) { NumStr1 = "0" +NumStr1; } while( NumStr2.Length()<Number2Len ) { NumStr2 = "0" +NumStr2; } Edit2->Text = NumStr1 ; Edit4->Text = NumStr2 ; temp= Edit1->Text + Edit2->Text+ Edit3->Text + Edit4->Text +Edit5->Text ; Memo1->Clear(); Memo1->Lines->Add(temp); Memo1->SelectAll(); Memo1->CopyToClipboard(); }
} //---------------------------------------------------------------------------
void __fastcall TForm1::Edit5Change(TObject *Sender) { if((Edit5->Text).Length()>=10) { Copy = false; } } //---------------------------------------------------------------------------[/QUOTE]