本文整理汇总了C++中OnKeyDown函数的典型用法代码示例。如果您正苦于以下问题:C++ OnKeyDown函数的具体用法?C++ OnKeyDown怎么用?C++ OnKeyDown使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OnKeyDown函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetCell
void XYGridControl::FinishEdit(const char* szText, int nValue, int nLastChar)
{
int nIndex = m_cellActive.m_nRow - 1;
// Change values in Grid
CGridCell* pCell = GetCell(m_cellActive.m_nRow, m_cellActive.m_nCol);
double val;
switch (m_cellActive.m_nCol) {
case 1: // X
if (!IsValidReal(szText, val))
{
val = nullReal;
}
if (nIndex < xyData.Size())
{
xyData[nIndex].x = val;
}
else
{
xyData.SetAtGrow(nIndex, XYItem(val, 0.0));
}
break;
case 2: // Y
if (!IsValidReal(szText, val))
{
val = nullReal;
}
if (nIndex < xyData.Size())
{
xyData[nIndex].y = val;
}
else
{
xyData.SetAtGrow(nIndex, XYItem(0.0, val));
}
break;
}
ResetCell(m_cellActive.m_nRow, m_cellActive.m_nCol);
StopEdit(false);
// if the right key continue editing on next cell
switch (nLastChar) {
case VK_TAB:
case VK_DOWN:
case VK_UP:
case VK_RIGHT:
case VK_LEFT:
case VK_NEXT:
case VK_PRIOR:
case VK_HOME:
case VK_END:
OnKeyDown(nLastChar, 0, 0);
UpdateWindow();
if (m_cellActive != m_cellActiveOld)
StartEdit(nLastChar);
break;
}
}
示例2: CanvasProc
// 캔버스 윈도우의 메시지 처리 함수
LRESULT CALLBACK CanvasProc(HWND hWnd,UINT iMessage,WPARAM wParam,LPARAM lParam)
{
switch(iMessage) {
case WM_CREATE:
return OnCreate(hWnd,wParam,lParam);
case WM_DESTROY:
return OnDestroy(hWnd,wParam,lParam);
case WM_PAINT:
return OnPaint(hWnd,wParam,lParam);
case WM_COMMAND:
return OnCommand(hWnd,wParam,lParam);
case WM_LBUTTONDOWN:
return OnLButtonDown(hWnd,wParam,lParam);
case WM_MOUSEMOVE:
return OnMouseMove(hWnd,wParam,lParam);
case WM_LBUTTONUP:
return OnLButtonUp(hWnd,wParam,lParam);
case WM_KEYDOWN:
return OnKeyDown(hWnd,wParam,lParam);
case WM_SETCURSOR:
return OnSetCursor(hWnd,wParam,lParam);
case WM_SIZE:
return OnSize(hWnd,wParam,lParam);
case WM_CONTEXTMENU:
return OnContextMenu(hWnd,wParam,lParam);
case WM_LBUTTONDBLCLK:
return OnLButtonDblclk(hWnd,wParam,lParam);
}
return(DefWindowProc(hWnd,iMessage,wParam,lParam));
}
示例3: lRet
LRESULT CDUIListBox::ProcessEvent(const DUIEvent& info, BOOL& bHandled)
{
LRESULT lRet(S_OK);
switch(info.dwEventType)
{
case DUI_EVENT_ELE_ITEM_CLICK:
OnItemClick(info);
bHandled = TRUE;
break;
case DUI_EVENT_ELE_ITEM_DBCLICK:
OnItemDBClick(info);
bHandled = TRUE;
break;
case DUI_EVENT_ELE_ITEM_MOUSEENTER:
case DUI_EVENT_ELE_ITEM_MOUSELEAVE:
OnItemHover(info);
bHandled = TRUE;
break;
case DUI_EVENT_KEYDOWN:
OnKeyDown(info);
bHandled = TRUE;
break;
default:
break;
}
if(bHandled) return lRet;
return theBase::ProcessEvent(info, bHandled);
}
示例4: while
void
COpenGLDemo::HandleEvents()
{
SDL_Event ev;
while ( SDL_PollEvent( &ev ))
{
switch( ev.type )
{
case SDL_QUIT:
OnQuit( ev.quit );
break;
case SDL_KEYDOWN:
OnKeyDown( ev.key );
break;
case SDL_KEYUP:
OnKeyUp( ev.key );
break;
case SDL_MOUSEMOTION:
OnMouseMotion( ev.motion );
break;
case SDL_MOUSEBUTTONUP:
OnMouseRelease( ev.button );
break;
case SDL_MOUSEBUTTONDOWN:
OnMousePress( ev.button );
break;
}
}
}
示例5: switch
LRESULT WindowImplBase::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
LRESULT lRes = 0;
BOOL bHandled = TRUE;
switch (uMsg)
{
case WM_CREATE: lRes = OnCreate(uMsg, wParam, lParam, bHandled); break;
case WM_CLOSE: lRes = OnClose(uMsg, wParam, lParam, bHandled); break;
case WM_DESTROY: lRes = OnDestroy(uMsg, wParam, lParam, bHandled); break;
#if defined(WIN32) && !defined(UNDER_CE)
case WM_NCACTIVATE: lRes = OnNcActivate(uMsg, wParam, lParam, bHandled); break;
case WM_NCCALCSIZE: lRes = OnNcCalcSize(uMsg, wParam, lParam, bHandled); break;
case WM_NCPAINT: lRes = OnNcPaint(uMsg, wParam, lParam, bHandled); break;
case WM_NCHITTEST: lRes = OnNcHitTest(uMsg, wParam, lParam, bHandled); break;
case WM_GETMINMAXINFO: lRes = OnGetMinMaxInfo(uMsg, wParam, lParam, bHandled); break;
case WM_MOUSEWHEEL: lRes = OnMouseWheel(uMsg, wParam, lParam, bHandled); break;
#endif
case WM_SIZE: lRes = OnSize(uMsg, wParam, lParam, bHandled); break;
case WM_SYSCOMMAND: lRes = OnSysCommand(uMsg, wParam, lParam, bHandled); break;
case WM_KEYDOWN: lRes = OnKeyDown(uMsg, wParam, lParam, bHandled); break;
case WM_KILLFOCUS: lRes = OnKillFocus(uMsg, wParam, lParam, bHandled); break;
case WM_SETFOCUS: lRes = OnSetFocus(uMsg, wParam, lParam, bHandled); break;
case WM_LBUTTONUP: lRes = OnLButtonUp(uMsg, wParam, lParam, bHandled); break;
case WM_LBUTTONDOWN: lRes = OnLButtonDown(uMsg, wParam, lParam, bHandled); break;
case WM_MOUSEMOVE: lRes = OnMouseMove(uMsg, wParam, lParam, bHandled); break;
default: bHandled = FALSE; break;
}
if (bHandled) return lRes;
lRes = HandleCustomMessage(uMsg, wParam, lParam, bHandled);
if (bHandled) return lRes;
if (paint_manager_.MessageHandler(uMsg, wParam, lParam, lRes)) return lRes;
return CWindowWnd::HandleMessage(uMsg, wParam, lParam);
}
示例6: WndProc
//窗口处理函数(自定义函数,处理消息)
LRESULT CALLBACK WndProc(HWND hWnd,
UINT msgID,
WPARAM wParam,
LPARAM lParam
){
switch(msgID)
{
case WM_CHAR:
OnChar(hWnd,wParam);
break;
case WM_PAINT:
OnPaint(hWnd);
break;
case WM_KEYDOWN:
OnKeyDown(hWnd,wParam);
break;
case WM_KEYUP:
OnKeyUp(hWnd,wParam);
break;
case WM_LBUTTONUP:
InvalidateRect(hWnd,NULL,true);
OnPaint(hWnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return DefWindowProc(hWnd,msgID,wParam,lParam);
}
示例7: switch
LRESULT RootWindow::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_CREATE:
return OnCreate();
case WM_MOUSEMOVE:
return OnMouseMove(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
case WM_NCDESTROY:
KillTimer(m_hwnd, ANIM_TIMER_ID);
// Death of the root window ends the thread
PostQuitMessage(0);
break;
case WM_SETFOCUS:
if (NULL != m_hwndChild)
SetFocus(m_hwndChild);
return 0;
case WM_TIMER:
OnTimer();
return 0;
case WM_KEYDOWN:
OnKeyDown(wParam, lParam);
return 0;
}
return super::HandleMessage(uMsg, wParam, lParam);
}
示例8: ProcessEvent
virtual bool ProcessEvent(wxEvent &event) {
bool handled = false;
if (event.GetEventType() == wxEVT_KEY_DOWN) {
handled = OnKeyDown((wxKeyEvent&)event);
}
return (handled || wxEvtHandler::ProcessEvent(event));
}
示例9: temp
void ProdRestartGridCtrl::FinishEdit(const char* szText, int nValue, int nLastChar)
{
int index = m_cellActive.m_nRow - 1;
UnitReal temp(productionRestartUnits, productionRestartTimes[index]);
if (temp.IsWithinRange(szText, -1.0E+08, 1.0E+08))
{
productionRestartTimes[index] = temp.GetMetricVal();
if (index > productionRestartTimes.UpperBound())
productionRestartTimes.SetSize(index + 1);
}
StopEdit(false);
UpdateAllRows();
// if the right key continue editing on next cell
switch (nLastChar) {
case VK_TAB:
case VK_DOWN:
case VK_UP:
case VK_RIGHT:
case VK_LEFT:
case VK_NEXT:
case VK_PRIOR:
case VK_HOME:
case VK_END:
OnKeyDown(nLastChar, 0, 0);
UpdateWindow();
if (m_cellActive != m_cellActiveOld)
StartEdit(nLastChar);
break;
}
}
示例10: switch
BOOL CPokeMiniEmulatorDlg::PreTranslateMessage(MSG* pMsg)
{
if (GS_NULL == pMsg)
{
return FALSE;
}
switch (pMsg->message)
{
case WM_KEYDOWN:
if (OnKeyDown(pMsg))
{
return TRUE;
}
break;
case WM_KEYUP:
if (OnKeyUp(pMsg))
{
return TRUE;
}
break;
default:
break;
}
return CDialogEx::PreTranslateMessage(pMsg);
}
示例11: dOnKeyDown
//==========================================================================
//
// 引擎捕捉键盘按下消息后,将调用到本函数
// 参数 iKey:被按下的键,值见 enum KeyCodes 宏定义
// 参数 iAltPress, iShiftPress,iCtrlPress:键盘上的功能键Alt,Ctrl,Shift当前是否也处于按下状态(0未按下,1按下)
//
void dOnKeyDown( const int iKey, const int iAltPress, const int iShiftPress, const int iCtrlPress )
{
// 可以在此添加游戏需要的响应函数
OnKeyDown(iKey, iAltPress, iShiftPress, iCtrlPress);
}
示例12: WndProc
//窗口处理函数
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg,
WPARAM wParam,LPARAM lParam)
{
switch(msg)
{
case WM_CHAR:
OnChar(hWnd,wParam);
break;
case WM_KEYDOWN:
OnKeyDown(hWnd,wParam);
break;
case WM_KEYUP:
OnKeyUp(hWnd,wParam);
break;
case WM_LBUTTONDOWN:
InvalidateRect(hWnd,NULL,TRUE);//想让PAINT消息出现就用这个函数
//但这个函数不会发送paint消息
break;
case WM_PAINT:
OnPaint(hWnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return DefWindowProc(hWnd,msg,wParam,lParam);
}
示例13: Keyboard
Keyboard(wxWindow *parent)
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxSize(0, kWhiteKeyHeight))
{
img_white_ = LoadImage(L"pianokey_white.png");
img_white_pushed_ = LoadImage(L"pianokey_white_pushed.png");
img_white_pushed_contiguous_ = LoadImage(L"pianokey_white_pushed_contiguous.png");
img_black_ = LoadImage(L"pianokey_black.png");
img_black_pushed_ = LoadImage(L"pianokey_black_pushed.png");
img_white_.Rescale(kKeyWidth, kWhiteKeyHeight);
img_white_pushed_.Rescale(kKeyWidth, kWhiteKeyHeight);
img_white_pushed_contiguous_.Rescale(kKeyWidth, kWhiteKeyHeight);
img_black_.Rescale(kKeyWidth+1, kBlackKeyHeight);
img_black_pushed_.Rescale(kKeyWidth+1, kBlackKeyHeight);
Bind(wxEVT_PAINT, [this](auto &ev) { OnPaint(); });
timer_.Bind(wxEVT_TIMER, [this](auto &ev) { OnTimer(); });
timer_.Start(50);
Bind(wxEVT_LEFT_DOWN, [this](auto &ev) { OnLeftDown(ev); });
Bind(wxEVT_LEFT_DCLICK, [this](auto &ev) { OnLeftDown(ev); });
Bind(wxEVT_LEFT_UP, [this](auto &ev) { OnLeftUp(ev); });
Bind(wxEVT_MOTION, [this](auto &ev) { OnMotion(ev); });
Bind(wxEVT_KEY_DOWN, [this](auto &ev) { OnKeyDown(ev); });
Bind(wxEVT_KEY_UP, [this](auto &ev) { OnKeyUp(ev); });
key_code_for_sample_note_.fill(0);
}
示例14: OnControlKeysChanged
void KeyboardReportParser::Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) {
// On error - return
if (buf[2] == 1)
return;
//KBDINFO *pki = (KBDINFO*)buf;
// provide event for changed control key state
if (prevState.bInfo[0x00] != buf[0x00]) {
OnControlKeysChanged(prevState.bInfo[0x00], buf[0x00]);
}
for (uint8_t i = 2; i < 8; i++) {
bool down = false;
bool up = false;
for (uint8_t j = 2; j < 8; j++) {
if (buf[i] == prevState.bInfo[j] && buf[i] != 1)
down = true;
if (buf[j] == prevState.bInfo[i] && prevState.bInfo[i] != 1)
up = true;
}
if (!down) {
HandleLockingKeys(hid, buf[i]);
OnKeyDown(*buf, buf[i]);
}
if (!up)
OnKeyUp(prevState.bInfo[0], prevState.bInfo[i]);
}
for (uint8_t i = 0; i < 8; i++)
prevState.bInfo[i] = buf[i];
};
示例15: handleLockingKeys
void KeyboardController::KeyboardEvent(bool press, int scode) {
uint8_t mod = 0, oemkey = 0;
unsigned char asciicode;
if (key[KEY_LCONTROL]) mod |= 0x01;
if (key[KEY_LSHIFT]) mod |= 0x02;
if (key[KEY_ALT]) mod |= 0x04;
if (key[KEY_LWIN]) mod |= 0x08;
if (key[KEY_RCONTROL]) mod |= 0x10;
if (key[KEY_RSHIFT]) mod |= 0x20;
if (key[KEY_ALTGR]) mod |= 0x40;
if (key[KEY_RWIN]) mod |= 0x80;
oemkey = scancodeMap[scode];
if(oemkey != 0x00) // pause is a special key, it occur one interuupt on pressing but not on releasing.
{
if(press)
{
handleLockingKeys(scode);
OnKeyDown(mod, oemkey);
}
else
{
OnKeyUp(mod, oemkey);
}
}
}