Tried the CreateParams override as suggested here, however, the taskbar button does not appear on initial load. The user has to activate another window, then re-activate the target window before the taskbar button appears.
Any reason why this is so? How do you workaround this?
Try adding the WS_EX_APPWINDOW flag to the ExStyle property of CreateParams.
Windows is trying to guess whether your window should have a taskbar button by looking at the caption and other styles. The WS_EX_APPWINDOW makes it explict so Windows doesn't have to guess.
WS_EX_TOOLWINDOW makes it explicit that you should NOT have a taskbar button.
Edit: like this
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x0040000; // add WS_EX_APPWINDOW
cp.Style &= ~0x00C00000; // remove WS_CAPTION
return cp;
}
}
Related
i'm just working on a project that i need to use 30~35 checkboxes in form and i have to set a custom background image for main form and the all checkboxes on it. But all must have to transparent backcolors when i set them to transparent in designer, form loads with flickers, i already tried DoubleBuffered = true and
protected override CreateParams CreateParams
{
get
{
CreateParams CP = base.CreateParams;
CP.ExStyle |= 0x02;
return CP;
}
}
But when i do these i can solve flickering but the interface load too slow and i wonder if there is any way to handle this?
What I basically did was a program that shows CPU/RAM/Sound levels in taskbar
but it also shows in the alt+tab dialog
I have used this code snippet for hiding applications from the alt+tab
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x80;
return cp;
}
}
But that only works if ShowInTaskbar is set to false but I need it on because obvious reasons. Is there some way to make it not show in alt+tab and still preserve itself in the taskbar?
I have borderless form window, with custom close/minimize buttons
= I have FormBorderStyle:None
And here is my problem. While using this setting, I cannot minimize my app through an icon in taskbar.
If I switch to, for example FormBorderStyle:Fixed3D, where are original system buttons present, the task bar icon come back to life and can minimize the app.
With restoring the app through taskbar icon, there is no problem.
So, is it possible to minimize the app through taskbar icon while FormBorderStyle:None ?
(using .NET 4.5 in MS Visual Studio 2012, Windows Form Application template)
Thanks in advance
Borderless windows don't have the WS_MINIMIZEBOX window style (because the controlbox is removed when you set FormBorderStyle to None), so you have to add it yourself by overriding the CreateParams property:
protected override CreateParams CreateParams {
get {
const int WS_MINIMIZEBOX = 0x00020000;
var cp = base.CreateParams;
cp.Style |= WS_MINIMIZEBOX;
return cp;
}
}
I have a Winforms application, which I'm able to minimize by clicking on the corresponding button on the top right of the window; I can then maximize it by clicking on this application's taskbar icon.
My problem is that if the window is maximized, it should be minimized when I click on the taskbar icon again, and it's currently not happening.
How can I make this behavior happen? I don't want to have to use NotifyIcon or system tray.
const int WS_MINIMIZEBOX = 0x20000;
const int CS_DBLCLKS = 0x8;
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.Style |= WS_MINIMIZEBOX;
cp.ClassStyle |= CS_DBLCLKS;
return cp;
}
}
You can do it with no borders too..
requires additional coding
Try to check what's going on in LocationChanged, Move, RegionChanged, Resize, ResizeBegin, ResizeEnd, SizeChanged events. Could be that some code in any of these events is blocking the behavior you described.
I am not seeing the described problem on a new empty form.
Update: I am using Window 7 Pro.
I've been developing an app for a while now that has a textbox with a vertical scrollbar. It's worked perfectly up until today. Today, after making some changes unrelated to scrolling, I noticed that the scrollbar wasn't moving up and down when I drag it with the mouse. The textbox that owns the scrollbar scrolls just fine, but the scrollbar doesn't move till I release the mouse button!
This is extremely annoying, and confusing for users of my application. My question is this: what would cause such a thing to happen, and how can I fix it?
The cause of the scrollbar not moving was my use of this overridden property:
protected override CreateParams CreateParams
{
get
{ // Turn on WS_EX_COMPOSITED
CreateParams cp = base.CreateParams; cp.ExStyle |= 0x02000000;
return cp;
}
}
I was using it to ensure double-buffering on all controls, but it had unintended side effects.