2 * Copyright 2003, 2004 Martin Fuchs
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 // Explorer start menu
27 // Martin Fuchs, 19.08.2003
29 // Credits: Thanks to Everaldo (http://www.everaldo.com) for his nice looking icons.
35 #include "../resource.h"
37 #include "desktopbar.h"
38 #include "startmenu.h"
40 #include "../dialogs/searchprogram.h"
41 #include "../dialogs/settings.h"
44 #define SHELLPATH_CONTROL_PANEL TEXT("::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{21EC2020-3AEA-1069-A2DD-08002B30309D}")
45 #define SHELLPATH_PRINTERS TEXT("::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{2227A280-3AEA-1069-A2DE-08002B30309D}")
46 #define SHELLPATH_NET_CONNECTIONS TEXT("::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{7007ACC7-3202-11D1-AAD2-00805FC1270E}")
49 StartMenu::StartMenu(HWND hwnd
, bool big_icons
)
53 _next_id
= IDC_FIRST_MENU
;
58 _bottom_max
= INT_MAX
;
60 _floating_btn
= false;
62 _scroll_mode
= SCROLL_NOT
;
66 _last_pos
= WindowRect(hwnd
).pos();
67 #ifdef _LIGHT_STARTMENU
73 StartMenu::StartMenu(HWND hwnd
, const StartMenuCreateInfo
& create_info
, bool big_icons
)
75 _create_info(create_info
),
78 for(StartMenuFolders::const_iterator it
=create_info
._folders
.begin(); it
!=create_info
._folders
.end(); ++it
)
80 _dirs
.push_back(ShellDirectory(GetDesktopFolder(), *it
, _hwnd
));
82 _next_id
= IDC_FIRST_MENU
;
86 _border_top
= create_info
._border_top
;
87 _bottom_max
= INT_MAX
;
89 _floating_btn
= create_info
._border_top
? true: false;
91 _scroll_mode
= SCROLL_NOT
;
95 _last_pos
= WindowRect(hwnd
).pos();
96 #ifdef _LIGHT_STARTMENU
102 StartMenu::~StartMenu()
104 SendParent(PM_STARTMENU_CLOSED
);
108 // We need this wrapper function for s_wcStartMenu, it calls the WIN32 API,
109 // though static C++ initializers are not allowed for Winelib applications.
110 BtnWindowClass
& StartMenu::GetWndClasss()
112 static BtnWindowClass
s_wcStartMenu(CLASSNAME_STARTMENU
);
114 return s_wcStartMenu
;
118 Window::CREATORFUNC_INFO
StartMenu::s_def_creator
= STARTMENU_CREATOR(StartMenu
);
120 HWND
StartMenu::Create(int x
, int y
, const StartMenuFolders
& folders
, HWND hwndParent
, LPCTSTR title
, bool parent_big_icons
,
121 CREATORFUNC_INFO creator
, void* info
, const String
& filter
)
123 UINT style
, ex_style
;
127 style
= WS_POPUP
|WS_THICKFRAME
|WS_CLIPCHILDREN
|WS_VISIBLE
;
129 top_height
= STARTMENU_TOP_BTN_SPACE
;
131 style
= WS_POPUP
|WS_CAPTION
|WS_SYSMENU
|WS_CLIPCHILDREN
|WS_VISIBLE
;
132 ex_style
= WS_EX_TOOLWINDOW
;
136 bool big_icons
= false;
137 RECT rect
= {x
, y
-STARTMENU_LINE_HEIGHT
-top_height
, x
+STARTMENU_WIDTH_MIN
, y
};
139 #ifndef _LIGHT_STARTMENU
140 rect
.top
+= STARTMENU_LINE_HEIGHT
;
143 AdjustWindowRectEx(&rect
, style
, FALSE
, ex_style
);
145 StartMenuCreateInfo create_info
;
147 create_info
._folders
= folders
;
148 create_info
._border_top
= top_height
;
149 create_info
._creator
= creator
;
150 create_info
._info
= info
;
151 create_info
._filter
= filter
;
154 create_info
._title
= title
;
156 HWND hwnd
= Window::Create(creator
, &create_info
, ex_style
, GetWndClasss(), title
,
157 style
, rect
.left
, rect
.top
, rect
.right
-rect
.left
, rect
.bottom
-rect
.top
, hwndParent
);
159 // make sure the window is not off the screen
166 LRESULT
StartMenu::Init(LPCREATESTRUCT pcs
)
171 if (super::Init(pcs
))
174 // create buttons for registered entries in _entries
175 for(ShellEntryMap::const_iterator it
=_entries
.begin(); it
!=_entries
.end(); ++it
) {
176 const StartMenuEntry
& sme
= it
->second
;
177 bool hasSubmenu
= false;
179 for(ShellEntrySet::const_iterator it
=sme
._entries
.begin(); it
!=sme
._entries
.end(); ++it
)
180 if ((*it
)->_data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
183 #ifdef _LIGHT_STARTMENU
184 _buttons
.push_back(SMBtnInfo(sme
, it
->first
, hasSubmenu
));
186 AddButton(sme
._title
, sme
._hIcon
, hasSubmenu
, it
->first
);
190 #ifdef _LIGHT_STARTMENU
191 if (_buttons
.empty())
193 if (!GetWindow(_hwnd
, GW_CHILD
))
195 AddButton(ResString(IDS_EMPTY
), ICID_NONE
, false, 0, false);
197 #ifdef _LIGHT_STARTMENU
201 #ifdef _LAZY_ICONEXTRACT
202 PostMessage(_hwnd
, PM_UPDATE_ICONS
, 0, 0);
204 } catch(COMException
& e
) {
205 HandleException(e
, pcs
->hwndParent
); // destroys the start menu window while switching focus
211 void StartMenu::AddEntries()
213 for(StartMenuShellDirs::iterator it
=_dirs
.begin(); it
!=_dirs
.end(); ++it
) {
214 StartMenuDirectory
& smd
= *it
;
215 ShellDirectory
& dir
= smd
._dir
;
220 #ifdef _LAZY_ICONEXTRACT
221 dir
.smart_scan(SORT_NAME
, SCAN_FILESYSTEM
); // lazy icon extraction, try to read directly from filesystem
223 dir
.smart_scan(SORT_NAME
, SCAN_EXTRACT_ICONS
|SCAN_FILESYSTEM
);
227 AddShellEntries(dir
, -1, smd
._ignore
);
232 static LPTSTR
trim_path_slash(LPTSTR path
)
239 if (p
>path
&& (p
[-1]=='\\' || p
[-1]=='/'))
245 void StartMenu::AddShellEntries(const ShellDirectory
& dir
, int max
, const String
& ignore
)
247 TCHAR ignore_path
[MAX_PATH
], ignore_dir
[MAX_PATH
], ignore_name
[_MAX_FNAME
], ignore_ext
[_MAX_EXT
];
248 TCHAR dir_path
[MAX_PATH
];
250 if (!ignore
.empty()) {
251 _tsplitpath_s(ignore
, ignore_path
, COUNTOF(ignore_path
), ignore_dir
, COUNTOF(ignore_dir
), ignore_name
, COUNTOF(ignore_name
), ignore_ext
, COUNTOF(ignore_ext
));
253 _tcscat(ignore_path
, ignore_dir
);
254 _tcscat(ignore_name
, ignore_ext
);
256 dir
.get_path(dir_path
, COUNTOF(dir_path
));
258 if (_tcsicmp(trim_path_slash(dir_path
), trim_path_slash(ignore_path
)))
263 String lwr_filter
= _create_info
._filter
;
264 lwr_filter
.toLower();
267 for(Entry
*entry
=dir
._down
; entry
; entry
=entry
->_next
) {
268 // hide files like "desktop.ini"
269 if (entry
->_shell_attribs
& SFGAO_HIDDEN
)
270 //not appropriate for drive roots: if (entry->_data.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)
273 // hide "Programs" subfolders if requested
274 if (*ignore_name
&& !_tcsicmp(entry
->_data
.cFileName
, ignore_name
))
277 // only 'max' entries shall be added.
281 // filter only non-directory entries
282 if (!(entry
->_data
.dwFileAttributes
&FILE_ATTRIBUTE_DIRECTORY
) && !lwr_filter
.empty()) {
283 String lwr_name
= entry
->_data
.cFileName
;
284 String lwr_disp
= entry
->_display_name
;
289 if (!_tcsstr(lwr_name
,lwr_filter
) && !_tcsstr(lwr_disp
,lwr_filter
))
293 if (entry
->_etype
== ET_SHELL
)
294 AddEntry(dir
._folder
, static_cast<ShellEntry
*>(entry
));
296 AddEntry(dir
._folder
, entry
);
301 LRESULT
StartMenu::WndProc(UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
305 PaintCanvas
canvas(_hwnd
);
310 ResizeButtons(LOWORD(lparam
)-_border_left
);
314 const POINTS
& pos
= MAKEPOINTS(lparam
);
316 // move open submenus of floating menus
318 int dx
= pos
.x
- _last_pos
.x
;
319 int dy
= pos
.y
- _last_pos
.y
;
322 WindowRect
rt(_submenu
);
323 SetWindowPos(_submenu
, 0, rt
.left
+dx
, rt
.top
+dy
, 0, 0, SWP_NOSIZE
|SWP_NOACTIVATE
);
324 //MoveVisible(_submenu);
333 LRESULT res
= super::WndProc(nmsg
, wparam
, lparam
);
335 if (res
>=HTSIZEFIRST
&& res
<=HTSIZELAST
)
336 return HTCLIENT
; // disable window resizing
340 case WM_LBUTTONDOWN
: {
343 // check mouse cursor for coordinates of floating button
344 GetFloatingButtonRect(&rect
);
346 if (PtInRect(&rect
, Point(lparam
))) {
347 // create a floating copy of the current start menu
348 WindowRect
pos(_hwnd
);
350 ///@todo do something similar to StartMenuRoot::TrackStartmenu() in order to automatically close submenus when clicking on the desktop background
351 StartMenu::Create(pos
.left
+3, pos
.bottom
-3, _create_info
._folders
, 0, _create_info
._title
, _big_icons
, _create_info
._creator
, _create_info
._info
);
355 #ifdef _LIGHT_STARTMENU
356 int id
= ButtonHitTest(Point(lparam
));
359 Command(id
, BN_CLICKED
);
364 if ((wparam
&0xFFF0) == SC_SIZE
)
365 return 0; // disable window resizing
369 // close start menu when activating another application
372 break; // don't call super::WndProc in case "this" has been deleted
377 #ifdef _LIGHT_STARTMENU
378 if (_scroll_mode
!= SCROLL_NOT
) {
385 #ifdef _LIGHT_STARTMENU
387 // automatically set the focus to startmenu entries when moving the mouse over them
388 if (lparam
!= _last_mouse_pos
) { // don't process WM_MOUSEMOVE when opening submenus using keyboard navigation
392 RECT rect_up
, rect_down
;
394 GetArrowButtonRects(&rect_up
, &rect_down
, _big_icons
);
396 SCROLL_MODE scroll_mode
= SCROLL_NOT
;
398 if (PtInRect(&rect_up
, pt
))
399 scroll_mode
= SCROLL_UP
;
400 else if (PtInRect(&rect_down
, pt
))
401 scroll_mode
= SCROLL_DOWN
;
403 if (scroll_mode
!= _scroll_mode
) {
404 if (scroll_mode
== SCROLL_NOT
) {
409 SetTimer(_hwnd
, 0, 150, NULL
); // 150 ms scroll interval
413 _scroll_mode
= scroll_mode
;
417 int new_id
= ButtonHitTest(pt
);
419 if (new_id
> 0 && new_id
!= _selected_id
)
420 SelectButton(new_id
);
422 _last_mouse_pos
= lparam
;
427 if (_scroll_mode
== SCROLL_UP
) {
428 if (_scroll_pos
> 0) {
430 InvalidateRect(_hwnd
, NULL
, TRUE
);
433 if (_scroll_pos
<= _invisible_lines
) {
435 InvalidateRect(_hwnd
, NULL
, TRUE
);
444 case PM_STARTENTRY_FOCUSED
: { ///@todo use TrackMouseEvent() and WM_MOUSEHOVER to wait a bit before opening submenus
445 BOOL hasSubmenu
= wparam
;
446 HWND hctrl
= (HWND
)lparam
;
448 // automatically open submenus
450 UpdateWindow(_hwnd
); // draw focused button before waiting on submenu creation
451 //SendMessage(_hwnd, WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(hctrl),BN_CLICKED), (LPARAM)hctrl);
452 Command(GetDlgCtrlID(hctrl
), BN_CLICKED
);
454 // close any open submenu
455 CloseOtherSubmenus();
460 #ifdef _LAZY_ICONEXTRACT
461 case PM_UPDATE_ICONS
:
462 UpdateIcons(/*wparam*/);
466 case PM_STARTENTRY_LAUNCHED
:
467 if (GetWindowStyle(_hwnd
) & WS_CAPTION
) // don't automatically close floating menus
470 // route message to the parent menu and close menus after launching an entry
471 if (!SendParent(nmsg
, wparam
, lparam
))
473 return 1; // signal that we have received and processed the message
475 case PM_STARTMENU_CLOSED
:
479 case PM_SELECT_ENTRY
:
480 SelectButtonIndex(0, wparam
!=0);
483 #ifdef _LIGHT_STARTMENU
484 case WM_CONTEXTMENU
: {
485 Point
screen_pt(lparam
), clnt_pt
=screen_pt
;
486 ScreenToClient(_hwnd
, &clnt_pt
);
488 int id
= ButtonHitTest(clnt_pt
);
491 StartMenuEntry
& sme
= _entries
[id
];
493 for(ShellEntrySet::iterator it
=sme
._entries
.begin(); it
!=sme
._entries
.end(); ++it
) {
497 CHECKERROR(entry
->do_context_menu(_hwnd
, screen_pt
, _cm_ifs
)); // may close start menu because of focus loss
498 break; ///@todo handle context menu for more than one entry
506 return super::WndProc(nmsg
, wparam
, lparam
);
513 #ifdef _LIGHT_STARTMENU
515 int StartMenu::ButtonHitTest(POINT pt
)
517 ClientRect
clnt(_hwnd
);
518 const bool big_icons
= _big_icons
;
519 RECT rect
= {_border_left
, _border_top
, clnt
.right
, STARTMENU_LINE_HEIGHT
};
521 if (pt
.x
<rect
.left
|| pt
.x
>rect
.right
)
524 for(SMBtnVector::const_iterator it
=_buttons
.begin()+_scroll_pos
; it
!=_buttons
.end(); ++it
) {
525 const SMBtnInfo
& info
= *it
;
530 rect
.bottom
= rect
.top
+ (info
._id
==-1? STARTMENU_SEP_HEIGHT
: STARTMENU_LINE_HEIGHT
);
532 if (rect
.bottom
> _bottom_max
)
535 if (pt
.y
< rect
.bottom
) // PtInRect(&rect, pt)
538 rect
.top
= rect
.bottom
;
544 void StartMenu::InvalidateSelection()
546 if (_selected_id
<= 0)
549 ClientRect
clnt(_hwnd
);
550 const bool big_icons
= _big_icons
;
551 RECT rect
= {_border_left
, _border_top
, clnt
.right
, STARTMENU_LINE_HEIGHT
};
553 for(SMBtnVector::const_iterator it
=_buttons
.begin()+_scroll_pos
; it
!=_buttons
.end(); ++it
) {
554 const SMBtnInfo
& info
= *it
;
556 rect
.bottom
= rect
.top
+ (info
._id
==-1? STARTMENU_SEP_HEIGHT
: STARTMENU_LINE_HEIGHT
);
558 if (info
._id
== _selected_id
) {
559 InvalidateRect(_hwnd
, &rect
, TRUE
);
563 rect
.top
= rect
.bottom
;
567 const SMBtnInfo
* StartMenu::GetButtonInfo(int id
) const
569 for(SMBtnVector::const_iterator it
=_buttons
.begin(); it
!=_buttons
.end(); ++it
)
576 bool StartMenu::SelectButton(int id
, bool open_sub
)
581 if (id
== _selected_id
)
584 InvalidateSelection();
586 const SMBtnInfo
* btn
= GetButtonInfo(id
);
588 if (btn
&& btn
->_enabled
) {
591 InvalidateSelection();
593 // automatically open submenus
594 if (btn
->_hasSubmenu
) {
598 CloseOtherSubmenus(); // close any open submenu
607 bool StartMenu::OpenSubmenu(bool select_first
)
609 if (_selected_id
== -1)
612 InvalidateSelection();
614 const SMBtnInfo
* btn
= GetButtonInfo(_selected_id
);
616 // automatically open submenus
617 if (btn
->_hasSubmenu
) {
618 //@@ allows destroying of startmenu when processing PM_UPDATE_ICONS -> GPF
619 UpdateWindow(_hwnd
); // draw focused button before waiting on submenu creation
620 Command(_selected_id
, BN_CLICKED
);
622 if (select_first
&& _submenu
)
623 SendMessage(_submenu
, PM_SELECT_ENTRY
, (WPARAM
)false, 0);
631 int StartMenu::GetSelectionIndex()
633 if (_selected_id
== -1)
636 for(int i
=0; i
<(int)_buttons
.size(); ++i
)
637 if (_buttons
[i
]._id
== _selected_id
)
643 bool StartMenu::SelectButtonIndex(int idx
, bool open_sub
)
645 if (idx
>=0 && idx
<(int)_buttons
.size())
646 return SelectButton(_buttons
[idx
]._id
, open_sub
);
651 void StartMenu::ProcessKey(int vk
)
656 Command(_selected_id
, BN_CLICKED
);
668 SelectButtonIndex(0, false);
672 SelectButtonIndex(_buttons
.size()-1, false);
677 CloseOtherSubmenus();
678 else if (!(GetWindowStyle(_hwnd
) & WS_CAPTION
)) // don't automatically close floating menus
679 DestroyWindow(_hwnd
);
691 if (vk
>='0' && vk
<='Z')
692 JumpToNextShortcut(vk
);
696 bool StartMenu::Navigate(int step
)
698 int idx
= GetSelectionIndex();
704 idx
= _buttons
.size() - step
;
709 if (idx
<0 || idx
>(int)_buttons
.size())
712 if (SelectButtonIndex(idx
, false))
719 bool StartMenu::JumpToNextShortcut(char c
)
721 int cur_idx
= GetSelectionIndex();
729 SMBtnVector::const_iterator cur_it
= _buttons
.begin();
730 cur_it
+= cur_idx
+ 1;
732 // first search down from current item...
733 SMBtnVector::const_iterator it
= cur_it
;
734 for(; it
!=_buttons
.end(); ++it
) {
735 const SMBtnInfo
& btn
= *it
;
737 if (!btn
._title
.empty() && toupper((TBYTE
)btn
._title
.at(0)) == c
) {
739 first_found
= btn
._id
;
745 // ...now search from top to the current item
746 it
= _buttons
.begin();
747 for(; it
!=_buttons
.end() && it
!=cur_it
; ++it
) {
748 const SMBtnInfo
& btn
= *it
;
750 if (!btn
._title
.empty() && toupper((TBYTE
)btn
._title
.at(0)) == c
) {
752 first_found
= btn
._id
;
759 SelectButton(first_found
);
762 Command(first_found
, BN_CLICKED
);
769 #endif // _LIGHT_STARTMENU
772 bool StartMenu::GetButtonRect(int id
, PRECT prect
) const
774 #ifdef _LIGHT_STARTMENU
775 ClientRect
clnt(_hwnd
);
776 const bool big_icons
= _big_icons
;
777 RECT rect
= {_border_left
, _border_top
, clnt
.right
, STARTMENU_LINE_HEIGHT
};
779 for(SMBtnVector::const_iterator it
=_buttons
.begin()+_scroll_pos
; it
!=_buttons
.end(); ++it
) {
780 const SMBtnInfo
& info
= *it
;
782 rect
.bottom
= rect
.top
+ (info
._id
==-1? STARTMENU_SEP_HEIGHT
: STARTMENU_LINE_HEIGHT
);
784 if (info
._id
== id
) {
789 rect
.top
= rect
.bottom
;
794 HWND btn
= GetDlgItem(_hwnd
, id
);
797 GetWindowRect(btn
, prect
);
798 ScreenToClient(_hwnd
, prect
);
807 void StartMenu::DrawFloatingButton(HDC hdc
)
809 static ResIconEx
floatingIcon(IDI_FLOATING
, 8, 4);
811 ClientRect
clnt(_hwnd
);
813 DrawIconEx(hdc
, clnt
.right
-12, 0, floatingIcon
, 8, 4, 0, 0, DI_NORMAL
);
816 void StartMenu::GetFloatingButtonRect(LPRECT prect
)
818 GetClientRect(_hwnd
, prect
);
821 prect
->left
= prect
->right
- 8;
826 void StartMenu::DrawArrows(HDC hdc
, bool big_icons
)
828 int cx
= big_icons
? 16: 8;
829 int cy
= big_icons
? 8: 4;
831 ResIconEx
arrowUpIcon(IDI_ARROW_UP
, cx
, cy
);
832 ResIconEx
arrowDownIcon(IDI_ARROW_DOWN
, cx
, cy
);
834 ClientRect
clnt(_hwnd
);
836 DrawIconEx(hdc
, clnt
.right
/2-cx
/2, _floating_btn
?3:1, arrowUpIcon
, cx
, cy
, 0, 0, DI_NORMAL
);
837 DrawIconEx(hdc
, clnt
.right
/2-cx
/2, clnt
.bottom
-cy
-1, arrowDownIcon
, cx
, cy
, 0, 0, DI_NORMAL
);
840 void StartMenu::GetArrowButtonRects(LPRECT prect_up
, LPRECT prect_down
, bool big_icons
)
842 int cx
= big_icons
? 16: 8;
843 int cy
= big_icons
? 8: 4;
845 GetClientRect(_hwnd
, prect_up
);
846 *prect_down
= *prect_up
;
848 // prect_up->left = prect_up->right/2 - cx/2;
849 // prect_up->right = prect_up->left + cy;
850 prect_up
->right
-= cx
;
851 prect_up
->top
= _floating_btn
? cy
-1: 1;
852 prect_up
->bottom
= prect_up
->top
+ cy
;
854 // prect_down->left = prect_down->right/2 - cx/2;
855 // prect_down->right = prect_down->left + cy;
856 prect_down
->right
-= cx
;
857 prect_down
->top
= prect_down
->bottom
- cy
- 1;
861 void StartMenu::Paint(PaintCanvas
& canvas
)
864 DrawFloatingButton(canvas
);
866 #ifdef _LIGHT_STARTMENU
868 DrawArrows(canvas
, _big_icons
);
870 ClientRect
clnt(_hwnd
);
871 const bool big_icons
= _big_icons
;
872 RECT rect
= {_border_left
, _border_top
, clnt
.right
, STARTMENU_LINE_HEIGHT
};
874 int sep_width
= rect
.right
-rect
.left
- 4;
876 FontSelection
font(canvas
, GetStockFont(DEFAULT_GUI_FONT
));
877 BkMode
bk_mode(canvas
, TRANSPARENT
);
879 for(SMBtnVector::const_iterator it
=_buttons
.begin()+_scroll_pos
; it
!=_buttons
.end(); ++it
) {
880 const SMBtnInfo
& btn
= *it
;
882 if (rect
.top
> canvas
.rcPaint
.bottom
)
885 if (btn
._id
== -1) { // a separator?
886 rect
.bottom
= rect
.top
+ STARTMENU_SEP_HEIGHT
;
888 if (rect
.bottom
> _bottom_max
)
891 BrushSelection
brush_sel(canvas
, GetSysColorBrush(COLOR_BTNSHADOW
));
892 PatBlt(canvas
, rect
.left
+2, rect
.top
+STARTMENU_SEP_HEIGHT
/2-1, sep_width
, 1, PATCOPY
);
894 SelectBrush(canvas
, GetSysColorBrush(COLOR_BTNHIGHLIGHT
));
895 PatBlt(canvas
, rect
.left
+2, rect
.top
+STARTMENU_SEP_HEIGHT
/2, sep_width
, 1, PATCOPY
);
897 rect
.bottom
= rect
.top
+ STARTMENU_LINE_HEIGHT
;
899 if (rect
.bottom
> _bottom_max
)
902 if (rect
.top
>= canvas
.rcPaint
.top
)
903 DrawStartMenuButton(canvas
, rect
, btn
._title
, btn
, btn
._id
==_selected_id
, false, _big_icons
);
906 rect
.top
= rect
.bottom
;
911 #ifdef _LAZY_ICONEXTRACT
912 void StartMenu::UpdateIcons(/*int idx*/)
916 #ifdef _SINGLE_ICONEXTRACT
919 int idx
= _scroll_pos
;
921 for(; idx
<(int)_buttons
.size(); ++idx
) {
922 SMBtnInfo
& btn
= _buttons
[idx
];
924 if (btn
._icon_id
==ICID_UNKNOWN
&& btn
._id
>0) {
925 StartMenuEntry
& sme
= _entries
[btn
._id
];
927 btn
._icon_id
= ICID_NONE
;
929 for(ShellEntrySet::iterator it
=sme
._entries
.begin(); it
!=sme
._entries
.end(); ++it
) {
932 if (entry
->_icon_id
== ICID_UNKNOWN
)
934 entry
->extract_icon(_big_icons
);
935 } catch(COMException
&) {
936 // ignore unexpected exceptions while extracting icons
939 if (entry
->_icon_id
> ICID_NONE
) {
940 btn
._icon_id
= (ICON_ID
)/*@@*/ entry
->_icon_id
;
944 GetButtonRect(btn
._id
, &rect
);
946 if (rect
.bottom
> _bottom_max
)
949 WindowCanvas
canvas(_hwnd
);
950 DrawStartMenuButton(canvas
, rect
, NULL
, btn
, btn
._id
==_selected_id
, false, _big_icons
);
952 //InvalidateRect(_hwnd, &rect, FALSE);
953 //UpdateWindow(_hwnd);
962 // if (++idx < (int)_buttons.size())
963 // PostMessage(_hwnd, PM_UPDATE_ICONS, idx, 0);
967 int icons_extracted
= 0;
968 int icons_updated
= 0;
970 for(StartMenuShellDirs::iterator it
=_dirs
.begin(); it
!=_dirs
.end(); ++it
) {
971 ShellDirectory
& dir
= it
->_dir
;
973 icons_extracted
+= dir
.extract_icons();
976 if (icons_extracted
) {
977 for(ShellEntryMap::iterator it1
=_entries
.begin(); it1
!=_entries
.end(); ++it1
) {
978 StartMenuEntry
& sme
= it1
->second
;
981 sme
._hIcon
= (HICON
)-1;
983 for(ShellEntrySet::const_iterator it2
=sme
._entries
.begin(); it2
!=sme
._entries
.end(); ++it2
) {
984 const Entry
* sm_entry
= *it2
;
986 if (sm_entry
->_hIcon
) {
987 sme
._hIcon
= sm_entry
->_hIcon
;
994 for(SMBtnVector::iterator it
=_buttons
.begin(); it
!=_buttons
.end(); ++it
) {
995 SMBtnInfo
& info
= *it
;
997 if (info
._id
>0 && !info
._hIcon
) {
998 info
._hIcon
= _entries
[info
._id
]._hIcon
;
1004 if (icons_updated
) {
1005 InvalidateRect(_hwnd
, NULL
, FALSE
);
1006 UpdateWindow(_hwnd
);
1013 // resize child button controls to accomodate for new window size
1014 void StartMenu::ResizeButtons(int cx
)
1016 HDWP hdwp
= BeginDeferWindowPos(10);
1018 for(HWND ctrl
=GetWindow(_hwnd
,GW_CHILD
); ctrl
; ctrl
=GetNextWindow(ctrl
,GW_HWNDNEXT
)) {
1019 ClientRect
rt(ctrl
);
1021 if (rt
.right
!= cx
) {
1022 int height
= rt
.bottom
- rt
.top
;
1024 // special handling for separator controls
1025 if (!height
&& (GetWindowStyle(ctrl
)&SS_TYPEMASK
)==SS_ETCHEDHORZ
)
1028 hdwp
= DeferWindowPos(hdwp
, ctrl
, 0, 0, 0, cx
, height
, SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOACTIVATE
);
1032 EndDeferWindowPos(hdwp
);
1036 int StartMenu::Command(int id
, int code
)
1038 #ifndef _LIGHT_STARTMENU
1046 ShellEntryMap::iterator found
= _entries
.find(id
);
1048 if (found
!= _entries
.end()) {
1049 ActivateEntry(id
, found
->second
._entries
);
1053 return super::Command(id
, code
);
1054 #ifndef _LIGHT_STARTMENU
1063 ShellEntryMap::iterator
StartMenu::AddEntry(const String
& title
, ICON_ID icon_id
, Entry
* entry
)
1065 // search for an already existing subdirectory entry with the same name
1066 if (entry
->_data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
1067 for(ShellEntryMap::iterator it
=_entries
.begin(); it
!=_entries
.end(); ++it
) {
1068 StartMenuEntry
& sme
= it
->second
;
1070 if (!_tcsicmp(sme
._title
, title
)) ///@todo speed up by using a map indexed by name
1071 for(ShellEntrySet::iterator it2
=sme
._entries
.begin(); it2
!=sme
._entries
.end(); ++it2
) {
1072 if ((*it2
)->_data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) {
1073 // merge the new shell entry with the existing of the same name
1074 sme
._entries
.insert(entry
);
1081 ShellEntryMap::iterator sme
= AddEntry(title
, icon_id
);
1083 sme
->second
._entries
.insert(entry
);
1088 ShellEntryMap::iterator
StartMenu::AddEntry(const String
& title
, ICON_ID icon_id
, int id
)
1096 sme
._icon_id
= icon_id
;
1098 ShellEntryMap::iterator it
= _entries
.insert(make_pair(id
, sme
)).first
;
1103 ShellEntryMap::iterator
StartMenu::AddEntry(const ShellFolder folder
, ShellEntry
* entry
)
1107 if (entry
->_data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
1108 icon_id
= ICID_FOLDER
;
1110 icon_id
= (ICON_ID
)/*@@*/ entry
->_icon_id
;
1112 return AddEntry(folder
.get_name(entry
->_pidl
), icon_id
, entry
);
1115 ShellEntryMap::iterator
StartMenu::AddEntry(const ShellFolder folder
, Entry
* entry
)
1119 if (entry
->_data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
1120 icon_id
= ICID_FOLDER
;
1122 icon_id
= (ICON_ID
)/*@@*/ entry
->_icon_id
;
1124 return AddEntry(entry
->_display_name
, icon_id
, entry
);
1128 void StartMenu::AddButton(LPCTSTR title
, ICON_ID icon_id
, bool hasSubmenu
, int id
, bool enabled
)
1130 #ifdef _LIGHT_STARTMENU
1131 _buttons
.push_back(SMBtnInfo(title
, icon_id
, id
, hasSubmenu
, enabled
));
1133 DWORD style
= enabled
? WS_VISIBLE
|WS_CHILD
|BS_OWNERDRAW
: WS_VISIBLE
|WS_CHILD
|BS_OWNERDRAW
|WS_DISABLED
;
1135 WindowRect
rect(_hwnd
);
1136 ClientRect
clnt(_hwnd
);
1138 // increase window height to make room for the new button
1139 rect
.top
-= STARTMENU_LINE_HEIGHT
;
1141 // move down if we are too high now
1143 rect
.top
+= STARTMENU_LINE_HEIGHT
;
1144 rect
.bottom
+= STARTMENU_LINE_HEIGHT
;
1147 WindowCanvas
canvas(_hwnd
);
1148 FontSelection
font(canvas
, GetStockFont(DEFAULT_GUI_FONT
));
1150 // widen window, if it is too small
1151 int text_width
= GetStartMenuBtnTextWidth(canvas
, title
, _hwnd
) + ICON_SIZE_X
+ 10/*placeholder*/ + 16/*arrow*/;
1153 int cx
= clnt
.right
- _border_left
;
1154 if (text_width
> cx
)
1155 rect
.right
+= text_width
-cx
;
1157 MoveWindow(_hwnd
, rect
.left
, rect
.top
, rect
.right
-rect
.left
, rect
.bottom
-rect
.top
, TRUE
);
1159 StartMenuCtrl(_hwnd
, _border_left
, clnt
.bottom
, rect
.right
-rect
.left
-_border_left
,
1160 title
, id
, g_Globals
._icon_cache
.get_icon(icon_id
)._hIcon
, hasSubmenu
, style
);
1164 void StartMenu::AddSeparator()
1166 #ifdef _LIGHT_STARTMENU
1167 _buttons
.push_back(SMBtnInfo(NULL
, ICID_NONE
, -1, false));
1169 WindowRect
rect(_hwnd
);
1170 ClientRect
clnt(_hwnd
);
1172 // increase window height to make room for the new separator
1173 rect
.top
-= STARTMENU_SEP_HEIGHT
;
1175 // move down if we are too high now
1177 rect
.top
+= STARTMENU_LINE_HEIGHT
;
1178 rect
.bottom
+= STARTMENU_LINE_HEIGHT
;
1181 MoveWindow(_hwnd
, rect
.left
, rect
.top
, rect
.right
-rect
.left
, rect
.bottom
-rect
.top
, TRUE
);
1183 StartMenuSeparator(_hwnd
, _border_left
, clnt
.bottom
, rect
.right
-rect
.left
-_border_left
);
1188 bool StartMenu::CloseOtherSubmenus(int id
)
1191 if (IsWindow(_submenu
)) {
1192 if (_submenu_id
== id
)
1196 DestroyWindow(_submenu
);
1197 // _submenu should be reset automatically by PM_STARTMENU_CLOSED, but safety first...
1208 void StartMenu::CreateSubmenu(int id
, LPCTSTR title
, CREATORFUNC_INFO creator
, void* info
)
1210 CreateSubmenu(id
, StartMenuFolders(), title
, creator
, info
);
1213 bool StartMenu::CreateSubmenu(int id
, int folder_id
, LPCTSTR title
, CREATORFUNC_INFO creator
, void* info
)
1216 SpecialFolderPath
folder(folder_id
, _hwnd
);
1218 StartMenuFolders new_folders
;
1219 new_folders
.push_back(folder
);
1221 CreateSubmenu(id
, new_folders
, title
, creator
, info
);
1224 } catch(COMException
&) {
1225 // ignore Exception and don't display anything
1226 CloseOtherSubmenus(id
);
1227 _buttons
[GetSelectionIndex()]._enabled
= false; // disable entries for non-existing folders
1232 bool StartMenu::CreateSubmenu(int id
, int folder_id1
, int folder_id2
, LPCTSTR title
, CREATORFUNC_INFO creator
, void* info
)
1234 StartMenuFolders new_folders
;
1237 new_folders
.push_back(SpecialFolderPath(folder_id1
, _hwnd
));
1238 } catch(COMException
&) {
1242 new_folders
.push_back(SpecialFolderPath(folder_id2
, _hwnd
));
1243 } catch(COMException
&) {
1246 if (!new_folders
.empty()) {
1247 CreateSubmenu(id
, new_folders
, title
, creator
, info
);
1250 CloseOtherSubmenus(id
);
1251 _buttons
[GetSelectionIndex()]._enabled
= false; // disable entries for non-existing folders
1256 void StartMenu::CreateSubmenu(int id
, const StartMenuFolders
& new_folders
, LPCTSTR title
, CREATORFUNC_INFO creator
, void* info
)
1258 // Only open one submenu at a time.
1259 if (!CloseOtherSubmenus(id
))
1265 if (GetButtonRect(id
, &rect
)) {
1266 ClientToScreen(_hwnd
, &rect
);
1268 x
= rect
.right
; // Submenus should overlap their parent a bit.
1269 const bool big_icons
= _big_icons
;
1270 y
= rect
.top
+STARTMENU_LINE_HEIGHT
+_border_top
/*own border*/ -STARTMENU_TOP_BTN_SPACE
/*border of new submenu*/;
1272 WindowRect
pos(_hwnd
);
1279 _submenu
= StartMenu::Create(x
, y
, new_folders
, _hwnd
, title
, _big_icons
, creator
, info
, _create_info
._filter
);
1283 void StartMenu::ActivateEntry(int id
, const ShellEntrySet
& entries
)
1285 StartMenuFolders new_folders
;
1288 for(ShellEntrySet::const_iterator it
=entries
.begin(); it
!=entries
.end(); ++it
) {
1289 Entry
* entry
= const_cast<Entry
*>(*it
);
1291 if (entry
->_data
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
) {
1293 ///@todo If the user explicitly clicked on a submenu, display this folder as floating start menu.
1295 if (entry
->_etype
== ET_SHELL
)
1296 new_folders
.push_back(entry
->create_absolute_pidl());
1298 TCHAR path
[MAX_PATH
];
1300 if (entry
->get_path(path
, COUNTOF(path
)))
1301 new_folders
.push_back(path
);
1305 title
= entry
->_display_name
;
1307 // The entry is no subdirectory, so there can only be one shell entry.
1308 assert(entries
.size()==1);
1310 HWND hparent
= GetParent(_hwnd
);
1311 ShellPath shell_path
= entry
->create_absolute_pidl();
1313 // close start menus when launching the selected entry
1316 ///@todo launch in the background; specify correct HWND for error message box titles
1317 SHELLEXECUTEINFO shexinfo
;
1319 shexinfo
.cbSize
= sizeof(SHELLEXECUTEINFO
);
1320 shexinfo
.fMask
= SEE_MASK_IDLIST
; // SEE_MASK_INVOKEIDLIST is also possible.
1321 shexinfo
.hwnd
= hparent
;
1322 shexinfo
.lpVerb
= NULL
;
1323 shexinfo
.lpFile
= NULL
;
1324 shexinfo
.lpParameters
= NULL
;
1325 shexinfo
.lpDirectory
= NULL
;
1326 shexinfo
.nShow
= SW_SHOWNORMAL
;
1328 shexinfo
.lpIDList
= &*shell_path
;
1330 // add PIDL to the recent file list
1331 SHAddToRecentDocs(SHARD_PIDL
, shexinfo
.lpIDList
);
1333 if (!ShellExecuteEx(&shexinfo
))
1334 display_error(hparent
, GetLastError());
1336 // we may have deleted 'this' - ensure we leave the loop and function
1341 if (!new_folders
.empty()) {
1342 // Only open one submenu at a time.
1343 if (!CloseOtherSubmenus(id
))
1346 CreateSubmenu(id
, new_folders
, title
);
1351 /// close all windows of the start menu popup
1352 void StartMenu::CloseStartMenu(int id
)
1354 if (!(GetWindowStyle(_hwnd
) & WS_CAPTION
)) { // don't automatically close floating menus
1355 if (!SendParent(PM_STARTENTRY_LAUNCHED
, id
, (LPARAM
)_hwnd
))
1356 DestroyWindow(_hwnd
);
1357 } else if (_submenu
) // instead close submenus of floating parent menus
1362 int GetStartMenuBtnTextWidth(HDC hdc
, LPCTSTR title
, HWND hwnd
)
1364 RECT rect
= {0, 0, 0, 0};
1365 DrawText(hdc
, title
, -1, &rect
, DT_SINGLELINE
|DT_NOPREFIX
|DT_CALCRECT
);
1367 return rect
.right
-rect
.left
;
1370 #ifdef _LIGHT_STARTMENU
1371 void DrawStartMenuButton(HDC hdc
, const RECT
& rect
, LPCTSTR title
, const SMBtnInfo
& btn
, bool has_focus
, bool pushed
, bool big_icons
)
1373 void DrawStartMenuButton(HDC hdc
, const RECT
& rect
, LPCTSTR title
, HICON hIcon
,
1374 bool hasSubmenu
, bool enabled
, bool has_focus
, bool pushed
, bool big_icons
);
1377 UINT style
= DFCS_BUTTONPUSH
;
1380 style
|= DFCS_INACTIVE
;
1382 POINT iconPos
= {rect
.left
+2, (rect
.top
+rect
.bottom
-ICON_SIZE_Y
)/2};
1383 RECT textRect
= {rect
.left
+ICON_SIZE_X
+4, rect
.top
+2, rect
.right
-4, rect
.bottom
-4};
1386 style
|= DFCS_PUSHED
;
1387 ++iconPos
.x
; ++iconPos
.y
;
1388 ++textRect
.left
; ++textRect
.top
;
1389 ++textRect
.right
; ++textRect
.bottom
;
1392 int bk_color_idx
= COLOR_BTNFACE
;
1393 int text_color_idx
= COLOR_BTNTEXT
;
1396 bk_color_idx
= COLOR_HIGHLIGHT
;
1397 text_color_idx
= COLOR_HIGHLIGHTTEXT
;
1400 COLORREF bk_color
= GetSysColor(bk_color_idx
);
1401 HBRUSH bk_brush
= GetSysColorBrush(bk_color_idx
);
1404 FillRect(hdc
, &rect
, bk_brush
);
1406 if (btn
._icon_id
> ICID_NONE
)
1407 g_Globals
._icon_cache
.get_icon(btn
._icon_id
).draw(hdc
, iconPos
.x
, iconPos
.y
, ICON_SIZE_X
, ICON_SIZE_Y
, bk_color
, bk_brush
/*, big_icons*/);
1409 // draw submenu arrow at the right
1410 if (btn
._hasSubmenu
) {
1411 ResIconEx
arrowIcon(IDI_ARROW
, ICON_SIZE_X
, ICON_SIZE_Y
);
1412 ResIconEx
selArrowIcon(IDI_ARROW_SELECTED
, ICON_SIZE_X
, ICON_SIZE_Y
);
1414 DrawIconEx(hdc
, rect
.right
-ICON_SIZE_X
, iconPos
.y
,
1415 has_focus
? selArrowIcon
: arrowIcon
,
1416 ICON_SIZE_X
, ICON_SIZE_Y
, 0, bk_brush
, DI_NORMAL
);
1420 BkMode
bk_mode(hdc
, TRANSPARENT
);
1422 if (!btn
._enabled
) // dis->itemState & (ODS_DISABLED|ODS_GRAYED)
1423 DrawGrayText(hdc
, &textRect
, title
, DT_SINGLELINE
|DT_NOPREFIX
|DT_VCENTER
);
1425 TextColor
lcColor(hdc
, GetSysColor(text_color_idx
));
1426 DrawText(hdc
, title
, -1, &textRect
, DT_SINGLELINE
|DT_NOPREFIX
|DT_VCENTER
);
1432 #ifdef _LIGHT_STARTMENU
1434 void StartMenu::ResizeToButtons()
1436 WindowRect
rect(_hwnd
);
1438 WindowCanvas
canvas(_hwnd
);
1439 FontSelection
font(canvas
, GetStockFont(DEFAULT_GUI_FONT
));
1441 const bool big_icons
= _big_icons
;
1443 int max_width
= STARTMENU_WIDTH_MIN
;
1446 for(SMBtnVector::const_iterator it
=_buttons
.begin(); it
!=_buttons
.end(); ++it
) {
1447 int w
= GetStartMenuBtnTextWidth(canvas
, it
->_title
, _hwnd
);
1453 height
+= STARTMENU_SEP_HEIGHT
;
1455 height
+= STARTMENU_LINE_HEIGHT
;
1458 // calculate new window size
1459 int text_width
= max_width
+ ICON_SIZE_X
+ 10/*placeholder*/ + 16/*arrow*/;
1461 RECT rt_hgt
= {rect
.left
, rect
.bottom
-_border_top
-height
, rect
.left
+_border_left
+text_width
, rect
.bottom
};
1462 AdjustWindowRectEx(&rt_hgt
, GetWindowStyle(_hwnd
), FALSE
, GetWindowExStyle(_hwnd
));
1464 // ignore movement, only look at the size change
1465 rect
.right
= rect
.left
+ (rt_hgt
.right
-rt_hgt
.left
);
1466 rect
.top
= rect
.bottom
- (rt_hgt
.bottom
-rt_hgt
.top
);
1468 // move down if we are too high
1475 // enable scroll mode for long start menus, which span more than the whole screen height
1476 int cyscreen
= GetSystemMetrics(SM_CYSCREEN
);
1479 if (rect
.bottom
> cyscreen
) {
1482 _invisible_lines
= (rect
.bottom
-cyscreen
+(STARTMENU_LINE_HEIGHT
-1))/STARTMENU_LINE_HEIGHT
+ 1;
1483 rect
.bottom
-= _invisible_lines
* STARTMENU_LINE_HEIGHT
;
1485 bottom_max
= rect
.bottom
;
1488 rect
.bottom
+= 6; // lower scroll arrow
1490 _border_top
+= 6; // upper scroll arrow
1491 rect
.bottom
+= 2*6; // upper+lower scroll arrow
1495 MoveWindow(_hwnd
, rect
.left
, rect
.top
, rect
.right
-rect
.left
, rect
.bottom
-rect
.top
, TRUE
);
1498 POINT pt
= {0, bottom_max
};
1500 ScreenToClient(_hwnd
, &pt
);
1506 #else // _LIGHT_STARTMENU
1508 LRESULT
StartMenuButton::WndProc(UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
1512 // automatically set the focus to startmenu entries when moving the mouse over them
1513 if (GetFocus()!=_hwnd
&& !(GetWindowStyle(_hwnd
)&WS_DISABLED
))
1518 PostParent(PM_STARTENTRY_FOCUSED
, _hasSubmenu
, (LPARAM
)_hwnd
);
1522 // route WM_CANCELMODE to the startmenu window
1523 return SendParent(nmsg
, wparam
, lparam
);
1526 return super::WndProc(nmsg
, wparam
, lparam
);
1532 void StartMenuButton::DrawItem(LPDRAWITEMSTRUCT dis
)
1534 TCHAR title
[BUFFER_LEN
];
1536 GetWindowText(_hwnd
, title
, BUFFER_LEN
);
1538 DrawStartMenuButton(dis
->hDC
, dis
->rcItem
, title
, _hIcon
,
1540 !(dis
->itemState
& ODS_DISABLED
),
1541 dis
->itemState
&ODS_FOCUS
? true: false,
1542 dis
->itemState
&ODS_SELECTED
? true: false);
1548 StartMenuRoot::StartMenuRoot(HWND hwnd
)
1549 : super(hwnd
, true) ///@todo big icons in start menu root
1551 #ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003)
1552 if (!g_Globals
._SHRestricted
|| !SHRestricted(REST_NOCOMMONGROUPS
))
1555 // insert directory "All Users\Start Menu"
1556 ShellDirectory
cmn_startmenu(GetDesktopFolder(), SpecialFolderPath(CSIDL_COMMON_STARTMENU
, _hwnd
), _hwnd
);
1557 _dirs
.push_back(StartMenuDirectory(cmn_startmenu
, (LPCTSTR
)SpecialFolderFSPath(CSIDL_COMMON_PROGRAMS
, _hwnd
)));
1558 } catch(COMException
&) {
1559 // ignore exception and don't show additional shortcuts
1563 // insert directory "<user name>\Start Menu"
1564 ShellDirectory
usr_startmenu(GetDesktopFolder(), SpecialFolderPath(CSIDL_STARTMENU
, _hwnd
), _hwnd
);
1565 _dirs
.push_back(StartMenuDirectory(usr_startmenu
, (LPCTSTR
)SpecialFolderFSPath(CSIDL_PROGRAMS
, _hwnd
)));
1566 } catch(COMException
&) {
1567 // ignore exception and don't show additional shortcuts
1573 void StartMenuRoot::ReadLogoSize()
1575 // read size of logo bitmap
1577 GetObject(ResBitmap(GetLogoResId()), sizeof(BITMAP
), &bmp_hdr
);
1578 _logo_size
.cx
= bmp_hdr
.bmWidth
;
1579 _logo_size
.cy
= bmp_hdr
.bmHeight
;
1582 _border_left
= _logo_size
.cx
+ 1;
1586 static void CalculateStartPos(HWND hwndOwner
, RECT
& rect
, bool big_icons
)
1588 WindowRect
pos(hwndOwner
);
1590 rect
.left
= pos
.left
;
1591 rect
.top
= pos
.top
-STARTMENU_LINE_HEIGHT
-4;
1592 rect
.right
= pos
.left
+STARTMENU_WIDTH_MIN
;
1593 rect
.bottom
= pos
.top
;
1595 #ifndef _LIGHT_STARTMENU
1596 rect
.top
+= STARTMENU_LINE_HEIGHT
;
1599 AdjustWindowRectEx(&rect
, WS_POPUP
|WS_THICKFRAME
|WS_CLIPCHILDREN
|WS_VISIBLE
, FALSE
, 0);
1602 HWND
StartMenuRoot::Create(HWND hwndOwner
, bool big_icons
)
1606 CalculateStartPos(hwndOwner
, rect
, big_icons
);
1608 return Window::Create(WINDOW_CREATOR(StartMenuRoot
), 0, GetWndClasss(), TITLE_STARTMENU
,
1609 WS_POPUP
|WS_THICKFRAME
|WS_CLIPCHILDREN
,
1610 rect
.left
, rect
.top
, rect
.right
-rect
.left
, rect
.bottom
-rect
.top
, hwndOwner
);
1614 void StartMenuRoot::TrackStartmenu()
1619 #ifdef _LIGHT_STARTMENU
1623 #ifdef _LIGHT_STARTMENU
1624 // recalculate start menu root position
1627 CalculateStartPos(GetParent(hwnd
), rect
, _big_icons
);
1629 SetWindowPos(hwnd
, 0, rect
.left
, rect
.top
, rect
.right
-rect
.left
, rect
.bottom
-rect
.top
, 0);
1634 // show previously hidden start menu
1635 ShowWindow(hwnd
, SW_SHOW
);
1636 SetForegroundWindow(hwnd
);
1638 while(IsWindow(hwnd
) && IsWindowVisible(hwnd
)) {
1639 if (!GetMessage(&msg
, 0, 0, 0)) {
1640 PostQuitMessage(msg
.wParam
);
1644 // Check for a mouse click on any window, that is not part of the start menu
1645 if (msg
.message
==WM_LBUTTONDOWN
|| msg
.message
==WM_MBUTTONDOWN
|| msg
.message
==WM_RBUTTONDOWN
) {
1646 StartMenu
* menu_wnd
= NULL
;
1648 for(HWND hwnd
=msg
.hwnd
; hwnd
; hwnd
=GetParent(hwnd
)) {
1649 menu_wnd
= WINDOW_DYNAMIC_CAST(StartMenu
, hwnd
);
1662 if (pretranslate_msg(&msg
))
1665 if (dispatch_dialog_msg(&msg
))
1668 TranslateMessage(&msg
);
1671 DispatchMessage(&msg
);
1672 } catch(COMException
& e
) {
1673 HandleException(e
, _hwnd
);
1675 } catch(COMException
& e
) {
1676 HandleException(e
, _hwnd
);
1682 LRESULT
StartMenuRoot::Init(LPCREATESTRUCT pcs
)
1684 // add buttons for entries in _entries
1685 if (super::Init(pcs
))
1695 if (RegOpenKey(HKEY_CURRENT_USER
, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer"), &hkey
))
1698 if (RegOpenKey(HKEY_CURRENT_USER
, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced"), &hkeyAdv
))
1701 #define IS_VALUE_ZERO(hk, name) \
1702 (!hk || (len=sizeof(value),RegQueryValueEx(hk, name, NULL, NULL, (LPBYTE)&value, &len) || !value))
1704 #define IS_VALUE_NOT_ZERO(hk, name) \
1705 (!hk || (len=sizeof(value),RegQueryValueEx(hk, name, NULL, NULL, (LPBYTE)&value, &len) || value>0))
1709 // insert hard coded start entries
1710 AddButton(ResString(IDS_PROGRAMS
), ICID_APPS
, true, IDC_PROGRAMS
);
1712 AddButton(ResString(IDS_DOCUMENTS
), ICID_DOCUMENTS
, true, IDC_DOCUMENTS
);
1714 #ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003)
1715 if (!g_Globals
._SHRestricted
|| !SHRestricted(REST_NORECENTDOCSMENU
))
1717 if (IS_VALUE_ZERO(hkey
, _T("NoRecentDocsMenu")))
1719 AddButton(ResString(IDS_RECENT
), ICID_DOCUMENTS
, true, IDC_RECENT
);
1721 AddButton(ResString(IDS_FAVORITES
), ICID_FAVORITES
, true, IDC_FAVORITES
);
1723 AddButton(ResString(IDS_SETTINGS
), ICID_CONFIG
, true, IDC_SETTINGS
);
1725 AddButton(ResString(IDS_BROWSE
), ICID_FOLDER
, true, IDC_BROWSE
);
1727 #ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003)
1728 if (!g_Globals
._SHRestricted
|| !SHRestricted(REST_NOFIND
))
1730 if (IS_VALUE_ZERO(hkey
, _T("NoFind")))
1732 AddButton(ResString(IDS_SEARCH
), ICID_SEARCH
, true, IDC_SEARCH
);
1734 AddButton(ResString(IDS_START_HELP
), ICID_INFO
, false, IDC_START_HELP
);
1736 #ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003)
1737 if (!g_Globals
._SHRestricted
|| !SHRestricted(REST_NORUN
))
1739 if (IS_VALUE_ZERO(hkey
, _T("NoRun")))
1741 AddButton(ResString(IDS_LAUNCH
), ICID_ACTION
, false, IDC_LAUNCH
);
1747 #ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003)
1748 if (!g_Globals
._SHRestricted
|| !SHRestricted(REST_NOCLOSE
))
1750 if (IS_VALUE_NOT_ZERO(hkeyAdv
, _T("StartMenuLogoff")))
1752 AddButton(ResString(IDS_LOGOFF
), ICID_LOGOFF
, false, IDC_LOGOFF
);
1755 #ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003)
1756 if (!g_Globals
._SHRestricted
|| SHRestricted(REST_STARTMENULOGOFF
) != 1)
1758 if (IS_VALUE_ZERO(hkey
, _T("NoClose")))
1760 AddButton(ResString(IDS_SHUTDOWN
), ICID_LOGOFF
, false, IDC_SHUTDOWN
);
1764 AddButton(ResString(IDS_TERMINATE
), ICID_LOGOFF
, false, IDC_TERMINATE
);
1769 RegCloseKey(hkeyAdv
);
1774 #ifdef _LIGHT_STARTMENU
1775 // set the window size to fit all buttons
1783 void StartMenuRoot::AddEntries()
1785 super::AddEntries();
1787 AddButton(ResString(IDS_EXPLORE
), ICID_EXPLORER
, false, IDC_EXPLORE
);
1791 LRESULT
StartMenuRoot::WndProc(UINT nmsg
, WPARAM wparam
, LPARAM lparam
)
1795 PaintCanvas
canvas(_hwnd
);
1799 case WM_DISPLAYCHANGE
:
1800 // re-evaluate logo size using the correct color depth
1805 return super::WndProc(nmsg
, wparam
, lparam
);
1811 void StartMenuRoot::Paint(PaintCanvas
& canvas
)
1814 ResBitmap
bmp(GetLogoResId());
1815 BitmapSelection
sel(mem_dc
, bmp
);
1817 ClientRect
clnt(_hwnd
);
1818 int h
= min(_logo_size
.cy
, clnt
.bottom
);
1820 RECT rect
= {0, 0, _logo_size
.cx
, clnt
.bottom
-h
};
1821 HBRUSH hbr
= CreateSolidBrush(GetPixel(mem_dc
, 0, 0));
1822 FillRect(canvas
, &rect
, hbr
);
1825 PatBlt(canvas
, _logo_size
.cx
, 0, 1, clnt
.bottom
, WHITENESS
);
1827 BitBlt(canvas
, 0, clnt
.bottom
-h
, _logo_size
.cx
, h
, mem_dc
, 0, 0, SRCCOPY
);
1829 super::Paint(canvas
);
1832 UINT
StartMenuRoot::GetLogoResId()
1834 WindowCanvas
dc(_hwnd
);
1836 int clr_bits
= GetDeviceCaps(dc
, BITSPIXEL
);
1840 else if (clr_bits
> 4)
1841 return IDB_LOGOV256
;
1847 void StartMenuRoot::CloseStartMenu(int id
)
1852 ShowWindow(_hwnd
, SW_HIDE
);
1855 void StartMenuRoot::ProcessKey(int vk
)
1860 CloseOtherSubmenus();
1861 // don't close start menu root
1865 super::ProcessKey(vk
);
1870 int StartMenuHandler::Command(int id
, int code
)
1877 CreateSubmenu(id
, CSIDL_COMMON_PROGRAMS
, CSIDL_PROGRAMS
, ResString(IDS_PROGRAMS
));
1882 explorer_show_frame(SW_SHOWNORMAL
);
1887 ShowLaunchDialog(g_Globals
._hwndDesktopBar
);
1891 CreateSubmenu(id
, CSIDL_PERSONAL
, ResString(IDS_DOCUMENTS
));
1895 CreateSubmenu(id
, CSIDL_RECENT
, ResString(IDS_RECENT
), STARTMENU_CREATOR(RecentStartMenu
));
1899 #ifndef _SHELL32_FAVORITES
1900 CreateSubmenu(id
, ResString(IDS_FAVORITES
), STARTMENU_CREATOR(FavoritesMenu
), &static_cast<BookmarkList
&>(g_Globals
._favorites
));
1902 CreateSubmenu(id
, CSIDL_COMMON_FAVORITES
, CSIDL_FAVORITES
, ResString(IDS_FAVORITES
));
1907 CreateSubmenu(id
, ResString(IDS_BROWSE
), STARTMENU_CREATOR(BrowseMenu
));
1911 CreateSubmenu(id
, ResString(IDS_SETTINGS
), STARTMENU_CREATOR(SettingsMenu
));
1915 CreateSubmenu(id
, ResString(IDS_SEARCH
), STARTMENU_CREATOR(SearchMenu
));
1918 case IDC_START_HELP
:
1920 MessageBox(g_Globals
._hwndDesktopBar
, TEXT("Help not yet implemented"), ResString(IDS_TITLE
), MB_OK
);
1925 ShowLogoffDialog(g_Globals
._hwndDesktopBar
);
1930 DestroyWindow(GetParent(_hwnd
));
1936 ShowExitWindowsDialog(g_Globals
._hwndDesktopBar
);
1942 case ID_DESKTOPBAR_SETTINGS
:
1944 ExplorerPropertySheet(g_Globals
._hwndDesktopBar
);
1947 case IDC_CONTROL_PANEL
: {
1951 XMLPos explorer_options
= g_Globals
.get_cfg("general/explorer");
1952 bool mdi
= XMLBool(explorer_options
, "mdi", true);
1955 MDIMainFrame::Create(TEXT("::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{21EC2020-3AEA-1069-A2DD-08002B30309D}"), 0);
1958 SDIMainFrame::Create(TEXT("::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{21EC2020-3AEA-1069-A2DD-08002B30309D}"), 0);
1960 launch_file(_hwnd
, SHELLPATH_CONTROL_PANEL
);
1964 case IDC_SETTINGS_MENU
:
1965 CreateSubmenu(id
, CSIDL_CONTROLS
, ResString(IDS_SETTINGS_MENU
));
1968 case IDC_PRINTERS
: {
1972 #ifdef _ROS_ // to be removed when printer folder will be implemented
1973 MessageBox(0, TEXT("printer folder not yet implemented in SHELL32"), ResString(IDS_TITLE
), MB_OK
);
1976 XMLPos explorer_options
= g_Globals
.get_cfg("general/explorer");
1977 bool mdi
= XMLBool(explorer_options
, "mdi", true);
1980 MDIMainFrame::Create(TEXT("::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{2227A280-3AEA-1069-A2DE-08002B30309D}"), 0);
1983 SDIMainFrame::Create(TEXT("::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{2227A280-3AEA-1069-A2DE-08002B30309D}"), 0);
1986 launch_file(_hwnd
, SHELLPATH_PRINTERS
);
1990 case IDC_PRINTERS_MENU
:
1991 CreateSubmenu(id
, CSIDL_PRINTERS
, CSIDL_PRINTHOOD
, ResString(IDS_PRINTERS
));
1992 /* StartMenuFolders new_folders;
1995 new_folders.push_back(ShellPath(TEXT("::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{2227A280-3AEA-1069-A2DE-08002B30309D}")));
1996 } catch(COMException&) {
1999 CreateSubmenu(id, new_folders, ResString(IDS_PRINTERS));*/
2004 CreateSubmenu(id
, CSIDL_COMMON_ADMINTOOLS
, CSIDL_ADMINTOOLS
, ResString(IDS_ADMIN
));
2005 //CloseStartMenu(id);
2006 //MainFrame::Create(SpecialFolderPath(CSIDL_COMMON_ADMINTOOLS, _hwnd), OWM_PIDL);
2008 launch_file(_hwnd
, SpecialFolderFSPath(CSIDL_COMMON_ADMINTOOLS
, _hwnd
));
2012 case IDC_CONNECTIONS
:
2014 #ifdef _ROS_ // to be removed when RAS will be implemented
2015 MessageBox(0, TEXT("RAS folder not yet implemented in SHELL32"), ResString(IDS_TITLE
), MB_OK
);
2017 CreateSubmenu(id
, CSIDL_CONNECTIONS
, ResString(IDS_CONNECTIONS
));
2018 //CloseStartMenu(id);
2019 //MainFrame::Create(SpecialFolderPath(CSIDL_CONNECTIONS, _hwnd), OWM_PIDL);
2022 launch_file(_hwnd
, SHELLPATH_NET_CONNECTIONS
);
2030 #ifdef _ROS_ ///@todo to be removed when network browsing will be implemented in shell namespace
2031 MessageBox(0, TEXT("network not yet implemented"), ResString(IDS_TITLE
), MB_OK
);
2033 CreateSubmenu(id
, CSIDL_NETWORK
, ResString(IDS_NETWORK
));
2038 ///@todo exclude removable drives
2039 CreateSubmenu(id
, CSIDL_DRIVES
, ResString(IDS_DRIVES
));
2045 case IDC_SEARCH_PROGRAM
:
2047 Dialog::DoModal(IDD_SEARCH_PROGRAM
, WINDOW_CREATOR(FindProgramDlg
));
2050 case IDC_SEARCH_FILES
:
2055 case IDC_SEARCH_COMPUTER
:
2057 ShowSearchComputer();
2062 return super::Command(id
, code
);
2069 void StartMenuHandler::ShowSearchDialog()
2071 #ifndef _ROS_ ///@todo to be removed when SHFindFiles() will be implemented in shell32.dll
2072 static DynamicFct
<SHFINDFILES
> SHFindFiles(TEXT("SHELL32"), 90);
2075 (*SHFindFiles
)(NULL
, NULL
);
2078 MessageBox(0, TEXT("SHFindFiles() not yet implemented in SHELL32"), ResString(IDS_TITLE
), MB_OK
);
2081 void StartMenuHandler::ShowSearchComputer()
2083 #ifndef _ROS_ ///@todo to be removed when SHFindComputer() will be implemented in shell32.dll
2084 static DynamicFct
<SHFINDCOMPUTER
> SHFindComputer(TEXT("SHELL32"), 91);
2087 (*SHFindComputer
)(NULL
, NULL
);
2090 MessageBox(0, TEXT("SHFindComputer() not yet implemented in SHELL32"), ResString(IDS_TITLE
), MB_OK
);
2093 void StartMenuHandler::ShowLaunchDialog(HWND hwndOwner
)
2095 ///@todo All text phrases should be put into the resources.
2096 static LPCSTR szTitle
= "Run";
2097 static LPCSTR szText
= "Type the name of a program, folder, document, or Internet resource, and Explorer will open it for you.";
2099 static DynamicFct
<RUNFILEDLG
> RunFileDlg(TEXT("SHELL32"), 61);
2101 // Show "Run..." dialog
2103 #ifndef _ROS_ /* FIXME: our shell32 always expects Ansi strings */
2104 if ((HIWORD(GetVersion())>>14) == W_VER_NT
) {
2105 WCHAR wTitle
[40], wText
[256];
2107 MultiByteToWideChar(CP_ACP
, 0, szTitle
, -1, wTitle
, 40);
2108 MultiByteToWideChar(CP_ACP
, 0, szText
, -1, wText
, 256);
2110 (*RunFileDlg
)(hwndOwner
, 0, NULL
, (LPCSTR
)wTitle
, (LPCSTR
)wText
, RFF_CALCDIRECTORY
);
2114 (*RunFileDlg
)(hwndOwner
, 0, NULL
, szTitle
, szText
, RFF_CALCDIRECTORY
);
2118 void StartMenuHandler::ShowLogoffDialog(HWND hwndOwner
)
2120 static DynamicFct
<LOGOFFWINDOWSDIALOG
> LogoffWindowsDialog(TEXT("SHELL32"), 54);
2121 // static DynamicFct<RESTARTWINDOWSDLG> RestartDialog(TEXT("SHELL32"), 59);
2123 if (LogoffWindowsDialog
)
2124 (*LogoffWindowsDialog
)(0);
2125 /* The RestartDialog function prompts about some system setting change. This is not what we want to display here.
2126 else if (RestartDialog)
2127 return (*RestartDialog)(hwndOwner, (LPWSTR)L"You selected <Log Off>.\n\n", EWX_LOGOFF) == 1; ///@todo ANSI string conversion if needed
2130 MessageBox(hwndOwner
, TEXT("LogoffWindowsDialog() not yet implemented in SHELL32"), ResString(IDS_TITLE
), MB_OK
);
2133 void ShowExitWindowsDialog(HWND hwndOwner
)
2135 static DynamicFct
<EXITWINDOWSDLG
> ExitWindowsDialog(TEXT("SHELL32"), 60);
2137 if (ExitWindowsDialog
)
2138 (*ExitWindowsDialog
)(hwndOwner
);
2140 MessageBox(hwndOwner
, TEXT("ExitWindowsDialog() not yet implemented in SHELL32"), ResString(IDS_TITLE
), MB_OK
);
2144 void SettingsMenu::AddEntries()
2146 super::AddEntries();
2148 #if defined(ROSSHELL) || defined(_ROS_) // _ROS_ to be removed when printer/network will be implemented
2149 AddButton(ResString(IDS_PRINTERS
), ICID_PRINTER
, false, IDC_PRINTERS_MENU
);
2150 AddButton(ResString(IDS_CONNECTIONS
), ICID_NETWORK
, false, IDC_CONNECTIONS
);
2152 AddButton(ResString(IDS_PRINTERS
), ICID_PRINTER
, true, IDC_PRINTERS_MENU
);
2153 AddButton(ResString(IDS_CONNECTIONS
), ICID_NETWORK
, true, IDC_CONNECTIONS
);
2155 AddButton(ResString(IDS_ADMIN
), ICID_CONFIG
, true, IDC_ADMIN
);
2157 #ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003)
2158 if (!g_Globals
._SHRestricted
|| !SHRestricted(REST_NOCONTROLPANEL
))
2160 AddButton(ResString(IDS_SETTINGS_MENU
), ICID_CONFIG
, true, IDC_SETTINGS_MENU
);
2162 AddButton(ResString(IDS_DESKTOPBAR_SETTINGS
), ICID_CONFIG
, false, ID_DESKTOPBAR_SETTINGS
);
2164 AddButton(ResString(IDS_PRINTERS
), ICID_PRINTER
, false, IDC_PRINTERS
);
2166 #ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003)
2167 if (!g_Globals
._SHRestricted
|| !SHRestricted(REST_NOCONTROLPANEL
))
2169 AddButton(ResString(IDS_CONTROL_PANEL
), ICID_CONFIG
, false, IDC_CONTROL_PANEL
);
2172 void BrowseMenu::AddEntries()
2174 super::AddEntries();
2176 #ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003)
2177 if (!g_Globals
._SHRestricted
|| !SHRestricted(REST_NONETHOOD
)) // or REST_NOENTIRENETWORK ?
2179 #if defined(ROSSHELL) || defined(_ROS_) // _ROS_ to be removed when printer/network will be implemented
2180 AddButton(ResString(IDS_NETWORK
), ICID_NETWORK
, false, IDC_NETWORK
);
2182 AddButton(ResString(IDS_NETWORK
), ICID_NETWORK
, true, IDC_NETWORK
);
2185 AddButton(ResString(IDS_DRIVES
), ICID_FOLDER
, true, IDC_DRIVES
);
2188 void SearchMenu::AddEntries()
2190 super::AddEntries();
2192 AddButton(ResString(IDS_SEARCH_FILES
), ICID_SEARCH_DOC
, false, IDC_SEARCH_FILES
);
2194 #ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003)
2195 if (!g_Globals
._SHRestricted
|| !SHRestricted(REST_HASFINDCOMPUTERS
))
2197 AddButton(ResString(IDS_SEARCH_COMPUTER
),ICID_COMPUTER
, false, IDC_SEARCH_COMPUTER
);
2199 AddButton(ResString(IDS_SEARCH_PRG
), ICID_APPS
, false, IDC_SEARCH_PROGRAM
);
2203 void RecentStartMenu::AddEntries()
2205 for(StartMenuShellDirs::iterator it
=_dirs
.begin(); it
!=_dirs
.end(); ++it
) {
2206 StartMenuDirectory
& smd
= *it
;
2207 ShellDirectory
& dir
= smd
._dir
;
2209 if (!dir
._scanned
) {
2212 #ifdef _LAZY_ICONEXTRACT
2213 dir
.smart_scan(SORT_NAME
, SCAN_FILESYSTEM
);
2215 dir
.smart_scan(SORT_NAME
, SCAN_EXTRACT_ICONS
|SCAN_FILESYSTEM
);
2219 dir
.sort_directory(SORT_DATE
);
2220 AddShellEntries(dir
, RECENT_DOCS_COUNT
, smd
._ignore
); ///@todo read max. count of entries from registry
2225 #ifndef _SHELL32_FAVORITES
2227 void FavoritesMenu::AddEntries()
2229 super::AddEntries();
2231 String lwr_filter
= _create_info
._filter
;
2232 lwr_filter
.toLower();
2234 for(BookmarkList::iterator it
=_bookmarks
.begin(); it
!=_bookmarks
.end(); ++it
) {
2235 BookmarkNode
& node
= *it
;
2237 int id
= ++_next_id
;
2239 _entries
[id
] = node
;
2241 if (node
._type
== BookmarkNode::BMNT_FOLDER
) {
2242 BookmarkFolder
& folder
= *node
._pfolder
;
2244 AddButton(folder
._name
, ICID_FOLDER
, true, id
);
2245 } else if (node
._type
== BookmarkNode::BMNT_BOOKMARK
) {
2246 Bookmark
& bookmark
= *node
._pbookmark
;
2248 ICON_ID icon
= ICID_NONE
;
2250 if (!bookmark
._icon_path
.empty())
2251 icon
= g_Globals
._icon_cache
.extract(bookmark
._icon_path
, bookmark
._icon_idx
);
2253 // filter non-directory entries
2254 if (!lwr_filter
.empty()) {
2255 String lwr_name
= bookmark
._name
;
2256 String lwr_desc
= bookmark
._description
;
2257 String lwr_url
= bookmark
._url
;
2263 if (!_tcsstr(lwr_name
,lwr_filter
) && !_tcsstr(lwr_desc
,lwr_filter
) && !_tcsstr(lwr_url
,lwr_filter
))
2267 AddButton(bookmark
._name
, icon
!=ICID_NONE
?icon
:ICID_BOOKMARK
, false, id
);
2272 int FavoritesMenu::Command(int id
, int code
)
2274 BookmarkMap::iterator found
= _entries
.find(id
);
2276 if (found
!= _entries
.end()) {
2277 BookmarkNode
& node
= found
->second
;
2279 if (node
._type
== BookmarkNode::BMNT_FOLDER
) {
2280 BookmarkFolder
& folder
= *node
._pfolder
;
2282 if (CloseOtherSubmenus(id
))
2283 CreateSubmenu(id
, folder
._name
, STARTMENU_CREATOR(FavoritesMenu
), &static_cast<BookmarkList
&>(folder
._bookmarks
));
2284 } else if (node
._type
== BookmarkNode::BMNT_BOOKMARK
) {
2285 Bookmark
& bookmark
= *node
._pbookmark
;
2287 String url
= bookmark
._url
;
2288 HWND hparent
= GetParent(_hwnd
);
2292 launch_file(hparent
, url
, SW_SHOWNORMAL
);
2298 return super::Command(id
, code
);