Disable NotifyIconOverflowWindow autohide - c#

I have done flyout window similar to win7 battery meter. It is behaving just like built in one except when it is shown via notify icon who is located on NotifyAreaOverflowWindow aka notify overfow area that window autohides itself after some time while it should hide only when my flyout closes. The only difference that I could spot with spyxx that after some time overflow window simply sends itself an WM_SHOWWINDOW wp:0 lp:0 message.
How can I prevent the overflow window from autohiding while my flyout is active?
Image 1: Test flyout shown after click on notify icon which is located on overflow area + couple seconds of user inactivity.
Image 2: Battery meter flyout shown by clicking on notify icon which is located in overflow area + 2 mins of user inactivity.

You should call
NotifyWinEvent(EVENT_SYSTEM_MENUPOPUPSTART, Handle, OBJID_CLIENT, 0);
before you show your window and call
NotifyWinEvent(EVENT_SYSTEM_MENUPOPUPEND, Handle, OBJID_CLIENT, 0);
after you hide it.

Flyouts are no different from any other window.
If I'm understanding your problem, which is that the windows disappear over time, then the solution is quite simple. Do not use whatever NotifyAreaOverflowWindow is. Instead, create your own window, with the appropriate properties (no control box, no max/min buttons, no title text, etc...). Because it's likely out of your control to set the duration of the class/object you're using. It's likely designed for single-notifications, and not something moderately useful ;).
Plus, you'll be able to do fancy things as desired without running into anymore issues.
The following tutorial goes in great lengths on how to position it so perfectly:
http://blog.quppa.net/2010/12/09/windows-7-style-notification-area-applications-in-wpf-part-3-taskbar-position/

Related

C# winforms, How can I make a Combobox open upwards / Is there one that does?

