Thread: Apps modify monitor work area

  1. #1
    Registered User
    Join Date
    Dec 2006
    Posts
    4

    Apps modify monitor work area

    I wrote this quick program to hide the taskbar with a hard-coded hotkey binding (I just needed it to work.. I actually use a binding that would never actually be pressed and use an extra mouse button to trigger it). Basically, hitting the hotkey will toggle the taskbar between being hidden or visible, and when the program first starts it changes the working area (the area of the monitor that programs can use) to take up the full screen, rather than lose the 30 pixels that the taskbar takes up.

    This worked fine until I noticed that every so often, the work area would revert to the default. It took me a little bit to figure it out, but it turns out that some apps or actions mess with the work area (the only one I've narrowed down is when you enable/disable a second monitor - there are others, but I've always noticed too late to pinpoint them). My first idea was to just add a timer that resets the work area at a regular interval, but that's just a quick-fix hack that I wouldn't be too happy with. It also occurred to me that there might be some way to detect a work area change, but that's out of the question because in practice, it would mean that my work area (and thus my open programs) resize, and then my toggler intercepts and resets it, and the programs end up staying shrunk until I resize them; this is far too noticeable. Does anyone have any ideas? I wrote the program in C# using P/Invoke to get access to the hotkey binders and other stuff.

    It's worth pointing out that while I was using Litestep, the taskbar wasn't running at all (Litestep is an explorer shell replacement). This meant that I had full screen real estate at all times, and since the taskbar wasn't running programs didn't resize the work area to adjust for it. So if there's some way to hide the fact that the taskbar is running, I think that would be an ideal solution. But I don't think there's any way to do that.

    Anyway, I'd really appreciate any input. I can upload the source code if need be. Thanks in advance!

    Edit: I just noticed that Windows Live Messenger resets the work area when it exits. Bloody annoying!
    Last edited by insanedesio; 12-22-2006 at 03:56 AM.

  2. #2
    Registered User
    Join Date
    Dec 2006
    Posts
    4
    Wow, thanks for the help >.<

  3. #3
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,058
    ]
    Anyway, I'd really appreciate any input. I can upload the source code if need be
    Post your code. Let's take a look at it.

    EDIT:

    Have you tried to disable the taskbar window after hiding it using EnableWindow?
    Last edited by BobS0327; 12-25-2006 at 09:04 PM.

  4. #4
    Registered User
    Join Date
    Dec 2006
    Posts
    4
    That was a good idea; unfortunately, it didn't work, and also stopped the taskbar from updating itself visually (though mouseover tooltips were updated).

    As for the source code, my coding style is pretty modular so the code is split across multiple files; it would be a bit unorganized to post all the needed code here. Instead I've uploaded it in a zip file.

  5. #5
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,058
    Maybe ITaskbarList2::MarkFullscreenWindow Method can be useful.

    Also, I believe I've found a quirk in your TBtool. When I open a lot of applications (5 or more) and minimize them to the taskbar and hotkey repeatedly, the apps would get mixed up. For example, if I try to maximize app4, app2 will appear instead of app4, trying to maximize app5 is impossible, but app1 and app2 will work properly. This quirk left me with no choice but to reboot the system.

    EDIT:

    Or possibly use SHAppBarMessage? A C example follows:

    Code:
    #include <windows.h>
    
    void AutoHide(void)
    {
        HWND hWnd = FindWindow("Shell_traywnd", NULL);
        APPBARDATA AppBarData;
        AppBarData.hWnd = hWnd;
        AppBarData.cbSize = sizeof(AppBarData);
        SHAppBarMessage(ABM_GETSTATE, &AppBarData);
        AppBarData.lParam = ABS_AUTOHIDE | ABS_ALWAYSONTOP;
        SHAppBarMessage(ABM_SETSTATE, &AppBarData);
    }
    
    int main(void)
    {
        AutoHide();
        return 0;
    }
    Last edited by BobS0327; 01-03-2007 at 09:05 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Windows apps verses Console apps
    By nano78 in forum Windows Programming
    Replies: 8
    Last Post: 09-22-2007, 03:41 AM
  2. area of a circle
    By wise_ron in forum C Programming
    Replies: 2
    Last Post: 10-02-2006, 03:15 PM
  3. very weird problem (pointers I think)
    By hannibar in forum C Programming
    Replies: 2
    Last Post: 10-11-2005, 06:45 AM
  4. Need help with switch
    By 3kgt in forum C Programming
    Replies: 2
    Last Post: 02-26-2003, 12:43 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM