Commit a0534afa authored by Vladislav Timonin's avatar Vladislav Timonin Committed by Alexandre Julliard

comdlg32: Enable visual styles when showing IFileDialog.

parent 5bc5d360
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#define COMDLG32_Atom MAKEINTATOM(0xa000) /* MS uses this one to identify props */ #define COMDLG32_Atom MAKEINTATOM(0xa000) /* MS uses this one to identify props */
extern HINSTANCE COMDLG32_hInstance DECLSPEC_HIDDEN; extern HINSTANCE COMDLG32_hInstance DECLSPEC_HIDDEN;
extern HANDLE COMDLG32_hActCtx DECLSPEC_HIDDEN;
void COMDLG32_SetCommDlgExtendedError(DWORD err) DECLSPEC_HIDDEN; void COMDLG32_SetCommDlgExtendedError(DWORD err) DECLSPEC_HIDDEN;
LPVOID COMDLG32_AllocMem(int size) __WINE_ALLOC_SIZE(1) DECLSPEC_HIDDEN; LPVOID COMDLG32_AllocMem(int size) __WINE_ALLOC_SIZE(1) DECLSPEC_HIDDEN;
......
...@@ -40,6 +40,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(commdlg); ...@@ -40,6 +40,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
DECLSPEC_HIDDEN HINSTANCE COMDLG32_hInstance = 0; DECLSPEC_HIDDEN HINSTANCE COMDLG32_hInstance = 0;
HANDLE COMDLG32_hActCtx = INVALID_HANDLE_VALUE;
static DWORD COMDLG32_TlsIndex = TLS_OUT_OF_INDEXES; static DWORD COMDLG32_TlsIndex = TLS_OUT_OF_INDEXES;
...@@ -59,13 +60,26 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD Reason, LPVOID Reserved) ...@@ -59,13 +60,26 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD Reason, LPVOID Reserved)
switch(Reason) switch(Reason)
{ {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
{
ACTCTXW actctx = {0};
COMDLG32_hInstance = hInstance; COMDLG32_hInstance = hInstance;
DisableThreadLibraryCalls(hInstance); DisableThreadLibraryCalls(hInstance);
break;
actctx.cbSize = sizeof(actctx);
actctx.hModule = COMDLG32_hInstance;
actctx.lpResourceName = MAKEINTRESOURCEW(123);
actctx.dwFlags = ACTCTX_FLAG_HMODULE_VALID | ACTCTX_FLAG_RESOURCE_NAME_VALID;
COMDLG32_hActCtx = CreateActCtxW(&actctx);
if (COMDLG32_hActCtx == INVALID_HANDLE_VALUE)
ERR("failed to create activation context, last error %lu\n", GetLastError());
break;
}
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
if (Reserved) break; if (Reserved) break;
if (COMDLG32_TlsIndex != TLS_OUT_OF_INDEXES) TlsFree(COMDLG32_TlsIndex); if (COMDLG32_TlsIndex != TLS_OUT_OF_INDEXES) TlsFree(COMDLG32_TlsIndex);
if (COMDLG32_hActCtx != INVALID_HANDLE_VALUE) ReleaseActCtx(COMDLG32_hActCtx);
break; break;
} }
return TRUE; return TRUE;
......
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity type="win32" name="Microsoft.Windows.Shell.comdlg32" version="0.0.0.0"/>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>
...@@ -602,3 +602,6 @@ NETWORK ICON network.ico ...@@ -602,3 +602,6 @@ NETWORK ICON network.ico
/* @makedep: fontpics.bmp */ /* @makedep: fontpics.bmp */
38 BITMAP fontpics.bmp 38 BITMAP fontpics.bmp
/* @makedep: comdlg32.manifest */
123 RT_MANIFEST comdlg32.manifest
...@@ -145,6 +145,8 @@ typedef struct FileDialogImpl { ...@@ -145,6 +145,8 @@ typedef struct FileDialogImpl {
DWORD opendropdown_selection; DWORD opendropdown_selection;
GUID client_guid; GUID client_guid;
HANDLE user_actctx;
} FileDialogImpl; } FileDialogImpl;
/************************************************************************** /**************************************************************************
...@@ -152,10 +154,14 @@ typedef struct FileDialogImpl { ...@@ -152,10 +154,14 @@ typedef struct FileDialogImpl {
*/ */
static HRESULT events_OnFileOk(FileDialogImpl *This) static HRESULT events_OnFileOk(FileDialogImpl *This)
{ {
ULONG_PTR ctx_cookie = 0;
events_client *cursor; events_client *cursor;
HRESULT hr = S_OK; HRESULT hr = S_OK;
TRACE("%p\n", This); TRACE("%p\n", This);
if (This->user_actctx != INVALID_HANDLE_VALUE)
ActivateActCtx(This->user_actctx, &ctx_cookie);
LIST_FOR_EACH_ENTRY(cursor, &This->events_clients, events_client, entry) LIST_FOR_EACH_ENTRY(cursor, &This->events_clients, events_client, entry)
{ {
TRACE("Notifying %p\n", cursor); TRACE("Notifying %p\n", cursor);
...@@ -164,6 +170,9 @@ static HRESULT events_OnFileOk(FileDialogImpl *This) ...@@ -164,6 +170,9 @@ static HRESULT events_OnFileOk(FileDialogImpl *This)
break; break;
} }
if (This->user_actctx != INVALID_HANDLE_VALUE)
DeactivateActCtx(0, ctx_cookie);
if(hr == E_NOTIMPL) if(hr == E_NOTIMPL)
hr = S_OK; hr = S_OK;
...@@ -172,10 +181,14 @@ static HRESULT events_OnFileOk(FileDialogImpl *This) ...@@ -172,10 +181,14 @@ static HRESULT events_OnFileOk(FileDialogImpl *This)
static HRESULT events_OnFolderChanging(FileDialogImpl *This, IShellItem *folder) static HRESULT events_OnFolderChanging(FileDialogImpl *This, IShellItem *folder)
{ {
ULONG_PTR ctx_cookie = 0;
events_client *cursor; events_client *cursor;
HRESULT hr = S_OK; HRESULT hr = S_OK;
TRACE("%p (%p)\n", This, folder); TRACE("%p (%p)\n", This, folder);
if (This->user_actctx != INVALID_HANDLE_VALUE)
ActivateActCtx(This->user_actctx, &ctx_cookie);
LIST_FOR_EACH_ENTRY(cursor, &This->events_clients, events_client, entry) LIST_FOR_EACH_ENTRY(cursor, &This->events_clients, events_client, entry)
{ {
TRACE("Notifying %p\n", cursor); TRACE("Notifying %p\n", cursor);
...@@ -184,6 +197,9 @@ static HRESULT events_OnFolderChanging(FileDialogImpl *This, IShellItem *folder) ...@@ -184,6 +197,9 @@ static HRESULT events_OnFolderChanging(FileDialogImpl *This, IShellItem *folder)
break; break;
} }
if (This->user_actctx != INVALID_HANDLE_VALUE)
DeactivateActCtx(0, ctx_cookie);
if(hr == E_NOTIMPL) if(hr == E_NOTIMPL)
hr = S_OK; hr = S_OK;
...@@ -192,47 +208,72 @@ static HRESULT events_OnFolderChanging(FileDialogImpl *This, IShellItem *folder) ...@@ -192,47 +208,72 @@ static HRESULT events_OnFolderChanging(FileDialogImpl *This, IShellItem *folder)
static void events_OnFolderChange(FileDialogImpl *This) static void events_OnFolderChange(FileDialogImpl *This)
{ {
ULONG_PTR ctx_cookie = 0;
events_client *cursor; events_client *cursor;
TRACE("%p\n", This); TRACE("%p\n", This);
if (This->user_actctx != INVALID_HANDLE_VALUE)
ActivateActCtx(This->user_actctx, &ctx_cookie);
LIST_FOR_EACH_ENTRY(cursor, &This->events_clients, events_client, entry) LIST_FOR_EACH_ENTRY(cursor, &This->events_clients, events_client, entry)
{ {
TRACE("Notifying %p\n", cursor); TRACE("Notifying %p\n", cursor);
IFileDialogEvents_OnFolderChange(cursor->pfde, (IFileDialog*)&This->IFileDialog2_iface); IFileDialogEvents_OnFolderChange(cursor->pfde, (IFileDialog*)&This->IFileDialog2_iface);
} }
if (This->user_actctx != INVALID_HANDLE_VALUE)
DeactivateActCtx(0, ctx_cookie);
} }
static void events_OnSelectionChange(FileDialogImpl *This) static void events_OnSelectionChange(FileDialogImpl *This)
{ {
ULONG_PTR ctx_cookie = 0;
events_client *cursor; events_client *cursor;
TRACE("%p\n", This); TRACE("%p\n", This);
if (This->user_actctx != INVALID_HANDLE_VALUE)
ActivateActCtx(This->user_actctx, &ctx_cookie);
LIST_FOR_EACH_ENTRY(cursor, &This->events_clients, events_client, entry) LIST_FOR_EACH_ENTRY(cursor, &This->events_clients, events_client, entry)
{ {
TRACE("Notifying %p\n", cursor); TRACE("Notifying %p\n", cursor);
IFileDialogEvents_OnSelectionChange(cursor->pfde, (IFileDialog*)&This->IFileDialog2_iface); IFileDialogEvents_OnSelectionChange(cursor->pfde, (IFileDialog*)&This->IFileDialog2_iface);
} }
if (This->user_actctx != INVALID_HANDLE_VALUE)
DeactivateActCtx(0, ctx_cookie);
} }
static void events_OnTypeChange(FileDialogImpl *This) static void events_OnTypeChange(FileDialogImpl *This)
{ {
ULONG_PTR ctx_cookie = 0;
events_client *cursor; events_client *cursor;
TRACE("%p\n", This); TRACE("%p\n", This);
if (This->user_actctx != INVALID_HANDLE_VALUE)
ActivateActCtx(This->user_actctx, &ctx_cookie);
LIST_FOR_EACH_ENTRY(cursor, &This->events_clients, events_client, entry) LIST_FOR_EACH_ENTRY(cursor, &This->events_clients, events_client, entry)
{ {
TRACE("Notifying %p\n", cursor); TRACE("Notifying %p\n", cursor);
IFileDialogEvents_OnTypeChange(cursor->pfde, (IFileDialog*)&This->IFileDialog2_iface); IFileDialogEvents_OnTypeChange(cursor->pfde, (IFileDialog*)&This->IFileDialog2_iface);
} }
if (This->user_actctx != INVALID_HANDLE_VALUE)
DeactivateActCtx(0, ctx_cookie);
} }
static HRESULT events_OnOverwrite(FileDialogImpl *This, IShellItem *shellitem) static HRESULT events_OnOverwrite(FileDialogImpl *This, IShellItem *shellitem)
{ {
ULONG_PTR ctx_cookie = 0;
events_client *cursor; events_client *cursor;
HRESULT hr = S_OK; HRESULT hr = S_OK;
FDE_OVERWRITE_RESPONSE response = FDEOR_DEFAULT; FDE_OVERWRITE_RESPONSE response = FDEOR_DEFAULT;
TRACE("%p %p\n", This, shellitem); TRACE("%p %p\n", This, shellitem);
if (This->user_actctx != INVALID_HANDLE_VALUE)
ActivateActCtx(This->user_actctx, &ctx_cookie);
LIST_FOR_EACH_ENTRY(cursor, &This->events_clients, events_client, entry) LIST_FOR_EACH_ENTRY(cursor, &This->events_clients, events_client, entry)
{ {
TRACE("Notifying %p\n", cursor); TRACE("Notifying %p\n", cursor);
...@@ -242,6 +283,9 @@ static HRESULT events_OnOverwrite(FileDialogImpl *This, IShellItem *shellitem) ...@@ -242,6 +283,9 @@ static HRESULT events_OnOverwrite(FileDialogImpl *This, IShellItem *shellitem)
break; break;
} }
if (This->user_actctx != INVALID_HANDLE_VALUE)
DeactivateActCtx(0, ctx_cookie);
if(hr == E_NOTIMPL) if(hr == E_NOTIMPL)
hr = S_OK; hr = S_OK;
...@@ -274,9 +318,13 @@ static inline HRESULT get_cctrl_event(IFileDialogEvents *pfde, IFileDialogContro ...@@ -274,9 +318,13 @@ static inline HRESULT get_cctrl_event(IFileDialogEvents *pfde, IFileDialogContro
static HRESULT cctrl_event_OnButtonClicked(FileDialogImpl *This, DWORD ctl_id) static HRESULT cctrl_event_OnButtonClicked(FileDialogImpl *This, DWORD ctl_id)
{ {
ULONG_PTR ctx_cookie = 0;
events_client *cursor; events_client *cursor;
TRACE("%p\n", This); TRACE("%p\n", This);
if (This->user_actctx != INVALID_HANDLE_VALUE)
ActivateActCtx(This->user_actctx, &ctx_cookie);
LIST_FOR_EACH_ENTRY(cursor, &This->events_clients, events_client, entry) LIST_FOR_EACH_ENTRY(cursor, &This->events_clients, events_client, entry)
{ {
IFileDialogControlEvents *pfdce; IFileDialogControlEvents *pfdce;
...@@ -288,14 +336,21 @@ static HRESULT cctrl_event_OnButtonClicked(FileDialogImpl *This, DWORD ctl_id) ...@@ -288,14 +336,21 @@ static HRESULT cctrl_event_OnButtonClicked(FileDialogImpl *This, DWORD ctl_id)
} }
} }
if (This->user_actctx != INVALID_HANDLE_VALUE)
DeactivateActCtx(0, ctx_cookie);
return S_OK; return S_OK;
} }
static HRESULT cctrl_event_OnItemSelected(FileDialogImpl *This, DWORD ctl_id, DWORD item_id) static HRESULT cctrl_event_OnItemSelected(FileDialogImpl *This, DWORD ctl_id, DWORD item_id)
{ {
ULONG_PTR ctx_cookie = 0;
events_client *cursor; events_client *cursor;
TRACE("%p %li %li\n", This, ctl_id, item_id); TRACE("%p %li %li\n", This, ctl_id, item_id);
if (This->user_actctx != INVALID_HANDLE_VALUE)
ActivateActCtx(This->user_actctx, &ctx_cookie);
LIST_FOR_EACH_ENTRY(cursor, &This->events_clients, events_client, entry) LIST_FOR_EACH_ENTRY(cursor, &This->events_clients, events_client, entry)
{ {
IFileDialogControlEvents *pfdce; IFileDialogControlEvents *pfdce;
...@@ -307,14 +362,21 @@ static HRESULT cctrl_event_OnItemSelected(FileDialogImpl *This, DWORD ctl_id, DW ...@@ -307,14 +362,21 @@ static HRESULT cctrl_event_OnItemSelected(FileDialogImpl *This, DWORD ctl_id, DW
} }
} }
if (This->user_actctx != INVALID_HANDLE_VALUE)
DeactivateActCtx(0, ctx_cookie);
return S_OK; return S_OK;
} }
static HRESULT cctrl_event_OnCheckButtonToggled(FileDialogImpl *This, DWORD ctl_id, BOOL checked) static HRESULT cctrl_event_OnCheckButtonToggled(FileDialogImpl *This, DWORD ctl_id, BOOL checked)
{ {
ULONG_PTR ctx_cookie = 0;
events_client *cursor; events_client *cursor;
TRACE("%p\n", This); TRACE("%p\n", This);
if (This->user_actctx != INVALID_HANDLE_VALUE)
ActivateActCtx(This->user_actctx, &ctx_cookie);
LIST_FOR_EACH_ENTRY(cursor, &This->events_clients, events_client, entry) LIST_FOR_EACH_ENTRY(cursor, &This->events_clients, events_client, entry)
{ {
IFileDialogControlEvents *pfdce; IFileDialogControlEvents *pfdce;
...@@ -326,15 +388,22 @@ static HRESULT cctrl_event_OnCheckButtonToggled(FileDialogImpl *This, DWORD ctl_ ...@@ -326,15 +388,22 @@ static HRESULT cctrl_event_OnCheckButtonToggled(FileDialogImpl *This, DWORD ctl_
} }
} }
if (This->user_actctx != INVALID_HANDLE_VALUE)
DeactivateActCtx(0, ctx_cookie);
return S_OK; return S_OK;
} }
static HRESULT cctrl_event_OnControlActivating(FileDialogImpl *This, static HRESULT cctrl_event_OnControlActivating(FileDialogImpl *This,
DWORD ctl_id) DWORD ctl_id)
{ {
ULONG_PTR ctx_cookie = 0;
events_client *cursor; events_client *cursor;
TRACE("%p\n", This); TRACE("%p\n", This);
if (This->user_actctx != INVALID_HANDLE_VALUE)
ActivateActCtx(This->user_actctx, &ctx_cookie);
LIST_FOR_EACH_ENTRY(cursor, &This->events_clients, events_client, entry) LIST_FOR_EACH_ENTRY(cursor, &This->events_clients, events_client, entry)
{ {
IFileDialogControlEvents *pfdce; IFileDialogControlEvents *pfdce;
...@@ -346,6 +415,9 @@ static HRESULT cctrl_event_OnControlActivating(FileDialogImpl *This, ...@@ -346,6 +415,9 @@ static HRESULT cctrl_event_OnControlActivating(FileDialogImpl *This,
} }
} }
if (This->user_actctx != INVALID_HANDLE_VALUE)
DeactivateActCtx(0, ctx_cookie);
return S_OK; return S_OK;
} }
...@@ -2244,16 +2316,33 @@ static INT_PTR CALLBACK itemdlg_dlgproc(HWND hwnd, UINT umessage, WPARAM wparam, ...@@ -2244,16 +2316,33 @@ static INT_PTR CALLBACK itemdlg_dlgproc(HWND hwnd, UINT umessage, WPARAM wparam,
static HRESULT create_dialog(FileDialogImpl *This, HWND parent) static HRESULT create_dialog(FileDialogImpl *This, HWND parent)
{ {
ULONG_PTR ctx_cookie = 0;
INT_PTR res; INT_PTR res;
if (This->dlg_hwnd) if (This->dlg_hwnd)
return E_UNEXPECTED; return E_UNEXPECTED;
if (!GetCurrentActCtx(&This->user_actctx))
This->user_actctx = INVALID_HANDLE_VALUE;
if (COMDLG32_hActCtx != INVALID_HANDLE_VALUE)
ActivateActCtx(COMDLG32_hActCtx, &ctx_cookie);
SetLastError(0); SetLastError(0);
res = DialogBoxParamW(COMDLG32_hInstance, res = DialogBoxParamW(COMDLG32_hInstance,
MAKEINTRESOURCEW(NEWFILEOPENV3ORD), MAKEINTRESOURCEW(NEWFILEOPENV3ORD),
parent, itemdlg_dlgproc, (LPARAM)This); parent, itemdlg_dlgproc, (LPARAM)This);
This->dlg_hwnd = NULL; This->dlg_hwnd = NULL;
if (COMDLG32_hActCtx != INVALID_HANDLE_VALUE)
DeactivateActCtx(0, ctx_cookie);
if (This->user_actctx != INVALID_HANDLE_VALUE)
{
ReleaseActCtx(This->user_actctx);
This->user_actctx = INVALID_HANDLE_VALUE;
}
if(res == -1) if(res == -1)
{ {
ERR("Failed to show dialog (LastError: %ld)\n", GetLastError()); ERR("Failed to show dialog (LastError: %ld)\n", GetLastError());
...@@ -4650,6 +4739,8 @@ static HRESULT FileDialog_constructor(IUnknown *pUnkOuter, REFIID riid, void **p ...@@ -4650,6 +4739,8 @@ static HRESULT FileDialog_constructor(IUnknown *pUnkOuter, REFIID riid, void **p
return E_FAIL; return E_FAIL;
} }
fdimpl->user_actctx = INVALID_HANDLE_VALUE;
hr = IFileDialog2_QueryInterface(&fdimpl->IFileDialog2_iface, riid, ppv); hr = IFileDialog2_QueryInterface(&fdimpl->IFileDialog2_iface, riid, ppv);
IFileDialog2_Release(&fdimpl->IFileDialog2_iface); IFileDialog2_Release(&fdimpl->IFileDialog2_iface);
return hr; return hr;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment