Skip to content

Commit

Permalink
CHtmlHelpを他実装に合わせる
Browse files Browse the repository at this point in the history
他のCDllImp派生クラスと実装が異なっていた。
HtmlHelpはwindows SDKに定義がある特殊な外部関数なので、
windows SDKの定義とCDllImp実装の両方の特性を活かせるように実装し直します。
  • Loading branch information
berryzplus committed Oct 13, 2018
1 parent bcb64af commit bdaaae5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 13 deletions.
21 changes: 12 additions & 9 deletions sakura_core/extmodule/CHtmlHelp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@
#include "StdAfx.h"
#include "CHtmlHelp.h"

CHtmlHelp::~CHtmlHelp(void)
{}
CHtmlHelp::CHtmlHelp(void) noexcept
: m_pfnHtmlHelp(nullptr)
{
}

/*!
HTML Help のファイル名を渡す
Expand All @@ -46,14 +48,15 @@ LPCTSTR CHtmlHelp::GetDllNameImp(int nIndex)

bool CHtmlHelp::InitDllImp()
{
if((HtmlHelp = (Proc_HtmlHelp)::GetProcAddress(GetInstance(),
#ifdef _UNICODE
"HtmlHelpW"
#else
"HtmlHelpA"
#endif
)) == NULL )
//DLL内関数名リスト
const ImportTable table[] = {
{ m_pfnHtmlHelp, "HtmlHelpW" },
{ NULL, 0 }
};

if (!RegisterEntries(table)) {
return false;
}

return true;
}
Expand Down
21 changes: 17 additions & 4 deletions sakura_core/extmodule/CHtmlHelp.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,25 @@
*/
class CHtmlHelp : public CDllImp {
public:
CHtmlHelp(){}
virtual ~CHtmlHelp();
CHtmlHelp() noexcept;
virtual ~CHtmlHelp() noexcept = default;

protected:
// HtmlHelp のEntry Point
typedef HWND (WINAPI* Proc_HtmlHelp)(HWND, LPCTSTR, UINT, DWORD_PTR);
Proc_HtmlHelp HtmlHelp;
typedef decltype(::HtmlHelp)* FnPtr_HtmlHelp;

FnPtr_HtmlHelp m_pfnHtmlHelp;

public:
inline HWND WINAPI HtmlHelp(
_In_opt_ HWND hwndCaller,
_In_ LPCWSTR pszFile,
_In_ UINT uCommand,
_In_ DWORD_PTR dwData
) const noexcept
{
return m_pfnHtmlHelp(hwndCaller, pszFile, uCommand, dwData);
}

protected:
virtual bool InitDllImp();
Expand Down

0 comments on commit bdaaae5

Please sign in to comment.