问题大礼包,答对有糖吃!(300分)

  • 主题发起人 主题发起人 fengsi
  • 开始时间 开始时间
F

fengsi

Unregistered / Unconfirmed
GUEST, unregistred user!
No.1 怎样编辑鼠标的OnClick事件使之调用系统默认浏览器至相应网址和调用默认邮件收发程序发送邮件?(越简单越好)
No.2 OnMouseMove事件是不是鼠标一移上去就开始?有没有鼠标离开事件(不会是UnMouseMove吧)?若要产生鼠标离开事件,该怎样做?
No.3 Image控件只有BMP、JPG等格式,我记得VB中还有个PictureBox控件,为什么Delphi没有?如果我要显示TGA或者PCX图片该怎么办?
No.4 怎样使用OpenPictureDialog(不好意思,惭愧惭愧)?
No.5 怎样进行文件的COPY(只是简单COPY至特定文件夹)?Windows的SYSTEM文件夹该怎样表示(如%Windows%等)?
No.6 怎样根据Memo控件输入内容(包括换行)生成ini文件(并生成字段)?然后怎样用Memo控件显示ini文件内容(要过滤字段名如[Temp]等)?
No.7 自定义光标还是没搞懂,可不可以发给我例程?
No.8 我不行了,这么多不懂,各位海涵了!
No.9 广告:我的个人主页http://netblackhole.126.com,欢迎参观!
No.10 300大圆,我要破产了! :(
 
这么大的礼包?
1。uses shellapi;
用 shellexecute()
2。OnMouseLeave
3。到 cakk.126.com 有图象控件支持
4。类似于 OpenDialog
5。LZCopy
6。用“ini”检索一下有一堆
7。点我的帐号,看看我的信息里那个请 SupperMMX进的问题
8。我不懂的更多
9。去看看
10。还有呢 :)
 
使用GetSystemDirectory函数
5。UINT GetSystemDirectory(
LPTSTR lpBuffer, // address of buffer for system directory
UINT uSize // size of directory buffer
);

Parameters
lpBuffer
Points to the buffer to receive the null-terminated string containing the path. This pathdo
es not end with a backslash unless the system directory is the root directory. For example, if the system directory is named WINDOWS/SYSTEM on drive C, the path of the system directory retrieved by this function is C:/WINDOWS/SYSTEM.
uSize
Specifies the maximum size of the buffer, in characters. This value should be set to at least MAX_PATH.

Return Values
If the function succeeds, the return value is the length, in characters, of the string copied to the buffer, not including the terminating null character. If the length is greater than the size of the buffer, the return value is the size of the buffer required to hold the path.
 
No.4 怎样使用OpenPictureDialog(不好意思,惭愧惭愧)?
用法与 OpenDialog一样,这是 OpenPictureDialog比OpenDialog多一个
图象浏览器,可以看支持的图象;
》》自定义光标还是没搞懂,可不可以发给我例程?
作为资源引用
 
NO.1 uses ShellApi,调用函数ShellExecute,只需注意其中的一个PChar
类型参数的写法即可。如调用主页用 PChar('http://www.edu.cn'),
而调用邮件用 PChar('mailsto:yoller@263.net')。
NO.2 产生OnMouseLeave事件。
NO.3 用其它控件。
NO.4 与OpenDialog的用法基本相同。如
if OpenPictureDialog1.Execute then
begin
...
end;
NO.7 例程:
const
crMyCursor = 5;
procedure TForm1.FormCreate(Sender: TObject);
begin
Screen.Cursors[crMyCursor] := LoadCursor(HInstance,'NewCursor');
Cursor := crMyCursor;
end;
 
我试了一下,怎么Label控件没有OnMouseLeave事件的选项呀?
 
sorry,是没有 :)
 
属性中有许多是hidden的,但我选择了view all,为什么还是有hidden?
 
