Page 2 of 3

Re: OnlyOne Module Crossplattform

Posted: Sat Feb 15, 2014 1:07 am
by electrochrisso
I get invalid memory access error on line 89, the window will not close - 5.21LTS(x86) - Intel Atom N550 :(

Re: OnlyOne Module Crossplattform

Posted: Sat Feb 15, 2014 9:08 am
by ts-soft
Update:
History wrote:; Version 1.1
; + IsWindow() in CloseWinCB()
; + Compiler OS Directive for PostEvent in CloseWinCB()

Re: OnlyOne Module Crossplattform

Posted: Sun Feb 16, 2014 12:18 am
by electrochrisso
Hi ts-soft,
Not sure if the update was a fix to my problem, but I still get a crash when closing the window, perhaps its peculiar to this computer, I will try the code on my other laptops when I get some time.

Re: OnlyOne Module Crossplattform

Posted: Sun Feb 16, 2014 12:27 am
by ts-soft
I can't reproduce it and i miss the Info what OS-Version is used, Compiler-Settings ...
Comes the IMA with the example or with other source?

Re: OnlyOne Module Crossplattform

Posted: Sun Feb 16, 2014 1:31 am
by ts-soft
Update:
History wrote:; Version 1.2
; - Removed the autoclean on #PB_Event_CloseWindow
; + ReleaseOne() to remove Timer and delete LockFile
; + changed Example to reflect the changes
I hope, this solve the problems by electrochrisso

Re: OnlyOne Module Crossplattform

Posted: Sun Feb 16, 2014 9:46 am
by Poshu
What if the application crash or is killed? You won't be able to restart it, right?

Re: OnlyOne Module Crossplattform

Posted: Sun Feb 16, 2014 10:02 am
by ts-soft
Poshu wrote:What if the application crash or is killed? You won't be able to restart it, right?
No problem on windows. On other OS you can restart after <5 Minutes!

Re: OnlyOne Module Crossplattform

Posted: Mon Feb 17, 2014 6:12 am
by electrochrisso
ts-soft wrote:Update:
History wrote:; Version 1.2
; - Removed the autoclean on #PB_Event_CloseWindow
; + ReleaseOne() to remove Timer and delete LockFile
; + changed Example to reflect the changes
I hope, this solve the problems by electrochrisso
Yes that update fixes the problem ts :)
Being new to modules, I am not sure what situations to use the code. :oops:

Re: OnlyOne Module Crossplattform

Posted: Mon Feb 17, 2014 7:36 am
by ts-soft
electrochrisso wrote:Being new to modules, I am not sure what situations to use the code. :oops:
Example: You have written a tabbed texteditor. You have registered the extension (Mime-Type) *.txt with your program.
With my module, you make sure your program runs only once. If the user open a textfile, you get the message with
the file to open in a new tab. No new instance of your program is started.

Re: OnlyOne Module Crossplattform

Posted: Tue Feb 18, 2014 12:35 am
by electrochrisso
ts-soft wrote:
electrochrisso wrote:Being new to modules, I am not sure what situations to use the code. :oops:
Example: You have written a tabbed texteditor. You have registered the extension (Mime-Type) *.txt with your program.
With my module, you make sure your program runs only once. If the user open a textfile, you get the message with
the file to open in a new tab. No new instance of your program is started.
Ok, now I see, this code will come in handy for certain types of applications, thanks for sharing. :)

Re: OnlyOne Module Crossplattform

Posted: Tue Feb 18, 2014 10:26 am
by Foz
An interesting take - I've always used a temporary port number instead of mutexes or files.

Code: Select all

InitNetwork()

If CreateNetworkServer(#PB_Any, 65000) = 0 ;<-- choose a port number in the range of 50000 - 65000 for an unused temporary port
  End
EndIf

MessageRequester("Yoohoo!", "I'm here!")
Of course in Windows that means you have to allow access to the network, so your code does win here as there is no "oh noes, the application is wanting to do something! It might be naughty!" of the UAC.

On the flipside, there is no file created, so if the application crashes, you can just just up and running again on the Linux and Mac systems.

I have to rethink my windows approach and use yours - cheers!

Re: OnlyOne Module Crossplattform

Posted: Sat Feb 22, 2014 6:59 pm
by Tenaja
I have found an annoyance. With Win7, the params, if files, are passed with the 8.3 shorthand...unfortunately, this means if you update the TitleBar with the filename, it is displayed in the truncated format.

Does anybody know how to expand it to the full filename?

thanks...

Re: OnlyOne Module Crossplattform

Posted: Sat Feb 22, 2014 7:04 pm
by ts-soft
You should always use #DQUOTE and not shortnames!
http://www.purebasic.fr/english/viewtop ... 24#p342324

Re: OnlyOne Module Crossplattform

Posted: Sat Feb 22, 2014 7:38 pm
by Tenaja
ts-soft wrote:You should always use #DQUOTE and not shortnames!
http://www.purebasic.fr/english/viewtop ... 24#p342324
Don't know where you suggest I use the DQ's--I wrapped the param filewrite with them, but that did not help. Then, I implemented your GetLongFromShort() and now it is working.

Thanks for the suggestion!

Re: OnlyOne Module Crossplattform

Posted: Sat Feb 22, 2014 7:50 pm
by ts-soft
On many windows-machines shortpathnames no more available. the creation is deactivated for performance reason on:
most server, most pcs using ssd, ...

Use

Code: Select all

param.s = #DQUOTE$ + "c:\Program Files\bla.txt" + #DQUOTE$
and not the shortnames.