+ Reply to Thread
Results 1 to 14 of 14

Hide a form from the taskbar

  1. #1
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Hide a form from the taskbar

    I have the attached workbook that works just fine as is. The intended purpose is to create a log for time spent on departmental tasks. The user clicks the "start" button to begin timing, then clicks "stop" to end it. This all works find.

    The tricky part is that the user needs to remember to click "stop". I have created a small form that appears notifying the user that they are currently timing a task. I used an API (by which I mean I copied other people's codes. This is way over my head) to make the form window always "on top" and to change the parent of the form from the workbook to the desktop. This gives the benefit of the form not being hidden when Excel is minimized or deactivated.

    My only niggling problem is that the form is now its own item in the taskbar. How would I go about hiding this form from the taskbar but retaining the functionality of always being visible and on top?
    Attached Files Attached Files
    Last edited by Whizbang; 07-02-2010 at 02:55 PM. Reason: Marking as solved.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Hide a form from the taskbar

    Hello Whizbang,

    You will need to use more API calls to add the minimize/restore window function to the UserForm. I can do this for you and will post back with the final code.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Hide a form from the taskbar

    Hello WhizBang,

    I clean up the API code and moved all into Module1. Now there is a single call in the UserForm_Initialize event to setup the UserForm. Here is the module and UserForm code. This has been added to the attached workbook.

    Module1 API Code Calls
    Please Login or Register  to view this content.

    UserForm Code
    Please Login or Register  to view this content.
    Attached Files Attached Files

  4. #4
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Hide a form from the taskbar

    Leith Ross, thank you very much for your time and assistance. I can see where this code can be very useful for some other projects of mine. But, this doesn't seem to address my problem. Perhaps I mispoke. I do not need or want min/max buttons on my form. I do not want to give the user the option to "hide" the warning by minimizing the form.

    Please see the attached image. This snapshot shows that when the form is opened, another item is placed in the taskbar. I would like to keep the form displayed on the screen, on top of all other windows, but to not display anything for the form in the taskbar.

    Before I added the bit to change the parent of the form to the desktop, there was no additional taskbar item. This suited me just fine, except that when the user minimized the Volumes workbook, the pop-up form was also minimized. So, I changed the parent to the desktop, making the form independant of the workbook's WindowState.

    Does that help at all?
    Attached Images Attached Images

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Hide a form from the taskbar

    Hello WhizBang,

    I got to thinking this probably wasn't what you wanted. The basic problem here is Windows places any top level Window (a window that is a child of the Desktop) onto the task bar. When the user form is child of Excel, it doesn't appear on the task bar but appears and disappears with Excel. I am not sure how to make the user form independent of Excel and not a child of the desktop. I'll have to think on this one.

  6. #6
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Hide a form from the taskbar

    Well, if it can't be done, or at least not easily, I am ok with that. It is really a minor problem. I was just hoping to not only make my project behave the way I desire, but to also learn something. Well, the first may never come to be, but the second has certainly occurred.

    Thank you very much for your API code. I incorporated the cleaner version into my own work (minus the min/max buttons) and I think I am learning this API stuff just a little bit.

  7. #7
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Hide a form from the taskbar

    I found these, but haven't tested them in an Excel 2003 environment.

    http://www.planetsourcecode.com/vb/s...59397&lngWId=1

    http://www.vbforums.com/showthread.p...47#post1308347

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Hide a form from the taskbar

    Hello WhizBang,

    I got it working. It is pretty simple. Any window that has the style bit WS_EX_APPWINDOW set is added to the taskbar. Here is the working code...
    Please Login or Register  to view this content.

  9. #9
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Hide a form from the taskbar

    After reading here (http://mc-computing.com/Languages/TaskBar.htm) and here (http://stackoverflow.com/questions/2...-ws-ex-toolwin) it appears that by setting the WS_EX_APPWINDOW, it adds the form to the taskbar. This is not what I want. The form is already in the taskbar, I want it gone/hidden from the taskbar. The second link refers to setting WS_EX_TOOLWINDOW to &H80, which should remove the button from the taskbar as long as WS_EX_APPWINDOW is not present in the form's style.

    So, how do I remove the WS_EX_APPWINDOW and add the WS_EX_TOOLWINDOW?

    The first website I linked in my previous post (http://www.planetsourcecode.com/vb/s...59397&lngWId=1) has this code, which seems intended to remove the WS_EX_APPWINDOW property from the style.
    Please Login or Register  to view this content.

  10. #10
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Hide a form from the taskbar

    Hello WhizBang,

    It isn't clear to me why the button must be absent from the Taskbar. The user can not minimize the UserForm when clicking it on the Taskbar nor close it by clicking the "X". You stated you wanted the UserForm to remain visible all the time as a reminder to the user. The code meets those requirements. What is failing?

  11. #11
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Hide a form from the taskbar

    Nothing is failing. I just don't like the button in the taskbar. It serves no purpose and takes up space in the taskbar. I have had a few users complain that they have several windows open and it is annoying that one of the buttons cluttering up the taskbar space (and therefore shrinking the other buttons) is ultimately useless since they are aware that timing is in progress since the form is constantly open and on top.

    As I have said all along, this is only a minor issue, but one that, if possible, I would like to resolve. I am learning loads about how to interact with the Windows environment from Excel. I realize that, in this case, this feature is merely a luxury, but it'd be nice to know how for future projects.

  12. #12
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Hide a form from the taskbar

    Hello WhizBang,

    The only other way I know of would be to create a Hidden window that is the parent of the UserForm. This has so some serious problems. The UserForm would be created in a separate process. As it is now, the UserForm is created in the same process as Excel. When that process terminates, it must close all associated windows. If the UserForm is in a separate process, it's parent window is then responsible for relaying all messages to the child window. This requires writing a WndProc for the parent window. If the parent fails to close the child then all hell breaks loose and the system will throw a GPF and down it goes. Insuring that the hidden window is closed when Excel closes or errors is not trivial and quite complex.

  13. #13
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Hide a form from the taskbar

    Ok. Then for now I will say it is not a possible/plausible option.

    Thank you very, very much for all your time and assistance in the matter, Leith. Truly, you've been a great help.

    Marking thread as Solved.

  14. #14
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Hide a form from the taskbar

    Hello WhizBang,

    After writing that explanation, it hit me what needed to be done. This keeps the UserFom up in the corner with no button on the taskbar. The UserForm stays visible until Excel is minimized and reappears when Excel is restored. I have added the macros below to the attached workbook.

    Module1 Code
    Please Login or Register  to view this content.

    UserForm Code
    Please Login or Register  to view this content.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1