国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Delphi > 正文

delphi一句話幫助終

2019-11-18 18:35:43
字體:
來源:轉載
供稿:網友
1.       產生隨機密碼(應該比較有用)
   function CreatePass:String;
const
      MAX_LEN=10;
var
      i: integer;
      s: string;
begin
      Randomize;
      s:='ABCDEFGHIJKLMNOPQRSTUVWXYZ'+'abcdefghijklmnopqrstuvwxyz'+ '0123456789';
      Result := '';
      for i := 0 to MAX_LEN-1 do
      begin
        Result := Result + s[Random(Length(s)-1)+1];
      end;
end;
2.       十進制數字轉換成羅馬數字
   function DecToRoman(iDecimal: longint): string;
const
      aRomans: array[1..13] of string = ('I', 'IV', 'V', 'IX', 'X', 'XL', 'L', 'XC',
         'C', 'CD', 'D', 'CM', 'M');
      aArabics: array[1..13] of integer = (1, 4, 5, 9, 10, 40, 50, 90, 100, 400,
         500, 900, 1000);
var
      i: integer;
begin
      result := '';
      for i := 13 downto 1 do
        while (iDecimal >= aArabics[i]) do
        begin
           iDecimal := iDecimal - aArabics[i];
           result := result + aRomans[i];
        end;
end;
 
PRocedure TForm1.Button1Click(Sender: TObject);
begin
      showmessage(DecToRoman(5));
end;
3.       格式化整數顯示
使用FormatFloat函數可以解決你很多問題。例如把1200000格式化為1,200,000輸出
procedure TForm1.Button1Click(Sender: TObject);
var
  i:integer;
  s:string;
begin
  i := 1200000;
  s := FormatFloat('#,0', i);
  showmessage(s);
end;
4.       判斷串口是否收到了數據可以使用ClearCommError函數,TcomStat結構體中cbInQue,cbOutQue可以幫助實現判斷。
5.       RGB顏色轉換為TColor類
   function RGBToColor(R,G,B:Byte): TColor;
begin
      Result:=B Shl 16 Or
             G Shl 8 Or
             R;
end;
6.       把TColor轉換為RGB值
   procedure TForm1.Button1Click(Sender: TObject);
var
      Color: TColor;
      R, G, B: Integer;
begin
      Color := clBlack;
      R := Color and $FF;
      G := (Color and $FF00) shr 8;
      B := (Color and $FF0000) shr 16;
      showmessage(inttostr(R));
      showmessage(inttostr(G));
      showmessage(inttostr(B));
end;
7.       瀏覽計算機對話框
uses ShlObj;
function BrowseForComputer(const winhandle : THANDLE; const title : string) : string;
var
  BrowseInfo: TBrowseInfo;
  IDRoot: PItemIDList;
  Path: array[0..MAX_PATH] of Char;
begin
  SHGetSpecialFolderLocation(winHandle, CSIDL_NETWORK, IDRoot);
  ZeroMemory(@BrowseInfo, SizeOf(TBrowseInfo));
  ZeroMemory(@path, MAX_PATH);
  BrowseInfo.hwndOwner := winhandle;
  BrowseInfo.pidlRoot := IDRoot;
  BrowseInfo.lpszTitle := PChar(title);
  BrowseInfo.pszDisplayName := @path;
  BrowseInfo.ulFlags:=BIF_BROWSEFORCOMPUTER;
  SHBrowseForFolder(BrowseInfo);
end;
 

上一篇:Delphi中兩個BUG的分析與修復

下一篇:Delphi與Word(三)取得Word文件的數據

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
學習交流
熱門圖片

新聞熱點

疑難解答

圖片精選

網友關注

主站蜘蛛池模板: 漳浦县| 辽源市| 黑水县| 石屏县| 清水河县| 鹤峰县| 临夏县| 双流县| 沭阳县| 石家庄市| 沾益县| 富平县| 从江县| 永宁县| 高尔夫| 安义县| 鲜城| 芦山县| 兴隆县| 独山县| 漳平市| 邮箱| 甘孜| 拉孜县| 略阳县| 怀仁县| 安顺市| 五台县| 榆树市| 福清市| 陆丰市| 连江县| 郓城县| 丰都县| 栾川县| 曲靖市| 安阳市| 阿拉善盟| 日土县| 余庆县| 霞浦县|