In C#, a winforms application,
How can I make a Combobox that opens upwards / Is there one that opens upwards?
I see some questions like this but they refer to a WPF application rather than a winforms one. I'm asking about a winforms application.
This is not easy when working with WinForms, but I could give you my idea.
You should know that even when the combobox visible property is set to false, its' dropdown menu can still be displayed programmatically.
So the idea is that creating a user control that contains 2 comboboxs:
Example of my user control
The upper combobox is invisible. When user clicks the main, below one, the upper one will be relocated and drop down.
private void cbb_main_Click(object sender, EventArgs e)
{
cbb_2.Location = new Point(cbb_main.Location.X, cbb_main.Location.Y - cbb_2.Size.Height - (cbb_2.ItemHeight *cbb_2.Items.Count));
cbb_main.DroppedDown = false;
cbb_2.DroppedDown = true;
}
Finally, add your custom control to the form and give it a try!
Result image here!
I hope this is what you're looking for.
If there is enough in your combobox, and your form is low enough, that the contents of the combobox hits as far as very near the bottom of the screen, then it will open upwards.
Downwards
Now i'll drag the form down a little bit. (Or I could add some elements to the combobox) And you see it opens upwards.
Upwards
Sure it would be better if it popped upwards when it covered a bit of taskbar(or if the combobox took priority in z-order, which it doesn't seem to). An annoying thing is if it's in a limbo where it is covering the taskbar 'cos the contents aren't falling low enough for it to pop upwards. Then when you select something low in the combobox you also hover over something in the taskbar, then windows 7 can open eg an explorer window as you hover over a group of them in the taskbar. (And btw that issue exists whatever size your taskbar is). But in that scenario, as this answer says, you could drag the form a bit lower to get around that.

Windows form with a transparent background that can be clicked through

INTRODUCTION
Using C# or VB.NET. I'm trying to make a form's background transparent; this form will be overlaped to other window, it will be a top-most window, so the transparent form (and its controls) must have the ability that they must not receive focus and they must can be clicked trough, this means if for example I perform a left-click on the transparent background, then the window on background of that (in the Z-order window) is the window that must receive the click instead.
Notes:
For avoiding the focus I'm overriding the CreateParams property as explained here.
For making my form transparent, I'm calling Win32 DwmExtendFrameIntoClientArea function and also using SharpDX library as explained here. But I think this really doesn't matter with the question itself.
PROBLEM
I'll show a demostration of what I mean using images. Here below is a image of a form (with no transparency, just to simplify understanding) overlapped to a window of a text editor program; note that my form doesn't receive focus. Well, the problem is when I do click on the form's background (or one of its controls) the window on background (the text editor window) still have focus but it can't receive the click.
Here is the same image of above but with a transparent form:
RESEARCH
I'm not really sure about what to investigate, so I'm going blind trying to find something useful in a trial-and-error stage by overriding the Window procedure (WndProc) of the transparent form to test related windows messages, like WM_NCHITEST or WM_MOUSEACTIVATE message as said here:
Windows form with a transparent background that cannot be clicked through
Make a form not focusable in C#
How do I create an "unfocusable" form in C#?
You can do this by sending click (mouse up & mouse down) messages to the window underneath the transparent window using WinAPI.
PostMessageA
You'll need to find the window underneath the point you require.
WindowFromPoint
You'll have to translate the position of the click events accordingly since messages are processed based on relative window position, not absolute screen position.
I actually did this quite successfully to automatically play a facebook game many years ago.
Check the RAD designer in Visual Studio.
Is the label docked to fill?
Where is the main form clickable?
The transparent color is click-though in the main parent, however, components will still retain clicks.

Balloon pop up over control mouse enter/exit

Hello,
Above is the program I am writing. On the right panel is basically two custom controls (the blue rectangle area) I created and just added them as controls to the background panel control when this winform program loads.
I used MS paint to draw out the pop up balloon that I want to see when my mouse enter this control's area. I want to do the following:
1. If mouse enter the control area, the yellow area balloon pop up and populate with the information of that specific control
2. If mouse move out of the control area, the pop up balloon disappear.
Can this be done with Winform application? I looked around and found out about Tooltip class but so far from researching I don't know if it does what I want to do.
I could be wrong but googling around gave me the impress that Tooltip offers very little in term of style. Ideally I want to make this pop up balloon into almost like a border-less pop up window where I can put image , font ect.....at will. Also Tooltip works if you hover over a button or specific field whereas I want the entire control area.
Can this be done? I appreciate if you can point me to any work around if there is one.
I wrote a comment, but I figure I'll expand it into a full answer. This is assuming you want a new control, which isn't a tooltip, for maximum customizability. I did something similar to this for work recently, to act as a non-modal info popup that disappears when clicked.
Creating a Custom Popup Form
What you want is essentially a floating popup that appears over your form, which means you'll want to define a new Form object, rather than a UserControl, as it won't actually be embedded within your other form.
Give it a multiline, non-editable textbox that you can fill with the information you want to populate, then simply call a new instance of the form on your Mouse_Enter event. Close it upon Mouse_Leave.
Adjusting The Style
You'll have to play with it a bit to get it to actually act like a popup and not just a window. I'd recommend setting it to a non-modal popup, and removing the border. You can write a function to automatically size it to its contents. I don't imagine you'll want the user manually resizing it.
Some other things to look into would be overriding the CreateParams property that comes with the basic Form object. You can force DropShadows and TopMost forms without making the form modal. Overriding ShowWithoutActivation to always return true will prevent the form from stealing focus when it pops up.
I'm not sure if you can pull off rounded edges like you have in your mockup. Perhaps you can pull it off with some wizardry in the OnPaint() function, but I couldn't tell you how to do it.
It might be a bit of a pain for fiddling around with, but you can get some good functionality and appearance out of it. If you think you can pull it off acceptably with the ToolTip class, go for it. It took me about a week to get my notifications where I wanted them (though I added several features that you probably don't need to worry about).
Examples
Some keywords to look up in related searches would be Toast Notification and Non-Modal Popup. This might be some use:
http://www.codeproject.com/Articles/442983/Android-Style-Toast-Notification-for-NET
Since you already have implemented custom user controls you might want to try it again. Make a control that is that style and color, changes it's size based on it's text. You can feed it information (such as the text to display) from your existing user control object. You can also have the mouse enter/leave code reside in your first user control.
If you're not sure how to make a rectangle with round corners you can either make it on the fly using a graphics object (which will turn into a bitmap on the screen) or make it how you want it to look in GIMP (or photoshop if you have it) then use that image as the background on your user control. Make the default background transparent (so your voids above the round corners are not grey). If you make a pre loaded image you'll need to be aware you will only be able to scale it equally in Y and X directions. unequal scaling will make it look distorted.
Can you use the Mouse_Enter event on the control?

How to make a form behave like windows taskbar using c#

I have created a taskbar using tabcontrols which works similarly to the Windows taskbar.
I want to make my own taskbar fixed on top of the windows.
It should not be movable, resizable, and it should be "docked" to the top.
I have not tried to do this, but my first attempt would be the following:
set form to be 'TopMost'
set border to 'None'
set Location: (0,0), Size(Screen.Width,H), where H is the Height you want your form to be
set 'ShowInTaskBar' to false
Something you might consider: how will you handle multiple screens?
You'll likely want to add a context menu allowing you to exit the application, since it won't have the normal system buttons. Also, you might consider what happens when the user presses ALT-F4: will your program close? If not, you'll need to add some code in the FormClosing event handler to cancel closing.
Hope this sets you in the right direction!
A long long time ago Jeffery Richter demonstrated how to do a true taskbar in a sample called AppBar (I've used it myself as a boiler plate), so here are some pages that may be of interest:
http://www.google.com/search?q=Jeffrey+Richter+appbar+c#

Drawing a toolbar on a window's titlebar

How do I draw a toolbar on the titlebar of a C# winforms window in windows vista? I have a window where it works, except when the window is unminimized/unmaximized it increases in size by about 16x32px. If possible, please provide code examples.
The only way to effectively do it is to handle the WM_NCPAINT message when you override the WndProc method for the Form.
Passing to the base implementation of WndProc will cause the windows frame to be painted, but at that point, you would be responsibile for painting your toolbar elements on the title bar.
You will also want to handle all the other WM_NC* messages as well, which will allow you to process button clicks and the like (which you will need to handle events for your painted controls).
I've been looking around for the same problem, because I wanted to code a ribbon bar with that big button in the upper left corner... The only good source I found was at CodeProject on this blog and this one and another one.

Categories

Resources