How to open tray popup like 'Sound Control' or 'Action Center' - winforms

I'm writing a winform app that lives in the notification tray and the user can open/close it by interacting with the notifyIcon control.
Whene some events happens, I need to notify the user about but the notifyIcon's BalloonTip is not enough, because I need to display a collection of messages paired with buttons, that the user must click in order to acknowledge the app that he really saw it(very serious stuff)
How can I accomplish that? Does winforms provide a specific API? If there's not such API, how do I set up a completely blank form?
Thanks a lot.

Take a look at this question. The notifyIcon1_Click displays a context menu at the mouse position. In your case you need to display a form.
I think the screenshot you put shows a regular form without the title bar. So you just have to make a new form and show it at the mouse position when the user clicks the notification icon.
To remove the title bar from a form just do this form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; or form.ControlBox = false;
form.MaximizeBox = false;
form.MinimizeBox = false;
form.Text = "";

As #dburner said
form.ControlBox = false;
form.MaximizeBox = false;
form.MinimizeBox = false;
form.Text = "";
worked for me. However the first option doesn't give the aero feel.

Related

How to create a connection bar for a application in wpf mvvm pattern

we need to create a application which has a pin button on title bar.
if its clicked the application should get hide on top of the desktop as like connection bar in remote desktop application.
can some one pls tell me how to do that... merely searched for 1 week but still could't find. connection bar example
Do you need the pin button to be in the border, like the close and minimize buttons, or just as part of your app? If its just part of your app then something like this should work:
this.WindowStyle = WindowStyle.None;
this.WindowState = WindowState.Maximized;
Just toggle that based on the button click and add an 'invisible' button to the top of your app, which displays a drop-down on mouse-over.

call a button of different form in c# Forms?

I am new to C#, I am creating a application in which there is a need of using two forms
one is Mainform and other is DialogForm.
The DialogForm has two buttons btnYes and btnNo.
whenever the user clicks the close button, FormClosing Event invokes in which I am calling the DialogForm as shown below:
DialogForm ex = new DialogForm();
ex.ShowDialog(this);
Now I want to give e.cancel=false for btnYes and e.cancel=true for btnNo. (this explained by my sir, only basics)
I know how to give functions to a Button which is in same Form but I dont know how to if the Form is different.
I have gone through some links but as I am new to c#, I can't understand it.
If you atleast provide me some links that would be appreciable.
Thanks in advance.
Forms have a property DialogResult. You can set it in the button event handlers.
DialogResult = DialogResult.Yes;
// or
DialogResult = DialogResult.No;
Then you can call the form like this
if (ex.ShowDialog(this) == DialogResult.Yes) {
// Do something
} else {
// Do something else
}
You can also set the CancelButton property of the form in the properties window. Microsoft says:
Gets or sets the button control that is clicked when the user presses the ESC key.
The form has also an AcceptButton property. Microsoft says:
Gets or sets the button on the form that is clicked when the user presses the ENTER key.

Showing multiple windows - activation problem

I'm writing small notification component, however I have a problem with showing multiple notification at once.
My alert/notification window inherits from window class. The contstructor of Alert looks like that
public Alert()
{
InitializeComponent();
Focusable = true;
ShowActivated = false;
ShowInTaskbar = false;
//Topmost = true;
AllowsTransparency = true;
Opacity = 1;
// Set up the fade in and fade out animations
_Hint = "hint";
Loaded += new RoutedEventHandler(DesktopAlertBase_Loaded);
}
In main window of application I have a list of alerts, thanks to this I know where to place alerts on the screen. If I want to show an alert I create an instance of Alert class and then I use Show() method. Alerts are shown and everything is OK except the fact that I can use/move/interact with only last alert window (last created window).The rest of alert windows can't be clicked. However if I close last window I can use one before last and so on... Is it possible to make multiple windows clicable/active ?
Can you please, provide code, where you use show method? It looks like you are using ShowDialog() method instead of Show().
Another possibility is some locks in your DesktopAlertBase_Loaded() method.

Popup window and context menu

I am using the ToolStripDropDown to host the user control as the pop-up window. The problem is when a context menu strip is displayed from within this pop-up window, the pop-up itself closes in the moment the context menu opens.
I have tried to subclass the ContextMenuStrip and added WS_EX_NOACTIVATE to CreateParams but nothing changed. First I thought that there is no way to do this since it is common behavior but then I tried to put a TextBox class onto the pop-up user control and invoke the Edit control context menu - and the parent pop-up window did not close.
What am I missing?
Had a similary Problem. On my UserControll was a toolstrip. When I pressed the toolsstripdropdownbutton the dropdown was shown but the popup disapeared.
The reason was that popup.Autoclose was true. After Setting to false the Popup is not closed any more.
ToolStripDropDown popup = new ToolStripDropDown();
popup.AutoClose = false; //Set to FALSE
popup.Margin = Padding.Empty;
popup.Padding = Padding.Empty;
ToolStripControlHost host = new ToolStripControlHost(userControl1);
host.Margin = Padding.Empty;
host.Padding = Padding.Empty;
popup.Items.Add(host);
popup.Show(button1, new Point(100,100));
Actual Solution should be the one in Martin's final comment:
Use ContextMenu Instead of ContextMenuStrip
That one worked for me, and the ToolStripDropDown no longer closes by itself when right clicking one of its content controls, like it should. We still need it to AutoClose, disabling AutoClose on ToolStripDropDown will do bad things, it is supposed to close on losing focus. Example: open any other app window, and the ToolStripDropDown will continue to appear on top

How to redirect to a different page clicking on an Image in silverlight 3.0?

I have a slide show of some images in my silverlight application.
When user clicks on any Image I want want to redirect to a different page.
How to implement this.
Please help.
From Silverlight you can catch/handle the MouseLeftButtonUp event and do
HtmlPage.Window.Navigate("http://www.example.com");
HTML.Navigate won't open a new page in several browsers. This makes it kind of worthless.
However, HyperlinkButtons magically make it work. I don't know how, so I just create a one of those, give it the URI that I want to open, and click it (all from code). if I set the TargetName of the HyperlinkButton to "_Blank" then it will open in a new page.
Calling a buttons click event from code isn't the easiest either, but I found some code somewhere that did it. Here's the code that you will need to open a new page:
HyperlinkButton button = new HyperlinkButton();
button.NavigateUri = new URI("The URI To Go To");
button.TargetName = "_Blank";
HyperlinkButtonAutomationPeer hyperlinkPeer = new HyperlinkButtonAutomationPeer(button);
IInvokeProvider invokeProvider = hyperlinkPeer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;
invokeProvider.Invoke();

Resources