📄 settingsdialog.cpp
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
//
#include "SettingsApp.hpp"
#include "settingsDialog.hpp"
#include "Resource.h"
#include "ControlDefinitions.h"
#include "Controls.hpp"
#include <commctrl.h>
SettingsDialog_t::SettingsDialog_t()
{
m_DialogScreen = NULL;
m_HelpDialog = NULL;
}
SettingsDialog_t::~SettingsDialog_t()
{
if (m_DialogScreen)
{
DestroyWindow(m_DialogScreen);
}
if (m_HelpDialog)
{
DestroyWindow(m_HelpDialog);
}
}
HRESULT
SettingsDialog_t::CreateDialogScreen(
UINT statusHeader,
UINT title,
UINT menuId,
UINT id
)
{
PH_DIALOG_SCREEN_PARAMETERS DialogScreenParameters = {0};
DialogScreenParameters.StructSize = sizeof(DialogScreenParameters);
DialogScreenParameters.pDialogHook = SettingsDialog_t::s_HookProc;
DialogScreenParameters.pUserData = (VOID*)this;
DialogScreenParameters.Instance = GlobalData_t::s_ModuleInstance;
DialogScreenParameters.Flags = VDF_TYPE_MODELESS;
DialogScreenParameters.pStatusHeader = MAKEINTRESOURCE(statusHeader);
DialogScreenParameters.pTitle = MAKEINTRESOURCE(title);
DialogScreenParameters.MenuId = menuId;
DialogScreenParameters.Id = id;
if (!PHDialogScreen(&DialogScreenParameters))
{
ASSERT(FALSE);
return E_FAIL;
}
return S_OK;
}
HWND
SettingsDialog_t::GetDialog()
{
return m_DialogScreen;
}
BOOL
CALLBACK
SettingsDialog_t::s_HookProc(
HWND hwndDialog,
UINT uMsg,
WPARAM wParam,
LPARAM lParam,
VOID* pvData
)
{
if (! pvData)
{
return FALSE;
}
return reinterpret_cast<SettingsDialog_t*>(pvData)->HookProc(hwndDialog, uMsg, wParam, lParam);
}
BOOL
SettingsDialog_t::HookProc(
HWND hwndDialog,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
switch (uMsg)
{
case WM_INITDIALOG:
m_DialogScreen = hwndDialog;
if (FAILED(Initialize()))
{
DestroyWindow(hwndDialog);
}
return FALSE;
case WM_DESTROY:
delete this;
return FALSE;
case WM_COMMAND:
return SUCCEEDED(OnCommand(wParam));
case WM_HELP:
return SUCCEEDED(OnHelp());
case WM_NOTIFY:
switch(wParam)
{
case IDC_HELPMSG_OK:
DestroyWindow(m_HelpDialog);
m_HelpDialog = NULL;
return TRUE;
}
OnNotify(wParam, lParam);
return FALSE;
case WM_HOTKEY:
return SUCCEEDED(OnFunctionKey(lParam));
case WM_HSCROLL:
switch (LOWORD(wParam))
{
case TB_PAGEUP:
case TB_PAGEDOWN:
case TB_THUMBPOSITION:
return SUCCEEDED(OnChildControlUpdate());
}
return FALSE;
default:
return FALSE;
}
}
HRESULT
SettingsDialog_t::OnResetContent(
void
)
{
ListBox_t ListBox;
ListBox = GetDlgItem (m_DialogScreen, IDC_LISTBOX);
return SendMessage(ListBox, LB_RESETCONTENT, 0, 0);
}
HRESULT
SettingsDialog_t::OnHelp(
void
)
{
if (IsWindow(m_HelpDialog))
{
return E_FAIL;
}
PH_MESSAGE_BOX_PARAMETERS Params = {0};
Params.StructSize = sizeof(Params);
Params.Flags = VDF_TYPE_MODELESS;
Params.IconId = IDB_HELP_ICON;
Params.Instance = GlobalData_t::s_ModuleInstance;
Params.Owner = m_DialogScreen;
Params.MenuId = IDMB_MSGBOX_HELP;
Params.pTitle = CommonUtilities_t::LoadString(GlobalData_t::s_ModuleInstance, IDS_TITLE_HELP);
Params.pText = CommonUtilities_t::LoadString(
GlobalData_t::s_ModuleInstance,
GetHelpStringId()
);
if (! PHMessageBox(&Params))
{
ASSERT(FALSE);
return E_FAIL;
}
m_HelpDialog = Params.result.Dialog;
return S_OK;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -