mirror of
https://github.com/reactos/reactos.git
synced 2024-08-08 04:08:29 +00:00
refresh attributes of existing taskbar buttons
svn path=/trunk/; revision=5617
This commit is contained in:
parent
76a258b41b
commit
6fba0a4d96
|
@ -332,10 +332,6 @@ SOURCE=.\res\toolbar.bmp
|
||||||
# PROP Default_Filter ""
|
# PROP Default_Filter ""
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\taskbar\shellhook.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=.\taskbar\taskbar.cpp
|
SOURCE=.\taskbar\taskbar.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
|
@ -68,6 +68,7 @@ struct String
|
||||||
: public string
|
: public string
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
String& operator=(LPCTSTR s) {assign(s); return *this;}
|
||||||
operator LPCTSTR() const {return c_str();}
|
operator LPCTSTR() const {return c_str();}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -209,6 +209,17 @@ static HBITMAP create_bitmap_from_icon(HICON hicon, HWND hwnd, HBRUSH hbrush_bkg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
TaskBarEntry::TaskBarEntry()
|
||||||
|
{
|
||||||
|
_id = 0;
|
||||||
|
_hbmp = 0;
|
||||||
|
_bmp_idx = 0;
|
||||||
|
_used = 0;
|
||||||
|
_btn_idx = 0;
|
||||||
|
_fsState = 0;
|
||||||
|
}
|
||||||
|
|
||||||
TaskBarMap::~TaskBarMap()
|
TaskBarMap::~TaskBarMap()
|
||||||
{
|
{
|
||||||
while(!empty()) {
|
while(!empty()) {
|
||||||
|
@ -329,6 +340,11 @@ BOOL CALLBACK TaskBar::EnumWndProc(HWND hwnd, LPARAM lparam)
|
||||||
!GetParent(hwnd) && !GetWindow(hwnd,GW_OWNER)) {
|
!GetParent(hwnd) && !GetWindow(hwnd,GW_OWNER)) {
|
||||||
TBBUTTON btn = {-2/*I_IMAGENONE*/, 0, TBSTATE_ENABLED/*|TBSTATE_ELLIPSES*/, BTNS_BUTTON, {0, 0}, 0, 0};
|
TBBUTTON btn = {-2/*I_IMAGENONE*/, 0, TBSTATE_ENABLED/*|TBSTATE_ELLIPSES*/, BTNS_BUTTON, {0, 0}, 0, 0};
|
||||||
|
|
||||||
|
TCHAR title[BUFFER_LEN];
|
||||||
|
|
||||||
|
if (!GetWindowText(hwnd, title, BUFFER_LEN))
|
||||||
|
title[0] = '\0';
|
||||||
|
|
||||||
TaskBarMap::iterator found = pThis->_map.find(hwnd);
|
TaskBarMap::iterator found = pThis->_map.find(hwnd);
|
||||||
int last_id = 0;
|
int last_id = 0;
|
||||||
|
|
||||||
|
@ -344,9 +360,14 @@ BOOL CALLBACK TaskBar::EnumWndProc(HWND hwnd, LPARAM lparam)
|
||||||
TBADDBITMAP ab = {0, (UINT_PTR)hbmp};
|
TBADDBITMAP ab = {0, (UINT_PTR)hbmp};
|
||||||
int bmp_idx = SendMessage(pThis->_htoolbar, TB_ADDBITMAP, 1, (LPARAM)&ab);
|
int bmp_idx = SendMessage(pThis->_htoolbar, TB_ADDBITMAP, 1, (LPARAM)&ab);
|
||||||
|
|
||||||
TaskBarEntry bmp = {pThis->_next_id++, hbmp, bmp_idx, 0, 0};
|
TaskBarEntry entry;
|
||||||
|
|
||||||
pThis->_map[hwnd] = bmp;
|
entry._id = pThis->_next_id++;
|
||||||
|
entry._hbmp = hbmp;
|
||||||
|
entry._bmp_idx = bmp_idx;
|
||||||
|
entry._title = title;
|
||||||
|
|
||||||
|
pThis->_map[hwnd] = entry;
|
||||||
found = pThis->_map.find(hwnd);
|
found = pThis->_map.find(hwnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,18 +376,11 @@ BOOL CALLBACK TaskBar::EnumWndProc(HWND hwnd, LPARAM lparam)
|
||||||
++entry._used;
|
++entry._used;
|
||||||
btn.idCommand = entry._id;
|
btn.idCommand = entry._id;
|
||||||
|
|
||||||
TCHAR title[BUFFER_LEN];
|
if (hwnd == GetForegroundWindow())
|
||||||
|
btn.fsState |= TBSTATE_PRESSED|TBSTATE_CHECKED;
|
||||||
|
|
||||||
if (!GetWindowText(hwnd, title, BUFFER_LEN))
|
|
||||||
title[0] = '\0';
|
|
||||||
|
|
||||||
//@@ refresh window titles
|
|
||||||
|
|
||||||
// create new toolbar buttons for new windows
|
|
||||||
if (!last_id) {
|
if (!last_id) {
|
||||||
if (hwnd == GetForegroundWindow())
|
// create new toolbar buttons for new windows
|
||||||
btn.fsState |= TBSTATE_PRESSED/*|TBSTATE_MARKED*/;
|
|
||||||
|
|
||||||
if (title[0])
|
if (title[0])
|
||||||
btn.iString = (INT_PTR)title;
|
btn.iString = (INT_PTR)title;
|
||||||
|
|
||||||
|
@ -374,11 +388,30 @@ BOOL CALLBACK TaskBar::EnumWndProc(HWND hwnd, LPARAM lparam)
|
||||||
entry._btn_idx = SendMessage(pThis->_htoolbar, TB_BUTTONCOUNT, 0, 0);
|
entry._btn_idx = SendMessage(pThis->_htoolbar, TB_BUTTONCOUNT, 0, 0);
|
||||||
|
|
||||||
SendMessage(pThis->_htoolbar, TB_INSERTBUTTON, entry._btn_idx, (LPARAM)&btn);
|
SendMessage(pThis->_htoolbar, TB_INSERTBUTTON, entry._btn_idx, (LPARAM)&btn);
|
||||||
|
} else {
|
||||||
|
// refresh attributes of existing buttons
|
||||||
|
if (btn.fsState != entry._fsState)
|
||||||
|
SendMessage(pThis->_htoolbar, TB_SETSTATE, entry._id, MAKELONG(btn.fsState,0));
|
||||||
|
|
||||||
|
if (entry._title != title) {
|
||||||
|
TBBUTTONINFO info;
|
||||||
|
|
||||||
|
info.cbSize = sizeof(TBBUTTONINFO);
|
||||||
|
info.dwMask = TBIF_TEXT;
|
||||||
|
info.pszText = title;
|
||||||
|
|
||||||
|
SendMessage(pThis->_htoolbar, TB_SETBUTTONINFO, entry._id, (LPARAM)&info);
|
||||||
|
|
||||||
|
entry._title = title;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// move iconic windows out of sight
|
entry._fsState = btn.fsState;
|
||||||
|
|
||||||
|
// move minimized windows out of sight
|
||||||
if (IsIconic(hwnd)) {
|
if (IsIconic(hwnd)) {
|
||||||
RECT rect;
|
RECT rect;
|
||||||
|
|
||||||
GetWindowRect(hwnd, &rect);
|
GetWindowRect(hwnd, &rect);
|
||||||
|
|
||||||
if (rect.bottom > 0)
|
if (rect.bottom > 0)
|
||||||
|
|
|
@ -58,12 +58,16 @@ protected:
|
||||||
#define IDW_TASKTOOLBAR 100
|
#define IDW_TASKTOOLBAR 100
|
||||||
|
|
||||||
struct TaskBarEntry
|
struct TaskBarEntry
|
||||||
{
|
{
|
||||||
|
TaskBarEntry();
|
||||||
|
|
||||||
int _id; // ID for WM_COMMAND
|
int _id; // ID for WM_COMMAND
|
||||||
HBITMAP _hbmp;
|
HBITMAP _hbmp;
|
||||||
int _bmp_idx;
|
int _bmp_idx;
|
||||||
int _used;
|
int _used;
|
||||||
int _btn_idx;
|
int _btn_idx;
|
||||||
|
String _title;
|
||||||
|
BYTE _fsState;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TaskBarMap : public map<HWND, TaskBarEntry>
|
struct TaskBarMap : public map<HWND, TaskBarEntry>
|
||||||
|
|
Loading…
Reference in a new issue