📄 introductionwizard.cpp
字号:
GetObject(GetStockObject(DEFAULT_GUI_FONT), sizeof(LOGFONT), &lf);
lf.lfWeight = FW_BOLD;
font = CreateFontIndirect(&lf);
oldFont = (HFONT)SelectObject(dis->hDC, font);
RECT clientRect;
GetClientRect(dis->hwndItem, &clientRect);
const char* caption;
if(ctrlId == IDC_CAPTION1)
caption = kCaption1;
else if(ctrlId == IDC_CAPTION2)
caption = kCaption2;
DrawText(dis->hDC,
caption,
strlen(caption),
&clientRect,
DT_LEFT|DT_WORDBREAK);
SelectObject(dis->hDC, oldFont);
DeleteObject(font);
break;
}
case IDC_TEXT1:
case IDC_TEXT2:
{
HFONT font, oldFont;
font = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
oldFont = (HFONT)SelectObject(dis->hDC, font);
RECT clientRect;
GetClientRect(dis->hwndItem, &clientRect);
const char* text;
if(ctrlId == IDC_TEXT1)
text = kMsg1;
else if(ctrlId == IDC_TEXT2)
text = kMsg2;
DrawText(dis->hDC,
text,
strlen(text),
&clientRect,
DT_LEFT|DT_WORDBREAK);
SelectObject(dis->hDC, oldFont);
DeleteObject(font);
break;
}
}
break;
}
case WM_COMMAND:
{
switch(LOWORD(wParam))
{
case IDC_DRIVES:
{
if(HIWORD(wParam) == CBN_CLOSEUP)
{
HWND hwndCombo = (HWND) lParam;
char temp[MAX_PATH];
int32 sel = ComboBox_GetCurSel(hwndCombo);
ComboBox_GetText( hwndCombo,
temp,
MAX_PATH);
HWND hwndDirectory = GetDlgItem(hwnd, IDC_DIRECTORY);
HWND hwndBrowse = GetDlgItem(hwnd, IDC_BROWSE);
BOOL enable = strcmp(temp, "All Drives");
if(!enable)
strcpy(temp, "All Folders");
else
sprintf(temp, "%s\\", temp);
Edit_SetText(hwndDirectory, temp);
//EnableWindow(hwndText, enable);
//EnableWindow(hwndDirectory, enable);
EnableWindow(hwndBrowse, enable);
}
break;
}
case IDC_DIRECTORY:
{
/*if(HIWORD(wParam) == EN_CHANGE)
{
char temp[MAX_PATH];
HWND hwndEdit = (HWND) lParam;
Edit_GetText( hwndEdit,
temp,
MAX_PATH);
}*/
break;
}
case IDC_BROWSE:
{
LPMALLOC pMalloc;
if(SUCCEEDED(SHGetMalloc(&pMalloc)))
{
HWND hwndDrives = GetDlgItem(hwnd, IDC_DRIVES);
HWND hwndDirectory = GetDlgItem(hwnd, IDC_DIRECTORY);
char temp[MAX_PATH];
LPITEMIDLIST pidlDrive;
// get the PIDL for this dir and set the root
LPSHELLFOLDER desktop;
if(SUCCEEDED(SHGetDesktopFolder(&desktop)))
{
OLECHAR drive[MAX_PATH];
OLECHAR path[MAX_PATH];
ULONG eaten;
LPITEMIDLIST pidlPath;
ComboBox_GetText(hwndDrives,
temp,
MAX_PATH);
strcat(temp, "\\");
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, temp,
-1, drive, sizeof(drive));
desktop->ParseDisplayName(hwnd, NULL, drive, &eaten, &pidlDrive, NULL);
Edit_GetText(hwndDirectory,
temp,
MAX_PATH);
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, temp,
-1, path, sizeof(path));
desktop->ParseDisplayName(hwnd, NULL, path, &eaten, &pidlPath, NULL);
BROWSEINFO bi;
LPITEMIDLIST browseId;
char displayName[MAX_PATH + 1];
bi.hwndOwner = hwnd;
bi.pidlRoot = pidlDrive;
bi.pszDisplayName = displayName;
bi.lpszTitle = "Please select the folder in which you want to search.";
bi.ulFlags = BIF_RETURNONLYFSDIRS;
bi.lpfn = BrowseCallbackProc;
bi.lParam = (LPARAM)pidlPath;
browseId = SHBrowseForFolder(&bi);
if(browseId)
{
SHGetPathFromIDList(browseId, temp);
Edit_SetText(hwndDirectory, temp);
pMalloc->Free(browseId);
}
// clean up
if(pidlPath)
pMalloc->Free(pidlPath);
if(pidlDrive)
pMalloc->Free(pidlDrive);
desktop->Release();
}
}
break;
}
}
break;
}
case WM_NOTIFY:
{
switch(((NMHDR*)lParam)->code)
{
case PSN_KILLACTIVE:
{
SetWindowLong(hwnd, DWL_MSGRESULT, FALSE);
result = TRUE;
break;
}
case PSN_RESET:
{
SetWindowLong(hwnd, DWL_MSGRESULT, FALSE);
break;
}
case PSN_SETACTIVE:
{
PropSheet_SetWizButtons(GetParent(hwnd), PSWIZB_BACK | PSWIZB_FINISH);
//HWND hwndFinish = GetDlgItem(GetParent(hwnd), 3025);
HWND hwndFinish = FindWindowEx(GetParent(hwnd), NULL, NULL, "Finish");
SetWindowText(hwndFinish, "Search");
break;
}
case PSN_WIZFINISH:
{
HWND hwndDrives = GetDlgItem(hwnd, IDC_DRIVES);
HWND hwndDirectory = GetDlgItem(hwnd, IDC_DIRECTORY);
char temp[MAX_PATH];
ComboBox_GetText(hwndDrives,
temp,
MAX_PATH);
BOOL allDrives = !strcmp(temp, "All Drives");
if(allDrives)
{
DWORD dwDrives;
char *szDrive = new char[5];
memset(szDrive, 0x00, sizeof(char)*5);
szDrive[1] = ':';
int32 i, ret;
dwDrives = GetLogicalDrives();
for(i = 0; i < sizeof(DWORD) * 8; i++)
{
if (dwDrives & (1 << i))
{
szDrive[0] = 'A' + i;
ret = GetDriveType(szDrive);
if (ret != DRIVE_CDROM && ret != DRIVE_REMOVABLE)
{
searchPaths->push_back(szDrive);
}
}
}
delete [] szDrive;
}
else
{
Edit_GetText(hwndDirectory,
temp,
MAX_PATH);
searchPaths->push_back(temp);
}
break;
}
case PSN_WIZBACK:
{
break;
}
}
break;
}
}
return result;
}
static BOOL CALLBACK IntroWizardRelatable(HWND hwnd,
UINT msg,
WPARAM wParam,
LPARAM lParam)
{
BOOL result = FALSE;
static HWND hwndOptIn = NULL;
static HWND hwndOptOut = NULL;
switch(msg)
{
case WM_INITDIALOG:
{
hwndOptIn = GetDlgItem(hwnd, IDC_RELATABLE_YES);
hwndOptOut = GetDlgItem(hwnd, IDC_RELATABLE_NO);
PROPSHEETPAGE *psp = (PROPSHEETPAGE*)lParam;
Button_SetCheck(hwndOptIn, TRUE);
Button_SetCheck(hwndOptOut, FALSE);
break;
}
case WM_DRAWITEM:
{
DRAWITEMSTRUCT* dis = (DRAWITEMSTRUCT*)lParam;
UINT ctrlId = wParam;
const char* kCaption1 = "Check out Relatable's new recommendation features";
const char* kMsg1 = "This version of "the_BRANDING" offers Relatable features that automatically\n"
"recommend music playlists and streams. It's our first public test of\n"
"an exciting new approach to discovering music. Relatable's system\n"
"'learns' listener preferences through "the_BRANDING" and compares them\n"
"with the preferences of like-minded listeners. Like virtual 'word of\n"
"mouth', Relatable introduces you to music that people like\n"
"you have enjoyed.";
const char* kCaption2 = "Private by Design";
const char* kMsg2 = "Please note that Relatable profiles are totally anonymous and\n"
"individual profiles are never shared with third parties. We\n"
"don't collect any personally identifiable information. Each\n"
"anonymous profile is stored on Relatable's secure servers, and\n"
"we're continually adding safeguards to protect our users. To\n"
"enjoy these features and help us test the system, just opt-in.\n"
"You will never be contacted by Relatable or anyone else (unless\n"
"you ask, of course!). That's Relatable's privacy promise. If you\n"
"have any questions, please contact us at info@relatable.com";
switch(ctrlId)
{
case IDC_RELATABLE_TEXT1:
case IDC_RELATABLE_TEXT2:
{
HFONT font, oldFont;
font = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
oldFont = (HFONT)SelectObject(dis->hDC, font);
RECT clientRect;
GetClientRect(dis->hwndItem, &clientRect);
const char *msg;
if (ctrlId == IDC_RELATABLE_TEXT1)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -