Issues with SVG files, and opening from File Explorer

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

IanOfYork
Posts: 118
Joined: Sat Nov 04, 2017 11:54 am
Location: York, England

Re: Issues with SVG files, and opening from File Explorer

Post by IanOfYork »

My notes claim I was using TextPad back in 1997 and maybe before then.
Frustrating when an old, reliable tool misbehaves for no apparent reason, isn't it.
I blame Windows 11, myself. I dread having to "upgrade" from Windows 10.

Also, putting all sorts of "magic" in the registry was one of the worst decisions that Microsoft ever made.
You can't beat a nice low-tech, human-readable .INI file.
User avatar
bbadmin
Site Admin
Posts: 882
Joined: Mon Feb 17, 2003 8:54 pm
Contact:

Re: Issues with SVG files, and opening from File Explorer

Post by bbadmin »

These are the relevant entries that TextPad's installer writes to the registry to enable File Explorer to request that it opens a file which has been double clicked:

Code: Select all

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\TextPad.exe
	C:\Program Files\TextPad\TextPad.exe

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Applications\TextPad.exe\shell\open\command
	"C:\Program Files\TextPad\TextPad.exe" -s

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Applications\TextPad.exe\shell\open\ddeexec\application
	TextPad.9

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Applications\TextPad.exe\shell\open\ddeexec\topic
	system

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Applications\TextPad.exe\shell\open\MultiSelectModel
	player
If you installed TextPad for the current user, rather than all users, the path to "Applications" will start with HKEY_CURRENT_USER.

Essentially, File Explorer looks up the associated application in the registry, then checks how that application should be started and informed of the file to open by looking for the it under the key "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Applications". If it has a "shell\open\ddeexec" subkey, it proceeds by sending it DDE messages. For "TextPad.exe", first, it broadcasts a message containing "system" and "TextPad.9" to all running applications that have registered to receive such messages. If it gets no response, after a timeout, it executes the command under "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Applications\TextPad.exe\shell\open\command" and gives it time to start. Then it sends a message with the command "open" and the name of the file as a parameter for each file to open. As file names are sent one at a time, there is no issue with spaces in their names.

I wondered if the timeouts were too short, so I tested it on an old PC which runs Windows 10 painfully slowly, but it worked as expected.

Please will you run regedit.exe and check that those entries are correct.
User avatar
AmigoJack
Posts: 536
Joined: Sun Oct 30, 2016 4:28 pm
Location: グリーン ヒル ゾーン
Contact:

Re: Issues with SVG files, and opening from File Explorer

Post by AmigoJack »

While this may work best when f.e. I select multiple files in the Explorer to then shell select "Open" or "Open with..." for decades the way to make your program single instance only was:
  1. to simply create a Mutex at the start and
  2. then check if it already existed:
    1. in that case just make inter-process communication to inform your other instance which additional file(s) should be opened (f.e. by using a custom message which the recently started program sends to the already running one)
    2. and then just exit running.
Maybe this is more bullet proof on Windows 11? It is totally unbound to DDE and Registry entries (setting those can fail due to missing permissions), while sending messages should always be possible. But I understand that this approach is not so nice when trying to open 40 files at once, effectively starting the program 40 times, too.
User avatar
bbadmin
Site Admin
Posts: 882
Joined: Mon Feb 17, 2003 8:54 pm
Contact:

Re: Issues with SVG files, and opening from File Explorer

Post by bbadmin »

That is how TextPad handles multiple instances, and you can get File Explorer to start a new instance of TextPad for each file by deleting the ddeexec stuff in the registry and changing the open command to pass in the filename using "%1" as a parameter, like Notepad does.
User avatar
AmigoJack
Posts: 536
Joined: Sun Oct 30, 2016 4:28 pm
Location: グリーン ヒル ゾーン
Contact:

Re: Issues with SVG files, and opening from File Explorer

Post by AmigoJack »

No, Notepad doesn't use Mutexes and/or doesn't forward file opening requests to the already running instance to then close its second instance right away. Did Windows 11 really change this?
User avatar
bbadmin
Site Admin
Posts: 882
Joined: Mon Feb 17, 2003 8:54 pm
Contact:

