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:
require "win32ole"
cd = WIN32OLE.new("MSComDlg.CommonDialog")
cd.filter = "All Files(*.*)|*.*" +"|Ruby Files(*.rb)|*.rb"
cd.filterIndex = 2
cd.maxFileSize = 128 # Set MaxFileSize
cd.showOpen()
file = cd.fileName # Retrieve file, path
if not file or file==""
puts "No filename entered."
else
puts "The user selected: #{file}\n"
end
Do you have the way to do that? Thank you.
on 2012-12-24 21:37
on 2012-12-25 07:51
On Tue, Dec 25, 2012 at 4:37 AM, Damián M. González <lists@ruby-forum.com>wrote: > Do you have the way to do that? Thank you. i cannot answer the win32ole part, but, .. regarding gui dialogs, you may want to try tk. simpler and works on almost all platform.. eg to select a .rb file, and then print its content, >require 'tk' >puts File.read Tk::getOpenFile( 'filetypes'=>[['Currently', '*.rb']] ) tested to run in windows/linux/aix unix kind regards -botp
on 2012-12-25 12:57
That's cool botp but I'm trying to not use any external gem rather than FXRuby gem, if I include Tk plus all the gems that I'm using for my project(roo, win32ole, etc..) the final pack will be big and I don't think that the fusion between both frameworks will be nice for the user, I mean FXRuby widgets are pretty differents that the Tk ones. The problem with the dialog in FXRuby is that its in English, I'm developing an Spanish language app, so I can not pop up a dialog in English expecting that the user will understand what said there. The solution for me will be if I can pop up the "open" file dialog of Windows(I'm developing just for windows). Of course I can create my own widget for file opening but you know, everything takes time, and now I'm running low, need the help you all can give me, thanks.
on 2012-12-25 19:55
Is this what you're looking for? http://www.fxruby.org/doc/api/classes/Fox/FXFileDialog.html
on 2012-12-26 01:07
It is completely in english, as I said, the app is in spanish language. Was wondering if I can save time using the windows open file dialog instead of develop a new widget like the one you showed, I'm trying to make a professional app so I don't want for example that the button 'cancel' say 'cancel' in it, it must be 'cancelar', spanish...
on 2012-12-26 14:37
Damián M. González wrote in post #1090200: > It is completely in english, as I said, the app is in spanish language. > Was wondering if I can save time using the windows open file dialog > instead of develop a new widget like the one you showed, I'm trying to > make a professional app so I don't want for example that the button > 'cancel' say 'cancel' in it, it must be 'cancelar', spanish... Doesn't the windows dialog correspond to the language currently in use in the operating system?
on 2012-12-26 15:54
> Doesn't the windows dialog correspond to the language currently in use > in the operating system? If you mean the #FXFileDialog from FXRuby then NO. I've tested it. It's always in English. If you mean the "Windows OS open dialog"(I mean the one which say "Open" as caption in English version and "Abrir" in Spanish version) then it depends of the language currently in use in the operating system, and that's what I want... because in this case the app is explicit for a user which is working in a PC with spanish language.
on 2012-12-27 10:22
I'd suggest looking into how that dialog is created and whether it's possible to change the source to something more suitable for your project. Have you tried asking the "Spanish Rails Group" on here? Someone there might have already solved this problem.
on 2012-12-27 13:22
Joel Pearson wrote in post #1090328: > I'd suggest looking into how that dialog is created and whether it's > possible to change the source to something more suitable for your > project. Well, FXRuby is basically a wraper to the C++ Fox framework, so the pre-mades widgets are in some way hidden in C++ code, as I can't interpret C++ code I can't do nothing. What I can do is combine a group of widgets until that groups becomes a sort of "file open dialog", but I'm trynig to avoid that because it takes time, and am low of it. > Have you tried asking the "Spanish Rails Group" on here? Someone there > might have already solved this problem. That's a good recomendation! I think is even better ask in the Ruby on Rails group since this is a global question, not explicit to some language. Thank you Joel. So if still anyone can help. I'll be thankfull. :)
on 2012-12-27 17:16
On Mon, Dec 24, 2012 at 8:37 PM, Damin M. Gonzlez <lists@ruby-forum.com>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-ca... 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/... See Win32 GetOpenFileName(): http://msdn.microsoft.com/en-us/library/ms646927%2... http://msdn.microsoft.com/en-us/library/ms646829(v... 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
on 2012-12-27 18:17
> 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) Same OS and Ruby version. > 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-ca... Same thing happen to me, I've been in that page. I've tried the solution but doesn't work for me, seems that the component is not installed on my machine. > 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/... > > See Win32 GetOpenFileName(): > http://msdn.microsoft.com/en-us/library/ms646927%2... > http://msdn.microsoft.com/en-us/library/ms646829(v... > > 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. Well, this solution can be a mess, since I've scaped every time that I looked to the Win32API, it hurst me. Seems that finally I have to appeal to construct the entire widget with FXRuby. > Feliz Navidad, > Kieran Thank you for taking the time to response. Feliz navidad y año nuevo! :) Damián.
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.