1. ShellExecute (Handle, 'open',
PChar ('tingweb@wx88.net'), '', '', sw_ShowNormal);
2.3.控件 实现4 同上
5。很罗嗦,一个实例
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, FileCtrl, ComCtrls;
const
SourceSect='Source';
DestSect ='Destination';
IncludeExtSect='Include extension';
MaskIdent ='Mask';
OverwriteSect='Overwrite options';
OverwriteIdent='Overwrite';
DriveIdent='Drive';
DirectoryIdent='Directory';
type
TCopyFiles = class(TForm)
Label1: TLabel;
Label2: TLabel;
SourcePath: TLabel;
DestinationPath: TLabel;
CopyFiles: TButton;
SourceDirectory: TDirectoryListBox;
DestinationDirectory: TDirectoryListBox;
SourceDrive: TDriveComboBox;
DestinationDrive: TDriveComboBox;
SourceFiles: TFileListBox;
DestinationFiles: TFileListBox;
IncludeExtBox: TScrollBox;
Label4: TLabel;
Bevel1: TBevel;
FIleCount: TLabel;
FilesLength: TLabel;
WriteOpt: TRadioGroup;
Bevel2: TBevel;
FreeLabel: TLabel;
ProgressBar: TProgressBar;
CopyingFileLabel: TLabel;
ButtonMkDir: TButton;
ButtonExit: TButton;
SaveINI: TButton;
SaveINIDlg: TSaveDialog;
procedure SourceDirectoryChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure DestinationDirectoryChange(Sender: TObject);
procedure CopyFilesClick(Sender: TObject);
procedure ButtonMkDirClick(Sender: TObject);
procedure ButtonExitClick(Sender: TObject);
procedure SaveINIClick(Sender: TObject);
private
{ Private declarations }
IncludeExt:TStringList;
SourceFilesList:TStringList;
procedure UpdateExt;
procedure UpdateMask;
procedure CheckBoxClick(Sender:TObject);
public
{ Public declarations }
function AutoCopy:boolean;
end;

var
CopyFiles: TCopyFiles;
implementation
{$R *.DFM}
uses Unit2,inifiles;
procedure TCopyFiles.SourceDirectoryChange(Sender: TObject);
begin
SourceFiles.Directory:=SourceDirectory.Directory;
UpdateExt;
end;

procedure TCopyFiles.UpdateExt;
var F:integer;
SearchRec:TSearchRec;
s:string[5];
i:integer;
CheckBox:TCheckBox;
Control:TControl;
SSepar:string;
begin
try
IncludeExtBox.Visible:=false;
{Remove old checkboxes and clear extensions list}
while IncludeExtBox.ControlCount > 0do
begin
Control:=IncludeExtBox.Controls[0];
IncludeExtBox.RemoveControl(Control);
Control.Destroy;
end;
IncludeExt.Clear;
{Create list of possible extensions}
if SourceDirectory.Directory[length(SourceDirectory.Directory)]='/'
then
SSepar:='' else
SSepar:='/';
F := FindFirst(SourceDirectory.Directory+SSepar+'*.*',
faAnyFile and (not faDirectory), SearchRec);
while F = 0do
begin
s:=ExtractFileExt(SearchRec.Name);
if s[1]='.' then
system.delete(s,1,1);
if length(s)=0 then
s:=' ';
IncludeExt.Add(s);
F := FindNext(SearchRec);
end;
FindClose(SearchRec);
CheckBox:=NIL;
{Insert new checkboxes}
for i:=0 to IncludeExt.Count-1do
begin
CheckBox:=TCheckBox.Create(IncludeExtBox);
CheckBox.Parent:=IncludeExtBox;
with CheckBoxdo
begin
Width:=50;
Height:=17;
Top:=4+Height*i;
Left:=4;
Caption:=IncludeExt;
Checked:=true;
Font.Name:='Times New Roman';
Font.Size:=8;
OnClick:=CheckBoxClick;
end;
end;
if CheckBox<>NIL then
IncludeExtBox.ScrollInView(CheckBox);
finally
IncludeExtBox.Visible:=true;
UpdateMask;
end;
end;

procedure TCopyFiles.UpdateMask;
var Mask:string;
i,size:integer;
SearchRec:TSearchRec;
begin
Screen.Cursor:=crHourGlass;
Mask:='';
for i:=0 to IncludeExtBox.ControlCount-1do
if (IncludeExtBox.Controls is TCheckBox) then
with (IncludeExtBox.Controls as TCheckBox)do
begin
if Checked then
Mask:=Mask+'*.'+Caption+';';
end;
SourceFiles.Mask:=Mask;
FileCount.Caption:='Number of files: '+IntToStr(SourceFiles.Items.Count);
size:=0;
for i:=0 to SourceFiles.Items.Count-1do
begin
FindFirst(SourceFiles.Items,faAnyFile,SearchRec);
size:=size+SearchRec.Size;
FindClose(SearchRec);
end;
FilesLength.Caption:='Total size: '+IntToStr(size div 1024)+' KB';
Screen.Cursor:=crDefault;
end;

