I'm working on a .Net (WPF/C#) application, the application displays notifications (similar to Growl notifications on OS X) at different times, I would like the notifications to display above all other windows, including when there is a full screened app (like a PowerPoint presentation).
Is there anyway to display a Window over a full screened app?
Did you try to set TopMost = true parameter of this window?
also check this thread:
Form top most?
or you can use Popup instead, it will on top of any window or control.
WPF.
private void Window_Deactivated(object sender, EventArgs e)
{
Thread.Sleep(2000);
this.Topmost = true;
}
But this is not the best option.
In full screen mode there is exclusive access to the display, and you can only display on top of this if you are allowed to implement it if it's a game in OpenGL, DirectX and BackBuffer to impose your data.
Related
Im building a WPF app and i'm trying to check several URL's in the background within a WebView2 window
Altough some urls have popups (which aren't real popups) in the upper left corner like asking for permission to use e.g. the microphone or something.
These popups are getting displayed in full size even if the visibility of the 1x1 pixel big webview is hidden
Here is an example of such a popup in my app:
The black corner is the edge of the app and as you can see the meet.google.com popup is displayed in full size even if the webview is invisible
I already tried to disable the notifications with the new window requested event but this doesn't work because it isn't a new window and it doesn't have a URL or anything.
I also tested many CoreWebView2 settings which made sense,like before no useful results
Does somebody know if there is a setting or something which i have to enable/disable in WebView2 to disable these notifications?
If any further information is required please ask me!
You need to look at the Permissions Requested event for mic and camera.
async private void InitializeWebView2()
{
await webView21.EnsureCoreWebView2Async();
webView21.CoreWebView2.PermissionRequested += CoreWebView2_PermissionRequested;
}
private void CoreWebView2_PermissionRequested(object sender, CoreWebView2PermissionRequestedEventArgs e)
{
Debug.WriteLine(e.PermissionKind.ToString());
e.State = CoreWebView2PermissionState.Allow;
}
Its that I am developing an application in C# and I have used three tab controls there. The problem is I can not change the actual window size of the application when I change to another tab because I do not need such big window for that and when I change back to the previous one it should go back to previous size.
In my opinion you should not change the size of the window when the selected tab changes. Design your window in such a way that you don't need to resize it.
Redesign your tabs in such a way that they always consume the same size so you don't need to resize the window.
I would not expect, as a user, that the window size changes because it may give you a bad user experience.
i think you want this:
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
{
if (tabControl1.SelectedTab.Text == "tabPage1")
{
// rezise tabcontrol
}
}
although i dont think its user-friendly
Sometimes when our application launches it flashes orange in the taskbar. I don't think we explicitly wrote any code to do this but it still happens. Our program is a c# winforms app that sometimes takes a while to load. Any ideas what could be causing this and how I can prevent it?
I believe you can use MSDN's flashwinfo .
Edit - Here's some more info .
From my experience, if the application isn't the current application the user is using, but does something 'on its own' to update the UI(?) the system recognizes this and notifies the user by the orange flash thing.
So if your application is doing some long processing and the user clicks away to another application/window, they probably will get the orange flash.
A possible alternative would be to prevent the application from showing in the Taskbar until loading has completed.
So, something along the lines of:
// prevent from showing in the constructor (or via the designer)
public MyAppMainForm()
{
this.ShowInTaskbar = false;
// other initialization
}
// now you're ready to show in the Taskbar
private void MyAppMainForm_Load(object sender, EventArgs e)
{
this.ShowInTaskbar = true;
}
I would like to display a WPF window from a windows forms application (.NET 3.5).
This code seems to work without any problem in a sample project:
public partial class WinFormsForm1 : Form
{
public WinFormsForm1() {
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e) {
WpfWindow1 w = new WpfWindow1();
w.Show();
}
}
The form is started from Main() as a normal Winforms form:
Application.Run(new WinFormsForm1());
This seems to me too easy to be true. Are there any shortcomings in this? Is this safe to do?
It has one serious shortcoming: the modeless WPF window would not get keyboard input.
The EnableModelessKeyboardInterop method call needs to be added before the WPF window is shown:
WpfWindow1 w = new WpfWindow1();
System.Windows.Forms.Integration.ElementHost.EnableModelessKeyboardInterop(w);
w.Show();
ElementHost resides in WindowsFormsIntegration.dll.
Further reading: http://msdn.microsoft.com/en-us/library/aa348549.aspx
Bottom line: it is.
We have pretty heavy application combining both WPF and winforms: windows, user controls, modal dialogs, you name it... and it's working in the medical market.
We've got into some dark corners, one is the infamous EnableModelessKeyboardInterop, another is having the WPF window be the child of the Winforms window, which you can read Here
It is really that simple. I can't think of any downside doing it this way.
How can I create a Popup balloon like you would see from Windows Messenger or AVG or Norton or whomever?
I want it to show the information, and then slide away after a few seconds.
Edit: It needs to be blocking like Form.ShowDialog() because the program exits after displaying the notification
You can use the notifyIcon control that's part of .NET 2.0 System.Windows.Forms. That allows you to place an icon for your application in the System Tray. Then, you can call the ShowBalloonTip(int timeOut) method on that. Be sure however to first set the text, and icon properties on the notifyIcon for it to work. Small code sample:
private void button1_Click(object sender, EventArgs e)
{
this.notifyIcon1.BalloonTipText = "Whatever";
this.notifyIcon1.BalloonTipTitle = "Title";
this.notifyIcon1.Icon = new Icon("icon.ico");
this.notifyIcon1.Visible = true;
this.notifyIcon1.ShowBalloonTip(3);
}
EDIT: Ok, so notifyIcon won't work for you. My second suggestion would then be to create your own control for this. Actually, I would use a form. A simple form, with no borders, and no control box and just have a timer running so you can set the Opacity for fade in/out. Then, you can easily get the bottom right of the screen using the Rectangle Screen.PrimaryScreen.WorkingArea. Then just show your form at that position.
Don't create a modal (blocking) balloon. Please. A big part of the design of these UIs is that they are not dialogs: they're transient, potentially non-interactive elements, intended to provide incidental information to a user without necessarily interrupting their workflow. A balloon that steals focus and blocks user input would be irritating at best - if you need a dialog, then use a dialog.
The .NET 1.1 Visual Basic Power Pack had a toaster control.