crypt32: Implement getting the hash for each signer of a signed encoded message.
[wine.git] / dlls / atl / atl_ax.c
blob8201d099b0a9176ee56ecc385e632553cae823b3
1 /*
2 * Active Template Library ActiveX functions (atl.dll)
4 * Copyright 2006 Andrey Turkin
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
22 #include <stdio.h>
24 #define COBJMACROS
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "winerror.h"
30 #include "winuser.h"
31 #include "wine/debug.h"
32 #include "objbase.h"
33 #include "objidl.h"
34 #include "ole2.h"
35 #include "exdisp.h"
36 #include "atlbase.h"
37 #include "atliface.h"
38 #include "atlwin.h"
40 #include "wine/unicode.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(atl);
44 typedef struct IOCS {
45 const IOleClientSiteVtbl *lpOleClientSiteVtbl;
46 const IOleContainerVtbl *lpOleContainerVtbl;
47 const IOleInPlaceSiteWindowlessVtbl *lpOleInPlaceSiteWindowlessVtbl;
48 const IOleInPlaceFrameVtbl *lpOleInPlaceFrameVtbl;
49 const IOleControlSiteVtbl *lpOleControlSiteVtbl;
51 LONG ref;
52 HWND hWnd;
53 IOleObject *control;
54 RECT size;
55 WNDPROC OrigWndProc;
56 BOOL fActive, fInPlace, fWindowless;
57 } IOCS;
59 /**********************************************************************
60 * AtlAxWin class window procedure
62 static LRESULT CALLBACK AtlAxWin_wndproc( HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam )
64 if ( wMsg == WM_CREATE )
66 DWORD len = GetWindowTextLengthW( hWnd ) + 1;
67 WCHAR *ptr = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
68 if (!ptr)
69 return 1;
70 GetWindowTextW( hWnd, ptr, len );
71 AtlAxCreateControlEx( ptr, hWnd, NULL, NULL, NULL, NULL, NULL );
72 HeapFree( GetProcessHeap(), 0, ptr );
73 return 0;
75 return DefWindowProcW( hWnd, wMsg, wParam, lParam );
78 /***********************************************************************
79 * AtlAxWinInit [ATL.@]
80 * Initializes the control-hosting code: registering the AtlAxWin,
81 * AtlAxWin7 and AtlAxWinLic7 window classes and some messages.
83 * RETURNS
84 * TRUE or FALSE
87 BOOL WINAPI AtlAxWinInit(void)
89 WNDCLASSEXW wcex;
90 const WCHAR AtlAxWin[] = {'A','t','l','A','x','W','i','n',0};
92 FIXME("semi-stub\n");
94 if ( FAILED( OleInitialize(NULL) ) )
95 return FALSE;
97 wcex.cbSize = sizeof(wcex);
98 wcex.style = 0;
99 wcex.cbClsExtra = 0;
100 wcex.cbWndExtra = 0;
101 wcex.hInstance = GetModuleHandleW( NULL );
102 wcex.hIcon = NULL;
103 wcex.hCursor = NULL;
104 wcex.hbrBackground = NULL;
105 wcex.lpszMenuName = NULL;
106 wcex.hIconSm = 0;
108 wcex.lpfnWndProc = AtlAxWin_wndproc;
109 wcex.lpszClassName = AtlAxWin;
110 if ( !RegisterClassExW( &wcex ) )
111 return FALSE;
113 return TRUE;
116 /***********************************************************************
117 * Atl container component implementation
121 static ULONG WINAPI IOCS_AddRef(IOCS *This)
123 ULONG ref = InterlockedIncrement(&This->ref);
125 TRACE( "(%p) : AddRef from %d\n", This, ref - 1 );
127 return ref;
130 #define THIS2IOLECLIENTSITE(This) ((IOleClientSite*)&This->lpOleClientSiteVtbl)
131 #define THIS2IOLECONTAINER(This) ((IOleContainer*)&This->lpOleContainerVtbl)
132 #define THIS2IOLEINPLACESITEWINDOWLESS(This) ((IOleInPlaceSiteWindowless*)&This->lpOleInPlaceSiteWindowlessVtbl)
133 #define THIS2IOLEINPLACEFRAME(This) ((IOleInPlaceFrame*)&This->lpOleInPlaceFrameVtbl)
134 #define THIS2IOLECONTROLSITE(This) ((IOleControlSite*)&This->lpOleControlSiteVtbl)
136 static HRESULT WINAPI IOCS_QueryInterface(IOCS *This, REFIID riid, void **ppv)
138 *ppv = NULL;
140 if ( IsEqualIID( &IID_IUnknown, riid )
141 || IsEqualIID( &IID_IOleClientSite, riid ) )
143 *ppv = THIS2IOLECLIENTSITE(This);
144 } else if ( IsEqualIID( &IID_IOleContainer, riid ) )
146 *ppv = THIS2IOLECONTAINER(This);
147 } else if ( IsEqualIID( &IID_IOleInPlaceSite, riid ) || IsEqualIID( &IID_IOleInPlaceSiteEx, riid ) || IsEqualIID( &IID_IOleInPlaceSiteWindowless, riid ) )
149 *ppv = THIS2IOLEINPLACESITEWINDOWLESS(This);
150 } else if ( IsEqualIID( &IID_IOleInPlaceFrame, riid ) )
152 *ppv = THIS2IOLEINPLACEFRAME(This);
153 } else if ( IsEqualIID( &IID_IOleControlSite, riid ) )
155 *ppv = THIS2IOLECONTROLSITE(This);
158 if (*ppv)
160 IOCS_AddRef( This );
161 return S_OK;
164 WARN("unsupported interface %s\n", debugstr_guid( riid ) );
165 *ppv = NULL;
166 return E_NOINTERFACE;
169 static HRESULT IOCS_Detach( IOCS *This );
170 static ULONG WINAPI IOCS_Release(IOCS *This)
172 ULONG ref = InterlockedDecrement(&This->ref);
174 TRACE( "(%p) : ReleaseRef to %d\n", This, ref );
176 if (!ref)
178 IOCS_Detach( This );
179 HeapFree( GetProcessHeap(), 0, This );
182 return ref;
185 #define DEFINE_THIS(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,lp ## ifc ## Vtbl)))
187 /****** IOleClientSite *****/
188 #undef IFACE2THIS
189 #define IFACE2THIS(iface) DEFINE_THIS(IOCS,OleClientSite, iface)
190 static HRESULT WINAPI OleClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
192 IOCS *This = IFACE2THIS(iface);
193 return IOCS_QueryInterface(This, riid, ppv);
195 static ULONG WINAPI OleClientSite_AddRef(IOleClientSite *iface)
197 IOCS *This = IFACE2THIS(iface);
198 return IOCS_AddRef(This);
200 static ULONG WINAPI OleClientSite_Release(IOleClientSite *iface)
202 IOCS *This = IFACE2THIS(iface);
203 return IOCS_Release(This);
205 static HRESULT WINAPI OleClientSite_SaveObject(IOleClientSite *iface)
207 IOCS *This = IFACE2THIS(iface);
208 FIXME( "(%p) - stub\n", This );
209 return E_NOTIMPL;
211 static HRESULT WINAPI OleClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk)
213 IOCS *This = IFACE2THIS(iface);
215 FIXME( "(%p, 0x%x, 0x%x, %p)\n", This, dwAssign, dwWhichMoniker, ppmk );
216 return E_NOTIMPL;
218 static HRESULT WINAPI OleClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
220 IOCS *This = IFACE2THIS(iface);
221 TRACE( "(%p, %p)\n", This, ppContainer );
222 return OleClientSite_QueryInterface( iface, &IID_IOleContainer, (void**)ppContainer );
224 static HRESULT WINAPI OleClientSite_ShowObject(IOleClientSite *iface)
226 IOCS *This = IFACE2THIS(iface);
227 FIXME( "(%p) - stub\n", This );
228 return S_OK;
230 static HRESULT WINAPI OleClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
232 IOCS *This = IFACE2THIS(iface);
233 FIXME( "(%p, %s) - stub\n", This, fShow ? "TRUE" : "FALSE" );
234 return E_NOTIMPL;
236 static HRESULT WINAPI OleClientSite_RequestNewObjectLayout(IOleClientSite *iface)
238 IOCS *This = IFACE2THIS(iface);
239 FIXME( "(%p) - stub\n", This );
240 return E_NOTIMPL;
242 #undef IFACE2THIS
245 /****** IOleContainer *****/
246 #define IFACE2THIS(iface) DEFINE_THIS(IOCS, OleContainer, iface)
247 static HRESULT WINAPI OleContainer_QueryInterface( IOleContainer* iface, REFIID riid, void** ppv)
249 IOCS *This = IFACE2THIS(iface);
250 return IOCS_QueryInterface( This, riid, ppv );
252 static ULONG WINAPI OleContainer_AddRef(IOleContainer* iface)
254 IOCS *This = IFACE2THIS(iface);
255 return IOCS_AddRef(This);
257 static ULONG WINAPI OleContainer_Release(IOleContainer* iface)
259 IOCS *This = IFACE2THIS(iface);
260 return IOCS_Release(This);
262 static HRESULT WINAPI OleContainer_ParseDisplayName(IOleContainer* iface, IBindCtx* pbc,
263 LPOLESTR pszDisplayName, ULONG* pchEaten, IMoniker** ppmkOut)
265 IOCS *This = IFACE2THIS(iface);
266 FIXME( "(%p,%p,%s,%p,%p) - stub\n", This, pbc, debugstr_w(pszDisplayName), pchEaten, ppmkOut );
267 return E_NOTIMPL;
269 static HRESULT WINAPI OleContainer_EnumObjects(IOleContainer* iface, DWORD grfFlags, IEnumUnknown** ppenum)
271 IOCS *This = IFACE2THIS(iface);
272 FIXME( "(%p, %u, %p) - stub\n", This, grfFlags, ppenum );
273 return E_NOTIMPL;
275 static HRESULT WINAPI OleContainer_LockContainer(IOleContainer* iface, BOOL fLock)
277 IOCS *This = IFACE2THIS(iface);
278 FIXME( "(%p, %s) - stub\n", This, fLock?"TRUE":"FALSE" );
279 return E_NOTIMPL;
281 #undef IFACE2THIS
284 /****** IOleInPlaceSiteWindowless *******/
285 #define IFACE2THIS(iface) DEFINE_THIS(IOCS, OleInPlaceSiteWindowless, iface)
286 static HRESULT WINAPI OleInPlaceSiteWindowless_QueryInterface(IOleInPlaceSiteWindowless *iface, REFIID riid, void **ppv)
288 IOCS *This = IFACE2THIS(iface);
289 return IOCS_QueryInterface(This, riid, ppv);
291 static ULONG WINAPI OleInPlaceSiteWindowless_AddRef(IOleInPlaceSiteWindowless *iface)
293 IOCS *This = IFACE2THIS(iface);
294 return IOCS_AddRef(This);
296 static ULONG WINAPI OleInPlaceSiteWindowless_Release(IOleInPlaceSiteWindowless *iface)
298 IOCS *This = IFACE2THIS(iface);
299 return IOCS_Release(This);
301 static HRESULT WINAPI OleInPlaceSiteWindowless_GetWindow(IOleInPlaceSiteWindowless* iface, HWND* phwnd)
303 IOCS *This = IFACE2THIS(iface);
305 TRACE("(%p,%p)\n", This, phwnd);
306 *phwnd = This->hWnd;
307 return S_OK;
309 static HRESULT WINAPI OleInPlaceSiteWindowless_ContextSensitiveHelp(IOleInPlaceSiteWindowless* iface, BOOL fEnterMode)
311 IOCS *This = IFACE2THIS(iface);
312 FIXME("(%p,%d) - stub\n", This, fEnterMode);
313 return E_NOTIMPL;
315 static HRESULT WINAPI OleInPlaceSiteWindowless_CanInPlaceActivate(IOleInPlaceSiteWindowless *iface)
317 IOCS *This = IFACE2THIS(iface);
318 TRACE("(%p)\n", This);
319 return S_OK;
321 static HRESULT WINAPI OleInPlaceSiteWindowless_OnInPlaceActivate(IOleInPlaceSiteWindowless *iface)
323 IOCS *This = IFACE2THIS(iface);
325 TRACE("(%p)\n", This);
327 This->fInPlace = TRUE;
328 return S_OK;
330 static HRESULT WINAPI OleInPlaceSiteWindowless_OnUIActivate(IOleInPlaceSiteWindowless *iface)
332 IOCS *This = IFACE2THIS(iface);
334 TRACE("(%p)\n", This);
336 return S_OK;
338 static HRESULT WINAPI OleInPlaceSiteWindowless_GetWindowContext(IOleInPlaceSiteWindowless *iface,
339 IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
340 LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
342 IOCS *This = IFACE2THIS(iface);
344 TRACE("(%p,%p,%p,%p,%p,%p)\n", This, ppFrame, ppDoc, lprcPosRect, lprcClipRect, lpFrameInfo);
346 if ( lprcClipRect )
347 memcpy(lprcClipRect, &This->size, sizeof(RECT));
348 if ( lprcPosRect )
349 memcpy(lprcPosRect, &This->size, sizeof(RECT));
351 if ( ppFrame )
353 IOCS_QueryInterface( This, &IID_IOleInPlaceFrame, (void**) ppFrame );
356 if ( ppDoc )
357 *ppDoc = NULL;
359 if ( lpFrameInfo )
361 lpFrameInfo->fMDIApp = FALSE;
362 lpFrameInfo->hwndFrame = This->hWnd;
363 lpFrameInfo->haccel = NULL;
364 lpFrameInfo->cAccelEntries = 0;
367 return S_OK;
369 static HRESULT WINAPI OleInPlaceSiteWindowless_Scroll(IOleInPlaceSiteWindowless *iface, SIZE scrollExtent)
371 IOCS *This = IFACE2THIS(iface);
372 FIXME("(%p) - stub\n", This);
373 return E_NOTIMPL;
375 static HRESULT WINAPI OleInPlaceSiteWindowless_OnUIDeactivate(IOleInPlaceSiteWindowless *iface, BOOL fUndoable)
377 IOCS *This = IFACE2THIS(iface);
378 FIXME("(%p,%d) - stub\n", This, fUndoable);
379 return E_NOTIMPL;
381 static HRESULT WINAPI OleInPlaceSiteWindowless_OnInPlaceDeactivate(IOleInPlaceSiteWindowless *iface)
383 IOCS *This = IFACE2THIS(iface);
385 TRACE("(%p)\n", This);
387 This->fInPlace = This->fWindowless = FALSE;
388 return S_OK;
390 static HRESULT WINAPI OleInPlaceSiteWindowless_DiscardUndoState(IOleInPlaceSiteWindowless *iface)
392 IOCS *This = IFACE2THIS(iface);
393 FIXME("(%p) - stub\n", This);
394 return E_NOTIMPL;
396 static HRESULT WINAPI OleInPlaceSiteWindowless_DeactivateAndUndo(IOleInPlaceSiteWindowless *iface)
398 IOCS *This = IFACE2THIS(iface);
399 FIXME("(%p) - stub\n", This);
400 return E_NOTIMPL;
402 static HRESULT WINAPI OleInPlaceSiteWindowless_OnPosRectChange(IOleInPlaceSiteWindowless *iface, LPCRECT lprcPosRect)
404 IOCS *This = IFACE2THIS(iface);
405 FIXME("(%p,%p) - stub\n", This, lprcPosRect);
406 return E_NOTIMPL;
408 static HRESULT WINAPI OleInPlaceSiteWindowless_OnInPlaceActivateEx( IOleInPlaceSiteWindowless *iface, BOOL* pfNoRedraw, DWORD dwFlags)
410 IOCS *This = IFACE2THIS(iface);
412 TRACE("\n");
414 This->fActive = This->fInPlace = TRUE;
415 if ( dwFlags & ACTIVATE_WINDOWLESS )
416 This->fWindowless = TRUE;
417 return S_OK;
419 static HRESULT WINAPI OleInPlaceSiteWindowless_OnInPlaceDeactivateEx( IOleInPlaceSiteWindowless *iface, BOOL fNoRedraw)
421 IOCS *This = IFACE2THIS(iface);
423 TRACE("\n");
425 This->fActive = This->fInPlace = This->fWindowless = FALSE;
426 return S_OK;
428 static HRESULT WINAPI OleInPlaceSiteWindowless_RequestUIActivate( IOleInPlaceSiteWindowless *iface)
430 FIXME("\n");
431 return E_NOTIMPL;
433 static HRESULT WINAPI OleInPlaceSiteWindowless_CanWindowlessActivate( IOleInPlaceSiteWindowless *iface)
435 FIXME("\n");
436 return S_OK;
438 static HRESULT WINAPI OleInPlaceSiteWindowless_GetCapture( IOleInPlaceSiteWindowless *iface)
440 FIXME("\n");
441 return E_NOTIMPL;
443 static HRESULT WINAPI OleInPlaceSiteWindowless_SetCapture( IOleInPlaceSiteWindowless *iface, BOOL fCapture)
445 FIXME("\n");
446 return E_NOTIMPL;
448 static HRESULT WINAPI OleInPlaceSiteWindowless_GetFocus( IOleInPlaceSiteWindowless *iface)
450 FIXME("\n");
451 return E_NOTIMPL;
453 static HRESULT WINAPI OleInPlaceSiteWindowless_SetFocus( IOleInPlaceSiteWindowless *iface, BOOL fFocus)
455 FIXME("\n");
456 return E_NOTIMPL;
458 static HRESULT WINAPI OleInPlaceSiteWindowless_GetDC( IOleInPlaceSiteWindowless *iface, LPCRECT pRect, DWORD grfFlags, HDC* phDC)
460 FIXME("\n");
461 return E_NOTIMPL;
463 static HRESULT WINAPI OleInPlaceSiteWindowless_ReleaseDC( IOleInPlaceSiteWindowless *iface, HDC hDC)
465 FIXME("\n");
466 return E_NOTIMPL;
468 static HRESULT WINAPI OleInPlaceSiteWindowless_InvalidateRect( IOleInPlaceSiteWindowless *iface, LPCRECT pRect, BOOL fErase)
470 FIXME("\n");
471 return E_NOTIMPL;
473 static HRESULT WINAPI OleInPlaceSiteWindowless_InvalidateRgn( IOleInPlaceSiteWindowless *iface, HRGN hRGN, BOOL fErase)
475 FIXME("\n");
476 return E_NOTIMPL;
478 static HRESULT WINAPI OleInPlaceSiteWindowless_ScrollRect( IOleInPlaceSiteWindowless *iface, INT dx, INT dy, LPCRECT pRectScroll, LPCRECT pRectClip)
480 FIXME("\n");
481 return E_NOTIMPL;
483 static HRESULT WINAPI OleInPlaceSiteWindowless_AdjustRect( IOleInPlaceSiteWindowless *iface, LPRECT prc)
485 FIXME("\n");
486 return E_NOTIMPL;
488 static HRESULT WINAPI OleInPlaceSiteWindowless_OnDefWindowMessage( IOleInPlaceSiteWindowless *iface, UINT msg, WPARAM wParam, LPARAM lParam, LRESULT* plResult)
490 FIXME("\n");
491 return E_NOTIMPL;
493 #undef IFACE2THIS
496 /****** IOleInPlaceFrame *******/
497 #define IFACE2THIS(iface) DEFINE_THIS(IOCS, OleInPlaceFrame, iface)
498 static HRESULT WINAPI OleInPlaceFrame_QueryInterface(IOleInPlaceFrame *iface, REFIID riid, void **ppv)
500 IOCS *This = IFACE2THIS(iface);
501 return IOCS_QueryInterface(This, riid, ppv);
503 static ULONG WINAPI OleInPlaceFrame_AddRef(IOleInPlaceFrame *iface)
505 IOCS *This = IFACE2THIS(iface);
506 return IOCS_AddRef(This);
508 static ULONG WINAPI OleInPlaceFrame_Release(IOleInPlaceFrame *iface)
510 IOCS *This = IFACE2THIS(iface);
511 return IOCS_Release(This);
513 static HRESULT WINAPI OleInPlaceFrame_GetWindow(IOleInPlaceFrame *iface, HWND *phWnd)
515 IOCS *This = IFACE2THIS(iface);
517 TRACE( "(%p,%p)\n", This, phWnd );
519 *phWnd = This->hWnd;
520 return S_OK;
523 static HRESULT WINAPI OleInPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame *iface, BOOL fEnterMode)
525 IOCS *This = IFACE2THIS(iface);
527 FIXME( "(%p,%d) - stub\n", This, fEnterMode );
528 return E_NOTIMPL;
531 static HRESULT WINAPI OleInPlaceFrame_GetBorder(IOleInPlaceFrame *iface, LPRECT lprectBorder)
533 IOCS *This = IFACE2THIS(iface);
535 FIXME( "(%p,%p) - stub\n", This, lprectBorder );
536 return E_NOTIMPL;
539 static HRESULT WINAPI OleInPlaceFrame_RequestBorderSpace(IOleInPlaceFrame *iface, LPCBORDERWIDTHS pborderwidths)
541 IOCS *This = IFACE2THIS(iface);
543 FIXME( "(%p,%p) - stub\n", This, pborderwidths );
544 return E_NOTIMPL;
547 static HRESULT WINAPI OleInPlaceFrame_SetBorderSpace(IOleInPlaceFrame *iface, LPCBORDERWIDTHS pborderwidths)
549 IOCS *This = IFACE2THIS(iface);
551 FIXME( "(%p,%p) - stub\n", This, pborderwidths );
552 return E_NOTIMPL;
555 static HRESULT WINAPI OleInPlaceFrame_SetActiveObject(IOleInPlaceFrame *iface, IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
557 IOCS *This = IFACE2THIS(iface);
559 FIXME( "(%p,%p,%s) - stub\n", This, pActiveObject, debugstr_w(pszObjName) );
560 return S_OK;
563 static HRESULT WINAPI OleInPlaceFrame_InsertMenus(IOleInPlaceFrame *iface, HMENU hmenuShared, LPOLEMENUGROUPWIDTHS lpMenuWidths)
565 IOCS *This = IFACE2THIS(iface);
567 FIXME( "(%p,%p,%p) - stub\n", This, hmenuShared, lpMenuWidths );
568 return E_NOTIMPL;
571 static HRESULT WINAPI OleInPlaceFrame_SetMenu(IOleInPlaceFrame *iface, HMENU hmenuShared, HOLEMENU holemenu, HWND hwndActiveObject)
573 IOCS *This = IFACE2THIS(iface);
575 FIXME( "(%p,%p,%p,%p) - stub\n", This, hmenuShared, holemenu, hwndActiveObject );
576 return E_NOTIMPL;
578 static HRESULT WINAPI OleInPlaceFrame_RemoveMenus(IOleInPlaceFrame *iface, HMENU hmenuShared)
580 IOCS *This = IFACE2THIS(iface);
582 FIXME( "(%p, %p) - stub\n", This, hmenuShared );
583 return E_NOTIMPL;
586 static HRESULT WINAPI OleInPlaceFrame_SetStatusText(IOleInPlaceFrame *iface, LPCOLESTR pszStatusText)
588 IOCS *This = IFACE2THIS(iface);
590 FIXME( "(%p, %s) - stub\n", This, debugstr_w( pszStatusText ) );
591 return E_NOTIMPL;
594 static HRESULT WINAPI OleInPlaceFrame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
596 IOCS *This = IFACE2THIS(iface);
598 FIXME( "(%p, %d) - stub\n", This, fEnable );
599 return E_NOTIMPL;
602 static HRESULT WINAPI OleInPlaceFrame_TranslateAccelerator(IOleInPlaceFrame *iface, LPMSG lpmsg, WORD wID)
604 IOCS *This = IFACE2THIS(iface);
606 FIXME( "(%p, %p, %x) - stub\n", This, lpmsg, wID );
607 return E_NOTIMPL;
609 #undef IFACE2THIS
612 /****** IOleControlSite *******/
613 #define IFACE2THIS(iface) DEFINE_THIS(IOCS, OleControlSite, iface)
614 static HRESULT WINAPI OleControlSite_QueryInterface(IOleControlSite *iface, REFIID riid, void **ppv)
616 IOCS *This = IFACE2THIS(iface);
617 return IOCS_QueryInterface(This, riid, ppv);
619 static ULONG WINAPI OleControlSite_AddRef(IOleControlSite *iface)
621 IOCS *This = IFACE2THIS(iface);
622 return IOCS_AddRef(This);
624 static ULONG WINAPI OleControlSite_Release(IOleControlSite *iface)
626 IOCS *This = IFACE2THIS(iface);
627 return IOCS_Release(This);
629 static HRESULT WINAPI OleControlSite_OnControlInfoChanged( IOleControlSite* This)
631 FIXME( "\n" );
632 return E_NOTIMPL;
634 static HRESULT WINAPI OleControlSite_LockInPlaceActive( IOleControlSite* This, BOOL fLock)
636 FIXME( "\n" );
637 return E_NOTIMPL;
639 static HRESULT WINAPI OleControlSite_GetExtendedControl( IOleControlSite* This, IDispatch** ppDisp)
641 FIXME( "\n" );
642 return E_NOTIMPL;
644 static HRESULT WINAPI OleControlSite_TransformCoords( IOleControlSite* This, POINTL* pPtlHimetric, POINTF* pPtfContainer, DWORD dwFlags)
646 FIXME( "\n" );
647 return E_NOTIMPL;
649 static HRESULT WINAPI OleControlSite_TranslateAccelerator( IOleControlSite* This, MSG* pMsg, DWORD grfModifiers)
651 FIXME( "\n" );
652 return E_NOTIMPL;
654 static HRESULT WINAPI OleControlSite_OnFocus( IOleControlSite* This, BOOL fGotFocus)
656 FIXME( "\n" );
657 return E_NOTIMPL;
659 static HRESULT WINAPI OleControlSite_ShowPropertyFrame( IOleControlSite* This)
661 FIXME( "\n" );
662 return E_NOTIMPL;
664 #undef IFACE2THIS
668 static const IOleClientSiteVtbl OleClientSite_vtbl = {
669 OleClientSite_QueryInterface,
670 OleClientSite_AddRef,
671 OleClientSite_Release,
672 OleClientSite_SaveObject,
673 OleClientSite_GetMoniker,
674 OleClientSite_GetContainer,
675 OleClientSite_ShowObject,
676 OleClientSite_OnShowWindow,
677 OleClientSite_RequestNewObjectLayout
679 static const IOleContainerVtbl OleContainer_vtbl = {
680 OleContainer_QueryInterface,
681 OleContainer_AddRef,
682 OleContainer_Release,
683 OleContainer_ParseDisplayName,
684 OleContainer_EnumObjects,
685 OleContainer_LockContainer
687 static const IOleInPlaceSiteWindowlessVtbl OleInPlaceSiteWindowless_vtbl = {
688 OleInPlaceSiteWindowless_QueryInterface,
689 OleInPlaceSiteWindowless_AddRef,
690 OleInPlaceSiteWindowless_Release,
691 OleInPlaceSiteWindowless_GetWindow,
692 OleInPlaceSiteWindowless_ContextSensitiveHelp,
693 OleInPlaceSiteWindowless_CanInPlaceActivate,
694 OleInPlaceSiteWindowless_OnInPlaceActivate,
695 OleInPlaceSiteWindowless_OnUIActivate,
696 OleInPlaceSiteWindowless_GetWindowContext,
697 OleInPlaceSiteWindowless_Scroll,
698 OleInPlaceSiteWindowless_OnUIDeactivate,
699 OleInPlaceSiteWindowless_OnInPlaceDeactivate,
700 OleInPlaceSiteWindowless_DiscardUndoState,
701 OleInPlaceSiteWindowless_DeactivateAndUndo,
702 OleInPlaceSiteWindowless_OnPosRectChange,
703 OleInPlaceSiteWindowless_OnInPlaceActivateEx,
704 OleInPlaceSiteWindowless_OnInPlaceDeactivateEx,
705 OleInPlaceSiteWindowless_RequestUIActivate,
706 OleInPlaceSiteWindowless_CanWindowlessActivate,
707 OleInPlaceSiteWindowless_GetCapture,
708 OleInPlaceSiteWindowless_SetCapture,
709 OleInPlaceSiteWindowless_GetFocus,
710 OleInPlaceSiteWindowless_SetFocus,
711 OleInPlaceSiteWindowless_GetDC,
712 OleInPlaceSiteWindowless_ReleaseDC,
713 OleInPlaceSiteWindowless_InvalidateRect,
714 OleInPlaceSiteWindowless_InvalidateRgn,
715 OleInPlaceSiteWindowless_ScrollRect,
716 OleInPlaceSiteWindowless_AdjustRect,
717 OleInPlaceSiteWindowless_OnDefWindowMessage
719 static const IOleInPlaceFrameVtbl OleInPlaceFrame_vtbl =
721 OleInPlaceFrame_QueryInterface,
722 OleInPlaceFrame_AddRef,
723 OleInPlaceFrame_Release,
724 OleInPlaceFrame_GetWindow,
725 OleInPlaceFrame_ContextSensitiveHelp,
726 OleInPlaceFrame_GetBorder,
727 OleInPlaceFrame_RequestBorderSpace,
728 OleInPlaceFrame_SetBorderSpace,
729 OleInPlaceFrame_SetActiveObject,
730 OleInPlaceFrame_InsertMenus,
731 OleInPlaceFrame_SetMenu,
732 OleInPlaceFrame_RemoveMenus,
733 OleInPlaceFrame_SetStatusText,
734 OleInPlaceFrame_EnableModeless,
735 OleInPlaceFrame_TranslateAccelerator
737 static const IOleControlSiteVtbl OleControlSite_vtbl =
739 OleControlSite_QueryInterface,
740 OleControlSite_AddRef,
741 OleControlSite_Release,
742 OleControlSite_OnControlInfoChanged,
743 OleControlSite_LockInPlaceActive,
744 OleControlSite_GetExtendedControl,
745 OleControlSite_TransformCoords,
746 OleControlSite_TranslateAccelerator,
747 OleControlSite_OnFocus,
748 OleControlSite_ShowPropertyFrame
751 static HRESULT IOCS_Detach( IOCS *This ) /* remove subclassing */
753 if ( This->hWnd )
755 SetWindowLongPtrW( This->hWnd, GWLP_WNDPROC, (ULONG_PTR) This->OrigWndProc );
756 SetWindowLongPtrW( This->hWnd, GWLP_USERDATA, (LONG_PTR) NULL );
757 This->hWnd = NULL;
759 if ( This->control )
761 IOleObject *control = This->control;
763 This->control = NULL;
764 IOleObject_SetClientSite( control, NULL );
765 IOleObject_Release( control );
767 return S_OK;
770 static void IOCS_OnSize( IOCS* This, LPCRECT rect )
772 SIZEL inPix, inHi;
774 This->size.left = rect->left; This->size.right = rect->right; This->size.top = rect->top; This->size.bottom = rect->bottom;
776 if ( !This->control )
777 return;
779 inPix.cx = rect->right - rect->left;
780 inPix.cy = rect->bottom - rect->top;
781 AtlPixelToHiMetric( &inPix, &inHi );
782 IOleObject_SetExtent( This->control, DVASPECT_CONTENT, &inHi );
784 if ( This->fInPlace )
786 IOleInPlaceObject *wl;
788 if ( SUCCEEDED( IOleObject_QueryInterface( This->control, &IID_IOleInPlaceObject, (void**)&wl ) ) )
790 IOleInPlaceObject_SetObjectRects( wl, rect, rect );
791 IOleInPlaceObject_Release( wl );
796 static void IOCS_OnShow( IOCS *This, BOOL fShow )
798 if (!This->control || This->fActive || !fShow )
799 return;
801 This->fActive = TRUE;
804 static void IOCS_OnDraw( IOCS *This )
806 IViewObject *view;
808 if ( !This->control || !This->fWindowless )
809 return;
811 if ( SUCCEEDED( IOleObject_QueryInterface( This->control, &IID_IViewObject, (void**)&view ) ) )
813 HDC dc = GetDC( This->hWnd );
814 RECTL rect;
816 rect.left = This->size.left; rect.top = This->size.top;
817 rect.bottom = This->size.bottom; rect.right = This->size.right;
819 IViewObject_Draw( view, DVASPECT_CONTENT, ~0, NULL, NULL, 0, dc, &rect, &rect, NULL, 0 );
820 IViewObject_Release( view );
821 ReleaseDC( This->hWnd, dc );
825 static LRESULT IOCS_OnWndProc( IOCS *This, HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
827 WNDPROC OrigWndProc = This->OrigWndProc;
829 switch( uMsg )
831 case WM_DESTROY:
832 IOCS_Detach( This );
833 break;
834 case WM_SIZE:
836 RECT r;
837 r.left = r.top = 0;
838 r.right = LOWORD( lParam );
839 r.bottom = HIWORD( lParam );
840 IOCS_OnSize( This, &r );
842 break;
843 case WM_SHOWWINDOW:
844 IOCS_OnShow( This, (BOOL) wParam );
845 break;
846 case WM_PAINT:
847 IOCS_OnDraw( This );
848 break;
851 return CallWindowProcW( OrigWndProc, hWnd, uMsg, wParam, lParam );
854 static LRESULT CALLBACK AtlHost_wndproc( HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam )
856 IOCS *This = (IOCS*) GetWindowLongPtrW( hWnd, GWLP_USERDATA );
857 return IOCS_OnWndProc( This, hWnd, wMsg, wParam, lParam );
860 static HRESULT IOCS_Attach( IOCS *This, HWND hWnd, IUnknown *pUnkControl ) /* subclass hWnd */
862 This->hWnd = hWnd;
863 IUnknown_QueryInterface( pUnkControl, &IID_IOleObject, (void**)&This->control );
864 IOleObject_SetClientSite( This->control, THIS2IOLECLIENTSITE( This ) );
865 SetWindowLongPtrW( hWnd, GWLP_USERDATA, (ULONG_PTR) This );
866 This->OrigWndProc = (WNDPROC)SetWindowLongPtrW( hWnd, GWLP_WNDPROC, (ULONG_PTR) AtlHost_wndproc );
868 return S_OK;
871 static HRESULT IOCS_Init( IOCS *This )
873 RECT rect;
874 static const WCHAR AXWIN[] = {'A','X','W','I','N',0};
876 IOleObject_SetHostNames( This->control, AXWIN, AXWIN );
878 GetClientRect( This->hWnd, &rect );
879 IOCS_OnSize( This, &rect );
880 IOleObject_DoVerb( This->control, OLEIVERB_INPLACEACTIVATE, NULL, THIS2IOLECLIENTSITE( This ), 0, This->hWnd, &rect );
882 return S_OK;
885 /**********************************************************************
886 * Create new instance of Atl host component and attach it to window *
888 static HRESULT IOCS_Create( HWND hWnd, IUnknown *pUnkControl, IOCS **ppSite )
890 HRESULT hr;
891 IOCS *This;
893 *ppSite = NULL;
894 This = HeapAlloc(GetProcessHeap(), 0, sizeof(IOCS));
896 if (!This)
897 return E_OUTOFMEMORY;
899 This->lpOleClientSiteVtbl = &OleClientSite_vtbl;
900 This->lpOleContainerVtbl = &OleContainer_vtbl;
901 This->lpOleInPlaceSiteWindowlessVtbl = &OleInPlaceSiteWindowless_vtbl;
902 This->lpOleInPlaceFrameVtbl = &OleInPlaceFrame_vtbl;
903 This->lpOleControlSiteVtbl = &OleControlSite_vtbl;
904 This->ref = 1;
906 This->OrigWndProc = NULL;
907 This->hWnd = NULL;
908 This->fWindowless = This->fActive = This->fInPlace = FALSE;
910 hr = IOCS_Attach( This, hWnd, pUnkControl );
911 if ( SUCCEEDED( hr ) )
912 hr = IOCS_Init( This );
913 if ( SUCCEEDED( hr ) )
914 *ppSite = This;
915 else
916 IOCS_Release( This );
918 return hr;
922 /***********************************************************************
923 * AtlAxCreateControl [ATL.@]
925 HRESULT WINAPI AtlAxCreateControl(LPCOLESTR lpszName, HWND hWnd,
926 IStream *pStream, IUnknown **ppUnkContainer)
928 return AtlAxCreateControlEx( lpszName, hWnd, pStream, ppUnkContainer,
929 NULL, NULL, NULL );
932 /***********************************************************************
933 * AtlAxCreateControlEx [ATL.@]
935 * REMARKS
936 * See http://www.codeproject.com/com/cwebpage.asp for some background
939 HRESULT WINAPI AtlAxCreateControlEx(LPCOLESTR lpszName, HWND hWnd,
940 IStream *pStream, IUnknown **ppUnkContainer, IUnknown **ppUnkControl,
941 REFIID iidSink, IUnknown *punkSink)
943 CLSID controlId;
944 HRESULT hRes;
945 IOleObject *pControl;
946 IUnknown *pUnkControl;
947 IPersistStreamInit *pPSInit;
948 IUnknown *pContainer;
949 enum {IsGUID=0,IsHTML=1,IsURL=2} content;
951 TRACE("(%s %p %p %p %p %p %p)\n", debugstr_w(lpszName), hWnd, pStream,
952 ppUnkContainer, ppUnkControl, iidSink, punkSink);
954 hRes = CLSIDFromString( (LPOLESTR) lpszName, &controlId );
955 if ( FAILED(hRes) )
956 hRes = CLSIDFromProgID( lpszName, &controlId );
957 if ( SUCCEEDED( hRes ) )
958 content = IsGUID;
959 else {
960 /* FIXME - check for MSHTML: prefix! */
961 content = IsURL;
962 memcpy( &controlId, &CLSID_WebBrowser, sizeof(controlId) );
965 hRes = CoCreateInstance( &controlId, 0, CLSCTX_ALL, &IID_IOleObject,
966 (void**) &pControl );
967 if ( FAILED( hRes ) )
969 WARN( "cannot create ActiveX control %s instance - error 0x%08x\n",
970 debugstr_guid( &controlId ), hRes );
971 return hRes;
974 hRes = IOleObject_QueryInterface( pControl, &IID_IPersistStreamInit, (void**) &pPSInit );
975 if ( SUCCEEDED( hRes ) )
977 if (!pStream)
978 IPersistStreamInit_InitNew( pPSInit );
979 else
980 IPersistStreamInit_Load( pPSInit, pStream );
981 IPersistStreamInit_Release( pPSInit );
982 } else
983 WARN("cannot get IID_IPersistStreamInit out of control\n");
985 IOleObject_QueryInterface( pControl, &IID_IUnknown, (void**) &pUnkControl );
986 IOleObject_Release( pControl );
989 hRes = AtlAxAttachControl( pUnkControl, hWnd, &pContainer );
990 if ( FAILED( hRes ) )
991 WARN("cannot attach control to window\n");
993 if ( content == IsURL )
995 IWebBrowser2 *browser;
997 hRes = IOleObject_QueryInterface( pControl, &IID_IWebBrowser2, (void**) &browser );
998 if ( !browser )
999 WARN( "Cannot query IWebBrowser2 interface: %08x\n", hRes );
1000 else {
1001 VARIANT url;
1003 IWebBrowser2_put_Visible( browser, VARIANT_TRUE ); /* it seems that native does this on URL (but do not on MSHTML:! why? */
1005 V_VT(&url) = VT_BSTR;
1006 V_BSTR(&url) = SysAllocString( lpszName );
1008 hRes = IWebBrowser2_Navigate2( browser, &url, NULL, NULL, NULL, NULL );
1009 if ( FAILED( hRes ) )
1010 WARN( "IWebBrowser2::Navigate2 failed: %08x\n", hRes );
1011 SysFreeString( V_BSTR(&url) );
1013 IWebBrowser2_Release( browser );
1017 if (ppUnkContainer)
1019 *ppUnkContainer = pContainer;
1020 if ( pContainer )
1021 IUnknown_AddRef( pContainer );
1023 if (ppUnkControl)
1025 *ppUnkControl = pUnkControl;
1026 if ( pUnkControl )
1027 IUnknown_AddRef( pUnkControl );
1030 IUnknown_Release( pUnkControl );
1031 if ( pContainer )
1032 IUnknown_Release( pContainer );
1034 return S_OK;
1037 /***********************************************************************
1038 * AtlAxAttachControl [ATL.@]
1040 HRESULT WINAPI AtlAxAttachControl(IUnknown* pControl, HWND hWnd, IUnknown** ppUnkContainer)
1042 IOCS *pUnkContainer;
1043 HRESULT hr;
1045 TRACE( "%p %p %p\n", pControl, hWnd, ppUnkContainer );
1047 *ppUnkContainer = NULL;
1049 hr = IOCS_Create( hWnd, pControl, &pUnkContainer );
1050 if ( SUCCEEDED( hr ) )
1052 *ppUnkContainer = (IUnknown*) pUnkContainer;
1055 return hr;
1058 /**********************************************************************
1059 * Helper function for AX_ConvertDialogTemplate
1061 static inline BOOL advance_array(WORD **pptr, DWORD *palloc, DWORD *pfilled, const WORD *data, DWORD size)
1063 if ( (*pfilled + size) > *palloc )
1065 *palloc = ((*pfilled+size) + 0xFF) & ~0xFF;
1066 *pptr = HeapReAlloc( GetProcessHeap(), 0, *pptr, *palloc * sizeof(WORD) );
1067 if (!*pptr)
1068 return FALSE;
1070 RtlMoveMemory( *pptr+*pfilled, data, size * sizeof(WORD) );
1071 *pfilled += size;
1072 return TRUE;
1075 /**********************************************************************
1076 * Convert ActiveX control templates to AtlAxWin class instances
1078 static LPDLGTEMPLATEW AX_ConvertDialogTemplate(LPCDLGTEMPLATEW src_tmpl)
1080 #define GET_WORD(x) (*(const WORD *)(x))
1081 #define GET_DWORD(x) (*(const DWORD *)(x))
1082 #define PUT_BLOCK(x,y) do {if (!advance_array(&output, &allocated, &filled, (x), (y))) return NULL;} while (0)
1083 #define PUT_WORD(x) do {WORD w = (x);PUT_BLOCK(&w, 1);} while(0)
1084 #define PUT_DWORD(x) do {DWORD w = (x);PUT_BLOCK(&w, 2);} while(0)
1085 const WORD *tmp, *src = (const WORD *)src_tmpl;
1086 WORD *output;
1087 DWORD allocated, filled; /* in WORDs */
1088 BOOL ext;
1089 WORD signature, dlgver, rescount;
1090 DWORD style;
1092 filled = 0; allocated = 256;
1093 output = HeapAlloc( GetProcessHeap(), 0, allocated * sizeof(WORD) );
1094 if (!output)
1095 return NULL;
1097 /* header */
1098 tmp = src;
1099 signature = GET_WORD(src);
1100 dlgver = GET_WORD(src + 1);
1101 if (signature == 1 && dlgver == 0xFFFF)
1103 ext = TRUE;
1104 src += 6;
1105 style = GET_DWORD(src);
1106 src += 2;
1107 rescount = GET_WORD(src++);
1108 src += 4;
1109 if ( GET_WORD(src) == 0xFFFF ) /* menu */
1110 src += 2;
1111 else
1112 src += strlenW(src) + 1;
1113 if ( GET_WORD(src) == 0xFFFF ) /* class */
1114 src += 2;
1115 else
1116 src += strlenW(src) + 1;
1117 src += strlenW(src) + 1; /* title */
1118 if ( style & (DS_SETFONT | DS_SHELLFONT) )
1120 src += 3;
1121 src += strlenW(src) + 1;
1123 } else {
1124 ext = FALSE;
1125 style = GET_DWORD(src);
1126 src += 4;
1127 rescount = GET_WORD(src++);
1128 src += 4;
1129 if ( GET_WORD(src) == 0xFFFF ) /* menu */
1130 src += 2;
1131 else
1132 src += strlenW(src) + 1;
1133 if ( GET_WORD(src) == 0xFFFF ) /* class */
1134 src += 2;
1135 else
1136 src += strlenW(src) + 1;
1137 src += strlenW(src) + 1; /* title */
1138 if ( style & DS_SETFONT )
1140 src++;
1141 src += strlenW(src) + 1;
1144 PUT_BLOCK(tmp, src-tmp);
1146 while(rescount--)
1148 src = (const WORD *)( ( ((ULONG_PTR)src) + 3) & ~3); /* align on DWORD boundary */
1149 filled = (filled + 1) & ~1; /* depends on DWORD-aligned allocation unit */
1151 tmp = src;
1152 if (ext)
1153 src += 11;
1154 else
1155 src += 9;
1156 PUT_BLOCK(tmp, src-tmp);
1158 tmp = src;
1159 if ( GET_WORD(src) == 0xFFFF ) /* class */
1161 src += 2;
1162 } else
1164 src += strlenW(src) + 1;
1166 src += strlenW(src) + 1; /* title */
1167 if ( GET_WORD(tmp) == '{' ) /* all this mess created because of this line */
1169 static const WCHAR AtlAxWin[9]={'A','t','l','A','x','W','i','n',0};
1170 PUT_BLOCK(AtlAxWin, sizeof(AtlAxWin)/sizeof(WCHAR));
1171 PUT_BLOCK(tmp, strlenW(tmp)+1);
1172 } else
1173 PUT_BLOCK(tmp, src-tmp);
1175 if ( GET_WORD(src) )
1177 WORD size = (GET_WORD(src)+sizeof(WORD)-1) / sizeof(WORD); /* quite ugly :( Maybe use BYTE* instead of WORD* everywhere ? */
1178 PUT_BLOCK(src, size);
1179 src+=size;
1181 else
1183 PUT_WORD(0);
1184 src++;
1187 return (LPDLGTEMPLATEW) output;
1190 /***********************************************************************
1191 * AtlAxCreateDialogA [ATL.@]
1193 * Creates a dialog window
1195 * PARAMS
1196 * hInst [I] Application instance
1197 * name [I] Dialog box template name
1198 * owner [I] Dialog box parent HWND
1199 * dlgProc [I] Dialog box procedure
1200 * param [I] This value will be passed to dlgProc as WM_INITDIALOG's message lParam
1202 * RETURNS
1203 * Window handle of dialog window.
1205 HWND WINAPI AtlAxCreateDialogA(HINSTANCE hInst, LPCSTR name, HWND owner, DLGPROC dlgProc ,LPARAM param)
1207 HWND res = NULL;
1208 int length;
1209 WCHAR *nameW;
1211 if ( HIWORD(name) == 0 )
1212 return AtlAxCreateDialogW( hInst, (LPCWSTR) name, owner, dlgProc, param );
1214 length = MultiByteToWideChar( CP_ACP, 0, name, -1, NULL, 0 );
1215 nameW = HeapAlloc( GetProcessHeap(), 0, length * sizeof(WCHAR) );
1216 if (nameW)
1218 MultiByteToWideChar( CP_ACP, 0, name, -1, nameW, length );
1219 res = AtlAxCreateDialogW( hInst, nameW, owner, dlgProc, param );
1220 HeapFree( GetProcessHeap(), 0, nameW );
1222 return res;
1225 /***********************************************************************
1226 * AtlAxCreateDialogW [ATL.@]
1228 * See AtlAxCreateDialogA
1231 HWND WINAPI AtlAxCreateDialogW(HINSTANCE hInst, LPCWSTR name, HWND owner, DLGPROC dlgProc ,LPARAM param)
1233 HRSRC hrsrc;
1234 HGLOBAL hgl;
1235 LPCDLGTEMPLATEW ptr;
1236 LPDLGTEMPLATEW newptr;
1237 HWND res;
1239 FIXME("(%p %s %p %p %lx) - not tested\n", hInst, debugstr_w(name), owner, dlgProc, param);
1241 hrsrc = FindResourceW( hInst, name, (LPWSTR)RT_DIALOG );
1242 if ( !hrsrc )
1243 return NULL;
1244 hgl = LoadResource (hInst, hrsrc);
1245 if ( !hgl )
1246 return NULL;
1247 ptr = (LPCDLGTEMPLATEW)LockResource ( hgl );
1248 if (!ptr)
1250 FreeResource( hgl );
1251 return NULL;
1253 newptr = AX_ConvertDialogTemplate( ptr );
1254 if ( newptr )
1256 res = CreateDialogIndirectParamW( hInst, newptr, owner, dlgProc, param );
1257 HeapFree( GetProcessHeap(), 0, newptr );
1258 } else
1259 res = NULL;
1260 FreeResource ( hrsrc );
1261 return res;
1264 /***********************************************************************
1265 * AtlAxGetHost [ATL.@]
1268 HRESULT WINAPI AtlAxGetHost(HWND hWnd, IUnknown **pUnk)
1270 IOCS *This;
1272 TRACE( "(%p, %p)\n", hWnd, pUnk );
1274 *pUnk = NULL;
1276 This = (IOCS*) GetWindowLongPtrW( hWnd, GWLP_USERDATA );
1277 if ( !This )
1279 WARN("No container attached to %p\n", hWnd );
1280 return E_FAIL;
1283 return IOCS_QueryInterface( This, &IID_IUnknown, (void**) pUnk );
1286 /***********************************************************************
1287 * AtlAxGetControl [ATL.@]
1290 HRESULT WINAPI AtlAxGetControl(HWND hWnd, IUnknown **pUnk)
1292 IOCS *This;
1294 TRACE( "(%p, %p)\n", hWnd, pUnk );
1296 *pUnk = NULL;
1298 This = (IOCS*) GetWindowLongPtrW( hWnd, GWLP_USERDATA );
1299 if ( !This || !This->control )
1301 WARN("No control attached to %p\n", hWnd );
1302 return E_FAIL;
1305 return IOleObject_QueryInterface( This->control, &IID_IUnknown, (void**) pUnk );