Let me know when you''ve got the cvs repo labeled -- I''m already to go to build the 0.4.0 installer for Windows. Curt
Curt Hibbs wrote:> Let me know when you''ve got the cvs repo labeled -- I''m already to go to > build the 0.4.0 installer for Windows.Ok. I updated the README files, and tagged the tree. Please build and release at your convenience. Let me know if I need to do anything, or can do anything to help. Thanks, Kevin
Kevin Smith wrote:> > Curt Hibbs wrote: > > Let me know when you''ve got the cvs repo labeled -- I''m already to go to > > build the 0.4.0 installer for Windows. > > Ok. I updated the README files, and tagged the tree. Please build and > release at your convenience. Let me know if I need to do anything, or > can do anything to help.Perfect... Now I can work on it over the weekend. Curt
Hello wxRuby gurus, 1. Is there any way to check from within a wxRuby application if a previous instance of that app is already running. I will be happy with a Windows specific solution too. 2. What is the easiest way to create a Login Dialog: one which accepts a login id and a password? Something like a TextEntryDialog ? Thanks, -- shanko
Shashank Date wrote:> 1. Is there any way to check from within a wxRuby application if a previous > instance of that app is already running. I will be happy with a Windows > specific solution too.My first thought was to use Window::find_window_by_name, which is a trick I used to use back in C with MS Windows 3.1. This doesn''t work in wxRuby because 1) it will segfault [I entered a bug for this], and 2) it only seems to search for windows created by this instance of the app, rather than system-wide. At least on Linux. So the best way is probably to use ruby''s own File#flock. Choose an arbitrary file for your application to lock while it is running. When another instance tries to lock the same file, it will fail.> 2. What is the easiest way to create a Login Dialog: one which accepts a > login id and a password? Something like a TextEntryDialog ?I am not aware of any pre-built dialog like this. But it''s not too hard to create your own. TextCtrl supports a TE_PASSWORD flag. So I would create a Dialog, and use a FlexGridSizer. The first row would have: StaticText "username", TextCtrl. The second row would be: StaticText "password", TextCtrl with TE_PASSWORD flag. Note that wxRuby (and possibly even wxWindows itself) will most likely leave a copy of the password in memory somewhere. someone might be able to find it by searching RAM, or it might get swapped to disk, where an attacker could find it. So I don''t recommend this for super-secure applications. Kevin
You should write a hidden file in your application''s directory with the corresponding PID. Depending on what you want to do if there is an application started you could make the proper dll function call to display the previous instance centered and with focus on the screen. Zach -----Original Message----- From: wxruby-users-bounces@rubyforge.org [mailto:wxruby-users-bounces@rubyforge.org]On Behalf Of Shashank Date Sent: Monday, June 07, 2004 11:51 PM To: General discussion of wxRuby Subject: [Wxruby-users] Application Prev Instance Hello wxRuby gurus, 1. Is there any way to check from within a wxRuby application if a previous instance of that app is already running. I will be happy with a Windows specific solution too. 2. What is the easiest way to create a Login Dialog: one which accepts a login id and a password? Something like a TextEntryDialog ? Thanks, -- shanko _______________________________________________ wxruby-users mailing list wxruby-users@rubyforge.org http://rubyforge.org/mailman/listinfo/wxruby-users --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.692 / Virus Database: 453 - Release Date: 5/28/2004 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.692 / Virus Database: 453 - Release Date: 5/28/2004
Hi Kevin,> Shashank Date wrote: > > 1. Is there any way to check from within a wxRuby application if aprevious> > instance of that app is already running. I will be happy with a Windows > > specific solution too. > > My first thought was to use Window::find_window_by_name, which is a > trick I used to use back in C with MS Windows 3.1. This doesn''t work in > wxRuby because 1) it will segfault [I entered a bug for this], and 2) it > only seems to search for windows created by this instance of the app, > rather than system-wide. At least on Linux.Yes, I see the same behaviour on Win XP.> So the best way is probably to use ruby''s own File#flock. Choose an > arbitrary file for your application to lock while it is running. When > another instance tries to lock the same file, it will fail.On Windows, it does not fail. It just waits for the lock to be released and then starts off. Here is the code I have: #----------------------------------- begin # Make sure that only instance of the application # is running at a time f = File.new("myapp.lck","w") f.flock(File::LOCK_EX) app = MyApp.new app.main_loop() rescue Exception => errmsg msg_box(errmsg, "Error") ensure f.flock(File::LOCK_UN) end #-----------------------------------> > 2. What is the easiest way to create a Login Dialog: one which accepts a > > login id and a password? Something like a TextEntryDialog ? > > I am not aware of any pre-built dialog like this. But it''s not too hard > to create your own. TextCtrl supports a TE_PASSWORD flag. So I would > create a Dialog, and use a FlexGridSizer. > > The first row would have: StaticText "username", TextCtrl. > The second row would be: StaticText "password", TextCtrl with > TE_PASSWORD flag. > > Note that wxRuby (and possibly even wxWindows itself) will most likely > leave a copy of the password in memory somewhere. someone might be able > to find it by searching RAM, or it might get swapped to disk, where an > attacker could find it. So I don''t recommend this for super-secure > applications.I will do that. Thanks for the hint about security. -- shanko
Shashank Date wrote:> On Windows, it does not fail. It just waits for the lock to be released and > then starts off. Here is the code I have: > #----------------------------------- > begin > > # Make sure that only instance of the application > # is running at a time > f = File.new("myapp.lck","w") > f.flock(File::LOCK_EX)Hmm. I hadn''t looked closely at ruby''s flock. I assumed there would be a timeout option. I wonder if there''s a way to enclose the locking inside a thread that could timeout, or be killed after a certain amount of time. There might be Windows-specfic ruby libraries that give you access to MS Windows system-wide mutexes. That would work. Another trick I used to use with Windows was to broadcast a WM_xxx to all top-level windows, that only my app would respond to. Another good approach is to open a socket for listening when the app starts up. Only one process can be listening on each socket at a time. Kevin