comctl32: toolbar: Make sure all TBUTTON_INFO fields are initialized when a button...
[wine] / dlls / dmband / dmband_main.c
1 /* DirectMusicBand Main
2  *
3  * Copyright (C) 2003-2004 Rok Mandeljc
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18  */
19
20 #include "dmband_private.h"
21
22 WINE_DEFAULT_DEBUG_CHANNEL(dmband);
23
24 LONG DMBAND_refCount = 0;
25
26 typedef struct {
27     const IClassFactoryVtbl *lpVtbl;
28 } IClassFactoryImpl;
29
30 /******************************************************************
31  *              DirectMusicBand ClassFactory
32  */
33  
34 static HRESULT WINAPI BandCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
35         FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
36
37         if (ppobj == NULL) return E_POINTER;
38         
39         return E_NOINTERFACE;
40 }
41
42 static ULONG WINAPI BandCF_AddRef(LPCLASSFACTORY iface) {
43         DMBAND_LockModule();
44
45         return 2; /* non-heap based object */
46 }
47
48 static ULONG WINAPI BandCF_Release(LPCLASSFACTORY iface) {
49         DMBAND_UnlockModule();
50
51         return 1; /* non-heap based object */
52 }
53
54 static HRESULT WINAPI BandCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
55         TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
56         
57         return DMUSIC_CreateDirectMusicBandImpl (riid, ppobj, pOuter);
58 }
59
60 static HRESULT WINAPI BandCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
61         TRACE("(%d)\n", dolock);
62
63         if (dolock)
64                 DMBAND_LockModule();
65         else
66                 DMBAND_UnlockModule();
67         
68         return S_OK;
69 }
70
71 static const IClassFactoryVtbl BandCF_Vtbl = {
72         BandCF_QueryInterface,
73         BandCF_AddRef,
74         BandCF_Release,
75         BandCF_CreateInstance,
76         BandCF_LockServer
77 };
78
79 static IClassFactoryImpl Band_CF = {&BandCF_Vtbl};
80
81
82 /******************************************************************
83  *              DirectMusicBandTrack ClassFactory
84  */
85  
86 static HRESULT WINAPI BandTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
87         FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
88         
89         if (ppobj == NULL) return E_POINTER;
90         
91         return E_NOINTERFACE;
92 }
93
94 static ULONG WINAPI BandTrackCF_AddRef(LPCLASSFACTORY iface) {
95         DMBAND_LockModule();
96
97         return 2; /* non-heap based object */
98 }
99
100 static ULONG WINAPI BandTrackCF_Release(LPCLASSFACTORY iface) {
101         DMBAND_UnlockModule();
102
103         return 1; /* non-heap based object */
104 }
105
106 static HRESULT WINAPI BandTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
107         TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
108         
109         return DMUSIC_CreateDirectMusicBandTrack (riid, ppobj, pOuter);
110 }
111
112 static HRESULT WINAPI BandTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
113         TRACE("(%d)\n", dolock);
114
115         if (dolock)
116                 DMBAND_LockModule();
117         else
118                 DMBAND_UnlockModule();
119         
120         return S_OK;
121 }
122
123 static const IClassFactoryVtbl BandTrackCF_Vtbl = {
124         BandTrackCF_QueryInterface,
125         BandTrackCF_AddRef,
126         BandTrackCF_Release,
127         BandTrackCF_CreateInstance,
128         BandTrackCF_LockServer
129 };
130
131 static IClassFactoryImpl BandTrack_CF = {&BandTrackCF_Vtbl};
132
133 /******************************************************************
134  *              DllMain
135  *
136  *
137  */
138 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
139         if (fdwReason == DLL_PROCESS_ATTACH) {
140             DisableThreadLibraryCalls(hinstDLL);
141                 /* FIXME: Initialisation */
142         } else if (fdwReason == DLL_PROCESS_DETACH) {
143                 /* FIXME: Cleanup */
144         }
145
146         return TRUE;
147 }
148
149
150 /******************************************************************
151  *              DllCanUnloadNow (DMBAND.@)
152  *
153  *
154  */
155 HRESULT WINAPI DllCanUnloadNow(void)
156 {
157         return DMBAND_refCount != 0 ? S_FALSE : S_OK;
158 }
159
160
161 /******************************************************************
162  *              DllGetClassObject (DMBAND.@)
163  *
164  *
165  */
166 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
167 {
168     TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
169
170         if (IsEqualCLSID (rclsid, &CLSID_DirectMusicBand) && IsEqualIID (riid, &IID_IClassFactory)) {
171                 *ppv = &Band_CF;
172                 IClassFactory_AddRef((IClassFactory*)*ppv);
173                 return S_OK;
174         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicBandTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
175                 *ppv = &BandTrack_CF;
176                 IClassFactory_AddRef((IClassFactory*)*ppv);
177                 return S_OK;    
178         }
179         
180     WARN("(%s, %s, %p): no interface found.\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
181     return CLASS_E_CLASSNOTAVAILABLE;
182 }