📄 dialog.cpp
字号:
MoveWindow(m_hPlaylistTitle,
titleRect.left,
titleRect.top,
(titleRect.right - titleRect.left),
titleRect.bottom - titleRect.top,
TRUE);
m_splitterRect.top = playlistRect.top;
m_splitterRect.bottom = playlistRect.bottom;
m_splitterRect.left = catalogRect.right + 1;
m_splitterRect.right = playlistRect.left - 1;
// resize headers... only wanna do this if we resized the window
int32 a,b,c,d,e,f,g,h;
size = sizeof(buf);
m_context->prefs->GetPrefString(kMusicBrowserHeaderWidthsPref, buf, &size);
if (sscanf(buf, " %d , %d , %d , %d , %d , %d , %d , %d", &a, &b, &c, &d,
&e, &f, &g, &h)
!= 8)
{
sscanf(buf, " %d , %d , %d , %d", &a, &b, &c, &d);
if(a >= 1 && b >= 5 && c >= 5 && d >= 5)
{
ListView_SetColumnWidth(m_hPlaylistView, 1, a);
ListView_SetColumnWidth(m_hPlaylistView, 2, b);
ListView_SetColumnWidth(m_hPlaylistView, 3, c);
ListView_SetColumnWidth(m_hPlaylistView, 4, d);
}
}
else
{
if(a >= 1 && b >= 5 && c >= 5 && d >= 5)
{
ListView_SetColumnWidth(m_hPlaylistView, 1, a);
ListView_SetColumnWidth(m_hPlaylistView, 2, b);
ListView_SetColumnWidth(m_hPlaylistView, 3, c);
ListView_SetColumnWidth(m_hPlaylistView, 4, d);
ListView_SetColumnWidth(m_hPlaylistView, 5, e);
ListView_SetColumnWidth(m_hPlaylistView, 6, f);
ListView_SetColumnWidth(m_hPlaylistView, 7, g);
ListView_SetColumnWidth(m_hPlaylistView, 8, h);
}
}
}
if(m_pParent)
{
ShowWindow(m_hWnd, SW_SHOW);
SetForegroundWindow(m_hWnd);
}
else
{
bool viewMusicBrowser = true;
m_context->prefs->GetPrefBoolean(kViewMusicBrowserPref, &viewMusicBrowser);
if(!viewMusicBrowser)
{
ExpandCollapseEvent();
}
}
bool check;
m_context->prefs->GetPrefBoolean(kCheckCDAutomaticallyPref, &check);
if (check)
CheckForCD();
m_initialized = true;
// UGLY hack to fix threading issue with win98 osr2 creating blank my music tree
m_context->target->AcceptEvent(new Event(INFO_MusicCatalogCleared));
}
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);
SendMessage(m_hTextToolbar, TB_AUTOSIZE, (WPARAM) 0, (LPARAM) 0);
RECT buttonRect;
SIZE sizeString;
char temp[] = "HowBigAmI?";
HDC hdc = GetDC(m_hTextToolbar);
SendMessage(m_hTextToolbar, TB_GETITEMRECT , (WPARAM) 0, (LPARAM) &buttonRect);
GetTextExtentPoint32(hdc, temp, strlen(temp), &sizeString);
ReleaseDC(m_hTextToolbar, hdc);
SendMessage(m_hTextToolbar, TB_SETBUTTONSIZE , 0,
MAKELPARAM(buttonRect.right - buttonRect.left, sizeString.cy + 6));
bool useTextLabels, useImages;
m_context->prefs->GetPrefBoolean(kShowToolbarTextLabelsPref, &useTextLabels);
m_context->prefs->GetPrefBoolean(kShowToolbarImagesPref, &useImages);
AddToolbarButtons(useTextLabels, useImages);
}
void MusicBrowserUI::SetTitles()
{
if (m_pParent == NULL)
{
SetWindowText(m_hPlaylistTitle,
"Currently Listening To:");
SetWindowText(m_hWnd,
"My Music - " BRANDING);
}
else
{
string oTitle, oName;
if (m_currentListName.length() == 0)
oName = "New Playlist";
else
{
char szBase[MAX_PATH];
_splitpath(m_currentListName.c_str(), NULL, NULL, szBase, NULL);
oName = szBase;
}
oTitle = string("Editing playlist: ") + oName;
SetWindowText(m_hPlaylistTitle,
oTitle.c_str());
oTitle = "Editing " + oName + " - " + BRANDING;
SetWindowText(m_hWnd, oTitle.c_str());
}
}
void MusicBrowserUI::DropFiles(HDROP dropHandle, bool filesAreURLs)
{
uint32 count;
char url[1024];
count = DragQueryFile( dropHandle,
-1L,
url,
sizeof(url));
for(uint32 i = 0; i < count; i++)
{
DragQueryFile( dropHandle,
i,
url,
sizeof(url));
//MessageBox(NULL, url, "url", MB_OK);
}
}
BOOL MusicBrowserUI::SetCursor(int hitTest, int mouseMsg)
{
BOOL result = FALSE;
if(hitTest == HTCLIENT)
{
result = TRUE;
}
return result;
}
void MusicBrowserUI::MouseMove(uint32 uFlags, POINT &sPoint)
{
if(m_trackSplitter)
{
HDC hdc = GetDC(NULL);
POINT pt = sPoint;
MapWindowPoints(m_hWnd, NULL, (LPPOINT)&pt, 1);
HBRUSH oldBrush = (HBRUSH)SelectObject(hdc, m_splitterBrush);
PatBlt(hdc,
m_splitterRect.left,
m_splitterRect.top,
m_splitterRect.right - m_splitterRect.left,
m_splitterRect.bottom - m_splitterRect.top,
PATINVERT);
OffsetRect(&m_splitterRect, (pt.x - m_splitterRect.left), 0);
PatBlt(hdc,
m_splitterRect.left,
m_splitterRect.top,
m_splitterRect.right - m_splitterRect.left,
m_splitterRect.bottom - m_splitterRect.top,
PATINVERT);
SelectObject(hdc, oldBrush);
ReleaseDC(NULL, hdc);
}
else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -