II. Using (Windows 's ) API operate right here with a few distinct purposes to illustrate : Software 1: Delphi has control MEMO, when you use needs to be Control input or editing,
Windows 7 Home Premium Key, methods to establish the current cursor place? Then you can phone the Windows API purpose in the EM_LINEFROMCHAR and EM_LINEINDEX MEMO manage message to decide the current cursor row and column , the particular strategy contact is as follows : procedure TForm1.Button1Click (Sender: TObject);
var LineNum: longint; CharsBeforeLine: longint; start LineNum: = SendMessage (Memo1.Manage, EM_LINEFROMCHAR, Memo1.SelStart, 0); CharsBeforeLine: = SendMessage (Memo1.Handle,
Windows 7 Pro, EM_LINEINDEX,
Office Pro Plus, LineNum, 0); Label1.Caption: = 'Line:' + IntToStr (LineNum + 1); Label2.Caption: = 'Position:' + IntToStr ((Memo1.SelStart - CharsBeforeLine) +1); finish; Application two: Delphi control TlistBox not provided inside the horizontal scroll bar , in case you would like to add A horizontal flow area , we just use the API function to deliver a LB_SetHorizontalExtent TListBox message around the line. source code is as follows : SendMessage (ListBox1.Deal with,
Office Standard 2010 Key, LB_SetHorizontalExtent, 2000, longint (0)); Apps 3: Once we need to obtain the resolution of the computer running the plan , you'll find two ways : ① provided by Delphi Display screen accessibility global variables ,
Office 2007 Pro Plus Key, specifically Display screen.WIDTH and Screen.Height to give the display screen pixel resolution. ② making use of the API perform WINDOWS GetDeviceCaps () to get employed to the exhibit resolution , source code is as follows : Application.Initialize; Software.CreateForm (TForm1, Form1); Situation GetDeviceCaps (GetDC (Form1.Deal with), HORZRES) of 640: / / 640 * 480 resolution for processing the code ; 800: / / 800 * 600 resolution for processing the code ;
1024 : / / 1024 * 768 resolution for processing the code ; 1280: / / 1280 * 1024 resolution about the code for processing ; Finish; Application.Run;