Make file open in current WPF application - wpf

I have a WPF application that I've associated with a custom file type.
The steps were:
1. Open Project Properties->Publish->Options->File Associations
2. Filled in Extension = .tr2, Description = TR2 file, ProgID = TR2File.tr2, Icon = W32.ico
3. Opened a blank text file, renamed it to test.tr2, double click it and the program starts up.
4. Created a second file, named test2.tr2, double click it and a second instance of my program starts up.
Now, I still haven't figured out how to actually open/read the files yet, but first I would really like to make it so that if the program is already running, then it just opens in the current app, and doesn't try to open a new instance of the app.

Have your program create a named pipe. When a second instance executes, before it does anything else, have it check for the existence of this named pipe. If it exists, open it and use it to send the filename being opened in the second instance, and then terminate. If it doesn't exist you don't have an existing instance, so you can open.

Related

adding actions to button, error code

I'm working on an app project on codenameone and I want to add an action so that every time a user types some text, into a text area on a screen of the app, it gets added to a box (Json). So I select the text area on the screen, I click on "events" and select "action events". Usually nothing should appear at this point, but I get a window asking to give a name and save a file.
Since I inserted the name and save to close the window, when I repeat all the process and select "Action Events" an error message is shown:
"Error opening Netbeans (...) Cannot running program (...)* : Create process error=2, Specified file not found".
*the name which follows is the one I created when the window appeared to me.
I also created the project again and I'm having the same problem here: by going to "Events" and clicking on "Action Events" I got the same error:
"Error opening Netbeans (...) Cannot running program (...)* : Create process error=2, Specified file not found".
You need to setup Netbeans, Open your theme.res by double clicking.
Choose Codename One -> Advance -> Reset Netbeans Settings. Then,
Choose file -> setup Netbeans and navigate to where your Netbeans.exe is, On my PC I did the this:
This PC -> Program Files -> Netbeans 8.1 -> bin -> netbeans.exe (or netbeans64.exe).
Your steps may be similar, depending on your computer.
Save theme.res and try again.

Installshield 2011: Take path from one window, take text from second

Good day, everyone. I have that task assigned which consists in creating simple installscript-only project, that should have 2 windows: first will prompt user to enter a path and create text file in this specified location, while second will promt for text input and save anything user writes into this text file.
Funny point is that I have small installshield experience (completed tutorials... well, yeah, that's all) and very little programming experience on top of that. As far as i understand, I should first create two custom dialog windows (for example by cloning them from standard ones), then create .rul files with functions, determining behavior for each. After which, include them into main setup.rul and call functions at specific point of time.
Question is - what exact dialog windows/functions/points of time will be best for such task? For reference i searched into "Serial Number Validation Sample Project" but, honestly, the way it customized default window is just confused me even more... So, please, can anybody help? Thank you.
For future reference, here's working solution.
Asked that same question at flexera forums, and here's what I got:
Off the top of my head (without InstallShield handy to check this) 1)
Create an InstallScript project, just accept all of the defaults in
the new project wizard unless you want to add localization or
something. 2) Your description implies that you do not need
maintenance (repair, modify, uninstall) support. If correct go to
Project\Settings and on the Maintenance tab select 'no uninstall or
maintenance'. 3) You can put your code at the top of the
OnFirstUIBefore function and then call Exit so that the rest of that
default code is never executed, since you are not installing anything.
As part of your InstallShield IDE, in the Start menu (for IS2012
Spring) is a tool that demonstrates all of the built in dialogs. You
can look through those choices and select the dialog that is best for
your situation. It sounds like you want to:
Call AskPath or SdAskDestPath (there are several other possibilities)
Then call AskText and save that string.
If you need to make layout or text changes to the default dialogs look
at your Dialogs view and select which ever dialog you selected above
and edit it. (If you decide to use skins make sure you select the skin
before you make any dialog layout changes.)
Then do something similar to the functional body of the WriteLine
example http://kb.flexerasoftware.com/doc/Helpnet/installshield14langref/LangrefWriteLine_Example.htm
The actual WriteLine example function prototype is for a MSI custom
action which is not what you want. Ignore the function protoype and
just use the code in your project to create the file at the path you
already collected and write the line of text that you collected.
Then call Exit;
(big thanks to user phill_mn for that answer)
And here's the code for setup.rul:
#include "ifx.h"
function OnFirstUIBefore()
number nvFileHandle;
string svResult;
string szTargetPath, szFeatures;
BOOL bLicenseAccepted;
begin
AskPath ("Please choose a path where text file will be saved","c:\\",szTargetPath);
MessageBox("File yourtext.txt wiil be created or overwritten at " +szTargetPath, INFORMATION);
AskText ("Please enter some text to save into that file", "Text goes here", svResult);
OpenFileMode (FILE_MODE_APPEND);
if (CreateFile (nvFileHandle, szTargetPath, "yourtext.txt") < 0) then
MessageBox ("Creating failed.", SEVERE);
abort;
else
if (WriteLine(nvFileHandle, svResult) < 0) then
MessageBox ("Writing failed.", SEVERE);
else
MessageBox ("Success.", INFORMATION);
endif;
endif;
CloseFile (nvFileHandle);
Do(EXIT);
return 0;
end;

