Results 1 to 25 of 25

Thread: [RESOLVED] [2005] this.Text = "" but with a Taskbar Title

  1. #1

    Thread Starter
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497

    Resolved [RESOLVED] [2005] this.Text = "" but with a Taskbar Title

    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).
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  2. #2
    Frenzied Member Fishcake's Avatar
    Join Date
    Feb 2001
    Location
    Derby, UK
    Posts
    1,092

    Re: [2005] this.Text = "" but with a Taskbar Title

    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?

  3. #3
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: [2005] this.Text = "" but with a Taskbar Title

    How does it belong to ASP.NET Forum?
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  4. #4
    Frenzied Member Fishcake's Avatar
    Join Date
    Feb 2001
    Location
    Derby, UK
    Posts
    1,092

    Re: [2005] this.Text = "" but with a Taskbar Title

    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.

  5. #5
    Frenzied Member Fishcake's Avatar
    Join Date
    Feb 2001
    Location
    Derby, UK
    Posts
    1,092

    Re: [2005] this.Text = "" but with a Taskbar Title

    Quote Originally Posted by Shuja Ali
    How does it belong to ASP.NET Forum?
    It doesn't but neither me or Lord_rat has the ability to move it to C#.

    ahem moderator please....

  6. #6

    Thread Starter
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497

    Re: [2005] this.Text = "" but with a Taskbar Title

    Quote Originally Posted by Fishcake
    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?
    This is exactly what I may end up resorting to, but it bugs the hell out of me.
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  7. #7

    Thread Starter
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497

    Re: [2005] this.Text = "" but with a Taskbar Title

    Quote Originally Posted by Shuja Ali
    How does it belong to ASP.NET Forum?
    I was in the wrong forum when I submitted my question. Sorry.
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  8. #8

    Thread Starter
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497

    Re: [2005] this.Text = "" but with a Taskbar Title

    Quote Originally Posted by Fishcake
    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.
    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.

    Stuff like that.
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  9. #9
    Addicted Member
    Join Date
    Jan 2006
    Posts
    247

    Re: [2005] this.Text = "" but with a Taskbar Title

    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

  10. #10
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2005] this.Text = "" but with a Taskbar Title

    Consider having no title bar at all?

  11. #11
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: [2005] this.Text = "" but with a Taskbar Title

    this.FormBorderStyle = FormBorderStyle.None;

  12. #12
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [2005] this.Text = "" but with a Taskbar Title

    Moved
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  13. #13

    Thread Starter
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497

    Re: [2005] this.Text = "" but with a Taskbar Title

    Quote Originally Posted by mendhak
    Consider having no title bar at all?
    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!

    As for tutorials, none of them ever address this issue.
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  14. #14

    Thread Starter
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497

    Re: [2005] this.Text = "" but with a Taskbar Title

    Quote Originally Posted by Seraphino
    Hey Lord Rat, you are using my .NET Lovers Userbar
    Are you saying you created it yourself? If so, good job.

    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)
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  15. #15
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: [2005] this.Text = "" but with a Taskbar Title

    I'm sure you could keep the title of the window blank but use an API to change the text in the taskbar button.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  16. #16

    Thread Starter
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497

    Re: [2005] this.Text = "" but with a Taskbar Title

    That could be a possibility. Hrm.
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  17. #17
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: [2005] this.Text = "" but with a Taskbar Title

    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?

  18. #18

    Thread Starter
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497

    Re: [2005] this.Text = "" but with a Taskbar Title

    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 ""?
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  19. #19
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: [2005] this.Text = "" but with a Taskbar Title

    Yes, what I posted in #11

  20. #20
    Lively Member
    Join Date
    Feb 2005
    Posts
    84

    Re: [2005] this.Text = "" but with a Taskbar Title

    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

  21. #21

    Thread Starter
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497

    Re: [2005] this.Text = "" but with a Taskbar Title

    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!) =)
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  22. #22

    Thread Starter
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497

    Re: [2005] this.Text = "" but with a Taskbar Title

    Quote Originally Posted by zildjohn01
    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
    Wow, looks interesting. And complex. I'll see what I can do with that.
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  23. #23

    Thread Starter
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497

    Re: [2005] this.Text = "" but with a Taskbar Title

    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...
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  24. #24

    Thread Starter
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497

    Re: [2005] this.Text = "" but with a Taskbar Title

    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;
            }
    Last edited by Lord_Rat; Jun 28th, 2006 at 05:46 PM.
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  25. #25

    Thread Starter
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497

    Re: [RESOLVED] [2005] this.Text = "" but with a Taskbar Title

    (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))
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width