◇[Delphi]产生鼠标拖动效果 通过MouseMove事件、DragOver事件、EndDrag事件实现,例如在PANEL上的LABEL: var xpanel,ypanel,xlabel,ylabel:integer; PANEL的MouseMove事件:xpanel:=x;ypanel:=y; PANEL的DragOver事件:xpanel:=x;ypanel:=y; LABEL的MouseMove事件:xlabel:=x;ylabel:=y; LABEL的EndDrag事件:label.left:=xpanel-xlabel;label.top:=ypanel-ylabel;
◇[Delphi]取得WINDOWS目录 uses shellapi; var windir:array[0..255] of char; getwindowsdirectory(windir,sizeof(windir)); 或者从注册表中读取,位置: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion SystemRoot键,取得如:C:\WINDOWS
◇[Delphi]在FORM或其他容器上画线 var x,y:array [0..50] of integer; canvas.pen.color:=clred; canvas.pen.style:=psDash; form1.canvas.moveto(trunc(x[i]),trunc(y[i])); form1.canvas.lineto(trunc(x[j]),trunc(y[j]));
◇[Delphi]字符串列表使用 var tips:tstringlist; tips:=tstringlist.create; tips.loadfromfile('filename.txt'); edit1.text:=tips[0]; tips.add('last line addition string'); tips.insert(1,'insert string at NO 2 line'); tips.savetofile('newfile.txt'); tips.free;
◇[Delphi]处理文件属性 attr:=filegetattr(filelistbox1.filename); if (attr and faReadonly)=faReadonly then ... //只读 if (attr and faSysfile)=faSysfile then ... //系统 if (attr and faArchive)=faArchive then ... //存档 if (attr and faHidden)=faHidden then ... //隐藏
◇[Delphi]取得系统运行的进程名 var hCurrentWindow:HWnd;szText:array[0..254] of char; begin hCurrentWindow:=Getwindow(handle,GW_HWndFrist); while hCurrentWindow <> 0 do begin if Getwindowtext(hcurrnetwindow,@sztext,255)>0 then listbox1.items.add(strpas(@sztext)); hCurrentWindow:=Getwindow(hCurrentwindow,GW_HWndNext); end; end;