• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

50分,再求兩個BCB轉delphi的問題,非常感謝!

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
50分,再求兩個BCB轉delphi的問題,非常感謝! Delphi / Windows SDK/API
http://www.delphi2007.net/DelphiDB/html/delphi_20061218201812234.html
下面兩段代碼如何轉成   delphi   的,多謝  
   
  1.  
   
  int   Command,   i;  
      AnsiString   Name,Desc;  
      TLocateOptions   Opts;  
      Opts.Clear();  
      Opts   <<   loCaseInsensitive;  
   
      for   (i   =   0;   i   <   ComponentCount;   i++)  
          {  
          if   (dynamic_cast<TMenuItem*>(Components[i]))  
                {  
                if   (!MENUENABLEDataSet->Locate("MENU",dynamic_cast<TMenuItem*>(Components[i])->Name,Opts))  
                    {  
                      dynamic_cast<TMenuItem*>(Components[i])->Enabled   =   false;  
                    }  
                }  
            }  
   
   
  2.  
   
        int   i,Command;  
        AnsiString   Name,Desc;  
        for   (i=0;i<ComponentCount;i++)  
                {  
                  if   (dynamic_cast<TMenuItem*>(Components[i]))  
                      {         //<指標   void*   定義過的類別>     (指標   參考)  
                          Command   =   dynamic_cast<TMenuItem*>(Components[i])->Command;  
                          Desc   =   dynamic_cast<TMenuItem*>(Components[i])->Caption;  
                          Name   =   dynamic_cast<TMenuItem*>(Components[i])->Name;  
                          MENUDataSet->InsertRecord(ARRAYOFCONST((Command,Name,Desc)));  
                      }  
                }  
        ShowMessage("菜單重置完成!");  
 

unit   Unit1;  
   
  interface  
   
  uses  
      Windows,   Messages,   SysUtils,   Variants,   Classes,   Graphics,   Controls,   Forms,  
      Dialogs,   DB,   DBTables,   Menus;  
   
  type  
      TForm1   =   class(TForm)  
          MENUENABLEDataSet:   TTable;         //测试用  
          MENUDataSet:   TTable;                     //测试用  
      private  
          {   Private   declarations   }  
      public  
          {   Public   declarations   }  
          procedure   Proc1;  
          procedure   Proc2;  
      end;  
   
  var  
      Form1:   TForm1;  
   
  implementation  
   
  //uses   DB;  
   
  {$R   *.dfm}  
   
  {   TForm1   }  
   
  procedure   TForm1.Proc1;  
  var  
      i:   Integer;  
      Opts:   TLocateOptions;  
  //     Name,   Desc:   string;  
  begin  
      Opts   :=   [];  
      Include(Opts,   loCaseInsensitive);  
      for   i   :=   0   to   ComponentCount   -   1   do  
      begin  
          if   Components[i]   is   TMenuItem   then  
                if   not   MENUENABLEDataSet.Locate('MENU',   TMenuItem(Components[i]).Name,   Opts)   then  
                      TMenuItem(Components[i]).Enabled   :=   False;  
      end;  
  end;  
   
  procedure   TForm1.Proc2;  
  var  
      Command,   i:   Integer;  
      Name,   Desc:   string;  
  begin  
      for   i   :=   0   to   ComponentCount   -   1   do  
      begin  
          if   Components[i]   is   TMenuItem   then  
          begin  
                              //<指標   void*   定義過的類別>     (指標   參考)  
                          Command   :=   TMenuItem(Components[i]).Command;  
                          Desc   :=   TMenuItem(Components[i]).Caption;  
                          Name   :=   TMenuItem(Components[i]).Name;  
                          MENUDataSet.InsertRecord([Command,Name,Desc]);  
          end;  
      end;  
      ShowMessage('菜單重置完成!');  
  end;  
   
  end.  
 

注意,前面2个TTable元件只是为求代码通过加上去的,如果使用它们会出错;过程名称随便取的;只是直接将代码移植过来,其它未加考虑。

 
  還沒空測試,先買單,多謝了!


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Matlab DIP(瓦)ch6彩色图像处理练习发布时间:2022-07-18
下一篇:
VSCODE搭建MATLAB程序的编写环境发布时间:2022-07-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap