📄 dialog.cpp
字号:
GetWindowRect(m_hMusicView, &sLoc);
GetWindowRect(m_hPlaylistView, &sLoc2);
//m_iCollapseMoveAmount = sLoc2.left - sLoc.left;
}
void MusicBrowserUI::InitDialog(HWND hWnd)
{
HIMAGELIST hList;
const int32 kNumPanes = 2;
int32 panes[kNumPanes]= {500, -1};
HINSTANCE hinst = (HINSTANCE)GetWindowLong(m_hWnd, GWL_HINSTANCE);
HICON appIcon = LoadIcon(hinst, MAKEINTRESOURCE(IDI_EXE_ICON));
SetClassLong(m_hWnd, GCL_HICON, (LONG)appIcon);
m_hWnd = hWnd;
m_hMusicView = GetDlgItem(m_hWnd, IDC_MUSICTREE);
m_hPlaylistView = GetDlgItem(m_hWnd, IDC_PLAYLISTBOX);
m_hPlaylistTitle = GetDlgItem(m_hWnd, IDC_PLAYLISTTITLE);
m_hMusicViewTitle = GetDlgItem(m_hWnd, IDC_MUSICCATALOGTEXT);
HBITMAP bmp;
hList = ImageList_Create(16, 16, ILC_COLOR24|ILC_MASK, 10, 0);
bmp = LoadBitmap(g_hinst, MAKEINTRESOURCE(IDB_CATALOG));
ImageList_AddMasked(hList, bmp, RGB(255,255,0));
DeleteObject(bmp);
bmp = LoadBitmap(g_hinst, MAKEINTRESOURCE(IDB_PLAYLIST));
ImageList_AddMasked(hList, bmp, RGB(255,0,0));
DeleteObject(bmp);
bmp = LoadBitmap(g_hinst, MAKEINTRESOURCE(IDB_ARTIST));
ImageList_AddMasked(hList, bmp, RGB(255,0,0));
DeleteObject(bmp);
bmp = LoadBitmap(g_hinst, MAKEINTRESOURCE(IDB_ALBUM));
ImageList_AddMasked(hList, bmp, RGB(255,0,0));
DeleteObject(bmp);
bmp = LoadBitmap(g_hinst, MAKEINTRESOURCE(IDB_TRACK));
ImageList_AddMasked(hList, bmp, RGB(255,0,0));
DeleteObject(bmp);
bmp = LoadBitmap(g_hinst, MAKEINTRESOURCE(IDB_ALL));
ImageList_AddMasked(hList, bmp, RGB(255,0,0));
DeleteObject(bmp);
bmp = LoadBitmap(g_hinst, MAKEINTRESOURCE(IDB_UNCATAGORIZED));
ImageList_AddMasked(hList, bmp, RGB(255,0,0));
DeleteObject(bmp);
bmp = LoadBitmap(g_hinst, MAKEINTRESOURCE(IDB_PORTABLE));
ImageList_AddMasked(hList, bmp, RGB(255,0,0));
DeleteObject(bmp);
bmp = LoadBitmap(g_hinst, MAKEINTRESOURCE(IDB_STREAMS));
ImageList_AddMasked(hList, bmp, RGB(255,0,0));
DeleteObject(bmp);
bmp = LoadBitmap(g_hinst, MAKEINTRESOURCE(IDB_WIREDPLANET));
ImageList_AddMasked(hList, bmp, RGB(255,0,0));
DeleteObject(bmp);
bmp = LoadBitmap(g_hinst, MAKEINTRESOURCE(IDB_ICECAST));
ImageList_AddMasked(hList, bmp, RGB(255,0,0));
DeleteObject(bmp);
bmp = LoadBitmap(g_hinst, MAKEINTRESOURCE(IDB_SHOUTCAST));
ImageList_AddMasked(hList, bmp, RGB(255,0,0));
DeleteObject(bmp);
bmp = LoadBitmap(g_hinst, MAKEINTRESOURCE(IDB_BUSY));
ImageList_AddMasked(hList, bmp, RGB(255,0,0));
DeleteObject(bmp);
TreeView_SetImageList(m_hMusicView, hList, TVSIL_NORMAL);
hList = ImageList_Create(16, 16, ILC_COLOR24|ILC_MASK, 1, 0);
bmp = LoadBitmap(g_hinst, MAKEINTRESOURCE(IDB_PLAYING));
ImageList_AddMasked(hList, bmp, RGB(255,0,0));
DeleteObject(bmp);
ListView_SetImageList(m_hPlaylistView, hList, LVSIL_SMALL);
InitTree();
InitList();
SetTitles();
CreateToolbar();
// Subclass the listview
// Set the proc address as a property
// of the window so it can get it
SetProp(m_hPlaylistView,
"oldproc",
(HANDLE)GetWindowLong(m_hPlaylistView, GWL_WNDPROC));
SetProp(m_hPlaylistView,
"this",
(HANDLE)this);
// Subclass the window so we can draw it
SetWindowLong(m_hPlaylistView,
GWL_WNDPROC,
(DWORD)::ListViewWndProc);
m_hPlaylistHeader = FindWindowEx(m_hPlaylistView, NULL, WC_HEADER, NULL);
if(m_hPlaylistHeader)
{
HD_ITEM hd_item;
hd_item.mask = HDI_FORMAT;
hd_item.fmt = HDF_OWNERDRAW;
Header_SetItem(m_hPlaylistHeader, 0, &hd_item);
}
// Subclass the treeview
// Set the proc address as a property
// of the window so it can get it
SetProp(m_hMusicView,
"oldproc",
(HANDLE)GetWindowLong(m_hMusicView, GWL_WNDPROC));
SetProp(m_hMusicView,
"this",
(HANDLE)this);
// Subclass the window so we can handle multi-select
SetWindowLong(m_hMusicView,
GWL_WNDPROC,
(DWORD)::TreeViewWndProc );
// register our OLE drag and drop crap
OleInitialize(NULL);
int result;
m_playlistDropTarget = new DropTarget(m_hPlaylistView);
//CoLockObjectExternal ((IUnknown*)m_playlistDropTarget, TRUE, TRUE);
result = RegisterDragDrop(m_hPlaylistView, m_playlistDropTarget);
m_hStatus= CreateStatusWindow(WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS,
"", m_hWnd, IDC_STATUS);
RECT rect;
GetClientRect(m_hWnd, &rect);
panes[0] = rect.right - rect.left - 70;
SendMessage(m_hStatus, SB_SETPARTS, kNumPanes, (LPARAM) panes);
SendMessage(m_hStatus, SB_SETTEXT, 1, (LPARAM) "0:00");
UpdateButtonMenuStates();
m_context->target->AcceptEvent(new Event(CMD_QueryPlayerState));
m_sMinSize.x = 500;
m_sMinSize.y = 300;
if (m_pParent == NULL)
{
// string lastPlaylist = FreeampDir(m_context->prefs);
// lastPlaylist += "\\currentlist.m3u";
// LoadPlaylist(lastPlaylist);
m_oPlm->SetActivePlaylist(kPlaylistKey_MasterPlaylist);
}
else if(m_portableDevice)
{
m_oPlm->SetActivePlaylist(kPlaylistKey_PortablePlaylist);
if(m_oPlm->IsPortableAvailable(m_portableDevice))
{
vector<PlaylistItem*> items;
m_oPlm->ReadPortablePlaylist(m_portableDevice, &items);
m_initialCount = items.size();
m_oPlm->AddItems(&items);
}
}
else
{
m_oPlm->SetActivePlaylist(kPlaylistKey_ExternalPlaylist);
LoadPlaylist(m_currentListName.c_str());
}
UpdateTotalTime();
if(m_pParent)
ShowWindow(m_hWnd, SW_SHOW);
else
{
bool viewMusicBrowser = true;
m_context->prefs->GetViewMusicBrowser(&viewMusicBrowser);
if(!viewMusicBrowser)
{
ExpandCollapseEvent();
}
}
}
void MusicBrowserUI::AddToolbarButtons(bool textLabels, bool images)
{
if(!textLabels && !images)
{
textLabels = true;
images = true;
}
SendMessage(m_hRebar, RB_DELETEBAND, 0, 0);
if(images && textLabels)
m_hToolbar = m_hBothToolbar;
else if(!images)
m_hToolbar = m_hTextToolbar;
else
m_hToolbar = m_hImageToolbar;
RECT windowRect, clientRect, buttonRect, rebarRect, titleRect;
uint32 top = 0;
GetWindowRect(m_hRebar, &windowRect);
GetClientRect(m_hRebar, &clientRect);
SendMessage(m_hToolbar, TB_GETITEMRECT , (WPARAM) 0, (LPARAM) &buttonRect);
REBARBANDINFO rbb;
// Initialize REBARBANDINFO for all rebar bands
rbb.cbSize = sizeof(REBARBANDINFO);
rbb.fMask = RBBIM_COLORS | // clrFore and clrBack are valid
RBBIM_CHILD | // hwndChild is valid
RBBIM_CHILDSIZE | // cxMinChild and cyMinChild are valid
RBBIM_STYLE | // fStyle is valid
RBBIM_ID; // wID is valid
rbb.clrFore = GetSysColor(COLOR_BTNTEXT);
rbb.clrBack = GetSysColor(COLOR_BTNFACE );
rbb.fStyle = RBBS_NOVERT | // do not display in vertical orientation
RBBS_CHILDEDGE;
rbb.hbmBack = NULL;
rbb.hwndChild = m_hToolbar;
rbb.wID = IDC_TOOLBAR;
rbb.cxMinChild = clientRect.right - clientRect.left;
rbb.cyMinChild = buttonRect.bottom - buttonRect.top;
// Insert band into rebar
SendMessage(m_hRebar, RB_INSERTBAND, (UINT) -1, (LPARAM) &rbb);
// resize rebar
SetWindowPos(m_hRebar, NULL,
0, 0,
windowRect.right - windowRect.left,
buttonRect.bottom - buttonRect.top + 4,
SWP_NOMOVE|SWP_NOZORDER );
GetWindowRect(m_hRebar, &rebarRect);
MapWindowPoints(NULL, m_hWnd, (LPPOINT)&rebarRect, 2);
top = rebarRect.bottom + 2;
HDWP hdwp = BeginDeferWindowPos(4);
// move music catalog and playlist views
GetWindowRect(m_hMusicViewTitle, &windowRect);
MapWindowPoints(NULL, m_hWnd, (LPPOINT)&windowRect, 2);
hdwp = DeferWindowPos(hdwp, m_hMusicViewTitle, NULL,
windowRect.left,
top,
0,
0,
SWP_NOZORDER| SWP_NOSIZE );
GetWindowRect(m_hPlaylistTitle, &windowRect);
MapWindowPoints(NULL, m_hWnd, (LPPOINT)&windowRect, 2);
hdwp = DeferWindowPos(hdwp, m_hPlaylistTitle, NULL,
windowRect.left,
top,
0,
0,
SWP_NOZORDER| SWP_NOSIZE );
GetWindowRect(m_hMusicViewTitle, &titleRect);
MapWindowPoints(NULL, m_hWnd, (LPPOINT)&titleRect, 2);
top += titleRect.bottom - titleRect.top + 3;
GetWindowRect(m_hMusicView, &windowRect);
MapWindowPoints(NULL, m_hWnd, (LPPOINT)&windowRect, 2);
hdwp = DeferWindowPos(hdwp, m_hMusicView, NULL,
windowRect.left,
top,
windowRect.right - windowRect.left,
windowRect.bottom - windowRect.top + (windowRect.top - top),
SWP_NOZORDER );
GetWindowRect(m_hPlaylistTitle, &titleRect);
MapWindowPoints(NULL, m_hWnd, (LPPOINT)&titleRect, 2);
GetWindowRect(m_hPlaylistView, &windowRect);
MapWindowPoints(NULL, m_hWnd, (LPPOINT)&windowRect, 2);
hdwp = DeferWindowPos(hdwp, m_hPlaylistView, NULL,
windowRect.left,
top,
windowRect.right - windowRect.left,
windowRect.bottom - windowRect.top + (windowRect.top - top),
SWP_NOZORDER );
EndDeferWindowPos(hdwp);
}
void MusicBrowserUI::CreateToolbar()
{
INITCOMMONCONTROLSEX icex;
RECT rect;
RECT dummyRect;
HWND hwndDummy = GetDlgItem(m_hWnd, IDC_DUMMYCONTROL);
GetWindowRect(hwndDummy, &dummyRect);
int32 toolbarHeight = dummyRect.bottom - dummyRect.top;
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
icex.dwICC = ICC_COOL_CLASSES ; // load the rebar
InitCommonControlsEx(&icex);
GetClientRect(m_hWnd, &rect);
// Create the REBAR control
m_hRebar = CreateWindowEx(
0L,
REBARCLASSNAME,
NULL,
WS_VISIBLE | WS_BORDER | WS_CHILD | 0 |
WS_CLIPSIBLINGS | CCS_NODIVIDER | RBS_VARHEIGHT |
RBS_BANDBORDERS | CCS_NOPARENTALIGN,
0, 0, rect.right - rect.left, toolbarHeight,
m_hWnd,
(HMENU)IDC_REBAR,
g_hinst,
NULL );
m_hImageToolbar = CreateWindowEx(0, TOOLBARCLASSNAME, (LPSTR) NULL,
WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT |
TBSTYLE_TOOLTIPS | WS_CLIPCHILDREN |
WS_CLIPSIBLINGS | CCS_NODIVIDER | CCS_NORESIZE,
0, 0, 0, 0, m_hRebar, (HMENU) IDC_TOOLBAR, g_hinst, NULL);
m_hTextToolbar = CreateWindowEx(0, TOOLBARCLASSNAME, (LPSTR) NULL,
WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT |
TBSTYLE_TOOLTIPS | WS_CLIPCHILDREN |
WS_CLIPSIBLINGS | CCS_NODIVIDER | CCS_NORESIZE,
0, 0, 0, 0, m_hRebar, (HMENU) IDC_TOOLBAR + 1, g_hinst, NULL);
m_hBothToolbar = CreateWindowEx(0, TOOLBARCLASSNAME, (LPSTR) NULL,
WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT |
TBSTYLE_TOOLTIPS | WS_CLIPCHILDREN |
WS_CLIPSIBLINGS | CCS_NODIVIDER | CCS_NORESIZE,
0, 0, 0, 0, m_hRebar, (HMENU) IDC_TOOLBAR + 2, g_hinst, NULL);
// Send the TB_BUTTONSTRUCTSIZE message, which is required for
// backward compatibility.
SendMessage(m_hImageToolbar, TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), 0);
SendMessage(m_hTextToolbar, TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), 0);
SendMessage(m_hBothToolbar, TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), 0);
SendMessage(m_hImageToolbar, TB_SETBITMAPSIZE, 0, MAKELPARAM(22, 18));
SendMessage(m_hTextToolbar, TB_SETBITMAPSIZE, 0, MAKELPARAM(0, 0));
SendMessage(m_hBothToolbar, TB_SETBITMAPSIZE, 0, MAKELPARAM(22, 18));
TBADDBITMAP tbab;
// Add the bitmap containing button images to the toolbar.
tbab.hInst = g_hinst;
tbab.nID = IDB_TOOLBAR;
SendMessage(m_hImageToolbar, TB_ADDBITMAP, (WPARAM) 10, (WPARAM) &tbab);
SendMessage(m_hBothToolbar, TB_ADDBITMAP, (WPARAM) 10, (WPARAM) &tbab);
SendMessage(m_hImageToolbar, TB_ADDBUTTONS, (WPARAM) 11, (LPARAM) &tbButtons);
SendMessage(m_hImageToolbar, TB_AUTOSIZE, (WPARAM) 0, (LPARAM) 0);
tbButtons[0].iString = SendMessage(m_hBothToolbar, TB_ADDSTRING, (WPARAM) 0, (LPARAM)"New Playlist");
tbButtons[1].iString = SendMessage(m_hBothToolbar, TB_ADDSTRING, (WPARAM) 0, (LPARAM)"Save Playlist");
tbButtons[3].iString = SendMessage(m_hBothToolbar, TB_ADDSTRING, (WPARAM) 0, (LPARAM)"Import Items");
tbButtons[4].iString = SendMessage(m_hBothToolbar, TB_ADDSTRING, (WPARAM) 0, (LPARAM)"Remove Items");
tbButtons[5].iString = SendMessage(m_hBothToolbar, TB_ADDSTRING, (WPARAM) 0, (LPARAM)"Edit Info");
tbButtons[7].iString = SendMessage(m_hBothToolbar, TB_ADDSTRING, (WPARAM) 0, (LPARAM)"Add Items");
tbButtons[8].iString = SendMessage(m_hBothToolbar, TB_ADDSTRING, (WPARAM) 0, (LPARAM)"Add Files");
tbButtons[9].iString = SendMessage(m_hBothToolbar, TB_ADDSTRING, (WPARAM) 0, (LPARAM)"Move Up");
tbButtons[10].iString = SendMessage(m_hBothToolbar, TB_ADDSTRING, (WPARAM) 0, (LPARAM)"Move Down");
SendMessage(m_hBothToolbar, TB_ADDBUTTONS, (WPARAM) 11, (LPARAM) &tbButtons);
SendMessage(m_hBothToolbar, TB_AUTOSIZE, (WPARAM) 0, (LPARAM) 0);
tbButtons[0].iString = SendMessage(m_hTextToolbar, TB_ADDSTRING, (WPARAM) 0, (LPARAM)"New Playlist");
tbButtons[1].iString = SendMessage(m_hTextToolbar, TB_ADDSTRING, (WPARAM) 0, (LPARAM)"Save Playlist");
tbButtons[3].iString = SendMessage(m_hTextToolbar, TB_ADDSTRING, (WPARAM) 0, (LPARAM)"Import Items");
tbButtons[4].iString = SendMessage(m_hTextToolbar, TB_ADDSTRING, (WPARAM) 0, (LPARAM)"Remove Items");
tbButtons[5].iString = SendMessage(m_hTextToolbar, TB_ADDSTRING, (WPARAM) 0, (LPARAM)"Edit Info");
tbButtons[7].iString = SendMessage(m_hTextToolbar, TB_ADDSTRING, (WPARAM) 0, (LPARAM)"Add Items");
tbButtons[8].iString = SendMessage(m_hTextToolbar, TB_ADDSTRING, (WPARAM) 0, (LPARAM)"Add Files");
tbButtons[9].iString = SendMessage(m_hTextToolbar, TB_ADDSTRING, (WPARAM) 0, (LPARAM)"Move Up");
tbButtons[10].iString = SendMessage(m_hTextToolbar, TB_ADDSTRING, (WPARAM) 0, (LPARAM)"Move Down");
SendMessage(m_hTextToolbar, TB_ADDBUTTONS, (WPARAM) 11, (LPARAM) &tbButtons);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -