mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 02:25:17 +00:00
implemented context menus for task bar
svn path=/trunk/; revision=5801
This commit is contained in:
parent
4d265e45f4
commit
20228bbf5d
9 changed files with 99 additions and 29 deletions
|
@ -1,6 +1,8 @@
|
|||
- extend shell view code in Wine
|
||||
- context menus for task bar and quick launch bar
|
||||
- tool tip texts for notification icons and clock display
|
||||
- context menus for quick launch bar
|
||||
- add rebars for resizable task bar, quick launch bar and notification area
|
||||
- handling of full screen applications
|
||||
- implement additional deskbands
|
||||
- Drag Drop on desktop does not work.
|
||||
- implement Drag Drop from the tree view.
|
||||
|
|
|
@ -21,3 +21,7 @@
|
|||
Start menu popup is now closed when clicking in another window.
|
||||
22.08.2003 m. fuchs implemented clock display in tray notification area
|
||||
implemented quick launch bar
|
||||
23.08.2003 m. fuchs implemented "Run..." dialog by calling shell32.dll
|
||||
fixed memory and GDI handle leaks
|
||||
implemented context menus for task bar
|
||||
tool tips for quick launch bar
|
||||
|
|
|
@ -114,7 +114,7 @@ int explorer_main(HINSTANCE hInstance, HWND hwndDesktop, int cmdshow)
|
|||
OleInit usingCOM;
|
||||
|
||||
// initialize Common Controls library
|
||||
CommonControlInit usingCmnCtrl(ICC_LISTVIEW_CLASSES|ICC_TREEVIEW_CLASSES|ICC_BAR_CLASSES);
|
||||
CommonControlInit usingCmnCtrl;
|
||||
|
||||
try {
|
||||
InitInstance(hInstance);
|
||||
|
|
|
@ -72,6 +72,7 @@ MainFrame::MainFrame(HWND hwnd)
|
|||
_htoolbar = CreateToolbarEx(hwnd, WS_CHILD|WS_VISIBLE,
|
||||
IDW_TOOLBAR, 2, g_Globals._hInstance, IDB_TOOLBAR, toolbarBtns,
|
||||
sizeof(toolbarBtns)/sizeof(TBBUTTON), 16, 15, 16, 15, sizeof(TBBUTTON));
|
||||
|
||||
CheckMenuItem(_menu_info._hMenuOptions, ID_VIEW_TOOL_BAR, MF_BYCOMMAND|MF_CHECKED);
|
||||
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@ HWND InitializeExplorerBar(HINSTANCE hInstance)
|
|||
|
||||
DesktopBar::DesktopBar(HWND hwnd)
|
||||
: super(hwnd),
|
||||
// initialize Common Controls library
|
||||
WM_TASKBARCREATED(RegisterWindowMessage(WINMSG_TASKBARCREATED))
|
||||
{
|
||||
SystemParametersInfo(SPI_GETWORKAREA, 0, &_work_area_org, 0);
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
|
||||
#define CLASSNAME_EXPLORERBAR _T("Shell_TrayWnd")
|
||||
#define TITLE_EXPLORERBAR _T("DesktopBar") //_T("")
|
||||
#define TITLE_EXPLORERBAR _T("") // use an empty window title, so windows taskmanager does not show the window in its application list
|
||||
|
||||
|
||||
#define WINMSG_TASKBARCREATED _T("TaskbarCreated")
|
||||
|
@ -64,6 +64,8 @@ struct DesktopBar : public OwnerDrawParent<Window>
|
|||
~DesktopBar();
|
||||
|
||||
protected:
|
||||
CommonControlInit _usingCmnCtrl;
|
||||
|
||||
int WM_TASKBARCREATED;
|
||||
RECT _work_area_org;
|
||||
|
||||
|
|
|
@ -80,9 +80,9 @@ LRESULT TaskBar::Init(LPCREATESTRUCT pcs)
|
|||
return 1;
|
||||
|
||||
_htoolbar = CreateToolbarEx(_hwnd,
|
||||
WS_CHILD|WS_VISIBLE|CCS_NODIVIDER|CCS_TOP|
|
||||
TBSTYLE_LIST|TBSTYLE_TOOLTIPS|TBSTYLE_WRAPABLE,
|
||||
IDW_TASKTOOLBAR, 0, 0, 0, NULL, 0, 0, 0, 16, 16, sizeof(TBBUTTON));
|
||||
WS_CHILD|WS_VISIBLE|CCS_NODIVIDER|CCS_TOP|
|
||||
TBSTYLE_LIST|TBSTYLE_TOOLTIPS|TBSTYLE_WRAPABLE,
|
||||
IDW_TASKTOOLBAR, 0, 0, 0, NULL, 0, 0, 0, 16, 16, sizeof(TBBUTTON));
|
||||
|
||||
SendMessage(_htoolbar, TB_SETBUTTONWIDTH, 0, MAKELONG(80,160));
|
||||
//SendMessage(_htoolbar, TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_MIXEDBUTTONS);
|
||||
|
@ -103,9 +103,6 @@ LRESULT TaskBar::Init(LPCREATESTRUCT pcs)
|
|||
LRESULT TaskBar::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
switch(nmsg) {
|
||||
/* case WM_CLOSE:
|
||||
break; */
|
||||
|
||||
case WM_SIZE:
|
||||
SendMessage(_htoolbar, WM_SIZE, 0, 0);
|
||||
break;
|
||||
|
@ -142,29 +139,75 @@ int TaskBar::Command(int id, int code)
|
|||
TaskBarMap::iterator found = _map.find_id(id);
|
||||
|
||||
if (found != _map.end()) {
|
||||
HWND hwnd = found->first;
|
||||
|
||||
if (hwnd==GetForegroundWindow() || hwnd==_last_foreground_wnd) {
|
||||
ShowWindowAsync(hwnd, SW_MINIMIZE);
|
||||
_last_foreground_wnd = 0;
|
||||
} else {
|
||||
// switch to selected application window
|
||||
if (IsIconic(hwnd))
|
||||
ShowWindowAsync(hwnd, SW_RESTORE);
|
||||
|
||||
SetForegroundWindow(hwnd);
|
||||
|
||||
_last_foreground_wnd = hwnd;
|
||||
}
|
||||
|
||||
Refresh();
|
||||
|
||||
ActivateApp(found);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return super::Command(id, code);
|
||||
}
|
||||
|
||||
int TaskBar::Notify(int id, NMHDR* pnmh)
|
||||
{
|
||||
if (pnmh->hwndFrom == _htoolbar)
|
||||
switch(pnmh->code) {
|
||||
case NM_RCLICK: {
|
||||
TaskBarMap::iterator it;
|
||||
Point pt(GetMessagePos());
|
||||
ScreenToClient(_htoolbar, &pt);
|
||||
|
||||
int idx = SendMessage(_htoolbar, TB_HITTEST, 0, (LPARAM)&pt);
|
||||
|
||||
if (idx>=0 && (it=_map.find_by_idx(idx))!=_map.end()) {
|
||||
TaskBarEntry& entry = it->second;
|
||||
|
||||
ActivateApp(it, false);
|
||||
ShowAppSystemMenu(it);
|
||||
}
|
||||
break;}
|
||||
|
||||
default:
|
||||
return super::Notify(id, pnmh);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void TaskBar::ActivateApp(TaskBarMap::iterator it, bool can_minimize)
|
||||
{
|
||||
HWND hwnd = it->first;
|
||||
|
||||
if (can_minimize && (hwnd==GetForegroundWindow() || hwnd==_last_foreground_wnd)) {
|
||||
ShowWindowAsync(hwnd, SW_MINIMIZE);
|
||||
_last_foreground_wnd = 0;
|
||||
} else {
|
||||
// switch to selected application window
|
||||
if (IsIconic(hwnd))
|
||||
ShowWindowAsync(hwnd, SW_RESTORE);
|
||||
|
||||
SetForegroundWindow(hwnd);
|
||||
|
||||
_last_foreground_wnd = hwnd;
|
||||
}
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void TaskBar::ShowAppSystemMenu(TaskBarMap::iterator it)
|
||||
{
|
||||
HMENU hmenu = GetSystemMenu(it->first, FALSE);
|
||||
|
||||
if (hmenu) {
|
||||
POINT pt;
|
||||
|
||||
GetCursorPos(&pt);
|
||||
int cmd = TrackPopupMenu(hmenu, TPM_LEFTBUTTON|TPM_RIGHTBUTTON|TPM_RETURNCMD, pt.x, pt.y, 0, _hwnd, NULL);
|
||||
|
||||
if (cmd)
|
||||
PostMessage(it->first, WM_SYSCOMMAND, cmd, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static HICON get_window_icon(HWND hwnd)
|
||||
{
|
||||
|
@ -348,3 +391,12 @@ TaskBarMap::iterator TaskBarMap::find_id(int id)
|
|||
|
||||
return end();
|
||||
}
|
||||
|
||||
TaskBarMap::iterator TaskBarMap::find_by_idx(int idx)
|
||||
{
|
||||
for(iterator it=begin(); it!=end(); ++it)
|
||||
if (it->second._btn_idx == idx)
|
||||
return it;
|
||||
|
||||
return end();
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
|
||||
#define IDW_TASKTOOLBAR 100
|
||||
|
||||
|
||||
/// internal task bar button management entry
|
||||
struct TaskBarEntry
|
||||
{
|
||||
|
@ -55,15 +56,15 @@ struct TaskBarEntry
|
|||
BYTE _fsState;
|
||||
};
|
||||
|
||||
/// map for managing the task bar buttons
|
||||
/// map for managing the task bar buttons, mapped by application window handle
|
||||
struct TaskBarMap : public map<HWND, TaskBarEntry>
|
||||
{
|
||||
~TaskBarMap();
|
||||
|
||||
iterator find_id(int id);
|
||||
iterator find_by_idx(int idx);
|
||||
};
|
||||
|
||||
struct DesktopBar;
|
||||
|
||||
/// Taskbar window
|
||||
struct TaskBar : public Window
|
||||
|
@ -84,6 +85,10 @@ protected:
|
|||
LRESULT Init(LPCREATESTRUCT pcs);
|
||||
LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
|
||||
int Command(int id, int code);
|
||||
int Notify(int id, NMHDR* pnmh);
|
||||
|
||||
void ActivateApp(TaskBarMap::iterator it, bool can_minimize=true);
|
||||
void ShowAppSystemMenu(TaskBarMap::iterator it);
|
||||
|
||||
static BOOL CALLBACK EnumWndProc(HWND hwnd, LPARAM lparam);
|
||||
|
||||
|
|
|
@ -49,6 +49,9 @@
|
|||
#define BTNS_BUTTON TBSTYLE_BUTTON //TODO: should be in mingw headers
|
||||
#define BTNS_SEP TBSTYLE_SEP
|
||||
#endif
|
||||
#ifndef TB_HITTEST //missing in mingw headers
|
||||
#define TB_HITTEST (WM_USER+69)
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -83,7 +86,7 @@ using namespace _com_util;
|
|||
|
||||
struct CommonControlInit
|
||||
{
|
||||
CommonControlInit(DWORD flags=ICC_LISTVIEW_CLASSES)
|
||||
CommonControlInit(DWORD flags=ICC_LISTVIEW_CLASSES|ICC_TREEVIEW_CLASSES|ICC_BAR_CLASSES|ICC_PROGRESS_CLASS|ICC_COOL_CLASSES)
|
||||
{
|
||||
INITCOMMONCONTROLSEX icc = {sizeof(INITCOMMONCONTROLSEX), flags};
|
||||
|
||||
|
|
Loading…
Reference in a new issue