mirror of
https://github.com/reactos/reactos.git
synced 2025-01-03 21:09:19 +00:00
[SHELL32] Code formatting only.
This commit is contained in:
parent
6d3921bdd5
commit
ae9ec94240
2 changed files with 120 additions and 124 deletions
|
@ -1200,7 +1200,6 @@ HRESULT STDMETHODCALLTYPE CShellLink::SetArguments(LPCSTR pszArgs)
|
||||||
if (!m_sArgs)
|
if (!m_sArgs)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_bDirty = TRUE;
|
m_bDirty = TRUE;
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
@ -1399,7 +1398,6 @@ HRESULT STDMETHODCALLTYPE CShellLink::Resolve(HWND hwnd, DWORD fFlags)
|
||||||
|
|
||||||
/* Clear the cached path */
|
/* Clear the cached path */
|
||||||
HeapFree(GetProcessHeap(), 0, m_sPath);
|
HeapFree(GetProcessHeap(), 0, m_sPath);
|
||||||
m_sPath = NULL;
|
|
||||||
m_sPath = shelllink_get_msi_component_path(component);
|
m_sPath = shelllink_get_msi_component_path(component);
|
||||||
if (!m_sPath)
|
if (!m_sPath)
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
@ -1553,15 +1551,14 @@ HRESULT STDMETHODCALLTYPE CShellLink::SetDescription(LPCWSTR pszName)
|
||||||
TRACE("(%p)->(desc=%s)\n", this, debugstr_w(pszName));
|
TRACE("(%p)->(desc=%s)\n", this, debugstr_w(pszName));
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, m_sDescription);
|
HeapFree(GetProcessHeap(), 0, m_sDescription);
|
||||||
|
m_sDescription = NULL;
|
||||||
|
|
||||||
if (pszName)
|
if (pszName)
|
||||||
{
|
{
|
||||||
m_sDescription = strdupW(pszName);
|
m_sDescription = strdupW(pszName);
|
||||||
if (!m_sDescription)
|
if (!m_sDescription)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
m_sDescription = NULL;
|
|
||||||
|
|
||||||
m_bDirty = TRUE;
|
m_bDirty = TRUE;
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
@ -1585,15 +1582,14 @@ HRESULT STDMETHODCALLTYPE CShellLink::SetWorkingDirectory(LPCWSTR pszDir)
|
||||||
TRACE("(%p)->(dir=%s)\n", this, debugstr_w(pszDir));
|
TRACE("(%p)->(dir=%s)\n", this, debugstr_w(pszDir));
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, m_sWorkDir);
|
HeapFree(GetProcessHeap(), 0, m_sWorkDir);
|
||||||
|
m_sWorkDir = NULL;
|
||||||
|
|
||||||
if (pszDir)
|
if (pszDir)
|
||||||
{
|
{
|
||||||
m_sWorkDir = strdupW(pszDir);
|
m_sWorkDir = strdupW(pszDir);
|
||||||
if (!m_sWorkDir)
|
if (!m_sWorkDir)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
m_sWorkDir = NULL;
|
|
||||||
|
|
||||||
m_bDirty = TRUE;
|
m_bDirty = TRUE;
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
@ -1617,15 +1613,14 @@ HRESULT STDMETHODCALLTYPE CShellLink::SetArguments(LPCWSTR pszArgs)
|
||||||
TRACE("(%p)->(args=%s)\n", this, debugstr_w(pszArgs));
|
TRACE("(%p)->(args=%s)\n", this, debugstr_w(pszArgs));
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, m_sArgs);
|
HeapFree(GetProcessHeap(), 0, m_sArgs);
|
||||||
|
m_sArgs = NULL;
|
||||||
|
|
||||||
if (pszArgs)
|
if (pszArgs)
|
||||||
{
|
{
|
||||||
m_sArgs = strdupW(pszArgs);
|
m_sArgs = strdupW(pszArgs);
|
||||||
if (!m_sArgs)
|
if (!m_sArgs)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
m_sArgs = NULL;
|
|
||||||
|
|
||||||
m_bDirty = TRUE;
|
m_bDirty = TRUE;
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
@ -1650,11 +1645,10 @@ HRESULT STDMETHODCALLTYPE CShellLink::GetIconLocation(LPWSTR pszIconPath, INT cc
|
||||||
pInfo = (LPEXP_SZ_LINK)SHFindDataBlock(m_pDBList, EXP_SZ_ICON_SIG);
|
pInfo = (LPEXP_SZ_LINK)SHFindDataBlock(m_pDBList, EXP_SZ_ICON_SIG);
|
||||||
if (pInfo && (pInfo->cbSize == sizeof(*pInfo)))
|
if (pInfo && (pInfo->cbSize == sizeof(*pInfo)))
|
||||||
{
|
{
|
||||||
|
SHExpandEnvironmentStringsW(pInfo->szwTarget, szPath, _countof(szPath));
|
||||||
|
|
||||||
m_Header.dwFlags &= ~SLDF_HAS_ICONLOCATION;
|
m_Header.dwFlags &= ~SLDF_HAS_ICONLOCATION;
|
||||||
HeapFree(GetProcessHeap(), 0, m_sIcoPath);
|
HeapFree(GetProcessHeap(), 0, m_sIcoPath);
|
||||||
m_sIcoPath = NULL;
|
|
||||||
|
|
||||||
SHExpandEnvironmentStringsW(pInfo->szwTarget, szPath, _countof(szPath));
|
|
||||||
|
|
||||||
m_sIcoPath = strdupW(szPath);
|
m_sIcoPath = strdupW(szPath);
|
||||||
if (!m_sIcoPath)
|
if (!m_sIcoPath)
|
||||||
|
@ -1931,7 +1925,6 @@ HRESULT STDMETHODCALLTYPE CShellLink::SetIconLocation(LPCWSTR pszIconPath, INT i
|
||||||
{
|
{
|
||||||
m_Header.dwFlags &= ~SLDF_HAS_ICONLOCATION;
|
m_Header.dwFlags &= ~SLDF_HAS_ICONLOCATION;
|
||||||
HeapFree(GetProcessHeap(), 0, m_sIcoPath);
|
HeapFree(GetProcessHeap(), 0, m_sIcoPath);
|
||||||
m_sIcoPath = NULL;
|
|
||||||
|
|
||||||
m_sIcoPath = strdupW(pszIconPath);
|
m_sIcoPath = strdupW(pszIconPath);
|
||||||
if (!m_sIcoPath)
|
if (!m_sIcoPath)
|
||||||
|
@ -1953,15 +1946,14 @@ HRESULT STDMETHODCALLTYPE CShellLink::SetRelativePath(LPCWSTR pszPathRel, DWORD
|
||||||
TRACE("(%p)->(path=%s %x)\n", this, debugstr_w(pszPathRel), dwReserved);
|
TRACE("(%p)->(path=%s %x)\n", this, debugstr_w(pszPathRel), dwReserved);
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, m_sPathRel);
|
HeapFree(GetProcessHeap(), 0, m_sPathRel);
|
||||||
|
m_sPathRel = NULL;
|
||||||
|
|
||||||
if (pszPathRel)
|
if (pszPathRel)
|
||||||
{
|
{
|
||||||
m_sPathRel = strdupW(pszPathRel);
|
m_sPathRel = strdupW(pszPathRel);
|
||||||
if (!m_sPathRel)
|
if (!m_sPathRel)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
m_sPathRel = NULL;
|
|
||||||
|
|
||||||
m_bDirty = TRUE;
|
m_bDirty = TRUE;
|
||||||
|
|
||||||
return ShellLink_UpdatePath(m_sPathRel, m_sPath, m_sWorkDir, &m_sPath);
|
return ShellLink_UpdatePath(m_sPathRel, m_sPath, m_sWorkDir, &m_sPath);
|
||||||
|
|
|
@ -92,17 +92,16 @@ DestroyIconList(HWND hDlgCtrl, PPICK_ICON_CONTEXT pIconContext)
|
||||||
static BOOL
|
static BOOL
|
||||||
DoLoadIcons(HWND hwndDlg, PICK_ICON_CONTEXT *pIconContext, LPCWSTR pszFile)
|
DoLoadIcons(HWND hwndDlg, PICK_ICON_CONTEXT *pIconContext, LPCWSTR pszFile)
|
||||||
{
|
{
|
||||||
// destroy previous
|
// Destroy previous icons
|
||||||
DestroyIconList(pIconContext->hDlgCtrl, pIconContext);
|
DestroyIconList(pIconContext->hDlgCtrl, pIconContext);
|
||||||
SendMessageW(pIconContext->hDlgCtrl, LB_RESETCONTENT, 0, 0);
|
SendMessageW(pIconContext->hDlgCtrl, LB_RESETCONTENT, 0, 0);
|
||||||
delete[] pIconContext->phIcons;
|
delete[] pIconContext->phIcons;
|
||||||
|
|
||||||
// store paths
|
// Store the paths
|
||||||
if (pIconContext->szPath != pszFile)
|
StringCchCopyW(pIconContext->szPath, _countof(pIconContext->szPath), pszFile);
|
||||||
StringCchCopyW(pIconContext->szPath, _countof(pIconContext->szPath), pszFile);
|
|
||||||
ExpandEnvironmentStringsW(pszFile, pIconContext->szExpandedPath, _countof(pIconContext->szExpandedPath));
|
ExpandEnvironmentStringsW(pszFile, pIconContext->szExpandedPath, _countof(pIconContext->szExpandedPath));
|
||||||
|
|
||||||
// load DLL if possible
|
// Load the module if possible
|
||||||
HMODULE hLibrary = LoadLibraryExW(pIconContext->szExpandedPath, NULL, LOAD_LIBRARY_AS_DATAFILE);
|
HMODULE hLibrary = LoadLibraryExW(pIconContext->szExpandedPath, NULL, LOAD_LIBRARY_AS_DATAFILE);
|
||||||
if (pIconContext->hLibrary)
|
if (pIconContext->hLibrary)
|
||||||
FreeLibrary(pIconContext->hLibrary);
|
FreeLibrary(pIconContext->hLibrary);
|
||||||
|
@ -110,7 +109,7 @@ DoLoadIcons(HWND hwndDlg, PICK_ICON_CONTEXT *pIconContext, LPCWSTR pszFile)
|
||||||
|
|
||||||
if (pIconContext->hLibrary)
|
if (pIconContext->hLibrary)
|
||||||
{
|
{
|
||||||
// load icons from DLL
|
// Load the icons from the module
|
||||||
pIconContext->nIcons = ExtractIconExW(pIconContext->szExpandedPath, -1, NULL, NULL, 0);
|
pIconContext->nIcons = ExtractIconExW(pIconContext->szExpandedPath, -1, NULL, NULL, 0);
|
||||||
pIconContext->phIcons = new HICON[pIconContext->nIcons];
|
pIconContext->phIcons = new HICON[pIconContext->nIcons];
|
||||||
|
|
||||||
|
@ -125,7 +124,7 @@ DoLoadIcons(HWND hwndDlg, PICK_ICON_CONTEXT *pIconContext, LPCWSTR pszFile)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// *.ico
|
// .ico file
|
||||||
pIconContext->nIcons = 1;
|
pIconContext->nIcons = 1;
|
||||||
pIconContext->phIcons = new HICON[1];
|
pIconContext->phIcons = new HICON[1];
|
||||||
|
|
||||||
|
@ -139,7 +138,7 @@ DoLoadIcons(HWND hwndDlg, PICK_ICON_CONTEXT *pIconContext, LPCWSTR pszFile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set text
|
// Set the text
|
||||||
SetDlgItemTextW(hwndDlg, IDC_EDIT_PATH, pIconContext->szPath);
|
SetDlgItemTextW(hwndDlg, IDC_EDIT_PATH, pIconContext->szPath);
|
||||||
|
|
||||||
if (pIconContext->nIcons == 0)
|
if (pIconContext->nIcons == 0)
|
||||||
|
@ -155,28 +154,28 @@ static const LPCWSTR s_pszDefaultPath = L"%SystemRoot%\\system32\\shell32.dll";
|
||||||
|
|
||||||
static void NoIconsInFile(HWND hwndDlg, PICK_ICON_CONTEXT *pIconContext)
|
static void NoIconsInFile(HWND hwndDlg, PICK_ICON_CONTEXT *pIconContext)
|
||||||
{
|
{
|
||||||
// show message
|
// Show an error message
|
||||||
CStringW strText, strTitle(MAKEINTRESOURCEW(IDS_PICK_ICON_TITLE));
|
CStringW strText, strTitle(MAKEINTRESOURCEW(IDS_PICK_ICON_TITLE));
|
||||||
strText.Format(IDS_NO_ICONS, pIconContext->szPath);
|
strText.Format(IDS_NO_ICONS, pIconContext->szPath);
|
||||||
MessageBoxW(hwndDlg, strText, strTitle, MB_ICONWARNING);
|
MessageBoxW(hwndDlg, strText, strTitle, MB_ICONWARNING);
|
||||||
|
|
||||||
// load default icons
|
// Load the default icons
|
||||||
DoLoadIcons(hwndDlg, pIconContext, s_pszDefaultPath);
|
DoLoadIcons(hwndDlg, pIconContext, s_pszDefaultPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// icon size
|
// Icon size
|
||||||
#define CX_ICON GetSystemMetrics(SM_CXICON)
|
#define CX_ICON GetSystemMetrics(SM_CXICON)
|
||||||
#define CY_ICON GetSystemMetrics(SM_CYICON)
|
#define CY_ICON GetSystemMetrics(SM_CYICON)
|
||||||
|
|
||||||
// item size
|
// Item size
|
||||||
#define CX_ITEM (CX_ICON + 4)
|
#define CX_ITEM (CX_ICON + 4)
|
||||||
#define CY_ITEM (CY_ICON + 12)
|
#define CY_ITEM (CY_ICON + 12)
|
||||||
|
|
||||||
INT_PTR CALLBACK PickIconProc(HWND hwndDlg,
|
INT_PTR CALLBACK PickIconProc(
|
||||||
|
HWND hwndDlg,
|
||||||
UINT uMsg,
|
UINT uMsg,
|
||||||
WPARAM wParam,
|
WPARAM wParam,
|
||||||
LPARAM lParam
|
LPARAM lParam)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
LPMEASUREITEMSTRUCT lpmis;
|
LPMEASUREITEMSTRUCT lpmis;
|
||||||
LPDRAWITEMSTRUCT lpdis;
|
LPDRAWITEMSTRUCT lpdis;
|
||||||
|
@ -190,105 +189,109 @@ INT_PTR CALLBACK PickIconProc(HWND hwndDlg,
|
||||||
|
|
||||||
switch(uMsg)
|
switch(uMsg)
|
||||||
{
|
{
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
pIconContext = (PPICK_ICON_CONTEXT)lParam;
|
|
||||||
SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pIconContext);
|
|
||||||
pIconContext->hDlgCtrl = GetDlgItem(hwndDlg, IDC_PICKICON_LIST);
|
|
||||||
|
|
||||||
SendMessageW(pIconContext->hDlgCtrl, LB_SETCOLUMNWIDTH, CX_ITEM, 0);
|
|
||||||
|
|
||||||
// load icons
|
|
||||||
if (!DoLoadIcons(hwndDlg, pIconContext, pIconContext->szPath))
|
|
||||||
{
|
{
|
||||||
NoIconsInFile(hwndDlg, pIconContext);
|
pIconContext = (PPICK_ICON_CONTEXT)lParam;
|
||||||
|
SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pIconContext);
|
||||||
|
pIconContext->hDlgCtrl = GetDlgItem(hwndDlg, IDC_PICKICON_LIST);
|
||||||
|
|
||||||
|
SendMessageW(pIconContext->hDlgCtrl, LB_SETCOLUMNWIDTH, CX_ITEM, 0);
|
||||||
|
|
||||||
|
// Load the icons
|
||||||
|
if (!DoLoadIcons(hwndDlg, pIconContext, pIconContext->szPath))
|
||||||
|
NoIconsInFile(hwndDlg, pIconContext);
|
||||||
|
|
||||||
|
// Set the selection
|
||||||
|
count = SendMessageW(pIconContext->hDlgCtrl, LB_GETCOUNT, 0, 0);
|
||||||
|
if (count != LB_ERR)
|
||||||
|
{
|
||||||
|
if (pIconContext->Index < 0)
|
||||||
|
{
|
||||||
|
// A negative value will be interpreted as a negated resource ID.
|
||||||
|
LPARAM lParam = -pIconContext->Index;
|
||||||
|
pIconContext->Index = (INT)SendMessageW(pIconContext->hDlgCtrl, LB_FINDSTRINGEXACT, -1, lParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pIconContext->Index < 0 || count <= pIconContext->Index)
|
||||||
|
pIconContext->Index = 0;
|
||||||
|
|
||||||
|
SendMessageW(pIconContext->hDlgCtrl, LB_SETCURSEL, pIconContext->Index, 0);
|
||||||
|
SendMessageW(pIconContext->hDlgCtrl, LB_SETTOPINDEX, pIconContext->Index, 0);
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set selection
|
case WM_COMMAND:
|
||||||
count = SendMessageW(pIconContext->hDlgCtrl, LB_GETCOUNT, 0, 0);
|
switch(LOWORD(wParam))
|
||||||
if (count != LB_ERR)
|
|
||||||
{
|
|
||||||
if (pIconContext->Index < 0)
|
|
||||||
{
|
{
|
||||||
// A negative value will be interpreted as a negated resource ID.
|
case IDOK:
|
||||||
LPARAM lParam = -pIconContext->Index;
|
index = SendMessageW(pIconContext->hDlgCtrl, LB_GETCURSEL, 0, 0);
|
||||||
pIconContext->Index = (INT)SendMessageW(pIconContext->hDlgCtrl, LB_FINDSTRINGEXACT, -1, lParam);
|
pIconContext->Index = index;
|
||||||
}
|
GetDlgItemTextW(hwndDlg, IDC_EDIT_PATH, pIconContext->szPath, _countof(pIconContext->szPath));
|
||||||
|
ExpandEnvironmentStringsW(pIconContext->szPath, pIconContext->szExpandedPath, _countof(pIconContext->szExpandedPath));
|
||||||
if (pIconContext->Index < 0 || count <= pIconContext->Index)
|
DestroyIconList(pIconContext->hDlgCtrl, pIconContext);
|
||||||
pIconContext->Index = 0;
|
delete[] pIconContext->phIcons;
|
||||||
|
EndDialog(hwndDlg, 1);
|
||||||
SendMessageW(pIconContext->hDlgCtrl, LB_SETCURSEL, pIconContext->Index, 0);
|
|
||||||
SendMessageW(pIconContext->hDlgCtrl, LB_SETTOPINDEX, pIconContext->Index, 0);
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
case WM_COMMAND:
|
|
||||||
switch(LOWORD(wParam))
|
|
||||||
{
|
|
||||||
case IDOK:
|
|
||||||
index = SendMessageW(pIconContext->hDlgCtrl, LB_GETCURSEL, 0, 0);
|
|
||||||
pIconContext->Index = index;
|
|
||||||
GetDlgItemTextW(hwndDlg, IDC_EDIT_PATH, pIconContext->szPath, MAX_PATH);
|
|
||||||
ExpandEnvironmentStringsW(pIconContext->szPath, pIconContext->szExpandedPath, _countof(pIconContext->szExpandedPath));
|
|
||||||
DestroyIconList(pIconContext->hDlgCtrl, pIconContext);
|
|
||||||
delete[] pIconContext->phIcons;
|
|
||||||
EndDialog(hwndDlg, 1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case IDCANCEL:
|
|
||||||
DestroyIconList(pIconContext->hDlgCtrl, pIconContext);
|
|
||||||
delete[] pIconContext->phIcons;
|
|
||||||
EndDialog(hwndDlg, 0);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case IDC_PICKICON_LIST:
|
|
||||||
switch (HIWORD(wParam))
|
|
||||||
{
|
|
||||||
case LBN_SELCHANGE:
|
|
||||||
InvalidateRect((HWND)lParam, NULL, TRUE);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case LBN_DBLCLK:
|
|
||||||
SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDOK, 0), 0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case IDC_BUTTON_PATH:
|
|
||||||
// choose DLL path
|
|
||||||
szText[0] = 0;
|
|
||||||
szFilter[0] = 0;
|
|
||||||
ZeroMemory(&ofn, sizeof(ofn));
|
|
||||||
ofn.lStructSize = sizeof(ofn);
|
|
||||||
ofn.hwndOwner = hwndDlg;
|
|
||||||
ofn.lpstrFile = szText;
|
|
||||||
ofn.nMaxFile = MAX_PATH;
|
|
||||||
strTitle.LoadString(IDS_PICK_ICON_TITLE);
|
|
||||||
ofn.lpstrTitle = strTitle;
|
|
||||||
LoadStringW(shell32_hInstance, IDS_PICK_ICON_FILTER, szFilter, _countof(szFilter));
|
|
||||||
ofn.lpstrFilter = szFilter;
|
|
||||||
if (!GetOpenFileNameW(&ofn))
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// load icons
|
case IDCANCEL:
|
||||||
if (!DoLoadIcons(hwndDlg, pIconContext, szText))
|
DestroyIconList(pIconContext->hDlgCtrl, pIconContext);
|
||||||
|
delete[] pIconContext->phIcons;
|
||||||
|
EndDialog(hwndDlg, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IDC_PICKICON_LIST:
|
||||||
|
switch (HIWORD(wParam))
|
||||||
|
{
|
||||||
|
case LBN_SELCHANGE:
|
||||||
|
InvalidateRect((HWND)lParam, NULL, TRUE);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LBN_DBLCLK:
|
||||||
|
SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDOK, 0), 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IDC_BUTTON_PATH:
|
||||||
{
|
{
|
||||||
NoIconsInFile(hwndDlg, pIconContext);
|
// Choose the module path
|
||||||
|
szText[0] = 0;
|
||||||
|
szFilter[0] = 0;
|
||||||
|
ZeroMemory(&ofn, sizeof(ofn));
|
||||||
|
ofn.lStructSize = sizeof(ofn);
|
||||||
|
ofn.hwndOwner = hwndDlg;
|
||||||
|
ofn.lpstrFile = szText;
|
||||||
|
ofn.nMaxFile = _countof(szText);
|
||||||
|
strTitle.LoadString(IDS_PICK_ICON_TITLE);
|
||||||
|
ofn.lpstrTitle = strTitle;
|
||||||
|
LoadStringW(shell32_hInstance, IDS_PICK_ICON_FILTER, szFilter, _countof(szFilter));
|
||||||
|
ofn.lpstrFilter = szFilter;
|
||||||
|
if (!GetOpenFileNameW(&ofn))
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Load the icons
|
||||||
|
if (!DoLoadIcons(hwndDlg, pIconContext, szText))
|
||||||
|
NoIconsInFile(hwndDlg, pIconContext);
|
||||||
|
|
||||||
|
// Set the selection
|
||||||
|
SendMessageW(pIconContext->hDlgCtrl, LB_SETCURSEL, 0, 0);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set selection
|
default:
|
||||||
SendMessageW(pIconContext->hDlgCtrl, LB_SETCURSEL, 0, 0);
|
break;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_MEASUREITEM:
|
case WM_MEASUREITEM:
|
||||||
lpmis = (LPMEASUREITEMSTRUCT) lParam;
|
lpmis = (LPMEASUREITEMSTRUCT)lParam;
|
||||||
lpmis->itemHeight = CY_ITEM;
|
lpmis->itemHeight = CY_ITEM;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
case WM_DRAWITEM:
|
case WM_DRAWITEM:
|
||||||
lpdis = (LPDRAWITEMSTRUCT) lParam;
|
{
|
||||||
|
lpdis = (LPDRAWITEMSTRUCT)lParam;
|
||||||
if (lpdis->itemID == (UINT)-1)
|
if (lpdis->itemID == (UINT)-1)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
@ -306,7 +309,7 @@ INT_PTR CALLBACK PickIconProc(HWND hwndDlg,
|
||||||
else
|
else
|
||||||
FillRect(lpdis->hDC, &lpdis->rcItem, (HBRUSH)(COLOR_WINDOW + 1));
|
FillRect(lpdis->hDC, &lpdis->rcItem, (HBRUSH)(COLOR_WINDOW + 1));
|
||||||
|
|
||||||
// centering
|
// Centering
|
||||||
INT x = lpdis->rcItem.left + (CX_ITEM - CX_ICON) / 2;
|
INT x = lpdis->rcItem.left + (CX_ITEM - CX_ICON) / 2;
|
||||||
INT y = lpdis->rcItem.top + (CY_ITEM - CY_ICON) / 2;
|
INT y = lpdis->rcItem.top + (CY_ITEM - CY_ICON) / 2;
|
||||||
|
|
||||||
|
@ -315,6 +318,7 @@ INT_PTR CALLBACK PickIconProc(HWND hwndDlg,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -328,7 +332,7 @@ BOOL WINAPI PickIconDlg(
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
// initialize
|
// Initialize the dialog
|
||||||
PICK_ICON_CONTEXT IconContext = { NULL };
|
PICK_ICON_CONTEXT IconContext = { NULL };
|
||||||
IconContext.Index = *lpdwIconIndex;
|
IconContext.Index = *lpdwIconIndex;
|
||||||
StringCchCopyW(IconContext.szPath, _countof(IconContext.szPath), lpstrFile);
|
StringCchCopyW(IconContext.szPath, _countof(IconContext.szPath), lpstrFile);
|
||||||
|
@ -339,22 +343,22 @@ BOOL WINAPI PickIconDlg(
|
||||||
{
|
{
|
||||||
if (IconContext.szExpandedPath[0])
|
if (IconContext.szExpandedPath[0])
|
||||||
{
|
{
|
||||||
// no such file
|
// No such file
|
||||||
CStringW strText, strTitle(MAKEINTRESOURCEW(IDS_PICK_ICON_TITLE));
|
CStringW strText, strTitle(MAKEINTRESOURCEW(IDS_PICK_ICON_TITLE));
|
||||||
strText.Format(IDS_FILE_NOT_FOUND, lpstrFile);
|
strText.Format(IDS_FILE_NOT_FOUND, lpstrFile);
|
||||||
MessageBoxW(hWndOwner, strText, strTitle, MB_ICONWARNING);
|
MessageBoxW(hWndOwner, strText, strTitle, MB_ICONWARNING);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set default value
|
// Set the default value
|
||||||
StringCchCopyW(IconContext.szPath, _countof(IconContext.szPath), s_pszDefaultPath);
|
StringCchCopyW(IconContext.szPath, _countof(IconContext.szPath), s_pszDefaultPath);
|
||||||
ExpandEnvironmentStringsW(s_pszDefaultPath, IconContext.szPath, _countof(IconContext.szPath));
|
ExpandEnvironmentStringsW(s_pszDefaultPath, IconContext.szPath, _countof(IconContext.szPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
// show dialog
|
// Show the dialog
|
||||||
res = DialogBoxParamW(shell32_hInstance, MAKEINTRESOURCEW(IDD_PICK_ICON), hWndOwner, PickIconProc, (LPARAM)&IconContext);
|
res = DialogBoxParamW(shell32_hInstance, MAKEINTRESOURCEW(IDD_PICK_ICON), hWndOwner, PickIconProc, (LPARAM)&IconContext);
|
||||||
if (res)
|
if (res)
|
||||||
{
|
{
|
||||||
// store
|
// Store the selected icon
|
||||||
StringCchCopyW(lpstrFile, nMaxFile, IconContext.szExpandedPath);
|
StringCchCopyW(lpstrFile, nMaxFile, IconContext.szExpandedPath);
|
||||||
*lpdwIconIndex = IconContext.Index;
|
*lpdwIconIndex = IconContext.Index;
|
||||||
}
|
}
|
||||||
|
@ -628,8 +632,8 @@ static INT_PTR CALLBACK RunDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARA
|
||||||
WCHAR filter[MAX_PATH], szCaption[MAX_PATH];
|
WCHAR filter[MAX_PATH], szCaption[MAX_PATH];
|
||||||
OPENFILENAMEW ofn;
|
OPENFILENAMEW ofn;
|
||||||
|
|
||||||
LoadStringW(shell32_hInstance, IDS_RUNDLG_BROWSE_FILTER, filter, MAX_PATH);
|
LoadStringW(shell32_hInstance, IDS_RUNDLG_BROWSE_FILTER, filter, _countof(filter));
|
||||||
LoadStringW(shell32_hInstance, IDS_RUNDLG_BROWSE_CAPTION, szCaption, MAX_PATH);
|
LoadStringW(shell32_hInstance, IDS_RUNDLG_BROWSE_CAPTION, szCaption, _countof(szCaption));
|
||||||
|
|
||||||
ZeroMemory(&ofn, sizeof(ofn));
|
ZeroMemory(&ofn, sizeof(ofn));
|
||||||
ofn.lStructSize = sizeof(ofn);
|
ofn.lStructSize = sizeof(ofn);
|
||||||
|
|
Loading…
Reference in a new issue