LicenseMemo displays plain texts after changing Parent to CustomForm - inno-setup

I have created Custom Form (CreateCustomForm) and changed LicenseMemo.Parent to this Form.
Unfortunately that results quite not as expected as the LicenseFile RTF is always displayed as Plain Text - all RTF formatting is gone (Font, Font Styles, Font Sizes, etc.).
Should I set additional formatting for LicenseMemo after changing it's parent?

This happens because when you are re-parenting a control, the control's window is internally re-created and since the TRichEditViewer component doesn't store the RTF stream anyhow, nor reload it when the control is being recreated, it simply loses its RTF content and shows only plain text which stored is.
What is also bad for this case is that even the RTFText property doesn't implement reading of the RTF stream from existing control instance, so you cannot even save the RTF by yourself before re-parenting for restoring it later on.
There is a way to get the RTF stream by using EM_STREAMOUT message, but that's a quite a lot of work which might finally be untranslatable for Inno Setup Pascal Script due to lack of missing pointer support.
The only easy workaround I can think of is to reload the RTF content file after re-parenting the control. I know that you'll need to include the license file into [Files] entries and extract it manually, but it's the least painful way to go.

Related

Edit contents of RTF file with Powershell - Hyperlink/Mailto

Trying to update a mailto value of an RTF document with a powershell script, but it seems that the issue is RTF file related rather than Powershell related because can't get it to work when doing it by hand either:
I have previously made small find and replace changes to RTF files by finding that bit of text and changing it within the file, not using any kind of RTF library or cmdlet but just using plain string processing. With more recent RTF files updating the mailto: value in the raw file text does not seem to update the address a new message is created addressed to, and the previous value is used for the new message's TO value. The previous value not appearing in the file in plain text at that point and yet being known once the mailto link is clicked.
I am aware that RTF files have changed over time and not all of the content is purely ASCII and formatting control markup and I presume that the mailto: target is held somewhere that's not plaintext. I need to know where this other instance of the data is held in the file and a way to edit it.
mailto still showing the old email that no longer appears in plaintext in file
mailto value updated in file
Thanks for any thoughts or suggestions for things to try next!
Kind regards,
Oscar
I am able to update html and txt files just fine, but more recently RTF files are seemingly not showing the updated values because somehow they are storing the hyperlink target in a second place in the file that is not human readable. Updating other elements just by changing the human-readable instances of them in the file seems to work fine, just not the hyperlink 'mailto:' section now. Updating the link in word processor causes the human-readable 'mailto:' section to be updated when viewed in a text editor, but updating the value in a text editor and then opening it in the word processor does not show the update. So it seems to be storing the value in multiple places and the plain text version is not used in the event they're different, in so far as I've established.
Perhaps there is an RTF cmdlet or library that lets you edit the binary portion (or whatever alternate location it's held in) of the RTF file, or it would be easier to create the RTF version of the file from the properly updated HTML version. Open to ideas!

Add text to pdf using Excel -VBA

I don't have much knowledge about VBA.
But I have a problem which I think can be solved with VBA.
I have a PDF file of 400 pages. I have an excel with page numbers and some text. Now I want this text to be copy pasted (Add Text under drawing markup in PDF tools) in the PDF.
I can do it manually but it will take 3 to 4 days. so can anybody help me and make my work easier. I wanted to do this in Excel-VBA.
I have 2013 Excel and Acrobat xi Pro.
It depends.
If the pdf has forms in it, you are of course able to fill them in a programmatic way.
If your document does not contain forms you are not going to be able to solve this problem in a trivial manner.
Why, I hear you ask?
PDF documents, despite their reputation are more like containers of instructions than they are a WYSIWYG format
instructions are bundled in groups called "objects"
objects can be compressed (DEFLATE) into streams
objects are indexed so they can be re-used (this is called the xref)
the index uses byte-offsets to get a grip on which object is where in the document
Now what would happen if you wanted to add a single character somewhere in the document
you would need to decode the streams to figure out where you're actually placing content
Once you've found the right stream, and you've inserted your character, you have also screwed up the xref table.
Nothing will work anymore

How to notify the editor about document changes

I work on a custom project system and I have an issue with renaming items. The project system implementation is based on MPF and renaming items via the solution explorer worked more or less without any problems, but...
When an item gets renamed, I also update information which are stored in the file itself. In case the document is opened by the code editor, the text in the editor doesn´t get refreshed (only the document window´s caption changes to the new filename). If I save the open document all changes applied by the rename operation are overriden, of course.
How can I force the editor to reload the document, so that the automatic changes will be shown?
Assuming it's a text file versus some custom designer, use the IVsRunningDocumentTable interfaces to get the text buffer for the file that's currently open. The fourth iteration of the interface is the easiest one to use from managed code. You can call IsMonikerValid (where the "moniker" is the file name) to see if the file is open, and if so then call GetDocumentData to get the IVsTextBuffer for the file. That type itself is fairly annoying to work with, so if you're only supporting Visual Studio 2010 or later, then pass that to this function to get the newer editor APIs version of it.
As far as they "why" it's a good idea to do this: if you edit the file on disk and then try to force a reload, there are various problems you might run into. If the file wasn't saved before the rename, you might accidentally lose those unsaved edits. The reload might cause the undo history of the file to be lost, and any other extensions/features that were tracking points in the file with editor tracking spans or markers might lose the points they're tracking. Performance should be a bit better too if the file is a large file.

Is there any ascii inline editor I can use on my webserver?

Perhaps I'm over thinking this but I don't seem to be able to find a simple, trivial way to edit a file inline on a webpage.
I need to allow users to edit files stored on the system (linux router). One page per file is totally acceptable to me.
This page would load the content of a text file in a text area, where at the bottom a Save button saves the content of the text into the file.
That's all. No security needed, no multi user, no login what so ever.
All the inline editor I can find out there are rich-text or WYSIWYG which I don't need and they actually might mess up the file content with unwanted tags.
Can anybody please point me in the right direction on how to implement such an editor? No ajax or funky things needed really, just a text area and a save button.

I want to change the way text is represented internally in ANY Text Editor

I want to use a algorithm to reduce memory used to save the particular text file.I don't really know how text is stored but i have an idea in mind.
Would it be better to extend a open source text editor (if yes than which one) or write a text editor myself.
It would be nice if someone could also give me a link or tutorial to some basics on how text editors work and the way data is stored.
Edited to add
To clarify, what I wanted to do is instead of saving duplicates of a word make a hash table and store the address where it needs to be placed.
That way I wouldn't be storing the duplicates.
This would have become specific to a particular text editor.
Update
thanks everyone I got what all of you'll are trying to say. Anyways all i wanted to do is instead of saving duplicates of a word make a hash table and store the address where it needs to be placed.
This was i wouldn't be storing the duplicates.
Yes and this would have become specific to a particular text editor. never realized that.
I want to use a algorithm to reduce memory used to save the particular text file
If you did this you would no longer have a text editor, but instead you would have created some sort of binary file editor.
The whole point of the text file format is that it is universal, meaning any text file can be open in any other text editor.
Emacs handles compression transparently. Just create a text file with .gz extension. Emacs will automatically compress contents of the file during save operation, and decompress when you open the file next time.
Text is basically stored as-is. i.e., every character takes up a byte or two (wide chars), and there is no conversion done on it when it's saved. It might add an end-of-file character or something though. Don't try coming up with your own algorithm to compress these files. That's why zip-files and other archives were created. They're really good at compressing text. If you wanted to add these feature to your text-editor, you'd have to add some sort of post-save hook to zip it, and then put a hook on the open command to unzip it. Unless you wanted to do it by hand every time. Don't try writing the text editor yourself from scratch, unless (maybe) you're writing notepad. Text editors with syntax highlighting aren't very easy to make, even with the proper libraries. I'd say write a plugin for something like Visual Studio or what have you. Or find an open-source text editor.

Resources