Show help in c# showing proper topic but wrong content in CHM

Below is the code I am using to show my CHM file.
Help.ShowHelp(control, HelpFile, HelpNavigator.Topic, topic);
topic="/foo_Manual/foo-Define_Technologies_1-Chapter9/Defining_foo.htm.";
It is opening the proper html widow in the right; however, the left side's contents tab is always pointing to 1st chapter.
Try this one
Help.ShowHelp(Control, HelpFileName, HelpNavigator.TopicId, TopicID);
This depends on the way your CHM file is compiled and/or the last user action.
But you need AutoSync too (see attached picture of HTMLHelp Workshop).
Please note one that the last visited tab is saved to a hh.dat file: When a CHM file is compiled, you can define the default tab displayed when the file is opened. If a user opened one of the other tabs (e.g. the index) and closes the file, the next time the file is opened, it will be opened in the Index tab.
Following code is working for me:
Help.ShowHelp(this.btnOpenHelpShowTopic, helpProvider1.HelpNamespace, HelpNavigator.Topic, #"/Garden/flowers.htm");

How to deny creating empty log file with be.file in Pantheios?

1)be.file backend has a feature - messages added before _be_file_set_filename() are not lost and will be appended to log later.
2)_be_file_set_filename opens file immediately => if no entries was added, emty file will be created
Question: how to suppress creating empty file (create file only when first log entry appended) and save feature 1) ?
Use the flag PANTHEIOS_BE_FILE_F_DELETE_IF_EMPTY, described here.
My guess is that the file is created synchronously to avoid the less-desirable situation where a log file cannot be created while a process is running. If you really want that, maybe add the functionality and supply back to the project?
I've solved this problem by writing custom backend - wrapper over be.file

How to start the associated program when selecting more than one files?

I have set .jpg file associated to my own program. I want to add the context menu to .jpg files, so I set the entry of HKCR.jpg\shell\open\command to "myProg.exe %1". After associating, there will be an item on the top of the context menu saying "Open image with myprog". This works right when I select a single .jpg file, but when I selected more than one file and click the top item of the context menu, nothing happended. How can I solve the problem?
Thank you very much
Each selected file will be sent to a new instance of your application. Your application should check if a previous version exists, or not. If a previous instance exists, it should sent its parameters to it (e.g. using Windows Messages) and then terminate.
Another approach is to use DDE (Dynamic Data Exchange), an old method used by Shell to send all files to one instance of your program.
You might need double quotes around the "%1".
Read this article for much more detailed information about how all this works.
http://msdn.microsoft.com/en-us/library/bb776883.aspx
Also, this blog entry talks about what you need to do specifically for multi-select command execution: http://blogs.msdn.com/pix/archive/2006/06/30/652889.aspx

Resources