Is the way to disable path shortening in windows TaskDialogs (c#)? - c#

I've used WindowsApiCodePack C# wrapper of windows TaskDialogs.
When I tried to show long text with paths, I got all my paths shortened by ellipsis instead of true word-wrap. This makes filenames in paths non-readable. Like here:
Same behavior when settings this text in spolier text or in main text.
Is the way to disable this feature? I want my paths to be shown completely, wrapped or somehow else.
This is what I expect from text. How MessageBox work with text:

Related

Null unicode in a clipboard does not paste

I have a button in wpf that when clicked does the following:
Clipboard.SetText("a\u0000b")
When I try and paste the contents of the clipboard into notepad all i get is:
a
How can I get the entire string?
If I render this string in a wpf control, i see a[square thing]b. In other words, the view control does not terminate at a null unicode character.
I tried to find if you can copy text with NUL in Windows, and it presumably is not possible. Maybe you could temporarily replace NUL with some other character, which should never appear in any text you process (although it probably will one day, as Murphy's law states), then open the text file and convert all occurrences of this character back to NUL?
var text = "a\u0000b";
var textToCopy = text.Replace("\u0000", "\u3f45");
Clipboard.SetText(textToCopy);
// Next paste the contents to the file and reverse the replacement there
It is a workaround, but if you're the one using those text files, it might be worth a try.

How to change webBrowser DocumentText?

I know that there is lot of reports that DocumentText isn't changing but Document.Body.innerHtml is.
I'm interested only in simply solution how to change it other way than ordinary string (replacing substrings). Is there a possibility to use getElementById().innerText ?
I want to open html file, make changes in and save it.

How to show a hyperlink in a text

I have a text which may contain some special characters like <b></b> or a link. I want the user to be able to click on the link and open it. TextBlock or RichTextBox seems doesn't show links in a proper way:
<RichTextBox >
<Paragraph>
click here: http://www.google.com
</Paragraph>
</RichTextBox>
How can I show a text like that in a page?
Update: seems my question isn't clear. I ask a server for content and it returns back to me something like this:
from <b><i><a href="http://www.google.com" rel=nofollow> lorem ipsom
NPR:

 tapped in front of you probably know Bill Gates...
I want to show this in a WINDOWS PHONE page. TextBlock doesn't render it well. how can I show it human readable?
The way to solve your problem I see in using of WebBrowser control.
Then, accordingly to the article, you should go with Javascript to manage the links clicking etc (unless you want the links would be opened automatically with standard logic of Windows Phone):
Script is disabled in the WebBrowser control by default. Set the
IsScriptEnabled property to true if you want to enable scripting in
your control. You can then call scripts using the InvokeScript method.
The ScriptNotify event occurs when JavaScript in the WebBrowser
control passes a string to managed code.
That's a bit tricky way, but if you want to go any other way, you would have to implement your own parser of the code and build the sentence with labels and custom hyperlinks (as in provided above suggestions from comments).

Printing Background Colors from WPF WebBrowser

Currently, I'm printing the contents of a WPF WebBrowser like so:
mshtml.IHTMLDocument2 doc = WebBrowser.Document as mshtml.IHTMLDocument2;
doc.execCommand("Print", true, null);
My HTML content has tables with background colors. Currently, when I print the content, the background colors do not print -- everything is solid white. Is there a way to tell the WebBrowser to print the background colors as well?
Also, this still causes a print dialog to pop up. Does anyone know what the command is to print the contents dialog-less?
Thanks a lot!
Assuming you're using 'SHDocVw.WebBrowser', you can use the ExecWB command. To print without the dialog, use the OLECMDEXECOPT_PROMPTUSER (1) constant. You can also pass an IE print template (just an HTML file) for more control over how the page is displayed.
It's something like this (taken from this MSDN question)
browser.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINT,
SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER,
"print_template.html", ref nullObject);
As for the background, it appears to be one of the options you can specify in the print template's LayoutRect. All print dialog settings are stored in the registry, but a print template is preferable because it won't change system-wide settings.

Get highlighted text from active window

I would like to know how can I get highlighted text from any window for example: (excel, ie, firefox,…).
please note that the following message not work in the above application
WM_GETTEXT,WM_COPY,EM_GETSELTEXT.
I have also tried control C (copy) and get selected text from clipboard but it is not a good idea.
Language used: C#
I haven't tried it myself, but the Microsoft UI Automation API should have the functionality that you need.
The UI Automation API is what you would use if you were building a screen reader to assist blind people. So it should definitely be able to access the selected text in an arbitrary application.
A good place to start would be with the "Text Pattern Overview" at http://msdn.microsoft.com/en-us/library/ms745158.aspx
Also keep your eye on question 517694. I think you'll find that answers to that question will solve your problem.
No answers huh? Well, I know you can get it from Excel, Word etc using interop. Look into that. It might give you som ideas on how to proceed with ie and ff. But basically the recieving application must have some sort of fascility for letting you do this and I don't think there's any general way which works all the time.
There is no general purpose answer to this question. Each window class will have a different solution.
For instance, if the hilighted text is in an edit window, then you can use EM_GETSEL to get the range of the selection, then WM_GETTEXT to get the text (and then throw the unselected part a way) or EM_LINEFROMCHAR to turn that range into line indexes, and then EM_GETLINE to get the selected text one line at a time.
But this won't work for any other window class.
No need to write this in C# from scratch. What's wrong with using the clipboard? This script ensures that it restores what was on the clipboard when it has finished.
Autohotkey makes this much simpler.
; Hotkey: Ctrl Shift t
^!t::
; Remember what was in the clipboard
clipboardPrev = %clipboard%
; Clear the clipboard
clipboard:=
Sleep,200
; Send a Ctrl C to copy the current selection
SendInput, {Ctrl down}c{Ctrl up}
Sleep,200
; Get the current selection from the clipboard
selectedText=%Clipboard%
if SelectedText =
{
; If the first attempt didn't get any test, try again
Sleep,200
; Send a Ctrl C to copy the current selection
SendInput, {Ctrl down}c{Ctrl up}
; Get the current selection from the clipboard
selectedText=%Clipboard%
}
; Restore the clipboard
clipboard=%clipboardPrev%
MsgBox, %selectedText%
return

Categories