Skip to content

Commit

Permalink
0.99
Browse files Browse the repository at this point in the history
  • Loading branch information
qbj196 committed Oct 20, 2020
1 parent 2708d1d commit 9376cac
Show file tree
Hide file tree
Showing 19 changed files with 941 additions and 207 deletions.
16 changes: 5 additions & 11 deletions ClassFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,13 @@ STDMETHODIMP_(ULONG) CClassFactory::AddRef()

STDMETHODIMP_(ULONG) CClassFactory::Release()
{
ULONG cRef;
ULONG cref;

cRef = InterlockedDecrement(&m_cRef);
if (cRef == 0)
{
cref = InterlockedDecrement(&m_cRef);
if (cref == 0)
delete this;
}

return cRef;
return cref;
}

//
Expand All @@ -67,7 +65,7 @@ STDMETHODIMP CClassFactory::CreateInstance(IUnknown *pUnkOuter, REFIID riid, voi
CDeskBand *pdb;

hr = CLASS_E_NOAGGREGATION;
pdb = NULL;
*ppvObject = NULL;

if (!pUnkOuter)
{
Expand All @@ -87,13 +85,9 @@ STDMETHODIMP CClassFactory::CreateInstance(IUnknown *pUnkOuter, REFIID riid, voi
STDMETHODIMP CClassFactory::LockServer(BOOL fLock)
{
if (fLock)
{
InterlockedIncrement(&g_cDllRef);
}
else
{
InterlockedDecrement(&g_cDllRef);
}

return S_OK;
}
1 change: 1 addition & 0 deletions ClassFactory.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <Windows.h>
#include <Unknwn.h>


class CClassFactory : public IClassFactory
Expand Down
56 changes: 21 additions & 35 deletions DeskBand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@


extern LONG g_cDllRef;
extern CLSID g_StartID;

DWORD g_dwBandID = 0;
extern CLSID CLSID_Start;


CDeskBand::CDeskBand()
{
m_cRef = 1;
m_fIsDirty = FALSE;
m_dwBandID = 0;
m_fCompositionEnabled = FALSE;

InterlockedIncrement(&g_cDllRef);
Expand Down Expand Up @@ -55,9 +53,7 @@ STDMETHODIMP CDeskBand::QueryInterface(REFIID riid, void **ppvObject)
}

if (*ppvObject)
{
AddRef();
}

return hr;
}
Expand All @@ -69,15 +65,13 @@ STDMETHODIMP_(ULONG) CDeskBand::AddRef()

STDMETHODIMP_(ULONG) CDeskBand::Release()
{
ULONG cRef;
ULONG cref;

cRef = InterlockedDecrement(&m_cRef);
if (cRef == 0)
{
cref = InterlockedDecrement(&m_cRef);
if (cref == 0)
delete this;
}

return cRef;
return cref;
}

//
Expand All @@ -100,6 +94,8 @@ STDMETHODIMP CDeskBand::ContextSensitiveHelp(BOOL fEnterMode)
//
STDMETHODIMP CDeskBand::ShowDW(BOOL fShow)
{
ShowStart(fShow, m_dwBandID);

return S_OK;
}

Expand All @@ -120,9 +116,9 @@ STDMETHODIMP CDeskBand::ResizeBorderDW(LPCRECT prcBorder, IUnknown *punkToolbarS
//
STDMETHODIMP CDeskBand::GetBandInfo(DWORD dwBandID, DWORD dwViewMode, DESKBANDINFO *pdbi)
{
g_dwBandID = dwBandID;
m_dwBandID = dwBandID;

return S_OK;
return E_NOTIMPL;
}

//
Expand All @@ -139,6 +135,8 @@ STDMETHODIMP CDeskBand::SetCompositionState(BOOL fCompositionEnabled)
{
m_fCompositionEnabled = fCompositionEnabled;

UpdateStart();

return S_OK;
}

Expand All @@ -154,7 +152,7 @@ STDMETHODIMP CDeskBand::GetCompositionState(BOOL *pfCompositionEnabled)
//
STDMETHODIMP CDeskBand::GetClassID(CLSID *pClassID)
{
*pClassID = g_StartID;
*pClassID = CLSID_Start;

return S_OK;
}
Expand All @@ -164,7 +162,7 @@ STDMETHODIMP CDeskBand::GetClassID(CLSID *pClassID)
//
STDMETHODIMP CDeskBand::IsDirty()
{
return m_fIsDirty ? S_OK : S_FALSE;
return S_FALSE;
}

STDMETHODIMP CDeskBand::Load(IStream *pStm)
Expand All @@ -174,11 +172,6 @@ STDMETHODIMP CDeskBand::Load(IStream *pStm)

STDMETHODIMP CDeskBand::Save(IStream *pStm, BOOL fClearDirty)
{
if (fClearDirty)
{
m_fIsDirty = FALSE;
}

return S_OK;
}

Expand All @@ -194,29 +187,22 @@ STDMETHODIMP CDeskBand::SetSite(IUnknown *pUnkSite)
{
HRESULT hr;
IOleWindow *pow;
HWND hWnd;
HWND hwnd;

hr = E_FAIL;
pow = NULL;
hWnd = NULL;

if (pUnkSite)
{
hr = pUnkSite->QueryInterface(IID_IOleWindow, reinterpret_cast<void **>(&pow));
hr = pUnkSite->QueryInterface(IID_IOleWindow,
reinterpret_cast<void **>(&pow));
if (SUCCEEDED(hr))
{
hr = pow->GetWindow(&hWnd);
hr = pow->GetWindow(&hwnd);
if (SUCCEEDED(hr))
{
hr = CreateStart(hWnd);
}
}
}
hr = CreateStart(hwnd);

if (pow)
{
pow->Release();
pow = NULL;
pow->Release();
}
}

return hr;
Expand Down
2 changes: 1 addition & 1 deletion DeskBand.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ class CDeskBand : public IDeskBand2, IPersistStream, IObjectWithSite
~CDeskBand();
private:
LONG m_cRef;
BOOL m_fIsDirty;
DWORD m_dwBandID;
BOOL m_fCompositionEnabled;
};
Loading

0 comments on commit 9376cac

Please sign in to comment.