📄 input.hpp
字号:
//
// 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.
//
#pragma once
#ifndef __INPUT_HPP__
#define __INPUT_HPP__
#include <Windows.h>
namespace Input_t
{
enum HotKeyId_e
{
hkidStar = 0,
hkidPound,
};
enum IMEType_e
{
itMultitap = 0,
itMultitapUppercase,
itNum,
};
enum InputEvent_e
{
ieEditControlGainFocus = 0, //IPARAM = HWND that gained focus
ieEditControlLostFocus, //IPARAM = HWND that lost focus
ieWMSettingChanged, //IPARAM is the WPARAM received with WM_SETTINGCHANGE
ieInsertSymbol, //IPARAM is the WCHAR symbol to insert
ieChangeInputPanelStatus,//IPARAM is a BOOL indicating the new "sip should be showing" status
};
typedef void* IPARAM;
}
/*------------------------------------------------------------------------------
Input_Initialize
Allows the input library to initialize internal controls/state -
Returns: HRESULT indicating success or failure. FAILURE indicates the app
could not start properly and must shutdown
------------------------------------------------------------------------------*/
HRESULT
Input_Initialize(
__in RECT* pDefaultScreen
);
/*------------------------------------------------------------------------------
Input_Uninitialize
Allows the input library to uninitialize and cleanup any allocated memory/state
------------------------------------------------------------------------------*/
HRESULT
Input_Uninitialize(
void
);
EXTERN_C
{
/*------------------------------------------------------------------------------
Input_GetIMEType
Determines the currently active IME type
------------------------------------------------------------------------------*/
Input_t::IMEType_e
Input_GetIMEType(
void
);
/*------------------------------------------------------------------------------
Input_GetInputPanelTop
Gets the top position of current Input panel
Parameters:
event: The event that occurred
param: The IPARAM associated with that event
------------------------------------------------------------------------------*/
int
Input_GetInputPanelTop(
void
);
/*------------------------------------------------------------------------------
Input_HandleEvent
Indicates that there is an event the input library may want to handle -
return value is ignored
Parameters:
event: The event that occurred
param: The IPARAM associated with that event
------------------------------------------------------------------------------*/
HRESULT
Input_HandleEvent(
Input_t::InputEvent_e event,
Input_t::IPARAM param
);
/*------------------------------------------------------------------------------
Input_HideInputPanel
Force the input panel to hide any windows or controls that may be visible on the screen
------------------------------------------------------------------------------*/
HRESULT
Input_HideInputPanel(
void
);
/*------------------------------------------------------------------------------
Input_IsIMEEnabled
Determine whether the phone IME is enabled or not
------------------------------------------------------------------------------*/
BOOL
Input_IsIMEEnabled(
void
);
/*------------------------------------------------------------------------------
Input_IsInputPanelEnabled
Determine whether the Input panel is enabled or not
------------------------------------------------------------------------------*/
BOOL
Input_IsInputPanelEnabled(
);
/*------------------------------------------------------------------------------
Input_IsInputPanelVisible
Determine whether the Input panel is visible on the screen or not
------------------------------------------------------------------------------*/
BOOL
Input_IsInputPanelVisible(
void
);
/*------------------------------------------------------------------------------
Input_SetIMEType
Sets the active IME type
------------------------------------------------------------------------------*/
HRESULT
Input_SetIMEType(
Input_t::IMEType_e type
);
/*------------------------------------------------------------------------------
Input_SetInputMode
Allows a control to request a specific IME mode
Parameters:
Control: Handle to the control window to set IME mode for
InputMode: The requested new mode
------------------------------------------------------------------------------*/
HRESULT
Input_SetInputMode(
HWND Control,
DWORD InputMode
);
/*------------------------------------------------------------------------------
Input_ShouldDispatchHotkey
Handles a hotkey (KEYDOWN) event concerning * or # hotkeys. Input lib is free to
modify the value that will be dispatched (e.g. instead of # dispatch a
space character). Return value indicates whether the key should be dispatched
or eaten
Parameters:
id: the identifier of the hotkey that was just pressed
pCharacterToDispatch: OUT param - the value of the character to be dispatched
Returns (BOOL): TRUE if the outparam should be dispatched, FALSE otherwise
------------------------------------------------------------------------------*/
BOOL
Input_ShouldDispatchHotkey(
Input_t::HotKeyId_e id,
__out WCHAR* pCharacterToDispatch
);
/*------------------------------------------------------------------------------
Input_ShouldDispatchKey
Function that allows the library to eat a keydown event before the event is passed to
an edit control
Parameters:
VirtualKey: The virtual keycode of the key
Returns (BOOL): TRUE - the keycode can passthrough to the control,
FALSE - the keycode should be eaten
------------------------------------------------------------------------------*/
BOOL
Input_ShouldDispatchKey(
UINT VirtualKey
);
/*------------------------------------------------------------------------------
Input_ShowInputPanel
Force the input panel to show
------------------------------------------------------------------------------*/
HRESULT
Input_ShowInputPanel(
void
);
/*------------------------------------------------------------------------------
Input_ToggleInputPanel
Force the input panel to show
------------------------------------------------------------------------------*/
HRESULT
Input_ToggleInputPanel(
void
);
}
#endif // !defined __INPUT_HPP__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -