Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes

QuickLaunchBar Struct Reference

quick launch bar window More...

#include <quicklaunch.h>

Inheritance diagram for QuickLaunchBar:
Inheritance graph
Collaboration diagram for QuickLaunchBar:
Collaboration graph

List of all members.

Public Types

typedef ExtContextMenuHandlerT
< SubclassedWindow

Public Member Functions

 QuickLaunchBar (HWND hwnd)
 ~QuickLaunchBar ()

Static Public Member Functions

static HWND Create (HWND hwndParent)

Protected Member Functions

LRESULT WndProc (UINT nmsg, WPARAM wparam, LPARAM lparam)
int Command (int id, int code)
int Notify (int id, NMHDR *pnmh)
void AddShortcuts ()
void AddButton (int id, HBITMAP hbmp, LPCTSTR name, Entry *entry, int flags=TBSTATE_ENABLED)
void UpdateDesktopButtons (int desktop_idx)

Protected Attributes

int _next_id
QuickLaunchMap _entries
int _btn_dist
int _size

Detailed Description

quick launch bar window

Definition at line 60 of file quicklaunch.h.

Member Typedef Documentation

Reimplemented from ExtContextMenuHandlerT< SubclassedWindow >.

Definition at line 62 of file quicklaunch.h.

Constructor & Destructor Documentation

QuickLaunchBar::QuickLaunchBar ( HWND  hwnd )

Definition at line 51 of file quicklaunch.cpp.

References _btn_dist, _dir, _next_id, _size, CONTEXT, HWND, IDC_FIRST_QUICK_ID, PM_REFRESH, and SetWindowStyle.

Referenced by Create().

 :  super(hwnd)

    _dir = NULL;
    _next_id = IDC_FIRST_QUICK_ID;
    _btn_dist = 20;
    _size = 0;

    HWND hwndToolTip = (HWND) SendMessage(hwnd, TB_GETTOOLTIPS, 0, 0);

    SetWindowStyle(hwndToolTip, GetWindowStyle(hwndToolTip)|TTS_ALWAYSTIP);

     // delay refresh to some time later
    PostMessage(hwnd, PM_REFRESH, 0, 0);

Here is the caller graph for this function:

QuickLaunchBar::~QuickLaunchBar (  )

Definition at line 69 of file quicklaunch.cpp.

References _dir.

    delete _dir;

Member Function Documentation

void QuickLaunchBar::AddButton ( int  id,
HBITMAP  hbmp,
LPCTSTR  name,
Entry entry,
int  flags = TBSTATE_ENABLED 
) [protected]

Definition at line 177 of file quicklaunch.cpp.

References _entries, QuickLaunchEntry::_entry, QuickLaunchEntry::_hbmp, WindowHandle::_hwnd, and QuickLaunchEntry::_title.

Referenced by AddShortcuts().

    TBADDBITMAP ab = {0, (UINT_PTR)hbmp};
    int bmp_idx = SendMessage(_hwnd, TB_ADDBITMAP, 1, (LPARAM)&ab);

    QuickLaunchEntry qle;

    qle._hbmp = hbmp;
    qle._title = name;
    qle._entry = entry;

    _entries[id] = qle;

    TBBUTTON btn = {0, 0, flags, BTNS_BUTTON|BTNS_NOPREFIX, {0, 0}, 0, 0};

    btn.idCommand = id;
    btn.iBitmap = bmp_idx;

    SendMessage(_hwnd, TB_INSERTBUTTON, INT_MAX, (LPARAM)&btn);

Here is the caller graph for this function:

void QuickLaunchBar::AddShortcuts (  ) [protected]

perhaps also look into CSIDL_COMMON_APPDATA ?

Definition at line 92 of file quicklaunch.cpp.

References _btn_dist, Desktops::_current_desktop, ExplorerGlobals::_desktops, _dir, Entry::_down, _entries, WindowHandle::_hwnd, ExplorerGlobals::_icon_cache, Entry::_next, _next_id, _size, _stprintf, AddButton(), CONTEXT, Icon::create_bitmap(), DESKTOP_COUNT, g_Globals, IconCache::get_icon(), GetDesktopFolder(), ICF_NORMAL, ICID_EXPLORER, ICID_MINIMIZE, ID_EXPLORE, ID_MINIMIZE_ALL, ID_SWITCH_DESKTOP_1, IDS_DESKTOP_NUM, IDS_MINIMIZE_ALL, IDS_TITLE, PM_RESIZE_CHILDREN, QUICKLAUNCH_FOLDER, RecursiveCreateDirectory(), Entry::smart_scan(), SORT_NAME, and TEXT.

