設置 | 登錄 | 註冊

作者共發了7篇帖子。

【程序】C++調用shell32.dll中的圖標選擇對話框

1樓 巨大八爪鱼 2016-1-14 19:59
【代碼】
void CShellFuncDlg::OnButton1()
{
    // TODO: Add your control notification handler code here
    int (WINAPI *PickIconDlg)(HWND, PWSTR, UINT, int *);
    HMODULE hmdl = LoadLibrary(TEXT("shell32.dll"));
    PickIconDlg = (int (WINAPI *)(HWND, PWSTR, UINT, int *))GetProcAddress(hmdl, "PickIconDlg");

    WCHAR path[MAX_PATH] = L"C:\\windows\\system32\\shell32.dll";
    int index = 10;
    int result = PickIconDlg(NULL, path, MAX_PATH, &index);
    WCHAR str[MAX_PATH + 50];
    swprintf(str, L"You have chosen Icon %d in %s", index, path);
    MessageBoxW(m_hWnd, str, L"Icon", MB_ICONINFORMATION);

    FreeLibrary(hmdl);
}
【運行效果】
2樓 巨大八爪鱼 2016-1-14 20:00
選擇圖標後:
3樓 巨大八爪鱼 2016-1-14 20:07
4樓 巨大八爪鱼 2016-1-14 20:08
Of course, shell32.dll is probably the largest icon archive in Windows.
shell32.dll可能是Windows系統中最大的圖標庫。。。。
http://www.cnet.com/forums/discussions/does-windows-have-other-icon-files-besides-shell32-dll-326156/
5樓 巨大八爪鱼 2016-1-14 20:19
【代碼2】
用戶如果單擊了對話框中的「取消」,則不顯示消息框。
void CShellFuncDlg::OnButton1()
{
    // TODO: Add your control notification handler code here
    int (WINAPI *PickIconDlg)(HWND, PWSTR, UINT, int *);
    HMODULE hmdl = LoadLibrary(TEXT("shell32.dll"));
    PickIconDlg = (int (WINAPI *)(HWND, PWSTR, UINT, int *))GetProcAddress(hmdl, "PickIconDlg");

    WCHAR path[MAX_PATH] = L"C:\\windows\\system32\\shell32.dll";
    int index = 10;
    int result = PickIconDlg(NULL, path, MAX_PATH, &index);
    if (result == 1)
    {
        WCHAR str[MAX_PATH + 50];
        swprintf(str, L"You have chosen Icon %d in %s", index, path);
        MessageBoxW(m_hWnd, str, L"Icon", MB_ICONINFORMATION);
    }

    FreeLibrary(hmdl);
}
6樓 巨大八爪鱼 2016-1-14 20:20
【連結】
MSDN上PickIconDlg函數的參考資料:
https://msdn.microsoft.com/en-us/library/windows/desktop/bb776481%28v=vs.85%29.aspx
遺憾的是,上面寫着「Deprecated API」,意思就是說這個函數已經不贊成使用了。
7樓 巨大八爪鱼 2016-1-14 20:44
【連結】
Where to find most of Windows 10's native icons?
http://www.digitalcitizen.life/where-find-most-windows-10s-native-icons
這篇文章里介紹了很多Windows中的大型圖標庫。(很多dll的圖標規模都相當於shell32.dll)

內容轉換:

回覆帖子
內容:
用戶名: 您目前是匿名發表。
驗證碼:
看不清?換一張
©2010-2025 Purasbar Ver3.0 [手機版] [桌面版]
除非另有聲明,本站採用知識共享署名-相同方式共享 3.0 Unported許可協議進行許可。