摘要: //sendmessage WM_PAINT带背景的窗体private{ Private declarations }Bitmap:TBitmap;procedure WMPaint(var msg:TWMPAINT);Message WM_PAINT;procedure TForm1.WMPaint(var msg:TWMPAINT);begininherited;StretchBlt(canv... 阅读全文
posted @ 2012-06-03 17:56 XE2011 阅读(222) 评论(0) 推荐(0)
摘要: //WM_PAINT带背景的窗体private{ Private declarations }Bitmap:TBitmap;procedure WMPaint(var msg:TWMPAINT);Message WM_PAINT;procedure TForm1.WMPaint(var msg:TWMPAINT);begininherited;StretchBlt(canvas.Handle,0,... 阅读全文
posted @ 2012-06-03 17:56 XE2011 阅读(481) 评论(0) 推荐(0)
摘要: //TMemo组件的光标定位privateprocedure MemoRow;{ Private declarations }varForm1: TForm1;procedure TForm1.MemoRow;varLpos,Cpos,LineLength:Integer;beginLpos := SendMessage(Memo1.Handle,em_linefromchar,Memo1.Sel... 阅读全文
posted @ 2012-06-03 17:56 XE2011 阅读(430) 评论(0) 推荐(0)
摘要: procedure TForm1.Button1Click(Sender: TObject);beginSendMessage(ComboBox1.Handle, CB_SHOWDROPDOWN, 1,0);end;通过 Wiz 发布 阅读全文
posted @ 2012-06-03 17:56 XE2011 阅读(255) 评论(0) 推荐(0)
摘要: http://www.websnap123.com/http://delphi.about.com/http://www.2ccc.com/http://www.delphifans.com/http://www.tommstudio.com/http://www.xuedelphi.cn/通过 Wiz 发布 阅读全文
posted @ 2012-06-03 17:55 XE2011 阅读(166) 评论(0) 推荐(0)
摘要: //With简化代码语句{With语句是一种用于简化代码的语句。如你要访问一个记录类型变量(或一个对象),用With语句就不必每次重复变量的名字with 对象名 dobegin对象名属性 := 属性值;end;}//例1with Button1 dobegincaption := 'Btn';width := 100;end;//例2with edit1 dobegintext := 'Hello... 阅读全文
posted @ 2012-06-03 17:55 XE2011 阅读(106) 评论(0) 推荐(0)
摘要: //简单语句和复合语句简单语句Pascal 简单语句中不包含任何别的语句,赋值语句和过程调用即是简单语句的例子。简单语句用分号隔开,如下所示:X := Y + Z; // assignmentRandomize; // procedure call复合语句用begin 和end 将简单语句括起来即组成复合语句,复合语句用法与普通的Pascal 语句相同,见下例:beginA := B;C := A... 阅读全文
posted @ 2012-06-03 17:55 XE2011 阅读(231) 评论(0) 推荐(0)
摘要: //while循环语句{while True dobegin...end;}procedure TForm1.Button1Click(Sender: TObject);varI: Integer;beginI := 0;while I > 100 dobeginI := I + Random (100);Listbox1.Items.Add ('Random Number: ' + IntToS... 阅读全文
posted @ 2012-06-03 17:55 XE2011 阅读(107) 评论(0) 推荐(0)
摘要: //计算100以内的奇数平方和varForm1: TForm1;i,k,sum:integer; //i,sum为整形数值 k为最后一个奇数为implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);begini:=0;sum:=0; //初始化 i,sum的值while i<=100 do //当 i是100以内... 阅读全文
posted @ 2012-06-03 17:55 XE2011 阅读(772) 评论(0) 推荐(0)
摘要: //repeat loop {repeat...until (True);...}通过 Wiz 发布 阅读全文
posted @ 2012-06-03 17:55 XE2011 阅读(239) 评论(0) 推荐(0)
摘要: //循环按1 到6 F1到F8procedure TForm1.Timer1Timer(Sender: TObject);varwmHwnd:HWND;i:integer;beginwmHwnd:=FindWindow(nil,'Element Client');for i := 49 to 54 do //键1到1键6beginSendMessage(wmHwnd,WM_KEYDOWN,i,0)... 阅读全文
posted @ 2012-06-03 17:55 XE2011 阅读(186) 评论(0) 推荐(0)
摘要: procedure TForm1.Button1Click(Sender: TObject);varhandle:integer;aBool:Boolean;beginSystemParametersInfo(SPI_GETSCREENSAVEACTIVE,0,@aBool,0);if aBool thenbeginhandle:=Findwindow('shell_traywnd',nil);S... 阅读全文
posted @ 2012-06-03 17:55 XE2011 阅读(89) 评论(0) 推荐(0)
摘要: procedure TForm1.Button1Click(Sender: TObject);varHWndCalculator : HWnd;beginHWndCalculator := FindWindow(nil, '计算器'); // 查找计算器句柄if HWndCalculator <> 0 thenSendMessage(HWndCalculator, WM_CLOSE, 0, 0);... 阅读全文
posted @ 2012-06-03 17:55 XE2011 阅读(164) 评论(0) 推荐(0)
摘要: //if 条件语句条件语句通过条件检测,判断是否执行该条件语句中包含的语句。条件语句可有两种基本形式:if语句和case语句。If语句对if-then型语句,仅当条件满足时,语句才执行;对if-then-else型,if语句在两条语句中选择一条执行。procedure TForm1.Button1Click(Sender: TObject);begin// simple if statementi... 阅读全文
posted @ 2012-06-03 17:55 XE2011 阅读(200) 评论(0) 推荐(0)
摘要: //For循环{Pascal 中的for循环严格地建立在计数器基础上,循环每执行一次,计数器不是增加一个值就是减小一个值。注意:用 Break 和 Continue 系统过程可以改变循环执行的标准流程。Break中断循环;Continue直接跳至循环测试句,或使计数器增加一个步长,然后继续循环(除非条件为空或计数器达到最大值)。还有两个系统过程 Exit 和 Halt,让你立即从函数或过程中返回,... 阅读全文
posted @ 2012-06-03 17:55 XE2011 阅读(127) 评论(0) 推荐(0)
摘要: uses ShellAPI;{$IFNDEF Win32}//Var上面end;下面function ShellAbout(Wnd: HWnd; App, Stuff: PChar; Icon: HIcon): Integer; far; external 'shell';{$ENDIF}procedure TForm1.Button1Click(Sender: TObject);beginShe... 阅读全文
posted @ 2012-06-03 17:55 XE2011 阅读(159) 评论(0) 推荐(0)
摘要: //列举正在运行的程序uses ShellApi;{在interface下面type上面输入}const MY_MESSAGE = WM_USER + 100;procedure TForm1.Button1Click(Sender: TObject);varhCurrentWindow:HWnd;szText:array[0..254] of char;beginhCurrentWindow :... 阅读全文
posted @ 2012-06-03 17:55 XE2011 阅读(143) 评论(0) 推荐(0)
摘要: //取得可执行文件的图标publicProcedure NextIcon;{ Public declarations }{在implementation下面引用};uses ShellAPI;procedure TForm1.NextIcon;varCount : Integer;FileName : String;i:integer;beginif( FileName <> Edit1.Text... 阅读全文
posted @ 2012-06-03 17:55 XE2011 阅读(174) 评论(0) 推荐(0)
摘要: //设置TMemo组件的边界procedure TForm1.Button1Click(Sender: TObject);vararea: TRect;beginSendMessage(memo1.Handle ,em_getrect,0,longint(@area));area.Left := 30;area.Top := 10;area.Right := area.Right - 29;are... 阅读全文
posted @ 2012-06-03 17:55 XE2011 阅读(94) 评论(0) 推荐(0)
摘要: procedure TForm1.Button1Click(Sender: TObject);varhandle:integer;aBool:Boolean;beginSystemParametersInfo(SPI_GETSCREENSAVEACTIVE,0,@aBool,0);if aBool thenbeginhandle:=Findwindow('shell_traywnd',nil);S... 阅读全文
posted @ 2012-06-03 17:55 XE2011 阅读(152) 评论(0) 推荐(0)
摘要: procedure TForm1.Button1Click(Sender: TObject);varHWndCalculator : HWnd;beginHWndCalculator := FindWindow(nil, '计算器'); // 查找计算器句柄if HWndCalculator <> 0 thenSendMessage(HWndCalculator, WM_CLOSE, 0, 0);... 阅读全文
posted @ 2012-06-03 17:55 XE2011 阅读(130) 评论(0) 推荐(0)
摘要: procedure TForm1.Button1Click(Sender: TObject);beginSendMessage(Application.Handle, WM_SYSCOMMAND, SC_MONITORPOWER, 2);end;通过 Wiz 发布 阅读全文
posted @ 2012-06-03 17:55 XE2011 阅读(232) 评论(0) 推荐(0)
摘要: function Mynum(hand:HWND;lparam:Lparam):integer;stdcall;function Mynum(hand:HWND;lparam:Lparam):integer;stdcall;varbuff:Array[0..255] of char;dc:HDC;beginif Hand<>0 thenbegingetwindowtext(hand,buff,25... 阅读全文
posted @ 2012-06-03 17:55 XE2011 阅读(328) 评论(0) 推荐(0)
摘要: 选择结构语句IFif语句通过对条件表达式的判断,来决定程序的执行流程。if <条件表达式>then语句1;{单分支条件语句}if<条件表达式>then语句1else 语句2;{双分支条件语句}if<条件表达式1>then语句1{嵌套形式条件语句}elseif<条件表达式2>then语句2elseif<条件表达式n>then语句3......else语句n;例1:单分支条件语句判断一个数的奇偶性。(... 阅读全文
posted @ 2012-06-03 17:54 XE2011 阅读(156) 评论(0) 推荐(0)
摘要: //ini//REG//XML操作INI文件函数作用GetPrivateProfileInt //从.INI文件中取得指定节指定键名的整型数信息GetPrivateProfileSection//从.INI文件中取得指定节的信息GetPrivateProfileSectionNames//从.INI文件中取得所有节的名称GetPrivateProfileString从.INI//文件中取得指定节指... 阅读全文
posted @ 2012-06-03 17:52 XE2011 阅读(333) 评论(0) 推荐(0)
摘要: AbortPrinter在假脱机的情况下删除打印缓冲文件 AbortProc当打印作业取消时调用的一个应用程序定义的回调函数 AddForm为指定的打印机从有效窗体列表中新增一个窗体 AddJob获取一个文件名用来保存打印缓冲工作 AddMonitor新安装一个打印机管理器 AddPort新增一个打印机端口 AddPrinter在指定的服务器上新安装一个打印机 AddPrinte... 阅读全文
posted @ 2012-06-03 17:52 XE2011 阅读(567) 评论(0) 推荐(0)
摘要: void __fastcall TForm1::Button1Click(TObject *Sender){ TBorderIcons A = BorderIcons ; A >> biMaximize; BorderIcons = A;}通过 为知笔记 发布 阅读全文
posted @ 2012-06-03 17:52 XE2011 阅读(112) 评论(0) 推荐(0)
摘要: void __fastcall TForm1::Button1Click(TObject *Sender){ String AppPath; AppPath=GetCurrentDir(); Memo1->Lines->LoadFromFile(AppPath+"\\"+"a.rtf");}void __fastcall TForm1::Button1Click(TObject *Sender){... 阅读全文
posted @ 2012-06-03 17:52 XE2011 阅读(147) 评论(0) 推荐(0)
摘要: void __fastcall TForm1::ComboBox1DropDown(TObject *Sender){ ComboBox1->Items= Screen->Fonts;}//---------------------------------------------------------------------------void __fastcall TForm1::ComboB... 阅读全文
posted @ 2012-06-03 17:52 XE2011 阅读(131) 评论(0) 推荐(0)
摘要: Memo1->Clear();Memo1->Lines->Add(GetCurrentDir());Memo1->Lines->Add(Application->ExeName);通过 为知笔记 发布 阅读全文
posted @ 2012-06-03 17:52 XE2011 阅读(176) 评论(0) 推荐(0)
摘要: project -> options-> liker -> user dynamic rtl 去掉 project -> options-> compiler -> 选 release project -> options-> packages-> builder with runtime packages 去掉通过 为知笔记 发布 阅读全文
posted @ 2012-06-03 17:52 XE2011 阅读(189) 评论(0) 推荐(0)
摘要: Application->Minimize();Edit1-> PasswordChar= '* '; //单引号btn1->Left = 16;btn1->Top = 16;btn1->Width = 75;btn1->Height = 25;btn1->Caption = "btn1";Button1->Enabled = true;Memo1->Clear();//清空Memo1->SetF... 阅读全文
posted @ 2012-06-03 17:52 XE2011 阅读(101) 评论(0) 推荐(0)
摘要: MessageBeep(MB_OK);发声if(MessageDlg("Are you sure to Exit",mtConfirmation, TMsgDlgButtons()<<mbYes<<mbNo,0)==mrYes){Close();}Application->ProcessMessages();MessageBox(this->Handle,"Text","Tips",MB_OK|M... 阅读全文
posted @ 2012-06-03 17:52 XE2011 阅读(124) 评论(0) 推荐(0)
摘要: void __fastcall TForm1::FormMouseMove(TObject *Sender, TShiftState Shift, int X, int Y){Canvas->FillRect(ClientRect);Canvas->MoveTo(0, 0);Canvas->LineTo(X, Y);}通过 为知笔记 发布 阅读全文
posted @ 2012-06-03 17:51 XE2011 阅读(164) 评论(0) 推荐(0)
摘要: Form1->Caption = LowerCase(Edit1->Text);通过 为知笔记 发布 阅读全文
posted @ 2012-06-03 17:51 XE2011 阅读(123) 评论(0) 推荐(0)
摘要: void __fastcall TForm1::Button1Click(TObject *Sender){PaintBox1->Canvas->Brush->Color = clRed;PaintBox1->Canvas->FillRect(PaintBox1->Canvas->ClipRect);PaintBox1->Canvas->Ellipse(0,0,100,100);}//------... 阅读全文
posted @ 2012-06-03 17:51 XE2011 阅读(273) 评论(0) 推荐(0)
摘要: void __fastcall TForm1::FormCloseQuery(TObject *Sender, bool &CanClose){if (MessageDlg("Close the form?", mtConfirmation, TMsgDlgButtons() << mbOK << mbCancel,0) == mrCancel)CanClose = false;}通过 为知笔记 ... 阅读全文
posted @ 2012-06-03 17:51 XE2011 阅读(137) 评论(0) 推荐(0)
摘要: void __fastcall TForm1::FormResize(TObject *Sender){//button1 的位置一直在窗体的最右边Button1->Left = Form1->ClientWidth - Button1->Width;}通过 为知笔记 发布 阅读全文
posted @ 2012-06-03 17:51 XE2011 阅读(137) 评论(0) 推荐(0)
摘要: void __fastcall TForm1::Edit1Enter(TObject *Sender){Edit1->Color = clYellow;}//---------------------------------------------------------------------------void __fastcall TForm1::Edit1Exit(TObject *Sen... 阅读全文
posted @ 2012-06-03 17:51 XE2011 阅读(102) 评论(0) 推荐(0)
摘要: String InputString = InputBox(L"Input Box", L"Prompt", L"Default string"); Edit1->Text = InputString;通过 为知笔记 发布 阅读全文
posted @ 2012-06-03 17:51 XE2011 阅读(341) 评论(0) 推荐(0)
摘要: //在系统菜单上添加所需的菜单项AppendMenu(GetSystemMenu(Handle,false),MF_SEPARATOR,0,"");AppendMenu(GetSystemMenu(Handle,false),MF_STRING,200,"NEW(&A)");通过 为知笔记 发布 阅读全文
posted @ 2012-06-03 17:51 XE2011 阅读(172) 评论(0) 推荐(0)
摘要: TForm1*Form1=newTForm1(this);Form1->Show();通过 Wiz 发布 阅读全文
posted @ 2012-06-03 17:51 XE2011 阅读(146) 评论(0) 推荐(0)
摘要: //模拟在Edit1组件中按下了字母a键PostMessage(Edit1->Handle,WM_KEYDOWN,65,0);通过 为知笔记 发布 阅读全文
posted @ 2012-06-03 17:51 XE2011 阅读(138) 评论(0) 推荐(0)
摘要: 文件操作常用的函数有:1.DeleteFile3.FileAge4.FileClose5.FileDateToDateTime6.FileExists7.FileGetAttr8.FileGetDate9.FileOpen10.FileRead11.FileSearch12.FileSeek13.FileSetAttr14.FileSetDate15.FileWrite16.FindClose17... 阅读全文
posted @ 2012-06-03 17:51 XE2011 阅读(225) 评论(0) 推荐(0)
摘要: void __fastcall TForm1::Button1Click(TObject *Sender){ TCanvas *DeskTop; DeskTop = new TCanvas; DeskTop-> Handle=GetWindowDC(GetDesktopWindow()) ; Image1-> Canvas-> CopyMode=cmSrcCopy; Image1-> Canvas... 阅读全文
posted @ 2012-06-03 17:50 XE2011 阅读(189) 评论(0) 推荐(0)
摘要: //单击左键弹起菜单 97void __fastcall TForm1::Button1MouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift,int X, int Y){POINT pt;::GetCursorPos(&pt);PopupMenu1->Popup(pt.x, pt.y);}通过 为知笔记 发布 阅读全文
posted @ 2012-06-03 17:50 XE2011 阅读(135) 评论(0) 推荐(0)
摘要: Label1->AutoSize = False;// TrueLabel1->Caption = "This string is too long to be the caption of this label";通过 为知笔记 发布 阅读全文
posted @ 2012-06-03 17:50 XE2011 阅读(155) 评论(0) 推荐(0)
摘要: #include "Unit2.h"void __fastcall TForm1::Button1Click(TObject *Sender){if (!Form2->Visible){Form2->Visible = true;Form2->BringToFront();}}通过 为知笔记 发布 阅读全文
posted @ 2012-06-03 17:50 XE2011 阅读(186) 评论(0) 推荐(0)
摘要: String String1 = "Abc";String String2 = "ABC";int I = CompareStr(String1, String2);// The value of I is less than 0.Edit1->Text = IntToStr(I); //Return Valueif (I != 0) ShowMessage ("The strings are n... 阅读全文
posted @ 2012-06-03 17:50 XE2011 阅读(170) 评论(0) 推荐(0)
摘要: void __fastcall TForm1::Button1Click(TObject *Sender){try{Form1->Caption = IntToStr(StrToInt(Edit1->Text) * StrToInt(Edit2->Text));}catch(...){ShowMessage("You must specify integer values. Please try ... 阅读全文
posted @ 2012-06-03 17:50 XE2011 阅读(176) 评论(0) 推荐(0)
摘要: #include <stdio.h>void main (){int value = 0;while (value <= 100){printf("%d\n", value);value++;}}通过 Wiz 发布 阅读全文
posted @ 2012-06-03 12:43 XE2011 阅读(160) 评论(0) 推荐(0)