Changed some treeview related definitions.
[wine] / dlls / shell32 / folders.c
1 /*
2  *      Copyright 1997  Marcus Meissner
3  *      Copyright 1998  Juergen Schmied
4  *
5  */
6
7 #include <stdlib.h>
8 #include <string.h>
9 #include "debug.h"
10 #include "objbase.h"
11 #include "winerror.h"
12
13 #include "pidl.h"
14 #include "shell32_main.h"
15 #include "shlguid.h"
16 #include "shlobj.h"
17
18
19 /******************************************************************************
20 * foreward declaration
21 */
22
23 /* IExtractIcon implementation*/
24 static HRESULT WINAPI IExtractIcon_QueryInterface(LPEXTRACTICON, REFIID, LPVOID *);
25 static ULONG WINAPI IExtractIcon_AddRef(LPEXTRACTICON);
26 static ULONG WINAPI IExtractIcon_AddRef(LPEXTRACTICON);
27 static ULONG WINAPI IExtractIcon_Release(LPEXTRACTICON);
28 static HRESULT WINAPI IExtractIcon_GetIconLocation(LPEXTRACTICON, UINT32, LPSTR, UINT32, int *, UINT32 *);
29 static HRESULT WINAPI IExtractIcon_Extract(LPEXTRACTICON, LPCSTR, UINT32, HICON32 *, HICON32 *, UINT32);
30
31
32 /***********************************************************************
33 *   IExtractIcon implementation
34 */
35 static struct IExtractIcon_VTable eivt = 
36 { IExtractIcon_QueryInterface,
37   IExtractIcon_AddRef,
38   IExtractIcon_Release,
39   IExtractIcon_GetIconLocation,
40   IExtractIcon_Extract
41 };
42 /**************************************************************************
43 *  IExtractIcon_Constructor
44 */
45 LPEXTRACTICON IExtractIcon_Constructor(LPCITEMIDLIST pidl)
46 { LPEXTRACTICON ei;
47
48   ei=(LPEXTRACTICON)HeapAlloc(GetProcessHeap(),0,sizeof(IExtractIcon));
49   ei->ref=1;
50   ei->lpvtbl=&eivt;
51   ei->pidl=ILClone(pidl);
52
53   pdump(pidl);
54
55         TRACE(shell,"(%p)\n",ei);
56         shell32_ObjCount++;
57         return ei;
58 }
59 /**************************************************************************
60  *  IExtractIcon_QueryInterface
61  */
62 static HRESULT WINAPI IExtractIcon_QueryInterface( LPEXTRACTICON this, REFIID riid, LPVOID *ppvObj)
63 {  char xriid[50];
64    WINE_StringFromCLSID((LPCLSID)riid,xriid);
65    TRACE(shell,"(%p)->(\n\tIID:\t%s,%p)\n",this,xriid,ppvObj);
66
67   *ppvObj = NULL;
68
69   if(IsEqualIID(riid, &IID_IUnknown))          /*IUnknown*/
70   { *ppvObj = this; 
71   }
72   else if(IsEqualIID(riid, &IID_IExtractIcon))  /*IExtractIcon*/
73   {    *ppvObj = (IExtractIcon*)this;
74   }   
75
76   if(*ppvObj)
77   { (*(LPEXTRACTICON*)ppvObj)->lpvtbl->fnAddRef(this);          
78     TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
79     return S_OK;
80   }
81         TRACE(shell,"-- Interface: E_NOINTERFACE\n");
82         return E_NOINTERFACE;
83 }   
84
85 /**************************************************************************
86 *  IExtractIcon_AddRef
87 */
88 static ULONG WINAPI IExtractIcon_AddRef(LPEXTRACTICON this)
89 {       TRACE(shell,"(%p)->(count=%lu)\n",this,(this->ref)+1);
90
91         shell32_ObjCount++;
92
93         return ++(this->ref);
94 }
95 /**************************************************************************
96 *  IExtractIcon_Release
97 */
98 static ULONG WINAPI IExtractIcon_Release(LPEXTRACTICON this)
99 {       TRACE(shell,"(%p)->()\n",this);
100
101         shell32_ObjCount--;
102
103   if (!--(this->ref)) 
104   { TRACE(shell," destroying IExtractIcon(%p)\n",this);
105     SHFree(this->pidl);
106     HeapFree(GetProcessHeap(),0,this);
107     return 0;
108   }
109   return this->ref;
110 }
111 /**************************************************************************
112 *  IExtractIcon_GetIconLocation
113 */
114 static HRESULT WINAPI IExtractIcon_GetIconLocation(LPEXTRACTICON this, UINT32 uFlags, LPSTR szIconFile, UINT32 cchMax, int * piIndex, UINT32 * pwFlags)
115 {       WARN (shell,"(%p) (flags=%u file=%s max=%u %p %p) semi-stub\n", this, uFlags, szIconFile, cchMax, piIndex, pwFlags);
116
117         *piIndex = (int) SHMapPIDLToSystemImageListIndex(0, this->pidl,0);
118         *pwFlags = GIL_NOTFILENAME;
119
120         WARN (shell,"-- %x\n",*piIndex);
121
122         return NOERROR;
123 }
124 /**************************************************************************
125 *  IExtractIcon_Extract
126 */
127 static HRESULT WINAPI IExtractIcon_Extract(LPEXTRACTICON this, LPCSTR pszFile, UINT32 nIconIndex, HICON32 *phiconLarge, HICON32 *phiconSmall, UINT32 nIconSize)
128 { FIXME (shell,"(%p) (file=%s index=%u %p %p size=%u) semi-stub\n", this, pszFile, nIconIndex, phiconLarge, phiconSmall, nIconSize);
129   *phiconLarge = pImageList_GetIcon(ShellBigIconList, nIconIndex, ILD_TRANSPARENT);
130   *phiconSmall = pImageList_GetIcon(ShellSmallIconList, nIconIndex, ILD_TRANSPARENT);
131   return S_OK;
132 }
133