Set CefSharp to single-process mode programmatically - c#

CefSharp allows to be started in single-process mode when passing the command line argument --single-process. Is there a way to enable this from the application itself (programmatically, on startup, by default)?
I don't see it anywhere in CefSharp's code. The flag might be captured somewhere lower-level.

Single Process mode is not supported in CefSharp (It's not supported in CEF either) so we don't expose a way to programmatically set the relevant property.
http://magpcss.org/ceforum/apidocs3/projects/%28default%29/_cef_settings_t.html#single_process
There are many scenarios where things just crash. See http://magpcss.org/ceforum/viewtopic.php?f=14&t=13259&p=28501#p28501 for one such example.
Basically use at your own risk.

Related

Is there a way to set the compatibility mode in Win7 programmatically in C#

I am working on a program. In testing it on Win7(32-bit, don't know if it will be the same in 64-bit) I found a problem.
Now my problem is that some of the functionality does not work(like the right click doesn't show options or the program takes long to react). If however I set up a the compatibility mode it works fine. I mainly see this problem in Microstation, but it does appear in other places as well.
My question is as follows, is there a way to set these settings(like the check boxes) programmatically from C# ?
This might be necessary in cases where we do not do the installation of the program, to insure that it works on every pc it is installed on. Let us assume that during the installation the program has admin rights. (would it be needed to do this??)
this has nothing to do with Internet Explorer. i wanted to add a picture, but i dont have enough rep yet
There is no way to change this while the application is running, you have two choices to handle this issue:
Modify the installer to create shortcuts that have the compatibility mode flag set to whatever you need
You can manually manipulate the registry to force an executable to use compatibility mode, your application will require admin rights todo so + will need to restart afterwards
Here it's explained how todo it manually, you simply have to do it programatically:
http://kb.winzip.com/kb/entry/139/
In general I discourage you from doing either, fix your bugs instead.

Programmatically (first-time!) enable aero theme/desktop composition

I want to enable desktop composition on a Windows 7 machine programmatically (preferrable C#) and already tried to do it with the infamous DwmEnableComposition P/Invoke. However, this does not seem to work if DWM has never been enabled (and the performance test has not run). I can, however, enable DWM via the "Personalization" control panel w/o running the performance test.
My question therefore is: how can I do the same programmatically? And a second question: how can I achieve that a change in the setting is persistent (e. g. if I set DwmEnableComposition(false) on a machine that has DWM enabled, it is re-enabled once the application exits)?
I found a less nasty solution than my first one: Invoking winsat dwm will turn on Aero automatically once it finishes and if the hardware supports it - and it does not change the wallpaper etc.
The answer is: You cannot do that.
Microsoft does not expose a programmatic way for programs to enable or disable desktop composition on the user's machine.
The reason they don't provide an API is that programs might use it.
In the past Microsoft trusted developers not to do the wrong thing. That has changed
Because programmers were trusted to do the right thing
DwmEnableComposition is only for your application to temporarily disable DWM if you aren't compatible with composition. It cannot be used to turn on composition, when the user has already turned it off.
Any computer sold in the last 5 years is graphically capable of using composition, and Windows turns it on by default if its supported. The only reason it would be turned off is:
the user turned it off
another application is running that doesn't support composition
In either case: you should not (and therefor cannot) turn it on.
You cannot do that.

C# global hotkey (without the usually used global hook)

I'm creating a program for my personal use that must react to some hotkeys. For example, when I press ctrl+win+z it must perform a certain action. At present, I can use GetKeyState() from user32.dll to detect the keypresses, however I am unable to stop them being passed to the active application. In the case of ctrl+win+z, the action I want to happen occurs, but if I am using explorer, for example, explorer will also read that as an 'undo'.
The obvious solution would be to use "SetWindowsHookEx()" (also from user32.dll), however each time I try a solution involving it (anything similar to this site's example code) I get a massive slow down the first time I use the hotkey. This is not acceptable.
I hope someone can help. I can provide more information if required.
Have you tried the RegisterHotKey function? It's definitely easier to use than a windows hook.

How to write my own Global Snippets program with .NET?

I want to write my own global snippets tool for Windows XP and higher. This would be an always running in the background tool that would pop-up on a globally-defined hotkey, allow me to select a snippet with substitution arguments, and then paste the expanded snippet into the text input of whatever control I had been in when activated it, and finally, return me to that previous app/input box.
I know how to do most of the algorithmic aspects, but I do not know how to accomplish these windows-based features:
1 - Global Hotkey: how do I define a key-sequence in windows (from .net?) that will work, even when entering data in another apps textbox? (Usually this will be a browser window)
2 - Pasting Into Another App: I could use the paste-buffer and Ctrl-C, but I want to avoid the extra keystrokes.
3 - Return Control to Original Window: Seamlessly return back into my input stream: how do I do that? In fact, how does my tool even know where I was before it popped up?
The reasons that I want to write this myself is first to learn how (because there are other tools like this I would like to make) and secondly, I don't know of any snippets tools that have the argument substitution that I want.
So, the two (2)questions are A) What should be my general approach? and B) how best can I accomplish items 1 to 3 above?
You'll need to use global system keyboard hooks to capture your hotkey. There is a CodeProject article showing how to do this from within .NET.
Once you've "trapped" your keystroke, you can use the Windows API to get the current windows handle. However, I'd try to avoid activating your application. You should be able to just paste your new text, and allow the application to handle it.
The disadvantage of using the Windows API is that it doesn't work in all cases, and the "broken" cases are getting more and more common. For example, WPF applications do not provide a HWND for each element within a window, so getting the current "control"s handle will just give you the window, not the appropriate element.
Edit: Another reference source is this article in MSDN Magazine. It shows how to do this via C# using P/Invoke.

Edit and Continue in Silverlight?

Edit-And-Continue is one of my favorite debugging tools which I have previously used on C# based Winforms and ASP.NET projects. However, I'm running a Silverlight 3.0 application on VS 2008 and whenever I try to make a change (after breaking) it says "Changes are not allowed when debugging Silverlight applications". Also there isn't an "Enable Edit and Continue" option in the project settings.
Does anyone (possibly an insider) know when this feature will be supported by Microsoft???
(I NEED IT!)
I doubt it will ever be a feature, to be honest. EAC has always required you to attach directly to your .exe in order to work. In the case of Silverlight, that .exe is the browser, which is not the .exe you are developing.
If you are looking to edit XAML while running, you might consider a dynamic loading situation where you can refresh the control at runtime. In that case, you can edit XAML while debugging, but I'm afraid you're stuck with the managed code.
EDIT:
One possibility that you might consider (but I haven't tried it) is to write your code against unit tests. Then, there is a tool called TestDriven.net that allows you to debug your tests with EAC (as an advanced feature). From there, you might be able to do some EAC, but you will be doing it via unit tests, not actually in the Silverlight environment.

Categories

Resources