Referenced by WndProc().


    WaitCursor wait;

    try {
        TCHAR path[MAX_PATH];

        SpecialFolderFSPath app_data(CSIDL_APPDATA, _hwnd); ///@todo perhaps also look into CSIDL_COMMON_APPDATA ?

        _stprintf(path, TEXT("%s\\")QUICKLAUNCH_FOLDER, (LPCTSTR)app_data);

        _dir = new ShellDirectory(GetDesktopFolder(), path, _hwnd);


         // immediatelly extract the shortcut icons
        for(Entry*entry=_dir->_down; entry; entry=entry->_next)
            entry->_icon_id = entry->safe_extract_icon(ICF_NORMAL);
    } catch(COMException&) {

    ShellFolder desktop_folder;
    WindowCanvas canvas(_hwnd);

    COLORREF bk_color = GetSysColor(COLOR_BTNFACE);
    HBRUSH bk_brush = GetSysColorBrush(COLOR_BTNFACE);

    AddButton(ID_MINIMIZE_ALL, g_Globals._icon_cache.get_icon(ICID_MINIMIZE).create_bitmap(bk_color, bk_brush, canvas), ResString(IDS_MINIMIZE_ALL), NULL);
    AddButton(ID_EXPLORE, g_Globals._icon_cache.get_icon(ICID_EXPLORER).create_bitmap(bk_color, bk_brush, canvas), ResString(IDS_TITLE), NULL);

    TBBUTTON sep = {0, -1, TBSTATE_ENABLED, BTNS_SEP, {0, 0}, 0, 0};
    SendMessage(_hwnd, TB_INSERTBUTTON, INT_MAX, (LPARAM)&sep);

    int cur_desktop = g_Globals._desktops._current_desktop;
    ResString desktop_fmt(IDS_DESKTOP_NUM);

    HDC hdc = CreateCompatibleDC(canvas);
    DWORD size = SendMessage(_hwnd, TB_GETBUTTONSIZE, 0, 0);
    int cx = LOWORD(size);
    int cy = HIWORD(size);
    RECT rect = {0, 0, cx, cy};
    RECT textRect = {0, 0, cx-7, cy-7};

    for(int i=0; i<DESKTOP_COUNT; ++i) {
        HBITMAP hbmp = CreateCompatibleBitmap(canvas, cx, cy);
        HBITMAP hbmp_old = SelectBitmap(hdc, hbmp);

        FmtString num_txt(TEXT("%d"), i+1);
        TextColor color(hdc, RGB(64,64,64));
        BkMode mode(hdc, TRANSPARENT);
        FillRect(hdc, &rect, GetSysColorBrush(COLOR_BTNFACE));
        DrawText(hdc, num_txt, num_txt.length(), &textRect, DT_CENTER|DT_VCENTER|DT_SINGLELINE);

        SelectBitmap(hdc, hbmp_old);

        AddButton(ID_SWITCH_DESKTOP_1+i, hbmp, FmtString(desktop_fmt, i+1), NULL, cur_desktop==i?TBSTATE_ENABLED|TBSTATE_CHECKED:TBSTATE_ENABLED);

    SendMessage(_hwnd, TB_INSERTBUTTON, INT_MAX, (LPARAM)&sep);

    for(Entry*entry=_dir->_down; entry; entry=entry->_next) {
         // hide files like "desktop.ini"
        if (entry->_data.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)

         // hide subfolders
        if (!(entry->_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
            HBITMAP hbmp = g_Globals._icon_cache.get_icon(entry->_icon_id).create_bitmap(bk_color, bk_brush, canvas);

            AddButton(_next_id++, hbmp, entry->_display_name, entry);   //entry->_etype==ET_SHELL? desktop_folder.get_name(static_cast<ShellEntry*>(entry)->_pidl): entry->_display_name);

    _btn_dist = LOWORD(SendMessage(_hwnd, TB_GETBUTTONSIZE, 0, 0));
    _size = _entries.size() * _btn_dist;

    SendMessage(GetParent(_hwnd), PM_RESIZE_CHILDREN, 0, 0);

Here is the call graph for this function:

Here is the caller graph for this function:

int QuickLaunchBar::Command ( int  id,
int  code 
) [protected, virtual]

Reimplemented from SubclassedWindow.

Definition at line 271 of file quicklaunch.cpp.

References _entries, QuickLaunchEntry::_entry, WindowHandle::_hwnd, CONTEXT, IDC_FIRST_QUICK_ID, and Entry::launch_entry().


    if ((id&~0xFF) == IDC_FIRST_QUICK_ID) {
        QuickLaunchEntry& qle = _entries[id];

        if (qle._entry) {
            return 0;

    return 0; // Don't return 1 to avoid recursion with DesktopBar::Command()

Here is the call graph for this function:

HWND QuickLaunchBar::Create ( HWND  hwndParent ) [static]

Definition at line 74 of file quicklaunch.cpp.

References CONTEXT, HWND, IDW_QUICKLAUNCHBAR, and QuickLaunchBar().


    ClientRect clnt(hwndParent);

    HWND hwnd = CreateToolbarEx(hwndParent,
                                IDW_QUICKLAUNCHBAR, 0, 0, 0, NULL, 0, 0, 0, 16, 16, sizeof(TBBUTTON));

    if (hwnd)
        new QuickLaunchBar(hwnd);

    return hwnd;

Here is the call graph for this function:

int QuickLaunchBar::Notify ( int  id,
NMHDR *  pnmh 
) [protected, virtual]

Reimplemented from SubclassedWindow.

Definition at line 287 of file quicklaunch.cpp.

References _entries, and SubclassedWindow::Notify().

    switch(pnmh->code) {
      case TTN_GETDISPINFO: {
        NMTTDISPINFO* ttdi = (NMTTDISPINFO*) pnmh;

        int id = ttdi->hdr.idFrom;
        ttdi->lpszText = _entries[id]._title.str();
        ttdi->uFlags |= TTF_DI_SETITEM;

         // enable multiline tooltips (break at CR/LF and for very long one-line strings)
        SendMessage(pnmh->hwndFrom, TTM_SETMAXTIPWIDTH, 0, 400);


        return super::Notify(id, pnmh);

    return 0;

Here is the call graph for this function:

void QuickLaunchBar::UpdateDesktopButtons ( int  desktop_idx ) [protected]

Definition at line 198 of file quicklaunch.cpp.

References WindowHandle::_hwnd, DESKTOP_COUNT, and ID_SWITCH_DESKTOP_1.

Referenced by WndProc().

    for(int i=0; i<DESKTOP_COUNT; ++i) {

        SendMessage(_hwnd, TB_SETBUTTONINFO, ID_SWITCH_DESKTOP_1+i, (LPARAM)&tbi);

Here is the caller graph for this function:

LRESULT QuickLaunchBar::WndProc ( UINT  nmsg,
WPARAM  wparam,
LPARAM  lparam 
) [protected, virtual]

Reimplemented from ExtContextMenuHandlerT< SubclassedWindow >.

Definition at line 207 of file quicklaunch.cpp.

References ExtContextMenuHandlerT< SubclassedWindow >::_cm_ifs, _entries, WindowHandle::_hwnd, _size, AddShortcuts(), CHECKERROR, Entry::do_context_menu(), PM_GET_WIDTH, PM_REFRESH, PM_UPDATE_DESKTOP, ScreenToClient(), UpdateDesktopButtons(), and ExtContextMenuHandlerT< SubclassedWindow >::WndProc().

    switch(nmsg) {
      case PM_REFRESH:

      case PM_GET_WIDTH: {
         // take line wrapping into account
        int btns = SendMessage(_hwnd, TB_BUTTONCOUNT, 0, 0);
        int rows = SendMessage(_hwnd, TB_GETROWS, 0, 0);

        if (rows<2 || rows==btns)
            return _size;

        RECT rect;
        int max_cx = 0;

        for(QuickLaunchMap::const_iterator it=_entries.begin(); it!=_entries.end(); ++it) {
            SendMessage(_hwnd, TB_GETRECT, it->first, (LPARAM)&rect);

            if (rect.right > max_cx)
                max_cx = rect.right;

        return max_cx;}


      case WM_CONTEXTMENU: {
        TBBUTTON btn;
        QuickLaunchMap::iterator it;
        Point screen_pt(lparam), clnt_pt=screen_pt;
        ScreenToClient(_hwnd, &clnt_pt);

        Entry* entry = NULL;
        int idx = SendMessage(_hwnd, TB_HITTEST, 0, (LPARAM)&clnt_pt);

        if (idx>=0 &&
            SendMessage(_hwnd, TB_GETBUTTON, idx, (LPARAM)&btn)!=-1 &&
            (it=_entries.find(btn.idCommand))!=_entries.end()) {
            entry = it->second._entry;

        if (entry) {    // entry is NULL for desktop switch buttons
            HRESULT hr = entry->do_context_menu(_hwnd, screen_pt, _cm_ifs);

            if (SUCCEEDED(hr))
                AddShortcuts(); //refresh();
        } else
            goto def;

      default: def:
        return super::WndProc(nmsg, wparam, lparam);

    return 0;

Here is the call graph for this function:

Member Data Documentation

int QuickLaunchBar::_btn_dist [protected]

Definition at line 78 of file quicklaunch.h.

Referenced by AddShortcuts(), and QuickLaunchBar().

Definition at line 74 of file quicklaunch.h.

Referenced by AddShortcuts(), QuickLaunchBar(), and ~QuickLaunchBar().

Definition at line 77 of file quicklaunch.h.

Referenced by AddButton(), AddShortcuts(), Command(), Notify(), and WndProc().

int QuickLaunchBar::_next_id [protected]

Definition at line 76 of file quicklaunch.h.

Referenced by AddShortcuts(), and QuickLaunchBar().

int QuickLaunchBar::_size [protected]

Definition at line 79 of file quicklaunch.h.

Referenced by AddShortcuts(), QuickLaunchBar(), and WndProc().

The documentation for this struct was generated from the following files:

ROS Explorer Source Code Documentation
generated on 02.01.2013 by doxygen

ROS Explorer Homepage