I have an VSTO Outlook Add-in and I would like to popup a notification (floating window) with a custom text message for a specific time (5 seconds for example) and then disappear automatically. I want to show this notification from within the compose window. How can I achieve this? some example will highly appreciated.
UPDATED: I would like the notification window to be a child of the compose window.
UPDATE 29.06.2022: I have done the following:
Outlook.Inspector currentInspector = this.Window as Outlook.Inspector;
IOleWindow ioleWnd = (IOleWindow)currentInspector;
ioleWnd.GetWindow(out IntPtr phwnd);
NativeWindow nativeWnd = new System.Windows.Forms.NativeWindow();
nativeWnd.AssignHandle(phwnd);
// frm is my notification window, borderless and without maximize, minimize and close buttons and without title bar.
Form frm = new Form();
frm.ControlBox = false;
frm.FormBorderStyle = FormBorderStyle.None;
NativeMethods.Rect rect = new NativeMethods.Rect();
NativeMethods.GetWindowRect(phwnd, ref rect);
frm.Left = rect.Right - 85;
frm.Top = rect.Bottom - 55;
frm.Width = 80;
frm.Height = 50;
frm.Location = new System.Drawing.Point(rect.Right - 85, rect.Bottom - 55);
frm.BackColor = System.Drawing.Color.Red;
TextBox txtBox = new TextBox();
txtBox.BackColor = System.Drawing.Color.Red;
txtBox.ForeColor = System.Drawing.Color.White;
txtBox.Location = new System.Drawing.Point(5, 5);
txtBox.Visible = true;
txtBox.Text = "This is a notification message";
frm.Controls.Add(txtBox);
frm.Show(nativeWnd);
What happens with above code is below:
- Notification window is not positioned on the bottom right hand corner of the compose window.
- If I move compose window, notification window keeps in the same position and it is not moving while I move the compose window.
- In windows task bar it appears as the notification window is a different process/program, not being part of the same compose window, maybe I need to do something like frm.Owner = nativeWnd but it is not working.
Any ideas?