PasswordChar in Delphi XE8's TMemo - delphi

I spent a few hours searching Google to see if anyone had shared their articles, but came up empty-handed.
If it's possible, I want to know how to enable/disable the PasswordChar in Delphi XE8's TMemo to hide user input like in TEdit. ? Maybe via a checkbox!
So when the checkbox is checked then all text turned to asterisks, and if the checkbox is unchecked, all text back to normal..

The VCL memo control is a loose wrapper around the Win32 multiline edit. The password character functionality of the edit control is only available for single line edits.
The behaviour is controlled by the ES_PASSWORD style for which the documentation says:
Displays an asterisk (*) for each character typed into the edit control. This style is valid only for single-line edit controls.
The FMX memo control offers no password character functionality for the multiline memo control.
Presumably these frameworks don't offer what you want because passwords are entered in single line edit controls. Developers tend not to provide functionality that has no clear case for being used.
Your options:
Use a single line TEdit.
Write your own multiline memo that supports your desired functionality.
Find a third party multiline memo that supports your desired functionality.
Now, since your question is so general I have assumed that you want full support for single line password character. That is, the user enters text and it appears masked.
But maybe you actually don't need editability. In that case it is simple enough. Do the following:
Load or add the true text into a separate TStringList.
When you want to display the true text assign the string list to the memo.
When you want to hide the content, process the true text into whatever you want to display, and display that.
Make the memo control read only.

if cBoxPassword.checked=false then
edtpassword.PasswordChar:='*';
if cBoxPassword.checked=true then
edtPassword.PasswordChar:=#0;

Related

How to preselect capslock in TouchKeyboard component

I am working with Delphi TTouchKeyboard component. Because in later use people will mainly use capital letters, I would like to preselect capslock.
My problem now is, that the Touchkeyboard only changes its key caption when I click directly on a key. If the state is toggled by an (external) keydown message, one can use capital letters, but the keyboard component will still dislpay small letters on the keys. How could I solve that?
As far as I can see the only work arround is to edit the original source code.
http://qc.embarcadero.com/wc/qcmain.aspx?d=88770 (I haven't tested it)
I've tried to write a patch with this code but with out any luck because I can not acces the private field Fbuttons.
So if you want this you'll have to patch the original code

Avoid checkbox captions from wrapping in Windows Vista dialogs

For a software project I need to align two additional personalized checkboxes in a microsoft windows vista dialog. I learned about adding checkboxes using Visual-Components and Visualgroups on a CustomizeInterface in delphi.
My Question: What do I need to do with those checkboxes' captions in order to avoid them from wrapping?
1st solution (showing the checkboxes one next to each other):
Dialog.QueryInterface(IFileDialogCustomize, lCustomizeInterface);
if getCheckBox1Caption <> '' then
lCustomizeInterface.AddCheckButton(DWORD(CheckBox1ID), pWideChar(getCheckBox1Caption), Checked1);
if getCheckBox2Caption <> '' then
lCustomizeInterface.AddCheckButton(DWORD(CheckBox2ID), pWideChar(getCheckBox2Caption), Checked2);
2nd solution (showing the checkboxes one below the other):
Dialog.QueryInterface(IFileDialogCustomize, lCustomizeInterface);
lCustomizeInterface.StartVisualGroup(DWORD(1005), pWideChar('Test'));
if getCheckBox1Caption <> '' then
lCustomizeInterface.AddCheckButton(DWORD(CheckBox1ID), pWideChar(getCheckBox1Caption), Checked1);
if getCheckBox2Caption <> '' then
lCustomizeInterface.AddCheckButton(DWORD(CheckBox2ID), pWideChar(getCheckBox2Caption), Checked2);
lCustomizeInterface.EndVisualGroup;
You cannot avoid them wrapping. The IFileDialogCustomize interface offers no functionality to control layout. The control does all of that.
The best you can do is to use a shorter caption if you wish to avoid wrapping onto multiple lines. Or add some extra spaces to avoid the rather nasty mid-word breaks. For instance if you use this text 'Generate expandable / collapsible Excel export' then the outcome is:

Add alternative text to a phrase in a document file

I use LibreOffice Writer and I want to insert an alternative text to a specific phrase in the document, how can I do it?
Example if we have an image in the document we can make double left click and add the alternative text like this:
Is it possible to make the same if we select a whole phrase of text? If yes how? And if No is there any other proposal?
The alternative text in 'word'/odt documents is actually intended as the 'alt' attribute in HTML (web) pages:
The alt attribute provides alternative information for an image if a
user for some reason cannot view it (because of slow connection, an
error in the src attribute, or if the user uses a screen reader).
(http://www.w3schools.com/tags/att_img_alt.asp)
It's only purpuse is thus to provide the user with information in case he/she can not view the image. Since having alternative text in case some text cannot be displayed is, well, silly, this 'alt' attribute is not defined for pieces of text. Alternatively, you could have a hyperlink pointing to nothing ("#"), which does provide a tooltip attribute.
What is it that you're intending to achieve anyway? It's not going to show up on any prints, which is the intended purpose of Writer... Footnotes (for prints) or Comments (for communication with co-editors) might suit you better.

How can I add text to a work item

We have a few bugs and change requests which have a complicated iteration path. This results in people coming over the team to ask 'Where do we raise items' a lot.
As you can't set a default value for the iteration path in TFS 2010 we think the best solution would be to add a string of text under the field which we can manually update every 7 weeks with the correct area to raise items in.
However TFS doesn't seem to allow just a line of text on its work items as a control. Is there a way to add a line of display text i.e. Not a field you edit, but just to inform those writing the items?
Please note that it needs to be visible at all times, using the tooltip 'help text' field on a control is not enough in this case.
You can use the LabelControl for this purpose.
You can not have a default in the work item for the iteration path, but what you can do is making use or the template url in web access or the work item templates in the power tools to create a work item that is prepopulated with values.
What about a custom field with a display control in read-only? You can give a default value to the field and the "read-only" control prevent other to change it.

RichEdit not respecting PlainText with pasted content

I create a new application, drop on a TRichedit and set the PlainText property to true. I then run the application and paste some rich formatted text into the RichEdit.
I would expect it to display as plain text however it shows the content with the formatting.
Anyone know how to use a TRichedit just as plain text (and not using a memo :))
You'll need to do the paste manually ensuring that the formatting is ignored.
if Clipboard.HasFormat(CF_TEXT) then
RichEdit.SelText := Clipboard.AsText;
Run this code from a message handler for WM_PASTE.
I currently do not know how to intercept the CTRL+V keypress and replace it with this code. The WM_PASTE message is not sent to rich edit controls.
As Cody suggests in the comment, one solution is as follows:
Make sure that all the text in the edit control is marked as protected.
Subclass TRichEdit and override CNNotify.
Handle the EN_PROTECTED message, and if msg=WM_PASTE then use the paste as text code above and return 1 from the message handler to indicate that the requested operation (a rich paste) is rejected.

Resources