From: Kieran Tully Date: 2012-12-28T01:16:25+09:00 Subject: Re: "Open" dialog of Windows --14dae9340ddf16bfcc04d1d7c906 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Mon, Dec 24, 2012 at 8:37 PM, Dami=E1n M. Gonz=E1lez wrote: > Hi guys, been researching about pop up the "open" file dialog of > Windows. I didn't find nothing, just a snippet of code that doesn't > work: Short answer: see http://www.ruby-forum.com/topic/168114 Long answer: It would have been helpful to include the error message and the Windows and Ruby software versions you are using. See http://www.catb.org/esr/faqs/smart-questions.html#beprecise Trying your example on Windows 7 Ruby 1.9.3 I get Win32_Test.rb:3:in `initialize': unknown OLE server: `MSComDlg.CommonDialog' (WIN32OLERuntimeError) This suggests that component is not installed on my machine. Even if it was installed, Google suggests there would be a Microsoft component licensing issue: http://dutchgemini.wordpress.com/2010/12/23/vba-cannot-create-mscomdlg-comm= ondialog-activex/ If you insist on solving your problem by using native Windows dialogs, an alternative to an OLE component would be to access the Win32 API directly: http://www.ruby-doc.org/docs/ProgrammingRuby/html/win32.html#S3 See Win32 GetOpenFileName(): http://msdn.microsoft.com/en-us/library/ms646927%28VS.85%29.aspx http://msdn.microsoft.com/en-us/library/ms646829(v=3Dvs.85).aspx#open_file GetOpenFileName() is deprecated but is probably easier to use than the alternative. However, it will involve packing the OPENFILENAME members, as in the example I linked to at the start of my email. Feliz Navidad, Kieran --=20 Kieran Tully, Software Developer and Tenor, http://ktully.net --14dae9340ddf16bfcc04d1d7c906 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Mon, Dec 24, 2012 at 8:37 PM, Dami=E1n M. Gonz=E1lez &= lt;lists@ruby-for= um.com> wrote:
Hi guys, been researching about pop up the "open" file dialog of<= br> Windows. I didn't find nothing, just a snippet of code that doesn't=
work:

Short answer: see=A0http://www.ruby-forum.com/topic/168114=A0

Long answer:
It would have been hel= pful to include the error message and the Windows and Ruby software version= s you are using. See http://www.catb.org/esr/faqs/smart-questions.html#bepreci= se

Trying your example on Windows 7 Ruby 1.9.3 I get
=
Win32_Test.rb:3:in `initialize': unknown OLE server: `MSComDl= g.CommonDialog' (WIN32OLERuntimeError)

This suggests that component is not installed on my machine. Even if it was= installed, Google suggests there would be a Microsoft component licensing = issue:
http://dutchgemini.wordpress= .com/2010/12/23/vba-cannot-create-mscomdlg-commondialog-activex/


If you insist on solving your probl= em by using native Windows dialogs, an alternative to an OLE component woul= d be to access the Win32 API directly:
http://www.ruby-doc.org/d= ocs/ProgrammingRuby/html/win32.html#S3

See Win32 GetOpenFileName():=A0
http://msdn= .microsoft.com/en-us/library/ms646927%28VS.85%29.aspx
http://msdn.microsoft.com/en-us/library/ms646829(v=3Dvs.85).aspx#= open_file

GetOpenFileName()=A0is deprecated but is probably= easier to use than the alternative. However, it will involve packing the O= PENFILENAME members, as in the example I linked to at the start of my email= .

Feliz Navidad,
Kieran
--=A0
Kieran Tully, Software Developer and Tenor, http://ktully.net
--14dae9340ddf16bfcc04d1d7c906--