mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-10-12 02:18:12 +00:00
[idd] helper: add simple static widget implementation
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include <CDebug.h>
|
||||
#include <windowsx.h>
|
||||
#include <strsafe.h>
|
||||
#include "VersionInfo.h"
|
||||
|
||||
ATOM CConfigWindow::s_atom = 0;
|
||||
|
||||
@@ -24,6 +25,8 @@ CConfigWindow::CConfigWindow()
|
||||
{
|
||||
DEBUG_ERROR_HR(GetLastError(), "Failed to create window");
|
||||
}
|
||||
|
||||
m_version.reset(new CStaticWidget(L"Looking Glass IDD " LG_VERSION_STR, WS_CHILD | WS_VISIBLE | SS_CENTERIMAGE, m_hwnd));
|
||||
}
|
||||
|
||||
LRESULT CConfigWindow::handleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
|
@@ -1,11 +1,15 @@
|
||||
#pragma once
|
||||
#include "CWindow.h"
|
||||
#include "CStaticWidget.h"
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
class CConfigWindow : public CWindow
|
||||
{
|
||||
static ATOM s_atom;
|
||||
|
||||
std::unique_ptr<CStaticWidget> m_version;
|
||||
|
||||
std::function<void()> m_onDestroy;
|
||||
|
||||
virtual LRESULT handleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) override;
|
||||
|
15
idd/LGIddHelper/CStaticWidget.cpp
Normal file
15
idd/LGIddHelper/CStaticWidget.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#include "CStaticWidget.h"
|
||||
#include <commctrl.h>
|
||||
#include <CDebug.h>
|
||||
|
||||
CStaticWidget::CStaticWidget(LPCWSTR title, DWORD style, HWND parent)
|
||||
{
|
||||
m_hwnd = createWindowSimple(WC_STATIC, title, style, parent);
|
||||
if (!m_hwnd)
|
||||
DEBUG_ERROR_HR(GetLastError(), "Failed to create static widget");
|
||||
}
|
||||
|
||||
void CStaticWidget::setText(LPCWSTR text)
|
||||
{
|
||||
SetWindowText(m_hwnd, text);
|
||||
}
|
10
idd/LGIddHelper/CStaticWidget.h
Normal file
10
idd/LGIddHelper/CStaticWidget.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "CWidget.h"
|
||||
|
||||
class CStaticWidget : public CWidget
|
||||
{
|
||||
public:
|
||||
CStaticWidget(LPCWSTR title, DWORD style, HWND parent);
|
||||
void setText(LPCWSTR text);
|
||||
};
|
21
idd/LGIddHelper/CWidget.cpp
Normal file
21
idd/LGIddHelper/CWidget.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include "CWidget.h"
|
||||
|
||||
HWND CWidget::createWindowSimple(LPCWSTR cls, LPCWSTR title, DWORD style, HWND parent)
|
||||
{
|
||||
return CreateWindow(cls, title, style, 0, 0, 0, 0, parent,
|
||||
NULL, (HINSTANCE)GetModuleHandle(NULL), NULL);
|
||||
}
|
||||
|
||||
CWidget::~CWidget()
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
|
||||
void CWidget::destroy()
|
||||
{
|
||||
if (m_hwnd)
|
||||
{
|
||||
DestroyWindow(m_hwnd);
|
||||
m_hwnd = NULL;
|
||||
}
|
||||
}
|
18
idd/LGIddHelper/CWidget.h
Normal file
18
idd/LGIddHelper/CWidget.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
class CWidget {
|
||||
protected:
|
||||
HWND m_hwnd = NULL;
|
||||
|
||||
HWND createWindowSimple(LPCWSTR cls, LPCWSTR title, DWORD style, HWND parent);
|
||||
|
||||
public:
|
||||
virtual ~CWidget();
|
||||
void destroy();
|
||||
|
||||
HWND hwnd() { return m_hwnd; }
|
||||
operator HWND() { return m_hwnd; }
|
||||
};
|
@@ -180,6 +180,8 @@ copy /Y "$(ProjectDir)VERSION" "$(SolutionDir)$(Platform)\$(Configuration)\LGIdd
|
||||
<ClCompile Include="CConfigWindow.cpp" />
|
||||
<ClCompile Include="CNotifyWindow.cpp" />
|
||||
<ClCompile Include="CPipeClient.cpp" />
|
||||
<ClCompile Include="CStaticWidget.cpp" />
|
||||
<ClCompile Include="CWidget.cpp" />
|
||||
<ClCompile Include="CWindow.cpp" />
|
||||
<ClCompile Include="main.cpp" />
|
||||
</ItemGroup>
|
||||
@@ -188,6 +190,8 @@ copy /Y "$(ProjectDir)VERSION" "$(SolutionDir)$(Platform)\$(Configuration)\LGIdd
|
||||
<ClInclude Include="CConfigWindow.h" />
|
||||
<ClInclude Include="CNotifyWindow.h" />
|
||||
<ClInclude Include="CPipeClient.h" />
|
||||
<ClInclude Include="CStaticWidget.h" />
|
||||
<ClInclude Include="CWidget.h" />
|
||||
<ClInclude Include="CWindow.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
Reference in New Issue
Block a user