码农的笔记

Delphi虽好,但已不流行; 博客真好,可以做笔记

博客园 首页 新随笔 联系 订阅 管理

----------Unit开始

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;

type
TForm1 = class(TForm)
ComboBox1: TComboBox;
Button1: TButton;
Button2: TButton;
Edit1: TEdit;
Button3: TButton;
Timer1: TTimer;
Memo1: TMemo;
Memo2: TMemo;
Edit2: TEdit;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Memo1Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
ss:string;
begin
ss:='发的手机号' ;
//TObject(ss)是强制转换
ComboBox1.Items.AddObject('11111',TObject(ss)); //赋值 ,,,,TObject(ss)是强制转换

end;

procedure TForm1.Button2Click(Sender: TObject);
var
sss:string;
begin
//string()是强制转换
sss:=string(ComboBox1.Items.Objects[ComboBox1.ItemIndex ]) ; //读取值
//sss:=IntToStr(Integer(ComboBox1.Items.Objects[ComboBox1.ItemIndex ]));
Edit1.text :=sss;
end;

procedure TForm1.Button3Click(Sender: TObject);
var
ii:integer;
begin
ii:=55;
ComboBox1.Items.AddObject('55',TObject(ii)); //赋值 ,,,,TObject(ss)是强制转换
end;

procedure TForm1.Timer1Timer(Sender: TObject);
var
lpCaption:array[0..299] of char;//需要显示多一点请把这个设置大一点
hwd:THANDLE;
p:Tpoint;
begin
GetCursorPos(p); //取当前鼠标指针位置
hWd := WindowFromPoint(p); //取当前鼠标指针位置句柄
GetWindowText(hWd, lpCaption, 300); //获取当前鼠标指针位置文本    //需要显示多一点请把这个设置大一点
memo1.Text :=string(lpCaption);
end;

procedure TForm1.Memo1Change(Sender: TObject);
begin
Edit2.Text:=inttostr(Length(Memo1.Text ));
end;

end.

-------------Unit结束

object Form1: TForm1
Left = 777
Top = 438
Width = 584
Height = 474
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object ComboBox1: TComboBox
Left = 16
Top = 32
Width = 73
Height = 21
Style = csDropDownList
ImeName = '中文(简体) - 搜狗拼音输入法'
ItemHeight = 13
TabOrder = 0
end
object Button1: TButton
Left = 96
Top = 32
Width = 75
Height = 25
Caption = 'button1_string'
TabOrder = 1
OnClick = Button1Click
end
object Button2: TButton
Left = 144
Top = 88
Width = 75
Height = 25
Caption = 'button2'
TabOrder = 2
OnClick = Button2Click
end
object Edit1: TEdit
Left = 8
Top = 88
Width = 129
Height = 21
ImeName = '中文(简体) - 搜狗拼音输入法'
TabOrder = 3
Text = 'Edit1'
end
object Button3: TButton
Left = 176
Top = 32
Width = 89
Height = 25
Caption = 'button3_integer'
TabOrder = 4
OnClick = Button3Click
end
object Memo1: TMemo
Left = 32
Top = 120
Width = 185
Height = 241
ImeName = '中文(简体) - 搜狗拼音输入法'
Lines.Strings = (
'Memo1')
TabOrder = 5
OnChange = Memo1Change
end
object Memo2: TMemo
Left = 352
Top = 16
Width = 185
Height = 353
ImeName = '中文(简体) - 搜狗拼音输入法'
Lines.Strings = (
'sdhfgjhasdgasdfjasdgjhasgdfjhgsdfjhs'
'df'
'sdhfgjhasdgasdfjasdgjhasgdfjhgsdfjhs'
'df'
'sdhfgjhasdgasdfjasdgjhasgdfjhgsdfjhs'
'df'
'sdhfgjhasdgasdfjasdgjhasgdfjhgsdfjhs'
'df'
'sdhfgjhasdgasdfjasdgjhasgdfjhgsdfjhs'
'df'
'sdhfgjhasdgasdfjasdgjhasgdfjhgsdfjhs'
'df'
'sdhfgjhasdgasdfjasdgjhasgdfjhgsdfjhs'
'df'
'sdhfgjhasdgasdfjasdgjhasgdfjhgsdfjhs'
'df'
'sdhfgjhasdgasdfjasdgjhasgdfjhgsdfjhs'
'df'
'sdhfgjhasdgasdfjasdgjhasgdfjhgsdfjhs'
'df'
'sdhfgjhasdgasdfjasdgjhasgdfjhgsdfjhs'
'df'
'sdhfgjhasdgasdfjasdgjhasgdfjhgsdfjhs'
'df'
'sdhfgjhasdgasdfjasdgjhasgdfjhgsdfjhs'
'df'
'sdhfgjhasdgasdfjasdgjhasgdfjhgsdfjhs'
'df'
'sdhfgjhasdgasdfjasdgjhasgdfjhgsdfjhs'
'df'
'sdhfgjhasdgasdfjasdgjhasgdfjhgsdfjhs'
'df'
'sdhfgjhasdgasdfjasdgjhasgdfjhgsdfjhs'
'df'
'sdhfgjhasdgasdfjasdgjhasgdfjhgsdfjhs'
'df'
'sdhfgjhasdgasdfjasdgjhasgdfjhgsdfjhs'
'df'
'sdhfgjhasdgasdfjasdgjhasgdfjhgsdfjhs'
'df'
''
'sdhfgjhasdgasdfjasdgjhasgdfjhgsdfjhs'
'df'
'sdhfgjhasdgasdfjasdgjhasgdfjhgsdfjhs'
'df')
TabOrder = 6
end
object Edit2: TEdit
Left = 224
Top = 256
Width = 121
Height = 21
ImeName = '中文(简体) - 搜狗拼音输入法'
TabOrder = 7
Text = 'Edit2'
end
object Timer1: TTimer
OnTimer = Timer1Timer
Left = 80
Top = 192
end
end

 

posted on 2020-12-18 17:50  码农的笔记  阅读(377)  评论(0编辑  收藏  举报