Posts

Showing posts from December, 2006

TMemo drag and drop

unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, extctrls; type TForm1 = class(TForm) Memo1: TMemo; Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; type TDragEdit = class(TMemo) private FLastSelStart : Integer; FLastSelLength : Integer; FDragImages: TDragImageList; procedure WMLButtonDown(var Message: TWMLButtonDown); message WM_LBUTTONDOWN; protected function GetDragImages: TDragImageList; override; public constructor Create(AOwner : TComponent); override; property LastSelStart : Integer read FLastSelStart write FLastSelStart; property LastSelLength : Integer read FLastSelLength write FLastSelLength; end; implementation {$R *.dfm} constructor TDragEdit.Create(AOwner: TComponent); begin inherited; ControlStyle := ControlStyle + [csDisplayD

Determine network status

unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComObj, ActiveX; type TForm1 = class(TForm) Button1: TButton; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation uses ActiveDs_TLB; {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); var wmi : variant; wmiService : variant; nicstatus : variant; card : Olevariant; cnt : integer; Enum: IEnumVariant; P : IUnknown; F : Cardinal; connected : integer; status : string; begin WMI:=CreateOleObject('WbemScripting.SWbemLocator'); wmiService := wmi.ConnectServer('.', 'root\wmi'); nicstatus := wmiService.InstancesOf('MSNdis_MediaConnectStatus'); p := nicstatus._NewEnum; p.QueryInterface(IEnumVariant, Enum); for cnt := 0 to nicstatus