菜鸟问题:如何建立一个无窗口单元,包含若干函数供其他窗口调用 File->New ,在对话框中选 Unit,单击OK。在别的单元中的Uses中加入这个单元的单元名后,就可用这个单元里的内容。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 // a exampleunit MyLib;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls,stdctrls;//ConnectToInternet打开一个IE窗口,并连接到对应网站function ConnnectToInternet(Addr:String):Integer;//CreateRotatedFont创建旋转字体function CreateRotatedFont(Font: TFont; Angle: Integer): HFont;//InputBox与VB类似的输入框function InputBox(const ACaption, APrompt: string; var Value: string): Boolean;implementationfunction ConnnectToInternet(Addr:String):Integer;var Rslt:LongBool; StartupInfo:TStartupInfo; ProcessInfo:TProcessInformation ; IEPath:array [0..MAX_PATH] of Char; IEName:String;begin GetWindowsDirectory(IEPath,MAX_PATH); IEName:=IEPath+'\Explorer.exe '+Addr; FillChar(StartupInfo,sizeof(TStartupInfo),0); with StartupInfo do begin cb:=sizeof(TStartupInfo); dwFlags:=STARTF_USESHOWWINDOW or STARTF_FORCEONFEEDBACK; wShowWindow:=SW_MAXIMIZE; end;Rslt:=CreateProcess(nil,Pchar(IEName),nil,nil,false, NORMAL_PRIORITY_CLASS,nil,nil,StartupInfo,ProcessInfo);if Rslt then with ProcessInfo do begin WaitForInputIdle(hProcess,INFINITE); CloseHandle(hThread); CloseHandle(hProcess); Result:=0; end else Result:=GetLastError;end;function CreateRotatedFont(Font: TFont; Angle: Integer): HFont;var LogFont: TLogFont;begin FillChar(LogFont, SizeOf(LogFont), 0); with LogFont do begin lfHeight := Font.Height; lfWidth := 0; lfEscapement := Angle * 10; lfOrientation := 0; if fsBold in Font.Style then lfWeight := FW_BOLD else lfWeight := FW_NORMAL; lfItalic := Ord(fsItalic in Font.Style); lfUnderline := Ord(fsUnderline in Font.Style); lfStrikeOut := Byte(fsStrikeOut in Font.Style);{$IFDEF RX_D3} lfCharSet := Byte(Font.Charset); if AnsiCompareText(Font.Name, 'Default') = 0 then StrPCopy(lfFaceName, DefFontData.Name) else StrPCopy(lfFaceName, Font.Name);{$ELSE} {$IFDEF VER93} lfCharSet := Byte(Font.Charset); {$ELSE} lfCharSet := DEFAULT_CHARSET; {$ENDIF} StrPCopy(lfFaceName, Font.Name);{$ENDIF} lfQuality := DEFAULT_QUALITY; lfOutPrecision := OUT_DEFAULT_PRECIS; lfClipPrecision := CLIP_DEFAULT_PRECIS; case Font.Pitch of fpVariable: lfPitchAndFamily := VARIABLE_PITCH; fpFixed: lfPitchAndFamily := FIXED_PITCH; else lfPitchAndFamily := DEFAULT_PITCH; end; end; Result := CreateFontIndirect(LogFont);end;function InputBox(const ACaption, APrompt: string; var Value: string): Boolean;var Form: TForm; Prompt: TLabel; Edit: TEdit; DialogUnits: TPoint; ButtonTop, ButtonWidth, ButtonHeight: Integer;begin Result := False; Form := TForm.Create(Application); with Form do try Font.Handle:=GetStockObject(Default_Gui_font); Canvas.Font := Font; DialogUnits := GetAveCharSize(Canvas); BorderStyle := bsDialog; Caption := ACaption; ClientWidth := MulDiv(180, DialogUnits.X, 4); ClientHeight := MulDiv(63, DialogUnits.Y, 8); Position := poScreenCenter; Prompt := TLabel.Create(Form); with Prompt do begin Parent := Form; AutoSize := True; Left := MulDiv(8, DialogUnits.X, 4); Top := MulDiv(8, DialogUnits.Y, 8); Caption := APrompt; end; Edit := TEdit.Create(Form); with Edit do begin Parent := Form; Left := Prompt.Left; Top := MulDiv(19, DialogUnits.Y, 8); Width := MulDiv(164, DialogUnits.X, 4); MaxLength := 255; Text := Value; SelectAll; end; ButtonTop := MulDiv(41, DialogUnits.Y, 8); ButtonWidth := MulDiv(50, DialogUnits.X, 4); ButtonHeight := MulDiv(14, DialogUnits.Y, 8); with TButton.Create(Form) do begin Parent := Form; Caption := '确定(&Y)'; ModalResult := mrOk; Default := True; SetBounds(MulDiv(38, DialogUnits.X, 4), ButtonTop, ButtonWidth, ButtonHeight); end; with TButton.Create(Form) do begin Parent := Form; Caption := '取消(&C)'; ModalResult := mrCancel; Cancel := True; SetBounds(MulDiv(92, DialogUnits.X, 4), ButtonTop, ButtonWidth, ButtonHeight); end; if ShowModal = mrOk then begin Value := Edit.Text; Result := True; end; finally Form.Free; end;end;end. Dephi windows服务如何打包发布? 关系密切的非技术问题! label 的拖动问题.!!!!!!!!! 呵呵!小问题!怎样取得一组字符串的ascii码? c/s需要什么技术 intraweb 发布成服务模式BDE连接出问题,高分200。。。。。 痛斥:SYBASE越活越老 上面下死任務﹕讓我對一個已做好的程序做最后的打包﹐望高手指點﹐分不夠可以再加﹗ 为什么我今天的程序按了F9编译,但是在目录里面却没有EXE这样的运行文件 动态构造sql问题 如何自定义一个事件? 取系统时间问题:
unit MyLib;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls,stdctrls;//ConnectToInternet打开一个IE窗口,并连接到对应网站
function ConnnectToInternet(Addr:String):Integer;
//CreateRotatedFont创建旋转字体
function CreateRotatedFont(Font: TFont; Angle: Integer): HFont;
//InputBox与VB类似的输入框
function InputBox(const ACaption, APrompt: string;
var Value: string): Boolean;
implementationfunction ConnnectToInternet(Addr:String):Integer;
var
Rslt:LongBool;
StartupInfo:TStartupInfo;
ProcessInfo:TProcessInformation ;
IEPath:array [0..MAX_PATH] of Char;
IEName:String;
begin
GetWindowsDirectory(IEPath,MAX_PATH);
IEName:=IEPath+'\Explorer.exe '+Addr;
FillChar(StartupInfo,sizeof(TStartupInfo),0);
with StartupInfo do
begin
cb:=sizeof(TStartupInfo);
dwFlags:=STARTF_USESHOWWINDOW or STARTF_FORCEONFEEDBACK;
wShowWindow:=SW_MAXIMIZE;
end;
Rslt:=CreateProcess(nil,Pchar(IEName),nil,nil,false,
NORMAL_PRIORITY_CLASS,nil,nil,StartupInfo,ProcessInfo);
if Rslt then
with ProcessInfo do
begin
WaitForInputIdle(hProcess,INFINITE);
CloseHandle(hThread);
CloseHandle(hProcess);
Result:=0;
end
else Result:=GetLastError;
end;function CreateRotatedFont(Font: TFont; Angle: Integer): HFont;
var
LogFont: TLogFont;
begin
FillChar(LogFont, SizeOf(LogFont), 0);
with LogFont do begin
lfHeight := Font.Height;
lfWidth := 0;
lfEscapement := Angle * 10;
lfOrientation := 0;
if fsBold in Font.Style then lfWeight := FW_BOLD
else lfWeight := FW_NORMAL;
lfItalic := Ord(fsItalic in Font.Style);
lfUnderline := Ord(fsUnderline in Font.Style);
lfStrikeOut := Byte(fsStrikeOut in Font.Style);
{$IFDEF RX_D3}
lfCharSet := Byte(Font.Charset);
if AnsiCompareText(Font.Name, 'Default') = 0 then
StrPCopy(lfFaceName, DefFontData.Name)
else
StrPCopy(lfFaceName, Font.Name);
{$ELSE}
{$IFDEF VER93}
lfCharSet := Byte(Font.Charset);
{$ELSE}
lfCharSet := DEFAULT_CHARSET;
{$ENDIF}
StrPCopy(lfFaceName, Font.Name);
{$ENDIF}
lfQuality := DEFAULT_QUALITY;
lfOutPrecision := OUT_DEFAULT_PRECIS;
lfClipPrecision := CLIP_DEFAULT_PRECIS;
case Font.Pitch of
fpVariable: lfPitchAndFamily := VARIABLE_PITCH;
fpFixed: lfPitchAndFamily := FIXED_PITCH;
else lfPitchAndFamily := DEFAULT_PITCH;
end;
end;
Result := CreateFontIndirect(LogFont);
end;function InputBox(const ACaption, APrompt: string;
var Value: string): Boolean;
var
Form: TForm;
Prompt: TLabel;
Edit: TEdit;
DialogUnits: TPoint;
ButtonTop, ButtonWidth, ButtonHeight: Integer;
begin
Result := False;
Form := TForm.Create(Application);
with Form do
try
Font.Handle:=GetStockObject(Default_Gui_font);
Canvas.Font := Font;
DialogUnits := GetAveCharSize(Canvas);
BorderStyle := bsDialog;
Caption := ACaption;
ClientWidth := MulDiv(180, DialogUnits.X, 4);
ClientHeight := MulDiv(63, DialogUnits.Y, 8);
Position := poScreenCenter;
Prompt := TLabel.Create(Form);
with Prompt do
begin
Parent := Form;
AutoSize := True;
Left := MulDiv(8, DialogUnits.X, 4);
Top := MulDiv(8, DialogUnits.Y, 8);
Caption := APrompt;
end;
Edit := TEdit.Create(Form);
with Edit do
begin
Parent := Form;
Left := Prompt.Left;
Top := MulDiv(19, DialogUnits.Y, 8);
Width := MulDiv(164, DialogUnits.X, 4);
MaxLength := 255;
Text := Value;
SelectAll;
end;
ButtonTop := MulDiv(41, DialogUnits.Y, 8);
ButtonWidth := MulDiv(50, DialogUnits.X, 4);
ButtonHeight := MulDiv(14, DialogUnits.Y, 8);
with TButton.Create(Form) do
begin
Parent := Form;
Caption := '确定(&Y)';
ModalResult := mrOk;
Default := True;
SetBounds(MulDiv(38, DialogUnits.X, 4), ButtonTop, ButtonWidth,
ButtonHeight);
end;
with TButton.Create(Form) do
begin
Parent := Form;
Caption := '取消(&C)';
ModalResult := mrCancel;
Cancel := True;
SetBounds(MulDiv(92, DialogUnits.X, 4), ButtonTop, ButtonWidth,
ButtonHeight);
end;
if ShowModal = mrOk then
begin
Value := Edit.Text;
Result := True;
end;
finally
Form.Free;
end;
end;
end.