procedure TCopyFiles.FormCreate(Sender: TObject);
begin
IncludeExt:=TStringList.Create;
IncludeExt.Sorted:=true;
IncludeExt.Duplicates:=dupIgnore;
SourceFilesList:=TStringList.Create;
UpdateExt;
end;

procedure TCopyFiles.FormDestroy(Sender: TObject);
begin
IncludeExt.Destroy;
SourceFilesList.Destroy;
end;

procedure TCopyFiles.CheckBoxClick(Sender:TObject);
begin
UpdateMask;
end;

procedure TCopyFiles.DestinationDirectoryChange(Sender: TObject);
begin
FreeLabel.Caption:='Free: '+IntToStr(DiskFree(0) div 1024)+' KB';
end;

procedure TCopyFiles.CopyFilesClick(Sender: TObject);
var FName,SDir,DDir:string;
CopyBuffer: Pointer;
{ buffer for copying }
TimeStamp, BytesCopied: Longint;
Source, Dest: Integer;
{ handles }
i:integer;
SSepar,DSepar:string;
label TryAgain,TryAgain2,TryAgain3,TryAgain4;
//Did I really use labels ????!!!
const
ChunkSize: Longint = 32768;
begin
if (SourceDrive.Drive=DestinationDrive.Drive) and
(SourceDirectory.Directory=DestinationDirectory.Directory) then
ShowMessage('You cannot copy to the same directory!')
else
begin
try
Screen.Cursor:=crHourGlass;
SDir:=SourceDirectory.Directory;
DDir:=DestinationDirectory.Directory;
if SDir[length(SDir)]='/' then
SSepar:='' else
SSepar:='/';
if DDir[length(DDir)]='/' then
DSepar:='' else
DSepar:='/';
GetMem(CopyBuffer, ChunkSize);
{ allocate the buffer }
for i:=0 to SourceFiles.Items.Count-1do
begin
FName:=ExtractFileName(SourceFiles.Items);
ProgressBar.Position:=trunc(i*100/SourceFiles.Items.Count);
CopyingFileLabel.Caption:='Copying: '+FName;
CopyingFileLabel.Update;
TimeStamp := FileAge(FName);
{ get source's time stamp }
TryAgain:
Source := FileOpen(SDir+SSepar+FName, fmShareDenyWrite);
{ open source file }
if Source < 0 then
case MessageDlg('Error reading file'#13#10+FName,mtError,
[mbAbort,mbRetry,mbIgnore],0) of
mrAbort:Break;
//Exit for... loop
mrRetry:GoTo TryAgain;
mrIgnore:Continue;//Continue for... loop
end;
if WriteOpt.ItemIndex=1 then
//See if there is an old file
if FileExists(DDir+DSepar+FName) then
case MessageDlg('File '+FName+' already exits'#13#10'Overwrite ?', mtConfirmation,
[mbYes,mbNo,mbAll],0) of
mrYes:begin
end;
mrNo: Continue;
//Continue for ... loop
mrAll:WriteOpt.ItemIndex:=0;
//Always overwrite
end;
TryAgain2:
Dest := FileCreate(DDir+DSepar+FName);
{ create output file}
if Dest < 0 then
case MessageDlg('Error creating '+FName,mtError,
[mbAbort,mbRetry,mbIgnore],0) of
mrAbort:Break;
//Exit for... loop
mrRetry:GoTo TryAgain2;
mrIgnore:Continue;//Continue for... loop
end;
try
repeat
TryAgain3:
{$I-}
BytesCopied := FileRead(Source, CopyBuffer^, ChunkSize);
{ read chunk }
{$I+}
if IOResult <> 0 then
case MessageDlg('Error reading file'#13#10+FName,mtError,
[mbAbort,mbRetry,mbIgnore],0) of
mrAbort:Break;
//Exit repeat... loop
mrRetry:GoTo TryAgain3;
mrIgnore:Continue;//Continue repeat... loop
end;
if BytesCopied > 0 then
begin
{ if we read anything... }
TryAgain4:
{$I-}
FileWrite(Dest, CopyBuffer^, BytesCopied);
{ ...write chunk }
{$I+}
if IOResult <> 0 then
case MessageDlg('Error writing file'#13#10+FName,mtError,
[mbAbort,mbRetry,mbIgnore],0) of
mrAbort:Break;
//Exit repeat... loop
mrRetry:GoTo TryAgain4;
mrIgnore:Continue;//Continue repeat... loop
end;
end;
until BytesCopied < ChunkSize;
{ until we run out of chunks }
finally
FileSetDate(Dest, TimeStamp);
FileClose(Dest);
{ close the destination file }
end;
end;
finally
ProgressBar.Position:=0;
CopyingFileLabel.Caption:='';
DestinationFiles.Update;
FreeMem(CopyBuffer, ChunkSize);
Screen.Cursor:=crDefault;
end;
end;
end;

procedure TCopyFiles.ButtonMkDirClick(Sender: TObject);
begin
with CreateNewDirDlgdo
if ShowModal=mrOk then
begin
{$I-}
MkDir(NewDir.Text);
{$I+}
if IOResult<>0 then
MessageDlg('Error creating directory'#13#10+
NewDir.Text,mtError,[mbOk],0)
else
begin
DestinationDirectory.Directory:=NewDir.Text;
end;
end;
end;

procedure TCopyFiles.ButtonExitClick(Sender: TObject);
begin
Close;
end;

procedure TCopyFiles.SaveINIClick(Sender: TObject);
var INIFile:TINIFile;
ININame:string;
begin
if SaveINIDlg.Execute then
begin
INIFile:=TINIFile.Create(SaveINIDlg.Filename);
INIFile.WriteString(SourceSect,DriveIdent,SourceDrive.Drive);
INIFile.WriteString(SourceSect,DirectoryIdent,SourceDirectory.Directory);
INIFile.WriteString(DestSect,DriveIdent,DestinationDrive.Drive);
INIFile.WriteString(DestSect,DirectoryIdent,DestinationDirectory.Directory);
INIFile.WriteInteger(OverwriteSect,OverwriteIdent,WriteOpt.ItemIndex);
INIFile.WriteString(IncludeExtSect,MaskIdent,SourceFiles.Mask);
end;
end;

function TCopyFiles.AutoCopy:boolean;
var INIFile:TINIFile;
ININame:string;
params:string;
begin
Result:=false;
if ParamCount > 1 then
if UpperCase(ParamStr(1))='/A' then
begin
if ExtractFileName(ParamStr(2))=ParamStr(2) then
begin
ININame:=GetCurrentDir;
if ININame[length(ININame)]='/' then
ININame:=ININame+ParamStr(2) else
ININame:=ININame+'/'+ParamStr(2)
end else
ININame:=ParamStr(2);
if FileExists(ININame) then
begin
Show;
INIFile:=TINIFile.Create(ININame);
SourceDrive.Drive:=INIFile.ReadString(SourceSect,DriveIdent,'')[1];
SourceDirectory.Directory:=INIFile.ReadString(SourceSect,DirectoryIdent,'');
DestinationDrive.Drive:=INIFile.ReadString(DestSect,DriveIdent,'')[1];
DestinationDirectory.Directory:=INIFile.ReadString(DestSect,DirectoryIdent,'');
WriteOpt.ItemIndex:=INIFile.ReadInteger(OverwriteSect,OverwriteIdent,1);
SourceFiles.Mask:=INIFile.ReadString(IncludeExtSect,MaskIdent,'');
CopyFilesClick(Self);
Result:=true;
end else
Showmessage('File not found: '+ParamStr(2));
end else
ShowMessage('Unknown command line parameter'#13#10+ParamStr(1));
end;

end.

6。建议使用tstringlist
ini的话 一试便知
var
pc:tinifile;
begin
pc:=tinifile.create('email.ini');
pc.writestring(s,'Host',edit1.text);
pc.writestring(s,'Email',edit2.text);
pc.writestring(s,'Name',edit3.text);
pc.writestring(s,'Port','110');
pc.free;
end;

 
谢谢各位!
 
多人接受答案了。
 
后退
顶部