Re: Issues with SVG files, and opening from File Explorer

Post by bbadmin »

Notepad on Windows 10 doesn't need to use a mutex, as it always opens each file in a separate instance. (Not sure about the Notepad app on Windows 11 which can open multiple files on separate tabs.) Sorry if my explanation of the way TextPad can be made to behave like Notepad, rather than use DDE messages, confused you.
User avatar
AmigoJack
Posts: 536
Joined: Sun Oct 30, 2016 4:28 pm
Location: グリーン ヒル ゾーン
Contact:

Re: Issues with SVG files, and opening from File Explorer

Post by AmigoJack »

Oh, you confirmed that TextPad does use/used a mutex already. I interpreted your post as being exclusive, like "the DDE is like a mutex", instead of being an addition that already exists in the background in case DDE fails to work as expected. I now understood it this way (and am glad it's already implemented):
bbadmin wrote: Sun Jun 23, 2024 8:15 amThat is how TextPad handles multiple instances ...[already when]... deleting the ddeexec stuff in the registry and changing the open command to pass in the filename using "%1" as a parameter, like Notepad does.
(Only the blue part covers the Notepad example - Notepad isn't meant as example for everything. The red words would have made it more unambiguous to me.)
MrSpock
Posts: 14
Joined: Thu Mar 02, 2023 6:25 pm

Re: Issues with SVG files, and opening from File Explorer

Post by MrSpock »

@bbadmin: I have installed Textpad for all users and the registry entries are identical.
An attempt with %1 showed slight success. Opening without a file no longer happened so often.
User avatar
bbadmin
Site Admin
Posts: 882
Joined: Mon Feb 17, 2003 8:54 pm
Contact:

Re: Issues with SVG files, and opening from File Explorer

Post by bbadmin »

@MrSpock: to allow for spaces in file pathnames, put the %1 in the registry in quotes.

Assuming that was not an issue, if TextPad is started with the name of a file in its parameters, it will either open it, or ask if you want to create it. Try it for yourself by running these commands in a command prompt window:

Code: Select all

"C:\Program Files\TextPad\TextPad.exe" junk
"C:\Program Files\TextPad\TextPad.exe" "C:\Program Files\TextPad\Readme\Readme.txt"
If you repeat the second command, does it consistently start and open the file?

You can use procmon to check that TextPad receives such a parameter when invoked by File Manager. After downloading and installing it, run procmon64.exe and add a process name filter that includes textpad.exe and excludes the registry and file system event classes. Click OK and right click the first instance of textpad.exe in the list and select Properties. That will show the command line TextPad was started with.
MrSpock
Posts: 14
Joined: Thu Mar 02, 2023 6:25 pm

Re: Issues with SVG files, and opening from File Explorer

Post by MrSpock »

OK, with %1 in quotation marks it seems to work. No longer had an empty view when opening a file several times.
I would consider this part of my post done.
There is still the problem with the SVG files.
User avatar
bbadmin
Site Admin
Posts: 882
Joined: Mon Feb 17, 2003 8:54 pm
Contact:

Re: Issues with SVG files, and opening from File Explorer

Post by bbadmin »

@MrSpock: thanks for confirming.

Please note that the installer will reset those registry entries after any updates. You might want to use regedit to export that section to make it easy to reinstate later.

It's not possible to mix bitmaps with vector graphics, so I can't help with your SVG issue. TextPad 8 still uses bitmaps in its toolbars, but it cannot read any workspace files created with version 9.

It is possible to get a list of the files open in a workspace using the Edit/Copy Other/All File Names command. That can be pasted into a document and saved as a file which can be used as an @-file to open them all in another version of TextPad.
MrSpock
Posts: 14
Joined: Thu Mar 02, 2023 6:25 pm

Re: Issues with SVG files, and opening from File Explorer

Post by MrSpock »

I have now succeeded in converting PNG files into SVG. On the website https://www.freeconvert.com you can convert 20 icons every day for free. However, they should have about 250 pixels so that the quality is appealing.
Post Reply