Move The Taskbar to the Top of Desktop

来源:互联网 发布:在线网络优化培训 编辑:程序博客网 时间:2024/05/17 21:57
 

Move The Taskbar to the Top of Desktop

To be more similar with Windows Mobile, First I want to move the Taskbar to top, so that the bottom we can add a softkey for the keypad use.

1、Just move the taskbar to top.
Change the code of function CTaskBbar::Show in taskbar.cpp, modify the show rect:

        rc.left = 0;
        rc.right = GetSystemMetrics(SM_CXSCREEN);

        ///Lex Luo 2008.06.17 + change the taskbar to top
        rc.bottom = TASKBAR_HEIGHT; ///GetSystemMetrics(SM_CYSCREEN);
        ///Lex Luo 2008.06.17 -
        rc.top = rc.bottom - TASKBAR_HEIGHT;

rebuild the project and sysgen the os, we can see that the taskbar had been move to top of desktop, but the icon of desktop was hide below the taskbar.

2、Move down the work area.
Move down the work area, so that the ICON should not be hide by the taskbar.
Change the code of function CTaskBar::SetWorkArea in taskbar.cpp, modify the rect of top:

    SystemParametersInfo(SPI_GETWORKAREA, 0, (void*)&rcWorkArea, 0);

    // if the taskbar isn't on top, the workarea is the screen
    SetRect(&rcWorkAreaNew, 0, 0, GetSystemMetrics(SM_CXSCREEN),
               GetSystemMetrics(SM_CYSCREEN));
    if (m_bTaskBarOnTop)
    {
        if (m_bTaskBarAutoHide)
        {
            ///Lex Luo 2008.06.17 + change the work area to bottom
                ///rcWorkAreaNew.bottom -= TASKBAR_HEIGHT_AUTOHIDE;
                rcWorkAreaNew.top += TASKBAR_HEIGHT_AUTOHIDE;
                ///Lex Luo 2008.06.17 -
        }
        else
        {
            ///Lex Luo 2008.06.17 + change the work area to bottom
                ///rcWorkAreaNew.bottom -= TASKBAR_HEIGHT;
        rcWorkAreaNew.top += TASKBAR_HEIGHT;
        ///Lex Luo 2008.06.17 -
        }
    }

        // currently, only the bottom will change
        ///Lex Luo 2008.06.17 + change to top
        ///if (rcWorkArea.bottom != rcWorkAreaNew.bottom)
    if (rcWorkArea.top != rcWorkAreaNew.top)
    ///Lex Luo 2008.06.17 -
        {
            SystemParametersInfo(SPI_SETWORKAREA, 0, (void*)&rcWorkAreaNew, SPIF_SENDCHANGE);
        MoveWindow(
            Desktop_GetWindow(),
            rcWorkAreaNew.left,
            rcWorkAreaNew.top,
            rcWorkAreaNew.right - rcWorkAreaNew.left,
            rcWorkAreaNew.bottom - rcWorkAreaNew.top,
            TRUE);
        }

after sysgen and build the os, we can see that the desktop first show at 0,0 and flash again move down below the taskbar. So we must change the first show of the desktop.

3、Change the desktop rect.
Go to desktop.cpp and change the rect in CDesktopwnd::Create function:

    fs.ViewMode = FVM_ICON;
    fs.fFlags = FWF_DESKTOP | FWF_ALIGNLEFT | FWF_NOSCROLL;

    ///Lex Luo 2008.06.19 + move down the desktop at first
        ///SetRect(&rc, 0, 0, GetSystemMetrics(SM_CXVIRTUALSCREEN), GetSystemMetrics(SM_CYVIRTUALSCREEN));
        SetRect(&rc, 0, 26, GetSystemMetrics(SM_CXVIRTUALSCREEN), GetSystemMetrics(SM_CYVIRTUALSCREEN));
    ///Lex Luo 2008.06.19 -
    // create the desktop's view window (no need to AddRef since CreateViewWindow does it)
    hr = _psv->CreateViewWindow(NULL,  &fs, (IShellBrowser *)this, &rc, &_hWnd);

So that we can see the desktop show below the taskbar. The other problem is that the start menu were show in 0,0 would hide the taskbar again.

4、Change the StartMenu show rect.
Go back to taskbar.cpp, and change the code in CTaskBar::StartMenu:

            ClientToScreen(hwnd, (LPPOINT)&rc);
            ClientToScreen(hwnd, (LPPOINT)&rc.right);

        ///Lex Luo 2008.06.18 + move down the start menu
                ///StartMenu_Track(TPM_LEFTALIGN | TPM_BOTTOMALIGN, rc.left, rc.top - 1,hwnd);
                StartMenu_Track(TPM_LEFTALIGN | TPM_TOPALIGN, rc.left, /*rc.top + */TASKBAR_HEIGHT,hwnd);
        ///Lex Luo 2008.06.18 -
            DrawItem(hwnd, hdc, 0, FALSE);

After there changes, we can see the taskbar at the top of desktop, and the work area show below the taskbar.Just finish the first work in WinCE.

imageimage

原创粉丝点击