desktop bar window, also known as "system tray" More...
#include <desktopbar.h>
Public Types | |
typedef OwnerDrawParent< Window > | super |
Public Member Functions | |
DesktopBar (HWND hwnd) | |
~DesktopBar () | |
Static Public Member Functions | |
static HWND | Create () |
Protected Member Functions | |
LRESULT | Init (LPCREATESTRUCT pcs) |
LRESULT | WndProc (UINT nmsg, WPARAM wparam, LPARAM lparam) |
int | Notify (int id, NMHDR *pnmh) |
int | Command (int id, int code) |
void | Resize (int cx, int cy) |
void | ControlResize (WPARAM wparam, LPARAM lparam) |
void | RegisterHotkeys () |
void | ProcessHotKey (int id_hotkey) |
void | ShowStartMenu () |
LRESULT | ProcessCopyData (COPYDATASTRUCT *pcd) |
Protected Attributes | |
RECT | _work_area_org |
int | _taskbar_pos |
WindowHandle | _hwndTaskBar |
WindowHandle | _hwndNotify |
WindowHandle | _hwndQuickLaunch |
WindowHandle | _hwndrebar |
WindowHandle | _hwndStartButton |
struct StartMenuRoot * | _startMenuRoot |
const UINT | WM_TASKBARCREATED |
desktop bar window, also known as "system tray"
Definition at line 68 of file desktopbar.h.
typedef OwnerDrawParent<Window> DesktopBar::super |
Reimplemented from OwnerDrawParent< Window >.
Definition at line 80 of file desktopbar.h.
DesktopBar::DesktopBar | ( | HWND | hwnd ) |
Definition at line 42 of file desktopbar.cpp.
References _work_area_org, IDI_REACTOS, and SetWindowIcon().
: super(hwnd), #ifdef __REACTOS__ _trayIcon(hwnd, ID_TRAY_VOLUME) #else WM_TASKBARCREATED(RegisterWindowMessage(WINMSG_TASKBARCREATED)) #endif { SetWindowIcon(hwnd, IDI_REACTOS); SystemParametersInfo(SPI_GETWORKAREA, 0, &_work_area_org, 0); }
DesktopBar::~DesktopBar | ( | ) |
Definition at line 55 of file desktopbar.cpp.
References _work_area_org.
{ // restore work area to the previous size SystemParametersInfo(SPI_SETWORKAREA, 0, &_work_area_org, 0); PostMessage(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETWORKAREA, 0); // exit application after destroying desktop window PostQuitMessage(0); }
int DesktopBar::Command | ( | int | id, |
int | code | ||
) | [protected, virtual] |
Reimplemented from Window.
Definition at line 401 of file desktopbar.cpp.
References ExplorerGlobals::_desktops, WindowHandle::_hwnd, ExplorerGlobals::_hwndDesktop, _hwndQuickLaunch, explorer_about(), explorer_show_frame(), ExplorerPropertySheet(), g_Globals, ID_ABOUT_EXPLORER, ID_DESKTOPBAR_SETTINGS, ID_EXPLORE, ID_MINIMIZE_ALL, ID_SWITCH_DESKTOP_1, ID_TASKMGR, ID_TRAY_VOLUME, ID_VOLUME_PROPERTIES, IDC_START, launch_cpanel(), launch_file(), PM_UPDATE_DESKTOP, ShowStartMenu(), Desktops::SwitchToDesktop(), TEXT, and Desktops::ToggleMinimize().
{ switch(id) { case IDC_START: ShowStartMenu(); break; case ID_ABOUT_EXPLORER: explorer_about(g_Globals._hwndDesktop); break; case ID_DESKTOPBAR_SETTINGS: ExplorerPropertySheet(g_Globals._hwndDesktop); break; case ID_MINIMIZE_ALL: g_Globals._desktops.ToggleMinimize(); break; case ID_EXPLORE: explorer_show_frame(SW_SHOWNORMAL); break; case ID_TASKMGR: launch_file(_hwnd, TEXT("taskmgr.exe"), SW_SHOWNORMAL); break; case ID_SWITCH_DESKTOP_1: case ID_SWITCH_DESKTOP_1+1: case ID_SWITCH_DESKTOP_1+2: case ID_SWITCH_DESKTOP_1+3: { int desktop_idx = id - ID_SWITCH_DESKTOP_1; g_Globals._desktops.SwitchToDesktop(desktop_idx); if (_hwndQuickLaunch) PostMessage(_hwndQuickLaunch, PM_UPDATE_DESKTOP, desktop_idx, 0); break;} #ifdef __REACTOS__ case ID_TRAY_VOLUME: launch_file(_hwnd, TEXT("sndvol32.exe"), SW_SHOWNORMAL); // launch volume control application break; case ID_VOLUME_PROPERTIES: launch_cpanel(_hwnd, TEXT("mmsys.cpl")); break; #endif default: if (_hwndQuickLaunch) return SendMessage(_hwndQuickLaunch, WM_COMMAND, MAKEWPARAM(id,code), 0); else return 1; } return 0; }
void DesktopBar::ControlResize | ( | WPARAM | wparam, |
LPARAM | lparam | ||
) | [protected] |
Definition at line 500 of file desktopbar.cpp.
References DESKTOPBARBAR_HEIGHT.
Referenced by WndProc().
{ PRECT dragRect = (PRECT) lparam; //int screenWidth = GetSystemMetrics(SM_CXSCREEN); int screenHeight = GetSystemMetrics(SM_CYSCREEN); ///@todo write code for taskbar being at sides or top. switch(wparam) { case WMSZ_BOTTOM: ///@todo Taskbar is at the top of the screen break; case WMSZ_TOP: // Taskbar is at the bottom of the screen dragRect->top = screenHeight - (((screenHeight - dragRect->top) + DESKTOPBARBAR_HEIGHT/2) / DESKTOPBARBAR_HEIGHT) * DESKTOPBARBAR_HEIGHT; if (dragRect->top < screenHeight / 2) dragRect->top = screenHeight - (screenHeight/2 / DESKTOPBARBAR_HEIGHT * DESKTOPBARBAR_HEIGHT); else if (dragRect->top > screenHeight - 5) dragRect->top = screenHeight - 5; break; case WMSZ_RIGHT: ///@todo Taskbar is at the left of the screen break; case WMSZ_LEFT: ///@todo Taskbar is at the right of the screen break; } }
HWND DesktopBar::Create | ( | ) | [static] |
Definition at line 66 of file desktopbar.cpp.
References CLASSNAME_EXPLORERBAR, DESKTOPBARBAR_HEIGHT, TITLE_EXPLORERBAR, and WINDOW_CREATOR.
Referenced by Init().
{ static BtnWindowClass wcDesktopBar(CLASSNAME_EXPLORERBAR); RECT rect; rect.left = -2; // hide left border #ifdef TASKBAR_AT_TOP rect.top = -2; // hide top border #else rect.top = GetSystemMetrics(SM_CYSCREEN) - DESKTOPBARBAR_HEIGHT; #endif rect.right = GetSystemMetrics(SM_CXSCREEN) + 2; rect.bottom = rect.top + DESKTOPBARBAR_HEIGHT + 2; return Window::Create(WINDOW_CREATOR(DesktopBar), WS_EX_PALETTEWINDOW, wcDesktopBar, TITLE_EXPLORERBAR, WS_POPUP|WS_THICKFRAME|WS_CLIPCHILDREN|WS_VISIBLE, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, 0); }
LRESULT DesktopBar::Init | ( | LPCREATESTRUCT | pcs ) | [protected, virtual] |
Reimplemented from Window.
Definition at line 88 of file desktopbar.cpp.
References ExplorerGlobals::_hInstance, WindowHandle::_hwnd, _hwndNotify, _hwndQuickLaunch, _hwndrebar, StartMenuRoot::_hwndStartButton, _hwndStartButton, _hwndTaskBar, _startMenuRoot, _taskbar_pos, StartMenuRoot::Create(), Create(), g_Globals, GET_WINDOW, HWND, IDC_START, IDS_START, IDW_QUICKLAUNCHBAR, IDW_TASKTOOLBAR, Window::Init(), RBBS_HIDETITLE, REBARBAND_HEIGHT, RegisterHotkeys(), STARTMENUROOT_ICON_SIZE, and WM_TASKBARCREATED.
{ if (super::Init(pcs)) return 1; // create start button ResString start_str(IDS_START); WindowCanvas canvas(_hwnd); RECT rect = {0, 0}; DrawText(canvas, start_str, -1, &rect, DT_SINGLELINE|DT_CALCRECT); int start_btn_width = rect.right+16+8; _taskbar_pos = start_btn_width + 6; // create "Start" button HWND hwndStart = Button(_hwnd, start_str, 1, 1, start_btn_width, REBARBAND_HEIGHT, IDC_START, WS_VISIBLE|WS_CHILD|BS_OWNERDRAW); new StartButton(hwndStart); /* Save the handle to the window, needed for push-state handling */ _hwndStartButton = hwndStart; // disable double clicks SetClassLong(hwndStart, GCL_STYLE, GetClassLong(hwndStart, GCL_STYLE) & ~CS_DBLCLKS); // create task bar _hwndTaskBar = TaskBar::Create(_hwnd); #ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003) if (!g_Globals._SHRestricted || !SHRestricted(REST_NOTRAYITEMSDISPLAY)) #endif // create tray notification area _hwndNotify = NotifyArea::Create(_hwnd); // notify all top level windows about the successfully created desktop bar //@@ Use SendMessage() instead of PostMessage() to avoid problems with delayed created shell service objects? PostMessage(HWND_BROADCAST, WM_TASKBARCREATED, 0, 0); _hwndQuickLaunch = QuickLaunchBar::Create(_hwnd); // create rebar window to manage task and quick launch bar #ifndef _NO_REBAR _hwndrebar = CreateWindowEx(WS_EX_TOOLWINDOW, REBARCLASSNAME, NULL, WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN| RBS_VARHEIGHT|RBS_AUTOSIZE|RBS_DBLCLKTOGGLE| //|RBS_REGISTERDROP CCS_NODIVIDER|CCS_NOPARENTALIGN|CCS_TOP, 0, 0, 0, 0, _hwnd, 0, g_Globals._hInstance, 0); REBARBANDINFO rbBand; rbBand.cbSize = sizeof(REBARBANDINFO); rbBand.fMask = RBBIM_TEXT|RBBIM_STYLE|RBBIM_CHILD|RBBIM_CHILDSIZE|RBBIM_SIZE|RBBIM_ID|RBBIM_IDEALSIZE; #ifndef RBBS_HIDETITLE // missing in MinGW headers as of 25.02.2004 #define RBBS_HIDETITLE 0x400 #endif rbBand.cyChild = REBARBAND_HEIGHT; rbBand.cyMaxChild = (ULONG)-1; rbBand.cyMinChild = REBARBAND_HEIGHT; rbBand.cyIntegral = REBARBAND_HEIGHT + 3; //@@ OK? rbBand.cxMinChild = rbBand.cyIntegral * 3; rbBand.fStyle = RBBS_VARIABLEHEIGHT|RBBS_GRIPPERALWAYS|RBBS_HIDETITLE; TCHAR QuickLaunchBand[] = _T("Quicklaunch"); rbBand.lpText = QuickLaunchBand; rbBand.hwndChild = _hwndQuickLaunch; rbBand.cx = 250; rbBand.wID = IDW_QUICKLAUNCHBAR; SendMessage(_hwndrebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbBand); TCHAR TaskbarBand[] = _T("Taskbar"); rbBand.lpText = TaskbarBand; rbBand.hwndChild = _hwndTaskBar; rbBand.cx = 200; //pcs->cx-_taskbar_pos-quicklaunch_width-(notifyarea_width+1); rbBand.wID = IDW_TASKTOOLBAR; SendMessage(_hwndrebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbBand); #endif RegisterHotkeys(); // prepare Startmenu, but hide it for now _startMenuRoot = GET_WINDOW(StartMenuRoot, StartMenuRoot::Create(_hwnd, STARTMENUROOT_ICON_SIZE)); _startMenuRoot->_hwndStartButton = _hwndStartButton; return 0; }
int DesktopBar::Notify | ( | int | id, |
NMHDR * | pnmh | ||
) | [protected, virtual] |
Reimplemented from Window.
Definition at line 352 of file desktopbar.cpp.
References IDW_TASKTOOLBAR.
{ if (pnmh->code == RBN_CHILDSIZE) { /* align the task bands to the top, so it's in row with the Start button */ NMREBARCHILDSIZE* childSize = (NMREBARCHILDSIZE*)pnmh; if (childSize->wID == IDW_TASKTOOLBAR) { int cy = childSize->rcChild.top - childSize->rcBand.top; if (cy) { childSize->rcChild.bottom -= cy; childSize->rcChild.top -= cy; } } } return 0; }
LRESULT DesktopBar::ProcessCopyData | ( | COPYDATASTRUCT * | pcd ) | [protected] |
Definition at line 484 of file desktopbar.cpp.
References _hwndNotify, GET_WINDOW, TrayNotifyCDS::nicon_data, and TrayNotifyCDS::notify_code.
Referenced by WndProc().
{ // Is this a tray notification message? if (pcd->dwData == 1) { TrayNotifyCDS* ptr = (TrayNotifyCDS*) pcd->lpData; NotifyArea* notify_area = GET_WINDOW(NotifyArea, _hwndNotify); if (notify_area) return notify_area->ProcessTrayNotification(ptr->notify_code, &ptr->nicon_data); } return FALSE; }
void DesktopBar::ProcessHotKey | ( | int | id_hotkey ) | [protected] |
Definition at line 250 of file desktopbar.cpp.
References explorer_show_frame().
Referenced by WndProc().
{ switch(id_hotkey) { case 0: explorer_show_frame(SW_SHOWNORMAL); break; ///@todo implement all common hotkeys } }
void DesktopBar::RegisterHotkeys | ( | ) | [protected] |
Definition at line 242 of file desktopbar.cpp.
References WindowHandle::_hwnd.
Referenced by Init().
{ // register hotkey WIN+E opening explorer RegisterHotKey(_hwnd, 0, MOD_WIN, 'E'); ///@todo register all common hotkeys }
void DesktopBar::Resize | ( | int | cx, |
int | cy | ||
) | [protected] |
Definition at line 371 of file desktopbar.cpp.
References WindowHandle::_hwnd, _hwndNotify, _hwndQuickLaunch, _hwndrebar, _hwndTaskBar, _taskbar_pos, and PM_GET_WIDTH.
Referenced by WndProc().
{ ///@todo general children resizing algorithm int quicklaunch_width = SendMessage(_hwndQuickLaunch, PM_GET_WIDTH, 0, 0); int notifyarea_width = SendMessage(_hwndNotify, PM_GET_WIDTH, 0, 0); HDWP hdwp = BeginDeferWindowPos(3); if (_hwndrebar) DeferWindowPos(hdwp, _hwndrebar, 0, _taskbar_pos, 1, cx-_taskbar_pos-(notifyarea_width+1), cy-2, SWP_NOZORDER|SWP_NOACTIVATE); else { if (_hwndQuickLaunch) DeferWindowPos(hdwp, _hwndQuickLaunch, 0, _taskbar_pos, 1, quicklaunch_width, cy-2, SWP_NOZORDER|SWP_NOACTIVATE); if (_hwndTaskBar) DeferWindowPos(hdwp, _hwndTaskBar, 0, _taskbar_pos+quicklaunch_width, 0, cx-_taskbar_pos-quicklaunch_width-(notifyarea_width+1), cy, SWP_NOZORDER|SWP_NOACTIVATE); } if (_hwndNotify) DeferWindowPos(hdwp, _hwndNotify, 0, cx-(notifyarea_width+1), 1, notifyarea_width, cy-2, SWP_NOZORDER|SWP_NOACTIVATE); EndDeferWindowPos(hdwp); WindowRect rect(_hwnd); RECT work_area = {0, 0, GetSystemMetrics(SM_CXSCREEN), rect.top}; SystemParametersInfo(SPI_SETWORKAREA, 0, &work_area, 0); // don't use SPIF_SENDCHANGE because then we have to wait for any message being delivered PostMessage(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETWORKAREA, 0); }
void DesktopBar::ShowStartMenu | ( | ) | [protected] |
Definition at line 461 of file desktopbar.cpp.
References _hwndStartButton, _startMenuRoot, and StartMenuRoot::TrackStartmenu().
Referenced by Command(), and WndProc().
{ if (_startMenuRoot) { // set the Button, if not set if (!Button_GetState(_hwndStartButton)) Button_SetState(_hwndStartButton, TRUE); _startMenuRoot->TrackStartmenu(); // StartMenu was closed, release button state Button_SetState(_hwndStartButton, false); } }
LRESULT DesktopBar::WndProc | ( | UINT | nmsg, |
WPARAM | wparam, | ||
LPARAM | lparam | ||
) | [protected, virtual] |
Reimplemented from OwnerDrawParent< Window >.
Definition at line 261 of file desktopbar.cpp.
References WindowHandle::_hwnd, _hwndNotify, _hwndTaskBar, ControlResize(), HWND, ID_TRAY_VOLUME, IDM_DESKTOPBAR, launch_file(), PM_GET_LAST_ACTIVE, PM_GET_NOTIFYAREA, PM_REFRESH_CONFIG, PM_RESIZE_CHILDREN, ProcessCopyData(), ProcessHotKey(), Resize(), ShowExitWindowsDialog(), ShowStartMenu(), TEXT, PopupMenu::TrackPopupMenu(), and OwnerDrawParent< Window >::WndProc().
{ switch(nmsg) { case WM_NCHITTEST: { LRESULT res = super::WndProc(nmsg, wparam, lparam); if (res>=HTSIZEFIRST && res<=HTSIZELAST) { #ifdef TASKBAR_AT_TOP if (res == HTBOTTOM) // enable vertical resizing at the lower border #else if (res == HTTOP) // enable vertical resizing at the upper border #endif return res; else return HTCLIENT; // disable any other resizing } return res;} case WM_SYSCOMMAND: if ((wparam&0xFFF0) == SC_SIZE) { #ifdef TASKBAR_AT_TOP if (wparam == SC_SIZE+6)// enable vertical resizing at the lower border #else if (wparam == SC_SIZE+3)// enable vertical resizing at the upper border #endif goto def; else return 0; // disable any other resizing } else if (wparam == SC_TASKLIST) ShowStartMenu(); goto def; case WM_SIZE: Resize(LOWORD(lparam), HIWORD(lparam)); break; case WM_SIZING: ControlResize(wparam, lparam); break; case PM_RESIZE_CHILDREN: { ClientRect size(_hwnd); Resize(size.right, size.bottom); break;} case WM_CLOSE: ShowExitWindowsDialog(_hwnd); break; case WM_HOTKEY: ProcessHotKey(wparam); break; case WM_COPYDATA: return ProcessCopyData((COPYDATASTRUCT*)lparam); case WM_CONTEXTMENU: { POINTS p; p.x = LOWORD(lparam); p.y = HIWORD(lparam); PopupMenu menu(IDM_DESKTOPBAR); SetMenuDefaultItem(menu, 0, MF_BYPOSITION); menu.TrackPopupMenu(_hwnd, p); break;} case PM_GET_LAST_ACTIVE: if (_hwndTaskBar) return SendMessage(_hwndTaskBar, nmsg, wparam, lparam); break; case PM_REFRESH_CONFIG: ///@todo read desktop bar settings SendMessage(_hwndNotify, PM_REFRESH_CONFIG, 0, 0); break; case WM_TIMER: if (wparam == ID_TRAY_VOLUME) { KillTimer(_hwnd, wparam); launch_file(_hwnd, TEXT("sndvol32.exe"), SW_SHOWNORMAL, TEXT("-t")); // launch volume control in small mode } break; case PM_GET_NOTIFYAREA: return (LRESULT)(HWND)_hwndNotify; default: def: return super::WndProc(nmsg, wparam, lparam); } return 0; }
WindowHandle DesktopBar::_hwndNotify [protected] |
Definition at line 105 of file desktopbar.h.
Referenced by Init(), ProcessCopyData(), Resize(), and WndProc().
WindowHandle DesktopBar::_hwndQuickLaunch [protected] |
Definition at line 106 of file desktopbar.h.
WindowHandle DesktopBar::_hwndrebar [protected] |
Definition at line 107 of file desktopbar.h.
WindowHandle DesktopBar::_hwndStartButton [protected] |
Definition at line 109 of file desktopbar.h.
Referenced by Init(), and ShowStartMenu().
WindowHandle DesktopBar::_hwndTaskBar [protected] |
Definition at line 104 of file desktopbar.h.
struct StartMenuRoot* DesktopBar::_startMenuRoot [protected] |
Definition at line 111 of file desktopbar.h.
Referenced by Init(), and ShowStartMenu().
int DesktopBar::_taskbar_pos [protected] |
Definition at line 90 of file desktopbar.h.
RECT DesktopBar::_work_area_org [protected] |
Definition at line 89 of file desktopbar.h.
Referenced by DesktopBar(), and ~DesktopBar().
const UINT DesktopBar::WM_TASKBARCREATED [protected] |
Definition at line 120 of file desktopbar.h.
Referenced by Init().
ROS Explorer Source Code Documentation
generated on 02.01.2013 by ![]() |