when I set my form's .Text property to a blank value (so that it doesnt have a titlebar) - how do I also set a value that it should use on the TaskBar button (since having a blank taskbar button is dumb, and good .. is dumb).
Printable View
when I set my form's .Text property to a blank value (so that it doesnt have a titlebar) - how do I also set a value that it should use on the TaskBar button (since having a blank taskbar button is dumb, and good .. is dumb).
I haven't tried this but just had an idea...
You could try setting your form to not show in the taskbar but also have another invisible form that does display in the taskbar.
You could then load your invisible form first and then open your main form as a dialogue of the invisible form.
That way clicking on the taskbar button will still bring your main form to focus.
Make sense or am i talking nonsense?
How does it belong to ASP.NET Forum? :confused:
instead of this.visible = false; use this.Opacity = 0; because if the first form is invisible it doesn't show in the task bar either.
It doesn't but neither me or Lord_rat has the ability to move it to C#.Quote:
Originally Posted by Shuja Ali
ahem moderator please....
This is exactly what I may end up resorting to, but it bugs the hell out of me.Quote:
Originally Posted by Fishcake
I was in the wrong forum when I submitted my question. Sorry.Quote:
Originally Posted by Shuja Ali
Yes I know. But there are other problems with this too. Like when you right click the button and MOVE, you will be moving the hidden form, not the real one.Quote:
Originally Posted by Fishcake
Stuff like that.
Hey Lord Rat, you are using my .NET Lovers Userbar :)
Anyway, I am sure that you could look for a tutorial somewhere if your question does not get answered. This is the best site for questions by far:
http://www.syncfusion.com/faq/aspnet/default.aspx
Consider having no title bar at all?
this.FormBorderStyle = FormBorderStyle.None;
Moved :)
I need a taskbar button still, so I have to have a title, otherwise I end up with a blank taskbar button and that's just as silly as Bolivia!Quote:
Originally Posted by mendhak
As for tutorials, none of them ever address this issue.
Are you saying you created it yourself? If so, good job.Quote:
Originally Posted by Seraphino
I also am using a couple I made myself in the rotation - DDO Player (which I need to remove as I no longer am) and Proud Father (which I never will remove)
I'm sure you could keep the title of the window blank but use an API to change the text in the taskbar button.
That could be a possibility. Hrm.
Why don't you just have no title bar like mendhak and I suggested? You still have a taskbar button with a title, just no actual title or window border.
otherwise, could you elaborate on the effect you are after?
Perhaps I missed something. Having no titlebar is exactly what I am after, but in order to do it I have had to set the .Text to "" which also blanks out the Taskbar Button.
Are you suggesting there is a method of having no titlebar without setting the .Text to ""?
Yes, what I posted in #11 :)
here's an article i stumbled upon (written in c#):
http://www.codeproject.com/csharp/taskbarsorter.asp
which i'm sure you could adapt to your needs. search through the buttons until you find the window handle that matches yours. then send a TB_SETBUTTONINFO to the taskbar to modify the text. seems a little brute-forced, but it would probably work. good luck
Well, you are right, that did allow me to have a taskbar button with a title, but is there a way to get a border back on my form now? (heh)
The fact that it is borderless is now umm, ugly. (Sorry to be such a pain, but I am very heavily interested in customer experience with every program I write and I WANT IT MY WAY!) =)
Wow, looks interesting. And complex. I'll see what I can do with that.Quote:
Originally Posted by zildjohn01
Well, after now spending three days working with this, it is above me and I must submit to my inferior knowledge.
The farthest I got was that I could find all the buttons on the taskbar. I could process a bunch of messages, to do fun stuff like enable/disable any of them, hide them, etc.
I could also GET the text of the button because a built in API exists for that. But there is no API to simply set it (what the hell were they thinking!)
But to process anything requiring that I change the button text itself, I have to use a TB_BUTTONINFO structure. Using it crashes Explorer (joy) unless I try to use it in Unicode mode (TB_BUTTONINFOW) in which case I just get bad data or if I am truly lucky, I start trying to read and write protected memory (yuck).
So, I am finally giving up. I will revisit this later with some other form of solution, when I am not so exhausted from spending three days trying to get text on a button.
Finally, MS shortcutted the button itself. I found out that you can assign the text of a button through the string pool. They point the button itself and the form title to the same stringpool ID. Thanks Microsoft...
Sometimes, the answer is staring you in the face. When I was doing all of my API stuff, I didnt think to modify the FORM through the API, I was modifying the TASKBAR BUTTON!!
Code is slightly ugly due to how windows handles redrawing forms, but it works:
Code:#region Window Title Functions
[DllImport("user32", EntryPoint = "GetWindowLong")]
public static extern int GetWindowLong(IntPtr hwnd, Int16 nIndex);
[DllImport("user32", EntryPoint = "SetWindowLong")]
public static extern int SetWindowLong(IntPtr hwnd, Int16 nIndex, int nValue);
[System.Runtime.InteropServices.DllImport("user32.dll")]
static extern bool SendMessage(IntPtr hWnd, Int32 msg, Int32 wParam, Int32 lParam);
private const Int16 GWL_STYLE = (-16);
private const int WS_CAPTIONBORDERLESS = ~0xC00000;
private const int WS_CAPTION3DBORDER = ~0x800000;
private const int WS_CAPTIONSINGLEBORDER = ~0x400000;
private const int WM_REDRAW = 0x000B;
private const int WM_REPAINT = 0xF;
#endregion
private void UpdateStyle()
{
int iHeight = this.Height;
IntPtr hWindow = this.Handle;
int iStyle = GetWindowLong(hWindow, GWL_STYLE);
iStyle = iStyle & WS_CAPTION3DBORDER;
SetWindowLong(hWindow, GWL_STYLE, iStyle);
this.Width = 334;
SendMessage(hWindow, WM_REDRAW, 0, 0);
this.Height = iHeight + 10;
this.Refresh();
this.Height = iHeight;
SendMessage(hWindow, WM_REDRAW, 1, 0);
this.Refresh();
this.Height = iHeight;
}
(Set the .Text property to whatever you want the taskbar button to show and modify all controlboxes accordingly as well (disable minimize if you dont want to be able to minimize from task bar, or maximize, etc))