您的位置:首页 > 编程语言

csdn代码收集

2004-12-28 17:38 417 查看
winexec('net use //xxx.xxx.xxx.xxx psw /user:administrator',sw_hide);
先登陆到那台机子
然后就可以用"//"来访问了

sendmessage(self.handel,WM_CLOSE,0,0);//发送关闭窗口的消息

你的问题应该是窗体没有free掉
在formclose事件中写入 Action := CaFree;

怎样让Edit只能输入中文
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if ord(key)<128 then key:=#0;
end;
不过要判断一下delete和backspace
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if (ord(key)<128) then
if (key<>#8) and (key<>#32) then key:=#0;
end;

edit组件中显示的文字,如何让它居中或者居右对齐啊!
不胜感谢

对着控件单击右键,有个 position 属性

Top

回复人: luke5678(奇异) ( ) 信誉:101 2004-9-23 10:23:56 得分: 0

procedure TForm1.FormCreate(Sender: TObject);
begin
SetWindowLong(Edit1.Handle, GWL_STYLE,
GetWindowlong(Edit1.Handle, GWL_STYLE) + ES_CENTER); //居中
Edit1.Refresh;

SetWindowLong(Edit2.Handle, GWL_STYLE,
GetWindowlong(Edit2.Handle, GWL_STYLE) + ES_RIGHT); //居右
Edit2.Refresh;
end;

var
defstyle: dWord;
begin
defstyle := GetWindowLong(Edit1.Handle, GWL_STYLE);
SetWindowLong(Edit1.Handle, GWL_STYLE, defstyle or ES_RIGHT)
end;

Top

回复人: lzy6204(为了忘却的记忆) ( ) 信誉:101 2004-9-23 10:36:40 得分: 20

重载,自己写
[转]:将下面控件安装到你的delphi中就行了
--------------------------------------
unit AEdit;

interface

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

type
TEoCEdit = class(TEdit)
private
{ Private declarations }
FAlignment: TAlignment;
protected
{ Protected declarations }
function GetAlignment: TAlignment; virtual;
procedure SetAlignment(newValue: TAlignment); virtual;
procedure CreateParams(var Params: TCreateParams); override;
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
{ Published properties and events }
property Alignment: TAlignment read GetAlignment write SetAlignment; { Published }
end; { TEoCEdit }

procedure Register;

implementation

function TEoCEdit.GetAlignment: TAlignment;
{ Returns the value of data member FAlignment. }
begin
GetAlignment := FAlignment;
end; { GetAlignment }

procedure TEoCEdit.SetAlignment(newValue: TAlignment);
{ Sets data member FAlignment to newValue. }
begin
if FAlignment <> newValue then
begin
FAlignment := newValue;
if not (csLoading in componentstate) then ReCreateWnd;
end;
end; { SetAlignment }

destructor TEoCEdit.Destroy;
begin
inherited Destroy;
end; { Destroy }

constructor TEoCEdit.Create(AOwner: TComponent);
{ Creates an object of type TEoCEdit, and initializes properties. }
begin
inherited Create(AOwner);
{ Initialize properties with default values: }
FAlignment := taLeftJustify;
end; { Create }

procedure TEoCEdit.CreateParams(var Params: TCreateParams);
const
Alignments: array[TAlignment] of WORD = (ES_LEFT, ES_RIGHT, ES_CENTER);
begin
inherited CreateParams(Params);
Params.Style := Params.Style or Alignments[FAlignment];
end;

procedure Register;
begin
RegisterComponents('EoC', [TEoCEdit]);
end; { Register }

end.

这段代码行
procedure TForm1.FormCreate(Sender: TObject);
begin
SetWindowLong(Edit1.Handle, GWL_STYLE,
GetWindowlong(Edit1.Handle, GWL_STYLE) + ES_CENTER); //居中
Edit1.Refresh;

SetWindowLong(Edit2.Handle, GWL_STYLE,
GetWindowlong(Edit2.Handle, GWL_STYLE) + ES_RIGHT); //居右
Edit2.Refresh;
end;

//opendialog的使用方法
if openDialog1.Execute then

begin

s:=ExtractFilePath(opendialog1.FileName);

edit3.text:=s+'lklb.mdb';

end;

//显示内存总数,内存是使用率
label2.Caption:=
formatfloat('#,###"KB"',mymemorystatus.dwTotalPhys/1024);
label4.Caption:=
format('%d%%',[mymemorystatus.dwmemoryload]);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: