winemac: Consolidate mouse move handling into -[WineApplicationController handleMouse...
[wine.git] / dlls / atl100 / atl_ax.c
blob319b3e896706a70a53789056b18cb635742f2a1a
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 "winerror.h"
29 #include "winuser.h"
30 #include "wine/debug.h"
31 #include "objbase.h"
32 #include "objidl.h"
33 #include "ole2.h"
34 #include "exdisp.h"
35 #include "atlbase.h"
36 #include "atliface.h"
37 #include "atlwin.h"
39 #include "wine/unicode.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(atl);
43 typedef struct IOCS {
44 IOleClientSite IOleClientSite_iface;
45 IOleContainer IOleContainer_iface;
46 IOleInPlaceSiteWindowless IOleInPlaceSiteWindowless_iface;
47 IOleInPlaceFrame IOleInPlaceFrame_iface;
48 IOleControlSite IOleControlSite_iface;
50 LONG ref;
51 HWND hWnd;
52 IOleObject *control;
53 RECT size;
54 WNDPROC OrigWndProc;
55 BOOL fActive, fInPlace, fWindowless;
56 } IOCS;
58 /**********************************************************************
59 * AtlAxWin class window procedure
61 static LRESULT CALLBACK AtlAxWin_wndproc( HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam )
63 if ( wMsg == WM_CREATE )
65 DWORD len = GetWindowTextLengthW( hWnd ) + 1;
66 WCHAR *ptr = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
67 if (!ptr)
68 return 1;
69 GetWindowTextW( hWnd, ptr, len );
70 AtlAxCreateControlEx( ptr, hWnd, NULL, NULL, NULL, NULL, NULL );
71 HeapFree( GetProcessHeap(), 0, ptr );
72 return 0;
74 return DefWindowProcW( hWnd, wMsg, wParam, lParam );
77 /***********************************************************************
78 * AtlAxWinInit [atl100.@]
79 * Initializes the control-hosting code: registering the AtlAxWin,
80 * AtlAxWin7 and AtlAxWinLic7 window classes and some messages.
82 * RETURNS
83 * TRUE or FALSE
86 BOOL WINAPI AtlAxWinInit(void)
88 WNDCLASSEXW wcex;
89 const WCHAR AtlAxWin100[] = {'A','t','l','A','x','W','i','n','1','0','0',0};
90 const WCHAR AtlAxWinLic100[] = {'A','t','l','A','x','W','i','n','L','i','c','1','0','0',0};
92 FIXME("semi-stub\n");
94 if ( FAILED( OleInitialize(NULL) ) )
95 return FALSE;
97 wcex.cbSize = sizeof(wcex);
98 wcex.style = CS_GLOBALCLASS | CS_DBLCLKS;
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 = AtlAxWin100;
110 if ( !RegisterClassExW( &wcex ) )
111 return FALSE;
113 wcex.lpszClassName = AtlAxWinLic100;
114 if ( !RegisterClassExW( &wcex ) )
115 return FALSE;
117 return TRUE;
120 /***********************************************************************
121 * Atl container component implementation
125 static ULONG IOCS_AddRef(IOCS *This)
127 ULONG ref = InterlockedIncrement(&This->ref);
129 TRACE( "(%p) : AddRef from %d\n", This, ref - 1 );
131 return ref;
134 static HRESULT IOCS_QueryInterface(IOCS *This, REFIID riid, void **ppv)
136 *ppv = NULL;
138 if ( IsEqualIID( &IID_IUnknown, riid )
139 || IsEqualIID( &IID_IOleClientSite, riid ) )
141 *ppv = &This->IOleClientSite_iface;
142 } else if ( IsEqualIID( &IID_IOleContainer, riid ) )
144 *ppv = &This->IOleContainer_iface;
145 } else if ( IsEqualIID( &IID_IOleInPlaceSite, riid ) || IsEqualIID( &IID_IOleInPlaceSiteEx, riid ) || IsEqualIID( &IID_IOleInPlaceSiteWindowless, riid ) )
147 *ppv = &This->IOleInPlaceSiteWindowless_iface;
148 } else if ( IsEqualIID( &IID_IOleInPlaceFrame, riid ) )
150 *ppv = &This->IOleInPlaceFrame_iface;
151 } else if ( IsEqualIID( &IID_IOleControlSite, riid ) )
153 *ppv = &This->IOleControlSite_iface;
156 if (*ppv)
158 IOCS_AddRef( This );
159 return S_OK;
162 WARN("unsupported interface %s\n", debugstr_guid( riid ) );
163 *ppv = NULL;
164 return E_NOINTERFACE;
167 static HRESULT IOCS_Detach( IOCS *This );
168 static ULONG IOCS_Release(IOCS *This)
170 ULONG ref = InterlockedDecrement(&This->ref);
172 TRACE( "(%p) : ReleaseRef to %d\n", This, ref );
174 if (!ref)
176 IOCS_Detach( This );
177 HeapFree( GetProcessHeap(), 0, This );
180 return ref;
183 /****** IOleClientSite *****/
184 static inline IOCS *impl_from_IOleClientSite(IOleClientSite *iface)
186 return CONTAINING_RECORD(iface, IOCS, IOleClientSite_iface);
189 static HRESULT WINAPI OleClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
191 IOCS *This = impl_from_IOleClientSite(iface);
192 return IOCS_QueryInterface(This, riid, ppv);
195 static ULONG WINAPI OleClientSite_AddRef(IOleClientSite *iface)
197 IOCS *This = impl_from_IOleClientSite(iface);
198 return IOCS_AddRef(This);
201 static ULONG WINAPI OleClientSite_Release(IOleClientSite *iface)
203 IOCS *This = impl_from_IOleClientSite(iface);
204 return IOCS_Release(This);
207 static HRESULT WINAPI OleClientSite_SaveObject(IOleClientSite *iface)
209 IOCS *This = impl_from_IOleClientSite(iface);
210 FIXME( "(%p) - stub\n", This );
211 return E_NOTIMPL;
214 static HRESULT WINAPI OleClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk)
216 IOCS *This = impl_from_IOleClientSite(iface);
218 FIXME( "(%p, 0x%x, 0x%x, %p)\n", This, dwAssign, dwWhichMoniker, ppmk );
219 return E_NOTIMPL;
222 static HRESULT WINAPI OleClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
224 IOCS *This = impl_from_IOleClientSite(iface);
225 TRACE( "(%p, %p)\n", This, ppContainer );
226 return OleClientSite_QueryInterface( iface, &IID_IOleContainer, (void**)ppContainer );
229 static HRESULT WINAPI OleClientSite_ShowObject(IOleClientSite *iface)
231 IOCS *This = impl_from_IOleClientSite(iface);
232 FIXME( "(%p) - stub\n", This );
233 return S_OK;
236 static HRESULT WINAPI OleClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
238 IOCS *This = impl_from_IOleClientSite(iface);
239 FIXME( "(%p, %s) - stub\n", This, fShow ? "TRUE" : "FALSE" );
240 return E_NOTIMPL;
243 static HRESULT WINAPI OleClientSite_RequestNewObjectLayout(IOleClientSite *iface)
245 IOCS *This = impl_from_IOleClientSite(iface);
246 FIXME( "(%p) - stub\n", This );
247 return E_NOTIMPL;
251 /****** IOleContainer *****/
252 static inline IOCS *impl_from_IOleContainer(IOleContainer *iface)
254 return CONTAINING_RECORD(iface, IOCS, IOleContainer_iface);
257 static HRESULT WINAPI OleContainer_QueryInterface( IOleContainer* iface, REFIID riid, void** ppv)
259 IOCS *This = impl_from_IOleContainer(iface);
260 return IOCS_QueryInterface( This, riid, ppv );
263 static ULONG WINAPI OleContainer_AddRef(IOleContainer* iface)
265 IOCS *This = impl_from_IOleContainer(iface);
266 return IOCS_AddRef(This);
269 static ULONG WINAPI OleContainer_Release(IOleContainer* iface)
271 IOCS *This = impl_from_IOleContainer(iface);
272 return IOCS_Release(This);
275 static HRESULT WINAPI OleContainer_ParseDisplayName(IOleContainer* iface, IBindCtx* pbc,
276 LPOLESTR pszDisplayName, ULONG* pchEaten, IMoniker** ppmkOut)
278 IOCS *This = impl_from_IOleContainer(iface);
279 FIXME( "(%p,%p,%s,%p,%p) - stub\n", This, pbc, debugstr_w(pszDisplayName), pchEaten, ppmkOut );
280 return E_NOTIMPL;
283 static HRESULT WINAPI OleContainer_EnumObjects(IOleContainer* iface, DWORD grfFlags, IEnumUnknown** ppenum)
285 IOCS *This = impl_from_IOleContainer(iface);
286 FIXME( "(%p, %u, %p) - stub\n", This, grfFlags, ppenum );
287 return E_NOTIMPL;
290 static HRESULT WINAPI OleContainer_LockContainer(IOleContainer* iface, BOOL fLock)
292 IOCS *This = impl_from_IOleContainer(iface);
293 FIXME( "(%p, %s) - stub\n", This, fLock?"TRUE":"FALSE" );
294 return E_NOTIMPL;
298 /****** IOleInPlaceSiteWindowless *******/
299 static inline IOCS *impl_from_IOleInPlaceSiteWindowless(IOleInPlaceSiteWindowless *iface)
301 return CONTAINING_RECORD(iface, IOCS, IOleInPlaceSiteWindowless_iface);
304 static HRESULT WINAPI OleInPlaceSiteWindowless_QueryInterface(IOleInPlaceSiteWindowless *iface, REFIID riid, void **ppv)
306 IOCS *This = impl_from_IOleInPlaceSiteWindowless(iface);
307 return IOCS_QueryInterface(This, riid, ppv);
310 static ULONG WINAPI OleInPlaceSiteWindowless_AddRef(IOleInPlaceSiteWindowless *iface)
312 IOCS *This = impl_from_IOleInPlaceSiteWindowless(iface);
313 return IOCS_AddRef(This);
316 static ULONG WINAPI OleInPlaceSiteWindowless_Release(IOleInPlaceSiteWindowless *iface)
318 IOCS *This = impl_from_IOleInPlaceSiteWindowless(iface);
319 return IOCS_Release(This);
322 static HRESULT WINAPI OleInPlaceSiteWindowless_GetWindow(IOleInPlaceSiteWindowless* iface, HWND* phwnd)
324 IOCS *This = impl_from_IOleInPlaceSiteWindowless(iface);
326 TRACE("(%p,%p)\n", This, phwnd);
327 *phwnd = This->hWnd;
328 return S_OK;
331 static HRESULT WINAPI OleInPlaceSiteWindowless_ContextSensitiveHelp(IOleInPlaceSiteWindowless* iface, BOOL fEnterMode)
333 IOCS *This = impl_from_IOleInPlaceSiteWindowless(iface);
334 FIXME("(%p,%d) - stub\n", This, fEnterMode);
335 return E_NOTIMPL;
338 static HRESULT WINAPI OleInPlaceSiteWindowless_CanInPlaceActivate(IOleInPlaceSiteWindowless *iface)
340 IOCS *This = impl_from_IOleInPlaceSiteWindowless(iface);
341 TRACE("(%p)\n", This);
342 return S_OK;
345 static HRESULT WINAPI OleInPlaceSiteWindowless_OnInPlaceActivate(IOleInPlaceSiteWindowless *iface)
347 IOCS *This = impl_from_IOleInPlaceSiteWindowless(iface);
349 TRACE("(%p)\n", This);
351 This->fInPlace = TRUE;
352 return S_OK;
355 static HRESULT WINAPI OleInPlaceSiteWindowless_OnUIActivate(IOleInPlaceSiteWindowless *iface)
357 IOCS *This = impl_from_IOleInPlaceSiteWindowless(iface);
359 TRACE("(%p)\n", This);
361 return S_OK;
363 static HRESULT WINAPI OleInPlaceSiteWindowless_GetWindowContext(IOleInPlaceSiteWindowless *iface,
364 IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
365 LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
367 IOCS *This = impl_from_IOleInPlaceSiteWindowless(iface);
369 TRACE("(%p,%p,%p,%p,%p,%p)\n", This, ppFrame, ppDoc, lprcPosRect, lprcClipRect, lpFrameInfo);
371 if ( lprcClipRect )
372 *lprcClipRect = This->size;
373 if ( lprcPosRect )
374 *lprcPosRect = This->size;
376 if ( ppFrame )
378 IOCS_QueryInterface( This, &IID_IOleInPlaceFrame, (void**) ppFrame );
381 if ( ppDoc )
382 *ppDoc = NULL;
384 if ( lpFrameInfo )
386 lpFrameInfo->fMDIApp = FALSE;
387 lpFrameInfo->hwndFrame = This->hWnd;
388 lpFrameInfo->haccel = NULL;
389 lpFrameInfo->cAccelEntries = 0;
392 return S_OK;
395 static HRESULT WINAPI OleInPlaceSiteWindowless_Scroll(IOleInPlaceSiteWindowless *iface, SIZE scrollExtent)
397 IOCS *This = impl_from_IOleInPlaceSiteWindowless(iface);
398 FIXME("(%p) - stub\n", This);
399 return E_NOTIMPL;
402 static HRESULT WINAPI OleInPlaceSiteWindowless_OnUIDeactivate(IOleInPlaceSiteWindowless *iface, BOOL fUndoable)
404 IOCS *This = impl_from_IOleInPlaceSiteWindowless(iface);
405 FIXME("(%p,%d) - stub\n", This, fUndoable);
406 return E_NOTIMPL;
409 static HRESULT WINAPI OleInPlaceSiteWindowless_OnInPlaceDeactivate(IOleInPlaceSiteWindowless *iface)
411 IOCS *This = impl_from_IOleInPlaceSiteWindowless(iface);
413 TRACE("(%p)\n", This);
415 This->fInPlace = This->fWindowless = FALSE;
416 return S_OK;
419 static HRESULT WINAPI OleInPlaceSiteWindowless_DiscardUndoState(IOleInPlaceSiteWindowless *iface)
421 IOCS *This = impl_from_IOleInPlaceSiteWindowless(iface);
422 FIXME("(%p) - stub\n", This);
423 return E_NOTIMPL;
426 static HRESULT WINAPI OleInPlaceSiteWindowless_DeactivateAndUndo(IOleInPlaceSiteWindowless *iface)
428 IOCS *This = impl_from_IOleInPlaceSiteWindowless(iface);
429 FIXME("(%p) - stub\n", This);
430 return E_NOTIMPL;
433 static HRESULT WINAPI OleInPlaceSiteWindowless_OnPosRectChange(IOleInPlaceSiteWindowless *iface, LPCRECT lprcPosRect)
435 IOCS *This = impl_from_IOleInPlaceSiteWindowless(iface);
436 FIXME("(%p,%p) - stub\n", This, lprcPosRect);
437 return E_NOTIMPL;
440 static HRESULT WINAPI OleInPlaceSiteWindowless_OnInPlaceActivateEx( IOleInPlaceSiteWindowless *iface, BOOL* pfNoRedraw, DWORD dwFlags)
442 IOCS *This = impl_from_IOleInPlaceSiteWindowless(iface);
444 TRACE("\n");
446 This->fActive = This->fInPlace = TRUE;
447 if ( dwFlags & ACTIVATE_WINDOWLESS )
448 This->fWindowless = TRUE;
449 return S_OK;
452 static HRESULT WINAPI OleInPlaceSiteWindowless_OnInPlaceDeactivateEx( IOleInPlaceSiteWindowless *iface, BOOL fNoRedraw)
454 IOCS *This = impl_from_IOleInPlaceSiteWindowless(iface);
456 TRACE("\n");
458 This->fActive = This->fInPlace = This->fWindowless = FALSE;
459 return S_OK;
461 static HRESULT WINAPI OleInPlaceSiteWindowless_RequestUIActivate( IOleInPlaceSiteWindowless *iface)
463 FIXME("\n");
464 return E_NOTIMPL;
466 static HRESULT WINAPI OleInPlaceSiteWindowless_CanWindowlessActivate( IOleInPlaceSiteWindowless *iface)
468 FIXME("\n");
469 return S_OK;
471 static HRESULT WINAPI OleInPlaceSiteWindowless_GetCapture( IOleInPlaceSiteWindowless *iface)
473 FIXME("\n");
474 return E_NOTIMPL;
476 static HRESULT WINAPI OleInPlaceSiteWindowless_SetCapture( IOleInPlaceSiteWindowless *iface, BOOL fCapture)
478 FIXME("\n");
479 return E_NOTIMPL;
481 static HRESULT WINAPI OleInPlaceSiteWindowless_GetFocus( IOleInPlaceSiteWindowless *iface)
483 FIXME("\n");
484 return E_NOTIMPL;
486 static HRESULT WINAPI OleInPlaceSiteWindowless_SetFocus( IOleInPlaceSiteWindowless *iface, BOOL fFocus)
488 FIXME("\n");
489 return E_NOTIMPL;
491 static HRESULT WINAPI OleInPlaceSiteWindowless_GetDC( IOleInPlaceSiteWindowless *iface, LPCRECT pRect, DWORD grfFlags, HDC* phDC)
493 FIXME("\n");
494 return E_NOTIMPL;
496 static HRESULT WINAPI OleInPlaceSiteWindowless_ReleaseDC( IOleInPlaceSiteWindowless *iface, HDC hDC)
498 FIXME("\n");
499 return E_NOTIMPL;
501 static HRESULT WINAPI OleInPlaceSiteWindowless_InvalidateRect( IOleInPlaceSiteWindowless *iface, LPCRECT pRect, BOOL fErase)
503 FIXME("\n");
504 return E_NOTIMPL;
506 static HRESULT WINAPI OleInPlaceSiteWindowless_InvalidateRgn( IOleInPlaceSiteWindowless *iface, HRGN hRGN, BOOL fErase)
508 FIXME("\n");
509 return E_NOTIMPL;
511 static HRESULT WINAPI OleInPlaceSiteWindowless_ScrollRect( IOleInPlaceSiteWindowless *iface, INT dx, INT dy, LPCRECT pRectScroll, LPCRECT pRectClip)
513 FIXME("\n");
514 return E_NOTIMPL;
516 static HRESULT WINAPI OleInPlaceSiteWindowless_AdjustRect( IOleInPlaceSiteWindowless *iface, LPRECT prc)
518 FIXME("\n");
519 return E_NOTIMPL;
521 static HRESULT WINAPI OleInPlaceSiteWindowless_OnDefWindowMessage( IOleInPlaceSiteWindowless *iface, UINT msg, WPARAM wParam, LPARAM lParam, LRESULT* plResult)
523 FIXME("\n");
524 return E_NOTIMPL;
528 /****** IOleInPlaceFrame *******/
529 static inline IOCS *impl_from_IOleInPlaceFrame(IOleInPlaceFrame *iface)
531 return CONTAINING_RECORD(iface, IOCS, IOleInPlaceFrame_iface);
534 static HRESULT WINAPI OleInPlaceFrame_QueryInterface(IOleInPlaceFrame *iface, REFIID riid, void **ppv)
536 IOCS *This = impl_from_IOleInPlaceFrame(iface);
537 return IOCS_QueryInterface(This, riid, ppv);
540 static ULONG WINAPI OleInPlaceFrame_AddRef(IOleInPlaceFrame *iface)
542 IOCS *This = impl_from_IOleInPlaceFrame(iface);
543 return IOCS_AddRef(This);
546 static ULONG WINAPI OleInPlaceFrame_Release(IOleInPlaceFrame *iface)
548 IOCS *This = impl_from_IOleInPlaceFrame(iface);
549 return IOCS_Release(This);
552 static HRESULT WINAPI OleInPlaceFrame_GetWindow(IOleInPlaceFrame *iface, HWND *phWnd)
554 IOCS *This = impl_from_IOleInPlaceFrame(iface);
556 TRACE( "(%p,%p)\n", This, phWnd );
558 *phWnd = This->hWnd;
559 return S_OK;
562 static HRESULT WINAPI OleInPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame *iface, BOOL fEnterMode)
564 IOCS *This = impl_from_IOleInPlaceFrame(iface);
566 FIXME( "(%p,%d) - stub\n", This, fEnterMode );
567 return E_NOTIMPL;
570 static HRESULT WINAPI OleInPlaceFrame_GetBorder(IOleInPlaceFrame *iface, LPRECT lprectBorder)
572 IOCS *This = impl_from_IOleInPlaceFrame(iface);
574 FIXME( "(%p,%p) - stub\n", This, lprectBorder );
575 return E_NOTIMPL;
578 static HRESULT WINAPI OleInPlaceFrame_RequestBorderSpace(IOleInPlaceFrame *iface, LPCBORDERWIDTHS pborderwidths)
580 IOCS *This = impl_from_IOleInPlaceFrame(iface);
582 FIXME( "(%p,%p) - stub\n", This, pborderwidths );
583 return E_NOTIMPL;
586 static HRESULT WINAPI OleInPlaceFrame_SetBorderSpace(IOleInPlaceFrame *iface, LPCBORDERWIDTHS pborderwidths)
588 IOCS *This = impl_from_IOleInPlaceFrame(iface);
590 FIXME( "(%p,%p) - stub\n", This, pborderwidths );
591 return E_NOTIMPL;
594 static HRESULT WINAPI OleInPlaceFrame_SetActiveObject(IOleInPlaceFrame *iface, IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
596 IOCS *This = impl_from_IOleInPlaceFrame(iface);
598 FIXME( "(%p,%p,%s) - stub\n", This, pActiveObject, debugstr_w(pszObjName) );
599 return S_OK;
602 static HRESULT WINAPI OleInPlaceFrame_InsertMenus(IOleInPlaceFrame *iface, HMENU hmenuShared, LPOLEMENUGROUPWIDTHS lpMenuWidths)
604 IOCS *This = impl_from_IOleInPlaceFrame(iface);
606 FIXME( "(%p,%p,%p) - stub\n", This, hmenuShared, lpMenuWidths );
607 return E_NOTIMPL;
610 static HRESULT WINAPI OleInPlaceFrame_SetMenu(IOleInPlaceFrame *iface, HMENU hmenuShared, HOLEMENU holemenu, HWND hwndActiveObject)
612 IOCS *This = impl_from_IOleInPlaceFrame(iface);
614 FIXME( "(%p,%p,%p,%p) - stub\n", This, hmenuShared, holemenu, hwndActiveObject );
615 return E_NOTIMPL;
618 static HRESULT WINAPI OleInPlaceFrame_RemoveMenus(IOleInPlaceFrame *iface, HMENU hmenuShared)
620 IOCS *This = impl_from_IOleInPlaceFrame(iface);
622 FIXME( "(%p, %p) - stub\n", This, hmenuShared );
623 return E_NOTIMPL;
626 static HRESULT WINAPI OleInPlaceFrame_SetStatusText(IOleInPlaceFrame *iface, LPCOLESTR pszStatusText)
628 IOCS *This = impl_from_IOleInPlaceFrame(iface);
630 FIXME( "(%p, %s) - stub\n", This, debugstr_w( pszStatusText ) );
631 return E_NOTIMPL;
634 static HRESULT WINAPI OleInPlaceFrame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
636 IOCS *This = impl_from_IOleInPlaceFrame(iface);
638 FIXME( "(%p, %d) - stub\n", This, fEnable );
639 return E_NOTIMPL;
642 static HRESULT WINAPI OleInPlaceFrame_TranslateAccelerator(IOleInPlaceFrame *iface, LPMSG lpmsg, WORD wID)
644 IOCS *This = impl_from_IOleInPlaceFrame(iface);
646 FIXME( "(%p, %p, %x) - stub\n", This, lpmsg, wID );
647 return E_NOTIMPL;
651 /****** IOleControlSite *******/
652 static inline IOCS *impl_from_IOleControlSite(IOleControlSite *iface)
654 return CONTAINING_RECORD(iface, IOCS, IOleControlSite_iface);
657 static HRESULT WINAPI OleControlSite_QueryInterface(IOleControlSite *iface, REFIID riid, void **ppv)
659 IOCS *This = impl_from_IOleControlSite(iface);
660 return IOCS_QueryInterface(This, riid, ppv);
663 static ULONG WINAPI OleControlSite_AddRef(IOleControlSite *iface)
665 IOCS *This = impl_from_IOleControlSite(iface);
666 return IOCS_AddRef(This);
669 static ULONG WINAPI OleControlSite_Release(IOleControlSite *iface)
671 IOCS *This = impl_from_IOleControlSite(iface);
672 return IOCS_Release(This);
675 static HRESULT WINAPI OleControlSite_OnControlInfoChanged( IOleControlSite* This)
677 FIXME( "\n" );
678 return E_NOTIMPL;
680 static HRESULT WINAPI OleControlSite_LockInPlaceActive( IOleControlSite* This, BOOL fLock)
682 FIXME( "\n" );
683 return E_NOTIMPL;
685 static HRESULT WINAPI OleControlSite_GetExtendedControl( IOleControlSite* This, IDispatch** ppDisp)
687 FIXME( "\n" );
688 return E_NOTIMPL;
690 static HRESULT WINAPI OleControlSite_TransformCoords( IOleControlSite* This, POINTL* pPtlHimetric, POINTF* pPtfContainer, DWORD dwFlags)
692 FIXME( "\n" );
693 return E_NOTIMPL;
695 static HRESULT WINAPI OleControlSite_TranslateAccelerator( IOleControlSite* This, MSG* pMsg, DWORD grfModifiers)
697 FIXME( "\n" );
698 return E_NOTIMPL;
700 static HRESULT WINAPI OleControlSite_OnFocus( IOleControlSite* This, BOOL fGotFocus)
702 FIXME( "\n" );
703 return E_NOTIMPL;
705 static HRESULT WINAPI OleControlSite_ShowPropertyFrame( IOleControlSite* This)
707 FIXME( "\n" );
708 return E_NOTIMPL;
712 static const IOleClientSiteVtbl OleClientSite_vtbl = {
713 OleClientSite_QueryInterface,
714 OleClientSite_AddRef,
715 OleClientSite_Release,
716 OleClientSite_SaveObject,
717 OleClientSite_GetMoniker,
718 OleClientSite_GetContainer,
719 OleClientSite_ShowObject,
720 OleClientSite_OnShowWindow,
721 OleClientSite_RequestNewObjectLayout
723 static const IOleContainerVtbl OleContainer_vtbl = {
724 OleContainer_QueryInterface,
725 OleContainer_AddRef,
726 OleContainer_Release,
727 OleContainer_ParseDisplayName,
728 OleContainer_EnumObjects,
729 OleContainer_LockContainer
731 static const IOleInPlaceSiteWindowlessVtbl OleInPlaceSiteWindowless_vtbl = {
732 OleInPlaceSiteWindowless_QueryInterface,
733 OleInPlaceSiteWindowless_AddRef,
734 OleInPlaceSiteWindowless_Release,
735 OleInPlaceSiteWindowless_GetWindow,
736 OleInPlaceSiteWindowless_ContextSensitiveHelp,
737 OleInPlaceSiteWindowless_CanInPlaceActivate,
738 OleInPlaceSiteWindowless_OnInPlaceActivate,
739 OleInPlaceSiteWindowless_OnUIActivate,
740 OleInPlaceSiteWindowless_GetWindowContext,
741 OleInPlaceSiteWindowless_Scroll,
742 OleInPlaceSiteWindowless_OnUIDeactivate,
743 OleInPlaceSiteWindowless_OnInPlaceDeactivate,
744 OleInPlaceSiteWindowless_DiscardUndoState,
745 OleInPlaceSiteWindowless_DeactivateAndUndo,
746 OleInPlaceSiteWindowless_OnPosRectChange,
747 OleInPlaceSiteWindowless_OnInPlaceActivateEx,
748 OleInPlaceSiteWindowless_OnInPlaceDeactivateEx,
749 OleInPlaceSiteWindowless_RequestUIActivate,
750 OleInPlaceSiteWindowless_CanWindowlessActivate,
751 OleInPlaceSiteWindowless_GetCapture,
752 OleInPlaceSiteWindowless_SetCapture,
753 OleInPlaceSiteWindowless_GetFocus,
754 OleInPlaceSiteWindowless_SetFocus,
755 OleInPlaceSiteWindowless_GetDC,
756 OleInPlaceSiteWindowless_ReleaseDC,
757 OleInPlaceSiteWindowless_InvalidateRect,
758 OleInPlaceSiteWindowless_InvalidateRgn,
759 OleInPlaceSiteWindowless_ScrollRect,
760 OleInPlaceSiteWindowless_AdjustRect,
761 OleInPlaceSiteWindowless_OnDefWindowMessage
763 static const IOleInPlaceFrameVtbl OleInPlaceFrame_vtbl =
765 OleInPlaceFrame_QueryInterface,
766 OleInPlaceFrame_AddRef,
767 OleInPlaceFrame_Release,
768 OleInPlaceFrame_GetWindow,
769 OleInPlaceFrame_ContextSensitiveHelp,
770 OleInPlaceFrame_GetBorder,
771 OleInPlaceFrame_RequestBorderSpace,
772 OleInPlaceFrame_SetBorderSpace,
773 OleInPlaceFrame_SetActiveObject,
774 OleInPlaceFrame_InsertMenus,
775 OleInPlaceFrame_SetMenu,
776 OleInPlaceFrame_RemoveMenus,
777 OleInPlaceFrame_SetStatusText,
778 OleInPlaceFrame_EnableModeless,
779 OleInPlaceFrame_TranslateAccelerator
781 static const IOleControlSiteVtbl OleControlSite_vtbl =
783 OleControlSite_QueryInterface,
784 OleControlSite_AddRef,
785 OleControlSite_Release,
786 OleControlSite_OnControlInfoChanged,
787 OleControlSite_LockInPlaceActive,
788 OleControlSite_GetExtendedControl,
789 OleControlSite_TransformCoords,
790 OleControlSite_TranslateAccelerator,
791 OleControlSite_OnFocus,
792 OleControlSite_ShowPropertyFrame
795 static HRESULT IOCS_Detach( IOCS *This ) /* remove subclassing */
797 if ( This->hWnd )
799 SetWindowLongPtrW( This->hWnd, GWLP_WNDPROC, (ULONG_PTR) This->OrigWndProc );
800 SetWindowLongPtrW( This->hWnd, GWLP_USERDATA, 0 );
801 This->hWnd = NULL;
803 if ( This->control )
805 IOleObject *control = This->control;
807 This->control = NULL;
808 IOleObject_Close( control, OLECLOSE_NOSAVE );
809 IOleObject_SetClientSite( control, NULL );
810 IOleObject_Release( control );
812 return S_OK;
815 static void IOCS_OnSize( IOCS* This, LPCRECT rect )
817 SIZEL inPix, inHi;
819 This->size.left = rect->left; This->size.right = rect->right; This->size.top = rect->top; This->size.bottom = rect->bottom;
821 if ( !This->control )
822 return;
824 inPix.cx = rect->right - rect->left;
825 inPix.cy = rect->bottom - rect->top;
826 AtlPixelToHiMetric( &inPix, &inHi );
827 IOleObject_SetExtent( This->control, DVASPECT_CONTENT, &inHi );
829 if ( This->fInPlace )
831 IOleInPlaceObject *wl;
833 if ( SUCCEEDED( IOleObject_QueryInterface( This->control, &IID_IOleInPlaceObject, (void**)&wl ) ) )
835 IOleInPlaceObject_SetObjectRects( wl, rect, rect );
836 IOleInPlaceObject_Release( wl );
841 static void IOCS_OnShow( IOCS *This, BOOL fShow )
843 if (!This->control || This->fActive || !fShow )
844 return;
846 This->fActive = TRUE;
849 static void IOCS_OnDraw( IOCS *This )
851 IViewObject *view;
853 if ( !This->control || !This->fWindowless )
854 return;
856 if ( SUCCEEDED( IOleObject_QueryInterface( This->control, &IID_IViewObject, (void**)&view ) ) )
858 HDC dc = GetDC( This->hWnd );
859 RECTL rect;
861 rect.left = This->size.left; rect.top = This->size.top;
862 rect.bottom = This->size.bottom; rect.right = This->size.right;
864 IViewObject_Draw( view, DVASPECT_CONTENT, ~0, NULL, NULL, 0, dc, &rect, &rect, NULL, 0 );
865 IViewObject_Release( view );
866 ReleaseDC( This->hWnd, dc );
870 static LRESULT IOCS_OnWndProc( IOCS *This, HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
872 WNDPROC OrigWndProc = This->OrigWndProc;
874 switch( uMsg )
876 case WM_DESTROY:
877 IOCS_Detach( This );
878 break;
879 case WM_SIZE:
881 RECT r;
882 r.left = r.top = 0;
883 r.right = LOWORD( lParam );
884 r.bottom = HIWORD( lParam );
885 IOCS_OnSize( This, &r );
887 break;
888 case WM_SHOWWINDOW:
889 IOCS_OnShow( This, (BOOL) wParam );
890 break;
891 case WM_PAINT:
892 IOCS_OnDraw( This );
893 break;
896 return CallWindowProcW( OrigWndProc, hWnd, uMsg, wParam, lParam );
899 static LRESULT CALLBACK AtlHost_wndproc( HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam )
901 IOCS *This = (IOCS*) GetWindowLongPtrW( hWnd, GWLP_USERDATA );
902 return IOCS_OnWndProc( This, hWnd, wMsg, wParam, lParam );
905 static HRESULT IOCS_Attach( IOCS *This, HWND hWnd, IUnknown *pUnkControl ) /* subclass hWnd */
907 This->hWnd = hWnd;
908 IUnknown_QueryInterface( pUnkControl, &IID_IOleObject, (void**)&This->control );
909 IOleObject_SetClientSite( This->control, &This->IOleClientSite_iface );
910 SetWindowLongPtrW( hWnd, GWLP_USERDATA, (ULONG_PTR) This );
911 This->OrigWndProc = (WNDPROC)SetWindowLongPtrW( hWnd, GWLP_WNDPROC, (ULONG_PTR) AtlHost_wndproc );
913 return S_OK;
916 static HRESULT IOCS_Init( IOCS *This )
918 RECT rect;
919 static const WCHAR AXWIN[] = {'A','X','W','I','N',0};
921 IOleObject_SetHostNames( This->control, AXWIN, AXWIN );
923 GetClientRect( This->hWnd, &rect );
924 IOCS_OnSize( This, &rect );
925 IOleObject_DoVerb( This->control, OLEIVERB_INPLACEACTIVATE, NULL, &This->IOleClientSite_iface,
926 0, This->hWnd, &rect );
928 return S_OK;
931 /**********************************************************************
932 * Create new instance of Atl host component and attach it to window *
934 static HRESULT IOCS_Create( HWND hWnd, IUnknown *pUnkControl, IOCS **ppSite )
936 HRESULT hr;
937 IOCS *This;
939 *ppSite = NULL;
940 This = HeapAlloc(GetProcessHeap(), 0, sizeof(IOCS));
942 if (!This)
943 return E_OUTOFMEMORY;
945 This->IOleClientSite_iface.lpVtbl = &OleClientSite_vtbl;
946 This->IOleContainer_iface.lpVtbl = &OleContainer_vtbl;
947 This->IOleInPlaceSiteWindowless_iface.lpVtbl = &OleInPlaceSiteWindowless_vtbl;
948 This->IOleInPlaceFrame_iface.lpVtbl = &OleInPlaceFrame_vtbl;
949 This->IOleControlSite_iface.lpVtbl = &OleControlSite_vtbl;
950 This->ref = 1;
952 This->OrigWndProc = NULL;
953 This->hWnd = NULL;
954 This->fWindowless = This->fActive = This->fInPlace = FALSE;
956 hr = IOCS_Attach( This, hWnd, pUnkControl );
957 if ( SUCCEEDED( hr ) )
958 hr = IOCS_Init( This );
959 if ( SUCCEEDED( hr ) )
960 *ppSite = This;
961 else
962 IOCS_Release( This );
964 return hr;
968 /***********************************************************************
969 * AtlAxCreateControl [atl100.@]
971 HRESULT WINAPI AtlAxCreateControl(LPCOLESTR lpszName, HWND hWnd,
972 IStream *pStream, IUnknown **ppUnkContainer)
974 return AtlAxCreateControlEx( lpszName, hWnd, pStream, ppUnkContainer,
975 NULL, NULL, NULL );
978 /***********************************************************************
979 * AtlAxCreateControlEx [atl100.@]
981 * REMARKS
982 * See http://www.codeproject.com/com/cwebpage.asp for some background
985 HRESULT WINAPI AtlAxCreateControlEx(LPCOLESTR lpszName, HWND hWnd,
986 IStream *pStream, IUnknown **ppUnkContainer, IUnknown **ppUnkControl,
987 REFIID iidSink, IUnknown *punkSink)
989 CLSID controlId;
990 HRESULT hRes;
991 IOleObject *pControl;
992 IUnknown *pUnkControl;
993 IPersistStreamInit *pPSInit;
994 IUnknown *pContainer;
995 enum {IsGUID=0,IsHTML=1,IsURL=2} content;
997 TRACE("(%s %p %p %p %p %p %p)\n", debugstr_w(lpszName), hWnd, pStream,
998 ppUnkContainer, ppUnkControl, iidSink, punkSink);
1000 hRes = CLSIDFromString( lpszName, &controlId );
1001 if ( FAILED(hRes) )
1002 hRes = CLSIDFromProgID( lpszName, &controlId );
1003 if ( SUCCEEDED( hRes ) )
1004 content = IsGUID;
1005 else {
1006 /* FIXME - check for MSHTML: prefix! */
1007 content = IsURL;
1008 controlId = CLSID_WebBrowser;
1011 hRes = CoCreateInstance( &controlId, 0, CLSCTX_ALL, &IID_IOleObject,
1012 (void**) &pControl );
1013 if ( FAILED( hRes ) )
1015 WARN( "cannot create ActiveX control %s instance - error 0x%08x\n",
1016 debugstr_guid( &controlId ), hRes );
1017 return hRes;
1020 hRes = IOleObject_QueryInterface( pControl, &IID_IPersistStreamInit, (void**) &pPSInit );
1021 if ( SUCCEEDED( hRes ) )
1023 if (!pStream)
1024 IPersistStreamInit_InitNew( pPSInit );
1025 else
1026 IPersistStreamInit_Load( pPSInit, pStream );
1027 IPersistStreamInit_Release( pPSInit );
1028 } else
1029 WARN("cannot get IID_IPersistStreamInit out of control\n");
1031 IOleObject_QueryInterface( pControl, &IID_IUnknown, (void**) &pUnkControl );
1032 IOleObject_Release( pControl );
1035 hRes = AtlAxAttachControl( pUnkControl, hWnd, &pContainer );
1036 if ( FAILED( hRes ) )
1037 WARN("cannot attach control to window\n");
1039 if ( content == IsURL )
1041 IWebBrowser2 *browser;
1043 hRes = IOleObject_QueryInterface( pControl, &IID_IWebBrowser2, (void**) &browser );
1044 if ( !browser )
1045 WARN( "Cannot query IWebBrowser2 interface: %08x\n", hRes );
1046 else {
1047 VARIANT url;
1049 IWebBrowser2_put_Visible( browser, VARIANT_TRUE ); /* it seems that native does this on URL (but do not on MSHTML:! why? */
1051 V_VT(&url) = VT_BSTR;
1052 V_BSTR(&url) = SysAllocString( lpszName );
1054 hRes = IWebBrowser2_Navigate2( browser, &url, NULL, NULL, NULL, NULL );
1055 if ( FAILED( hRes ) )
1056 WARN( "IWebBrowser2::Navigate2 failed: %08x\n", hRes );
1057 SysFreeString( V_BSTR(&url) );
1059 IWebBrowser2_Release( browser );
1063 if (ppUnkContainer)
1065 *ppUnkContainer = pContainer;
1066 if ( pContainer )
1067 IUnknown_AddRef( pContainer );
1069 if (ppUnkControl)
1071 *ppUnkControl = pUnkControl;
1072 if ( pUnkControl )
1073 IUnknown_AddRef( pUnkControl );
1076 if ( pUnkControl )
1077 IUnknown_Release( pUnkControl );
1078 if ( pContainer )
1079 IUnknown_Release( pContainer );
1081 return S_OK;
1084 /***********************************************************************
1085 * AtlAxAttachControl [atl100.@]
1087 HRESULT WINAPI AtlAxAttachControl(IUnknown* pControl, HWND hWnd, IUnknown** ppUnkContainer)
1089 IOCS *pUnkContainer;
1090 HRESULT hr;
1092 TRACE( "%p %p %p\n", pControl, hWnd, ppUnkContainer );
1094 if (!pControl)
1095 return E_INVALIDARG;
1097 hr = IOCS_Create( hWnd, pControl, &pUnkContainer );
1098 if ( SUCCEEDED( hr ) && ppUnkContainer)
1100 *ppUnkContainer = (IUnknown*) pUnkContainer;
1103 if(!hWnd)
1104 return S_FALSE;
1106 return hr;
1109 /**********************************************************************
1110 * Helper function for AX_ConvertDialogTemplate
1112 static inline BOOL advance_array(WORD **pptr, DWORD *palloc, DWORD *pfilled, const WORD *data, DWORD size)
1114 if ( (*pfilled + size) > *palloc )
1116 *palloc = ((*pfilled+size) + 0xFF) & ~0xFF;
1117 *pptr = HeapReAlloc( GetProcessHeap(), 0, *pptr, *palloc * sizeof(WORD) );
1118 if (!*pptr)
1119 return FALSE;
1121 RtlMoveMemory( *pptr+*pfilled, data, size * sizeof(WORD) );
1122 *pfilled += size;
1123 return TRUE;
1126 /**********************************************************************
1127 * Convert ActiveX control templates to AtlAxWin class instances
1129 static LPDLGTEMPLATEW AX_ConvertDialogTemplate(LPCDLGTEMPLATEW src_tmpl)
1131 #define GET_WORD(x) (*(const WORD *)(x))
1132 #define GET_DWORD(x) (*(const DWORD *)(x))
1133 #define PUT_BLOCK(x,y) do {if (!advance_array(&output, &allocated, &filled, (x), (y))) return NULL;} while (0)
1134 #define PUT_WORD(x) do {WORD w = (x);PUT_BLOCK(&w, 1);} while(0)
1135 #define PUT_DWORD(x) do {DWORD w = (x);PUT_BLOCK(&w, 2);} while(0)
1136 const WORD *tmp, *src = (const WORD *)src_tmpl;
1137 WORD *output;
1138 DWORD allocated, filled; /* in WORDs */
1139 BOOL ext;
1140 WORD signature, dlgver, rescount;
1141 DWORD style;
1143 filled = 0; allocated = 256;
1144 output = HeapAlloc( GetProcessHeap(), 0, allocated * sizeof(WORD) );
1145 if (!output)
1146 return NULL;
1148 /* header */
1149 tmp = src;
1150 signature = GET_WORD(src);
1151 dlgver = GET_WORD(src + 1);
1152 if (signature == 1 && dlgver == 0xFFFF)
1154 ext = TRUE;
1155 src += 6;
1156 style = GET_DWORD(src);
1157 src += 2;
1158 rescount = GET_WORD(src++);
1159 src += 4;
1160 if ( GET_WORD(src) == 0xFFFF ) /* menu */
1161 src += 2;
1162 else
1163 src += strlenW(src) + 1;
1164 if ( GET_WORD(src) == 0xFFFF ) /* class */
1165 src += 2;
1166 else
1167 src += strlenW(src) + 1;
1168 src += strlenW(src) + 1; /* title */
1169 if ( style & (DS_SETFONT | DS_SHELLFONT) )
1171 src += 3;
1172 src += strlenW(src) + 1;
1174 } else {
1175 ext = FALSE;
1176 style = GET_DWORD(src);
1177 src += 4;
1178 rescount = GET_WORD(src++);
1179 src += 4;
1180 if ( GET_WORD(src) == 0xFFFF ) /* menu */
1181 src += 2;
1182 else
1183 src += strlenW(src) + 1;
1184 if ( GET_WORD(src) == 0xFFFF ) /* class */
1185 src += 2;
1186 else
1187 src += strlenW(src) + 1;
1188 src += strlenW(src) + 1; /* title */
1189 if ( style & DS_SETFONT )
1191 src++;
1192 src += strlenW(src) + 1;
1195 PUT_BLOCK(tmp, src-tmp);
1197 while(rescount--)
1199 src = (const WORD *)( ( ((ULONG_PTR)src) + 3) & ~3); /* align on DWORD boundary */
1200 filled = (filled + 1) & ~1; /* depends on DWORD-aligned allocation unit */
1202 tmp = src;
1203 if (ext)
1204 src += 12;
1205 else
1206 src += 9;
1207 PUT_BLOCK(tmp, src-tmp);
1209 tmp = src;
1210 if ( GET_WORD(src) == 0xFFFF ) /* class */
1212 src += 2;
1213 } else
1215 src += strlenW(src) + 1;
1217 src += strlenW(src) + 1; /* title */
1218 if ( GET_WORD(tmp) == '{' ) /* all this mess created because of this line */
1220 static const WCHAR AtlAxWin[] = {'A','t','l','A','x','W','i','n', 0};
1221 PUT_BLOCK(AtlAxWin, sizeof(AtlAxWin)/sizeof(WCHAR));
1222 PUT_BLOCK(tmp, strlenW(tmp)+1);
1223 } else
1224 PUT_BLOCK(tmp, src-tmp);
1226 if ( GET_WORD(src) )
1228 WORD size = (GET_WORD(src)+sizeof(WORD)-1) / sizeof(WORD); /* quite ugly :( Maybe use BYTE* instead of WORD* everywhere ? */
1229 PUT_BLOCK(src, size);
1230 src+=size;
1232 else
1234 PUT_WORD(0);
1235 src++;
1238 return (LPDLGTEMPLATEW) output;
1241 /***********************************************************************
1242 * AtlAxCreateDialogA [atl100.@]
1244 * Creates a dialog window
1246 * PARAMS
1247 * hInst [I] Application instance
1248 * name [I] Dialog box template name
1249 * owner [I] Dialog box parent HWND
1250 * dlgProc [I] Dialog box procedure
1251 * param [I] This value will be passed to dlgProc as WM_INITDIALOG's message lParam
1253 * RETURNS
1254 * Window handle of dialog window.
1256 HWND WINAPI AtlAxCreateDialogA(HINSTANCE hInst, LPCSTR name, HWND owner, DLGPROC dlgProc ,LPARAM param)
1258 HWND res = NULL;
1259 int length;
1260 WCHAR *nameW;
1262 if (IS_INTRESOURCE(name))
1263 return AtlAxCreateDialogW( hInst, (LPCWSTR) name, owner, dlgProc, param );
1265 length = MultiByteToWideChar( CP_ACP, 0, name, -1, NULL, 0 );
1266 nameW = HeapAlloc( GetProcessHeap(), 0, length * sizeof(WCHAR) );
1267 if (nameW)
1269 MultiByteToWideChar( CP_ACP, 0, name, -1, nameW, length );
1270 res = AtlAxCreateDialogW( hInst, nameW, owner, dlgProc, param );
1271 HeapFree( GetProcessHeap(), 0, nameW );
1273 return res;
1276 /***********************************************************************
1277 * AtlAxCreateDialogW [atl100.@]
1279 * See AtlAxCreateDialogA
1282 HWND WINAPI AtlAxCreateDialogW(HINSTANCE hInst, LPCWSTR name, HWND owner, DLGPROC dlgProc ,LPARAM param)
1284 HRSRC hrsrc;
1285 HGLOBAL hgl;
1286 LPCDLGTEMPLATEW ptr;
1287 LPDLGTEMPLATEW newptr;
1288 HWND res;
1290 TRACE("(%p %s %p %p %lx)\n", hInst, debugstr_w(name), owner, dlgProc, param);
1292 hrsrc = FindResourceW( hInst, name, (LPWSTR)RT_DIALOG );
1293 if ( !hrsrc )
1294 return NULL;
1295 hgl = LoadResource (hInst, hrsrc);
1296 if ( !hgl )
1297 return NULL;
1298 ptr = LockResource ( hgl );
1299 if (!ptr)
1301 FreeResource( hgl );
1302 return NULL;
1304 newptr = AX_ConvertDialogTemplate( ptr );
1305 if ( newptr )
1307 res = CreateDialogIndirectParamW( hInst, newptr, owner, dlgProc, param );
1308 HeapFree( GetProcessHeap(), 0, newptr );
1309 } else
1310 res = NULL;
1311 FreeResource ( hrsrc );
1312 return res;
1315 /***********************************************************************
1316 * AtlAxGetHost [atl100.@]
1319 HRESULT WINAPI AtlAxGetHost(HWND hWnd, IUnknown **pUnk)
1321 IOCS *This;
1323 TRACE( "(%p, %p)\n", hWnd, pUnk );
1325 *pUnk = NULL;
1327 This = (IOCS*) GetWindowLongPtrW( hWnd, GWLP_USERDATA );
1328 if ( !This )
1330 WARN("No container attached to %p\n", hWnd );
1331 return E_FAIL;
1334 return IOCS_QueryInterface( This, &IID_IUnknown, (void**) pUnk );
1337 /***********************************************************************
1338 * AtlAxGetControl [atl100.@]
1341 HRESULT WINAPI AtlAxGetControl(HWND hWnd, IUnknown **pUnk)
1343 IOCS *This;
1345 TRACE( "(%p, %p)\n", hWnd, pUnk );
1347 *pUnk = NULL;
1349 This = (IOCS*) GetWindowLongPtrW( hWnd, GWLP_USERDATA );
1350 if ( !This || !This->control )
1352 WARN("No control attached to %p\n", hWnd );
1353 return E_FAIL;
1356 return IOleObject_QueryInterface( This->control, &IID_IUnknown, (void**) pUnk );
1359 /***********************************************************************
1360 * AtlAxDialogBoxW [atl100.35]
1363 INT_PTR WINAPI AtlAxDialogBoxW(HINSTANCE hInstance, LPCWSTR lpTemplateName, HWND hWndParent, DLGPROC lpDialogProc,
1364 LPARAM dwInitParam)
1366 FIXME("(%p %s %p %p %lx)\n", hInstance, debugstr_w(lpTemplateName), hWndParent, lpDialogProc, dwInitParam);
1367 return 0;
1370 /***********************************************************************
1371 * AtlAxDialogBoxA [atl100.36]
1374 INT_PTR WINAPI AtlAxDialogBoxA(HINSTANCE hInstance, LPCSTR lpTemplateName, HWND hWndParent, DLGPROC lpDialogProc,
1375 LPARAM dwInitParam)
1377 FIXME("(%p %s %p %p %lx)\n", hInstance, debugstr_a(lpTemplateName), hWndParent, lpDialogProc, dwInitParam);
1378 return 0;