Is there a way I can edit or rewrite default Matlab Apps? - image

Is there a way I can edit or rewrite default Matlab Apps such as "Image Viewer?"
Matlab R2016b

The Image Viewer App is called from the command line as imtool. You can open this file in the Editor using edit like so:
edit imtool
or you can find its location with which and open it in whatever other editor you like:
>> which imtool
C:\Program Files\MATLAB\R2016b\toolbox\images\imuitools\imtool.m
If you really want to modify it, I suggest making a copy of your own and renaming it, leaving the built-in one unchanged and still available.
For other apps, if you go to the "APPS" tab and pull down the menu it will list all the built-in ones available:
Notice that hovering over an app will give a brief description with an associated function name in parentheses. For example, the Video Viewer App can be called with the function implay.

Related

API or other method for accessing Finder icon preview images

It appears that macOS now generates preview images for certain files (notably RAW image files) that are not custom icons but something else. (You can toggle them on/off in latish model macOS via "show icon preview" in Finder window "Show View Options".)
I'd love to be able to either obtain these images or use the API that generates them but I'm obviously googling the wrong terms. The usual APIs will get me the file icon (which is usually a generic document icon) and not the preview. The tricks for getting custom icons (e.g. .DS_Store etc.) do not apply.
The tool you want is qlmanage. In particular, look at qlmanage -t (thumbnail) and qlmanage -p (preview). By default, it opens a viewer for you. If you want to generate files to process yourself, see the -o option. For example:
qlmanage -t image.png -o .
This will create a thumbnail file called ./image.png.png (it attaches .png to whatever the filename is).
If you want to build your own tools around this, see the QuickLook framework.
A little more info w.r.t. using QuickLook framework. The key method is QLThumbnailImageCreate (QuickLook previews are PDFs which are not what I want and likely not what someone doing something similar wants).
Even though the function name indicates that it creates thumbnails, it can create an image of any size (and the size parameter dictates a maximum dimension).

source file links in xcode console output

A lot of dev environments have some basic parsing logic applied to the output of programs while debugging such that if a program writes to the console (as a result of an error, assert) something like:
/Users/Foo/Project/SomeFile.m:12 - SOMETHING BAD HAPPENED HERE
the file path & line name are automatically detected as link to source, and one can click or double click on the text in question inside the console window to make the source editor jump here.
I have been trying to find out if XCode has something similar, but I haven't had much luck. Is any such functionality missing in XCode or am I just not finding the preferred text shape that it prefers?
Thanks
I just remembered "Open Quickly…". If you copy the text of the file name, then use the "Open Quickly…" function (Cmd-Shift-O by default), you can paste the filename in and press enter, and it will display the file.

How do I display a file or directory browser dialog using MATLAB

I have created a blank GUI and now I want to program a push button to display a file or directory browser dialog.
Your question could use a little more detail, but here's a general suggestion to get you started...
You could set the callback for your push button so that it invokes one of the built-in dialog boxes available in MATLAB. You may be most interested in UIGETDIR or UIGETFILE to browse for and select a directory or file, respectively.
In addition to gnovice's advice, if you want your directory browser to be embedded within your GUI (as opposed to opening in a separate dialog window), you can use Java component. Take a look at my UICOMPONENT utility on the File Exchange for a working example.
Alternately, you can design your own tree-view of folder contents within a matlab panel, using the documented yet unsupported UITREE function or a Java JTree component (take a look at my UIINSPECT or FINDJOBJ utilities for working examples).

How does Windows associate icons to files in explorer shell?

I have both InDesign CS2 and CS3 installed. Both use files with .indd extension. How does Windows know which icon to use? It uses correct icons i.e. CS2 files have cs2 icon and CS3 files have CS3 icon.
How does Windows know how to do this?
And how can I extract or use this version-detection system in my programs?
Edit:
Thank you for your shell-extension-icon-handler answers. Something new to me. But is there any way I could connect to IconHandler that InDesign provides and use it to detect version of the InDesign file?
You need to write an Icon Handler shell extension. See the MSDN documentation for IExtractIcon. The basic mechanism is that you create a shell extension and register the icon handler for the file type you want (look in HKEY_CLASSES_ROOT/.indd) and then the shell loads your handler, passes the file information and requests an icon in return. There's also the IExtractImage method if you want to provide a thumbnail bitmap rather than just an icon.
Note that you need to be especially careful writing shell extension handlers as any memory leaks or crashes can nuke the explorer and any other applications that display a file open/save dialog.
For some files it's HKEY_CLASSES_ROOT\<file extension here>\DefaultIcon registry entry, but most files map to a more friendly name, e.g. .pdf\(Default) -> AcroExch.Document (if Adobe Reader is installed).
In that case you have to go along the registry to AcroExch.Document and see that either
DefaultIcon is right there or
AcroExch.Document\CLSID\(Default) is some GUID. Then, follow HKEY_CLASSES_ROOT\CLSID\<insert that guid here> and you'll notice that this key contains DefaultIcon
... and DefaultIcon is where the icon is loaded from.
Hope that was clear enough ;). I don't know about your special case but there should be a distinction in the registry.
It almost certainly installs a shell icon extension handler. Writing your own and knowing how to detect the version in a file format that isn't documented well or at all is quite tricky.

Is it possible to replace the system open file dialog?

I want to replace the standard system open file dialog with the one I wrote, that means no matter within which programs you are opening a file, my dialog will be shown instead of the standard one, is this possible?
It seems that that there is no such API provided to accomplish this, is it possible to use some hooking technique, but this has to be reliable and not to be treated as spyware by anti-virus tools?
any other options?
If this is not possible, is it possible to add to the spacebar or toolbar in the standard open file dialog a button which invokes my dialog, which allow users select a file and in turn returns the path of the selected file to the "File name" input box of the standard dialog?
Any hits, links and code examples will be appreciated.
Starting in Vista, the FileOpen/FileSave dialogs are now "Common Item Dialogs" of which IFileOpenDialog & IFileSaveDialog are the two published implementations.
Since they're just COM objects with known CLSIDs you might get away with just replacing them by re-registering using their CLSIDs. Never tried something like that, might trip all sorts of alarm bells.
Pre-Vista file dialogs can be hooked in process, but I've never come across anything about global hooks or equivalent.
If you copy a file/folder to a dialog's filename field it usually pastes the full path anyway.
For example, if you have open both a program calling the standard open/save dialog box and also have a window open at the file or path that you want to work with (open from/save to), you can simply copy the file/folder from the explorer window, and then paste into the filename field of the dialog box, and it will insert the full path of the file/folder. No custom script is required!
Alternatively, for those programs that use custom dialog boxes where this step fails, copy the same file/folder in the window into the address bar of the same window (assuming it is visible). This will paste the full path, which you can copy again, and then paste this full path into the custom dialog box. I often use this when creating Office hyperlinks (Ctrl+K), because the Insert Hyperlink dialog does not work for the first method.
You can also use similar methods but paste into address bar fields and it works.

Resources