CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
IBM Rational 系统开发最佳实践工具包 WebSphere MQ 最佳实践 TOP 15
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  .NET技术 >  C#

200分求一小段代码淂翻译 c# - vb.net

楼主lyhold(让你飞)2006-03-20 14:13:43 在 .NET技术 / C# 提问

public   class   GetFileNameClass  
        {  
              [DllImport(   "user32.dll"   )]    
              private   static   extern   IntPtr   GetForegroundWindow();    
              FolderBrowserDialog   _oFileDialog;  
              //   Properties  
              public   string   FileName  
              {  
                    get   {   return   _oFileDialog.SelectedPath;   }  
                    set   {   _oFileDialog.SelectedPath     =   value;   }  
              }  
  //             public   string   InitialDirectory  
  //             {  
  //                   get   {   return   _oFileDialog.InitialDirectory;   }  
  //                   set   {   _oFileDialog.InitialDirectory   =   value;   }  
  //             }  
     
              //   Constructor  
              public   GetFileNameClass()  
              {  
                    _oFileDialog   =   new   FolderBrowserDialog();  
              }  
     
              //   Methods  
     
              public   void   GetFileName()  
              {  
                    IntPtr   ptr   =   GetForegroundWindow();  
                    WindowWrapper   oWindow   =   new   WindowWrapper(ptr);  
                    if   (_oFileDialog.ShowDialog(oWindow)   !=   DialogResult.OK)  
                    {  
                          _oFileDialog.SelectedPath     =   string.Empty;  
                    }  
                    oWindow   =   null;  
              }  
        }  
   
   
    public   class   WindowWrapper   :   System.Windows.Forms.IWin32Window  
        {  
              private   IntPtr   _hwnd;  
     
              //   Property  
              public   virtual   IntPtr   Handle  
              {  
                    get   {   return   _hwnd;   }  
              }  
     
              //   Constructor  
              public   WindowWrapper(IntPtr   handle)  
              {  
                    _hwnd   =   handle;  
              }  
        }  
   
  谢谢 问题点数:200、回复次数:11Top

1 楼yf1025(小桥,流水,人家)回复于 2006-03-20 14:20:26 得分 100

Public   Class   GetFileNameClass  
              <DllImport("user32.dll")>   _      
              private   static   extern   IntPtr   GetForegroundWindow()    
              Dim   _oFileDialog   As   FolderBrowserDialog  
              '   Properties  
              Public   Property   FileName()   As   String  
              Get    
                      Return   _oFileDialog.SelectedPath  
              End   Get  
              Set   (ByVal   Value   As   String)    
                      _oFileDialog.SelectedPath     =   value  
              End   Set  
              End   Property  
  '             public   string   InitialDirectory  
  '             {  
  '                   get   {   return   _oFileDialog.InitialDirectory;   }  
  '                   set   {   _oFileDialog.InitialDirectory   =   value;   }  
  '             }  
     
              '   Constructor  
              Public     Sub   New()  
                    _oFileDialog   =   New   FolderBrowserDialog()  
              End   Sub  
     
              '   Methods  
     
              Public     Sub   GetFileName()  
                    Dim   ptr   As   IntPtr   =     GetForegroundWindow()    
                    Dim   oWindow   As   WindowWrapper   =     New   WindowWrapper(ptr)    
                    If   _oFileDialog.ShowDialog(oWindow)   <>   DialogResult.OK   Then  
                          _oFileDialog.SelectedPath     =   String.Empty  
                    End   If  
                    oWindow   =   Nothing  
              End   Sub  
  End   Class  
     
     
    Public   Class   WindowWrapper  
    Inherits   System.Windows.Forms.IWin32Window  
              Private   _hwnd   As   IntPtr  
     
              '   Property  
              Public   Overridable   ReadOnly   Property   Handle()   As   IntPtr  
              Get    
                      Return   _hwnd  
              End   Get  
              End   Property  
     
              '   Constructor  
              Public     Sub   New(ByVal   handle   As   IntPtr)  
                    _hwnd   =   handle  
              End   Sub  
    End   ClassTop

2 楼lyhold(让你飞)回复于 2006-03-20 14:28:51 得分 0

楼上淂兄弟,对不起,又几处错误能编译不过去Top

3 楼Mittermeyer(疾风之狼)回复于 2006-03-20 14:37:12 得分 20

在当前系统的前台窗口前显示一个FileDialog。  
  应该没有其他意思了。Top

4 楼BookSirSwordsMan(书生剑客)回复于 2006-03-20 14:42:04 得分 0

网上有那么多的软件可以转换从C#-VB.NET,从VB.NET-C#Top

5 楼lyhold(让你飞)回复于 2006-03-20 14:45:42 得分 0

但是感觉转换淂效果不好,编译不过去,而且运行淂结果跟C#不一样Top

6 楼wxdl1981(沉默之狼)回复于 2006-03-20 14:56:53 得分 0

楼主可真会偷懒啊!Top

7 楼20011521()回复于 2006-03-20 14:59:29 得分 0

我们公司有买了一个老外的  
  100美圆转得很好Top

8 楼20011521()回复于 2006-03-20 14:59:58 得分 0

现在找不到了那个转换的工具了Top

9 楼lyhold(让你飞)回复于 2006-03-20 15:04:08 得分 0

楼上的兄弟能帮个忙吗?Top

10 楼lyhold(让你飞)回复于 2006-03-21 10:25:48 得分 0

[DllImport("user32.dll",   EntryPoint="GetForegroundWindow")]  
  public   static   extern   int   GetForegroundWindow   ();  
   
  vb.net应该怎么写!谢谢!  
  [DllImport("user32.dll",   EntryPoint="GetForegroundWindow")]  
  public   static   extern   int   GetForegroundWindow   ();  
   
  vb.net应该怎么写!谢谢!Top

11 楼independently(我是风筝高高飞)回复于 2006-03-21 10:46:17 得分 80

DllImport("user32.dll",   EntryPoint:="GetForegroundWindow")=   _  
          Private   Shared   Function   GetForegroundWindow()   As   IntPtr  
          End   Function  
  Top

相关问题

  • 谁能把下面的VB代码翻译为C#
  • 谁能把下面的VB代码翻译为C#
  • 这句C#代码怎么翻译成VB?
  • 麻烦翻译一段c语言代码为vb代码,在线等,急!!!
  • 三行VB代码,请帮忙翻译成C#代码,高分在线等
  • 那位大哥帮我把这段c代码翻译成vb阿...急
  • 我开始从VB转学C#,请大家帮忙翻译一下我原来的VB代码
  • VB到BCB代码的翻译
  • 如何将vb中的Asc函数翻译成C#中的代码啊====各位高手想想办法啊
  • 如何将vb中的Asc函数翻译成C#中的代码啊====各位高手想想办法啊

关键词

  • c#
  • vb.net
  • win32
  • vb
  • 转换
  • dll
  • ofiledialog
  • windowwrapper
  • getforegroundwindow
  • owindow

得分解答快速导航

  • 帖主:lyhold
  • yf1025
  • Mittermeyer
  • independently

相关链接

  • CSDN .NET频道
  • .NET类图书
  • C#类图书
  • .NET类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo